From a8843d4be7f14af4c738aa98633e7782a3edbee3 Mon Sep 17 00:00:00 2001 From: Sean Macfarlane Date: Tue, 18 Aug 2020 16:18:49 -0400 Subject: [PATCH] fixed pagination --- app/containers/Accounts/index.js | 11 ++-- app/containers/Alarms/index.js | 11 ++-- .../Network/containers/AccessPoints/index.js | 2 +- .../containers/BulkEditAccessPoints/index.js | 2 +- .../Network/containers/ClientDevices/index.js | 2 +- app/graphql/queries.js | 52 ++++++------------- 6 files changed, 28 insertions(+), 52 deletions(-) diff --git a/app/containers/Accounts/index.js b/app/containers/Accounts/index.js index 36303b8..6628a8b 100644 --- a/app/containers/Accounts/index.js +++ b/app/containers/Accounts/index.js @@ -8,8 +8,8 @@ import { Accounts as AccountsPage, Loading } from '@tip-wlan/wlan-cloud-ui-libra import UserContext from 'contexts/UserContext'; const GET_ALL_USERS = gql` - query GetAllUsers($customerId: ID!, $cursor: String) { - getAllUsers(customerId: $customerId, cursor: $cursor) { + query GetAllUsers($customerId: ID!, $context: JSONObject) { + getAllUsers(customerId: $customerId, context: $context) { items { id email: username @@ -17,10 +17,7 @@ const GET_ALL_USERS = gql` lastModifiedTimestamp customerId } - context { - cursor - lastPage - } + context } } `; @@ -82,7 +79,7 @@ const Accounts = () => { const handleLoadMore = () => { if (!data.getAllUsers.context.lastPage) { fetchMore({ - variables: { cursor: data.getAllUsers.context.cursor }, + variables: { context: data.getAllUsers.context }, updateQuery: (previousResult, { fetchMoreResult }) => { const previousEntry = previousResult.getAllUsers; const newItems = fetchMoreResult.getAllUsers.items; diff --git a/app/containers/Alarms/index.js b/app/containers/Alarms/index.js index 90ab355..43794be 100644 --- a/app/containers/Alarms/index.js +++ b/app/containers/Alarms/index.js @@ -7,8 +7,8 @@ import { Alarms as AlarmsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import UserContext from 'contexts/UserContext'; const GET_ALL_ALARMS = gql` - query GetAllAlarms($customerId: ID!, $cursor: String) { - getAllAlarms(customerId: $customerId, cursor: $cursor) { + query GetAllAlarms($customerId: ID!, $context: JSONObject) { + getAllAlarms(customerId: $customerId, context: $context) { items { severity alarmCode @@ -19,10 +19,7 @@ const GET_ALL_ALARMS = gql` name } } - context { - cursor - lastPage - } + context } } `; @@ -53,7 +50,7 @@ const Alarms = () => { const handleLoadMore = () => { if (!data.getAllAlarms.context.lastPage) { fetchMore({ - variables: { cursor: data.getAllAlarms.context.cursor }, + variables: { context: data.getAllAlarms.context }, updateQuery: (previousResult, { fetchMoreResult }) => { const previousEntry = previousResult.getAllAlarms; const newItems = fetchMoreResult.getAllAlarms.items; diff --git a/app/containers/Network/containers/AccessPoints/index.js b/app/containers/Network/containers/AccessPoints/index.js index f4df457..ffce5f7 100644 --- a/app/containers/Network/containers/AccessPoints/index.js +++ b/app/containers/Network/containers/AccessPoints/index.js @@ -128,7 +128,7 @@ const AccessPoints = ({ checkedLocations }) => { const handleLoadMore = () => { if (!equipData.filterEquipment.context.lastPage) { fetchMore({ - variables: { cursor: equipData.filterEquipment.context.cursor }, + variables: { context: equipData.filterEquipment.context }, updateQuery: (previousResult, { fetchMoreResult }) => { const previousEntry = previousResult.filterEquipment; const newItems = fetchMoreResult.filterEquipment.items; diff --git a/app/containers/Network/containers/BulkEditAccessPoints/index.js b/app/containers/Network/containers/BulkEditAccessPoints/index.js index 1138a30..a46b416 100644 --- a/app/containers/Network/containers/BulkEditAccessPoints/index.js +++ b/app/containers/Network/containers/BulkEditAccessPoints/index.js @@ -327,7 +327,7 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { const handleLoadMore = () => { if (!equipData.filterEquipment.context.lastPage) { fetchMore({ - variables: { cursor: equipData.filterEquipment.context.cursor }, + variables: { context: equipData.filterEquipment.context }, updateQuery: (previousResult, { fetchMoreResult }) => { const previousEntry = previousResult.filterEquipment; const newItems = fetchMoreResult.filterEquipment.items; diff --git a/app/containers/Network/containers/ClientDevices/index.js b/app/containers/Network/containers/ClientDevices/index.js index e8ea1e9..ea26887 100644 --- a/app/containers/Network/containers/ClientDevices/index.js +++ b/app/containers/Network/containers/ClientDevices/index.js @@ -39,7 +39,7 @@ const ClientDevices = ({ checkedLocations }) => { const handleLoadMore = () => { if (!data.filterClientSessions.context.lastPage) { fetchMore({ - variables: { cursor: data.filterClientSessions.context.cursor }, + variables: { context: data.filterClientSessions.context }, updateQuery: (previousResult, { fetchMoreResult }) => { const previousEntry = previousResult.filterClientSessions; const newItems = fetchMoreResult.filterClientSessions.items; diff --git a/app/graphql/queries.js b/app/graphql/queries.js index db2edac..369d292 100644 --- a/app/graphql/queries.js +++ b/app/graphql/queries.js @@ -16,13 +16,13 @@ export const FILTER_EQUIPMENT = gql` $locationIds: [ID] $customerId: ID! $equipmentType: String - $cursor: String + $context: JSONObject ) { filterEquipment( customerId: $customerId locationIds: $locationIds equipmentType: $equipmentType - cursor: $cursor + context: $context ) { items { name @@ -63,10 +63,7 @@ export const FILTER_EQUIPMENT = gql` } } } - context { - lastPage - cursor - } + context } } `; @@ -76,13 +73,13 @@ export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql` $locationIds: [ID] $customerId: ID! $equipmentType: String - $cursor: String + $context: JSONObject ) { filterEquipment( customerId: $customerId locationIds: $locationIds equipmentType: $equipmentType - cursor: $cursor + context: $context ) { items { name @@ -91,10 +88,7 @@ export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql` channel details } - context { - lastPage - cursor - } + context } } `; @@ -112,8 +106,8 @@ export const GET_LOCATION = gql` `; export const FILTER_CLIENT_SESSIONS = gql` - query FilterClientSessions($customerId: ID!, $locationIds: [ID], $cursor: String) { - filterClientSessions(customerId: $customerId, locationIds: $locationIds, cursor: $cursor) { + query FilterClientSessions($customerId: ID!, $locationIds: [ID], $context: JSONObject) { + filterClientSessions(customerId: $customerId, locationIds: $locationIds, context: $context) { items { id macAddress @@ -127,10 +121,7 @@ export const FILTER_CLIENT_SESSIONS = gql` name } } - context { - lastPage - cursor - } + context } } `; @@ -157,7 +148,7 @@ export const GET_CLIENT_SESSION = gql` export const FILTER_SERVICE_METRICS = gql` query FilterServiceMetrics( $customerId: ID! - $cursor: String + $context: JSONObject $fromTime: String! $toTime: String! $clientMacs: [String] @@ -167,7 +158,7 @@ export const FILTER_SERVICE_METRICS = gql` ) { filterServiceMetrics( customerId: $customerId - cursor: $cursor + context: $context fromTime: $fromTime toTime: $toTime clientMacs: $clientMacs @@ -183,15 +174,12 @@ export const FILTER_SERVICE_METRICS = gql` txBytes detailsJSON } - context { - lastPage - cursor - } + context } } `; -export const GET_ALL_PROFILES = fields => gql` +export const GET_ALL_PROFILES = (fields = '') => gql` query GetAllProfiles( $customerId: ID! $cursor: String @@ -229,10 +217,7 @@ export const GET_ALL_STATUS = gql` clientCountPerOui } } - context { - lastPage - cursor - } + context } } `; @@ -308,7 +293,7 @@ export const FILTER_SYSTEM_EVENTS = gql` $toTime: String! $equipmentIds: [ID] $dataTypes: [String] - $cursor: String + $context: JSONObject $limit: Int ) { filterSystemEvents( @@ -317,14 +302,11 @@ export const FILTER_SYSTEM_EVENTS = gql` toTime: $toTime dataTypes: $dataTypes equipmentIds: $equipmentIds - cursor: $cursor + context: $context limit: $limit ) { items - context { - lastPage - cursor - } + context } } `;