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, AdaptiveModulationDatabaseDataType } 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';
31 import ToggleContainer from './toggleContainer';
32 import { SetSubViewAction, SetFilterVisibility } from '../actions/toggleActions';
34 const mapProps = (state: IApplicationStoreState) => ({
35 adaptiveModulationProperties: createAdaptiveModulationProperties(state),
36 currentView: state.performanceHistory.subViews.adaptiveModulation.subView,
37 isFilterVisible: state.performanceHistory.subViews.adaptiveModulation.isFilterVisible,
38 existingFilter: state.performanceHistory.adaptiveModulation.filter
41 const mapDisp = (dispatcher: IDispatcher) => ({
42 adaptiveModulationActions: createAdaptiveModulationActions(dispatcher.dispatch),
43 setSubView: (value: "chart" | "table") => dispatcher.dispatch(new SetSubViewAction("adaptiveModulation", value)),
44 toggleFilterButton: (value: boolean) => { dispatcher.dispatch(new SetFilterVisibility("adaptiveModulation", value)) },
47 type AdaptiveModulationComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp> & {
48 selectedTimePeriod: string
51 const AdaptiveModulationTable = MaterialTable as MaterialTableCtorType<AdaptiveModulationDataType>;
54 * The Component which gets the adaptiveModulation data from the database based on the selected time period.
56 class AdaptiveModulationComponent extends React.Component<AdaptiveModulationComponentProps>{
58 onToggleFilterButton = () => {
59 this.props.toggleFilterButton(!this.props.isFilterVisible);
62 onChange = (value: "chart" | "table") => {
63 this.props.setSubView(value);
66 onFilterChanged = (property: string, filterTerm: string) => {
67 this.props.adaptiveModulationActions.onFilterChanged(property, filterTerm);
68 if (!this.props.adaptiveModulationProperties.showFilter)
69 this.props.adaptiveModulationActions.onToggleFilter(false);
72 render(): JSX.Element {
73 const properties = this.props.adaptiveModulationProperties;
74 const actions = this.props.adaptiveModulationActions;
76 const chartPagedData = this.getChartDataValues(properties.rows);
77 const adaptiveModulationColumns: ColumnModel<AdaptiveModulationDataType>[] = [
78 { property: "radioSignalId", title: "Radio signal", type: ColumnType.text },
79 { property: "scannerId", title: "Scanner ID", type: ColumnType.text },
80 { property: "timeStamp", title: "End Time", type: ColumnType.text },
82 property: "suspectIntervalFlag", title: "Suspect Interval", type: ColumnType.boolean
85 chartPagedData.datasets.forEach(ds => {
86 adaptiveModulationColumns.push(addColumnLabels<AdaptiveModulationDataType>(ds.name, ds.columnLabel));
91 <ToggleContainer onToggleFilterButton={this.onToggleFilterButton} showFilter={this.props.isFilterVisible} existingFilter={this.props.adaptiveModulationProperties.filter} onFilterChanged={this.onFilterChanged} selectedValue={this.props.currentView} onChange={this.onChange}>
92 {lineChart(chartPagedData)}
93 <AdaptiveModulationTable stickyHeader idProperty={"_id"} tableId="adaptive-modulation-table" columns={adaptiveModulationColumns} {...properties} {...actions} />
100 * This function gets the performance values for Adaptive modulation according on the chartjs dataset structure
101 * which is to be sent to the chart.
104 private getChartDataValues = (rows: AdaptiveModulationDataType[]): IDataSetsObject => {
105 const _rows = [...rows];
106 sortDataByTimeStamp(_rows);
108 const datasets: IDataSet[] = [{
109 name: "time2StatesS",
111 borderColor: '#62a309fc',
116 columnLabel: "QAM2S",
120 borderColor: '#62a309fc',
127 name: "time2StatesL",
129 borderColor: '#62a309fc',
134 columnLabel: "QAM2L",
136 name: "time4StatesS",
138 borderColor: '#b308edde',
143 columnLabel: "QAM4S",
147 borderColor: '#b308edde',
154 name: "time4StatesL",
156 borderColor: '#b308edde',
161 columnLabel: "QAM4L",
163 name: "time16StatesS",
165 borderColor: '#9b15e2',
170 columnLabel: "QAM16S",
172 name: "time16States",
174 borderColor: '#9b15e2',
179 columnLabel: "QAM16",
181 name: "time16StatesL",
183 borderColor: '#9b15e2',
188 columnLabel: "QAM16L",
190 name: "time32StatesS",
192 borderColor: '#2704f5f0',
197 columnLabel: "QAM32S",
199 name: "time32States",
201 borderColor: '#2704f5f0',
206 columnLabel: "QAM32",
208 name: "time32StatesL",
210 borderColor: '#2704f5f0',
215 columnLabel: "QAM32L",
217 name: "time64StatesS",
219 borderColor: '#347692',
224 columnLabel: "QAM64S",
226 name: "time64States",
228 borderColor: '#347692',
233 columnLabel: "QAM64",
235 name: "time64StatesL",
237 borderColor: '#347692',
242 columnLabel: "QAM64L",
244 name: "time128StatesS",
246 borderColor: '#885e22',
251 columnLabel: "QAM128S",
253 name: "time128States",
255 borderColor: '#885e22',
260 columnLabel: "QAM128",
262 name: "time128StatesL",
264 borderColor: '#885e22',
269 columnLabel: "QAM128L",
271 name: "time256StatesS",
273 borderColor: '#de07807a',
278 columnLabel: "QAM256S",
280 name: "time256States",
282 borderColor: '#de07807a',
287 columnLabel: "QAM256",
289 name: "time256StatesL",
291 borderColor: '#de07807a',
296 columnLabel: "QAM256L",
298 name: "time512StatesS",
300 borderColor: '#8fdaacde',
305 columnLabel: "QAM512S",
307 name: "time512States",
309 borderColor: '#8fdaacde',
314 columnLabel: "QAM512",
317 name: "time512StatesL",
319 borderColor: '#8fdaacde',
324 columnLabel: "QAM512L",
327 name: "time1024StatesS",
329 borderColor: '#435b22',
334 columnLabel: "QAM1024S",
337 name: "time1024States",
339 borderColor: '#435b22',
344 columnLabel: "QAM1024",
347 name: "time1024StatesL",
349 borderColor: '#435b22',
354 columnLabel: "QAM1024L",
356 name: "time2048StatesS",
358 borderColor: '#e87a5b',
363 columnLabel: "QAM2048S",
365 name: "time2048States",
367 borderColor: '#e87a5b',
372 columnLabel: "QAM2048",
374 name: "time2048StatesL",
376 borderColor: '#e87a5b',
381 columnLabel: "QAM2048L",
383 name: "time4096StatesS",
385 borderColor: '#5be878',
390 columnLabel: "QAM4096S",
392 name: "time4096States",
394 borderColor: '#5be878',
399 columnLabel: "QAM4096",
401 name: "time4096StatesL",
403 borderColor: '#5be878',
408 columnLabel: "QAM4096L",
410 name: "time8192StatesS",
412 borderColor: '#cb5be8',
417 columnLabel: "QAM8192S",
419 name: "time8192States",
421 borderColor: '#cb5be8',
426 columnLabel: "QAM8192",
428 name: "time8192StatesL",
430 borderColor: '#cb5be8',
435 columnLabel: "QAM8192L",
439 _rows.forEach(row => {
440 row.time2StatesS = row.performanceData.time2StatesS
441 row.time2States = row.performanceData.time2States;
442 row.time2StatesL = row.performanceData.time2StatesL;
443 row.time4StatesS = row.performanceData.time4StatesS
444 row.time4States = row.performanceData.time4States;
445 row.time4StatesL = row.performanceData.time4StatesL;
446 row.time16StatesS = row.performanceData.time16StatesS;
447 row.time16States = row.performanceData.time16States;
448 row.time16StatesL = row.performanceData.time16StatesL;
449 row.time32StatesS = row.performanceData.time32StatesS;
450 row.time32States = row.performanceData.time32States;
451 row.time32StatesL = row.performanceData.time32StatesL;
452 row.time64StatesS = row.performanceData.time64StatesS;
453 row.time64States = row.performanceData.time64States;
454 row.time64StatesL = row.performanceData.time64StatesL;
455 row.time128StatesS = row.performanceData.time128StatesS;
456 row.time128States = row.performanceData.time128States;
457 row.time128StatesL = row.performanceData.time128StatesL;
458 row.time256StatesS = row.performanceData.time256StatesS;
459 row.time256States = row.performanceData.time256States;
460 row.time256StatesL = row.performanceData.time256StatesL;
461 row.time512StatesS = row.performanceData.time512StatesS;
462 row.time512States = row.performanceData.time512States;
463 row.time512StatesL = row.performanceData.time512StatesL;
464 row.time1024StatesS = row.performanceData.time1024StatesS;
465 row.time1024States = row.performanceData.time1024States;
466 row.time1024StatesL = row.performanceData.time1024StatesL;
467 row.time2048StatesS = row.performanceData.time2048StatesS;
468 row.time2048States = row.performanceData.time2048States;
469 row.time2048StatesL = row.performanceData.time2048StatesL;
470 row.time4096StatesS = row.performanceData.time4096StatesS;
471 row.time4096States = row.performanceData.time4096States;
472 row.time4096StatesL = row.performanceData.time4096StatesL;
473 row.time8192StatesS = row.performanceData.time8192StatesS;
474 row.time8192States = row.performanceData.time8192States;
475 row.time8192StatesL = row.performanceData.time8192StatesL;
476 datasets.forEach(ds => {
478 x: row["timeStamp" as keyof AdaptiveModulationDataType] as string,
479 y: row.performanceData[ds.name as keyof AdaptiveModulationDatabaseDataType] as string
489 const AdaptiveModulation = withRouter(connect(mapProps, mapDisp)(AdaptiveModulationComponent));
490 export default AdaptiveModulation;