Merge pull request #88 from Telecominfraproject/bugfix/WIFI-1442

Bugfix/WIFI-1442: Bulk-Edit APs Page Fixes
This commit is contained in:
Sean Macfarlane
2021-02-18 11:10:06 -05:00
committed by GitHub
2 changed files with 61 additions and 54 deletions

View File

@@ -11,6 +11,8 @@ import { UPDATE_EQUIPMENT_BULK } from 'graphql/mutations';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import styles from './index.module.scss'; import styles from './index.module.scss';
const defaultAppliedRadios = { is5GHzL: 'is5GHzL', is2dot4GHz: 'is2dot4GHz', is5GHzU: 'is5GHzU' };
const renderTableCell = tabCell => { const renderTableCell = tabCell => {
if (Array.isArray(tabCell)) { if (Array.isArray(tabCell)) {
return ( return (
@@ -25,47 +27,54 @@ const renderTableCell = tabCell => {
return <span>{tabCell}</span>; return <span>{tabCell}</span>;
}; };
const accessPointsChannelTableColumns = [ const accessPointsChannelTableColumns = [
{ title: 'NAME', dataIndex: 'name', key: 'name', render: renderTableCell }, { title: 'Name', dataIndex: 'name', key: 'name', width: 150, render: renderTableCell },
{ {
title: 'CHANNEL', title: 'Channel',
dataIndex: 'channel', dataIndex: 'channel',
key: 'channel', key: 'channel',
editable: true, editable: true,
width: 150,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'CELL SIZE', title: 'Cell Size',
dataIndex: 'cellSize', dataIndex: 'cellSize',
key: 'cellSize', key: 'cellSize',
editable: true, editable: true,
width: 150,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'PROB RESPONSE THRESHOLD', title: 'Probe Response Threshold',
dataIndex: 'probeResponseThreshold', dataIndex: 'probeResponseThreshold',
key: 'probeResponseThreshold', key: 'probeResponseThreshold',
editable: true, editable: true,
width: 200,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'CLIENT DISCONNECT THRESHOLD', title: 'Client Disconnect Threshold',
dataIndex: 'clientDisconnectThreshold', dataIndex: 'clientDisconnectThreshold',
key: 'clientDisconnectThreshold', key: 'clientDisconnectThreshold',
editable: true, editable: true,
width: 200,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'SNR (% DROP)', title: 'SNR (% Drop)',
dataIndex: 'snrDrop', dataIndex: 'snrDrop',
key: 'snrDrop', key: 'snrDrop',
editable: true, editable: true,
width: 175,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'MIN LOAD', title: 'Min Load',
dataIndex: 'minLoad', dataIndex: 'minLoad',
key: 'minLoad', key: 'minLoad',
editable: true, editable: true,
width: 150,
render: renderTableCell, render: renderTableCell,
}, },
]; ];
@@ -162,42 +171,44 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
const getRadioDetails = (radioDetails, type) => { const getRadioDetails = (radioDetails, type) => {
if (type === 'cellSize') { if (type === 'cellSize') {
const cellSizeValues = []; const cellSizeValues = [];
Object.keys(radioDetails.radioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return cellSizeValues.push(radioDetails.radioMap[i].rxCellSizeDb.value); return cellSizeValues.push(radioDetails.radioMap[i]?.rxCellSizeDb?.value);
}); });
return cellSizeValues; return cellSizeValues;
} }
if (type === 'probeResponseThreshold') { if (type === 'probeResponseThreshold') {
const probeResponseThresholdValues = []; const probeResponseThresholdValues = [];
Object.keys(radioDetails.radioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return probeResponseThresholdValues.push( return probeResponseThresholdValues.push(
radioDetails.radioMap[i].probeResponseThresholdDb.value radioDetails.radioMap[i]?.probeResponseThresholdDb?.value
); );
}); });
return probeResponseThresholdValues; return probeResponseThresholdValues;
} }
if (type === 'clientDisconnectThreshold') { if (type === 'clientDisconnectThreshold') {
const clientDisconnectThresholdValues = []; const clientDisconnectThresholdValues = [];
Object.keys(radioDetails.radioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return clientDisconnectThresholdValues.push( return clientDisconnectThresholdValues.push(
radioDetails.radioMap[i].clientDisconnectThresholdDb.value radioDetails.radioMap[i]?.clientDisconnectThresholdDb?.value
); );
}); });
return clientDisconnectThresholdValues; return clientDisconnectThresholdValues;
} }
if (type === 'snrDrop') { if (type === 'snrDrop') {
const snrDropValues = []; const snrDropValues = [];
Object.keys(radioDetails.advancedRadioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return snrDropValues.push( return snrDropValues.push(
radioDetails.advancedRadioMap[i].bestApSettings.dropInSnrPercentage radioDetails.advancedRadioMap[i]?.bestApSettings?.value?.dropInSnrPercentage
); );
}); });
return snrDropValues; return snrDropValues;
} }
const minLoadValue = []; const minLoadValue = [];
Object.keys(radioDetails.advancedRadioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return minLoadValue.push(radioDetails.advancedRadioMap[i].bestApSettings.minLoadFactor); return minLoadValue.push(
radioDetails.advancedRadioMap[i]?.bestApSettings?.value?.minLoadFactor
);
}); });
return minLoadValue; return minLoadValue;
}; };
@@ -234,7 +245,7 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
let minLoadFactor; let minLoadFactor;
dataSource.items.forEach(({ id: itemId, details }) => { dataSource.items.forEach(({ id: itemId, details }) => {
if (equipmentId === itemId) { if (equipmentId === itemId) {
Object.keys(details.radioMap).forEach((i, dataIndex) => { Object.keys(details?.radioMap || defaultAppliedRadios).forEach((i, dataIndex) => {
const frequencies = {}; const frequencies = {};
dropInSnrPercentage = snrDrop[dataIndex]; dropInSnrPercentage = snrDrop[dataIndex];
minLoadFactor = minLoad[dataIndex]; minLoadFactor = minLoad[dataIndex];
@@ -286,42 +297,39 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
const handleSaveChanges = updatedRows => { const handleSaveChanges = updatedRows => {
const editedRowsArr = []; const editedRowsArr = [];
if (updatedRows.length > 0) { Object.keys(updatedRows).forEach(key => {
updatedRows.map( const {
({ id: equipmentId,
id: equipmentId, channel,
channel, cellSize,
cellSize, probeResponseThreshold,
probeResponseThreshold, clientDisconnectThreshold,
clientDisconnectThreshold, snrDrop,
snrDrop, minLoad,
minLoad, } = updatedRows[key];
}) => { const updatedEuips = setUpdatedBulkEditTableData(
const updatedEuips = setUpdatedBulkEditTableData( equipmentId,
equipmentId, channel,
channel, cellSize,
cellSize, probeResponseThreshold,
probeResponseThreshold, clientDisconnectThreshold,
clientDisconnectThreshold, snrDrop,
snrDrop, minLoad,
minLoad, equipData && equipData.filterEquipment
equipData && equipData.filterEquipment
);
const tempObj = {
equipmentId,
perRadioDetails: {},
};
updatedEuips.map(item => {
Object.keys(item).forEach(i => {
tempObj.perRadioDetails[i] = item[i];
});
return tempObj;
});
return editedRowsArr.push(tempObj);
}
); );
updateEquipments(editedRowsArr); const tempObj = {
} equipmentId,
perRadioDetails: {},
};
updatedEuips.map(item => {
Object.keys(item).forEach(i => {
tempObj.perRadioDetails[i] = item[i];
});
return tempObj;
});
return editedRowsArr.push(tempObj);
});
updateEquipments(editedRowsArr);
}; };
const handleLoadMore = () => { const handleLoadMore = () => {

View File

@@ -1,5 +1,4 @@
.tabColumn { .tabColumn {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 0 30px;
} }