Merge branch 'master' into hotfix/WIFI-588

This commit is contained in:
Sean Macfarlane
2020-08-19 17:45:53 -04:00
14 changed files with 504 additions and 630 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

@@ -33,8 +33,8 @@ const CREATE_PROFILE = gql`
const AddProfile = () => {
const { customerId } = useContext(UserContext);
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES, {
variables: { customerId, type: 'ssid' },
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'ssid', limit: 100 },
});
const [createProfile] = useMutation(CREATE_PROFILE);

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

@@ -10,7 +10,7 @@ import {
Loading,
} from '@tip-wlan/wlan-cloud-ui-library';
import { FILTER_SERVICE_METRICS } from 'graphql/queries';
import { FILTER_SERVICE_METRICS, GET_ALL_FIRMWARE, GET_ALL_PROFILES } from 'graphql/queries';
import { UPDATE_EQUIPMENT_FIRMWARE } from 'graphql/mutations';
import UserContext from 'contexts/UserContext';
@@ -74,20 +74,6 @@ const GET_EQUIPMENT = gql`
}
`;
export const GET_ALL_FIRMWARE = gql`
query GetAllFirmware {
getAllFirmware {
id
modelId
versionName
description
filename
commit
releaseDate
}
}
`;
const UPDATE_EQUIPMENT = gql`
mutation UpdateEquipment(
$id: ID!
@@ -133,28 +119,6 @@ const UPDATE_EQUIPMENT = gql`
}
`;
export const GET_ALL_PROFILES = gql`
query GetAllProfiles($customerId: ID!, $cursor: String, $type: String, $limit: Int) {
getAllProfiles(customerId: $customerId, cursor: $cursor, type: $type, limit: $limit) {
items {
id
name
profileType
details
childProfiles {
id
name
details
}
}
context {
cursor
lastPage
}
}
}
`;
const toTime = moment();
const fromTime = moment().subtract(1, 'hour');
@@ -163,14 +127,31 @@ const AccessPointDetails = ({ locations }) => {
const { customerId } = useContext(UserContext);
const { loading, error, data, refetch } = useQuery(GET_EQUIPMENT, {
variables: { id },
variables: {
id,
},
});
const { data: dataProfiles, error: errorProfiles, loading: landingProfiles } = useQuery(
GET_ALL_PROFILES,
const { data: dataFirmware, error: errorFirmware, loading: loadingFirmware } = useQuery(
GET_ALL_FIRMWARE,
{
skip: !data?.getEquipment?.model,
variables: { modelId: data?.getEquipment?.model?.toLowerCase() },
}
);
const { data: dataProfiles, error: errorProfiles, loading: loadingProfiles } = useQuery(
GET_ALL_PROFILES(`
childProfiles {
id
name
details
}`),
{
variables: { customerId, type: 'equipment_ap', limit: 100 },
}
);
const {
loading: metricsLoading,
error: metricsError,
@@ -190,10 +171,6 @@ const AccessPointDetails = ({ locations }) => {
const [updateEquipment] = useMutation(UPDATE_EQUIPMENT);
const [updateEquipmentFirmware] = useMutation(UPDATE_EQUIPMENT_FIRMWARE);
const { data: dataFirmware, error: errorFirmware, loading: landingFirmware } = useQuery(
GET_ALL_FIRMWARE
);
const refetchData = () => {
refetch();
metricsRefetch();
@@ -266,7 +243,7 @@ const AccessPointDetails = ({ locations }) => {
})
);
if (loading || landingProfiles || landingFirmware) {
if (loading) {
return <Loading />;
}
@@ -281,42 +258,24 @@ const AccessPointDetails = ({ locations }) => {
);
}
if (errorProfiles) {
return (
<Alert
message="Error"
description="Failed to load Access Point profiles."
type="error"
showIcon
/>
);
}
if (errorFirmware) {
return (
<Alert
message="Error"
description="Failed to load Access Point firmware."
type="error"
showIcon
/>
);
}
return (
<AccessPointDetailsPage
handleRefresh={refetchData}
onUpdateEquipment={handleUpdateEquipment}
data={data.getEquipment}
profiles={dataProfiles.getAllProfiles.items}
data={data?.getEquipment}
profiles={dataProfiles?.getAllProfiles?.items}
osData={{
loading: metricsLoading,
error: metricsError,
data: metricsData && metricsData.filterServiceMetrics.items,
}}
firmware={dataFirmware.getAllFirmware}
firmware={dataFirmware?.getAllFirmware}
locations={locations}
onUpdateEquipmentFirmware={handleUpdateEquipmentFirmware}
loadingProfiles={loadingProfiles}
errorProfiles={errorProfiles}
loadingFirmware={loadingFirmware}
errorFirmware={errorFirmware}
/>
);
};

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

@@ -27,7 +27,7 @@ const Network = () => {
variables: { customerId },
});
const { loading: loadingProfile, error: errorProfile, data: apProfiles } = useQuery(
GET_ALL_PROFILES,
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'equipment_ap' },
}

View File

@@ -77,9 +77,14 @@ const ProfileDetails = () => {
const { loading, error, data } = useQuery(GET_PROFILE, {
variables: { id },
});
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES, {
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'ssid' },
});
const { data: radiusProfiles } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'radius' },
});
const [updateProfile] = useMutation(UPDATE_PROFILE);
const [deleteProfile] = useMutation(DELETE_PROFILE);
@@ -170,6 +175,7 @@ const ProfileDetails = () => {
ssidProfiles={
(ssidProfiles && ssidProfiles.getAllProfiles && ssidProfiles.getAllProfiles.items) || []
}
radiusProfiles={radiusProfiles?.getAllProfiles?.items}
fileUpload={handleFileUpload}
/>
);

