From c28fa88a80405f170916abf22ed67b8f125859b8 Mon Sep 17 00:00:00 2001 From: Alex Santos Date: Tue, 28 Jun 2022 11:31:28 -0300 Subject: [PATCH 1/6] update --- src/components/administrativeTables/TableView.ts | 6 +++--- src/components/buttons/loginButton/LoginButtonView.ts | 2 +- src/pages/forgotPassword.tsx | 1 + src/pages/index.tsx | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/administrativeTables/TableView.ts b/src/components/administrativeTables/TableView.ts index e0fadf3..0f6b52e 100644 --- a/src/components/administrativeTables/TableView.ts +++ b/src/components/administrativeTables/TableView.ts @@ -20,7 +20,7 @@ export const TableView = styled.main` border-radius: 16px; tr { th { - font-family: 'poppins'; + font-family: 'Poppins'; font-weight: 500; font-size: 16px; color: #6A707E; @@ -28,13 +28,13 @@ export const TableView = styled.main` td { :nth-child(3) { - font-family: 'poppins'; + font-family: 'Poppins'; font-weight: 500; font-size: 16px; color: #6A707E; } :nth-child(4) { - font-family: 'poppins'; + font-family: 'Poppins'; font-weight: 400; font-size: 12px; color: #828282; diff --git a/src/components/buttons/loginButton/LoginButtonView.ts b/src/components/buttons/loginButton/LoginButtonView.ts index f91b815..69553a0 100644 --- a/src/components/buttons/loginButton/LoginButtonView.ts +++ b/src/components/buttons/loginButton/LoginButtonView.ts @@ -11,7 +11,7 @@ export const LoginButtonView = styled.button` background: rgb(2,0,36); background: linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(37,79,127,1) 35%, rgba(136,136,136,1) 100%); - font-family: 'Nunito Sans'; + font-family: 'Poppins'; font-weight: 700; font-size: calc(99.98% + 10px); line-height: 44px; diff --git a/src/pages/forgotPassword.tsx b/src/pages/forgotPassword.tsx index db8c81a..0703298 100644 --- a/src/pages/forgotPassword.tsx +++ b/src/pages/forgotPassword.tsx @@ -64,3 +64,4 @@ export default function ForgotPassword() { ) } + diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 09dd6e2..45a8cfd 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -91,8 +91,8 @@ export default function Home() { useEffect(() => { setValues({ - password: null, - showPassword: false, + password: (''), + showPassword: null, }); setEmail("") }, [rota]) From a3407db07c26008c1e65cd605000217d383238c8 Mon Sep 17 00:00:00 2001 From: joseCorte-exe Date: Tue, 28 Jun 2022 12:12:47 -0300 Subject: [PATCH 2/6] add loading at telemetry charts --- src/components/graph/SingleBar.tsx | 2 +- src/pages/chartTelemetry.tsx | 178 ++++++++++-------- src/pages/news.tsx | 7 +- src/styles/Home.module.css | 103 ---------- .../ChatTelemetry/ChatTelemetryView.ts | 43 ++++- src/styles/layouts/news/NewsView.ts | 14 ++ 6 files changed, 158 insertions(+), 189 deletions(-) diff --git a/src/components/graph/SingleBar.tsx b/src/components/graph/SingleBar.tsx index da7c3f9..5875681 100644 --- a/src/components/graph/SingleBar.tsx +++ b/src/components/graph/SingleBar.tsx @@ -56,7 +56,7 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, barLabel offset: -40, align: "start", font: { - size: 10 + size: 12 } }, legend: { diff --git a/src/pages/chartTelemetry.tsx b/src/pages/chartTelemetry.tsx index a3fc940..b183829 100644 --- a/src/pages/chartTelemetry.tsx +++ b/src/pages/chartTelemetry.tsx @@ -53,10 +53,10 @@ export default function chartTelemetry({userName}) { const [openDemandaContratada, setOpenDemandaContratada] = useState(false); const handleCloseDemandaContratada = () => setOpenDemandaContratada(false); - const [fatorPotenciaData, setFatorPotenciaData] = useState([]); - const [demRegXDemCon, setDemRegXDemCon] = useState([]); - const [discretizedConsumptionData, setDiscretizedConsumptionData] = useState([]); - const [discretizedConsumptionDataReativa, setDiscretizedConsumptionDataReativa] = useState([]); + const [fatorPotenciaData, setFatorPotenciaData] = useState(null); + const [demRegXDemCon, setDemRegXDemCon] = useState(null); + const [discretizedConsumptionData, setDiscretizedConsumptionData] = useState(null); + const [discretizedConsumptionDataReativa, setDiscretizedConsumptionDataReativa] = useState(null); const { ['user-cod_client']: cod_client } = parseCookies() @@ -77,29 +77,6 @@ export default function chartTelemetry({userName}) { console.log(res) }) - await api.post('/telemetry/demand', { - "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, - {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} - ] - }).then(res => { - setDemRegXDemCon(res.data.data) - }).catch(res => { - console.log(res) - }) - - await api.post('/telemetry/discretization', { - "type": "5_min", - "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, - {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} - ] - }).then(res => { - setDiscretizedConsumptionData(res.data.data) - }).catch(res => { - console.log(res) - }) - await api.post('/telemetry/discretization', { "type": "5_min", "filters": [ @@ -111,10 +88,36 @@ export default function chartTelemetry({userName}) { }).catch(res => { console.log(res) }) + + await api.post('/telemetry/discretization', { + "type": "5_min", + "filters": [ + {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} + ] + }).then(res => { + setDiscretizedConsumptionData(res.data.data) + }).catch(res => { + console.log(res) + }) + + await api.post('/telemetry/demand', { + "filters": [ + {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} + ] + }).then(res => { + setDemRegXDemCon(res.data.data) + }).catch(res => { + console.log(res) + }) } + + useEffect(() => { getChartsData() + console.log(fatorPotenciaData) }, []) return ( @@ -125,62 +128,77 @@ export default function chartTelemetry({userName}) {
-
setOpenFatorPotencia(true)}> - value.hora)} /> -
- - - - - + { + demRegXDemCon==null? +
+ + + + + +
+ : + <> +
setOpenFatorPotencia(true)}> + +
+ + + + + -
setOpenConsumoDiscretizado1(true)}> - parseFloat(data.reativa).toFixed(3))} /> -
- - - data.reativa)} /> - - +
setOpenConsumoDiscretizado1(true)}> + parseFloat(data.reativa).toFixed(3))} /> +
+ + + data.reativa)} /> + + -
setOpenConsumoDiscretizado2(true)}> - value.minut)} dataset={'Consumo'} dataset1='Estimado' month/> -
- - - - - +
setOpenConsumoDiscretizado2(true)}> + value.minut)} dataset={'Consumo'} dataset1='Estimado' month/> +
+ + + value.minut)} dataset={'Consumo'} dataset1='Estimado' month/> + + -
setOpenDemandaContratada(true)}> - value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/> -
- - - value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/> - - -
+
setOpenDemandaContratada(true)}> + value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/> +
+ + + value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/> + + + + } + ) } diff --git a/src/pages/news.tsx b/src/pages/news.tsx index b436af2..4882be4 100644 --- a/src/pages/news.tsx +++ b/src/pages/news.tsx @@ -2,6 +2,7 @@ import axios from 'axios'; import { GetServerSideProps } from 'next'; import Head from 'next/head'; import Link from 'next/link' +import { Router } from 'next/router'; import { parseCookies } from 'nookies'; import React from 'react' @@ -27,17 +28,17 @@ export default function aboutUs({userName, news}: any) { return <>
-

+

ANEEL APROVA REAJUSTE TARIFÁRIO ANUAL DA ENERGISA SERGIPE DE 16,46 % PARA O CONSUMIDOR RESIDENCIAL

{ -

+

}

diff --git a/src/styles/Home.module.css b/src/styles/Home.module.css index fbaf78e..567de43 100644 --- a/src/styles/Home.module.css +++ b/src/styles/Home.module.css @@ -19,106 +19,3 @@ align-items: center; font-family: 'Poppins'; } - -.footer { - display: flex; - flex: 1; - padding: 2rem 0; - border-top: 1px solid #eaeaea; - justify-content: center; - align-items: center; -} - -.footer a { - display: flex; - justify-content: center; - align-items: center; - flex-grow: 1; -} - -.title a { - color: #0070f3; - text-decoration: none; -} - -.title a:hover, -.title a:focus, -.title a:active { - text-decoration: underline; -} - -.title { - margin: 0; - line-height: 1.15; - font-size: 4rem; -} - -.title, -.description { - text-align: center; -} - -.description { - margin: 4rem 0; - line-height: 1.5; - font-size: 1.5rem; -} - -.code { - background: #fafafa; - border-radius: 5px; - padding: 0.75rem; - font-size: 1.1rem; - font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, - Bitstream Vera Sans Mono, Courier New, monospace; -} - -.grid { - display: flex; - align-items: center; - justify-content: center; - flex-wrap: wrap; - max-width: 800px; -} - -.card { - margin: 1rem; - padding: 1.5rem; - text-align: left; - color: inherit; - text-decoration: none; - border: 1px solid #eaeaea; - border-radius: 10px; - transition: color 0.15s ease, border-color 0.15s ease; - max-width: 300px; -} - -.card:hover, -.card:focus, -.card:active { - color: #0070f3; - border-color: #0070f3; -} - -.card h2 { - margin: 0 0 1rem 0; - font-size: 1.5rem; -} - -.card p { - margin: 0; - font-size: 1.25rem; - line-height: 1.5; -} - -.logo { - height: 1em; - margin-left: 0.5rem; -} - -@media (max-width: 600px) { - .grid { - width: 100%; - flex-direction: column; - } -} diff --git a/src/styles/layouts/ChatTelemetry/ChatTelemetryView.ts b/src/styles/layouts/ChatTelemetry/ChatTelemetryView.ts index 15f757f..06d922b 100644 --- a/src/styles/layouts/ChatTelemetry/ChatTelemetryView.ts +++ b/src/styles/layouts/ChatTelemetry/ChatTelemetryView.ts @@ -2,14 +2,14 @@ import styled from "styled-components"; export const ChatTelemetryView = styled.main` display: flex; - justify-content: center; + justify-content: flex-start; align-items: center; flex-direction: column; width: 100%; - padding-top: 0px!important; + padding-top: 40px!important; .chartContainer { display: flex; @@ -18,4 +18,43 @@ export const ChatTelemetryView = styled.main` width: 100%; } + + #preloader_1{ + position:absolute; + top: 50%; + left: 50%; + } + #preloader_1 span{ + display:block; + bottom:0px; + width: 9px; + height: 5px; + background:#9b59b6; + position:absolute; + animation: preloader_1 1.5s infinite ease-in-out; + } + + #preloader_1 span:nth-child(2){ + left:11px; + animation-delay: .2s; + + } + #preloader_1 span:nth-child(3){ + left:22px; + animation-delay: .4s; + } + #preloader_1 span:nth-child(4){ + left:33px; + animation-delay: .6s; + } + #preloader_1 span:nth-child(5){ + left:44px; + animation-delay: .8s; + } + @keyframes preloader_1 { + 0% {height:5px;transform:translateY(0px);background:rgb(1,138,138);} + 25% {height:30px;transform:translateY(15px);background:#254F7F;} + 50% {height:5px;transform:translateY(0px);background:rgb(231,153,47);} + 100% {height:5px;transform:translateY(0px);background:rgb(1,138,138);} + } ` diff --git a/src/styles/layouts/news/NewsView.ts b/src/styles/layouts/news/NewsView.ts index 992fc0b..ce39590 100644 --- a/src/styles/layouts/news/NewsView.ts +++ b/src/styles/layouts/news/NewsView.ts @@ -5,6 +5,20 @@ export const NewsView = styled.main` margin-bottom: 100px; + .description { + a { + display: none; + } + p { + :last-child { + display: none; + } + } + .read-more { + display: none; + } + } + p { font-family: 'Poppins'; font-style: normal; From 9fd2da24dbedc30b59be258649aa7e8fa7c56374 Mon Sep 17 00:00:00 2001 From: joseCorte-exe Date: Tue, 28 Jun 2022 12:19:35 -0300 Subject: [PATCH 3/6] add month on resumo operacao table --- src/pages/resumoOperacao.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/resumoOperacao.tsx b/src/pages/resumoOperacao.tsx index 93c0238..70a8238 100644 --- a/src/pages/resumoOperacao.tsx +++ b/src/pages/resumoOperacao.tsx @@ -96,6 +96,8 @@ export default function ResumoOperacao({tableData, clientsData, userName, client setTableDataState(tableData) } + console.log(tableData) + console.log(month) }, [month, unidade]) @@ -148,6 +150,7 @@ export default function ResumoOperacao({tableData, clientsData, userName, client + @@ -161,6 +164,7 @@ export default function ResumoOperacao({tableData, clientsData, userName, client tableDataState.map((value, index) => { return <> + From 843da7c9333430663bf5002c9982df1b66c6ac36 Mon Sep 17 00:00:00 2001 From: Alex Santos Date: Tue, 28 Jun 2022 16:16:04 -0300 Subject: [PATCH 4/6] =?UTF-8?q?=1B[200~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../administrative/industryInfo/index.tsx | 6 +++--- src/pages/resumoOperacao.tsx | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/pages/administrative/industryInfo/index.tsx b/src/pages/administrative/industryInfo/index.tsx index 432fe3d..54b7a39 100644 --- a/src/pages/administrative/industryInfo/index.tsx +++ b/src/pages/administrative/industryInfo/index.tsx @@ -8,7 +8,7 @@ import PageTitle from '../../../components/pageTitle/PageTitle' import { IndustryInfoView } from '../../../styles/layouts/industryInfo/IndustryInfoView' import InputUploadPdf from '../../../components/inputUploadPdf/inputUpload'; import { api } from '../../../services/api' -import PdfThumbnail from 'react-pdf-thumbnail'; +// import PdfThumbnail from 'react-pdf-thumbnail'; import FormData from 'form-data'; @@ -58,12 +58,12 @@ export default function industryInfo({userName}: any) { - PDF Baixado com Sucesso! + PDF enviado com Sucesso! - PDF não baixado! + Falha ao enviar PDF! diff --git a/src/pages/resumoOperacao.tsx b/src/pages/resumoOperacao.tsx index 93c0238..a144c82 100644 --- a/src/pages/resumoOperacao.tsx +++ b/src/pages/resumoOperacao.tsx @@ -36,8 +36,24 @@ export default function ResumoOperacao({tableData, clientsData, userName, client setUnidade(event.target.value); }; + function stringToBytes(text) { + const length = text.length; + const result = new Uint8Array(length); + for (let i = 0; i < length; i++) { + const code = text.charCodeAt(i); + const byte = code > 255 ? 32 : code; + result[i] = byte; + } + return result; + } + + // const originalString = 'ååå'; + // const bytes = stringToBytes(originalString); + // const blob = new Blob([bytes.buffer], { type: 'text/plain; charset=ISO-8859-1' }); + function downloadCSVFile(csv, filename) { - const csv_file = new Blob([csv], {type: "text/csv"}); + + const csv_file = new Blob(["\ufeff",csv], {type: "text/csv"}); const download_link = document.createElement("a"); @@ -63,7 +79,8 @@ export default function ResumoOperacao({tableData, clientsData, userName, client row.push(cols[j].innerText); } - data.push(row.join(",")); + + data.push(row.join(";")); } downloadCSVFile(data.join("\n"), filename); From a9fd40162c4375ff57a79bff4de7c5481bd0488a Mon Sep 17 00:00:00 2001 From: joseCorte-exe Date: Tue, 28 Jun 2022 16:36:54 -0300 Subject: [PATCH 5/6] fix telemetria --- .../buttons/gradientButton/GradientButton.tsx | 8 +- src/components/header/Header.tsx | 2 +- src/components/header/HeaderView.ts | 2 + src/pages/chartTelemetry.tsx | 14 +- src/pages/resumoOperacao.tsx | 4 - src/pages/telemetria.tsx | 241 ++++++++++++++++-- .../ChatTelemetry/ChatTelemetryView.ts | 2 +- .../layouts/Telemetria/TelemetriaView.ts | 210 ++++++++++++++- 8 files changed, 445 insertions(+), 38 deletions(-) diff --git a/src/components/buttons/gradientButton/GradientButton.tsx b/src/components/buttons/gradientButton/GradientButton.tsx index 78d9c53..8873d16 100644 --- a/src/components/buttons/gradientButton/GradientButton.tsx +++ b/src/components/buttons/gradientButton/GradientButton.tsx @@ -15,12 +15,12 @@ interface GradientButtonInterface { } export default function GradientButton({ title, description, orange, purple, green, onClick }: GradientButtonInterface) { - // function handleClick() { - // onClick() - // } + function handleClick() { + onClick() + } return ( - + handleClick()}>

{title}

{description}

diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index 927ae07..0023023 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -29,7 +29,7 @@ export default function Header({name, admin}: headerInterface) { !admin && profile_picture? : - null + } ) diff --git a/src/components/header/HeaderView.ts b/src/components/header/HeaderView.ts index bdeeb85..cff6ebb 100644 --- a/src/components/header/HeaderView.ts +++ b/src/components/header/HeaderView.ts @@ -6,6 +6,8 @@ export const HeaderView = styled.header` width: 100%; + margin-bottom: 40px; + .icon { display: flex; align-items: center; diff --git a/src/pages/chartTelemetry.tsx b/src/pages/chartTelemetry.tsx index b183829..4c833ed 100644 --- a/src/pages/chartTelemetry.tsx +++ b/src/pages/chartTelemetry.tsx @@ -62,13 +62,13 @@ export default function chartTelemetry({userName}) { const router = useRouter() - const {startDate, endDate} = router.query + const {startDate, endDate, unity, discretization} = router.query async function getChartsData() { console.log(router.query) await api.post('/telemetry/powerFactor', { "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "=", "field": discretization, "value": unity}, {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} ] }).then(res => { @@ -80,8 +80,8 @@ export default function chartTelemetry({userName}) { await api.post('/telemetry/discretization', { "type": "5_min", "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, - {"type" : "between", "field": "dia_num", "value": ["2022-01-03", "2022-01-03"]} + {"type" : "=", "field": discretization, "value": unity}, + {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} ] }).then(res => { setDiscretizedConsumptionDataReativa(res.data.data) @@ -92,7 +92,7 @@ export default function chartTelemetry({userName}) { await api.post('/telemetry/discretization', { "type": "5_min", "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "=", "field": discretization, "value": unity}, {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} ] }).then(res => { @@ -103,7 +103,7 @@ export default function chartTelemetry({userName}) { await api.post('/telemetry/demand', { "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "=", "field": discretization, "value": unity}, {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} ] }).then(res => { @@ -113,8 +113,6 @@ export default function chartTelemetry({userName}) { }) } - - useEffect(() => { getChartsData() console.log(fatorPotenciaData) diff --git a/src/pages/resumoOperacao.tsx b/src/pages/resumoOperacao.tsx index 70a8238..e6333a2 100644 --- a/src/pages/resumoOperacao.tsx +++ b/src/pages/resumoOperacao.tsx @@ -95,10 +95,6 @@ export default function ResumoOperacao({tableData, clientsData, userName, client } else { setTableDataState(tableData) } - - console.log(tableData) - - console.log(month) }, [month, unidade]) return ( diff --git a/src/pages/telemetria.tsx b/src/pages/telemetria.tsx index 707ca85..ffc2c5a 100644 --- a/src/pages/telemetria.tsx +++ b/src/pages/telemetria.tsx @@ -1,5 +1,4 @@ -import React, { useState } from 'react'; -import router, { useRouter } from 'next/router' +import React, { useEffect, useState } from 'react'; import Banner from '../components/banner/Banner'; import { TelemetriaView, Buttons} from '../styles/layouts/Telemetria/TelemetriaView'; @@ -17,26 +16,154 @@ import { FatorPotencia } from '../services/fatorPotencia'; import RenderIf from '../utils/renderIf'; import { GetServerSideProps } from 'next'; import { parseCookies } from 'nookies'; +import { api } from '../services/api'; +import Snackbar from '@mui/material/Snackbar' +import MuiAlert, { AlertProps } from '@mui/material/Alert' +import getAPIClient from '../services/ssrApi'; -export default function Telemetria({userName}: any) { +const style = { + position: 'absolute' as const, + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: 400, + bgcolor: 'background.paper', + border: '2px solid #000', + boxShadow: 24, + p: 4, +}; + +const Alert = React.forwardRef(function Alert( + props, + ref +) { + return +}) + +export default function Telemetria({userName, clients}: any) { const [unity, setUnity] = useState(''); const [startDate, setStartDate] = useState(''); const [endDate, setEndDate] = useState(''); const [discretization, setDiscretization] = useState(''); + const [openSnackSuccess, setOpenSnackSuccess] = useState(false) + const [openSnackError, setOpenSnackError] = useState(false) + const handleCloseSnack = ( + event?: React.SyntheticEvent | Event, + reason?: string + ) => { + if (reason === 'clickaway') { + return + } + + setOpenSnackError(false) + setOpenSnackSuccess(false) + } + + function downloadCSVFile(csv, filename) { + const csv_file = new Blob([csv], {type: "text/csv"}); + + const download_link = document.createElement("a"); + + download_link.download = filename; + + download_link.href = window.URL.createObjectURL(csv_file); + + download_link.style.display = "none"; + + document.body.appendChild(download_link); + + download_link.click(); + } + + function htmlToCSV(html, filename) { + const data = []; + const rows = document.querySelectorAll("table tr"); + + for (let i = 0; i < rows.length; i++) { + const row = [], cols: any = rows[i].querySelectorAll("td, th"); + + for (let j = 0; j < cols.length; j++) { + row.push(cols[j].innerText); + } + + data.push(row.join(",")); + } + + downloadCSVFile(data.join("\n"), filename); + } + + const [tableData, setTableData] = useState(null) + const [date, setDate] = useState(''); const [showChart, setShowChart] = useState(false); - const handleChange = (event: SelectChangeEvent) => { - // setAge(event.target.value); - }; + const [exception, setException] = useState(false); + const [send, setSend] = useState(false); + + const [open, setOpen] = useState(false); + + async function getTableData() { + if (startDate!=='' && endDate!=='' && send) + setOpen(true) + await api.post('/telemetry/powerFactor', { + "type": "15_min", + "filters": [ + {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "between", "field": "dia_num", "value": ["2022-01-03", "2022-01-03"]} + ] + }).then(res => { + setTableData(res.data.data) + setOpenSnackError(false) + setOpenSnackSuccess(true) + setOpen(false) + }).catch(res => { + setException(true) + setSend(false) + setOpenSnackError(true) + setOpenSnackSuccess(false) + console.log(res) + }) + } + + useEffect(() => { + setSend(false) + }, [startDate, endDate]) + return( Smart Energia - Telemetria + + + Dados coletados com sucesso com Sucesso! + + + + + Não foi possivel pegar os dados! + + +

Data inicial

- setStartDate(value.target.value)}/> + setStartDate(value.target.value)} onSelect={value => console.log(value)}/>
-

Data final

- +

Data final

setEndDate(value.target.value)}/>
@@ -95,11 +222,66 @@ export default function Telemetria({userName}: any) { Nenhum + 5 minutos + 15 minutos + 1 hora + 1 dia + + +
+
+ + + + + +
+
+
+ +
Mês Unidade Operação Montante (MWh)
{value.mes} {value.cod_smart_unidade} {value.operacao} {parseFloat(value.montante_nf).toLocaleString('pt-br')}
+ + + + + + + + + + + + + { + tableData!==null? + tableData?.map((value, index) => { + return <> + + + + + + + + + + + }) + : + null + } + +
PontoNumero do diaDia formatadoHoraMinutoConsumoReativa
{value.ponto}{parseFloat(value.dia_num)}{value.day_formatted}{value.hora}{value.minut}{parseFloat(value.consumo).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})}{parseFloat(value.reativa).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})}
+ + @@ -110,17 +292,20 @@ export default function Telemetria({userName}: any) { query: { startDate, endDate, - discretization + discretization: discretization==='5_min'? 'med_5min.ponto' : discretization==='15_min'? '15min.ponto' : discretization==='1_hora'? 'med_1hora.ponto' : discretization==='1_dia'? 'med_1dia.ponto' : 'med_5min.ponto', + unity }, }} > - {/* */} - {/* router.replace('/chartTelemetry')}/> */} - + { + const html = document.querySelector("table").outerHTML; + htmlToCSV(html, "telemetria.csv"); + console.log('clicando') + }}/> setShowChart(!showChart)} green />

@@ -132,6 +317,7 @@ export default function Telemetria({userName}: any) { medição - Distribuidora.

+ ) } @@ -139,6 +325,22 @@ export default function Telemetria({userName}: any) { export const getServerSideProps: GetServerSideProps = async (ctx) => { const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) + const { ['user-client_id']: id } = parseCookies(ctx) + const apiClient = getAPIClient(ctx) + + let clients = [] + + await apiClient.post('/units', { + "filters": [ + {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": id} + ], + "fields": ["cod_smart_unidade", "codigo_scde"], + "distinct": true + }).then(res => { + clients = res.data.data + }).catch(res => { + console.log(res) + }) if (!token) { return { @@ -151,7 +353,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { return { props: { - userName + userName, + clients } } } diff --git a/src/styles/layouts/ChatTelemetry/ChatTelemetryView.ts b/src/styles/layouts/ChatTelemetry/ChatTelemetryView.ts index 06d922b..f1f9414 100644 --- a/src/styles/layouts/ChatTelemetry/ChatTelemetryView.ts +++ b/src/styles/layouts/ChatTelemetry/ChatTelemetryView.ts @@ -29,7 +29,7 @@ export const ChatTelemetryView = styled.main` bottom:0px; width: 9px; height: 5px; - background:#9b59b6; + background:#254F7F; position:absolute; animation: preloader_1 1.5s infinite ease-in-out; } diff --git a/src/styles/layouts/Telemetria/TelemetriaView.ts b/src/styles/layouts/Telemetria/TelemetriaView.ts index 77238d0..34266df 100644 --- a/src/styles/layouts/Telemetria/TelemetriaView.ts +++ b/src/styles/layouts/Telemetria/TelemetriaView.ts @@ -1,9 +1,67 @@ import styled from 'styled-components'; export const TelemetriaView = styled.main` - padding: 20px ; + padding: 20px; width: 100%; + .modal { + position: absolute; + + background: rgba( 255, 255, 255, 0.25 ); + box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37 ); + backdrop-filter: blur( 4px ); + -webkit-backdrop-filter: blur( 4px ); + border-radius: 10px; + border: 1px solid rgba( 255, 255, 255, 0.18 ); + + top: 0; + left: 0; + + width: 100%; + height: 100vh; + + z-index: 999; + } + + #preloader_1{ + position:absolute; + top: 50%; + left: 50%; + } + #preloader_1 span{ + display:block; + bottom:0px; + width: 9px; + height: 5px; + background:#254F7F; + position:absolute; + animation: preloader_1 1.5s infinite ease-in-out; + } + + #preloader_1 span:nth-child(2){ + left:11px; + animation-delay: .2s; + + } + #preloader_1 span:nth-child(3){ + left:22px; + animation-delay: .4s; + } + #preloader_1 span:nth-child(4){ + left:33px; + animation-delay: .6s; + } + #preloader_1 span:nth-child(5){ + left:44px; + animation-delay: .8s; + } + @keyframes preloader_1 { + 0% {height:5px;transform:translateY(0px);background:rgb(1,138,138);} + 25% {height:30px;transform:translateY(15px);background:#254F7F;} + 50% {height:5px;transform:translateY(0px);background:rgb(231,153,47);} + 100% {height:5px;transform:translateY(0px);background:rgb(1,138,138);} + } + .title { color: black; font-weight: 600; @@ -12,6 +70,105 @@ export const TelemetriaView = styled.main` margin: 0 0 0 10px; } + .sendButton { + width: 60px; + height: 40px; + + background:#254F7F; + color: white; + + border: none; + border-radius: 8px; + + font-family: 'Poppins'; + font-size: 14px; + + color: #FFFFFF; + + margin-top: 20px; + } + + table { + display: none; + } + + .tg{ + border-collapse:collapse; + border-spacing:0; + font-family:Poppins; + width: 100%; + } + + .tg td{ + border-color:#DDDFE1; + border-style:solid; + border-width:1px; + font-family:Poppins; + font-size: 10px; + overflow:hidden; + padding:17px 30px; + word-break:normal; + } + + .tg th{ + border-color:#DDDFE1; + border-style:solid; + border-width:1px; + font-family:Poppins; + font-size:10px; + font-weight:500; + overflow:hidden; + padding:10px 5px; + word-break:normal; + } + .tg .tg-8oo6{ + color:#464a53; + font-size:13px; + text-align:center; + vertical-align:top; + padding: 10px 18px; + text-align: center; + } + .tg .tg-uulg{ + background-color:#efefef; + color:#abafb3; + font-size:14px; + text-align:center; + vertical-align:top + } + .tg .tg-gceh{ + background-color:#efefef; + color:#6a707e; + font-size:14px; + text-align:center; + vertical-align:top + } + .tg .tg-0tzy{ + color:#abafb3; + font-size:14px; + text-align:center; + vertical-align:top + } + .tg .tg-hq65{color:#6a707e; + font-size:14px; + text-align:center; + vertical-align:top + } + + .tg .tg-baqh{ + text-align:center; + vertical-align:top + } + .tg .tg-0lax{ + text-align:left; + vertical-align:top + } + .tg .tg-womg{ + background-color:#dddfe1; + text-align:center; + vertical-align:top + } + input { width: 15rem; height: 2.5rem; @@ -132,6 +289,57 @@ export const Buttons = styled.div` } } + #preloader_1{ + position:absolute; + top: 50%; + left: 50%; + } + #preloader_1 span{ + display:block; + bottom:0px; + width: 9px; + height: 5px; + background:#254F7F; + position:absolute; + animation: preloader_1 1.5s infinite ease-in-out; + } + + #preloader_1 span:nth-child(2){ + left:11px; + animation-delay: .2s; + + } + #preloader_1 span:nth-child(3){ + left:22px; + animation-delay: .4s; + } + #preloader_1 span:nth-child(4){ + left:33px; + animation-delay: .6s; + } + #preloader_1 span:nth-child(5){ + left:44px; + animation-delay: .8s; + } + @keyframes preloader_1 { + 0% {height:5px;transform:translateY(0px);background:rgb(1,138,138);} + 25% {height:30px;transform:translateY(15px);background:#254F7F;} + 50% {height:5px;transform:translateY(0px);background:rgb(231,153,47);} + 100% {height:5px;transform:translateY(0px);background:rgb(1,138,138);} + } + + .loadingTable { + position: relative; + top: 50%; + left: 50%; + width: 100%; + height: 100%; + + z-index: 9999999; + + background-color: #FFFFFF; + } + @media (max-width: 942px) { align-items: center; justify-content: center; From 2631df84f52ac22f1a6f6857c6e25aa685900be5 Mon Sep 17 00:00:00 2001 From: Alex Santos Date: Tue, 28 Jun 2022 16:37:06 -0300 Subject: [PATCH 6/6] Fixing update --- src/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 53c26d8..d25b0a3 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -70,7 +70,7 @@ export default function Home() { }else{ try { await signIn({email, password}).then((res: any) => { - if (res.response.status === 422 || res.response.status === 401) { + if (res.response.status === 422 || res.response.status === 401 || res.response.status === 500 ) { setOpenSnackError(true) } })