2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 import * as React from 'react';
20 import { withRouter, RouteComponentProps } from 'react-router-dom';
22 import { MaterialTable, ColumnType, ColumnModel, MaterialTableCtorType } from '../../../../framework/src/components/material-table';
23 import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore';
24 import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect';
26 import { SignalToInterferenceDataType } from '../models/signalToInteferenceDataType';
27 import { IDataSet, IDataSetsObject } from '../models/chartTypes';
28 import { createSignalToInterferenceProperties, createSignalToInterferenceActions } from '../handlers/signalToInterferenceHandler';
29 import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils';
30 import { addColumnLabels } from '../utils/tableUtils';
32 const mapProps = (state: IApplicationStoreState) => ({
33 signalToInterferenceProperties: createSignalToInterferenceProperties(state),
36 const mapDisp = (dispatcher: IDispatcher) => ({
37 signalToInterferenceActions: createSignalToInterferenceActions(dispatcher.dispatch),
40 type SignalToInterferenceComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & {
41 selectedTimePeriod: string
44 const SignalToInterferenceTable = MaterialTable as MaterialTableCtorType<SignalToInterferenceDataType>;
47 * The Component which gets the signal to interference data from the database based on the selected time period.
49 class SignalToInterferenceComponent extends React.Component<SignalToInterferenceComponentProps>{
50 render(): JSX.Element {
51 const properties = this.props.signalToInterferenceProperties;
52 const actions = this.props.signalToInterferenceActions;
54 const chartPagedData = this.getChartDataValues(properties.rows);
56 const sinrColumns: ColumnModel<SignalToInterferenceDataType>[] = [
57 { property: "radioSignalId", title: "Radio signal", type: ColumnType.text },
58 { property: "scannerId", title: "Scanner ID", type: ColumnType.text },
59 { property: "utcTimeStamp", title: "End Time", type: ColumnType.text, disableFilter: true },
61 property: "suspectIntervalFlag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => {
62 const suspectIntervalFlag = rowData["suspectIntervalFlag"].toString();
63 return <div >{suspectIntervalFlag} </div>
68 chartPagedData.datasets.forEach(ds => {
69 sinrColumns.push(addColumnLabels<SignalToInterferenceDataType>(ds.name, ds.columnLabel));
73 {lineChart(chartPagedData)}
74 <SignalToInterferenceTable idProperty={"_id"} columns={sinrColumns} {...properties} {...actions}
81 * This function gets the performance values for SINR according on the chartjs dataset structure
82 * which is to be sent to the chart.
85 private getChartDataValues = (rows: SignalToInterferenceDataType[]): IDataSetsObject => {
86 const _rows = [...rows];
87 sortDataByTimeStamp(_rows);
89 const datasets: IDataSet[] = [{
92 borderColor: '#0e17f3de',
97 columnLabel: "SINR (min)[db]"
101 borderColor: '#08edb6de',
106 columnLabel: "SINR (avg)[db]"
110 borderColor: '#b308edde',
115 columnLabel: "SINR (max)[db]"
118 _rows.forEach(row => {
119 datasets.forEach(ds => {
121 x: row["utcTimeStamp" as keyof SignalToInterferenceDataType] as string,
122 y: row[ds.name as keyof SignalToInterferenceDataType] as string
132 const SignalToInterference = withRouter(connect(mapProps, mapDisp)(SignalToInterferenceComponent));
133 export default SignalToInterference;