From 9bf737c1eb45c65ce8f2ccd704566a3b862ee48c Mon Sep 17 00:00:00 2001 From: irtiza-h30 Date: Wed, 3 Mar 2021 14:22:02 -0500 Subject: [PATCH] Manual backup channel change for Bulk-Edit APs --- .../containers/AccessPointDetails/index.js | 125 ++---------------- .../containers/BulkEditAccessPoints/index.js | 70 ++++++---- app/graphql/mutations.js | 56 ++++++++ app/graphql/queries.js | 58 ++++++++ 4 files changed, 168 insertions(+), 141 deletions(-) diff --git a/app/containers/Network/containers/AccessPointDetails/index.js b/app/containers/Network/containers/AccessPointDetails/index.js index e8f2869..571947f 100644 --- a/app/containers/Network/containers/AccessPointDetails/index.js +++ b/app/containers/Network/containers/AccessPointDetails/index.js @@ -1,7 +1,7 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import { useParams, useHistory } from 'react-router-dom'; -import { useQuery, useMutation, gql } from '@apollo/client'; +import { useQuery, useMutation } from '@apollo/client'; import { Alert, notification } from 'antd'; import moment from 'moment'; import { @@ -9,8 +9,15 @@ import { Loading, } from '@tip-wlan/wlan-cloud-ui-library'; -import { FILTER_SERVICE_METRICS, GET_ALL_FIRMWARE, GET_ALL_PROFILES } from 'graphql/queries'; import { + GET_EQUIPMENT, + FILTER_SERVICE_METRICS, + GET_ALL_FIRMWARE, + GET_ALL_PROFILES, +} from 'graphql/queries'; +import { + UPDATE_EQUIPMENT, + DELETE_EQUIPMENT, UPDATE_EQUIPMENT_FIRMWARE, REQUEST_EQUIPMENT_SWITCH_BANK, REQUEST_EQUIPMENT_REBOOT, @@ -18,120 +25,6 @@ import { import { fetchMoreProfiles } from 'graphql/functions'; import UserContext from 'contexts/UserContext'; -const GET_EQUIPMENT = gql` - query GetEquipment($id: ID!) { - getEquipment(id: $id) { - id - equipmentType - inventoryId - customerId - profileId - locationId - name - latitude - longitude - serial - lastModifiedTimestamp - details - profile { - id - name - childProfiles { - id - name - details - } - } - baseMacAddress - manufacturer - status { - firmware { - detailsJSON - } - protocol { - detailsJSON - } - radioUtilization { - detailsJSON - } - clientDetails { - detailsJSON - details { - numClientsPerRadio - } - } - osPerformance { - detailsJSON - } - } - model - alarmsCount - alarms { - severity - alarmCode - details - createdTimestamp - } - } - } -`; - -const UPDATE_EQUIPMENT = gql` - mutation UpdateEquipment( - $id: ID! - $equipmentType: String! - $inventoryId: String! - $customerId: ID! - $profileId: ID! - $locationId: ID! - $name: String! - $baseMacAddress: String - $latitude: String - $longitude: String - $serial: String - $lastModifiedTimestamp: String - $details: JSONObject - ) { - updateEquipment( - id: $id - equipmentType: $equipmentType - inventoryId: $inventoryId - customerId: $customerId - profileId: $profileId - locationId: $locationId - name: $name - baseMacAddress: $baseMacAddress - latitude: $latitude - longitude: $longitude - serial: $serial - lastModifiedTimestamp: $lastModifiedTimestamp - details: $details - ) { - id - equipmentType - inventoryId - customerId - profileId - locationId - name - baseMacAddress - latitude - longitude - serial - lastModifiedTimestamp - details - } - } -`; - -const DELETE_EQUIPMENT = gql` - mutation DeleteEquipment($id: ID!) { - deleteEquipment(id: $id) { - id - } - } -`; - const toTime = moment(); const fromTime = moment().subtract(1, 'hour'); diff --git a/app/containers/Network/containers/BulkEditAccessPoints/index.js b/app/containers/Network/containers/BulkEditAccessPoints/index.js index 36993f4..6a230cb 100644 --- a/app/containers/Network/containers/BulkEditAccessPoints/index.js +++ b/app/containers/Network/containers/BulkEditAccessPoints/index.js @@ -27,13 +27,22 @@ const renderTableCell = tabCell => { return {tabCell}; }; const accessPointsChannelTableColumns = [ - { title: 'Name', dataIndex: 'name', key: 'name', width: 150, render: renderTableCell }, + { title: 'Name', dataIndex: 'name', key: 'name', width: 250, render: renderTableCell }, { - title: 'Channel', - dataIndex: 'channel', - key: 'channel', + title: 'Manual Active Channel', + dataIndex: 'manualChannelNumber', + key: 'manualChannelNumber', editable: true, - width: 150, + width: 200, + render: renderTableCell, + }, + + { + title: 'Manual Backup Channel', + dataIndex: 'manualBackupChannelNumber', + key: 'manualBackupChannelNumber', + editable: true, + width: 210, render: renderTableCell, }, { @@ -49,7 +58,7 @@ const accessPointsChannelTableColumns = [ dataIndex: 'probeResponseThreshold', key: 'probeResponseThreshold', editable: true, - width: 200, + width: 210, render: renderTableCell, }, { @@ -57,7 +66,7 @@ const accessPointsChannelTableColumns = [ dataIndex: 'clientDisconnectThreshold', key: 'clientDisconnectThreshold', editable: true, - width: 200, + width: 210, render: renderTableCell, }, @@ -66,7 +75,7 @@ const accessPointsChannelTableColumns = [ dataIndex: 'snrDrop', key: 'snrDrop', editable: true, - width: 175, + width: 150, render: renderTableCell, }, { @@ -169,6 +178,21 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { const [updateEquipmentBulk] = useMutation(UPDATE_EQUIPMENT_BULK); const getRadioDetails = (radioDetails, type) => { + if (type === 'manualChannelNumber') { + const manualChannelNumbers = []; + Object.keys(radioDetails?.radioMap || {}).map(i => { + return manualChannelNumbers.push(radioDetails.radioMap[i]?.manualChannelNumber); + }); + return manualChannelNumbers; + } + + if (type === 'manualBackupChannelNumber') { + const manualBackupChannelNumbers = []; + Object.keys(radioDetails?.radioMap || {}).map(i => { + return manualBackupChannelNumbers.push(radioDetails.radioMap[i]?.manualBackupChannelNumber); + }); + return manualBackupChannelNumbers; + } if (type === 'cellSize') { const cellSizeValues = []; Object.keys(radioDetails?.radioMap || {}).map(i => { @@ -214,12 +238,13 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { }; const setAccessPointsBulkEditTableData = (dataSource = []) => { - const tableData = dataSource.items.map(({ id: key, name, channel, details }) => { + const tableData = dataSource.items.map(({ id: key, name, details }) => { return { key, id: key, name, - channel, + manualChannelNumber: getRadioDetails(details, 'manualChannelNumber'), + manualBackupChannelNumber: getRadioDetails(details, 'manualBackupChannelNumber'), cellSize: getRadioDetails(details, 'cellSize'), probeResponseThreshold: getRadioDetails(details, 'probeResponseThreshold'), clientDisconnectThreshold: getRadioDetails(details, 'clientDisconnectThreshold'), @@ -232,7 +257,8 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { const setUpdatedBulkEditTableData = ( equipmentId, - channel, + manualChannelNumber, + manualBackupChannelNumber, cellSize, probeResponseThreshold, clientDisconnectThreshold, @@ -251,7 +277,8 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { minLoadFactor = minLoad[dataIndex]; frequencies[`${i}`] = { - channelNumber: channel[dataIndex], + channelNumber: manualChannelNumber[dataIndex], + backupChannelNumber: manualBackupChannelNumber[dataIndex], rxCellSizeDb: { auto: true, value: cellSize[dataIndex], @@ -300,7 +327,8 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { Object.keys(updatedRows).forEach(key => { const { id: equipmentId, - channel, + manualChannelNumber, + manualBackupChannelNumber, cellSize, probeResponseThreshold, clientDisconnectThreshold, @@ -309,7 +337,8 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { } = updatedRows[key]; const updatedEuips = setUpdatedBulkEditTableData( equipmentId, - channel, + manualChannelNumber, + manualBackupChannelNumber, cellSize, probeResponseThreshold, clientDisconnectThreshold, @@ -364,18 +393,9 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { return ( diff --git a/app/graphql/mutations.js b/app/graphql/mutations.js index cb0eecb..6145a8a 100644 --- a/app/graphql/mutations.js +++ b/app/graphql/mutations.js @@ -255,6 +255,62 @@ export const CREATE_EQUIPMENT = gql` } `; +export const UPDATE_EQUIPMENT = gql` + mutation UpdateEquipment( + $id: ID! + $equipmentType: String! + $inventoryId: String! + $customerId: ID! + $profileId: ID! + $locationId: ID! + $name: String! + $baseMacAddress: String + $latitude: String + $longitude: String + $serial: String + $lastModifiedTimestamp: String + $details: JSONObject + ) { + updateEquipment( + id: $id + equipmentType: $equipmentType + inventoryId: $inventoryId + customerId: $customerId + profileId: $profileId + locationId: $locationId + name: $name + baseMacAddress: $baseMacAddress + latitude: $latitude + longitude: $longitude + serial: $serial + lastModifiedTimestamp: $lastModifiedTimestamp + details: $details + ) { + id + equipmentType + inventoryId + customerId + profileId + locationId + name + baseMacAddress + latitude + longitude + serial + lastModifiedTimestamp + details + } + } +`; + +export const DELETE_EQUIPMENT = gql` + mutation DeleteEquipment($id: ID!) { + deleteEquipment(id: $id) { + id + } + } +`; + export const UPDATE_CUSTOMER = gql` mutation UpdateCustomer( $id: ID! diff --git a/app/graphql/queries.js b/app/graphql/queries.js index b790a18..38059bd 100644 --- a/app/graphql/queries.js +++ b/app/graphql/queries.js @@ -77,6 +77,64 @@ export const FILTER_EQUIPMENT = gql` } `; +export const GET_EQUIPMENT = gql` + query GetEquipment($id: ID!) { + getEquipment(id: $id) { + id + equipmentType + inventoryId + customerId + profileId + locationId + name + latitude + longitude + serial + lastModifiedTimestamp + details + profile { + id + name + childProfiles { + id + name + details + } + } + baseMacAddress + manufacturer + status { + firmware { + detailsJSON + } + protocol { + detailsJSON + } + radioUtilization { + detailsJSON + } + clientDetails { + detailsJSON + details { + numClientsPerRadio + } + } + osPerformance { + detailsJSON + } + } + model + alarmsCount + alarms { + severity + alarmCode + details + createdTimestamp + } + } + } +`; + export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql` query FilterEquipment( $locationIds: [ID]