1 import * as React from 'react';
3 import { withRouter, RouteComponentProps } from 'react-router-dom';
5 import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table';
6 import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore';
7 import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect';
9 import { PerformanceDataType } from '../models/performanceDataType';
10 import { createPerformanceData15minProperties, createPerformanceData15minActions } from '../handlers/performanceData15minHandler';
11 import { createPerformanceData24hoursProperties, createPerformanceData24hoursActions } from '../handlers/performanceData24hoursHandler';
13 const mapProps = (state: IApplicationStoreState) => ({
14 performanceData15minProperties: createPerformanceData15minProperties(state),
15 performanceData24hoursProperties: createPerformanceData24hoursProperties(state),
18 const mapDisp = (dispatcher: IDispatcher) => ({
19 performanceData15minActions: createPerformanceData15minActions(dispatcher.dispatch),
20 performanceData24hoursActions: createPerformanceData24hoursActions(dispatcher.dispatch),
23 type PerformanceDataComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & {
24 selectedTimePeriod: string
27 const PerformanceDataTable = MaterialTable as MaterialTableCtorType<PerformanceDataType>;
30 * The Component which gets the performance data from the database based on the selected time period.
32 class PerformanceDataComponent extends React.Component<PerformanceDataComponentProps>{
33 render(): JSX.Element {
34 if (this.props.selectedTimePeriod == "15min") {
36 <PerformanceDataTable idProperty={"_id"} columns={[
37 { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text },
38 { property: "scanner-id", title: "Scanner ID", type: ColumnType.text },
39 { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true },
41 property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => {
42 const suspectIntervalFlag = rowData["suspect-interval-flag"].toString();
43 return <div >{suspectIntervalFlag} </div>
46 { property: "es", title: "ES", type: ColumnType.text, disableFilter: true, disableSorting: true },
47 { property: "ses", title: "SES", type: ColumnType.text, disableFilter: true, disableSorting: true },
48 { property: "unavailability", title: "UAS", type: ColumnType.text, disableFilter: true, disableSorting: true },
49 ]} {...this.props.performanceData15minProperties} {...this.props.performanceData15minActions}
54 <PerformanceDataTable idProperty={"_id"} columns={[
55 { property: "radio-signal-id", title: "Radio signal", type: ColumnType.text },
56 { property: "scanner-id", title: "Scanner ID", type: ColumnType.text },
57 { property: "time-stamp", title: "End Time", type: ColumnType.text, disableFilter: true },
59 property: "suspect-interval-flag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => {
60 const suspectIntervalFlag = rowData["suspect-interval-flag"].toString();
61 return <div >{suspectIntervalFlag} </div>
64 { property: "es", title: "ES", type: ColumnType.text, disableFilter: true, disableSorting: true },
65 { property: "ses", title: "SES", type: ColumnType.text, disableFilter: true, disableSorting: true },
66 { property: "unavailability", title: "UAS", type: ColumnType.text, disableFilter: true, disableSorting: true },
67 ]} {...this.props.performanceData24hoursProperties} {...this.props.performanceData24hoursActions}
74 export const PerformanceData = withRouter(connect(mapProps, mapDisp)(PerformanceDataComponent));
75 export default PerformanceData;