From 2317b6a4ab8c895f9f3e3d2c9aea033d08807449 Mon Sep 17 00:00:00 2001 From: Irtiza-h30 Date: Tue, 14 Jul 2020 16:43:10 -0400 Subject: [PATCH] updated changes --- app/containers/MasterLayout/index.js | 39 ++++++++++++++++++---------- app/graphql/queries.js | 1 + 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/containers/MasterLayout/index.js b/app/containers/MasterLayout/index.js index 33b9f42..b52cfe8 100644 --- a/app/containers/MasterLayout/index.js +++ b/app/containers/MasterLayout/index.js @@ -1,9 +1,12 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; +import { Alert } from 'antd'; import { useLocation } from 'react-router-dom'; -import { useApolloClient } from '@apollo/react-hooks'; +import { useApolloClient, useQuery } from '@apollo/react-hooks'; -import { AppLayout as Layout } from '@tip-wlan/wlan-cloud-ui-library'; +import { GET_ALL_STATUS } from 'graphql/queries'; + +import { AppLayout as Layout, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { AUTH_TOKEN } from 'constants/index'; @@ -12,7 +15,7 @@ import { removeItem } from 'utils/localStorage'; import UserContext from 'contexts/UserContext'; const MasterLayout = ({ children }) => { - const { role } = useContext(UserContext); + const { role, customerId } = useContext(UserContext); const client = useApolloClient(); const location = useLocation(); @@ -38,11 +41,6 @@ const MasterLayout = ({ children }) => { path: '/profiles', text: 'Profiles', }, - { - key: 'alarms', - path: '/alarms', - text: 'Alarms', - }, ]; const mobileMenuItems = [ @@ -61,11 +59,6 @@ const MasterLayout = ({ children }) => { path: '/profiles', text: 'Profiles', }, - { - key: 'alarms', - path: '/alarms', - text: 'Alarms', - }, { key: 'settings', @@ -98,12 +91,32 @@ const MasterLayout = ({ children }) => { }); } + const { loading, error, data } = useQuery(GET_ALL_STATUS, { + variables: { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] }, + }); + + if (loading) { + return ; + } + + if (error) { + return ; + } + + const alarms = data.getAllStatus.items[0].alarmsCount.totalCountsPerAlarmCodeMap; + + let totalAlarms = 0; + Object.keys(alarms).forEach(i => { + totalAlarms += alarms[i]; + }); + return ( {children} diff --git a/app/graphql/queries.js b/app/graphql/queries.js index f5fa9d1..70feebb 100644 --- a/app/graphql/queries.js +++ b/app/graphql/queries.js @@ -215,6 +215,7 @@ export const GET_ALL_STATUS = gql` equipmentCountPerOui clientCountPerOui } + alarmsCount } context { lastPage