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, SignalToInterferenceDatabaseDataType } 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';
31 import { SetSubViewAction, SetFilterVisibility } from '../actions/toggleActions';
32 import ToggleContainer from './toggleContainer';
34 const mapProps = (state: IApplicationStoreState) => ({
35 signalToInterferenceProperties: createSignalToInterferenceProperties(state),
36 currentView: state.performanceHistory.subViews.SINR.subView,
37 isFilterVisible: state.performanceHistory.subViews.SINR.isFilterVisible,
38 existingFilter: state.performanceHistory.signalToInterference.filter
41 const mapDisp = (dispatcher: IDispatcher) => ({
42 signalToInterferenceActions: createSignalToInterferenceActions(dispatcher.dispatch),
43 setSubView: (value: "chart" | "table") => dispatcher.dispatch(new SetSubViewAction("SINR", value)),
44 toggleFilterButton: (value: boolean) => { dispatcher.dispatch(new SetFilterVisibility("SINR", value)) },
47 type SignalToInterferenceComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & {
48 selectedTimePeriod: string
51 const SignalToInterferenceTable = MaterialTable as MaterialTableCtorType<SignalToInterferenceDataType>;
54 * The Component which gets the signal to interference data from the database based on the selected time period.
56 class SignalToInterferenceComponent extends React.Component<SignalToInterferenceComponentProps>{
58 onToggleFilterButton = () => {
59 this.props.toggleFilterButton(!this.props.isFilterVisible);
62 onChange = (value: "chart" | "table") => {
63 this.props.setSubView(value);
66 render(): JSX.Element {
67 const properties = this.props.signalToInterferenceProperties;
68 const actions = this.props.signalToInterferenceActions;
70 const chartPagedData = this.getChartDataValues(properties.rows);
72 const sinrColumns: ColumnModel<SignalToInterferenceDataType>[] = [
73 { property: "radioSignalId", title: "Radio signal", type: ColumnType.text },
74 { property: "scannerId", title: "Scanner ID", type: ColumnType.text },
75 { property: "timeStamp", title: "End Time", type: ColumnType.text },
77 property: "suspectIntervalFlag", title: "Suspect Interval", type: ColumnType.boolean
81 chartPagedData.datasets.forEach(ds => {
82 sinrColumns.push(addColumnLabels<SignalToInterferenceDataType>(ds.name, ds.columnLabel));
86 <ToggleContainer onToggleFilterButton={this.onToggleFilterButton} showFilter={this.props.isFilterVisible} existingFilter={this.props.signalToInterferenceProperties.filter} onFilterChanged={this.props.signalToInterferenceActions.onFilterChanged} selectedValue={this.props.currentView} onChange={this.onChange}>
87 {lineChart(chartPagedData)}
88 <SignalToInterferenceTable stickyHeader idProperty={"_id"} columns={sinrColumns} {...properties} {...actions}
96 * This function gets the performance values for SINR according on the chartjs dataset structure
97 * which is to be sent to the chart.
100 private getChartDataValues = (rows: SignalToInterferenceDataType[]): IDataSetsObject => {
101 const _rows = [...rows];
102 sortDataByTimeStamp(_rows);
104 const datasets: IDataSet[] = [{
107 borderColor: '#0e17f3de',
112 columnLabel: "SINR (min)[db]"
116 borderColor: '#08edb6de',
121 columnLabel: "SINR (avg)[db]"
125 borderColor: '#b308edde',
130 columnLabel: "SINR (max)[db]"
133 _rows.forEach(row => {
134 row.snirMin = row.performanceData.snirMin;
135 row.snirAvg = row.performanceData.snirAvg;
136 row.snirMax = row.performanceData.snirMax;
137 datasets.forEach(ds => {
139 x: row["timeStamp" as keyof SignalToInterferenceDataType] as string,
140 y: row.performanceData[ds.name as keyof SignalToInterferenceDatabaseDataType] as string
150 const SignalToInterference = withRouter(connect(mapProps, mapDisp)(SignalToInterferenceComponent));
151 export default SignalToInterference;