View File

@@ -1,29 +1,11 @@
import React, { useContext } from 'react';
import gql from 'graphql-tag';
import { useQuery, useMutation } from '@apollo/react-hooks';
import { Alert, notification } from 'antd';
import { Profile as ProfilePage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import UserContext from 'contexts/UserContext';
const GET_ALL_PROFILES = gql`
query GetAllProfiles($customerId: ID!, $cursor: String, $limit: Int) {
getAllProfiles(customerId: $customerId, cursor: $cursor, limit: $limit) {
items {
id
name
profileType
details
equipmentCount
}
context {
cursor
lastPage
}
}
}
`;
import { GET_ALL_PROFILES } from 'graphql/queries';
import UserContext from 'contexts/UserContext';
const DELETE_PROFILE = gql`
mutation DeleteProfile($id: ID!) {
@@ -35,9 +17,12 @@ const DELETE_PROFILE = gql`
const Profiles = () => {
const { customerId } = useContext(UserContext);
const { loading, error, data, refetch, fetchMore } = useQuery(GET_ALL_PROFILES, {
variables: { customerId, limit: 100 },
});
const { loading, error, data, refetch, fetchMore } = useQuery(
GET_ALL_PROFILES(`equipmentCount`),
{
variables: { customerId },
}
);
const [deleteProfile] = useMutation(DELETE_PROFILE);
const reloadTable = () => {
@@ -59,14 +44,14 @@ const Profiles = () => {
const handleLoadMore = () => {
if (!data.getAllProfiles.context.lastPage) {
fetchMore({
variables: { cursor: data.getAllProfiles.context.cursor },
variables: { context: { ...data.getAllProfiles.context } },
updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.getAllProfiles;
const newItems = fetchMoreResult.getAllProfiles.items;
return {
getAllProfiles: {
context: fetchMoreResult.getAllProfiles.context,
context: { ...fetchMoreResult.getAllProfiles.context },
items: [...previousEntry.items, ...newItems],
__typename: previousEntry.__typename,
},
@@ -83,6 +68,7 @@ const Profiles = () => {
message: 'Success',
description: 'Profile successfully deleted.',
});
refetch();
})
.catch(() =>
notification.error({
@@ -104,7 +90,7 @@ const Profiles = () => {
<ProfilePage
data={data.getAllProfiles.items}
onReload={reloadTable}
isLastPage={data.getAllProfiles.context.lastPage}
isLastPage={data?.getAllProfiles?.context?.lastPage}
onDeleteProfile={handleDeleteProfile}
onLoadMore={handleLoadMore}
/>

View File

@@ -21,7 +21,7 @@ const AutoProvision = () => {
}
);
const { data: dataProfile, loading: loadingProfile, error: errorProfile } = useQuery(
GET_ALL_PROFILES,
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'equipment_ap' },
}

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,27 +174,34 @@ export const FILTER_SERVICE_METRICS = gql`
txBytes
detailsJSON
}
context {
lastPage
cursor
}
context
}
}
`;
export const GET_ALL_PROFILES = gql`
query GetAllProfiles($customerId: ID!, $cursor: String, $type: String) {
getAllProfiles(customerId: $customerId, cursor: $cursor, type: $type) {
export const GET_ALL_PROFILES = (fields = '') => gql`
query GetAllProfiles(
$customerId: ID!
$cursor: String
$limit: Int
$type: String
$context: JSONObject
) {
getAllProfiles(
customerId: $customerId
cursor: $cursor
limit: $limit
type: $type
context: $context
) {
items {
id
name
profileType
details
${fields}
}
context {
cursor
lastPage
}
context
}
}
`;
@@ -219,10 +217,7 @@ export const GET_ALL_STATUS = gql`
clientCountPerOui
}
}
context {
lastPage
cursor
}
context
}
}
`;
@@ -298,7 +293,7 @@ export const FILTER_SYSTEM_EVENTS = gql`
$toTime: String!
$equipmentIds: [ID]
$dataTypes: [String]
$cursor: String
$context: JSONObject
$limit: Int
) {
filterSystemEvents(
@@ -307,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
}
}
`;

873
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "wlan-cloud-ui",
"version": "0.2.9",
"version": "0.3.0",
"author": "ConnectUs",
"description": "React Portal",
"engines": {
@@ -20,8 +20,8 @@
"@ant-design/icons": "^4.2.1",
"@apollo/react-hoc": "^3.1.4",
"@apollo/react-hooks": "^3.1.3",
"@tip-wlan/wlan-cloud-ui-library": "^0.2.9",
"antd": "^4.3.1",
"@tip-wlan/wlan-cloud-ui-library": "^0.3.0",
"antd": "^4.5.2",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",