mirror of
https://github.com/Telecominfraproject/wlan-cloud-ui.git
synced 2026-03-20 20:39:22 +00:00
Compare commits
189 Commits
hotfix/tes
...
hotfix/WIF
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cd1458f17 | ||
|
|
2b80c7cb82 | ||
|
|
92b522e14b | ||
|
|
917b949fea | ||
|
|
439ff1afbe | ||
|
|
3f3c81f5db | ||
|
|
76acff8b89 | ||
|
|
4bab1f3c1c | ||
|
|
2f12264af3 | ||
|
|
016d1ff439 | ||
|
|
1f06e0b89c | ||
|
|
cacb2a3833 | ||
|
|
bf39c6b6dc | ||
|
|
8d2de52870 | ||
|
|
8b0dc34ac4 | ||
|
|
6646226cb7 | ||
|
|
120ae073fb | ||
|
|
834b7b28a7 | ||
|
|
d9a970350b | ||
|
|
60c2c21997 | ||
|
|
26d74f6059 | ||
|
|
1682a2ca21 | ||
|
|
1fa7080593 | ||
|
|
ac405ae1c4 | ||
|
|
c1264c3ea0 | ||
|
|
cfee505a5b | ||
|
|
ba49ca4e16 | ||
|
|
acf36fb42b | ||
|
|
273ca85fde | ||
|
|
c40a8ca157 | ||
|
|
0dfb7a7901 | ||
|
|
153394cad0 | ||
|
|
1507320fae | ||
|
|
673002b685 | ||
|
|
c014ba5e40 | ||
|
|
b20caa666d | ||
|
|
c75e5ea934 | ||
|
|
631482ab6f | ||
|
|
2d42d59c54 | ||
|
|
229d50f1a8 | ||
|
|
f6078182ff | ||
|
|
3f0c1c0e33 | ||
|
|
6dbaddc021 | ||
|
|
64096d040d | ||
|
|
5a634b2e8a | ||
|
|
69972e0033 | ||
|
|
743c4f3665 | ||
|
|
d70df54986 | ||
|
|
b40b29f73d | ||
|
|
2206a9bf3f | ||
|
|
450fe6280f | ||
|
|
d0424480fe | ||
|
|
ea2b4f90b7 | ||
|
|
fbfd4895b1 | ||
|
|
eafc05b645 | ||
|
|
0009bd5ca6 | ||
|
|
e38dd84f11 | ||
|
|
e6a0dc9f12 | ||
|
|
327c4ea3d1 | ||
|
|
01dbd0a887 | ||
|
|
5b46dbf657 | ||
|
|
46c860f310 | ||
|
|
51d34055ba | ||
|
|
be3582514c | ||
|
|
afc6ddc30e | ||
|
|
4314239e1d | ||
|
|
bac628ea67 | ||
|
|
bac2f43eb0 | ||
|
|
f7681e9bd3 | ||
|
|
5d822bdd78 | ||
|
|
cbfce876b3 | ||
|
|
16d4933190 | ||
|
|
85f3386c23 | ||
|
|
c929a1eff5 | ||
|
|
401f22b10a | ||
|
|
40f2ef31ce | ||
|
|
2813057c31 | ||
|
|
8d1339c412 | ||
|
|
54ca94cefa | ||
|
|
d750a0e798 | ||
|
|
09f2e91f4c | ||
|
|
4f18a93375 | ||
|
|
5a41840f1d | ||
|
|
f5f30f3784 | ||
|
|
6edc98af47 | ||
|
|
15df3caf6b | ||
|
|
94a26fef43 | ||
|
|
b44290a28a | ||
|
|
823d7d0fef | ||
|
|
d33caa8885 | ||
|
|
c4d9f76c2e | ||
|
|
c416d87106 | ||
|
|
5023ed9d96 | ||
|
|
125e988f25 | ||
|
|
4069374d58 | ||
|
|
ded926c98b | ||
|
|
7b0becec58 | ||
|
|
9be76979ea | ||
|
|
cf9cc4d6ac | ||
|
|
0ef102e28e | ||
|
|
41f27c76b1 | ||
|
|
124a84b75f | ||
|
|
1b5a09636f | ||
|
|
81cc493aa3 | ||
|
|
41a27ff9ef | ||
|
|
1c6f8dfdba | ||
|
|
5911395fac | ||
|
|
941b952ff6 | ||
|
|
4065a9272c | ||
|
|
333b37a139 | ||
|
|
0939aacdbe | ||
|
|
bb1da8f0c9 | ||
|
|
a11c7d651d | ||
|
|
07f1f64537 | ||
|
|
8bde2ad4bc | ||
|
|
ac848713ea | ||
|
|
4bebfe68f6 | ||
|
|
7bf25f4edb | ||
|
|
0ff45e9d87 | ||
|
|
f877b4c3c1 | ||
|
|
ecf2c2fa8c | ||
|
|
d5c094d749 | ||
|
|
26dba66470 | ||
|
|
5ae31d7198 | ||
|
|
2bd50d4560 | ||
|
|
a8843d4be7 | ||
|
|
644cdd2c45 | ||
|
|
035a714fa6 | ||
|
|
2d7514fbde | ||
|
|
0c5f0842e9 | ||
|
|
86087930da | ||
|
|
e60ec0c713 | ||
|
|
fd4f90173b | ||
|
|
a4d4dce73a | ||
|
|
7b8f45d9f2 | ||
|
|
3affd7b6a6 | ||
|
|
5854c1a0a0 | ||
|
|
a2352e2d01 | ||
|
|
c0074b6610 | ||
|
|
dfb4bf21cd | ||
|
|
2514d9e77c | ||
|
|
f2c5b5c5f3 | ||
|
|
8b5af07f87 | ||
|
|
a1d4081f0b | ||
|
|
d6d054f53e | ||
|
|
5a49a0301e | ||
|
|
7936777344 | ||
|
|
057e7c2d0a | ||
|
|
7911c630b4 | ||
|
|
0108229ddb | ||
|
|
51750b83c8 | ||
|
|
aaf14b0d0a | ||
|
|
b2bee67551 | ||
|
|
afc222bb4a | ||
|
|
c595424269 | ||
|
|
69fbceefff | ||
|
|
f9c66adf00 | ||
|
|
56c0329bdb | ||
|
|
06cb3feac3 | ||
|
|
a159705cae | ||
|
|
02c20ffd6e | ||
|
|
dc8374300e | ||
|
|
c001ce21ba | ||
|
|
2dd3bff53c | ||
|
|
04bbc5fbed | ||
|
|
902de8bcb0 | ||
|
|
6c6635017a | ||
|
|
8891b5b3f9 | ||
|
|
8d2e5bb8a5 | ||
|
|
f29f31558a | ||
|
|
6e0cf15616 | ||
|
|
49d5771fca | ||
|
|
3794869adb | ||
|
|
3d105340af | ||
|
|
c8ee2138ad | ||
|
|
2e9dd99f3a | ||
|
|
ad0a6d299b | ||
|
|
0d58a8bb6a | ||
|
|
bcadd1f8d4 | ||
|
|
af809974b6 | ||
|
|
573718bc1e | ||
|
|
c7a1ec1dc3 | ||
|
|
19c0bb4393 | ||
|
|
2a521ce036 | ||
|
|
85e1ee16ee | ||
|
|
195518a137 | ||
|
|
6ea3c778cd | ||
|
|
3b6d1a57ca | ||
|
|
6498e2a984 |
28
.github/workflows/dockerpublish.yml
vendored
28
.github/workflows/dockerpublish.yml
vendored
@@ -13,6 +13,10 @@ on:
|
||||
# Run tests for any PRs.
|
||||
pull_request:
|
||||
|
||||
schedule:
|
||||
# runs nightly build at 5AM
|
||||
- cron: '00 09 * * *'
|
||||
|
||||
env:
|
||||
IMAGE_NAME: wlan-cloud-ui
|
||||
DOCKER_REPO: tip-tip-wlan-cloud-docker-repo.jfrog.io
|
||||
@@ -39,11 +43,28 @@ jobs:
|
||||
needs: test
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push'
|
||||
if: github.event_name == 'push' || github.event_name == 'schedule'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Adding property file with component version and commit hash
|
||||
run: |
|
||||
# Strip git ref prefix from version
|
||||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||
|
||||
# Strip "v" prefix from tag name
|
||||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||
|
||||
# Use Docker `latest` tag convention
|
||||
[ "$VERSION" == "master" ] && VERSION=latest
|
||||
|
||||
TIMESTAMP=$(date +'%Y-%m-%d')
|
||||
|
||||
echo date=$TIMESTAMP > app/commit.properties
|
||||
echo commitId=$GITHUB_SHA >> app/commit.properties
|
||||
echo projectVersion=$VERSION>> app/commit.properties
|
||||
|
||||
- name: Build image
|
||||
run: docker build . -f Dockerfile -t image --build-arg NPM_TOKEN=${{secrets.NPM_REPO_AUTH_TOKEN}}
|
||||
|
||||
@@ -56,6 +77,7 @@ jobs:
|
||||
- name: Push image
|
||||
run: |
|
||||
IMAGE_ID=$DOCKER_REPO/$IMAGE_NAME
|
||||
TIMESTAMP=$(date +'%Y-%m-%d')
|
||||
|
||||
# Change all uppercase to lowercase
|
||||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
|
||||
@@ -71,6 +93,10 @@ jobs:
|
||||
|
||||
echo IMAGE_ID=$IMAGE_ID
|
||||
echo VERSION=$VERSION
|
||||
echo TIMESTAMP=$TIMESTAMP
|
||||
|
||||
docker tag image $IMAGE_ID:$VERSION
|
||||
docker push $IMAGE_ID:$VERSION
|
||||
|
||||
docker tag image $IMAGE_ID:$VERSION-$TIMESTAMP
|
||||
docker push $IMAGE_ID:$VERSION-$TIMESTAMP
|
||||
|
||||
@@ -13,6 +13,7 @@ ENV PATH /app/node_modules/.bin:$PATH
|
||||
# where available (npm@5+)
|
||||
COPY package*.json ./
|
||||
|
||||
|
||||
#RUN npm install
|
||||
# If you are building your code for production
|
||||
RUN (echo "@tip-wlan:registry=https://tip.jfrog.io/artifactory/api/npm/tip-wlan-cloud-npm-repo/" && echo "//tip.jfrog.io/artifactory/api/npm/tip-wlan-cloud-npm-repo/:_authToken=$NPM_TOKEN") > .npmrc
|
||||
@@ -24,7 +25,12 @@ RUN npm run build
|
||||
|
||||
# production environment
|
||||
FROM nginx:stable-alpine
|
||||
RUN apk add --no-cache jq
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY docker_entrypoint.sh generate_config_js.sh /
|
||||
COPY app/commit.properties /
|
||||
RUN chmod +x docker_entrypoint.sh generate_config_js.sh
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
ENTRYPOINT ["/docker_entrypoint.sh"]
|
||||
|
||||
40
README.md
40
README.md
@@ -2,12 +2,30 @@
|
||||
|
||||
## Set up environment:
|
||||
|
||||
Delete from package.json (undo this delete after all steps)
|
||||
`"@tip-wlan/wlan-cloud-ui-library": X.X.X,`
|
||||
|
||||
Install Dependencies
|
||||
Install Dependencies:
|
||||
`npm install`
|
||||
|
||||
You will get an error installing the package [wlan-cloud-ui-library](https://github.com/Telecominfraproject/wlan-cloud-ui-library) because it is in a private npm registry.
|
||||
You can either install the package with the commands below or clone the repo [wlan-cloud-ui-library](https://github.com/Telecominfraproject/wlan-cloud-ui-library) and skip to the section Set up Full Development.
|
||||
|
||||
Run
|
||||
|
||||
```
|
||||
npm login --registry=https://tip.jfrog.io/artifactory/api/npm/tip-wlan-cloud-npm-repo/
|
||||
```
|
||||
|
||||
And enter the supplied credentials. Ask @sean-macfarlane for credentials if you don't have.
|
||||
|
||||
Install package:
|
||||
|
||||
```
|
||||
npm i --registry=https://tip.jfrog.io/artifactory/api/npm/tip-wlan-cloud-npm-repo/ @tip-wlan/wlan-cloud-ui-library
|
||||
```
|
||||
|
||||
### Set up Full Development
|
||||
|
||||
_Skip this section if you are not using a local [wlan-cloud-ui-library](https://github.com/Telecominfraproject/wlan-cloud-ui-library)_
|
||||
|
||||
Clone [wlan-cloud-ui-library](https://github.com/Telecominfraproject/wlan-cloud-ui-library) in parent folder
|
||||
|
||||
```
|
||||
@@ -28,15 +46,25 @@ If `npm link` fails due to Permissions run with `sudo`
|
||||
sudo npm link ../wlan-cloud-ui-library
|
||||
```
|
||||
|
||||
To run Full Development you must clone [wlan-cloud-graphql-gw](https://github.com/Telecominfraproject/wlan-cloud-graphql-gw), follow it's README, and run it. Or you use the live production build by setting the environment variable `API` to the GraphQL domain.
|
||||
|
||||
## Run:
|
||||
|
||||
### Development
|
||||
### Bare Development
|
||||
|
||||
This is if you only want to run this repo locally, and want to use the live production builds of [wlan-cloud-ui-library](https://github.com/Telecominfraproject/wlan-cloud-ui-library) and [wlan-cloud-graphql-gw](https://github.com/Telecominfraproject/wlan-cloud-graphql-gw)
|
||||
|
||||
`npm run start:bare`
|
||||
|
||||
### Full Development
|
||||
|
||||
If you have cloned [wlan-cloud-ui-library](https://github.com/Telecominfraproject/wlan-cloud-ui-library) and [wlan-cloud-graphql-gw](https://github.com/Telecominfraproject/wlan-cloud-graphql-gw)
|
||||
|
||||
`npm start`
|
||||
|
||||
### Tests
|
||||
|
||||
`npm run test`
|
||||
`npm test`
|
||||
|
||||
### Production
|
||||
|
||||
|
||||
4
app/commit.properties
Normal file
4
app/commit.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
#This file will be used when running the docker locally
|
||||
date=${date}
|
||||
commitId=${commit.id}
|
||||
projectVersion=${project.version}
|
||||
@@ -1,15 +1,15 @@
|
||||
import React, { useContext } from 'react';
|
||||
import gql from 'graphql-tag';
|
||||
import { useQuery, useMutation } from '@apollo/react-hooks';
|
||||
import { Alert, notification } from 'antd';
|
||||
import { useMutation, gql } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
|
||||
import { Accounts as AccountsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { Accounts as AccountsPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -69,120 +66,117 @@ const DELETE_USER = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const Accounts = () => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const Accounts = withQuery(
|
||||
({ data, fetchMore, refetch }) => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
|
||||
const { data, loading, error, refetch, fetchMore } = useQuery(GET_ALL_USERS, {
|
||||
variables: { customerId },
|
||||
});
|
||||
const [createUser] = useMutation(CREATE_USER);
|
||||
const [updateUser] = useMutation(UPDATE_USER);
|
||||
const [deleteUser] = useMutation(DELETE_USER);
|
||||
const [createUser] = useMutation(CREATE_USER);
|
||||
const [updateUser] = useMutation(UPDATE_USER);
|
||||
const [deleteUser] = useMutation(DELETE_USER);
|
||||
|
||||
const handleLoadMore = () => {
|
||||
if (!data.getAllUsers.context.lastPage) {
|
||||
fetchMore({
|
||||
variables: { cursor: data.getAllUsers.context.cursor },
|
||||
updateQuery: (previousResult, { fetchMoreResult }) => {
|
||||
const previousEntry = previousResult.getAllUsers;
|
||||
const newItems = fetchMoreResult.getAllUsers.items;
|
||||
const handleLoadMore = () => {
|
||||
if (!data.getAllUsers.context.lastPage) {
|
||||
fetchMore({
|
||||
variables: { context: data.getAllUsers.context },
|
||||
updateQuery: (previousResult, { fetchMoreResult }) => {
|
||||
const previousEntry = previousResult.getAllUsers;
|
||||
const newItems = fetchMoreResult.getAllUsers.items;
|
||||
|
||||
return {
|
||||
getAllUsers: {
|
||||
context: fetchMoreResult.getAllUsers.context,
|
||||
items: [...previousEntry.items, ...newItems],
|
||||
__typename: previousEntry.__typename,
|
||||
},
|
||||
};
|
||||
return {
|
||||
getAllUsers: {
|
||||
context: fetchMoreResult.getAllUsers.context,
|
||||
items: [...previousEntry.items, ...newItems],
|
||||
__typename: previousEntry.__typename,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreateUser = (email, password, role) => {
|
||||
createUser({
|
||||
variables: {
|
||||
username: email,
|
||||
password,
|
||||
role,
|
||||
customerId,
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreateUser = (email, password, role) => {
|
||||
createUser({
|
||||
variables: {
|
||||
username: email,
|
||||
password,
|
||||
role,
|
||||
customerId,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Account successfully created.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Account could not be created.',
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Account successfully created.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Account could not be created.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleEditUser = (id, email, password, role, lastModifiedTimestamp) => {
|
||||
updateUser({
|
||||
variables: {
|
||||
id,
|
||||
username: email,
|
||||
password,
|
||||
role,
|
||||
customerId,
|
||||
lastModifiedTimestamp,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Account successfully updated.',
|
||||
});
|
||||
const handleEditUser = (id, email, password, role, lastModifiedTimestamp) => {
|
||||
updateUser({
|
||||
variables: {
|
||||
id,
|
||||
username: email,
|
||||
password,
|
||||
role,
|
||||
customerId,
|
||||
lastModifiedTimestamp,
|
||||
},
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Account could not be updated.',
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Account successfully updated.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Account could not be updated.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleDeleteUser = id => {
|
||||
deleteUser({ variables: { id } })
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Account successfully deleted.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Account could not be deleted.',
|
||||
const handleDeleteUser = id => {
|
||||
deleteUser({ variables: { id } })
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Account successfully deleted.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Account could not be deleted.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
return (
|
||||
<AccountsPage
|
||||
data={data.getAllUsers.items}
|
||||
onLoadMore={handleLoadMore}
|
||||
onCreateUser={handleCreateUser}
|
||||
onEditUser={handleEditUser}
|
||||
onDeleteUser={handleDeleteUser}
|
||||
isLastPage={data.getAllUsers.context.lastPage}
|
||||
/>
|
||||
);
|
||||
},
|
||||
GET_ALL_USERS,
|
||||
() => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
return { customerId };
|
||||
}
|
||||
);
|
||||
|
||||
if (error) {
|
||||
return <Alert message="Error" description="Failed to load Users." type="error" showIcon />;
|
||||
}
|
||||
|
||||
return (
|
||||
<AccountsPage
|
||||
data={data.getAllUsers.items}
|
||||
onLoadMore={handleLoadMore}
|
||||
onCreateUser={handleCreateUser}
|
||||
onEditUser={handleEditUser}
|
||||
onDeleteUser={handleDeleteUser}
|
||||
isLastPage={data.getAllUsers.context.lastPage}
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default Accounts;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { AddProfile as AddProfilePage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import gql from 'graphql-tag';
|
||||
import { useMutation, useQuery } from '@apollo/react-hooks';
|
||||
import { useMutation, useQuery, gql } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { GET_ALL_PROFILES } from 'graphql/queries';
|
||||
import { updateQueryGetAllProfiles } from 'graphql/functions';
|
||||
|
||||
const CREATE_PROFILE = gql`
|
||||
mutation CreateProfile(
|
||||
@@ -33,10 +34,11 @@ const CREATE_PROFILE = gql`
|
||||
|
||||
const AddProfile = () => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES, {
|
||||
const { data: ssidProfiles, fetchMore } = useQuery(GET_ALL_PROFILES(), {
|
||||
variables: { customerId, type: 'ssid' },
|
||||
});
|
||||
const [createProfile] = useMutation(CREATE_PROFILE);
|
||||
const history = useHistory();
|
||||
|
||||
const handleAddProfile = (profileType, name, details, childProfileIds = []) => {
|
||||
createProfile({
|
||||
@@ -53,6 +55,7 @@ const AddProfile = () => {
|
||||
message: 'Success',
|
||||
description: 'Profile successfully created.',
|
||||
});
|
||||
history.push('/profiles', { refetch: true });
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
@@ -62,12 +65,31 @@ const AddProfile = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const handleFetchProfiles = e => {
|
||||
if (ssidProfiles.getAllProfiles.context.lastPage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
e.persist();
|
||||
const { target } = e;
|
||||
|
||||
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
|
||||
fetchMore({
|
||||
variables: { context: { ...ssidProfiles.getAllProfiles.context } },
|
||||
updateQuery: updateQueryGetAllProfiles,
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
return (
|
||||
<AddProfilePage
|
||||
onCreateProfile={handleAddProfile}
|
||||
ssidProfiles={
|
||||
(ssidProfiles && ssidProfiles.getAllProfiles && ssidProfiles.getAllProfiles.items) || []
|
||||
}
|
||||
onFetchMoreProfiles={handleFetchProfiles}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React, { useContext } from 'react';
|
||||
import gql from 'graphql-tag';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import { Alert, notification } from 'antd';
|
||||
import { Alarms as AlarmsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { gql } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import { Alarms as AlarmsPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
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,71 +19,63 @@ const GET_ALL_ALARMS = gql`
|
||||
name
|
||||
}
|
||||
}
|
||||
context {
|
||||
cursor
|
||||
lastPage
|
||||
}
|
||||
context
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const Alarms = () => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { loading, error, data, refetch, fetchMore } = useQuery(GET_ALL_ALARMS, {
|
||||
variables: { customerId },
|
||||
});
|
||||
|
||||
const handleOnReload = () => {
|
||||
refetch()
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Alarms reloaded.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Alarms could not be reloaded.',
|
||||
const Alarms = withQuery(
|
||||
({ data, refetch, fetchMore }) => {
|
||||
const handleOnReload = () => {
|
||||
refetch()
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Alarms reloaded.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Alarms could not be reloaded.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleLoadMore = () => {
|
||||
if (!data.getAllAlarms.context.lastPage) {
|
||||
fetchMore({
|
||||
variables: { cursor: data.getAllAlarms.context.cursor },
|
||||
updateQuery: (previousResult, { fetchMoreResult }) => {
|
||||
const previousEntry = previousResult.getAllAlarms;
|
||||
const newItems = fetchMoreResult.getAllAlarms.items;
|
||||
const handleLoadMore = () => {
|
||||
if (!data.getAllAlarms.context.lastPage) {
|
||||
fetchMore({
|
||||
variables: { context: data.getAllAlarms.context },
|
||||
updateQuery: (previousResult, { fetchMoreResult }) => {
|
||||
const previousEntry = previousResult.getAllAlarms;
|
||||
const newItems = fetchMoreResult.getAllAlarms.items;
|
||||
|
||||
return {
|
||||
getAllAlarms: {
|
||||
context: fetchMoreResult.getAllAlarms.context,
|
||||
items: [...previousEntry.items, ...newItems],
|
||||
__typename: previousEntry.__typename,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
return {
|
||||
getAllAlarms: {
|
||||
context: fetchMoreResult.getAllAlarms.context,
|
||||
items: [...previousEntry.items, ...newItems],
|
||||
__typename: previousEntry.__typename,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
return (
|
||||
<AlarmsPage
|
||||
data={data.getAllAlarms.items}
|
||||
onReload={handleOnReload}
|
||||
onLoadMore={handleLoadMore}
|
||||
isLastPage={data.getAllAlarms.context.lastPage}
|
||||
/>
|
||||
);
|
||||
},
|
||||
GET_ALL_ALARMS,
|
||||
() => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
return { customerId, errorPolicy: 'all' };
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <Alert message="Error" description="Failed to load alarms." type="error" showIcon />;
|
||||
}
|
||||
return (
|
||||
<AlarmsPage
|
||||
data={data.getAllAlarms.items}
|
||||
onReload={handleOnReload}
|
||||
onLoadMore={handleLoadMore}
|
||||
isLastPage={data.getAllAlarms.context.lastPage}
|
||||
/>
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
export default Alarms;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React, { useContext, useMemo, useState } from 'react';
|
||||
import { Alert } from 'antd';
|
||||
import React, { useContext, useEffect, useMemo, useState, useRef } from 'react';
|
||||
import moment from 'moment';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import { Dashboard as DashboardPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { useQuery } from '@apollo/client';
|
||||
import { Dashboard as DashboardPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { FILTER_SYSTEM_EVENTS, GET_ALL_STATUS } from 'graphql/queries';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
function formatBytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
@@ -13,7 +13,7 @@ function formatBytes(bytes, decimals = 2) {
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
const i = Math.floor(Math.log(Math.abs(bytes)) / Math.log(k));
|
||||
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i] || ''}`;
|
||||
@@ -36,180 +36,252 @@ const USER_FRIENDLY_RADIOS = {
|
||||
is5GHz: '5GHz',
|
||||
};
|
||||
|
||||
const Dashboard = () => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { loading, error, data } = useQuery(GET_ALL_STATUS, {
|
||||
variables: { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] },
|
||||
});
|
||||
const [toTime] = useState(
|
||||
moment()
|
||||
.valueOf()
|
||||
.toString()
|
||||
);
|
||||
const [fromTime] = useState(
|
||||
moment()
|
||||
.subtract(24, 'hours')
|
||||
.valueOf()
|
||||
.toString()
|
||||
);
|
||||
const lineChartConfig = [
|
||||
{ key: 'inservicesAPs', title: 'Inservice APs (24 hours)' },
|
||||
{ key: 'clientDevices', title: 'Client Devices (24 hours)' },
|
||||
{
|
||||
key: 'traffic',
|
||||
title: 'Traffic (24 hours)',
|
||||
options: { formatter: trafficLabelFormatter, tooltipFormatter: trafficTooltipFormatter },
|
||||
},
|
||||
];
|
||||
|
||||
const {
|
||||
loading: metricsLoading,
|
||||
error: metricsError,
|
||||
data: metricsData,
|
||||
// refetch: metricsRefetch,
|
||||
} = useQuery(FILTER_SYSTEM_EVENTS, {
|
||||
variables: {
|
||||
customerId,
|
||||
fromTime,
|
||||
toTime,
|
||||
equipmentIds: [0],
|
||||
dataTypes: ['StatusChangedEvent'],
|
||||
limit: 1000,
|
||||
},
|
||||
});
|
||||
const Dashboard = withQuery(
|
||||
({ data }) => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const initialGraphTime = useRef({
|
||||
toTime: moment()
|
||||
.valueOf()
|
||||
.toString(),
|
||||
fromTime: moment()
|
||||
.subtract(24, 'hours')
|
||||
.valueOf()
|
||||
.toString(),
|
||||
});
|
||||
|
||||
const formatLineChartData = (list = []) => {
|
||||
const lineChartData = {
|
||||
const [lineChartData, setLineChartData] = useState({
|
||||
inservicesAPs: {
|
||||
title: 'Inservice APs (24 hours)',
|
||||
data: { key: 'Inservice APs', value: [] },
|
||||
key: 'Inservice APs',
|
||||
value: [],
|
||||
},
|
||||
clientDevices: {
|
||||
is2dot4GHz: {
|
||||
key: USER_FRIENDLY_RADIOS.is2dot4GHz,
|
||||
value: [],
|
||||
},
|
||||
is5GHz: {
|
||||
key: USER_FRIENDLY_RADIOS.is5GHz,
|
||||
value: [],
|
||||
},
|
||||
},
|
||||
clientDevices: { title: 'Client Devices (24 hours)' },
|
||||
traffic: {
|
||||
title: 'Traffic (24 hours)',
|
||||
formatter: trafficLabelFormatter,
|
||||
tooltipFormatter: trafficTooltipFormatter,
|
||||
data: {
|
||||
trafficBytesDownstream: { key: 'Down Stream', value: [] },
|
||||
trafficBytesUpstream: { key: 'Up Stream', value: [] },
|
||||
trafficBytesDownstream: {
|
||||
key: 'Down Stream',
|
||||
value: [],
|
||||
},
|
||||
trafficBytesUpstream: {
|
||||
key: 'Up Stream',
|
||||
value: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
const clientDevicesData = {};
|
||||
});
|
||||
|
||||
list.forEach(
|
||||
({
|
||||
eventTimestamp,
|
||||
details: {
|
||||
payload: {
|
||||
details: {
|
||||
equipmentInServiceCount,
|
||||
associatedClientsCountPerRadio: radios,
|
||||
trafficBytesDownstream,
|
||||
trafficBytesUpstream,
|
||||
},
|
||||
},
|
||||
const { loading: metricsLoading, error: metricsError, data: metricsData, fetchMore } = useQuery(
|
||||
FILTER_SYSTEM_EVENTS,
|
||||
{
|
||||
variables: {
|
||||
customerId,
|
||||
fromTime: initialGraphTime.current.fromTime,
|
||||
toTime: initialGraphTime.current.toTime,
|
||||
equipmentIds: [0],
|
||||
dataTypes: ['StatusChangedEvent'],
|
||||
limit: 3000, // TODO: make get all in GraphQL
|
||||
},
|
||||
}) => {
|
||||
lineChartData.inservicesAPs.data.value.push([eventTimestamp, equipmentInServiceCount]);
|
||||
Object.keys(radios).forEach(key => {
|
||||
if (!clientDevicesData[key]) {
|
||||
clientDevicesData[key] = {
|
||||
key: USER_FRIENDLY_RADIOS[key] || key,
|
||||
value: [],
|
||||
};
|
||||
}
|
||||
clientDevicesData[key].value.push([eventTimestamp, radios[key]]);
|
||||
});
|
||||
|
||||
lineChartData.traffic.data.trafficBytesDownstream.value.push([
|
||||
eventTimestamp,
|
||||
trafficBytesDownstream,
|
||||
]);
|
||||
lineChartData.traffic.data.trafficBytesUpstream.value.push([
|
||||
eventTimestamp,
|
||||
trafficBytesUpstream,
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
...lineChartData,
|
||||
clientDevices: { ...lineChartData.clientDevices, data: { ...clientDevicesData } },
|
||||
const formatLineChartData = (list = []) => {
|
||||
if (list.length) {
|
||||
setLineChartData(prev => {
|
||||
const inservicesAPs = [];
|
||||
const clientDevices2dot4GHz = [];
|
||||
const clientDevices5GHz = [];
|
||||
const trafficBytesDownstreamData = [];
|
||||
const trafficBytesUpstreamData = [];
|
||||
let totalDown = 0;
|
||||
let totalUp = 0;
|
||||
|
||||
list.forEach(
|
||||
({
|
||||
eventTimestamp,
|
||||
details: {
|
||||
payload: {
|
||||
details: {
|
||||
equipmentInServiceCount,
|
||||
associatedClientsCountPerRadio: radios,
|
||||
trafficBytesDownstream,
|
||||
trafficBytesUpstream,
|
||||
},
|
||||
},
|
||||
},
|
||||
}) => {
|
||||
inservicesAPs.push([eventTimestamp, equipmentInServiceCount]);
|
||||
|
||||
let total5GHz = 0;
|
||||
total5GHz += (radios?.is5GHz || 0) + (radios?.is5GHzL || 0) + (radios?.is5GHzU || 0); // combine all 5GHz radios
|
||||
|
||||
clientDevices2dot4GHz.push([eventTimestamp, radios.is2dot4GHz || 0]);
|
||||
clientDevices5GHz.push([eventTimestamp, total5GHz || 0]);
|
||||
|
||||
trafficBytesDownstreamData.push([eventTimestamp, trafficBytesDownstream || 0]);
|
||||
trafficBytesUpstreamData.push([eventTimestamp, trafficBytesUpstream || 0]);
|
||||
|
||||
totalDown += trafficBytesDownstream || 0;
|
||||
totalUp += trafficBytesUpstream || 0;
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
inservicesAPs: {
|
||||
...prev.inservicesAPs,
|
||||
value: [...prev.inservicesAPs.value, ...inservicesAPs],
|
||||
},
|
||||
clientDevices: {
|
||||
is2dot4GHz: {
|
||||
...prev.clientDevices.is2dot4GHz,
|
||||
value: [...prev.clientDevices.is2dot4GHz.value, ...clientDevices2dot4GHz],
|
||||
},
|
||||
is5GHz: {
|
||||
...prev.clientDevices.is5GHz,
|
||||
value: [...prev.clientDevices.is5GHz.value, ...clientDevices5GHz],
|
||||
},
|
||||
},
|
||||
traffic: {
|
||||
trafficBytesDownstream: {
|
||||
...prev.traffic.trafficBytesDownstream,
|
||||
value: [
|
||||
...prev.traffic.trafficBytesDownstream.value,
|
||||
...trafficBytesDownstreamData,
|
||||
],
|
||||
},
|
||||
trafficBytesUpstream: {
|
||||
...prev.traffic.trafficBytesUpstream,
|
||||
value: [...prev.traffic.trafficBytesUpstream.value, ...trafficBytesUpstreamData],
|
||||
},
|
||||
},
|
||||
totalDownstreamTraffic: totalDown,
|
||||
totalUpstreamTraffic: totalUp,
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const lineChartsData = useMemo(
|
||||
() => formatLineChartData(metricsData?.filterSystemEvents?.items),
|
||||
[metricsData]
|
||||
);
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
const toTime = moment()
|
||||
.valueOf()
|
||||
.toString();
|
||||
const fromTime = moment()
|
||||
.subtract(5, 'minutes')
|
||||
.valueOf()
|
||||
.toString();
|
||||
fetchMore({
|
||||
variables: {
|
||||
fromTime,
|
||||
toTime,
|
||||
},
|
||||
updateQuery: (_, { fetchMoreResult }) => {
|
||||
formatLineChartData(fetchMoreResult?.filterSystemEvents?.items);
|
||||
},
|
||||
});
|
||||
}, 300000);
|
||||
|
||||
const statsArr = useMemo(() => {
|
||||
const status = data?.getAllStatus?.items[0]?.detailsJSON || {};
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
const {
|
||||
associatedClientsCountPerRadio,
|
||||
totalProvisionedEquipment,
|
||||
equipmentInServiceCount,
|
||||
equipmentWithClientsCount,
|
||||
trafficBytesDownstream,
|
||||
trafficBytesUpstream,
|
||||
} = status;
|
||||
useEffect(() => {
|
||||
formatLineChartData(metricsData?.filterSystemEvents?.items);
|
||||
}, [metricsData]);
|
||||
|
||||
const clientRadios = {};
|
||||
let totalAssociated = 0;
|
||||
if (associatedClientsCountPerRadio) {
|
||||
Object.keys(associatedClientsCountPerRadio).forEach(i => {
|
||||
if (i.includes('5GHz')) {
|
||||
if (!clientRadios['5GHz']) {
|
||||
clientRadios['5GHz'] = 0;
|
||||
const statsData = useMemo(() => {
|
||||
const status = data?.getAllStatus?.items[0]?.detailsJSON || {};
|
||||
|
||||
const {
|
||||
associatedClientsCountPerRadio,
|
||||
totalProvisionedEquipment,
|
||||
equipmentInServiceCount,
|
||||
equipmentWithClientsCount,
|
||||
} = status;
|
||||
|
||||
const clientRadios = {};
|
||||
let totalAssociated = 0;
|
||||
if (associatedClientsCountPerRadio) {
|
||||
Object.keys(associatedClientsCountPerRadio).forEach(i => {
|
||||
if (i.includes('5GHz')) {
|
||||
if (!clientRadios['5GHz']) {
|
||||
clientRadios['5GHz'] = 0;
|
||||
}
|
||||
clientRadios['5GHz'] += associatedClientsCountPerRadio[i];
|
||||
} else {
|
||||
const key = USER_FRIENDLY_RADIOS[i] || i;
|
||||
clientRadios[key] = associatedClientsCountPerRadio[i];
|
||||
}
|
||||
clientRadios['5GHz'] += associatedClientsCountPerRadio[i];
|
||||
} else {
|
||||
const key = USER_FRIENDLY_RADIOS[i] || i;
|
||||
clientRadios[key] = associatedClientsCountPerRadio[i];
|
||||
}
|
||||
totalAssociated += associatedClientsCountPerRadio[i];
|
||||
});
|
||||
}
|
||||
totalAssociated += associatedClientsCountPerRadio[i];
|
||||
});
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
title: 'Access Point',
|
||||
'Total Provisioned': totalProvisionedEquipment,
|
||||
'In Service': equipmentInServiceCount,
|
||||
'With Clients': equipmentWithClientsCount,
|
||||
},
|
||||
{
|
||||
title: 'Client Devices',
|
||||
'Total Associated': totalAssociated,
|
||||
...clientRadios,
|
||||
},
|
||||
{
|
||||
title: 'Usage Information',
|
||||
'Total Traffic (US)': formatBytes(trafficBytesUpstream),
|
||||
'Total Traffic (DS)': formatBytes(trafficBytesDownstream),
|
||||
},
|
||||
];
|
||||
}, [data]);
|
||||
return {
|
||||
totalProvisionedEquipment,
|
||||
equipmentInServiceCount,
|
||||
equipmentWithClientsCount,
|
||||
totalAssociated,
|
||||
clientRadios,
|
||||
};
|
||||
}, [data]);
|
||||
|
||||
const pieChartsData = useMemo(() => {
|
||||
const { clientCountPerOui, equipmentCountPerOui } = data?.getAllStatus?.items[0]?.details || {};
|
||||
const pieChartsData = useMemo(() => {
|
||||
const { clientCountPerOui, equipmentCountPerOui } =
|
||||
data?.getAllStatus?.items[0]?.details || {};
|
||||
|
||||
return [
|
||||
{ title: 'AP Vendors', ...equipmentCountPerOui },
|
||||
{ title: 'Client Vendors', ...clientCountPerOui },
|
||||
];
|
||||
}, [data]);
|
||||
return [
|
||||
{ title: 'AP Vendors', ...equipmentCountPerOui },
|
||||
{ title: 'Client Vendors', ...clientCountPerOui },
|
||||
];
|
||||
}, [data]);
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
return (
|
||||
<DashboardPage
|
||||
statsCardDetails={[
|
||||
{
|
||||
title: 'Access Point',
|
||||
'Total Provisioned': statsData?.totalProvisionedEquipment,
|
||||
'In Service': statsData?.equipmentInServiceCount,
|
||||
'With Clients': statsData?.equipmentWithClientsCount,
|
||||
},
|
||||
{
|
||||
title: 'Client Devices',
|
||||
'Total Associated': statsData?.totalAssociated,
|
||||
...statsData?.clientRadios,
|
||||
},
|
||||
{
|
||||
title: 'Usage Information (24 hours)',
|
||||
'Total Traffic (US)': formatBytes(lineChartData?.totalUpstreamTraffic),
|
||||
'Total Traffic (DS)': formatBytes(lineChartData?.totalDownstreamTraffic),
|
||||
},
|
||||
]}
|
||||
pieChartDetails={pieChartsData}
|
||||
lineChartData={lineChartData}
|
||||
lineChartConfig={lineChartConfig}
|
||||
lineChartLoading={metricsLoading}
|
||||
lineChartError={metricsError}
|
||||
/>
|
||||
);
|
||||
},
|
||||
GET_ALL_STATUS,
|
||||
() => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
return { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] };
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <Alert message="Error" description="Failed to load Dashboard" type="error" showIcon />;
|
||||
}
|
||||
|
||||
return (
|
||||
<DashboardPage
|
||||
statsCardDetails={statsArr}
|
||||
pieChartDetails={pieChartsData}
|
||||
lineChartDetails={lineChartsData}
|
||||
lineChartLoading={metricsLoading}
|
||||
lineChartError={metricsError}
|
||||
/>
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
export default Dashboard;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useContext } from 'react';
|
||||
import gql from 'graphql-tag';
|
||||
import { useMutation, useQuery } from '@apollo/react-hooks';
|
||||
import { notification, Alert } from 'antd';
|
||||
import { EditAccount as EditAccountPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { useMutation, gql } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import { EditAccount as EditAccountPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
|
||||
@@ -44,47 +44,45 @@ const UPDATE_USER = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const EditAccount = () => {
|
||||
const { id, email } = useContext(UserContext);
|
||||
const { loading, error, data } = useQuery(GET_USER, { variables: { id } });
|
||||
const [updateUser] = useMutation(UPDATE_USER);
|
||||
const EditAccount = withQuery(
|
||||
({ data }) => {
|
||||
const { id, email } = useContext(UserContext);
|
||||
const [updateUser] = useMutation(UPDATE_USER);
|
||||
|
||||
const handleSubmit = newPassword => {
|
||||
const { role, customerId, lastModifiedTimestamp } = data.getUser;
|
||||
const handleSubmit = newPassword => {
|
||||
const { role, customerId, lastModifiedTimestamp } = data.getUser;
|
||||
|
||||
updateUser({
|
||||
variables: {
|
||||
id,
|
||||
username: email,
|
||||
password: newPassword,
|
||||
role,
|
||||
customerId,
|
||||
lastModifiedTimestamp,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Password successfully updated.',
|
||||
});
|
||||
updateUser({
|
||||
variables: {
|
||||
id,
|
||||
username: email,
|
||||
password: newPassword,
|
||||
role,
|
||||
customerId,
|
||||
lastModifiedTimestamp,
|
||||
},
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Password could not be updated.',
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Password successfully updated.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Password could not be updated.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
return <EditAccountPage onSubmit={handleSubmit} email={email} />;
|
||||
},
|
||||
GET_USER,
|
||||
() => {
|
||||
const { id } = useContext(UserContext);
|
||||
return { id };
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <Alert message="Error" description="Failed to load User." type="error" showIcon />;
|
||||
}
|
||||
|
||||
return <EditAccountPage onSubmit={handleSubmit} email={email} />;
|
||||
};
|
||||
);
|
||||
|
||||
export default EditAccount;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import gql from 'graphql-tag';
|
||||
import { useMutation, useApolloClient } from '@apollo/react-hooks';
|
||||
import { useMutation, useApolloClient, gql } from '@apollo/client';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { notification } from 'antd';
|
||||
|
||||
@@ -27,9 +26,10 @@ const Login = () => {
|
||||
const handleLogin = (email, password) => {
|
||||
authenticateUser({ variables: { email, password } })
|
||||
.then(({ data }) => {
|
||||
client.resetStore();
|
||||
updateToken(data.authenticateUser);
|
||||
history.push('/');
|
||||
client.resetStore().then(() => {
|
||||
updateToken(data.authenticateUser);
|
||||
history.push('/');
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { useApolloClient, useQuery } from '@apollo/react-hooks';
|
||||
import { useApolloClient, useQuery } from '@apollo/client';
|
||||
import { AppLayout as Layout } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import { GET_ALARM_COUNT } from 'graphql/queries';
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import React, { useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import gql from 'graphql-tag';
|
||||
import { useQuery, useMutation } from '@apollo/react-hooks';
|
||||
import { Alert, Spin, notification } from 'antd';
|
||||
import { useQuery, useMutation, gql } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import moment from 'moment';
|
||||
import { AccessPointDetails as AccessPointDetailsPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import { FILTER_SERVICE_METRICS } from 'graphql/queries';
|
||||
import { UPDATE_EQUIPMENT_FIRMWARE } from 'graphql/mutations';
|
||||
import { FILTER_SERVICE_METRICS, GET_ALL_FIRMWARE, GET_ALL_PROFILES } from 'graphql/queries';
|
||||
import {
|
||||
UPDATE_EQUIPMENT_FIRMWARE,
|
||||
REQUEST_EQUIPMENT_SWITCH_BANK,
|
||||
REQUEST_EQUIPMENT_REBOOT,
|
||||
} from 'graphql/mutations';
|
||||
import { updateQueryGetAllProfiles } from 'graphql/functions';
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
const GET_EQUIPMENT = gql`
|
||||
query GetEquipment($id: ID!) {
|
||||
@@ -27,6 +32,7 @@ const GET_EQUIPMENT = gql`
|
||||
lastModifiedTimestamp
|
||||
details
|
||||
profile {
|
||||
id
|
||||
name
|
||||
childProfiles {
|
||||
id
|
||||
@@ -70,20 +76,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!
|
||||
@@ -129,193 +121,225 @@ const UPDATE_EQUIPMENT = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_ALL_PROFILES = gql`
|
||||
query GetAllProfiles($customerId: ID!, $cursor: String, $type: String) {
|
||||
getAllProfiles(customerId: $customerId, cursor: $cursor, type: $type) {
|
||||
items {
|
||||
id
|
||||
name
|
||||
profileType
|
||||
details
|
||||
childProfiles {
|
||||
id
|
||||
name
|
||||
details
|
||||
}
|
||||
}
|
||||
context {
|
||||
cursor
|
||||
lastPage
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const toTime = moment();
|
||||
const fromTime = moment().subtract(1, 'hour');
|
||||
|
||||
const AccessPointDetails = ({ locations }) => {
|
||||
const { id } = useParams();
|
||||
const { customerId } = useContext(UserContext);
|
||||
const AccessPointDetails = withQuery(
|
||||
({ data, refetch, locations }) => {
|
||||
const { id } = useParams();
|
||||
const { customerId } = useContext(UserContext);
|
||||
|
||||
const { loading, error, data, refetch } = useQuery(GET_EQUIPMENT, {
|
||||
variables: { id },
|
||||
});
|
||||
const { data: dataProfiles, error: errorProfiles, loading: landingProfiles } = useQuery(
|
||||
GET_ALL_PROFILES,
|
||||
{
|
||||
variables: { customerId, type: 'equipment_ap' },
|
||||
}
|
||||
);
|
||||
const {
|
||||
loading: metricsLoading,
|
||||
error: metricsError,
|
||||
data: metricsData,
|
||||
refetch: metricsRefetch,
|
||||
} = useQuery(FILTER_SERVICE_METRICS, {
|
||||
variables: {
|
||||
customerId,
|
||||
fromTime: fromTime.valueOf().toString(),
|
||||
toTime: toTime.valueOf().toString(),
|
||||
equipmentIds: [id],
|
||||
dataTypes: ['ApNode'],
|
||||
limit: 100,
|
||||
},
|
||||
});
|
||||
const { data: dataFirmware, error: errorFirmware, loading: loadingFirmware } = useQuery(
|
||||
GET_ALL_FIRMWARE,
|
||||
{
|
||||
skip: !data?.getEquipment?.model,
|
||||
variables: { modelId: data?.getEquipment?.model },
|
||||
}
|
||||
);
|
||||
|
||||
const [updateEquipment] = useMutation(UPDATE_EQUIPMENT);
|
||||
const [updateEquipmentFirmware] = useMutation(UPDATE_EQUIPMENT_FIRMWARE);
|
||||
const {
|
||||
data: dataProfiles,
|
||||
error: errorProfiles,
|
||||
loading: loadingProfiles,
|
||||
fetchMore,
|
||||
} = useQuery(
|
||||
GET_ALL_PROFILES(`
|
||||
childProfiles {
|
||||
id
|
||||
name
|
||||
details
|
||||
}`),
|
||||
{
|
||||
variables: { customerId, type: 'equipment_ap' },
|
||||
}
|
||||
);
|
||||
|
||||
const { data: dataFirmware, error: errorFirmware, loading: landingFirmware } = useQuery(
|
||||
GET_ALL_FIRMWARE
|
||||
);
|
||||
|
||||
const refetchData = () => {
|
||||
refetch();
|
||||
metricsRefetch();
|
||||
};
|
||||
|
||||
const handleUpdateEquipment = (
|
||||
equipmentId,
|
||||
equipmentType,
|
||||
inventoryId,
|
||||
custId,
|
||||
profileId,
|
||||
locationId,
|
||||
name,
|
||||
latitude,
|
||||
longitude,
|
||||
serial,
|
||||
lastModifiedTimestamp,
|
||||
details
|
||||
) => {
|
||||
updateEquipment({
|
||||
const {
|
||||
loading: metricsLoading,
|
||||
error: metricsError,
|
||||
data: metricsData,
|
||||
refetch: metricsRefetch,
|
||||
} = useQuery(FILTER_SERVICE_METRICS, {
|
||||
variables: {
|
||||
id: equipmentId,
|
||||
equipmentType,
|
||||
inventoryId,
|
||||
customerId: custId,
|
||||
profileId,
|
||||
locationId,
|
||||
name,
|
||||
latitude,
|
||||
longitude,
|
||||
serial,
|
||||
lastModifiedTimestamp,
|
||||
details,
|
||||
customerId,
|
||||
fromTime: fromTime.valueOf().toString(),
|
||||
toTime: toTime.valueOf().toString(),
|
||||
equipmentIds: [id],
|
||||
dataTypes: ['ApNode'],
|
||||
limit: 100,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Equipment settings successfully updated.',
|
||||
});
|
||||
});
|
||||
|
||||
const [updateEquipment] = useMutation(UPDATE_EQUIPMENT);
|
||||
const [updateEquipmentFirmware] = useMutation(UPDATE_EQUIPMENT_FIRMWARE);
|
||||
const [requestEquipmentSwitchBank] = useMutation(REQUEST_EQUIPMENT_SWITCH_BANK);
|
||||
const [requestEquipmentReboot] = useMutation(REQUEST_EQUIPMENT_REBOOT);
|
||||
|
||||
const refetchData = () => {
|
||||
refetch();
|
||||
metricsRefetch();
|
||||
};
|
||||
|
||||
const handleUpdateEquipment = (
|
||||
equipmentId,
|
||||
equipmentType,
|
||||
inventoryId,
|
||||
custId,
|
||||
profileId,
|
||||
locationId,
|
||||
name,
|
||||
latitude,
|
||||
longitude,
|
||||
serial,
|
||||
lastModifiedTimestamp,
|
||||
details
|
||||
) => {
|
||||
updateEquipment({
|
||||
variables: {
|
||||
id: equipmentId,
|
||||
equipmentType,
|
||||
inventoryId,
|
||||
customerId: custId,
|
||||
profileId,
|
||||
locationId,
|
||||
name,
|
||||
latitude,
|
||||
longitude,
|
||||
serial,
|
||||
lastModifiedTimestamp,
|
||||
details,
|
||||
},
|
||||
})
|
||||
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment settings could not be updated.',
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Equipment settings successfully updated.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleUpdateEquipmentFirmware = (equipmentId, firmwareVersionId) =>
|
||||
updateEquipmentFirmware({ variables: { equipmentId, firmwareVersionId } })
|
||||
.then(firmwareResp => {
|
||||
if (firmwareResp && firmwareResp.updateEquipmentFirmware.success === false) {
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment settings could not be updated.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleUpdateEquipmentFirmware = (equipmentId, firmwareVersionId) =>
|
||||
updateEquipmentFirmware({ variables: { equipmentId, firmwareVersionId } })
|
||||
.then(firmwareResp => {
|
||||
if (firmwareResp?.data?.updateEquipmentFirmware?.success === true) {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Equipment Firmware Upgrade in progress',
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment Firmware Upgrade could not be updated.',
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment Firmware Upgrade could not be updated.',
|
||||
});
|
||||
} else {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Equipment Firmware Upgrade in progress',
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment Firmware Upgrade could not be updated.',
|
||||
})
|
||||
);
|
||||
|
||||
const handleRequestEquipmentSwitchBank = equipmentId =>
|
||||
requestEquipmentSwitchBank({ variables: { equipmentId } })
|
||||
.then(firmwareResp => {
|
||||
if (firmwareResp?.data?.requestEquipmentSwitchBank?.success === true) {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Equipment Firmware in progress',
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment Firmware could not be updated.',
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment Firmware could not be updated.',
|
||||
})
|
||||
);
|
||||
|
||||
if (loading || landingProfiles || landingFirmware) {
|
||||
return <Spin size="large" />;
|
||||
}
|
||||
const handleRequestEquipmentReboot = equipmentId =>
|
||||
requestEquipmentReboot({ variables: { equipmentId } })
|
||||
.then(firmwareResp => {
|
||||
if (firmwareResp?.data?.requestEquipmentReboot?.success === true) {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Equipment Firmware in progress',
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment Firmware could not be updated.',
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment Firmware could not be updated.',
|
||||
})
|
||||
);
|
||||
|
||||
const handleFetchProfiles = e => {
|
||||
if (dataProfiles.getAllProfiles.context.lastPage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
e.persist();
|
||||
const { target } = e;
|
||||
|
||||
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
|
||||
fetchMore({
|
||||
variables: { context: { ...dataProfiles.getAllProfiles.context } },
|
||||
updateQuery: updateQueryGetAllProfiles,
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Alert
|
||||
message="Error"
|
||||
description="Failed to load Access Point data."
|
||||
type="error"
|
||||
showIcon
|
||||
<AccessPointDetailsPage
|
||||
handleRefresh={refetchData}
|
||||
onUpdateEquipment={handleUpdateEquipment}
|
||||
data={data?.getEquipment}
|
||||
profiles={dataProfiles?.getAllProfiles?.items}
|
||||
osData={{
|
||||
loading: metricsLoading,
|
||||
error: metricsError,
|
||||
data: metricsData && metricsData.filterServiceMetrics.items,
|
||||
}}
|
||||
firmware={dataFirmware?.getAllFirmware}
|
||||
locations={locations}
|
||||
onUpdateEquipmentFirmware={handleUpdateEquipmentFirmware}
|
||||
onRequestEquipmentSwitchBank={handleRequestEquipmentSwitchBank}
|
||||
onRequestEquipmentReboot={handleRequestEquipmentReboot}
|
||||
loadingProfiles={loadingProfiles}
|
||||
errorProfiles={errorProfiles}
|
||||
loadingFirmware={loadingFirmware}
|
||||
errorFirmware={errorFirmware}
|
||||
onFetchMoreProfiles={handleFetchProfiles}
|
||||
isLastProfilesPage={dataProfiles?.getAllProfiles?.context?.lastPage}
|
||||
/>
|
||||
);
|
||||
},
|
||||
GET_EQUIPMENT,
|
||||
() => {
|
||||
const { id } = useParams();
|
||||
return { id };
|
||||
}
|
||||
|
||||
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}
|
||||
osData={{
|
||||
loading: metricsLoading,
|
||||
error: metricsError,
|
||||
data: metricsData && metricsData.filterServiceMetrics.items,
|
||||
}}
|
||||
firmware={dataFirmware.getAllFirmware}
|
||||
locations={locations}
|
||||
onUpdateEquipmentFirmware={handleUpdateEquipmentFirmware}
|
||||
/>
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
AccessPointDetails.propTypes = {
|
||||
locations: PropTypes.instanceOf(Array).isRequired,
|
||||
|
||||
@@ -1,27 +1,40 @@
|
||||
import React, { useEffect, useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useLazyQuery } from '@apollo/react-hooks';
|
||||
import { Alert } from 'antd';
|
||||
import { NetworkTable, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import moment from 'moment';
|
||||
import { useLazyQuery } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import { floor, padStart } from 'lodash';
|
||||
import { NetworkTableContainer } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { FILTER_EQUIPMENT } from 'graphql/queries';
|
||||
|
||||
import styles from './index.module.scss';
|
||||
|
||||
const renderTableCell = tabCell => {
|
||||
if (Array.isArray(tabCell)) {
|
||||
const renderTableCell = (text, _record, _index, defaultValue = 'N/A') => {
|
||||
if (Array.isArray(text)) {
|
||||
if (text.length < 1) {
|
||||
return defaultValue;
|
||||
}
|
||||
return (
|
||||
<div className={styles.tabColumn}>
|
||||
{tabCell.map((i, key) => (
|
||||
{text.map((i, key) => (
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
<span key={key}>{i}</span>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return tabCell;
|
||||
return text !== null ? text : defaultValue;
|
||||
};
|
||||
|
||||
const durationToString = duration =>
|
||||
`${floor(duration.asDays())}d ${floor(duration.hours())}h ${padStart(
|
||||
duration.minutes(),
|
||||
2,
|
||||
0
|
||||
)}m ${padStart(duration.seconds(), 2, 0)}s`;
|
||||
|
||||
const accessPointsTableColumns = [
|
||||
{
|
||||
title: 'NAME',
|
||||
@@ -53,6 +66,11 @@ const accessPointsTableColumns = [
|
||||
dataIndex: ['status', 'protocol', 'details', 'manufacturer'],
|
||||
render: renderTableCell,
|
||||
},
|
||||
{
|
||||
title: 'FIRMWARE',
|
||||
dataIndex: ['status', 'firmware', 'detailsJSON', 'activeSwVersion'],
|
||||
render: renderTableCell,
|
||||
},
|
||||
{
|
||||
title: 'ASSET ID',
|
||||
dataIndex: 'inventoryId',
|
||||
@@ -61,7 +79,7 @@ const accessPointsTableColumns = [
|
||||
{
|
||||
title: 'UP TIME',
|
||||
dataIndex: ['status', 'osPerformance', 'details', 'uptimeInSeconds'],
|
||||
render: renderTableCell,
|
||||
render: upTimeInSeconds => durationToString(moment.duration(upTimeInSeconds, 'seconds')),
|
||||
},
|
||||
{
|
||||
title: 'PROFILE',
|
||||
@@ -74,7 +92,7 @@ const accessPointsTableColumns = [
|
||||
render: renderTableCell,
|
||||
},
|
||||
{
|
||||
title: 'CAPACITY',
|
||||
title: 'OCCUPANCY',
|
||||
dataIndex: ['status', 'radioUtilization', 'details', 'capacityDetails'],
|
||||
render: renderTableCell,
|
||||
},
|
||||
@@ -86,23 +104,39 @@ const accessPointsTableColumns = [
|
||||
{
|
||||
title: 'DEVICES',
|
||||
dataIndex: ['status', 'clientDetails', 'details', 'numClientsPerRadio'],
|
||||
render: renderTableCell,
|
||||
render: (text, record, index) => renderTableCell(text, record, index, 0),
|
||||
},
|
||||
];
|
||||
|
||||
const AccessPoints = ({ checkedLocations }) => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const [filterEquipment, { loading, error, data: equipData, fetchMore }] = useLazyQuery(
|
||||
const [filterEquipment, { loading, error, data: equipData, refetch, fetchMore }] = useLazyQuery(
|
||||
FILTER_EQUIPMENT,
|
||||
{
|
||||
errorPolicy: 'all',
|
||||
}
|
||||
);
|
||||
|
||||
const handleOnRefresh = () => {
|
||||
refetch()
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Access points reloaded.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Access points could not be reloaded.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
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;
|
||||
@@ -129,22 +163,18 @@ const AccessPoints = ({ checkedLocations }) => {
|
||||
fetchFilterEquipment();
|
||||
}, [checkedLocations]);
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
if (error && !equipData?.filterEquipment?.items) {
|
||||
return <Alert message="Error" description="Failed to load equipment." type="error" showIcon />;
|
||||
}
|
||||
|
||||
return (
|
||||
<NetworkTable
|
||||
<NetworkTableContainer
|
||||
activeTab="/network/access-points"
|
||||
onRefresh={handleOnRefresh}
|
||||
tableColumns={accessPointsTableColumns}
|
||||
tableData={equipData && equipData.filterEquipment && equipData.filterEquipment.items}
|
||||
onLoadMore={handleLoadMore}
|
||||
isLastPage={
|
||||
equipData && equipData.filterEquipment && equipData.filterEquipment.context.lastPage
|
||||
}
|
||||
loading={loading}
|
||||
error={error && !equipData?.filterEquipment?.items && 'Failed to load equipment.'}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
.tabColumn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0 30px;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useContext, useMemo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Alert, notification } from 'antd';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useQuery, useMutation } from '@apollo/react-hooks';
|
||||
import { useParams, Redirect } from 'react-router-dom';
|
||||
import { useQuery, useMutation } from '@apollo/client';
|
||||
import { BulkEditAccessPoints, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import { FILTER_EQUIPMENT_BULK_EDIT_APS } from 'graphql/queries';
|
||||
@@ -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;
|
||||
@@ -348,6 +348,12 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
|
||||
}
|
||||
|
||||
if (filterEquipmentError) {
|
||||
if (
|
||||
filterEquipmentError.message === '403: Forbidden' ||
|
||||
filterEquipmentError.message === '401: Unauthorized'
|
||||
) {
|
||||
return <Redirect to="/login" />;
|
||||
}
|
||||
return (
|
||||
<Alert message="Error" description="Failed to load equipments data." type="error" showIcon />
|
||||
);
|
||||
|
||||
@@ -1,81 +1,74 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import { useQuery } from '@apollo/client';
|
||||
import moment from 'moment';
|
||||
import { Alert, notification } from 'antd';
|
||||
import {
|
||||
Loading,
|
||||
ClientDeviceDetails as ClientDevicesDetailsPage,
|
||||
} from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { notification } from 'antd';
|
||||
import { ClientDeviceDetails as ClientDevicesDetailsPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { GET_CLIENT_SESSION, FILTER_SERVICE_METRICS } from 'graphql/queries';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
const toTime = moment();
|
||||
const fromTime = moment().subtract(1, 'hour');
|
||||
const fromTime = moment().subtract(4, 'hours');
|
||||
|
||||
const ClientDeviceDetails = () => {
|
||||
const { id } = useParams();
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { loading, error, data, refetch } = useQuery(GET_CLIENT_SESSION, {
|
||||
variables: { customerId, macAddress: id },
|
||||
errorPolicy: 'all',
|
||||
});
|
||||
const {
|
||||
loading: metricsLoading,
|
||||
error: metricsError,
|
||||
data: metricsData,
|
||||
refetch: metricsRefetch,
|
||||
} = useQuery(FILTER_SERVICE_METRICS, {
|
||||
variables: {
|
||||
customerId,
|
||||
fromTime: fromTime.valueOf().toString(),
|
||||
toTime: toTime.valueOf().toString(),
|
||||
clientMacs: [id],
|
||||
dataTypes: ['Client'],
|
||||
limit: 100,
|
||||
},
|
||||
});
|
||||
const ClientDeviceDetails = withQuery(
|
||||
({ data, refetch }) => {
|
||||
const { id } = useParams();
|
||||
const { customerId } = useContext(UserContext);
|
||||
|
||||
const handleOnRefresh = () => {
|
||||
metricsRefetch();
|
||||
refetch()
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Successfully reloaded.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Could not be reloaded.',
|
||||
const {
|
||||
loading: metricsLoading,
|
||||
error: metricsError,
|
||||
data: metricsData,
|
||||
refetch: metricsRefetch,
|
||||
} = useQuery(FILTER_SERVICE_METRICS, {
|
||||
variables: {
|
||||
customerId,
|
||||
fromTime: fromTime.valueOf().toString(),
|
||||
toTime: toTime.valueOf().toString(),
|
||||
clientMacs: [id],
|
||||
dataTypes: ['Client'],
|
||||
limit: 1000,
|
||||
},
|
||||
});
|
||||
|
||||
const handleOnRefresh = () => {
|
||||
metricsRefetch();
|
||||
refetch()
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Successfully reloaded.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Could not be reloaded.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
if (error && !data?.getClientSession) {
|
||||
return (
|
||||
<Alert message="Error" description="Failed to load Client Device." type="error" showIcon />
|
||||
<ClientDevicesDetailsPage
|
||||
data={data.getClientSession[0]}
|
||||
onRefresh={handleOnRefresh}
|
||||
metricsLoading={metricsLoading}
|
||||
metricsError={metricsError}
|
||||
metricsData={
|
||||
metricsData && metricsData.filterServiceMetrics && metricsData.filterServiceMetrics.items
|
||||
}
|
||||
historyDate={{ toTime, fromTime }}
|
||||
/>
|
||||
);
|
||||
},
|
||||
GET_CLIENT_SESSION,
|
||||
() => {
|
||||
const { id } = useParams();
|
||||
const { customerId } = useContext(UserContext);
|
||||
return { customerId, macAddress: id, errorPolicy: 'all' };
|
||||
}
|
||||
|
||||
return (
|
||||
<ClientDevicesDetailsPage
|
||||
data={data.getClientSession[0]}
|
||||
onRefresh={handleOnRefresh}
|
||||
metricsLoading={metricsLoading}
|
||||
metricsError={metricsError}
|
||||
metricsData={
|
||||
metricsData && metricsData.filterServiceMetrics && metricsData.filterServiceMetrics.items
|
||||
}
|
||||
historyDate={toTime}
|
||||
/>
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
export default ClientDeviceDetails;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { useEffect, useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useLazyQuery } from '@apollo/react-hooks';
|
||||
import { Alert } from 'antd';
|
||||
import { NetworkTable, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { useLazyQuery } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
|
||||
import { NetworkTableContainer } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { FILTER_CLIENT_SESSIONS } from 'graphql/queries';
|
||||
@@ -23,12 +24,24 @@ const clientDevicesTableColumns = [
|
||||
{ title: 'SSID', dataIndex: 'ssid' },
|
||||
{ title: 'BAND', dataIndex: 'radioType' },
|
||||
{ title: 'SIGNAL', dataIndex: 'signal' },
|
||||
{ title: 'STATUS', dataIndex: 'status' },
|
||||
{
|
||||
title: 'STATUS',
|
||||
dataIndex: ['details', 'associationState'],
|
||||
render: text => {
|
||||
if (text === 'Active_Data') {
|
||||
return 'Connected';
|
||||
}
|
||||
if (text === 'Disconnected') {
|
||||
return 'Disconnected';
|
||||
}
|
||||
return 'N/A';
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const ClientDevices = ({ checkedLocations }) => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const [filterClientSessions, { loading, error, data, fetchMore }] = useLazyQuery(
|
||||
const [filterClientSessions, { loading, error, data, refetch, fetchMore }] = useLazyQuery(
|
||||
FILTER_CLIENT_SESSIONS,
|
||||
{
|
||||
errorPolicy: 'all',
|
||||
@@ -38,7 +51,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;
|
||||
@@ -61,26 +74,36 @@ const ClientDevices = ({ checkedLocations }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleOnRefresh = () => {
|
||||
refetch()
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Client devices reloaded.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Client devices could not be reloaded.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchFilterClientSessions();
|
||||
}, [checkedLocations]);
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
if (error && !data?.filterClientSessions?.items) {
|
||||
return (
|
||||
<Alert message="Error" description="Failed to load client devices." type="error" showIcon />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<NetworkTable
|
||||
<NetworkTableContainer
|
||||
activeTab="/network/client-devices"
|
||||
tableColumns={clientDevicesTableColumns}
|
||||
tableData={data && data.filterClientSessions && data.filterClientSessions.items}
|
||||
tableData={data?.filterClientSessions?.items}
|
||||
onLoadMore={handleLoadMore}
|
||||
onRefresh={handleOnRefresh}
|
||||
isLastPage={data && data.filterClientSessions && data.filterClientSessions.context.lastPage}
|
||||
loading={loading}
|
||||
error={error && !data?.filterClientSessions?.items && 'Failed to load client devices.'}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,275 +1,326 @@
|
||||
import React, { useMemo, useContext, useState } from 'react';
|
||||
import { useLocation, Switch, Route, useRouteMatch, Redirect } from 'react-router-dom';
|
||||
import { useQuery, useMutation, useLazyQuery } from '@apollo/react-hooks';
|
||||
import { Alert, notification } from 'antd';
|
||||
import { Switch, Route, useRouteMatch, Redirect } from 'react-router-dom';
|
||||
import { useQuery, useMutation, useLazyQuery } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import { Network as NetworkPage, PopoverMenu, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { Network as NetworkPage, PopoverMenu } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import AccessPointDetails from 'containers/Network/containers/AccessPointDetails';
|
||||
import AccessPoints from 'containers/Network/containers/AccessPoints';
|
||||
import ClientDevices from 'containers/Network/containers/ClientDevices';
|
||||
import ClientDeviceDetails from 'containers/Network/containers/ClientDeviceDetails';
|
||||
import BulkEditAccessPoints from 'containers/Network/containers/BulkEditAccessPoints';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { GET_ALL_LOCATIONS, GET_LOCATION, GET_ALL_PROFILES } from 'graphql/queries';
|
||||
import {
|
||||
GET_ALL_LOCATIONS,
|
||||
GET_LOCATION,
|
||||
GET_ALL_PROFILES,
|
||||
FILTER_EQUIPMENT,
|
||||
} from 'graphql/queries';
|
||||
import {
|
||||
CREATE_LOCATION,
|
||||
UPDATE_LOCATION,
|
||||
DELETE_LOCATION,
|
||||
CREATE_EQUIPMENT,
|
||||
} from 'graphql/mutations';
|
||||
import { updateQueryGetAllProfiles } from 'graphql/functions';
|
||||
|
||||
const Network = () => {
|
||||
const { path } = useRouteMatch();
|
||||
const { customerId } = useContext(UserContext);
|
||||
const location = useLocation();
|
||||
const { loading, error, refetch, data } = useQuery(GET_ALL_LOCATIONS, {
|
||||
variables: { customerId },
|
||||
});
|
||||
const { loading: loadingProfile, error: errorProfile, data: apProfiles } = useQuery(
|
||||
GET_ALL_PROFILES,
|
||||
{
|
||||
variables: { customerId, type: 'equipment_ap' },
|
||||
}
|
||||
);
|
||||
const Network = withQuery(
|
||||
({ data, refetch }) => {
|
||||
const { path } = useRouteMatch();
|
||||
const { customerId } = useContext(UserContext);
|
||||
|
||||
const [getLocation, { data: selectedLocation }] = useLazyQuery(GET_LOCATION);
|
||||
const [createLocation] = useMutation(CREATE_LOCATION);
|
||||
const [updateLocation] = useMutation(UPDATE_LOCATION);
|
||||
const [deleteLocation] = useMutation(DELETE_LOCATION);
|
||||
const [createEquipment] = useMutation(CREATE_EQUIPMENT);
|
||||
const [checkedLocations, setCheckedLocations] = useState([]);
|
||||
const [deleteModal, setDeleteModal] = useState(false);
|
||||
const [editModal, setEditModal] = useState(false);
|
||||
const [addModal, setAddModal] = useState(false);
|
||||
const [apModal, setApModal] = useState(false);
|
||||
|
||||
const handleGetSingleLocation = id => {
|
||||
getLocation({
|
||||
variables: { id },
|
||||
});
|
||||
};
|
||||
|
||||
const formatLocationListForTree = (list = []) => {
|
||||
const checkedTreeLocations = [];
|
||||
list.forEach(ele => {
|
||||
checkedTreeLocations.push(ele.id);
|
||||
});
|
||||
setCheckedLocations(checkedTreeLocations);
|
||||
|
||||
function unflatten(array, p, t) {
|
||||
let tree = typeof t !== 'undefined' ? t : [];
|
||||
const parent = typeof p !== 'undefined' ? p : { id: '0' };
|
||||
let children = _.filter(array, child => child.parentId === parent.id);
|
||||
children = children.map(c => ({
|
||||
title: (
|
||||
<PopoverMenu
|
||||
locationId={c.id}
|
||||
locationType={c.locationType}
|
||||
setAddModal={setAddModal}
|
||||
setEditModal={setEditModal}
|
||||
setDeleteModal={setDeleteModal}
|
||||
setApModal={setApModal}
|
||||
>
|
||||
{c.name}
|
||||
</PopoverMenu>
|
||||
),
|
||||
value: `${c.id}`,
|
||||
key: c.id,
|
||||
...c,
|
||||
}));
|
||||
if (!_.isEmpty(children)) {
|
||||
if (parent.id === '0') {
|
||||
tree = children;
|
||||
} else {
|
||||
parent.children = children;
|
||||
}
|
||||
_.each(children, child => unflatten(array, child));
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
return [
|
||||
const { loading: loadingProfile, error: errorProfile, data: apProfiles, fetchMore } = useQuery(
|
||||
GET_ALL_PROFILES(),
|
||||
{
|
||||
title: (
|
||||
<PopoverMenu locationType="NETWORK" setAddModal={setAddModal}>
|
||||
Network
|
||||
</PopoverMenu>
|
||||
),
|
||||
id: '0',
|
||||
value: '0',
|
||||
key: '0',
|
||||
children: unflatten(list),
|
||||
},
|
||||
];
|
||||
};
|
||||
variables: { customerId, type: 'equipment_ap' },
|
||||
}
|
||||
);
|
||||
|
||||
const handleAddLocation = (name, parentId, locationType) => {
|
||||
setAddModal(false);
|
||||
createLocation({
|
||||
variables: {
|
||||
locationType,
|
||||
customerId,
|
||||
parentId,
|
||||
name,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Location successfully added.',
|
||||
});
|
||||
refetch();
|
||||
const [getLocation, { data: selectedLocation }] = useLazyQuery(GET_LOCATION);
|
||||
const [createLocation] = useMutation(CREATE_LOCATION);
|
||||
const [updateLocation] = useMutation(UPDATE_LOCATION);
|
||||
const [deleteLocation] = useMutation(DELETE_LOCATION);
|
||||
const [checkedLocations, setCheckedLocations] = useState([]);
|
||||
const [deleteModal, setDeleteModal] = useState(false);
|
||||
const [editModal, setEditModal] = useState(false);
|
||||
const [addModal, setAddModal] = useState(false);
|
||||
const [apModal, setApModal] = useState(false);
|
||||
|
||||
const [createEquipment] = useMutation(CREATE_EQUIPMENT, {
|
||||
refetchQueries: [
|
||||
{
|
||||
query: FILTER_EQUIPMENT,
|
||||
variables: { customerId, locationIds: checkedLocations, equipmentType: 'AP' },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const handleGetSingleLocation = id => {
|
||||
getLocation({
|
||||
variables: { id },
|
||||
});
|
||||
};
|
||||
|
||||
const formatLocationListForTree = (list = []) => {
|
||||
const checkedTreeLocations = ['0'];
|
||||
list.forEach(ele => {
|
||||
checkedTreeLocations.push(ele.id);
|
||||
});
|
||||
setCheckedLocations(checkedTreeLocations);
|
||||
|
||||
function unflatten(array, p, t) {
|
||||
let tree = typeof t !== 'undefined' ? t : [];
|
||||
const parent = typeof p !== 'undefined' ? p : { id: '0' };
|
||||
let children = _.filter(array, child => child.parentId === parent.id);
|
||||
children = children.map(c => ({
|
||||
title: (
|
||||
<PopoverMenu
|
||||
locationId={c.id}
|
||||
locationType={c.locationType}
|
||||
setAddModal={setAddModal}
|
||||
setEditModal={setEditModal}
|
||||
setDeleteModal={setDeleteModal}
|
||||
setApModal={setApModal}
|
||||
>
|
||||
{c.name}
|
||||
</PopoverMenu>
|
||||
),
|
||||
value: `${c.id}`,
|
||||
key: c.id,
|
||||
...c,
|
||||
}));
|
||||
if (!_.isEmpty(children)) {
|
||||
if (parent.id === '0') {
|
||||
tree = children;
|
||||
} else {
|
||||
parent.children = children;
|
||||
}
|
||||
_.each(children, child => unflatten(array, child));
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
return [
|
||||
{
|
||||
title: (
|
||||
<PopoverMenu locationId="0" locationType="NETWORK" setAddModal={setAddModal}>
|
||||
Network
|
||||
</PopoverMenu>
|
||||
),
|
||||
id: '0',
|
||||
key: '0',
|
||||
value: '0',
|
||||
children: unflatten(list),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
const handleAddLocation = ({ location }) => {
|
||||
setAddModal(false);
|
||||
let id;
|
||||
let locationType;
|
||||
|
||||
// adding location from root makes selecetedLocation null so we check for that
|
||||
if (selectedLocation && selectedLocation.getLocation) {
|
||||
id = selectedLocation.getLocation.id;
|
||||
locationType = 'SITE';
|
||||
} else {
|
||||
id = '0';
|
||||
locationType = 'COUNTRY';
|
||||
}
|
||||
|
||||
createLocation({
|
||||
variables: {
|
||||
locationType,
|
||||
customerId,
|
||||
parentId: id,
|
||||
name: location,
|
||||
},
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Location could not be added.',
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Location successfully added.',
|
||||
});
|
||||
refetch();
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Location could not be added.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleEditLocation = (id, parentId, name, locationType, lastModifiedTimestamp) => {
|
||||
setEditModal(false);
|
||||
updateLocation({
|
||||
variables: {
|
||||
customerId,
|
||||
id,
|
||||
parentId,
|
||||
name,
|
||||
locationType,
|
||||
lastModifiedTimestamp,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Location successfully edited.',
|
||||
});
|
||||
refetch();
|
||||
const handleEditLocation = ({ name }) => {
|
||||
setEditModal(false);
|
||||
const { id, parentId, locationType, lastModifiedTimestamp } = selectedLocation.getLocation;
|
||||
|
||||
updateLocation({
|
||||
variables: {
|
||||
customerId,
|
||||
id,
|
||||
parentId,
|
||||
name,
|
||||
locationType,
|
||||
lastModifiedTimestamp,
|
||||
},
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Location could not be edited.',
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Location successfully edited.',
|
||||
});
|
||||
refetch();
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Location could not be edited.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleDeleteLocation = id => {
|
||||
setDeleteModal(false);
|
||||
deleteLocation({ variables: { id } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Location successfully deleted.',
|
||||
const handleDeleteLocation = () => {
|
||||
setDeleteModal(false);
|
||||
const { id } = selectedLocation.getLocation;
|
||||
|
||||
deleteLocation({ variables: { id } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Location successfully deleted.',
|
||||
});
|
||||
refetch();
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Location could not be deleted.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleCreateEquipment = ({ inventoryId, name, profileId }) => {
|
||||
setApModal(false);
|
||||
const { id: locationId } = selectedLocation.getLocation;
|
||||
|
||||
createEquipment({ variables: { customerId, inventoryId, locationId, name, profileId } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Equipment successfully created.',
|
||||
});
|
||||
refetch();
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment could not be created.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const onSelect = (selectedKeys, info) => {
|
||||
const { id } = info.node;
|
||||
handleGetSingleLocation(id);
|
||||
};
|
||||
|
||||
const onCheck = checkedKeys => {
|
||||
setCheckedLocations(checkedKeys.checked);
|
||||
};
|
||||
|
||||
const handleFetchProfiles = e => {
|
||||
if (apProfiles.getAllProfiles.context.lastPage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
e.persist();
|
||||
const { target } = e;
|
||||
|
||||
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
|
||||
fetchMore({
|
||||
variables: { context: { ...apProfiles.getAllProfiles.context } },
|
||||
updateQuery: updateQueryGetAllProfiles,
|
||||
});
|
||||
refetch();
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Location could not be deleted.',
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const handleCreateEquipment = (inventoryId, locationId, name, profileId) => {
|
||||
setApModal(false);
|
||||
createEquipment({ variables: { customerId, inventoryId, locationId, name, profileId } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Equipment successfully created.',
|
||||
});
|
||||
refetch();
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Equipment could not be created.',
|
||||
})
|
||||
);
|
||||
};
|
||||
return true;
|
||||
};
|
||||
|
||||
const onSelect = (selectedKeys, info) => {
|
||||
const { id } = info.node;
|
||||
handleGetSingleLocation(id);
|
||||
};
|
||||
const locationsTree = useMemo(() => formatLocationListForTree(data && data.getAllLocations), [
|
||||
data,
|
||||
]);
|
||||
|
||||
const onCheck = checkedKeys => {
|
||||
setCheckedLocations(checkedKeys.checked);
|
||||
};
|
||||
return (
|
||||
<NetworkPage
|
||||
onSelect={onSelect}
|
||||
onCheck={onCheck}
|
||||
checkedLocations={checkedLocations}
|
||||
locations={locationsTree}
|
||||
selectedLocation={selectedLocation && selectedLocation.getLocation}
|
||||
addModal={addModal}
|
||||
editModal={editModal}
|
||||
deleteModal={deleteModal}
|
||||
apModal={apModal}
|
||||
setAddModal={setAddModal}
|
||||
setEditModal={setEditModal}
|
||||
setDeleteModal={setDeleteModal}
|
||||
setApModal={setApModal}
|
||||
onAddLocation={handleAddLocation}
|
||||
onEditLocation={handleEditLocation}
|
||||
onDeleteLocation={handleDeleteLocation}
|
||||
onCreateEquipment={handleCreateEquipment}
|
||||
profiles={
|
||||
(apProfiles && apProfiles.getAllProfiles && apProfiles.getAllProfiles.items) || []
|
||||
}
|
||||
loadingProfile={loadingProfile}
|
||||
errorProfile={errorProfile}
|
||||
onFetchMoreProfiles={handleFetchProfiles}
|
||||
isLastProfilesPage={apProfiles?.getAllProfiles?.context?.lastPage}
|
||||
>
|
||||
<Switch>
|
||||
<Route
|
||||
exact
|
||||
path={`${path}/access-points/bulk-edit/:id`}
|
||||
render={props => (
|
||||
<BulkEditAccessPoints
|
||||
locations={locationsTree}
|
||||
checkedLocations={checkedLocations}
|
||||
{...props}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${path}/access-points`}
|
||||
render={props => <AccessPoints checkedLocations={checkedLocations} {...props} />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${path}/access-points/:id/:tab`}
|
||||
render={props => <AccessPointDetails locations={locationsTree} {...props} />}
|
||||
/>
|
||||
|
||||
const locationsTree = useMemo(
|
||||
() => formatLocationListForTree(data && data.getAllLocations)[0].children,
|
||||
[data]
|
||||
);
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
<Route
|
||||
exact
|
||||
path={`${path}/client-devices`}
|
||||
render={props => <ClientDevices checkedLocations={checkedLocations} {...props} />}
|
||||
/>
|
||||
<Route exact path={`${path}/client-devices/:id`} component={ClientDeviceDetails} />
|
||||
<Redirect from={`${path}/access-points/:id`} to={`${path}/access-points/:id/general`} />
|
||||
<Redirect from={path} to={`${path}/access-points`} />
|
||||
</Switch>
|
||||
</NetworkPage>
|
||||
);
|
||||
},
|
||||
GET_ALL_LOCATIONS,
|
||||
() => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
return { customerId };
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <Alert message="Error" description="Failed to load locations." type="error" showIcon />;
|
||||
}
|
||||
|
||||
return (
|
||||
<NetworkPage
|
||||
onSelect={onSelect}
|
||||
onCheck={onCheck}
|
||||
checkedLocations={checkedLocations}
|
||||
locations={locationsTree}
|
||||
activeTab={location.pathname}
|
||||
selectedLocation={selectedLocation && selectedLocation.getLocation}
|
||||
addModal={addModal}
|
||||
editModal={editModal}
|
||||
deleteModal={deleteModal}
|
||||
apModal={apModal}
|
||||
setAddModal={setAddModal}
|
||||
setEditModal={setEditModal}
|
||||
setDeleteModal={setDeleteModal}
|
||||
setApModal={setApModal}
|
||||
onAddLocation={handleAddLocation}
|
||||
onEditLocation={handleEditLocation}
|
||||
onDeleteLocation={handleDeleteLocation}
|
||||
onCreateEquipment={handleCreateEquipment}
|
||||
profiles={(apProfiles && apProfiles.getAllProfiles && apProfiles.getAllProfiles.items) || []}
|
||||
loadingProfile={loadingProfile}
|
||||
errorProfile={errorProfile}
|
||||
>
|
||||
<Switch>
|
||||
<Route
|
||||
exact
|
||||
path={`${path}/access-points/bulk-edit/:id`}
|
||||
render={props => (
|
||||
<BulkEditAccessPoints
|
||||
locations={locationsTree}
|
||||
checkedLocations={checkedLocations}
|
||||
{...props}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${path}/access-points`}
|
||||
render={props => <AccessPoints checkedLocations={checkedLocations} {...props} />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${path}/access-points/:id`}
|
||||
render={props => <AccessPointDetails locations={locationsTree} {...props} />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${path}/client-devices`}
|
||||
render={props => <ClientDevices checkedLocations={checkedLocations} {...props} />}
|
||||
/>
|
||||
<Route exact path={`${path}/client-devices/:id`} component={ClientDeviceDetails} />
|
||||
<Redirect from={path} to={`${path}/access-points`} />
|
||||
</Switch>
|
||||
</NetworkPage>
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
export default Network;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import React, { useState, useContext } from 'react';
|
||||
import { useParams, Redirect } from 'react-router-dom';
|
||||
import gql from 'graphql-tag';
|
||||
import { useQuery, useMutation } from '@apollo/react-hooks';
|
||||
import { Alert, Spin, notification } from 'antd';
|
||||
import { useQuery, useMutation, gql } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import { ProfileDetails as ProfileDetailsPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { GET_ALL_PROFILES } from 'graphql/queries';
|
||||
import { FILE_UPLOAD } from 'graphql/mutations';
|
||||
import { updateQueryGetAllProfiles } from 'graphql/functions';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
const GET_PROFILE = gql`
|
||||
query GetProfile($id: ID!) {
|
||||
@@ -68,111 +69,179 @@ const DELETE_PROFILE = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const ProfileDetails = () => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { id } = useParams();
|
||||
const ProfileDetails = withQuery(
|
||||
({ data }) => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { id } = useParams();
|
||||
|
||||
const [redirect, setRedirect] = useState(false);
|
||||
const [redirect, setRedirect] = useState(false);
|
||||
|
||||
const { loading, error, data } = useQuery(GET_PROFILE, {
|
||||
variables: { id },
|
||||
});
|
||||
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES, {
|
||||
variables: { customerId, type: 'ssid' },
|
||||
});
|
||||
const [updateProfile] = useMutation(UPDATE_PROFILE);
|
||||
const [deleteProfile] = useMutation(DELETE_PROFILE);
|
||||
const { data: ssidProfiles, fetchMore } = useQuery(GET_ALL_PROFILES(), {
|
||||
variables: { customerId, type: 'ssid' },
|
||||
});
|
||||
|
||||
const [fileUpload] = useMutation(FILE_UPLOAD);
|
||||
|
||||
const handleDeleteProfile = () => {
|
||||
deleteProfile({ variables: { id } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Profile successfully deleted.',
|
||||
});
|
||||
|
||||
setRedirect(true);
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Profile could not be deleted.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleUpdateProfile = (
|
||||
name,
|
||||
details,
|
||||
childProfileIds = data.getProfile.childProfileIds
|
||||
) => {
|
||||
updateProfile({
|
||||
variables: {
|
||||
...data.getProfile,
|
||||
name,
|
||||
childProfileIds,
|
||||
details,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Profile successfully updated.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Profile could not be updated.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleFileUpload = (fileName, file) =>
|
||||
fileUpload({ variables: { fileName, file } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'File successfully uploaded.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'File could not be uploaded.',
|
||||
})
|
||||
);
|
||||
|
||||
if (loading) {
|
||||
return <Spin size="large" />;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Alert message="Error" description="Failed to load profile data." type="error" showIcon />
|
||||
);
|
||||
}
|
||||
|
||||
if (redirect) {
|
||||
return <Redirect to="/profiles" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ProfileDetailsPage
|
||||
name={data.getProfile.name}
|
||||
profileType={data.getProfile.profileType}
|
||||
details={data.getProfile.details}
|
||||
childProfileIds={data.getProfile.childProfileIds}
|
||||
onDeleteProfile={handleDeleteProfile}
|
||||
onUpdateProfile={handleUpdateProfile}
|
||||
ssidProfiles={
|
||||
(ssidProfiles && ssidProfiles.getAllProfiles && ssidProfiles.getAllProfiles.items) || []
|
||||
const { data: radiusProfiles, fetchMore: fetchMoreRadiusProfiles } = useQuery(
|
||||
GET_ALL_PROFILES(),
|
||||
{
|
||||
variables: { customerId, type: 'radius' },
|
||||
}
|
||||
fileUpload={handleFileUpload}
|
||||
/>
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
const { data: captiveProfiles, fetchMore: fetchMoreCaptiveProfiles } = useQuery(
|
||||
GET_ALL_PROFILES(),
|
||||
{
|
||||
variables: { customerId, type: 'captive_portal' },
|
||||
}
|
||||
);
|
||||
|
||||
const [updateProfile] = useMutation(UPDATE_PROFILE);
|
||||
const [deleteProfile] = useMutation(DELETE_PROFILE);
|
||||
|
||||
const [fileUpload] = useMutation(FILE_UPLOAD);
|
||||
|
||||
const handleDeleteProfile = () => {
|
||||
deleteProfile({ variables: { id } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Profile successfully deleted.',
|
||||
});
|
||||
|
||||
setRedirect(true);
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Profile could not be deleted.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleUpdateProfile = (
|
||||
name,
|
||||
details,
|
||||
childProfileIds = data.getProfile.childProfileIds
|
||||
) => {
|
||||
updateProfile({
|
||||
variables: {
|
||||
...data.getProfile,
|
||||
name,
|
||||
childProfileIds,
|
||||
details,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Profile successfully updated.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Profile could not be updated.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleFileUpload = (fileName, file) =>
|
||||
fileUpload({ variables: { fileName, file } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'File successfully uploaded.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'File could not be uploaded.',
|
||||
})
|
||||
);
|
||||
|
||||
const handleFetchProfiles = e => {
|
||||
if (ssidProfiles.getAllProfiles.context.lastPage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
e.persist();
|
||||
const { target } = e;
|
||||
|
||||
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
|
||||
fetchMore({
|
||||
variables: { context: { ...ssidProfiles.getAllProfiles.context } },
|
||||
updateQuery: updateQueryGetAllProfiles,
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const handleFetchRadiusProfiles = e => {
|
||||
if (radiusProfiles.getAllProfiles.context.lastPage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
e.persist();
|
||||
const { target } = e;
|
||||
|
||||
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
|
||||
fetchMoreRadiusProfiles({
|
||||
variables: { context: { ...radiusProfiles.getAllProfiles.context } },
|
||||
updateQuery: updateQueryGetAllProfiles,
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const handleFetchCaptiveProfiles = e => {
|
||||
if (captiveProfiles.getAllProfiles.context.lastPage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
e.persist();
|
||||
const { target } = e;
|
||||
|
||||
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
|
||||
fetchMoreCaptiveProfiles({
|
||||
variables: { context: { ...captiveProfiles.getAllProfiles.context } },
|
||||
updateQuery: updateQueryGetAllProfiles,
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if (redirect) {
|
||||
return <Redirect to="/profiles" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ProfileDetailsPage
|
||||
name={data.getProfile.name}
|
||||
profileType={data.getProfile.profileType}
|
||||
details={data.getProfile.details}
|
||||
childProfileIds={data.getProfile.childProfileIds}
|
||||
onDeleteProfile={handleDeleteProfile}
|
||||
onUpdateProfile={handleUpdateProfile}
|
||||
ssidProfiles={
|
||||
(ssidProfiles && ssidProfiles.getAllProfiles && ssidProfiles.getAllProfiles.items) || []
|
||||
}
|
||||
radiusProfiles={radiusProfiles?.getAllProfiles?.items}
|
||||
captiveProfiles={captiveProfiles?.getAllProfiles?.items}
|
||||
fileUpload={handleFileUpload}
|
||||
onFetchMoreProfiles={handleFetchProfiles}
|
||||
onFetchMoreRadiusProfiles={handleFetchRadiusProfiles}
|
||||
onFetchMoreCaptiveProfiles={handleFetchCaptiveProfiles}
|
||||
/>
|
||||
);
|
||||
},
|
||||
GET_PROFILE,
|
||||
() => {
|
||||
const { id } = useParams();
|
||||
return { id, fetchPolicy: 'network-only' };
|
||||
}
|
||||
);
|
||||
|
||||
export default ProfileDetails;
|
||||
|
||||
@@ -1,28 +1,13 @@
|
||||
import React, { useContext } from 'react';
|
||||
import gql from 'graphql-tag';
|
||||
import { useQuery, useMutation } from '@apollo/react-hooks';
|
||||
|
||||
import { Alert, Spin, notification } from 'antd';
|
||||
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
import { useMutation, gql } from '@apollo/client';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { notification } from 'antd';
|
||||
import { Profile as ProfilePage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import UserContext from 'contexts/UserContext';
|
||||
|
||||
const GET_ALL_PROFILES = gql`
|
||||
query GetAllProfiles($customerId: ID!, $cursor: String) {
|
||||
getAllProfiles(customerId: $customerId, cursor: $cursor) {
|
||||
items {
|
||||
id
|
||||
name
|
||||
profileType
|
||||
details
|
||||
}
|
||||
context {
|
||||
cursor
|
||||
lastPage
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import { GET_ALL_PROFILES } from 'graphql/queries';
|
||||
import { updateQueryGetAllProfiles } from 'graphql/functions';
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
const DELETE_PROFILE = gql`
|
||||
mutation DeleteProfile($id: ID!) {
|
||||
@@ -32,82 +17,85 @@ const DELETE_PROFILE = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const Profiles = () => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { loading, error, data, refetch, fetchMore } = useQuery(GET_ALL_PROFILES, {
|
||||
variables: { customerId },
|
||||
});
|
||||
const [deleteProfile] = useMutation(DELETE_PROFILE);
|
||||
const Profiles = withQuery(
|
||||
({ data, fetchMore, refetch }) => {
|
||||
const [deleteProfile] = useMutation(DELETE_PROFILE);
|
||||
const { customerId } = useContext(UserContext);
|
||||
const location = useLocation();
|
||||
|
||||
const reloadTable = () => {
|
||||
refetch()
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Profiles reloaded.',
|
||||
useEffect(() => {
|
||||
if (location.state && location.state.refetch) {
|
||||
refetch({
|
||||
variables: { refresh: Date.now() },
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
const reloadTable = () => {
|
||||
refetch({
|
||||
variables: { refresh: Date.now() },
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Profiles could not be reloaded.',
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Profiles reloaded.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Profiles could not be reloaded.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleLoadMore = () => {
|
||||
if (!data.getAllProfiles.context.lastPage) {
|
||||
fetchMore({
|
||||
variables: { cursor: data.getAllProfiles.context.cursor },
|
||||
updateQuery: (previousResult, { fetchMoreResult }) => {
|
||||
const previousEntry = previousResult.getAllProfiles;
|
||||
const newItems = fetchMoreResult.getAllProfiles.items;
|
||||
|
||||
return {
|
||||
getAllProfiles: {
|
||||
context: fetchMoreResult.getAllProfiles.context,
|
||||
items: [...previousEntry.items, ...newItems],
|
||||
__typename: previousEntry.__typename,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteProfile = id => {
|
||||
deleteProfile({ variables: { id } })
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Profile successfully deleted.',
|
||||
const handleLoadMore = () => {
|
||||
if (!data.getAllProfiles.context.lastPage) {
|
||||
fetchMore({
|
||||
variables: { context: { ...data.getAllProfiles.context } },
|
||||
updateQuery: updateQueryGetAllProfiles,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteProfile = id => {
|
||||
deleteProfile({
|
||||
variables: { id },
|
||||
refetchQueries: [
|
||||
{
|
||||
query: GET_ALL_PROFILES(`equipmentCount`),
|
||||
variables: { customerId },
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Profile could not be deleted.',
|
||||
.then(() => {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Profile successfully deleted.',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <Spin size="large" />;
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Profile could not be deleted.',
|
||||
})
|
||||
);
|
||||
};
|
||||
return (
|
||||
<ProfilePage
|
||||
data={data.getAllProfiles.items}
|
||||
onReload={reloadTable}
|
||||
isLastPage={data?.getAllProfiles?.context?.lastPage}
|
||||
onDeleteProfile={handleDeleteProfile}
|
||||
onLoadMore={handleLoadMore}
|
||||
/>
|
||||
);
|
||||
},
|
||||
GET_ALL_PROFILES(`equipmentCount`),
|
||||
() => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
return { customerId, fetchPolicy: 'network-only' };
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <Alert message="Error" description="Failed to load profiles." type="error" showIcon />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ProfilePage
|
||||
data={data.getAllProfiles.items}
|
||||
onReload={reloadTable}
|
||||
isLastPage={data.getAllProfiles.context.lastPage}
|
||||
onDeleteProfile={handleDeleteProfile}
|
||||
onLoadMore={handleLoadMore}
|
||||
/>
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
export default Profiles;
|
||||
|
||||
25
app/containers/QueryWrapper/index.js
Normal file
25
app/containers/QueryWrapper/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import { Alert } from 'antd';
|
||||
import { Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { useQuery } from '@apollo/client';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
|
||||
export const withQuery = (Comp, query, getVariables) => props => {
|
||||
const { loading, error, data, refetch, fetchMore } = useQuery(query, {
|
||||
variables: getVariables(),
|
||||
});
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (error.message === '403: Forbidden' || error.message === '401: Unauthorized') {
|
||||
return <Redirect to="/login" />;
|
||||
}
|
||||
|
||||
return <Alert message="Error" description="Failed to load profiles." type="error" showIcon />;
|
||||
}
|
||||
|
||||
return <Comp {...props} data={data} fetchMore={fetchMore} refetch={refetch} />;
|
||||
};
|
||||
@@ -1,87 +1,82 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { useQuery, useMutation } from '@apollo/react-hooks';
|
||||
import { Alert, notification } from 'antd';
|
||||
import { AutoProvision as AutoProvisionPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { useQuery, useMutation } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import { AutoProvision as AutoProvisionPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { GET_CUSTOMER, GET_ALL_LOCATIONS, GET_ALL_PROFILES } from 'graphql/queries';
|
||||
import { UPDATE_CUSTOMER } from 'graphql/mutations';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
const AutoProvision = () => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { data, loading, error, refetch } = useQuery(GET_CUSTOMER, {
|
||||
variables: { id: customerId },
|
||||
});
|
||||
const [updateCustomer] = useMutation(UPDATE_CUSTOMER);
|
||||
const AutoProvision = withQuery(
|
||||
({ data, refetch }) => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const [updateCustomer] = useMutation(UPDATE_CUSTOMER);
|
||||
|
||||
const { data: dataLocation, loading: loadingLoaction, error: errorLocation } = useQuery(
|
||||
GET_ALL_LOCATIONS,
|
||||
{
|
||||
variables: { customerId },
|
||||
}
|
||||
);
|
||||
const { data: dataProfile, loading: loadingProfile, error: errorProfile } = useQuery(
|
||||
GET_ALL_PROFILES,
|
||||
{
|
||||
variables: { customerId, type: 'equipment_ap' },
|
||||
}
|
||||
);
|
||||
|
||||
const handleUpdateCustomer = (
|
||||
id,
|
||||
email,
|
||||
name,
|
||||
details,
|
||||
createdTimestamp,
|
||||
lastModifiedTimestamp
|
||||
) => {
|
||||
updateCustomer({
|
||||
variables: {
|
||||
id,
|
||||
email,
|
||||
name,
|
||||
details,
|
||||
createdTimestamp,
|
||||
lastModifiedTimestamp,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Settings successfully updated.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Settings could not be updated.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Alert message="Error" description="Failed to load Customer Data." type="error" showIcon />
|
||||
const { data: dataLocation, loading: loadingLoaction, error: errorLocation } = useQuery(
|
||||
GET_ALL_LOCATIONS,
|
||||
{
|
||||
variables: { customerId },
|
||||
}
|
||||
);
|
||||
const { data: dataProfile, loading: loadingProfile, error: errorProfile } = useQuery(
|
||||
GET_ALL_PROFILES(),
|
||||
{
|
||||
variables: { customerId, type: 'equipment_ap', limit: 100 },
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<AutoProvisionPage
|
||||
data={data && data.getCustomer}
|
||||
dataLocation={dataLocation && dataLocation.getAllLocations}
|
||||
dataProfile={dataProfile && dataProfile.getAllProfiles.items}
|
||||
loadingLoaction={loadingLoaction}
|
||||
loadingProfile={loadingProfile}
|
||||
errorLocation={errorLocation}
|
||||
errorProfile={errorProfile}
|
||||
onUpdateCustomer={handleUpdateCustomer}
|
||||
/>
|
||||
);
|
||||
};
|
||||
const handleUpdateCustomer = (
|
||||
id,
|
||||
email,
|
||||
name,
|
||||
details,
|
||||
createdTimestamp,
|
||||
lastModifiedTimestamp
|
||||
) => {
|
||||
updateCustomer({
|
||||
variables: {
|
||||
id,
|
||||
email,
|
||||
name,
|
||||
details,
|
||||
createdTimestamp,
|
||||
lastModifiedTimestamp,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Settings successfully updated.',
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Settings could not be updated.',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<AutoProvisionPage
|
||||
data={data && data.getCustomer}
|
||||
dataLocation={dataLocation && dataLocation.getAllLocations}
|
||||
dataProfile={dataProfile && dataProfile.getAllProfiles.items}
|
||||
loadingLoaction={loadingLoaction}
|
||||
loadingProfile={loadingProfile}
|
||||
errorLocation={errorLocation}
|
||||
errorProfile={errorProfile}
|
||||
onUpdateCustomer={handleUpdateCustomer}
|
||||
/>
|
||||
);
|
||||
},
|
||||
GET_CUSTOMER,
|
||||
() => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
return { id: customerId };
|
||||
}
|
||||
);
|
||||
|
||||
export default AutoProvision;
|
||||
|
||||
@@ -1,78 +1,76 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { useQuery, useMutation } from '@apollo/react-hooks';
|
||||
import { Alert, notification } from 'antd';
|
||||
import { BlockedList as BlockedListPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import { BlockedList as BlockedListPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { GET_BLOCKED_CLIENTS } from 'graphql/queries';
|
||||
import { UPDATE_CLIENT, ADD_BLOCKED_CLIENT } from 'graphql/mutations';
|
||||
import UserContext from 'contexts/UserContext';
|
||||
import { withQuery } from 'containers/QueryWrapper';
|
||||
|
||||
const BlockedList = () => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const { data, error, loading, refetch } = useQuery(GET_BLOCKED_CLIENTS, {
|
||||
variables: { customerId },
|
||||
});
|
||||
const [addClient] = useMutation(ADD_BLOCKED_CLIENT);
|
||||
const [updateClient] = useMutation(UPDATE_CLIENT);
|
||||
const BlockedList = withQuery(
|
||||
({ refetch, data }) => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
const [addClient] = useMutation(ADD_BLOCKED_CLIENT);
|
||||
const [updateClient] = useMutation(UPDATE_CLIENT);
|
||||
|
||||
const handleAddClient = macAddress => {
|
||||
addClient({
|
||||
variables: {
|
||||
customerId,
|
||||
macAddress,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Client successfully added to Blocked List',
|
||||
});
|
||||
const handleAddClient = macAddress => {
|
||||
addClient({
|
||||
variables: {
|
||||
customerId,
|
||||
macAddress,
|
||||
},
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Client could not be added to Blocked List',
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Client successfully added to Blocked List',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Client could not be added to Blocked List',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleUpdateClient = (macAddress, details) => {
|
||||
updateClient({
|
||||
variables: {
|
||||
customerId,
|
||||
macAddress,
|
||||
details,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Client successfully removed from Blocked List',
|
||||
});
|
||||
const handleUpdateClient = (macAddress, details) => {
|
||||
updateClient({
|
||||
variables: {
|
||||
customerId,
|
||||
macAddress,
|
||||
details,
|
||||
},
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Client could not be removed from Blocked List',
|
||||
.then(() => {
|
||||
refetch();
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'Client successfully removed from Blocked List',
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'Client could not be removed from Blocked List',
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) return <Loading />;
|
||||
|
||||
if (error)
|
||||
return (
|
||||
<Alert message="Error" description="Failed to load Client Data." type="error" showIcon />
|
||||
<BlockedListPage
|
||||
data={data && data.getBlockedClients}
|
||||
onUpdateClient={handleUpdateClient}
|
||||
onAddClient={handleAddClient}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<BlockedListPage
|
||||
data={data && data.getBlockedClients}
|
||||
onUpdateClient={handleUpdateClient}
|
||||
onAddClient={handleAddClient}
|
||||
/>
|
||||
);
|
||||
};
|
||||
},
|
||||
GET_BLOCKED_CLIENTS,
|
||||
() => {
|
||||
const { customerId } = useContext(UserContext);
|
||||
return customerId;
|
||||
}
|
||||
);
|
||||
|
||||
export default BlockedList;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { useQuery, useMutation, useLazyQuery } from '@apollo/react-hooks';
|
||||
import { useQuery, useMutation, useLazyQuery } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import {
|
||||
GET_ALL_FIRMWARE,
|
||||
@@ -83,8 +83,18 @@ const Firmware = () => {
|
||||
firmwareVersionRecordId,
|
||||
modelId,
|
||||
createdTimestamp,
|
||||
lastModifiedTimestamp
|
||||
lastModifiedTimestamp,
|
||||
prevFirmwareVersionRecordId
|
||||
) => {
|
||||
if (prevFirmwareVersionRecordId !== firmwareVersionRecordId) {
|
||||
deleteTrackAssignment({
|
||||
variables: {
|
||||
firmwareTrackId: firmwareTrackData.getFirmwareTrack.recordId,
|
||||
firmwareVersionId: prevFirmwareVersionRecordId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
updateTrackAssignment({
|
||||
variables: {
|
||||
trackRecordId: firmwareTrackData.getFirmwareTrack.recordId,
|
||||
@@ -130,6 +140,7 @@ const Firmware = () => {
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const handleCreateFirmware = (
|
||||
modelId,
|
||||
versionName,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import React from 'react';
|
||||
import gql from 'graphql-tag';
|
||||
import { useMutation, useLazyQuery } from '@apollo/react-hooks';
|
||||
import React, { useState } from 'react';
|
||||
import { useQuery, useMutation, useLazyQuery, gql } from '@apollo/client';
|
||||
import { notification } from 'antd';
|
||||
import { Manufacturer as ManufacturerPage } from '@tip-wlan/wlan-cloud-ui-library';
|
||||
import { OUI_UPLOAD } from 'graphql/mutations';
|
||||
|
||||
import { AUTH_TOKEN } from 'constants/index';
|
||||
import { GET_API_URL } from 'graphql/queries';
|
||||
import { getItem } from 'utils/localStorage';
|
||||
|
||||
const GET_OUI = gql`
|
||||
query GetOui($oui: String!) {
|
||||
@@ -28,7 +30,12 @@ const UPDATE_OUI = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const System = () => {
|
||||
const token = getItem(AUTH_TOKEN);
|
||||
const [loadingFileUpload, setLoadingFileUpload] = useState(false);
|
||||
|
||||
const { data: apiUrl } = useQuery(GET_API_URL);
|
||||
const [updateOUI] = useMutation(UPDATE_OUI);
|
||||
const [searchOUI, { data }] = useLazyQuery(GET_OUI, {
|
||||
onError: () => {
|
||||
@@ -37,8 +44,16 @@ const System = () => {
|
||||
description: 'No matching manufacturer found for OUI',
|
||||
});
|
||||
},
|
||||
onCompleted: () => {
|
||||
if (!data?.getOui?.oui) {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'No matching manufacturer found for OUI',
|
||||
});
|
||||
}
|
||||
},
|
||||
fetchPolicy: 'no-cache',
|
||||
});
|
||||
const [fileUpload] = useMutation(OUI_UPLOAD);
|
||||
|
||||
const handleUpdateOUI = (oui, manufacturerAlias, manufacturerName) => {
|
||||
updateOUI({
|
||||
@@ -66,33 +81,54 @@ const System = () => {
|
||||
searchOUI({ variables: { oui } });
|
||||
};
|
||||
|
||||
const handleFileUpload = (fileName, file) =>
|
||||
fileUpload({ variables: { fileName, file } })
|
||||
.then(resp => {
|
||||
if (resp?.ouiUpload?.success) {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'File successfully uploaded.',
|
||||
});
|
||||
} else {
|
||||
const handleFileUpload = (fileName, file) => {
|
||||
if (apiUrl?.getApiUrl) {
|
||||
setLoadingFileUpload(true);
|
||||
|
||||
fetch(`${apiUrl?.getApiUrl}portal/manufacturer/oui/upload?fileName=${fileName}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: token ? `Bearer ${token.access_token}` : '',
|
||||
'Content-Type': 'application/octet-stream',
|
||||
},
|
||||
body: file,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(resp => {
|
||||
if (resp?.success) {
|
||||
notification.success({
|
||||
message: 'Success',
|
||||
description: 'File successfully uploaded.',
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'File could not be uploaded.',
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'File could not be uploaded.',
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() =>
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'File could not be uploaded.',
|
||||
})
|
||||
);
|
||||
.finally(() => setLoadingFileUpload(false));
|
||||
} else {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: 'File could not be uploaded.',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ManufacturerPage
|
||||
onSearchOUI={handleSearchOUI}
|
||||
onUpdateOUI={handleUpdateOUI}
|
||||
returnedOUI={data && data.getOui}
|
||||
fileUpload={handleFileUpload}
|
||||
loadingFileUpload={loadingFileUpload}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
12
app/graphql/functions.js
Normal file
12
app/graphql/functions.js
Normal file
@@ -0,0 +1,12 @@
|
||||
export const updateQueryGetAllProfiles = (previousResult, { fetchMoreResult }) => {
|
||||
const previousEntry = previousResult.getAllProfiles;
|
||||
const newItems = fetchMoreResult.getAllProfiles.items;
|
||||
|
||||
return {
|
||||
getAllProfiles: {
|
||||
context: { ...fetchMoreResult.getAllProfiles.context },
|
||||
items: [...previousEntry.items, ...newItems],
|
||||
__typename: previousEntry.__typename,
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import gql from 'graphql-tag';
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const REFRESH_TOKEN = gql`
|
||||
mutation UpdateToken($refreshToken: String!) {
|
||||
@@ -99,6 +99,22 @@ export const UPDATE_EQUIPMENT_FIRMWARE = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const REQUEST_EQUIPMENT_SWITCH_BANK = gql`
|
||||
mutation RequestEquipmentSwitchBank($equipmentId: ID) {
|
||||
requestEquipmentSwitchBank(equipmentId: $equipmentId) {
|
||||
success
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const REQUEST_EQUIPMENT_REBOOT = gql`
|
||||
mutation RequestEquipmentReboot($equipmentId: ID) {
|
||||
requestEquipmentReboot(equipmentId: $equipmentId) {
|
||||
success
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPDATE_TRACK_ASSIGNMENT = gql`
|
||||
mutation UpdateFirmwareTrackAssignment(
|
||||
$trackRecordId: ID!
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import gql from 'graphql-tag';
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const GET_API_URL = gql`
|
||||
query GetApiUrl {
|
||||
getApiUrl
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_ALL_LOCATIONS = gql`
|
||||
query GetAllLocations($customerId: ID!) {
|
||||
@@ -16,13 +22,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
|
||||
@@ -61,12 +67,12 @@ export const FILTER_EQUIPMENT = gql`
|
||||
numClientsPerRadio
|
||||
}
|
||||
}
|
||||
firmware {
|
||||
detailsJSON
|
||||
}
|
||||
}
|
||||
}
|
||||
context {
|
||||
lastPage
|
||||
cursor
|
||||
}
|
||||
context
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -76,13 +82,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 +97,7 @@ export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql`
|
||||
channel
|
||||
details
|
||||
}
|
||||
context {
|
||||
lastPage
|
||||
cursor
|
||||
}
|
||||
context
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -112,8 +115,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
|
||||
@@ -123,14 +126,12 @@ export const FILTER_CLIENT_SESSIONS = gql`
|
||||
radioType
|
||||
signal
|
||||
manufacturer
|
||||
details
|
||||
equipment {
|
||||
name
|
||||
}
|
||||
}
|
||||
context {
|
||||
lastPage
|
||||
cursor
|
||||
}
|
||||
context
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -157,7 +158,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 +168,7 @@ export const FILTER_SERVICE_METRICS = gql`
|
||||
) {
|
||||
filterServiceMetrics(
|
||||
customerId: $customerId
|
||||
cursor: $cursor
|
||||
context: $context
|
||||
fromTime: $fromTime
|
||||
toTime: $toTime
|
||||
clientMacs: $clientMacs
|
||||
@@ -181,28 +182,36 @@ export const FILTER_SERVICE_METRICS = gql`
|
||||
rssi
|
||||
rxBytes
|
||||
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
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -218,10 +227,7 @@ export const GET_ALL_STATUS = gql`
|
||||
clientCountPerOui
|
||||
}
|
||||
}
|
||||
context {
|
||||
lastPage
|
||||
cursor
|
||||
}
|
||||
context
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -297,7 +303,7 @@ export const FILTER_SYSTEM_EVENTS = gql`
|
||||
$toTime: String!
|
||||
$equipmentIds: [ID]
|
||||
$dataTypes: [String]
|
||||
$cursor: String
|
||||
$context: JSONObject
|
||||
$limit: Int
|
||||
) {
|
||||
filterSystemEvents(
|
||||
@@ -306,14 +312,11 @@ export const FILTER_SYSTEM_EVENTS = gql`
|
||||
toTime: $toTime
|
||||
dataTypes: $dataTypes
|
||||
equipmentIds: $equipmentIds
|
||||
cursor: $cursor
|
||||
context: $context
|
||||
limit: $limit
|
||||
) {
|
||||
items
|
||||
context {
|
||||
lastPage
|
||||
cursor
|
||||
}
|
||||
context
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
<!-- Allow installing the app to the homescreen -->
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<script type="text/javascript" src="/config.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
15
app/index.js
15
app/index.js
@@ -1,12 +1,10 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Router } from 'react-router-dom';
|
||||
import { ApolloClient } from 'apollo-client';
|
||||
import { InMemoryCache } from 'apollo-cache-inmemory';
|
||||
import { onError } from 'apollo-link-error';
|
||||
import { ApolloClient, ApolloProvider, ApolloLink, Observable } from '@apollo/client';
|
||||
import { InMemoryCache } from '@apollo/client/cache';
|
||||
import { onError } from '@apollo/client/link/error';
|
||||
import { createUploadLink } from 'apollo-upload-client';
|
||||
import { ApolloLink, Observable } from 'apollo-link';
|
||||
import { ApolloProvider } from '@apollo/react-hooks';
|
||||
|
||||
import 'styles/antd.less';
|
||||
import 'styles/index.scss';
|
||||
@@ -17,16 +15,13 @@ import { REFRESH_TOKEN } from 'graphql/mutations';
|
||||
import { getItem, setItem, removeItem } from 'utils/localStorage';
|
||||
import history from 'utils/history';
|
||||
|
||||
const API_URI =
|
||||
process.env.NODE_ENV === 'development'
|
||||
? 'http://localhost:4000/'
|
||||
: 'https://wlan-graphql.zone3.lab.connectus.ai/';
|
||||
const API_URI = process.env.NODE_ENV === 'production' ? window.REACT_APP_API : process.env.API;
|
||||
const MOUNT_NODE = document.getElementById('root');
|
||||
|
||||
const cache = new InMemoryCache();
|
||||
|
||||
const uploadLink = createUploadLink({
|
||||
uri: API_URI,
|
||||
uri: `${API_URI}/graphql`,
|
||||
});
|
||||
|
||||
const request = async operation => {
|
||||
|
||||
3
docker_entrypoint.sh
Normal file
3
docker_entrypoint.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh -eu
|
||||
./generate_config_js.sh >/usr/share/nginx/html/config.js
|
||||
nginx -g "daemon off;"
|
||||
10
generate_config_js.sh
Normal file
10
generate_config_js.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh -eu
|
||||
if [ -z "${API:-}" ]; then
|
||||
API_URL_JSON=undefined
|
||||
else
|
||||
API_URL_JSON=$(jq -n --arg api "$API" '$api')
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
window.REACT_APP_API = $API_URL_JSON;
|
||||
EOF
|
||||
6049
package-lock.json
generated
6049
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wlan-cloud-ui",
|
||||
"version": "0.2.3",
|
||||
"version": "0.5.3",
|
||||
"author": "ConnectUs",
|
||||
"description": "React Portal",
|
||||
"engines": {
|
||||
@@ -10,6 +10,8 @@
|
||||
"scripts": {
|
||||
"test": "jest --passWithNoTests --coverage",
|
||||
"start": "cross-env NODE_ENV=development webpack-dev-server",
|
||||
"start:bare": "cross-env API=https://wlan-graphql.zone3.lab.connectus.ai NODE_ENV=bare webpack-dev-server",
|
||||
"start:dev": "cross-env API=https://wlan-graphql.qa.lab.wlan.tip.build NODE_ENV=development webpack-dev-server",
|
||||
"build": "webpack --mode=production",
|
||||
"format": "prettier --write \"app/**/*.js\"",
|
||||
"eslint-fix": "eslint --fix \"app/**/*.js\"",
|
||||
@@ -18,20 +20,13 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@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.3",
|
||||
"antd": "^4.3.1",
|
||||
"apollo-cache-inmemory": "^1.6.6",
|
||||
"apollo-client": "^2.6.10",
|
||||
"apollo-link": "^1.2.14",
|
||||
"apollo-link-error": "^1.1.13",
|
||||
"apollo-link-http": "^1.5.17",
|
||||
"@apollo/client": "^3.1.3",
|
||||
"@tip-wlan/wlan-cloud-ui-library": "^0.3.16",
|
||||
"antd": "^4.5.2",
|
||||
"apollo-upload-client": "^13.0.0",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"graphql": "^14.6.0",
|
||||
"graphql-tag": "^2.10.3",
|
||||
"highcharts": "^8.1.1",
|
||||
"highcharts": "^8.1.0",
|
||||
"highcharts-react-official": "^3.0.0",
|
||||
"history": "^4.10.1",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
|
||||
@@ -4,6 +4,7 @@ const common = require('./webpack/webpack.common');
|
||||
const envs = {
|
||||
development: 'dev',
|
||||
production: 'prod',
|
||||
bare: 'bare',
|
||||
};
|
||||
/* eslint-disable global-require,import/no-dynamic-require */
|
||||
const env = envs[process.env.NODE_ENV || 'production'];
|
||||
|
||||
73
webpack/webpack.bare.js
Normal file
73
webpack/webpack.bare.js
Normal file
@@ -0,0 +1,73 @@
|
||||
const path = require('path');
|
||||
|
||||
const commonPaths = require('./paths');
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
output: {
|
||||
path: commonPaths.outputPath,
|
||||
publicPath: '/',
|
||||
filename: '[name].js',
|
||||
chunkFilename: '[name].js',
|
||||
},
|
||||
devtool: 'inline-source-map',
|
||||
devServer: {
|
||||
port: 3000,
|
||||
historyApiFallback: true,
|
||||
contentBase: commonPaths.outputPath,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(css|scss)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'style-loader',
|
||||
},
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
modules: {
|
||||
localIdentName: '[name]__[local]___[hash:base64:5]',
|
||||
},
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'style-loader',
|
||||
},
|
||||
{
|
||||
loader: 'css-loader',
|
||||
},
|
||||
{
|
||||
loader: 'less-loader', // compiles Less to CSS
|
||||
options: {
|
||||
lessOptions: {
|
||||
javascriptEnabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
modules: ['node_modules', 'app'],
|
||||
alias: {
|
||||
app: path.resolve(__dirname, '../', 'app'),
|
||||
react: path.resolve(__dirname, '../', 'node_modules', 'react'),
|
||||
'react-router-dom': path.resolve('./node_modules/react-router-dom'),
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -22,23 +22,6 @@ module.exports = {
|
||||
exclude: /node_modules/,
|
||||
use: ['babel-loader', 'eslint-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'style-loader',
|
||||
},
|
||||
{
|
||||
loader: 'css-loader',
|
||||
},
|
||||
{
|
||||
loader: 'less-loader',
|
||||
options: {
|
||||
javascriptEnabled: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
@@ -47,7 +30,7 @@ module.exports = {
|
||||
favicon: './app/images/favicon.ico',
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.GRAPHQL_URL': JSON.stringify(process.env.GRAPHQL_URL),
|
||||
'process.env.API': JSON.stringify(process.env.API || 'http://localhost:4000'),
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
@@ -34,6 +34,26 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'style-loader',
|
||||
},
|
||||
{
|
||||
loader: 'css-loader',
|
||||
},
|
||||
{
|
||||
loader: 'less-loader', // compiles Less to CSS
|
||||
options: {
|
||||
javascriptEnabled: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -14,6 +14,7 @@ module.exports = {
|
||||
chunkFilename: `${commonPaths.jsFolder}/[name].[chunkhash].js`,
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
// Use multi-process parallel running to improve the build speed
|
||||
@@ -67,6 +68,21 @@ module.exports = {
|
||||
'sass-loader',
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
loader: 'css-loader',
|
||||
},
|
||||
{
|
||||
loader: 'less-loader', // compiles Less to CSS
|
||||
options: {
|
||||
javascriptEnabled: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
|
||||
Reference in New Issue
Block a user