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 { AdaptiveModulationDataType } from '../models/adaptiveModulationDataType';
27 import { IDataSet, IDataSetsObject } from '../models/chartTypes';
28 import { createAdaptiveModulationProperties, createAdaptiveModulationActions } from '../handlers/adaptiveModulationHandler';
29 import { lineChart, sortDataByTimeStamp } from '../utils/chartUtils';
30 import { addColumnLabels } from '../utils/tableUtils';
32 const mapProps = (state: IApplicationStoreState) => ({
33 adaptiveModulationProperties: createAdaptiveModulationProperties(state),
36 const mapDisp = (dispatcher: IDispatcher) => ({
37 adaptiveModulationActions: createAdaptiveModulationActions(dispatcher.dispatch),
40 type AdaptiveModulationComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & {
41 selectedTimePeriod: string
44 const AdaptiveModulationTable = MaterialTable as MaterialTableCtorType<AdaptiveModulationDataType>;
47 * The Component which gets the adaptiveModulation data from the database based on the selected time period.
49 class AdaptiveModulationComponent extends React.Component<AdaptiveModulationComponentProps>{
50 render(): JSX.Element {
51 const properties = this.props.adaptiveModulationProperties;
52 const actions = this.props.adaptiveModulationActions;
54 const chartPagedData = this.getChartDataValues(properties.rows);
55 const adaptiveModulationColumns: ColumnModel<AdaptiveModulationDataType>[] = [
56 { property: "radioSignalId", title: "Radio signal", type: ColumnType.text },
57 { property: "scannerId", title: "Scanner ID", type: ColumnType.text },
58 { property: "utcTimeStamp", title: "End Time", type: ColumnType.text, disableFilter: true },
60 property: "suspectIntervalFlag", title: "Suspect Interval", type: ColumnType.custom, customControl: ({ rowData }) => {
61 const suspectIntervalFlag = rowData["suspectIntervalFlag"].toString();
62 return <div >{suspectIntervalFlag} </div>
66 chartPagedData.datasets.forEach(ds => {
67 adaptiveModulationColumns.push(addColumnLabels<AdaptiveModulationDataType>(ds.name, ds.columnLabel));
72 {lineChart(chartPagedData)}
73 <AdaptiveModulationTable idProperty={"_id"} columns={adaptiveModulationColumns} {...properties} {...actions} />
79 * This function gets the performance values for Adaptive modulation according on the chartjs dataset structure
80 * which is to be sent to the chart.
83 private getChartDataValues = (rows: AdaptiveModulationDataType[]): IDataSetsObject => {
84 const _rows = [...rows];
85 sortDataByTimeStamp(_rows);
87 const datasets: IDataSet[] = [{
90 borderColor: '#62a309fc',
99 borderColor: '#62a309fc',
106 name: "time2StatesL",
108 borderColor: '#62a309fc',
113 columnLabel: "QAM2L",
115 name: "time4StatesS",
117 borderColor: '#b308edde',
122 columnLabel: "QAM4S",
126 borderColor: '#b308edde',
133 name: "time4StatesL",
135 borderColor: '#b308edde',
140 columnLabel: "QAM4L",
142 name: "time16StatesS",
144 borderColor: '#9b15e2',
149 columnLabel: "QAM16S",
151 name: "time16States",
153 borderColor: '#9b15e2',
158 columnLabel: "QAM16",
160 name: "time16StatesL",
162 borderColor: '#9b15e2',
167 columnLabel: "QAM16L",
169 name: "time32StatesS",
171 borderColor: '#2704f5f0',
176 columnLabel: "QAM32S",
178 name: "time32States",
180 borderColor: '#2704f5f0',
185 columnLabel: "QAM32",
187 name: "time32StatesL",
189 borderColor: '#2704f5f0',
194 columnLabel: "QAM32L",
196 name: "time64StatesS",
198 borderColor: '#347692',
203 columnLabel: "QAM64S",
205 name: "time64States",
207 borderColor: '#347692',
212 columnLabel: "QAM64",
214 name: "time64StatesL",
216 borderColor: '#347692',
221 columnLabel: "QAM64L",
223 name: "time128StatesS",
225 borderColor: '#885e22',
230 columnLabel: "QAM128S",
232 name: "time128States",
234 borderColor: '#885e22',
239 columnLabel: "QAM128",
241 name: "time128StatesL",
243 borderColor: '#885e22',
248 columnLabel: "QAM128L",
250 name: "time256StatesS",
252 borderColor: '#de07807a',
257 columnLabel: "QAM256S",
259 name: "time256States",
261 borderColor: '#de07807a',
266 columnLabel: "QAM256",
268 name: "time256StatesL",
270 borderColor: '#de07807a',
275 columnLabel: "QAM256L",
277 name: "time512StatesS",
279 borderColor: '#8fdaacde',
284 columnLabel: "QAM512S",
286 name: "time512States",
288 borderColor: '#8fdaacde',
293 columnLabel: "QAM512",
296 name: "time512StatesL",
298 borderColor: '#8fdaacde',
303 columnLabel: "QAM512L",
306 name: "time1024StatesS",
308 borderColor: '#435b22',
313 columnLabel: "QAM1024S",
316 name: "time1024States",
318 borderColor: '#435b22',
323 columnLabel: "QAM1024",
326 name: "time1024StatesL",
328 borderColor: '#435b22',
333 columnLabel: "QAM1024L",
335 name: "time2048StatesS",
337 borderColor: '#e87a5b',
342 columnLabel: "QAM2048S",
344 name: "time2048States",
346 borderColor: '#e87a5b',
351 columnLabel: "QAM2048",
353 name: "time2048StatesL",
355 borderColor: '#e87a5b',
360 columnLabel: "QAM2048L",
362 name: "time4096StatesS",
364 borderColor: '#5be878',
369 columnLabel: "QAM4096S",
371 name: "time4096States",
373 borderColor: '#5be878',
378 columnLabel: "QAM4096",
380 name: "time4096StatesL",
382 borderColor: '#5be878',
387 columnLabel: "QAM4096L",
389 name: "time8192StatesS",
391 borderColor: '#cb5be8',
396 columnLabel: "QAM8192S",
398 name: "time8192States",
400 borderColor: '#cb5be8',
405 columnLabel: "QAM8192",
407 name: "time8192StatesL",
409 borderColor: '#cb5be8',
414 columnLabel: "QAM8192L",
418 _rows.forEach(row => {
419 datasets.forEach(ds => {
421 x: row["utcTimeStamp" as keyof AdaptiveModulationDataType] as string,
422 y: row[ds.name as keyof AdaptiveModulationDataType] as string
432 const AdaptiveModulation = withRouter(connect(mapProps, mapDisp)(AdaptiveModulationComponent));
433 export default AdaptiveModulation;