diff --git a/src/components/graph/ChartView.ts b/src/components/graph/ChartView.ts index 5a80505..8fb2fd7 100644 --- a/src/components/graph/ChartView.ts +++ b/src/components/graph/ChartView.ts @@ -1,7 +1,7 @@ import styled from "styled-components" export const ChartView = styled.div` - width: 90%; + min-width: 90%; div{ /* margin-top: 10px; */ diff --git a/src/components/graph/DemRegXDemConChart.tsx b/src/components/graph/DemRegXDemConChart.tsx index 3ba52cf..4e5d94b 100644 --- a/src/components/graph/DemRegXDemConChart.tsx +++ b/src/components/graph/DemRegXDemConChart.tsx @@ -84,12 +84,22 @@ export function DemRegXDemConChart({ }: LineBarChartInterface) { const chartRef = useRef(null); - const currentTime = new Date(); - const labels = label const options: any = { responsive: true, + scales: { + x: { + grid: { + display: false + } + }, + y: { + grid: { + display: false + } + }, + }, plugins: { datalabels: { display: true, @@ -144,7 +154,7 @@ export function DemRegXDemConChart({ return ( - + {/* */}
diff --git a/src/components/graph/DiscretizedConsumptionChart.tsx b/src/components/graph/DiscretizedConsumptionChart.tsx index 90ed38c..6b0b543 100644 --- a/src/components/graph/DiscretizedConsumptionChart.tsx +++ b/src/components/graph/DiscretizedConsumptionChart.tsx @@ -2,7 +2,8 @@ import { BarElement, CategoryScale, Chart as ChartJS, Legend, LinearScale, Title import ChartDataLabels from 'chartjs-plugin-datalabels'; import { draw, generate } from 'patternomaly' import React from 'react'; -import { Bar } from 'react-chartjs-2'; +import { Bar, Chart } from 'react-chartjs-2'; +// import Chart from './Chart'; import ChartTitle from './ChartTitle'; import { ChartView } from './ChartView'; @@ -30,82 +31,76 @@ interface SingleBarInterface{ } export function DiscretizedConsumptionChart({ title, subtitle, dataProps, label, dataset, barLabel, year, month }: SingleBarInterface) { - const currentTime = new Date(); - const options: object = { + const labels = label + + const options: any = { responsive: true, - series: { - downsample: { - threshold: 1000 - } + scales: { + x: { + grid: { + display: false + } + }, + y: { + grid: { + display: false + } + }, }, plugins: { datalabels: { - formatter: (value, ctx) => { - let sum = 0; - const dataArr = ctx.chart.data.datasets[0].data; - dataArr.map(data => { - sum += data; - }); - const percentage = (dataProps[ctx.dataIndex].econ_percentual*100).toFixed(0)+"%"; - const result = `${parseInt(value).toFixed(0)}\n ${percentage}` - - return value==null? null : result - }, - display: true, - color: barLabel? 'black' : "rgba(255, 255, 255, 0)", - anchor: "end", - offset: -40, - align: "start", - font: { - size: 10 - } + display: false, }, legend: { position: 'bottom' as const, }, title: { - display: false, + display: true, text: '', }, }, }; - const labels = label; - const data: any = { - labels, + labels: dataProps.map(value => value.day_formatted), datasets: [ { - label: dataset, + type: 'line' as const, + label: 'reativa', + borderColor: '#F00' , + fill: false, + borderDash: [5, 5], + backgroundColor: 'rgba(255, 145, 0, 0)' , + pointBorderColor: 'rgba(255, 145, 0, 0)', + data: dataProps.map(value => value.reativa), + }, + { + type: 'bar' as const, + label: 'consumo', + backgroundColor: '#74acec', data: dataProps.map(value => value.consumo), - backgroundColor: '#255488' - }, - { - type: 'line' as const, - label: 'base', - data: dataProps.map(value => 500), - borderColor: 'rgb(0, 0, 0)', - fill: false, - backgroundColor: 'rgb(0, 0, 0)' , - pointBorderColor: 'rgba(255, 145, 0, 0)', - }, - { - type: 'line' as const, - label: 'tolerância', - data: dataProps.map(value => 525), - borderColor: 'rgb(255, 0, 0)', - fill: false, - backgroundColor: 'rgb(255, 0, 0)' , - pointBorderColor: 'rgba(255, 145, 0, 0)', }, + // { + // type: 'line' as const, + // label: 'Livre', + // // backgroundColor: '#255488', + // backgroundColor: (value, ctx) => { + // return '#255488' + // }, + // data: dataProps.map(value => { + // return parseInt(value.custo_livre) + // }), + // }, ], } return ( - - + {/* */} +
+ +
) } diff --git a/src/components/graph/fatorPotenciaChart.tsx b/src/components/graph/fatorPotenciaChart.tsx index 986c5b0..6034d2e 100644 --- a/src/components/graph/fatorPotenciaChart.tsx +++ b/src/components/graph/fatorPotenciaChart.tsx @@ -46,6 +46,18 @@ interface ChartInterface { export default function FatorPotenciaChart({ title, subtitle, data1, data2, label, dataset1, dataset2, dataset3, dataset4, barLabel }: ChartInterface) { const options: any = { responsive: true, + scales: { + x: { + grid: { + display: false + } + }, + y: { + grid: { + display: false + } + }, + }, plugins: { datalabels: { display: true, @@ -93,7 +105,7 @@ export default function FatorPotenciaChart({ title, subtitle, data1, data2, labe return ( - + {/* */} ) diff --git a/src/components/graph/grossMensalChart/GrossMensalChart.tsx b/src/components/graph/grossMensalChart/GrossMensalChart.tsx index 6a184f3..318b599 100644 --- a/src/components/graph/grossMensalChart/GrossMensalChart.tsx +++ b/src/components/graph/grossMensalChart/GrossMensalChart.tsx @@ -50,8 +50,6 @@ export default function GrossMensalChart({ title, data1, data2, label, subtitle, return spaces } - const labels = label; - const options: any = { responsive: true, scales: { @@ -104,7 +102,7 @@ export default function GrossMensalChart({ title, data1, data2, label, subtitle, datasets: [ { type: 'bar', - label: 'Acumulado', + label: 'Consolidado', data: data1.map(value => value?.economia_acumulada), backgroundColor: '#255488' }, diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx index 325241f..4f805fc 100644 --- a/src/components/sidebar/Sidebar.tsx +++ b/src/components/sidebar/Sidebar.tsx @@ -129,12 +129,12 @@ export default function Sidebar() {
  • {'Telemetria'}
  • {'Resumo de Op. '}
  • {'Notícias'}
  • -
  • setPldDrawer(!pldDrawer)} className={router.pathname=='/pld'? 'actualPath' : null}>{'PLD >'}
  • -
    +
  • setPldDrawer(!pldDrawer)} className={router.pathname=='/pld'? 'actualPath' : null}>{'PLD >'}
  • + {/*
  • setPldMenu(0)} className={pldMenu==0? 'actualPathDrawer' : null}>PLD Histórico
  • setPldMenu(1)} className={pldMenu===1? 'actualPathDrawer' : null}>Valores Diários
  • setPldMenu(2)} className={pldMenu===2? 'actualPathDrawer' : null}>Valores Horários
  • -
    +
    */}
  • {'Info Setorial'}
  • {/*
  • {'Consumo'}
  • */}
  • {'Notificações'}

    {notificationsCount}

  • diff --git a/src/pages/aboutUs/index.tsx b/src/pages/aboutUs/index.tsx index 5bf4ed2..87a895d 100644 --- a/src/pages/aboutUs/index.tsx +++ b/src/pages/aboutUs/index.tsx @@ -5,6 +5,7 @@ import { parseCookies } from 'nookies' import React from 'react' import Banner from '../../components/banner/Banner' import Header from '../../components/header/Header' +import PageTitle from '../../components/pageTitle/PageTitle' import getAPIClient from '../../services/ssrApi' import { AboutUsView } from '../../styles/layouts/aboutUs/AboutUsView' @@ -15,8 +16,10 @@ export default function aboutUs({userName, text}) { Smart Energia - Sobre nós -
    - +
    + +
    + {/* */}
    diff --git a/src/pages/chartTelemetry/index.tsx b/src/pages/chartTelemetry/index.tsx index 189f0aa..4fb2e4d 100644 --- a/src/pages/chartTelemetry/index.tsx +++ b/src/pages/chartTelemetry/index.tsx @@ -35,9 +35,9 @@ export default function chartTelemetry({userName}) { function getChartsData() { console.log(token) - getPowerFactorData("PRAXCUENTR101P", "2022-01-01", "2022-01-31", "med_5min") - .then(result => setFatorPotenciaData(result)) - .catch(exception => console.log('exeption', exception)) + // getPowerFactorData("PRAXCUENTR101P", "2022-01-01", "2022-01-31", "med_5min") + // .then(result => setFatorPotenciaData(result)) + // .catch(exception => console.log('exeption', exception)) // getDiscretization("PRAXCUENTR101P", "2022-01-01", "2022-01-31", "med_5min") // .then(result => setDiscretizedConsumptionDataReativa(result)) diff --git a/src/pages/economy/index.tsx b/src/pages/economy/index.tsx index 6b4d1dd..1ad93a3 100644 --- a/src/pages/economy/index.tsx +++ b/src/pages/economy/index.tsx @@ -93,13 +93,13 @@ export default function economy({userName, anual, years, brutaMensal, yearsBruta
    - +
    setEconomyMenu(nv)} aria-label=""> - - + + @@ -125,25 +125,27 @@ export default function economy({userName, anual, years, brutaMensal, yearsBruta - - Unidade - - +
    + + Unidade + + +
    - - Unidade - - +
    + + Unidade + + +
    value.mes.slice(4, 8).includes('2021')) diff --git a/src/pages/faq/index.tsx b/src/pages/faq/index.tsx index 03747dd..372776c 100644 --- a/src/pages/faq/index.tsx +++ b/src/pages/faq/index.tsx @@ -10,7 +10,6 @@ import { api } from '../../services/api' import getAPIClient from '../../services/ssrApi' import { FaqView } from '../../styles/layouts/commonQuestions/FaqView' - export default function commonQuestions({faqData, userName}) { return ( @@ -18,8 +17,9 @@ export default function commonQuestions({faqData, userName}) { Smart Energia - FAQ
    +
    - + {/* */}
    { faqData.length<1? diff --git a/src/pages/industryInfo/index.tsx b/src/pages/industryInfo/index.tsx index 6394455..5b6b989 100644 --- a/src/pages/industryInfo/index.tsx +++ b/src/pages/industryInfo/index.tsx @@ -59,8 +59,9 @@ export default function industryInfo({userName}: any) { Smart Energia - Info de Setor
    +
    - + {/* */}

    Um resumo das atualizações gerais do Setor Elétrico, com dados sobre geração consumo, demanda, meteorologia baseadas em informações do ONS, CCEE, ANEEL, 10 Maiores Jornais e Revistas e CPTEC

    diff --git a/src/pages/news/index.tsx b/src/pages/news/index.tsx index 4bc5720..fff5df3 100644 --- a/src/pages/news/index.tsx +++ b/src/pages/news/index.tsx @@ -8,6 +8,7 @@ import React from 'react' import Banner from '../../components/banner/Banner' import BasicButton from '../../components/buttons/basicButton/BasicButton'; import Header from '../../components/header/Header' +import PageTitle from '../../components/pageTitle/PageTitle'; import getAPIClient from '../../services/ssrApi'; import { Button, NewsView } from '../../styles/layouts/news/NewsView' @@ -17,11 +18,13 @@ export default function aboutUs({userName, news}: any) { Smart Energia - Noticias -
    - +
    + +
    + {/* */} { - news.map(data => { + news.slice(0, 3).map(data => { return <>
    diff --git a/src/pages/notifications/index.tsx b/src/pages/notifications/index.tsx index 251398b..0521ae9 100644 --- a/src/pages/notifications/index.tsx +++ b/src/pages/notifications/index.tsx @@ -17,8 +17,9 @@ export default function Notifications({notificationData, userName}: any) { Smart Energia - Notificações
    +
    - + {/* */}
    { notificationData.length!=0? diff --git a/src/pages/pld/index.tsx b/src/pages/pld/index.tsx index 6de55b9..793b1c7 100644 --- a/src/pages/pld/index.tsx +++ b/src/pages/pld/index.tsx @@ -153,7 +153,7 @@ export default function pld({tableData, userName, clientMonth}: pldInterface) { }) } - function handleColorNorte(value, region) { + function handleColor(value, region) { if (value <= tableData.result[1].norte_min) return '' else if (value >= tableData.result[0][`${region}_max`]) @@ -373,9 +373,8 @@ export default function pld({tableData, userName, clientMonth}: pldInterface) {
    -
    Região -
    - - Mês - + Nenhum + { + clientMonth.sort((a, b) => { + if (parseFloat(a.mes_ref.slice(0, 2)) < parseFloat(b.mes_ref.slice(0, 2))) + if (parseFloat(a.mes_ref.slice(3, 7)) > parseFloat(b.mes_ref.slice(3, 7))) return -1 + else return 1 + if (parseFloat(a.mes_ref.slice(0, 2)) > parseFloat(b.mes_ref.slice(0, 2))) + if (parseFloat(a.mes_ref.slice(3, 7)) < parseFloat(b.mes_ref.slice(3, 7))) return 1 + else return -1 - return 0 - }).map((data, index) => { - return {data.mes_ref} - }) - } + return 0 + }).map((data, index) => { + return {data.mes_ref} + }) + }
    diff --git a/src/pages/telemetria/index.tsx b/src/pages/telemetria/index.tsx index 0cc5627..e46a2ee 100644 --- a/src/pages/telemetria/index.tsx +++ b/src/pages/telemetria/index.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import Banner from '../../components/banner/Banner'; -import { TelemetriaView, Buttons, TableHeader} from '../../styles/layouts/Telemetria/TelemetriaView'; +import { TelemetriaView, Buttons, TableHeader, ChartFilters} from '../../styles/layouts/Telemetria/TelemetriaView'; import GradientButton from '../../components/buttons/gradientButton/GradientButton' import Header from '../../components/header/Header'; import MenuItem from '@mui/material/MenuItem'; @@ -31,6 +31,10 @@ import BasicButton from '../../components/buttons/basicButton/BasicButton'; import { DiscretizedConsumptionChart } from '../../components/graph/DiscretizedConsumptionChart'; import DiscretizedConsumptionChartLine from '../../components/graph/DiscretizedConsumptionChartLine'; import FatorPotenciaChart from '../../components/graph/fatorPotenciaChart'; +import { getDiscretization } from '../../services/charts/telemetry/getDiscretization'; +import { getPowerFactorData } from '../../services/charts/telemetry/getPowerFactor'; +import { getDemand } from '../../services/charts/telemetry/getDemand'; +import PageTitle from '../../components/pageTitle/PageTitle'; const Alert = React.forwardRef(function Alert( props, @@ -49,6 +53,8 @@ export default function Telemetria({userName, clients}: any) { const [openSnackError, setOpenSnackError] = useState(false) const [openSnackFields, setOpenSnackFields] = useState(false) + const currentDate = new Date().toLocaleDateString().split('/').reverse().join('-') + const handleCloseSnack = ( event?: React.SyntheticEvent | Event, reason?: string @@ -106,8 +112,6 @@ export default function Telemetria({userName, clients}: any) { const [open, setOpen] = useState(false); - // const [demRegXDemCon, setDemRegXDemCon] = useState(null); - const handleChangeStartDate = (newValue: Date | null) => { console.log(newValue) setStartDate(newValue) @@ -123,8 +127,8 @@ export default function Telemetria({userName, clients}: any) { await api.post('/telemetry/powerFactor', { "type": discretization, "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, - {"type" : "between", "field": "dia_num", "value": ["2022-01-03", "2022-01-03"]} + {"type" : "=", "field": "med_5min.ponto", "value": unity}, + {"type" : "between", "field": "dia_num", "value": [currentDate, currentDate]} ] }).then(res => { setTableData(res.data.data) @@ -132,8 +136,8 @@ export default function Telemetria({userName, clients}: any) { setOpenSnackSuccess(true) setOpen(false) }).catch(res => { - setException(true) setSend(false) + setException(true) setOpenSnackError(true) setOpenSnackSuccess(false) }) @@ -171,33 +175,11 @@ export default function Telemetria({userName, clients}: any) { }) } + const [filters, setFilters] = useState() + const [fatorPotenciaData, setFatorPotenciaData] = useState([]); const [demRegXDemCon, setDemRegXDemCon] = useState([]); const [discretizedConsumptionData, setDiscretizedConsumptionData] = useState([]); - const [discretizedConsumptionDataReativa, setDiscretizedConsumptionDataReativa] = useState([]); - function getChartsData() { - // console.log(token) - // getPowerFactorData("PRAXCUENTR101P", "2022-01-01", "2022-01-31", "med_5min") - // .then(result => setFatorPotenciaData(result)) - // .catch(exception => console.log('exeption', exception)) - - // getDiscretization("PRAXCUENTR101P", "2022-01-01", "2022-01-31", "med_5min") - // .then(result => setDiscretizedConsumptionDataReativa(result)) - // .catch(exception => console.log(exception)) - - // getDiscretization("PRAXCUENTR101P", "2022-01-01", "2022-01-31", "med_5min") - // .then(result => setDiscretizedConsumptionData(result)) - // .catch(exception => console.log(exception)) - - // getDemand("PRAXCUENTR101P", "2022-01-01", "2022-01-31", "med_5min") - // .then(result => setDemRegXDemCon(result)) - // .catch(exception => console.log(exception)) - - // setFatorPotenciaData(res.data.data) - // setDiscretizedConsumptionDataReativa(res.data.data) - // setDiscretizedConsumptionData(res.data.data) - // setDemRegXDemCon(res.data.data) - } useEffect(() => { setSend(false) @@ -208,6 +190,12 @@ export default function Telemetria({userName, clients}: any) { getChartData() }, [send]) + useEffect(() => { + // getDiscretization("PRAXCUENTR101P", "2022-01-01", "2022-01-31", "med_5min") + // .then(result => setDiscretizedConsumptionData(result)) + // .catch(exception => console.log(exception)) + }, [discretization]) + return( @@ -254,153 +242,370 @@ export default function Telemetria({userName, clients}: any) { -
    - +
    + {/* + - Distribuidora.' imgSource='/assets/graphical.png' /> */} -
    -
    -

    Unidade

    - - Unidade - - -
    - -
    -

    Discretização

    - - Discretização - - -
    - - -
    -

    Data inicial

    - } - /> -
    -
    -

    Data final

    - handleChangeEndDate(newValue)} - renderInput={(params) => } - /> -
    -
    - - { - setSend(true) - getTableData() - }}/> -
    - - + setMenu(nv)} aria-label=""> - - + + - - {/* */} - -
    - value.minut)} dataset={'Consumo'} dataset1='Estimado' month/> -

    {`Mês - ${startDate}`}

    + + +
    + + Unidade + +
    -
    +
    + + Discretização + + +
    + +
    + } + /> +
    +
    + handleChangeEndDate(newValue)} + renderInput={(params) => } + /> +
    +
    +
    + { + getDiscretization(unity, startDate, endDate, discretization) + .then(result => setDiscretizedConsumptionData(result)) + .catch(exception => console.log(exception)) + }}/> +
    + + {/* */} + value.minut)} dataset={'Consumo'} dataset1='Estimado' month/> + {/*

    {`Mês - ${startDate}`}

    */} + {/*
    */} + - -
    - parseFloat(data.reativa).toFixed(3))} /> + + +
    + + Unidade + +
    -
    +
    + + Discretização + + +
    + +
    + } + /> +
    +
    + handleChangeEndDate(newValue)} + renderInput={(params) => } + /> +
    +
    +
    + { + getDiscretization(unity, startDate, endDate, discretization) + .then(result => setDiscretizedConsumptionData(result)) + .catch(exception => console.log(exception)) + }}/> +
    + + value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/> -
    - value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/> -
    + +
    + + Unidade + + +
    +
    + + Discretização + + +
    + +
    + } + /> +
    +
    + handleChangeEndDate(newValue)} + renderInput={(params) => } + /> +
    +
    +
    + { + getDiscretization(unity, startDate, endDate, discretization) + .then(result => setDiscretizedConsumptionData(result)) + .catch(exception => console.log(exception)) + }}/> +
    +
    + parseFloat(value.dia_num))} />
    -
    - parseFloat(value.dia_num))} /> -
    + +
    + + Unidade + + +
    +
    + + Discretização + + +
    +
    + { + getDiscretization(unity, startDate, endDate, discretization) + .then(result => setDiscretizedConsumptionData(result)) + .catch(exception => console.log(exception)) + }}/> +
    +
    + value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/>
    -
    @@ -451,12 +656,19 @@ export default function Telemetria({userName, clients}: any) { value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/> + - setShowChart(!showChart)} purple /> - handleVerifyFields()} orange /> + {/* setShowChart(!showChart)} purple /> */} + {/* handleVerifyFields()} orange /> */} { - const html = document.querySelector("table").outerHTML; - htmlToCSV(html, "telemetria.csv"); + if (send) { + const html = document.querySelector("table").outerHTML; + htmlToCSV(html, "telemetria.csv"); + } + else { + setSend(true) + getTableData() + } }}/>

    diff --git a/src/services/charts/telemetry/getDemand.ts b/src/services/charts/telemetry/getDemand.ts index 101e881..12012dd 100644 --- a/src/services/charts/telemetry/getDemand.ts +++ b/src/services/charts/telemetry/getDemand.ts @@ -1,22 +1,19 @@ import axios from "axios" import { parseCookies } from "nookies" +import { api } from "../../api" export async function getDemand( unity: string, - startDate: string, - endDate: string, + startDate: Date, + endDate: Date, discretization: string ) { const { '@smartAuth-token': token } = parseCookies() - const { data } = await axios.post('https://smart-energia-api.herokuapp.com/api/telemetry/demand', { + const { data } = await api.post('https://smart-energia-api.herokuapp.com/api/telemetry/demand', { "filters": [ - {"type" : "=", "field": `${discretization}.ponto`, "value": unity}, - {"type" : "between", "field": ["dia_num"], "value": [startDate, endDate]} + {"type" : "=", "field": `med_5min.ponto`, "value": unity}, + {"type" : "between", "field": "dia_num", "value": [startDate.toLocaleDateString().split('/').reverse().join('-'), endDate.toLocaleDateString().split('/').reverse().join('-')]} ] - }, { - headers: { - 'Authorization': `Bearer 1260|RHfh3uMsEfHwCTqxKOhy1CEIr34UIln9OFdf5Fc8` - } }) return data.data diff --git a/src/services/charts/telemetry/getDiscretization.ts b/src/services/charts/telemetry/getDiscretization.ts index bf515bc..56b712c 100644 --- a/src/services/charts/telemetry/getDiscretization.ts +++ b/src/services/charts/telemetry/getDiscretization.ts @@ -1,24 +1,28 @@ import axios from "axios" import { parseCookies } from "nookies" +import { api } from "../../api" + +const { '@smartAuth-token': token } = parseCookies() export async function getDiscretization( unity: string, - startDate: string, - endDate: string, + startDate: Date, + endDate: Date, discretization: string ) { - const { '@smartAuth-token': token } = parseCookies() - const { data } = await axios.post('https://smart-energia-api.herokuapp.com/api/telemetry/discretization', { - "type": discretization, - "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": unity} - ] - }, { - headers: { - 'Authorization': `Bearer 1260|RHfh3uMsEfHwCTqxKOhy1CEIr34UIln9OFdf5Fc8` + console.log(new Date(startDate).toLocaleDateString().split('/').reverse().join('-'), endDate.toLocaleDateString()) + const { data } = await api.post('/telemetry/discretization', { + "type": discretization, + // "type": "1_hora", + "filters": [ + {"type" : "=", "field": "med_5min.ponto", "value": unity}, + {"type" : "between", "field": "dia_num", "value": [startDate.toLocaleDateString().split('/').reverse().join('-'), endDate.toLocaleDateString().split('/').reverse().join('-')]} + ] + // "filters": [ + // {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"} + // ] } - } - ) + ) return data.data } diff --git a/src/services/charts/telemetry/getPowerFactor.ts b/src/services/charts/telemetry/getPowerFactor.ts index 95d0333..3b3dc80 100644 --- a/src/services/charts/telemetry/getPowerFactor.ts +++ b/src/services/charts/telemetry/getPowerFactor.ts @@ -1,23 +1,18 @@ import axios from "axios" import { parseCookies } from "nookies" +import { api } from "../../api" export async function getPowerFactorData( unity: string, - startDate: string, - endDate: string, + startDate: Date, + endDate: Date, discretization: string ) { - const { '@smartAuth-token': token } = parseCookies() - console.log(token.replace(/"/g, '')) - const { data } = await axios.post('http://smart-energia-api.herokuapp.com/api/telemetry/powerFactor', { + const { data } = await api.post('http://smart-energia-api.herokuapp.com/api/telemetry/powerFactor', { "filters": [ - {"type" : "=", "field": "med_5min.ponto", "value": "PRAXCUENTR101P"}, - {"type" : "between", "field": "dia_num", "value": ["2022-01-01", "2022-01-31"]} + {"type" : "=", "field": "med_5min.ponto", "value": unity}, + {"type" : "between", "field": "dia_num", "value": [startDate.toLocaleDateString().split('/').reverse().join('-'), endDate.toLocaleDateString().split('/').reverse().join('-')]} ] - }, { - headers: { - 'Authorization': `Bearer 1292|E4jbc5ZWmgCCBMOVn4PvPx56MUbf4nUg5MNgxjmP` - } }) return data.data } diff --git a/src/styles/layouts/Telemetria/TelemetriaView.ts b/src/styles/layouts/Telemetria/TelemetriaView.ts index 0c37160..91bcc3d 100644 --- a/src/styles/layouts/Telemetria/TelemetriaView.ts +++ b/src/styles/layouts/Telemetria/TelemetriaView.ts @@ -1,6 +1,12 @@ import styled from 'styled-components'; export const TelemetriaView = styled.main` + display: flex; + align-items: center; + justify-content: center; + + flex-direction: column; + padding: 20px; width: 100%; @@ -18,7 +24,7 @@ export const TelemetriaView = styled.main` left: 0; width: 100%; - height: 100%; + height: 100vh; z-index: 999; } @@ -37,11 +43,9 @@ export const TelemetriaView = styled.main` 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; @@ -172,6 +176,8 @@ export const TelemetriaView = styled.main` input { width: 15rem; + height: 10px!important; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; font-weight: 400; @@ -181,6 +187,12 @@ export const TelemetriaView = styled.main` background-color: #F9F9F9; } + .input { + .MuiInputLabel-root, .MuiInputLabel-formControl { + margin-top: 11px; + } + } + span { font-family: 'Inter'; font-style: normal; @@ -216,7 +228,7 @@ export const TelemetriaView = styled.main` justify-content: center; flex-direction: column; - height: 10em; + /* height: 10em; */ :nth-child(1) { label { @@ -362,7 +374,7 @@ export const Uploads = styled.div` padding-right: 100px; `; -export const TableHeader = styled.label` +export const TableHeader = styled.div` width: 100%; display: flex; @@ -373,3 +385,17 @@ export const TableHeader = styled.label` padding: 0 40px 0 40px ` + +export const ChartFilters = styled.section` + display: flex; + align-items: center; + justify-content: center!important; + + align-self: flex-start; + + width: 100%; + + margin-top: 20px; + + /* margin-left: 108px; */ +` diff --git a/src/styles/layouts/pld/PldView.ts b/src/styles/layouts/pld/PldView.ts index f84af69..42984d8 100644 --- a/src/styles/layouts/pld/PldView.ts +++ b/src/styles/layouts/pld/PldView.ts @@ -444,13 +444,11 @@ export const PldGraphView = styled.main` justify-content: center; align-items: flex-start!important; + align-self: flex-start; + flex-direction: row; - padding-bottom: 13px; - - p { - margin: 0; - } + flex-wrap: nowrap; } .toolsbar2 { display: flex; @@ -459,7 +457,7 @@ export const PldGraphView = styled.main` flex-direction: column; - margin-bottom: 9px; + /* margin-bottom: 9px; */ /* transform: translateY(-8px); */