From a056e4286ccaee213e8c40a011500f66dd9342cb Mon Sep 17 00:00:00 2001 From: Irtiza-h30 Date: Wed, 15 Jul 2020 13:14:17 -0400 Subject: [PATCH] updated changes (without useMemo) --- app/containers/Dashboard/index.js | 6 ++---- app/containers/MasterLayout/index.js | 32 +++++++++++++++++----------- app/graphql/queries.js | 19 +++++++++++++++++ 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/app/containers/Dashboard/index.js b/app/containers/Dashboard/index.js index 8751f4d..bd4a1ce 100644 --- a/app/containers/Dashboard/index.js +++ b/app/containers/Dashboard/index.js @@ -50,13 +50,11 @@ const Dashboard = () => { totalAssociated += associatedClientsCountPerRadio[i]; }); - const { is2dot4GHz, is5GHz, is5GHzL, is5GHzU } = associatedClientsCountPerRadio; + const { is2dot4GHz, is5GHzL, is5GHzU } = associatedClientsCountPerRadio; const frequencies = { '2.4GHz': is2dot4GHz || 0, - '5GHz': is5GHz || 0, - '5GHz (L)': is5GHzL || 0, - '5GHz (U)': is5GHzU || 0, + '5GHz': parseInt((is5GHzL || 0) + (is5GHzU || 0), 10), }; const statsArr = [ diff --git a/app/containers/MasterLayout/index.js b/app/containers/MasterLayout/index.js index b52cfe8..669b9e9 100644 --- a/app/containers/MasterLayout/index.js +++ b/app/containers/MasterLayout/index.js @@ -1,10 +1,9 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; -import { Alert } from 'antd'; import { useLocation } from 'react-router-dom'; import { useApolloClient, useQuery } from '@apollo/react-hooks'; -import { GET_ALL_STATUS } from 'graphql/queries'; +import { GET_ALL_STATUS_ALARMS } from 'graphql/queries'; import { AppLayout as Layout, Loading } from '@tip-wlan/wlan-cloud-ui-library'; @@ -91,7 +90,7 @@ const MasterLayout = ({ children }) => { }); } - const { loading, error, data } = useQuery(GET_ALL_STATUS, { + const { loading, data } = useQuery(GET_ALL_STATUS_ALARMS, { variables: { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] }, }); @@ -99,16 +98,23 @@ const MasterLayout = ({ children }) => { return ; } - if (error) { - return ; - } + const alarmsArr = + (data && + data.getAllStatus && + data.getAllStatus.items[0] && + data.getAllStatus.items[0].alarmsCount && + data.getAllStatus.items[0].alarmsCount.totalCountsPerAlarmCodeMap) || + {}; - const alarms = data.getAllStatus.items[0].alarmsCount.totalCountsPerAlarmCodeMap; - - let totalAlarms = 0; - Object.keys(alarms).forEach(i => { - totalAlarms += alarms[i]; - }); + const findAlarmCount = () => { + let totalAlarms = 0; + if (alarmsArr) { + Object.keys(alarmsArr).forEach(i => { + totalAlarms += alarmsArr[i]; + }); + } + return totalAlarms; + }; return ( { locationState={location} menuItems={menuItems} mobileMenuItems={mobileMenuItems} - totalAlarms={totalAlarms} + totalAlarms={findAlarmCount()} > {children} diff --git a/app/graphql/queries.js b/app/graphql/queries.js index 70feebb..1a35e93 100644 --- a/app/graphql/queries.js +++ b/app/graphql/queries.js @@ -206,6 +206,25 @@ export const GET_ALL_PROFILES = gql` `; export const GET_ALL_STATUS = gql` + query GetAllStatus($customerId: Int!, $statusDataTypes: [String]) { + getAllStatus(customerId: $customerId, statusDataTypes: $statusDataTypes) { + items { + customerId + detailsJSON + details { + equipmentCountPerOui + clientCountPerOui + } + } + context { + lastPage + cursor + } + } + } +`; + +export const GET_ALL_STATUS_ALARMS = gql` query GetAllStatus($customerId: Int!, $statusDataTypes: [String]) { getAllStatus(customerId: $customerId, statusDataTypes: $statusDataTypes) { items {