diff options
author | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-06-07 17:55:16 +0200 |
---|---|---|
committer | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-06-07 17:58:18 +0200 |
commit | 47fc603b864b52a70157515f29ec741dd9192f3a (patch) | |
tree | 12e8cb752efc4b2c92e35325780ac4242b5d791d /sdnr/wt/odlux/apps/performanceHistoryApp/src/components | |
parent | d93e6a996e60fb6abce9a870cef6b2d57bfa70fd (diff) |
SDNR align ODLUX
Add missing chart view to UX Performance app
Issue-ID: SDNC-790
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Change-Id: I6f5af1e01d2246927b8d05f826f629c7dd5f59a5
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/performanceHistoryApp/src/components')
7 files changed, 924 insertions, 358 deletions
diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/adaptiveModulation.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/adaptiveModulation.tsx index 024315c3a..281ee2f8d 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/adaptiveModulation.tsx +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/adaptiveModulation.tsx @@ -2,23 +2,25 @@ import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; +import { MaterialTable, ColumnType, ColumnModel, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect'; import { AdaptiveModulationDataType } from '../models/adaptiveModulationDataType'; -import { createAdaptiveModulation15minProperties, createAdaptiveModulation15minActions, adaptiveModulation15minReloadAction } from '../handlers/adaptiveModulation15minHandler'; -import { createAdaptiveModulation24hoursProperties, createAdaptiveModulation24hoursActions, adaptiveModulation24hoursReloadAction } from '../handlers/adaptiveModulation24hoursHandler'; - +import { IDataSet, IDataSetsObject } from '../models/chartTypes'; +import { createAdaptiveModulation15minProperties, createAdaptiveModulation15minActions } from '../handlers/adaptiveModulation15minHandler'; +import { createAdaptiveModulation24hoursProperties, createAdaptiveModulation24hoursActions } from '../handlers/adaptiveModulation24hoursHandler'; +import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils'; +import { addColumnLabels } from '../utils/tableUtils'; const mapProps = (state: IApplicationStoreState) => ({ adaptiveModulation15minProperties: createAdaptiveModulation15minProperties(state), - adaptiveModulation24hoursProperties: createAdaptiveModulation24hoursProperties(state), + adaptiveModulation24hoursProperties: createAdaptiveModulation24hoursProperties(state) }); const mapDisp = (dispatcher: IDispatcher) => ({ adaptiveModulation15minActions: createAdaptiveModulation15minActions(dispatcher.dispatch), - adaptiveModulation24hoursActions: createAdaptiveModulation24hoursActions(dispatcher.dispatch), + adaptiveModulation24hoursActions: createAdaptiveModulation24hoursActions(dispatcher.dispatch) }); type AdaptiveModulationComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & { @@ -32,109 +34,391 @@ const AdaptiveModulationTable = MaterialTable as MaterialTableCtorType<AdaptiveM */ class AdaptiveModulationComponent extends React.Component<AdaptiveModulationComponentProps>{ render(): JSX.Element { - if (this.props.selectedTimePeriod == "15min") { - return ( - <AdaptiveModulationTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "time2-states-s", title: "QAM2S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2-states", title: "QAM2", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2-states-l", title: "QAM2L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4-states-s", title: "QAM4S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4-states", title: "QAM4", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4-states-l", title: "QAM4L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time16-states-s", title: "QAM16S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time16-states", title: "QAM16", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time16-states-l", title: "QAM16L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time32-states-s", title: "QAM32S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time32-states", title: "QAM32", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time32-states-l", title: "QAM32L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time64-states-s", title: "QAM64S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time64-states", title: "QAM64", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time64-states-l", title: "QAM64L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time128-states-s", title: "QAM128S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time128-states", title: "QAM128", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time128-states-l", title: "QAM128L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time256-states-s", title: "QAM256S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time256-states", title: "QAM256", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time256-states-l", title: "QAM256L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time512-states-s", title: "QAM512S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time512-states", title: "QAM512", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time512-states-l", title: "QAM512L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time1024-states-s", title: "QAM1024S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time1024-states", title: "QAM1024", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time1024-states-l", title: "QAM1024L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2048-states-s", title: "QAM2048S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2048-states", title: "QAM2048", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2048-states-l", title: "QAM2048L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4096-states-s", title: "QAM4096S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4096-states", title: "QAM4096", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4096-states-l", title: "QAM4096L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time8192-states-s", title: "QAM8192S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time8192-states", title: "QAM8192", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time8192-states-l", title: "QAM8192L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.adaptiveModulation15minProperties} {...this.props.adaptiveModulation15minActions} /> - ); - } else { - return ( - <AdaptiveModulationTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "time2-states-s", title: "QAM2S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2-states", title: "QAM2", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2-states-l", title: "QAM2L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4-states-s", title: "QAM4S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4-states", title: "QAM4", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4-states-l", title: "QAM4L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time16-states-s", title: "QAM16S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time16-states", title: "QAM16", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time16-states-l", title: "QAM16L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time32-states-s", title: "QAM32S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time32-states", title: "QAM32", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time32-states-l", title: "QAM32L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time64-states-s", title: "QAM64S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time64-states", title: "QAM64", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time64-states-l", title: "QAM64L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time128-states-s", title: "QAM128S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time128-states", title: "QAM128", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time128-states-l", title: "QAM128L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time256-states-s", title: "QAM256S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time256-states", title: "QAM256", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time256-states-l", title: "QAM256L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time512-states-s", title: "QAM512S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time512-states", title: "QAM512", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time512-states-l", title: "QAM512L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time1024-states-s", title: "QAM1024S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time1024-states", title: "QAM1024", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time1024-states-l", title: "QAM1024L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2048-states-s", title: "QAM2048S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2048-states", title: "QAM2048", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time2048-states-l", title: "QAM2048L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4096-states-s", title: "QAM4096S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4096-states", title: "QAM4096", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time4096-states-l", title: "QAM4096L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time8192-states-s", title: "QAM8192S", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time8192-states", title: "QAM8192", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "time8192-states-l", title: "QAM8192L", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.adaptiveModulation24hoursProperties} {...this.props.adaptiveModulation24hoursActions} /> - ); - } + const properties = this.props.selectedTimePeriod === "15min" + ? this.props.adaptiveModulation15minProperties + : this.props.adaptiveModulation24hoursProperties; + + const actions = this.props.selectedTimePeriod === "15min" + ? this.props.adaptiveModulation15minActions + : this.props.adaptiveModulation24hoursActions; + + const chartPagedData = this.getChartDataValues(properties.rows); + const adaptiveModulationColumns: ColumnModel<AdaptiveModulationDataType>[] = [ + { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, + { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, + { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, + { + property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { + const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); + return <div >{suspectIntervalFlag} </div> + } + }]; + + chartPagedData.datasets.forEach(ds => { + adaptiveModulationColumns.push(addColumnLabels<AdaptiveModulationDataType>(ds.name, ds.columnLabel)); + }); + + return ( + <> + {lineChart(chartPagedData)} + <AdaptiveModulationTable idProperty={"_id"} columns={adaptiveModulationColumns} {...properties} {...actions} /> + </> + ); }; -} -export const AdaptiveModulation = withRouter(connect(mapProps, mapDisp)(AdaptiveModulationComponent)); + /** + * This function gets the performance values for Adaptive modulation according on the chartjs dataset structure + * which is to be sent to the chart. + */ + + private getChartDataValues = (rows: AdaptiveModulationDataType[]): IDataSetsObject => { + const _rows = [...rows]; + sortDataByTimeStamp(_rows); + + const datasets: IDataSet[] = [{ + name: "time2-states-s", + label: "QAM2S", + borderColor: '#62a309fc', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM2S", + }, { + name: "time2-states", + label: "QAM2", + borderColor: '#62a309fc', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM2", + }, { + name: "time2-states-l", + label: "QAM2L", + borderColor: '#62a309fc', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM2L", + }, { + name: "time4-states-s", + label: "QAM4S", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM4S", + }, { + name: "time4-states", + label: "QAM4", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM4", + }, { + name: "time4-states-l", + label: "QAM4L", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM4L", + }, { + name: "time16-states-s", + label: "QAM16S", + borderColor: '#9b15e2', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM16S", + }, { + name: "time16-states", + label: "QAM16", + borderColor: '#9b15e2', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM16", + }, { + name: "time16-states-l", + label: "QAM16L", + borderColor: '#9b15e2', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM16L", + }, { + name: "time32-states-s", + label: "QAM32S", + borderColor: '#2704f5f0', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM32S", + }, { + name: "time32-states", + label: "QAM32", + borderColor: '#2704f5f0', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM32", + }, { + name: "time32-states-l", + label: "QAM32L", + borderColor: '#2704f5f0', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM32L", + }, { + name: "time64-states-s", + label: "QAM64S", + borderColor: '#347692', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM64S", + }, { + name: "time64-states", + label: "QAM64", + borderColor: '#347692', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM64", + }, { + name: "time64-states-l", + label: "QAM64L", + borderColor: '#347692', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM64L", + }, { + name: "time128-states-s", + label: "QAM128S", + borderColor: '#885e22', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM128S", + }, { + name: "time128-states", + label: "QAM128", + borderColor: '#885e22', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM128", + }, { + name: "time128-states-l", + label: "QAM128L", + borderColor: '#885e22', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM128L", + }, { + name: "time256-states-s", + label: "QAM256S", + borderColor: '#de07807a', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM256S", + }, { + name: "time256-states", + label: "QAM256", + borderColor: '#de07807a', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM256", + }, { + name: "time256-states-l", + label: "QAM256L", + borderColor: '#de07807a', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM256L", + }, { + name: "time512-states-s", + label: "QAM512S", + borderColor: '#8fdaacde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM512S", + }, { + name: "time512-states", + label: "QAM512", + borderColor: '#8fdaacde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM512", + }, { + + name: "time512-states-l", + label: "QAM512L", + borderColor: '#8fdaacde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM512L", + }, { + + name: "time1024-states-s", + label: "QAM1024S", + borderColor: '#435b22', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM1024S", + }, { + + name: "time1024-states", + label: "QAM1024", + borderColor: '#435b22', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM1024", + }, { + + name: "time1024-states-l", + label: "QAM1024L", + borderColor: '#435b22', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM1024L", + }, { + name: "time2048-states-s", + label: "QAM2048S", + borderColor: '#e87a5b', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM2048S", + }, { + name: "time2048-states", + label: "QAM2048", + borderColor: '#e87a5b', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM2048", + }, { + name: "time2048-states-l", + label: "QAM2048L", + borderColor: '#e87a5b', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM2048L", + }, { + name: "time4096-states-s", + label: "QAM4096S", + borderColor: '#5be878', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM4096S", + }, { + name: "time4096-states", + label: "QAM4096", + borderColor: '#5be878', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM4096", + }, { + name: "time4096-states-l", + label: "QAM4096L", + borderColor: '#5be878', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM4096L", + }, { + name: "time8192-states-s", + label: "QAM8192s", + borderColor: '#cb5be8', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM8192S", + }, { + name: "time8192-states", + label: "QAM8192", + borderColor: '#cb5be8', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM8192", + }, { + name: "time8192-states-l", + label: "QAM8192L", + borderColor: '#cb5be8', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "QAM8192L", + } + ]; + + _rows.forEach(row => { + datasets.forEach(ds => { + ds.data.push({ + x: row["time-stamp"], + y: row[ds.name as keyof AdaptiveModulationDataType] as string + }); + }); + }); + + return { + datasets: datasets + }; + } +} +const AdaptiveModulation = withRouter(connect(mapProps, mapDisp)(AdaptiveModulationComponent)); export default AdaptiveModulation; diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/crossPolarDiscrimination.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/crossPolarDiscrimination.tsx index bbed8abfe..42e3f93a6 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/crossPolarDiscrimination.tsx +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/crossPolarDiscrimination.tsx @@ -2,23 +2,25 @@ import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; +import { MaterialTable, ColumnType, MaterialTableCtorType, ColumnModel } from '../../../../framework/src/components/material-table'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect'; import { CrossPolarDiscriminationDataType } from '../models/crossPolarDiscriminationDataType'; -import { createCrossPolarDiscrimination15minProperties, createCrossPolarDiscrimination15minActions, crossPolarDiscrimination15minReloadAction } from '../handlers/crossPolarDiscrimination15minHandler'; -import { createCrossPolarDiscrimination24hoursProperties, createCrossPolarDiscrimination24hoursActions, crossPolarDiscrimination24hoursReloadAction } from '../handlers/crossPolarDiscrimination24hoursHandler'; - +import { IDataSet, IDataSetsObject } from '../models/chartTypes'; +import { createCrossPolarDiscrimination15minProperties, createCrossPolarDiscrimination15minActions } from '../handlers/crossPolarDiscrimination15minHandler'; +import { createCrossPolarDiscrimination24hoursProperties, createCrossPolarDiscrimination24hoursActions } from '../handlers/crossPolarDiscrimination24hoursHandler'; +import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils'; +import { addColumnLabels } from '../utils/tableUtils'; const mapProps = (state: IApplicationStoreState) => ({ crossPolarDiscrimination15minProperties: createCrossPolarDiscrimination15minProperties(state), - crossPolarDiscrimination24hoursProperties: createCrossPolarDiscrimination24hoursProperties(state), + crossPolarDiscrimination24hoursProperties: createCrossPolarDiscrimination24hoursProperties(state) }); const mapDisp = (dispatcher: IDispatcher) => ({ crossPolarDiscrimination15minActions: createCrossPolarDiscrimination15minActions(dispatcher.dispatch), - crossPolarDiscrimination24hoursActions: createCrossPolarDiscrimination24hoursActions(dispatcher.dispatch), + crossPolarDiscrimination24hoursActions: createCrossPolarDiscrimination24hoursActions(dispatcher.dispatch) }); type CrossPolarDiscriminationComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & { @@ -32,43 +34,87 @@ const CrossPolarDiscriminationTable = MaterialTable as MaterialTableCtorType<Cro */ class CrossPolarDiscriminationComponent extends React.Component<CrossPolarDiscriminationComponentProps>{ render(): JSX.Element { - if (this.props.selectedTimePeriod == "15min") { - return ( - <CrossPolarDiscriminationTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "xpd-min", title: "CPD (min)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "xpd-avg", title: "CPD (avg)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "xpd-max", title: "CPD (max)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.crossPolarDiscrimination15minProperties} {...this.props.crossPolarDiscrimination15minActions} /> - ); - } else { - return ( - <CrossPolarDiscriminationTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "xpd-min", title: "CPD (min)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "xpd-avg", title: "CPD (avg)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "xpd-max", title: "CPD (max)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.crossPolarDiscrimination24hoursProperties} {...this.props.crossPolarDiscrimination24hoursActions} /> - ); - } + const properties = this.props.selectedTimePeriod === "15min" + ? this.props.crossPolarDiscrimination15minProperties + : this.props.crossPolarDiscrimination24hoursProperties; + const actions = this.props.selectedTimePeriod === "15min" + ? this.props.crossPolarDiscrimination15minActions + : this.props.crossPolarDiscrimination24hoursActions; + + const chartPagedData = this.getChartDataValues(properties.rows); + + const cpdColumns: ColumnModel<CrossPolarDiscriminationDataType>[] = [ + { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, + { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, + { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, + { + property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { + const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); + return <div >{suspectIntervalFlag} </div> + } + } + ]; + + chartPagedData.datasets.forEach(ds => { + cpdColumns.push(addColumnLabels<CrossPolarDiscriminationDataType>(ds.name, ds.columnLabel)); + }); + return ( + <> + {lineChart(chartPagedData)} + <CrossPolarDiscriminationTable idProperty={"_id"} columns={cpdColumns} {...properties} {...actions} /> + </> + ); }; -} -export const CrossPolarDiscrimination = withRouter(connect(mapProps, mapDisp)(CrossPolarDiscriminationComponent)); + /** + * This function gets the performance values for CPD according on the chartjs dataset structure + * which is to be sent to the chart. + */ + private getChartDataValues = (rows: CrossPolarDiscriminationDataType[]): IDataSetsObject => { + const _rows = [...rows]; + sortDataByTimeStamp(_rows); + + const datasets: IDataSet[] = [{ + name: "xpd-min", + label: "xpd-min", + borderColor: '#0e17f3de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "CPD (min)[db]" + }, { + name: "xpd-avg", + label: "xpd-avg", + borderColor: '#08edb6de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "CPD (avg)[db]" + }, { + name: "xpd-max", + label: "xpd-max", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "CPD (max)[db]" + }]; + + _rows.forEach(row => { + datasets.forEach(ds => { + ds.data.push({ + x: row["time-stamp"], + y: row[ds.name as keyof CrossPolarDiscriminationDataType] as string + }); + }); + }); + return { + datasets: datasets + }; + } +} +const CrossPolarDiscrimination = withRouter(connect(mapProps, mapDisp)(CrossPolarDiscriminationComponent)); export default CrossPolarDiscrimination; diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/performanceData.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/performanceData.tsx index e9a373b11..578022db7 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/performanceData.tsx +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/performanceData.tsx @@ -2,22 +2,24 @@ import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; +import { MaterialTable, ColumnType, ColumnModel, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect'; - import { PerformanceDataType } from '../models/performanceDataType'; +import { IDataSet, IDataSetsObject } from '../models/chartTypes'; import { createPerformanceData15minProperties, createPerformanceData15minActions } from '../handlers/performanceData15minHandler'; import { createPerformanceData24hoursProperties, createPerformanceData24hoursActions } from '../handlers/performanceData24hoursHandler'; +import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils'; +import { addColumnLabels } from '../utils/tableUtils'; const mapProps = (state: IApplicationStoreState) => ({ performanceData15minProperties: createPerformanceData15minProperties(state), - performanceData24hoursProperties: createPerformanceData24hoursProperties(state), + performanceData24hoursProperties: createPerformanceData24hoursProperties(state) }); const mapDisp = (dispatcher: IDispatcher) => ({ performanceData15minActions: createPerformanceData15minActions(dispatcher.dispatch), - performanceData24hoursActions: createPerformanceData24hoursActions(dispatcher.dispatch), + performanceData24hoursActions: createPerformanceData24hoursActions(dispatcher.dispatch) }); type PerformanceDataComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & { @@ -31,45 +33,87 @@ const PerformanceDataTable = MaterialTable as MaterialTableCtorType<PerformanceD */ class PerformanceDataComponent extends React.Component<PerformanceDataComponentProps>{ render(): JSX.Element { - if (this.props.selectedTimePeriod == "15min") { - return ( - <PerformanceDataTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "es", title: "ES", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "ses", title: "SES", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "unavailability", title: "UAS", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.performanceData15minProperties} {...this.props.performanceData15minActions} - /> - ); - } else { - return ( - <PerformanceDataTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "es", title: "ES", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "ses", title: "SES", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "unavailability", title: "UAS", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.performanceData24hoursProperties} {...this.props.performanceData24hoursActions} - /> - ); - } + const properties = this.props.selectedTimePeriod === "15min" + ? this.props.performanceData15minProperties + : this.props.performanceData24hoursProperties; + const actions = this.props.selectedTimePeriod === "15min" + ? this.props.performanceData15minActions + : this.props.performanceData24hoursActions; + + const chartPagedData = this.getChartDataValues(properties.rows); + const performanceColumns: ColumnModel<PerformanceDataType>[] = [ + { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, + { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, + { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, + { + property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { + const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); + return <div >{suspectIntervalFlag} </div> + } + } + ]; + + chartPagedData.datasets.forEach(ds => { + performanceColumns.push(addColumnLabels<PerformanceDataType>(ds.name, ds.columnLabel)); + }); + return ( + <> + {lineChart(chartPagedData)} + <PerformanceDataTable idProperty={"_id"} columns={performanceColumns} {...properties} {...actions} /> + </> + ); }; + + /** + * This function gets the performance values for PerformanceData according on the chartjs dataset structure + * which is to be sent to the chart. + */ + private getChartDataValues = (rows: PerformanceDataType[]): IDataSetsObject => { + const _rows = [...rows]; + sortDataByTimeStamp(_rows); + + const datasets: IDataSet[] = [{ + name: "es", + label: "es", + borderColor: '#0e17f3de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "ES" + }, { + name: "ses", + label: "ses", + borderColor: '#08edb6de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "SES" + }, { + name: "unavailability", + label: "unavailability", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Unavailability" + }]; + + _rows.forEach(row => { + datasets.forEach(ds => { + ds.data.push({ + x: row["time-stamp"], + y: row[ds.name as keyof PerformanceDataType] as string + }); + }); + }); + return { + datasets: datasets + }; + } } -export const PerformanceData = withRouter(connect(mapProps, mapDisp)(PerformanceDataComponent)); +const PerformanceData = withRouter(connect(mapProps, mapDisp)(PerformanceDataComponent)); export default PerformanceData; diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/receiveLevel.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/receiveLevel.tsx index 5f62e585a..b893ce149 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/receiveLevel.tsx +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/receiveLevel.tsx @@ -2,23 +2,25 @@ import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; +import { MaterialTable, ColumnType, ColumnModel, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect'; import { ReceiveLevelDataType } from '../models/receiveLevelDataType'; -import { createReceiveLevel15minProperties, createReceiveLevel15minActions, receiveLevel15minReloadAction } from '../handlers/receiveLevel15minHandler'; -import { createReceiveLevel24hoursProperties, createReceiveLevel24hoursActions, receiveLevel24hoursReloadAction } from '../handlers/receiveLevel24hoursHandler'; - +import { IDataSet, IDataSetsObject } from '../models/chartTypes'; +import { createReceiveLevel15minProperties, createReceiveLevel15minActions } from '../handlers/receiveLevel15minHandler'; +import { createReceiveLevel24hoursProperties, createReceiveLevel24hoursActions } from '../handlers/receiveLevel24hoursHandler'; +import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils'; +import { addColumnLabels } from '../utils/tableUtils'; const mapProps = (state: IApplicationStoreState) => ({ receiveLevel15minProperties: createReceiveLevel15minProperties(state), - receiveLevel24hoursProperties: createReceiveLevel24hoursProperties(state), + receiveLevel24hoursProperties: createReceiveLevel24hoursProperties(state) }); const mapDisp = (dispatcher: IDispatcher) => ({ receiveLevel15minActions: createReceiveLevel15minActions(dispatcher.dispatch), - receiveLevel24hoursActions: createReceiveLevel24hoursActions(dispatcher.dispatch), + receiveLevel24hoursActions: createReceiveLevel24hoursActions(dispatcher.dispatch) }); type ReceiveLevelComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & { @@ -32,43 +34,88 @@ const ReceiveLevelTable = MaterialTable as MaterialTableCtorType<ReceiveLevelDat */ class ReceiveLevelComponent extends React.Component<ReceiveLevelComponentProps>{ render(): JSX.Element { - if (this.props.selectedTimePeriod == "15min") { - return ( - <ReceiveLevelTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "rx-level-min", title: "Rx min", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "rx-level-avg", title: "Rx avg", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "rx-level-max", title: "Rx max", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.receiveLevel15minProperties} {...this.props.receiveLevel15minActions} /> - ); - } else { - return ( - <ReceiveLevelTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "rx-level-min", title: "Rx min", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "rx-level-avg", title: "Rx avg", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "rx-level-max", title: "Rx max", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.receiveLevel24hoursProperties} {...this.props.receiveLevel24hoursActions} /> - ); - } + const properties = this.props.selectedTimePeriod === "15min" + ? this.props.receiveLevel15minProperties + : this.props.receiveLevel24hoursProperties; + const actions = this.props.selectedTimePeriod === "15min" + ? this.props.receiveLevel15minActions + : this.props.receiveLevel24hoursActions; + + const chartPagedData = this.getChartDataValues(properties.rows); + const receiveLevelColumns: ColumnModel<ReceiveLevelDataType>[] = [ + { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, + { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, + { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, + { + property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { + const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); + return <div >{suspectIntervalFlag} </div> + } + } + ]; + + chartPagedData.datasets.forEach(ds => { + receiveLevelColumns.push(addColumnLabels<ReceiveLevelDataType>(ds.name, ds.columnLabel)); + }); + + return ( + <> + {lineChart(chartPagedData)} + <ReceiveLevelTable idProperty={"_id"} columns={receiveLevelColumns} {...properties} {...actions} /> + </> + ); }; + + /** + * This function gets the performance values for ReceiveLevel according on the chartjs dataset structure + * which is to be sent to the chart. + */ + private getChartDataValues = (rows: ReceiveLevelDataType[]): IDataSetsObject => { + const _rows = [...rows]; + sortDataByTimeStamp(_rows); + + const datasets: IDataSet[] = [{ + name: "rx-level-min", + label: "rx-level-min", + borderColor: '#0e17f3de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Rx min" + }, { + name: "rx-level-avg", + label: "rx-level-avg", + borderColor: '#08edb6de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Rx avg" + }, { + name: "rx-level-max", + label: "rx-level-max", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Rx max" + }]; + + _rows.forEach(row => { + datasets.forEach(ds => { + ds.data.push({ + x: row["time-stamp"], + y: row[ds.name as keyof ReceiveLevelDataType] as string + }); + }); + }); + return { + datasets: datasets + }; + } } -export const ReceiveLevel = withRouter(connect(mapProps, mapDisp)(ReceiveLevelComponent)); +const ReceiveLevel = withRouter(connect(mapProps, mapDisp)(ReceiveLevelComponent)); export default ReceiveLevel; diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/signalToInterference.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/signalToInterference.tsx index bd612822e..90ed1a9cb 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/signalToInterference.tsx +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/signalToInterference.tsx @@ -2,22 +2,25 @@ import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; +import { MaterialTable, ColumnType, ColumnModel, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect'; import { SignalToInterferenceDataType } from '../models/signalToInteferenceDataType'; +import { IDataSet, IDataSetsObject } from '../models/chartTypes'; import { createSignalToInterference15minProperties, createSignalToInterference15minActions } from '../handlers/signalToInterference15minHandler'; import { createSignalToInterference24hoursProperties, createSignalToInterference24hoursActions } from '../handlers/signalToInterference24hoursHandler'; +import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils'; +import { addColumnLabels } from '../utils/tableUtils'; const mapProps = (state: IApplicationStoreState) => ({ signalToInterference15minProperties: createSignalToInterference15minProperties(state), - signalToInterference24hoursProperties: createSignalToInterference24hoursProperties(state), + signalToInterference24hoursProperties: createSignalToInterference24hoursProperties(state) }); const mapDisp = (dispatcher: IDispatcher) => ({ signalToInterference15minActions: createSignalToInterference15minActions(dispatcher.dispatch), - signalToInterference24hoursActions: createSignalToInterference24hoursActions(dispatcher.dispatch), + signalToInterference24hoursActions: createSignalToInterference24hoursActions(dispatcher.dispatch) }); type SignalToInterferenceComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & { @@ -31,45 +34,91 @@ const SignalToInterferenceTable = MaterialTable as MaterialTableCtorType<SignalT */ class SignalToInterferenceComponent extends React.Component<SignalToInterferenceComponentProps>{ render(): JSX.Element { - if (this.props.selectedTimePeriod == "15min") { - return ( - <SignalToInterferenceTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "snir-min", title: "SINR (min)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "snir-avg", title: "SINR (avg)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "snir-max", title: "SINR (max)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.signalToInterference15minProperties} {...this.props.signalToInterference15minActions} - /> - ); - } else { - return ( - <SignalToInterferenceTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "snir-min", title: "SINR (min)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "snir-avg", title: "SINR (avg)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "snir-max", title: "SINR (max)[db]", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.signalToInterference24hoursProperties} {...this.props.signalToInterference24hoursActions} + const properties = this.props.selectedTimePeriod === "15min" + ? this.props.signalToInterference15minProperties + : this.props.signalToInterference24hoursProperties; + const actions = this.props.selectedTimePeriod === "15min" + ? this.props.signalToInterference15minActions + : this.props.signalToInterference24hoursActions; + + const chartPagedData = this.getChartDataValues(properties.rows); + + const sinrColumns: ColumnModel<SignalToInterferenceDataType>[] = [ + + { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, + { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, + { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, + { + property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { + const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); + return <div >{suspectIntervalFlag} </div> + } + } + ]; + + chartPagedData.datasets.forEach(ds => { + sinrColumns.push(addColumnLabels<SignalToInterferenceDataType>(ds.name, ds.columnLabel)); + }); + return ( + <> + {lineChart(chartPagedData)} + <SignalToInterferenceTable idProperty={"_id"} columns={sinrColumns} {...properties} {...actions} /> - ); - } + </> + ); }; + + /** + * This function gets the performance values for SINR according on the chartjs dataset structure + * which is to be sent to the chart. + */ + + private getChartDataValues = (rows: SignalToInterferenceDataType[]): IDataSetsObject => { + const _rows = [...rows]; + sortDataByTimeStamp(_rows); + + const datasets: IDataSet[] = [{ + name: "snir-min", + label: "snir-min", + borderColor: '#0e17f3de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "SINR (min)[db]" + }, { + name: "snir-avg", + label: "snir-avg", + borderColor: '#08edb6de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "SINR (avg)[db]" + }, { + name: "snir-max", + label: "snir-max", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "SINR (max)[db]" + }]; + + _rows.forEach(row => { + datasets.forEach(ds => { + ds.data.push({ + x: row["time-stamp"], + y: row[ds.name as keyof SignalToInterferenceDataType] as string + }); + }); + }); + return { + datasets: datasets + }; + } } -export const SignalToInterference = withRouter(connect(mapProps, mapDisp)(SignalToInterferenceComponent)); +const SignalToInterference = withRouter(connect(mapProps, mapDisp)(SignalToInterferenceComponent)); export default SignalToInterference; diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/temperature.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/temperature.tsx index 1496396aa..f105bfd46 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/temperature.tsx +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/temperature.tsx @@ -2,23 +2,25 @@ import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; +import { MaterialTable, ColumnType, ColumnModel, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect'; import { TemperatureDataType } from '../models/temperatureDataType'; -import { createTemperature15minProperties, createTemperature15minActions, temperature15minReloadAction } from '../handlers/temperature15minHandler'; -import { createTemperature24hoursProperties, createTemperature24hoursActions, temperature24hoursReloadAction } from '../handlers/temperature24hoursHandler'; - +import { IDataSet, IDataSetsObject } from '../models/chartTypes'; +import { createTemperature15minProperties, createTemperature15minActions } from '../handlers/temperature15minHandler'; +import { createTemperature24hoursProperties, createTemperature24hoursActions } from '../handlers/temperature24hoursHandler'; +import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils'; +import { addColumnLabels } from '../utils/tableUtils'; const mapProps = (state: IApplicationStoreState) => ({ temperature15minProperties: createTemperature15minProperties(state), - temperature24hoursProperties: createTemperature24hoursProperties(state), + temperature24hoursProperties: createTemperature24hoursProperties(state) }); const mapDisp = (dispatcher: IDispatcher) => ({ temperature15minActions: createTemperature15minActions(dispatcher.dispatch), - temperature24hoursActions: createTemperature24hoursActions(dispatcher.dispatch), + temperature24hoursActions: createTemperature24hoursActions(dispatcher.dispatch) }); type TemperatureComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & { @@ -32,43 +34,88 @@ const TemperatureTable = MaterialTable as MaterialTableCtorType<TemperatureDataT */ class TemperatureComponent extends React.Component<TemperatureComponentProps>{ render(): JSX.Element { - if (this.props.selectedTimePeriod == "15min") { - return ( - <TemperatureTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "rf-temp-min", title: "Rx min", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "rf-temp-avg", title: "Rx avg", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "rf-temp-max", title: "Rx max", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.temperature15minProperties} {...this.props.temperature15minActions} /> - ); - } else { - return ( - <TemperatureTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "rf-temp-min", title: "Rx min", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "rf-temp-avg", title: "Rx avg", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "rf-temp-max", title: "Rx max", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.temperature24hoursProperties} {...this.props.temperature24hoursActions} /> - ); - } + const properties = this.props.selectedTimePeriod === "15min" + ? this.props.temperature15minProperties + : this.props.temperature24hoursProperties; + const actions = this.props.selectedTimePeriod === "15min" + ? this.props.temperature15minActions + : this.props.temperature24hoursActions; + + const chartPagedData = this.getChartDataValues(properties.rows); + const temperatureColumns: ColumnModel<TemperatureDataType>[] = [ + { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, + { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, + { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, + { + property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { + const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); + return <div >{suspectIntervalFlag} </div> + } + } + ]; + + chartPagedData.datasets.forEach(ds => { + temperatureColumns.push(addColumnLabels<TemperatureDataType>(ds.name, ds.columnLabel)); + }); + return ( + <> + {lineChart(chartPagedData)} + <TemperatureTable idProperty={"_id"} columns={temperatureColumns} {...properties} {...actions} /> + </> + ); }; + + /** + * This function gets the performance values for Temperature according on the chartjs dataset structure + * which is to be sent to the chart. + */ + + private getChartDataValues = (rows: TemperatureDataType[]): IDataSetsObject => { + const _rows = [...rows]; + sortDataByTimeStamp(_rows); + + const datasets: IDataSet[] = [{ + name: "rf-temp-min", + label: "rf-temp-min", + borderColor: '#0e17f3de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Rf Temp Min[deg C]" + }, { + name: "rf-temp-avg", + label: "rf-temp-avg", + borderColor: '#08edb6de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Rf Temp Avg[deg C]" + }, { + name: "rf-temp-max", + label: "rf-temp-max", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Rf Temp Max[deg C]" + }]; + + _rows.forEach(row => { + datasets.forEach(ds => { + ds.data.push({ + x: row["time-stamp"], + y: row[ds.name as keyof TemperatureDataType] as string + }); + }); + }); + return { + datasets: datasets + }; + } } -export const Temperature = withRouter(connect(mapProps, mapDisp)(TemperatureComponent)); +const Temperature = withRouter(connect(mapProps, mapDisp)(TemperatureComponent)); export default Temperature; diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/transmissionPower.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/transmissionPower.tsx index 10c25874a..088a83eed 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/transmissionPower.tsx +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/components/transmissionPower.tsx @@ -2,23 +2,25 @@ import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; +import { MaterialTable, ColumnType, ColumnModel, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect'; import { TransmissionPowerDataType } from '../models/transmissionPowerDataType'; +import { IDataSet, IDataSetsObject } from '../models/chartTypes'; import { createTransmissionPower15minProperties, createTransmissionPower15minActions } from '../handlers/transmissionPower15minHandler'; import { createTransmissionPower24hoursProperties, createTransmissionPower24hoursActions } from '../handlers/transmissionPower24hoursHandler'; - +import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils'; +import { addColumnLabels } from '../utils/tableUtils'; const mapProps = (state: IApplicationStoreState) => ({ transmissionPower15minProperties: createTransmissionPower15minProperties(state), - transmissionPower24hoursProperties: createTransmissionPower24hoursProperties(state), + transmissionPower24hoursProperties: createTransmissionPower24hoursProperties(state) }); const mapDisp = (dispatcher: IDispatcher) => ({ transmissionPower15minActions: createTransmissionPower15minActions(dispatcher.dispatch), - transmissionPower24hoursActions: createTransmissionPower24hoursActions(dispatcher.dispatch), + transmissionPower24hoursActions: createTransmissionPower24hoursActions(dispatcher.dispatch) }); type TransmissionPowerComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & { @@ -32,43 +34,90 @@ const TransmissionPowerTable = MaterialTable as MaterialTableCtorType<Transmissi */ class TransmissionPowerComponent extends React.Component<TransmissionPowerComponentProps>{ render(): JSX.Element { - if (this.props.selectedTimePeriod == "15min") { - return ( - <TransmissionPowerTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "tx-level-min", title: "Tx min", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "tx-level-avg", title: "Tx avg", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "tx-level-max", title: "Tx max", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.transmissionPower15minProperties} {...this.props.transmissionPower15minActions} /> - ); - } else { - return ( - <TransmissionPowerTable idProperty={"_id"} columns={[ - { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, - { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, - { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, - { - property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { - const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); - return <div >{suspectIntervalFlag} </div> - } - }, - { property: "tx-level-min", title: "Tx min", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "tx-level-avg", title: "Tx avg", type: ColumnType.text, disableFilter: true, disableSorting: true }, - { property: "tx-level-max", title: "Tx max", type: ColumnType.text, disableFilter: true, disableSorting: true }, - ]} {...this.props.transmissionPower24hoursProperties} {...this.props.transmissionPower24hoursActions} /> - ); - } + const properties = this.props.selectedTimePeriod === "15min" + ? this.props.transmissionPower15minProperties + : this.props.transmissionPower24hoursProperties; + const actions = this.props.selectedTimePeriod === "15min" + ? this.props.transmissionPower15minActions + : this.props.transmissionPower24hoursActions; + + const chartPagedData = this.getChartDataValues(properties.rows); + + const transmissionColumns: ColumnModel<TransmissionPowerDataType>[] = [ + { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text }, + { property: "scanner-id", title: "Scanner ID", type: ColumnType.text }, + { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true }, + { + property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => { + const suspectIntervalFlag = rowData["suspect-interval-flag"].toString(); + return <div >{suspectIntervalFlag} </div> + } + } + ]; + + chartPagedData.datasets.forEach(ds => { + transmissionColumns.push(addColumnLabels<TransmissionPowerDataType>(ds.name, ds.columnLabel)); + }); + + return ( + <> + {lineChart(chartPagedData)} + <TransmissionPowerTable idProperty={"_id"} columns={transmissionColumns} {...properties} {...actions} /> + </> + ); }; + + /** + * This function gets the performance values for TransmissionPower according on the chartjs dataset structure + * which is to be sent to the chart. + */ + + private getChartDataValues = (rows: TransmissionPowerDataType[]): IDataSetsObject => { + const _rows = [...rows]; + sortDataByTimeStamp(_rows); + + const datasets: IDataSet[] = [{ + name: "tx-level-min", + label: "tx-level-min", + borderColor: '#0e17f3de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Tx min" + }, { + name: "tx-level-avg", + label: "tx-level-avg", + borderColor: '#08edb6de', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Tx avg" + }, { + name: "tx-level-max", + label: "tx-level-max", + borderColor: '#b308edde', + bezierCurve: false, + lineTension: 0, + fill: false, + data: [], + columnLabel: "Tx max" + }]; + + _rows.forEach(row => { + datasets.forEach(ds => { + ds.data.push({ + x: row["time-stamp"], + y: row[ds.name as keyof TransmissionPowerDataType] as string + }); + }); + }); + return { + datasets: datasets + }; + } } -export const TransmissionPower = withRouter(connect(mapProps, mapDisp)(TransmissionPowerComponent)); +const TransmissionPower = withRouter(connect(mapProps, mapDisp)(TransmissionPowerComponent)); export default TransmissionPower; |