mirror of
https://github.com/Telecominfraproject/wlan-cloud-ui.git
synced 2025-11-01 11:17:59 +00:00
updated changes
This commit is contained in:
@@ -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 <Loading />;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <Alert message="Error" description="Failed to load Alarms" type="error" showIcon />;
|
||||
}
|
||||
|
||||
const alarms = data.getAllStatus.items[0].alarmsCount.totalCountsPerAlarmCodeMap;
|
||||
|
||||
let totalAlarms = 0;
|
||||
Object.keys(alarms).forEach(i => {
|
||||
totalAlarms += alarms[i];
|
||||
});
|
||||
|
||||
return (
|
||||
<Layout
|
||||
onLogout={handleLogout}
|
||||
locationState={location}
|
||||
menuItems={menuItems}
|
||||
mobileMenuItems={mobileMenuItems}
|
||||
totalAlarms={totalAlarms}
|
||||
>
|
||||
{children}
|
||||
</Layout>
|
||||
|
||||
@@ -215,6 +215,7 @@ export const GET_ALL_STATUS = gql`
|
||||
equipmentCountPerOui
|
||||
clientCountPerOui
|
||||
}
|
||||
alarmsCount
|
||||
}
|
||||
context {
|
||||
lastPage
|
||||
|
||||
Reference in New Issue
Block a user