3 * ============LICENSE_START========================================================================
4 * ONAP : ccsdk feature sdnr wt odlux
5 * =================================================================================================
6 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
7 * =================================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software distributed under the License
14 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15 * or implied. See the License for the specific language governing permissions and limitations under
17 * ============LICENSE_END==========================================================================
20 import React, { FC, useEffect, useState } from 'react';
22 import CloseIcon from '@mui/icons-material/Close';
23 import makeStyles from '@mui/styles/makeStyles';
24 import { InputProps } from '@mui/material/Input';
25 import Dialog from '@mui/material/Dialog';
26 import DialogContentText from '@mui/material/DialogContentText';
27 import DialogTitle from '@mui/material/DialogTitle';
28 import DialogContent from '@mui/material/DialogContent';
29 import DialogActions from '@mui/material/DialogActions';
30 import IconButton from '@mui/material/IconButton';
31 import Box from '@mui/material/Box';
33 import MaterialTable, { ColumnType, MaterialTableCtorType } from '../../../../../framework/src/components/material-table';
35 import { AdaptiveModulationTable } from '../model/adaptiveModulationTable';
36 import { Modulation } from '../model/modulation';
37 import Checkbox from '@mui/material/Checkbox';
38 import Button from '@mui/material/Button';
41 type PropTypes = InputProps & {
42 style?: React.CSSProperties;
45 row: AdaptiveModulationTable[];
47 selectedElement: string[];
48 updateModulation(data: string[]): void;
51 const ModulationTable = MaterialTable as MaterialTableCtorType<AdaptiveModulationTable>;
52 const styles = makeStyles({
60 marginTop: 20, position: 'absolute', top: '850px', right: '50px',
63 marginTop: 20, position: 'absolute', top: '850px', right: '160px',
67 export const AdaptiveModulationDialog: FC<PropTypes> = ({ open, row, close, direction, selectedElement, updateModulation }) => {
68 const [selectedElements, setSelectedElements] = useState<string[]>(selectedElement);
69 const classes = styles();
71 const onChange = (element: any) => {
72 const data: { modulation: string; parameters: Modulation | null } = { modulation: element.target.value, parameters: null };
73 setSelectedElements([element.target.value]);
75 if (selectedElements.includes(data.modulation)) {
77 setSelectedElements(selectedElements.filter((i) => i !== data.modulation));
80 var newData = [...selectedElements, data.modulation];
81 setSelectedElements(newData);
86 const onClose = () => {
90 const onSave = () => {
91 updateModulation(selectedElements);
95 setSelectedElements(selectedElement);
100 <Dialog onClose={() => onClose()} open={open} fullWidth maxWidth={'lg'} >
105 <DialogTitle>{direction}</DialogTitle>
110 className={classes.closeIcon}
111 onClick={() => onClose()}
119 <><ModulationTable allowHtmlHeader stickyHeader idProperty="modulation" tableId={`adaptive-modulation-${direction}`} title='Select adaptive modulations'
120 defaultSortColumn='modulation' defaultSortOrder='desc' rows={row}
122 { property: 'modulation', title: 'Supported Modulation', type: ColumnType.text, width: '20px' },
124 property: 'enabledModulation', type: ColumnType.custom, title: 'Enabled Modulation',
125 customControl: ({ rowData }) => (<Checkbox color="secondary" checked={selectedElements.includes(rowData.modulation)}
126 value={rowData.modulation} onClick={(e) => onChange(e)} />),
128 { property: 'dataRate', title: 'Data Rate (Mbit/s)', type: ColumnType.numeric },
129 { property: 'receiverThresholdBER-3', title: 'Thrs BER 10<sup>-3</sup> (dBm)', type: ColumnType.numeric },
130 { property: 'receiverThresholdBER-6', title: 'Thrs BER 10<sup>-6</sup> (dBm)', type: ColumnType.numeric },
131 { property: 'receivedSignalLevel', title: 'RSL (dBm)', type: ColumnType.numeric },
132 { property: 'linkMarginBER-3', title: 'Margin (dB)\n BER 10<sup>-3</sup>', type: ColumnType.numeric },
133 { property: 'linkMarginBER-6', title: 'Margin (dB)\n BER 10<sup>-6</sup>', type: ColumnType.numeric },
134 { property: 'txPowerMin', title: 'txPower\nMin(dBm)', type: ColumnType.numeric },
135 { property: 'txPowerMax', title: 'txPower\nMax(dBm)', type: ColumnType.numeric },
136 { property: 'rainAvailabilityBER-3', title: 'Rain Availability\n BER10<sup>-3</sup>', type: ColumnType.numeric },
137 { property: 'rainAvailabilityBER-6', title: 'Rain Availability\n BER10<sup>-6</sup>', type: ColumnType.numeric },
138 { property: 'multipathAvailabilityBER-3', title: 'multipath Fading\n BER10<sup>-3</sup>', type: ColumnType.numeric },
139 { property: 'multipathAvailabilityBER-6', title: 'multipath Fading\n BER10<sup>-6</sup>', type: ColumnType.numeric },
142 <Button variant="contained" color="primary" onClick={() => onClose()} className={classes.closeButton}>
145 <Button variant="contained" color="primary" onClick={() => onSave()} className={classes.applyButton}>
157 export default AdaptiveModulationDialog;