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';
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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
}
}
`;