fixed pagination

This commit is contained in:
Sean Macfarlane
2020-08-18 16:18:49 -04:00
parent 86087930da
commit a8843d4be7
6 changed files with 28 additions and 52 deletions

View File

@@ -8,8 +8,8 @@ import { Accounts as AccountsPage, Loading } from '@tip-wlan/wlan-cloud-ui-libra
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
const GET_ALL_USERS = gql` const GET_ALL_USERS = gql`
query GetAllUsers($customerId: ID!, $cursor: String) { query GetAllUsers($customerId: ID!, $context: JSONObject) {
getAllUsers(customerId: $customerId, cursor: $cursor) { getAllUsers(customerId: $customerId, context: $context) {
items { items {
id id
email: username email: username
@@ -17,10 +17,7 @@ const GET_ALL_USERS = gql`
lastModifiedTimestamp lastModifiedTimestamp
customerId customerId
} }
context { context
cursor
lastPage
}
} }
} }
`; `;
@@ -82,7 +79,7 @@ const Accounts = () => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!data.getAllUsers.context.lastPage) { if (!data.getAllUsers.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: data.getAllUsers.context.cursor }, variables: { context: data.getAllUsers.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.getAllUsers; const previousEntry = previousResult.getAllUsers;
const newItems = fetchMoreResult.getAllUsers.items; const newItems = fetchMoreResult.getAllUsers.items;

View File

@@ -7,8 +7,8 @@ import { Alarms as AlarmsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
const GET_ALL_ALARMS = gql` const GET_ALL_ALARMS = gql`
query GetAllAlarms($customerId: ID!, $cursor: String) { query GetAllAlarms($customerId: ID!, $context: JSONObject) {
getAllAlarms(customerId: $customerId, cursor: $cursor) { getAllAlarms(customerId: $customerId, context: $context) {
items { items {
severity severity
alarmCode alarmCode
@@ -19,10 +19,7 @@ const GET_ALL_ALARMS = gql`
name name
} }
} }
context { context
cursor
lastPage
}
} }
} }
`; `;
@@ -53,7 +50,7 @@ const Alarms = () => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!data.getAllAlarms.context.lastPage) { if (!data.getAllAlarms.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: data.getAllAlarms.context.cursor }, variables: { context: data.getAllAlarms.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.getAllAlarms; const previousEntry = previousResult.getAllAlarms;
const newItems = fetchMoreResult.getAllAlarms.items; const newItems = fetchMoreResult.getAllAlarms.items;

View File

@@ -128,7 +128,7 @@ const AccessPoints = ({ checkedLocations }) => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!equipData.filterEquipment.context.lastPage) { if (!equipData.filterEquipment.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: equipData.filterEquipment.context.cursor }, variables: { context: equipData.filterEquipment.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.filterEquipment; const previousEntry = previousResult.filterEquipment;
const newItems = fetchMoreResult.filterEquipment.items; const newItems = fetchMoreResult.filterEquipment.items;

View File

@@ -327,7 +327,7 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!equipData.filterEquipment.context.lastPage) { if (!equipData.filterEquipment.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: equipData.filterEquipment.context.cursor }, variables: { context: equipData.filterEquipment.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.filterEquipment; const previousEntry = previousResult.filterEquipment;
const newItems = fetchMoreResult.filterEquipment.items; const newItems = fetchMoreResult.filterEquipment.items;

View File

@@ -39,7 +39,7 @@ const ClientDevices = ({ checkedLocations }) => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!data.filterClientSessions.context.lastPage) { if (!data.filterClientSessions.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: data.filterClientSessions.context.cursor }, variables: { context: data.filterClientSessions.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.filterClientSessions; const previousEntry = previousResult.filterClientSessions;
const newItems = fetchMoreResult.filterClientSessions.items; const newItems = fetchMoreResult.filterClientSessions.items;

View File

@@ -16,13 +16,13 @@ export const FILTER_EQUIPMENT = gql`
$locationIds: [ID] $locationIds: [ID]
$customerId: ID! $customerId: ID!
$equipmentType: String $equipmentType: String
$cursor: String $context: JSONObject
) { ) {
filterEquipment( filterEquipment(
customerId: $customerId customerId: $customerId
locationIds: $locationIds locationIds: $locationIds
equipmentType: $equipmentType equipmentType: $equipmentType
cursor: $cursor context: $context
) { ) {
items { items {
name name
@@ -63,10 +63,7 @@ export const FILTER_EQUIPMENT = gql`
} }
} }
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
@@ -76,13 +73,13 @@ export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql`
$locationIds: [ID] $locationIds: [ID]
$customerId: ID! $customerId: ID!
$equipmentType: String $equipmentType: String
$cursor: String $context: JSONObject
) { ) {
filterEquipment( filterEquipment(
customerId: $customerId customerId: $customerId
locationIds: $locationIds locationIds: $locationIds
equipmentType: $equipmentType equipmentType: $equipmentType
cursor: $cursor context: $context
) { ) {
items { items {
name name
@@ -91,10 +88,7 @@ export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql`
channel channel
details details
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
@@ -112,8 +106,8 @@ export const GET_LOCATION = gql`
`; `;
export const FILTER_CLIENT_SESSIONS = gql` export const FILTER_CLIENT_SESSIONS = gql`
query FilterClientSessions($customerId: ID!, $locationIds: [ID], $cursor: String) { query FilterClientSessions($customerId: ID!, $locationIds: [ID], $context: JSONObject) {
filterClientSessions(customerId: $customerId, locationIds: $locationIds, cursor: $cursor) { filterClientSessions(customerId: $customerId, locationIds: $locationIds, context: $context) {
items { items {
id id
macAddress macAddress
@@ -127,10 +121,7 @@ export const FILTER_CLIENT_SESSIONS = gql`
name name
} }
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
@@ -157,7 +148,7 @@ export const GET_CLIENT_SESSION = gql`
export const FILTER_SERVICE_METRICS = gql` export const FILTER_SERVICE_METRICS = gql`
query FilterServiceMetrics( query FilterServiceMetrics(
$customerId: ID! $customerId: ID!
$cursor: String $context: JSONObject
$fromTime: String! $fromTime: String!
$toTime: String! $toTime: String!
$clientMacs: [String] $clientMacs: [String]
@@ -167,7 +158,7 @@ export const FILTER_SERVICE_METRICS = gql`
) { ) {
filterServiceMetrics( filterServiceMetrics(
customerId: $customerId customerId: $customerId
cursor: $cursor context: $context
fromTime: $fromTime fromTime: $fromTime
toTime: $toTime toTime: $toTime
clientMacs: $clientMacs clientMacs: $clientMacs
@@ -183,15 +174,12 @@ export const FILTER_SERVICE_METRICS = gql`
txBytes txBytes
detailsJSON detailsJSON
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
export const GET_ALL_PROFILES = fields => gql` export const GET_ALL_PROFILES = (fields = '') => gql`
query GetAllProfiles( query GetAllProfiles(
$customerId: ID! $customerId: ID!
$cursor: String $cursor: String
@@ -229,10 +217,7 @@ export const GET_ALL_STATUS = gql`
clientCountPerOui clientCountPerOui
} }
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
@@ -308,7 +293,7 @@ export const FILTER_SYSTEM_EVENTS = gql`
$toTime: String! $toTime: String!
$equipmentIds: [ID] $equipmentIds: [ID]
$dataTypes: [String] $dataTypes: [String]
$cursor: String $context: JSONObject
$limit: Int $limit: Int
) { ) {
filterSystemEvents( filterSystemEvents(
@@ -317,14 +302,11 @@ export const FILTER_SYSTEM_EVENTS = gql`
toTime: $toTime toTime: $toTime
dataTypes: $dataTypes dataTypes: $dataTypes
equipmentIds: $equipmentIds equipmentIds: $equipmentIds
cursor: $cursor context: $context
limit: $limit limit: $limit
) { ) {
items items
context { context
lastPage
cursor
}
} }
} }
`; `;