mirror of
https://github.com/Telecominfraproject/wlan-cloud-ui.git
synced 2025-11-01 19:27:51 +00:00
changed alarm count gql
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import React, { useContext, useMemo } from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { useApolloClient, useQuery } from '@apollo/react-hooks';
|
||||
|
||||
import { GET_ALL_STATUS_ALARMS } from 'graphql/queries';
|
||||
import { GET_ALARM_COUNT } from 'graphql/queries';
|
||||
|
||||
import { AppLayout as Layout } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
@@ -19,27 +19,10 @@ const MasterLayout = ({ children }) => {
|
||||
const client = useApolloClient();
|
||||
const location = useLocation();
|
||||
|
||||
const { data } = useQuery(GET_ALL_STATUS_ALARMS, {
|
||||
variables: { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] },
|
||||
const { data } = useQuery(GET_ALARM_COUNT, {
|
||||
variables: { customerId },
|
||||
});
|
||||
|
||||
const alarmsCount = useMemo(() => {
|
||||
const alarmsArr =
|
||||
(data &&
|
||||
data.getAllStatus &&
|
||||
data.getAllStatus.items[0] &&
|
||||
data.getAllStatus.items[0].alarmsCount &&
|
||||
data.getAllStatus.items[0].alarmsCount.totalCountsPerAlarmCodeMap) ||
|
||||
{};
|
||||
let totalAlarms = 0;
|
||||
if (alarmsArr) {
|
||||
Object.keys(alarmsArr).forEach(i => {
|
||||
totalAlarms += alarmsArr[i];
|
||||
});
|
||||
}
|
||||
return totalAlarms;
|
||||
}, [data]);
|
||||
|
||||
const handleLogout = () => {
|
||||
removeItem(AUTH_TOKEN);
|
||||
client.resetStore();
|
||||
@@ -117,7 +100,7 @@ const MasterLayout = ({ children }) => {
|
||||
locationState={location}
|
||||
menuItems={menuItems}
|
||||
mobileMenuItems={mobileMenuItems}
|
||||
totalAlarms={alarmsCount}
|
||||
totalAlarms={data && data.getAlarmCount}
|
||||
>
|
||||
{children}
|
||||
</Layout>
|
||||
|
||||
@@ -224,22 +224,8 @@ export const GET_ALL_STATUS = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_ALL_STATUS_ALARMS = gql`
|
||||
query GetAllStatus($customerId: Int!, $statusDataTypes: [String]) {
|
||||
getAllStatus(customerId: $customerId, statusDataTypes: $statusDataTypes) {
|
||||
items {
|
||||
customerId
|
||||
detailsJSON
|
||||
details {
|
||||
equipmentCountPerOui
|
||||
clientCountPerOui
|
||||
}
|
||||
alarmsCount
|
||||
}
|
||||
context {
|
||||
lastPage
|
||||
cursor
|
||||
}
|
||||
}
|
||||
export const GET_ALARM_COUNT = gql`
|
||||
query GetAlarmCount($customerId: Int!) {
|
||||
getAlarmCount(customerId: $customerId)
|
||||
}
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user