275 Commits

Author SHA1 Message Date
Sean Macfarlane
922e11938e patch ui-library 2021-05-13 10:59:38 -04:00
Sean Macfarlane
84c8dc19ce updated dev API 2021-05-03 16:32:08 -04:00
Sean Macfarlane
77dd63ea43 Merge pull request #97 from Telecominfraproject/NOJIRA-replace-highcharts
WIFI-1917: Make compatible with recharts
2021-05-03 15:45:13 -04:00
Sean Macfarlane
adcffb5b73 v1.1.8 2021-05-03 15:30:24 -04:00
Sean Macfarlane
2c0171fe7a Merge branch 'master' into NOJIRA-replace-highcharts 2021-05-03 14:46:43 -04:00
Sean Macfarlane
debd0712b3 v.1.1.7 2021-04-26 15:03:59 -04:00
Sean Macfarlane
0c39ad4d52 v1.1.6 2021-04-21 20:22:05 -04:00
Sean Macfarlane
23574b0970 Merge pull request #100 from Telecominfraproject/bugfix/WIFI-1846
bugfix/WIFI-1846: Fixed fetchPolicy for AP details profile dropdown
2021-04-21 16:12:37 -04:00
Sean Macfarlane
177b41dc8d v1.1.5 2021-04-21 16:10:54 -04:00
irtiza-h30
9b5340dfcd fixed fetchPolicy for AP details profile dropdown 2021-04-21 14:55:08 -04:00
Sean Macfarlane
d3be117c5b Merge pull request #99 from Telecominfraproject/WIFI-2026
WIFI-2026 Change docker tags from 0.0.1-SNAPSHOT to 1.1.0-SNAPSHOT
2021-04-16 17:03:05 -04:00
Akshay Jagadish
f317b2869a WIFI-2026 Change docker tags from 0.0.1-SNAPSHOT to 1.1.0-SNAPSHOT 2021-04-16 15:59:16 -04:00
Sean Macfarlane
3cf5c9e732 v1.1.4 2021-04-16 14:41:48 -04:00
Sean Macfarlane
170d62aee8 v1.1.3 2021-04-09 14:33:57 -04:00
Sean Macfarlane
ca7acd6e80 update version 2021-04-08 14:43:17 -04:00
Sean Macfarlane
2bd5601443 Merge pull request #98 from Telecominfraproject/bugfix/NETEXP-1399
bugfix/NETEXP-1399: Added Pagination for AP select in Auto-Provision page
2021-04-07 15:19:01 -04:00
irtiza-h30
eecae86de6 pagination for AP select in Auto-Provision page 2021-04-07 14:40:51 -04:00
Hassan Azmi
90c4e5bedc add recharts and remove highcharts 2021-04-01 14:19:40 -04:00
Sean Macfarlane
f6fbe3a52a fixed graphql API 2021-04-01 12:32:13 -04:00
Hassan Azmi
a526b70fc2 make compatible with recharts 2021-04-01 11:11:56 -04:00
Sean Macfarlane
8ed817256f fixed webpack 2021-03-29 16:46:36 -04:00
Sean Macfarlane
eab121730c fixed webpack 2021-03-28 16:04:36 -04:00
Sean Macfarlane
b73d547223 temp webpack fix 2021-03-26 18:07:06 -04:00
Sean Macfarlane
08b8038c60 fixed webpack 2021-03-25 16:50:39 -04:00
Sean Macfarlane
9d9938fb4a Merge pull request #96 from Telecominfraproject/bugfix/NETEXP-1296
bugfix/NETEXP-1296: Fixed refetching of service metrics data
2021-03-24 11:15:33 -04:00
irtiza-h30
e7cb25a398 fixed refetching of service metrics data 2021-03-23 20:00:06 -04:00
Sean Macfarlane
7810f51baf updated versions 2021-03-23 11:05:19 -04:00
Sean Macfarlane
300f00cc85 Merge pull request #95 from Telecominfraproject/bugfix/NETEXP-1335
bugfix/NETEXP-1335: Added associatedSsidProfiles field in GetProfile query
2021-03-23 10:49:20 -04:00
irtiza-h30
0b83cce523 Added osuSsidProfile in getProfile query 2021-03-22 15:26:22 -04:00
irtiza-h30
5de121330e associatedSsidProfiles field in GetProfile query 2021-03-19 17:11:11 -04:00
Sean Macfarlane
252047aad4 WIFI-1557 2021-03-19 00:42:26 -04:00
Sean Macfarlane
a7c7b0f295 Merge pull request #94 from Telecominfraproject/bugfix/WIFI-1755
bugfix/WIFI-1755: Used correct dataIndex for AP Table Channels
2021-03-17 14:09:27 -04:00
Sean Macfarlane
8d14212702 updated library 2021-03-17 14:03:06 -04:00
irtiza-h30
70d609643c used correct dataIndex for AP Table Channels 2021-03-17 12:45:02 -04:00
Sean Macfarlane
a6e2f9b5c7 Merge pull request #93 from Telecominfraproject/hotfix/BulkEditTable
hotfix/BulkEditTable: Added radioMap property to tableData array
2021-03-17 11:47:25 -04:00
irtiza-h30
569ce9d5f9 added radioMap property to tableData array 2021-03-16 19:32:41 -04:00
Sean Macfarlane
a0506eaf07 update library 2021-03-12 13:52:50 -05:00
Sean Macfarlane
31074ac42e fixed image upload 2021-03-11 18:46:11 -05:00
Sean Macfarlane
2eebd4ac3d update version 2021-03-09 21:11:46 -05:00
Sean Macfarlane
153e4f7dcf updated library 2021-03-09 17:43:13 -05:00
Sean Macfarlane
325f86ff42 Merge pull request #92 from Telecominfraproject/bugfix/WIFI-1452
bugfix/WIFI-1452: Fixed bug on Edit User page
2021-03-09 12:04:06 -05:00
irtiza-h30
5bff3379d5 fixed rendering bug 2021-03-08 22:05:04 -05:00
irtiza-h30
a2cf42e90c Fixed bug on Edit User page 2021-03-08 17:56:50 -05:00
Sean Macfarlane
0fd5803584 updated library 2021-03-08 16:01:11 -05:00
Sean Macfarlane
af98ac522a Merge pull request #91 from Telecominfraproject/bugfix/WIFI-824
bugfix/WIFI-824: File downloading functionality for Captive Portal Page
2021-03-08 16:00:00 -05:00
irtiza-h30
6baf3785da file downloading functionality 2021-03-08 15:39:15 -05:00
Sean Macfarlane
36682cd207 fixed publish action 2021-03-04 13:25:12 -05:00
Sean Macfarlane
63ac433ad8 fixed actin 2021-03-04 13:16:13 -05:00
Sean Macfarlane
2ed09f903c release 1.0.0 2021-03-04 13:01:34 -05:00
Sean Macfarlane
2c0fa53896 Merge pull request #90 from Telecominfraproject/bugfix/WIFI-1505
hotfix/WIFI-1505: Manual Channel Editing
2021-03-04 12:41:10 -05:00
irtiza-h30
9bf737c1eb Manual backup channel change for Bulk-Edit APs 2021-03-03 14:22:02 -05:00
Sean Macfarlane
cf5be15402 removed caching 2021-02-26 14:06:09 -05:00
Sean Macfarlane
f3ee2f5a7c fixed ap details profiles 2021-02-22 22:27:56 -05:00
Sean Macfarlane
6ddd9b30f3 updated library 2021-02-20 20:38:19 -05:00
Sean Macfarlane
8acdd0ca4a updated library 2021-02-18 14:10:41 -05:00
Sean Macfarlane
8670e74b77 Merge pull request #88 from Telecominfraproject/bugfix/WIFI-1442
Bugfix/WIFI-1442: Bulk-Edit APs Page Fixes
2021-02-18 11:10:06 -05:00
irtiza-h30
c8798dd6b3 fixed function for updated param type 2021-02-18 10:19:38 -05:00
Sean Macfarlane
82b5688503 WIFI-1557 2021-02-17 13:55:54 -05:00
irtiza-h30
fadb618c6a fixed column styling 2021-02-16 17:53:46 -05:00
Sean Macfarlane
dbf54d26b6 updated library 2021-02-16 14:36:42 -05:00
irtiza-h30
11e7b92902 null safe fix 2021-02-12 14:52:23 -05:00
irtiza-h30
cb8364b1ab fixed saving bug 2021-02-12 11:45:53 -05:00
Sean Macfarlane
796bf24ef9 updated library 2021-02-05 12:45:47 -05:00
Sean Macfarlane
444a9a929d updated library 2021-01-29 14:25:45 -05:00
Sean Macfarlane
efea725ce9 Merge pull request #87 from Telecominfraproject/hotfix/ProfilePages
hotfix/ProfilePages: fixed prop names
2021-01-23 16:01:41 -05:00
Sean Macfarlane
7a3bcbb2cb update versions 2021-01-23 16:00:06 -05:00
Sean Macfarlane
a3e304323d Merge branch 'master' into hotfix/ProfilePages 2021-01-22 19:04:16 -05:00
Sean Macfarlane
af182c93c6 fixed update equipment 2021-01-22 18:56:16 -05:00
irtiza-h30
78fde75678 fixed props 2021-01-21 19:32:14 -05:00
Sean Macfarlane
7eda2074b2 updated version 2021-01-20 12:22:44 -05:00
Sean Macfarlane
ded1b2d088 fixed error policies 2021-01-20 12:21:45 -05:00
Sean Macfarlane
e1f0357c1f Merge pull request #86 from Telecominfraproject/bugfix/NETEXP-523
bugfix/NETEXP-523: Passed down radius & captive profiles to AddProfile
2021-01-05 12:14:21 -05:00
ToanDo
b84e156f74 Passed down radius&captive profiles to AddProfile 2021-01-04 18:02:00 -05:00
Sean Macfarlane
cae23638ee Merge pull request #85 from Telecominfraproject/bugfix/NETEXP-839
bugfix/NETEXP-839: Added comparison to filter out negative values of the traffic graph
2020-12-21 21:59:40 -05:00
ToanDo
569154ff95 Added comparator to filter out negative traffic 2020-12-21 15:15:03 -05:00
Sean Macfarlane
78146969f3 update version 2020-12-16 13:22:20 -05:00
Sean Macfarlane
c39ee3e2c0 update version 2020-12-14 22:59:10 -05:00
Sean Macfarlane
017a3de539 Merge pull request #83 from Telecominfraproject/bugfix/NETEXP-783
bugfix/NETEXP-783: AP table uses baseMacAddress and manufacturer
2020-12-14 22:30:34 -05:00
Sean Macfarlane
85ef801831 fixed macaddress 2020-12-14 22:25:12 -05:00
ToanDo
9582ca56af AP table uses baseMacAddress and manufacturer 2020-12-14 21:49:32 -05:00
Sean Macfarlane
26c11502e3 Merge pull request #82 from Telecominfraproject/hotfix/NETEXP-558
hotfix/NETEXP-558: Auto updates firmware version
2020-12-13 14:38:21 -05:00
Sean Macfarlane
83e4bc5e33 updated library 2020-12-13 12:12:54 -05:00
Sean Macfarlane
a89ac6e550 Merge pull request #81 from Telecominfraproject/hotfix/NETEXP-750
hotfix/NETEXP-750: Friendly Radio Names
2020-12-13 11:55:58 -05:00
chris-cosentino
3910e75712 updated list of firmware targets 2020-12-13 01:28:25 -05:00
chris-cosentino
2bf34a62e3 additional user friendly radio label fixes 2020-12-12 20:49:18 -05:00
Sean Macfarlane
2d06e56ffb update version 2020-12-12 18:43:39 -05:00
chris-cosentino
f13ec45465 added radioTypes constant 2020-12-12 17:50:35 -05:00
Sean Macfarlane
d2fe2c7dc3 Merge pull request #80 from Telecominfraproject/bugfix/NETEXP-741
bugfix/NETEXP-741: Passed down currentUserId to accounts page
2020-12-12 15:45:18 -05:00
ToanDo
2aeaaab3bc Passed down currentUserId to accounts page 2020-12-12 15:17:51 -05:00
Sean Macfarlane
4dbed9922b updated library 2020-12-10 14:01:07 -05:00
Sean Macfarlane
7d2b1ea5fc Merge pull request #78 from Telecominfraproject/hotfix/WIFI-640
Hotfix/WIFI-640: Added delete button
2020-12-09 17:24:00 -05:00
chris-cosentino
6dd251dd94 added fetch policy 2020-12-09 16:26:35 -05:00
Sean Macfarlane
285444f0b9 Merge pull request #79 from Telecominfraproject/feature/WIFI-1089
Feature/WIFI-1089: Added venue, operator, & id provider props
2020-12-09 16:13:52 -05:00
Sean Macfarlane
7c16a50e81 Merge branch 'master' into feature/WIFI-1089 2020-12-09 15:48:19 -05:00
chris-cosentino
8f2a33b625 used history push and removed cache when delete ap 2020-12-09 11:04:11 -05:00
chris-cosentino
3be405a577 added delete equipment 2020-12-08 15:52:30 -05:00
Toan Do
940eeb72fd Add childProfiles prop 2020-12-07 11:03:25 -05:00
Toan Do
0c14857dac removed unused props 2020-12-03 17:36:40 -05:00
Sean Macfarlane
612e9eb449 fixed precommit 2020-12-03 13:55:29 -05:00
Sean Macfarlane
e02bd79c26 fixed precommit 2020-12-03 13:54:18 -05:00
Sean Macfarlane
0b1e2a7427 Merge pull request #77 from Telecominfraproject/hotfix/WIFI-1133
hotfix/WIFI-1133: Added rfProfiles and fetchMoreRfProfiles
2020-12-03 13:49:40 -05:00
Sean Macfarlane
ea605f333c update package 2020-12-03 13:49:10 -05:00
Sean Macfarlane
1e8306ad4b updated version and fixed precommit 2020-12-03 12:55:47 -05:00
Sean Macfarlane
965dca7e7f Merge branch 'master' into hotfix/WIFI-1133 2020-12-03 12:39:03 -05:00
Toan Do
de2570662a added childProfiles prop 2020-12-01 15:52:16 -05:00
Toan Do
64a1ecae8a Added childProfiles prop 2020-12-01 15:17:40 -05:00
Toan Do
0ceff9e42e adjusted ssid & rf profiles props 2020-12-01 10:10:05 -05:00
Toan Do
b287aa4005 included new API in package.json 2020-12-01 10:00:16 -05:00
Sean Macfarlane
23cc799d71 switched live server 2020-12-01 01:56:22 -05:00
Toan Do
4ea1e55cdd Added rfProfiles and fetchMoreRfProfiles 2020-11-30 12:25:54 -05:00
Sean Macfarlane
cca9fc3667 switched Role to Roles 2020-11-27 20:34:29 -05:00
Toan Do
883379c48c Added profiiles data&fetch to AddProfiles 2020-11-26 10:06:49 -05:00
Toan Do
514100c6bc Added venue, operator, and id provider data &fetch 2020-11-26 09:45:11 -05:00
Sean Macfarlane
0f463832a7 added GenericNotFound 2020-11-21 01:03:03 -05:00
Sean Macfarlane
157b4ecb33 update version 2020-11-21 00:38:35 -05:00
Sean Macfarlane
155aeb27e0 made constant for Routes 2020-11-21 00:36:48 -05:00
Sean Macfarlane
6b43f8967d updated package 2020-11-19 21:26:52 -05:00
Sean Macfarlane
e744fed5d8 updated version 2020-11-17 18:00:59 -05:00
Sean Macfarlane
1f9da3f314 updated version 2020-11-17 17:58:57 -05:00
Sean Macfarlane
0d6b2f05af fixed prettier formatting 2020-11-17 15:24:57 -05:00
Sean Macfarlane
98d6fb6dbd fixed npm commands 2020-11-16 15:18:06 -05:00
Sean Macfarlane
3f3c81f5db fixed OUI upload error 2020-11-11 10:52:47 -05:00
Sean Macfarlane
76acff8b89 fixed profile refetch 2020-11-09 16:21:40 -05:00
Sean Macfarlane
4bab1f3c1c Merge pull request #75 from Telecominfraproject/hotfix/profiles-refetch
hotfix/WIFI-735: fixed profiles refetch
2020-11-09 15:31:12 -05:00
Sean Macfarlane
2f12264af3 fixed profiles refetch 2020-11-09 15:24:35 -05:00
Sean Macfarlane
016d1ff439 update package 2020-11-07 19:07:17 -05:00
Sean Macfarlane
1f06e0b89c update version 2020-11-06 11:48:11 -05:00
Sean Macfarlane
cacb2a3833 added null check 2020-11-06 11:47:08 -05:00
Sean Macfarlane
bf39c6b6dc fixed dashboard usage 2020-11-06 11:45:38 -05:00
Sean Macfarlane
8d2de52870 update version 2020-11-06 01:08:38 -05:00
Sean Macfarlane
8b0dc34ac4 update version 2020-11-05 23:18:43 -05:00
Sean Macfarlane
6646226cb7 Merge pull request #72 from Telecominfraproject/hotfix/WIFI-1043
hotfix/WIFI-1043: Usage info on dashboard shows total sum of traffic
2020-11-05 16:16:28 -05:00
chris-cosentino
120ae073fb hotfix/WIFI-1043: Usage info on dashboard shows total sum of traffic 2020-11-05 15:05:59 -05:00
chris-cosentino
834b7b28a7 hotfix/WIFI-1043: Usage info on dashboard shows total sum of traffic 2020-11-05 14:01:27 -05:00
chris-cosentino
d9a970350b hotfix/WIFI-1043: Usage info on dashboard shows total sum of traffic 2020-11-05 13:53:19 -05:00
Sean Macfarlane
60c2c21997 fixed webpack less loader 2020-11-04 20:31:31 -05:00
Sean Macfarlane
26d74f6059 audit fixed 2020-11-04 20:23:48 -05:00
Sean Macfarlane
1682a2ca21 fixed webpack 2020-11-04 20:05:57 -05:00
Sean Macfarlane
1fa7080593 update version 2020-11-04 14:29:49 -05:00
Sean Macfarlane
ac405ae1c4 Merge pull request #71 from Telecominfraproject/feature/WIFI-1012
feature/WIFI-1012: Added client device status support
2020-11-02 15:55:47 -05:00
chris-cosentino
c1264c3ea0 WIFI-1012: Added client device status support 2020-11-02 15:06:39 -05:00
chris-cosentino
cfee505a5b feature/WIFI-1012: Added client device status support 2020-11-02 13:16:05 -05:00
chris-cosentino
ba49ca4e16 feature/WIFI-1012: Added client device status support 2020-10-30 16:43:48 -04:00
Sean Macfarlane
c40a8ca157 update version 2020-10-14 15:13:16 -04:00
Sean Macfarlane
0dfb7a7901 Merge pull request #69 from Telecominfraproject/WIFI-846
WIFI 846: docker cron schedule
2020-10-13 10:27:35 -04:00
AkshayJagadish-ne
153394cad0 Updated condition for push job
Updated condition for push job to get executed even on nightly builds
2020-10-13 02:09:11 -04:00
AkshayJagadish-ne
1507320fae Added a commit.properties file to support running the docker locally 2020-10-13 02:05:16 -04:00
AkshayJagadish-ne
673002b685 Correction
moved copy statement to the production environment
2020-10-12 23:05:28 -04:00
Sean Macfarlane
c014ba5e40 Merge pull request #61 from Telecominfraproject/hotfix/WIFI-851
hotfix/WIFI-851: Fixed editing Model Target Version creating duplicates
2020-10-09 11:25:25 -04:00
Sean Macfarlane
b20caa666d update version 2020-10-09 10:27:09 -04:00
Sean Macfarlane
c75e5ea934 fixed OUI Upload 2020-10-08 18:12:35 -04:00
Sean Macfarlane
631482ab6f Merge pull request #66 from Telecominfraproject/WIFI-846
Wifi 846
2020-10-07 18:19:55 -04:00
Sean Macfarlane
2d42d59c54 Merge pull request #65 from Telecominfraproject/WIFI-845
WIFI-845: Support Kubernetes Deployment Versioning
2020-10-07 18:19:18 -04:00
Toan Do
229d50f1a8 Added parameter to handleUpdateTrack 2020-10-07 14:41:00 -04:00
AkshayJagadish-ne
f6078182ff Subtask WIFI-913
Added a step to copy the commit.properties file that would be created by the workflow into the container.
2020-10-07 13:40:07 -04:00
AkshayJagadish-ne
3f0c1c0e33 Subtask WIFI-913
cleared line spaces
2020-10-07 13:25:40 -04:00
AkshayJagadish-ne
6dbaddc021 Subtask WIFI-913 2020-10-07 13:24:21 -04:00
AkshayJagadish-ne
64096d040d Subtask WIFI-913
A property file with commit hash and version will be added to the container's directory during the build. This file would be used by QA
2020-10-07 13:20:14 -04:00
AkshayJagadish-ne
5a634b2e8a Subtask WIFI-922
Added nightly build to generate images with a timestamp. This is done so that the front-end and back-end components would have the same timestamp tag. The timestamp would then be used to test a deployment version for a specific day.
2020-10-07 13:02:49 -04:00
Sean Macfarlane
69972e0033 Merge pull request #62 from Telecominfraproject/hotfix/WIFI-774
hotfix/WIFI-774
2020-10-05 17:22:44 -04:00
Toan Do
743c4f3665 adjusted onComplete of searchOUI 2020-10-05 15:27:40 -04:00
Sean Macfarlane
d70df54986 Merge pull request #64 from Telecominfraproject/feature/WIFI-817
Feature/wifi 817: Switch to Inactive Bank, and Reboot AP
2020-10-02 17:51:03 -04:00
Sean Macfarlane
b40b29f73d new version 2020-10-02 17:49:01 -04:00
Sean Macfarlane
2206a9bf3f new version 2020-10-02 17:48:50 -04:00
Sean Macfarlane
450fe6280f added Inactive bank and Reboot AP 2020-10-02 17:14:42 -04:00
Toan Do
d0424480fe removed cache for searchOUI query 2020-10-02 13:20:09 -04:00
Toan Do
ea2b4f90b7 fixed searchOUI error notification 2020-10-02 11:49:59 -04:00
Toan Do
fbfd4895b1 updated condtion for updateTrackAssignment 2020-10-01 13:10:55 -04:00
Toan Do
eafc05b645 fixed updateTrackAssignment for edit btn 2020-09-30 17:54:48 -04:00
Sean Macfarlane
0009bd5ca6 Merge pull request #60 from Telecominfraproject/hotfix/WIFI-758
WIFI-758: Fixed data path for updateEquipmentFirmware
2020-09-15 13:43:20 -04:00
Sean Macfarlane
e38dd84f11 Merge pull request #59 from Telecominfraproject/feature/WIFI-613
Feature/wifi 613 Added Firmware Version to AP Table
2020-09-15 13:42:45 -04:00
Sean Macfarlane
e6a0dc9f12 added npm script for graphql server 2020-09-15 13:16:36 -04:00
Toan Do
327c4ea3d1 Fixed data path for updateEquipmentFirmware 2020-09-15 09:47:57 -04:00
Toan Do
01dbd0a887 changed FIRMWARE column title 2020-09-14 17:05:04 -04:00
Sean Macfarlane
5b46dbf657 Merge pull request #58 from Telecominfraproject/hotfix/WIFI-708
Hotfix/wifi 708: Added default values to the Access Points table
2020-09-14 17:04:09 -04:00
Toan Do
46c860f310 Added Firmware Version column to AP table 2020-09-14 14:47:43 -04:00
Toan Do
51d34055ba Modied FILTER_EQUIPMENT to include firmware 2020-09-14 14:47:01 -04:00
Toan Do
be3582514c removed padding 2020-09-11 16:52:59 -04:00
Toan Do
afc6ddc30e made default for AP table 2020-09-11 16:52:39 -04:00
Sean Macfarlane
4314239e1d fixed fetchPolicy for profiles 2020-09-11 15:32:21 -04:00
Toan Do
bac628ea67 added renderDefaultTableCell function 2020-09-11 13:56:48 -04:00
Sean Macfarlane
bac2f43eb0 made it easier to run repo locally 2020-09-08 13:21:59 -04:00
Sean Macfarlane
f7681e9bd3 update version 2020-09-02 19:47:54 -04:00
Sean Macfarlane
5d822bdd78 fixed bugs and pagination 2020-09-02 19:35:15 -04:00
Sean Macfarlane
cbfce876b3 Merge pull request #57 from Telecominfraproject/hotfix/Pagination
hotfix/Pagination: Pagination for profiles query
2020-09-02 11:22:50 -04:00
Sean Macfarlane
16d4933190 update version 2020-08-26 20:02:24 -04:00
Irtiza-h30
85f3386c23 pagination for profiles query 2020-08-26 18:33:04 -04:00
Sean Macfarlane
c929a1eff5 Merge pull request #53 from Telecominfraproject/hotfix/WIFI-644
hotfix/WIFI-644: Location restructure
2020-08-26 18:03:38 -04:00
Sean Macfarlane
401f22b10a Merge pull request #50 from Telecominfraproject/hotfix/WIFI-553
hotfix/WIFI-553: Confirm Modal
2020-08-26 18:00:17 -04:00
Sean Macfarlane
40f2ef31ce Merge branch 'master' into hotfix/WIFI-553 2020-08-26 17:54:19 -04:00
Sean Macfarlane
2813057c31 Merge branch 'master' into hotfix/WIFI-644 2020-08-26 17:09:59 -04:00
Sean Macfarlane
8d1339c412 added missing slash 2020-08-25 14:36:01 -04:00
Sean Macfarlane
54ca94cefa update version 2020-08-25 00:34:29 -04:00
Sean Macfarlane
d750a0e798 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-ui 2020-08-24 23:54:43 -04:00
Sean Macfarlane
09f2e91f4c Merge pull request #54 from Telecominfraproject/feature/WIFI-661
Feature/WIFI-661: Upgrade Apollo Client
2020-08-24 23:54:30 -04:00
Sean Macfarlane
4f18a93375 changed apollo server to use express 2020-08-24 23:54:14 -04:00
Sean Macfarlane
5a41840f1d Merge pull request #55 from Telecominfraproject/hotfix/WIFI-679
hotfix/WIFI-679: Dashboard traffic has NaN values
2020-08-24 23:47:00 -04:00
Sean Macfarlane
f5f30f3784 Merge pull request #56 from Telecominfraproject/hotfix/WIFI-612
hotfix/WIFI-612: Fixed Firmware Query on AP Details
2020-08-24 23:41:55 -04:00
Sean Macfarlane
6edc98af47 increased profiles limit 2020-08-24 16:32:26 -04:00
Irtiza-h30
15df3caf6b fixed firwmare query 2020-08-24 14:01:04 -04:00
Hassan Azmi
94a26fef43 Use absolute value of bytes when determining exponent 2020-08-21 14:57:36 -04:00
Hassan Azmi
b44290a28a Add back cloud-ui-library to the package-lock 2020-08-21 13:30:57 -04:00
Hassan Azmi
823d7d0fef Merge branch 'master' into feature/WIFI-661
# Conflicts:
#	app/containers/Profiles/index.js
2020-08-21 13:07:04 -04:00
Hassan Azmi
d33caa8885 Upgraded to Apollo Client 3. 2020-08-21 12:43:56 -04:00
Irtiza-h30
c4d9f76c2e Merge branch 'master' into hotfix/WIFI-553 2020-08-21 12:30:11 -04:00
Sean Macfarlane
c416d87106 Merge pull request #51 from Telecominfraproject/hotfix/WIFI-592
hotfix/WIFI-592: Add Profile goes back and refreshes profiles
2020-08-21 11:19:47 -04:00
Sean Macfarlane
5023ed9d96 Merge pull request #52 from Telecominfraproject/hotfix/AddAP
hotfix/AddAP: filter_equipment query refetches after AP is added
2020-08-21 11:18:13 -04:00
Hassan Azmi
125e988f25 Perform add/edit/delete/create logic in this repo instead of library to prevent unnecessary passing of variables 2020-08-21 10:06:26 -04:00
Hassan Azmi
4069374d58 Workaround for root of tree to create COUNTRY locations 2020-08-20 16:24:13 -04:00
Irtiza-h30
ded926c98b filter_equipment query refetches after AP is added 2020-08-20 13:12:12 -04:00
Irtiza-h30
7b0becec58 merged with master 2020-08-20 10:24:00 -04:00
Irtiza-h30
9be76979ea fixed redirect 2020-08-19 20:50:01 -04:00
Irtiza-h30
cf9cc4d6ac undo 2020-08-19 20:35:20 -04:00
Irtiza-h30
0ef102e28e Merge branch 'hotfix/WIFI-553' of https://github.com/Telecominfraproject/wlan-cloud-ui into hotfix/WIFI-553 2020-08-19 20:33:44 -04:00
Irtiza-h30
41f27c76b1 undo 2020-08-19 20:33:36 -04:00
Irtiza-h30
124a84b75f undo 2020-08-19 20:33:15 -04:00
Hassan Azmi
1b5a09636f Only refetch when explicitly intended 2020-08-19 19:06:18 -04:00
Irtiza-h30
81cc493aa3 fixed redirect 2020-08-19 18:21:41 -04:00
Hassan Azmi
41a27ff9ef preliminary work 644 2020-08-19 18:09:04 -04:00
Sean Macfarlane
1c6f8dfdba Merge pull request #48 from Telecominfraproject/hotfix/WIFI-588
hotfix/WIFI-588: Error on login
2020-08-19 17:46:56 -04:00
Sean Macfarlane
5911395fac Merge branch 'master' into hotfix/WIFI-588 2020-08-19 17:45:53 -04:00
Hassan Azmi
941b952ff6 Route to profiles when adding profile is complete 2020-08-19 14:08:23 -04:00
Hassan Azmi
4065a9272c no message 2020-08-19 13:44:52 -04:00
Sean Macfarlane
333b37a139 Merge pull request #49 from Telecominfraproject/hotfix/WIFI-590
hotfix/WIFI-590: Reload profiles when one is deleted
2020-08-19 12:46:17 -04:00
Hassan Azmi
0939aacdbe Make resetting the store synchronous 2020-08-19 12:46:04 -04:00
Irtiza-h30
bb1da8f0c9 updated redirect 2020-08-19 12:33:48 -04:00
Sean Macfarlane
a11c7d651d update version 2020-08-19 12:09:31 -04:00
Sean Macfarlane
07f1f64537 Merge pull request #42 from Telecominfraproject/feature/TW-975
Feature/TW-975: Captive User List & Radius
2020-08-18 18:00:23 -04:00
Sean Macfarlane
8bde2ad4bc cleanup 2020-08-18 17:50:37 -04:00
Sean Macfarlane
ac848713ea Merge branch 'master' into feature/TW-975 2020-08-18 17:23:40 -04:00
Sean Macfarlane
4bebfe68f6 Merge pull request #47 from Telecominfraproject/hotfix/pagination
Hotfix/pagination
2020-08-18 17:23:06 -04:00
Sean Macfarlane
7bf25f4edb update version 2020-08-18 17:19:31 -04:00
Sean Macfarlane
0ff45e9d87 Merge branch 'master' into hotfix/pagination 2020-08-18 17:19:07 -04:00
Sean Macfarlane
f877b4c3c1 Merge branch 'master' into feature/TW-975 2020-08-18 17:15:28 -04:00
Sean Macfarlane
ecf2c2fa8c Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-ui 2020-08-18 16:52:42 -04:00
Sean Macfarlane
d5c094d749 update antd 2020-08-18 16:52:39 -04:00
Hassan Azmi
26dba66470 Refetch profiles when going back to router 2020-08-18 16:45:17 -04:00
Sean Macfarlane
5ae31d7198 Merge pull request #45 from Telecominfraproject/hotfix/WIFI-571
hotfix/WIFI-571: updated firmware query
2020-08-18 16:41:43 -04:00
Sean Macfarlane
2bd50d4560 update version 2020-08-18 16:20:10 -04:00
Sean Macfarlane
a8843d4be7 fixed pagination 2020-08-18 16:18:49 -04:00
Hassan Azmi
644cdd2c45 Refetch instead of reload table 2020-08-18 15:24:05 -04:00
Hassan Azmi
035a714fa6 Reload table on profile create 2020-08-18 14:35:06 -04:00
Hassan Azmi
2d7514fbde Do not reset store when user is authenticated. Instead clear cache. 2020-08-18 13:58:59 -04:00
Irtiza-h30
0c5f0842e9 split up errors/loading for profile and firmware 2020-08-18 11:00:59 -04:00
Sean Macfarlane
86087930da fixed profiles pagination 2020-08-18 00:40:45 -04:00
Irtiza-h30
e60ec0c713 added tab to access point details component route 2020-08-17 19:27:05 -04:00
Sean Macfarlane
fd4f90173b Update README.md 2020-08-17 11:56:34 -04:00
Sean Macfarlane
a4d4dce73a Update README.md 2020-08-17 11:54:59 -04:00
Sean Macfarlane
7b8f45d9f2 Update README.md 2020-08-17 11:44:48 -04:00
Irtiza-h30
3affd7b6a6 removed useEffect and used skip (works) 2020-08-15 10:27:27 -04:00
Irtiza-h30
5854c1a0a0 updated query 2020-08-14 23:43:50 -04:00
Sean Macfarlane
a2352e2d01 Merge branch 'master' into feature/TW-975 2020-08-14 14:20:29 -04:00
Sean Macfarlane
c0074b6610 Merge pull request #46 from Telecominfraproject/hotfix/WIFI-584
hotfix/WIFI-584: Added Equipment Count
2020-08-14 12:18:51 -04:00
Irtiza-h30
dfb4bf21cd added equipmentCount 2020-08-14 10:18:43 -04:00
Irtiza-h30
2514d9e77c updated firmware query 2020-08-13 16:38:16 -04:00
Sean Macfarlane
f2c5b5c5f3 Merge pull request #44 from Telecominfraproject/hotfix/TW-959
Hotfix/TW-959: Loading circle in wrong place for AP Details, Profiles, ProfileDetails components
2020-08-12 18:17:48 -04:00
Alidev123
8b5af07f87 fixed loading circle placement for AccessPointDetails, Profile and ProfileDetails 2020-08-12 13:51:15 -04:00
Sean Macfarlane
a1d4081f0b oops 2020-08-12 12:43:41 -04:00
Sean Macfarlane
d6d054f53e temporarily fixed Profiles 2020-08-11 22:31:41 -04:00
Sean Macfarlane
7936777344 Merge pull request #37 from Telecominfraproject/feature/network-page-reload-function
Feature/network-page-reload-function
2020-08-04 15:06:14 -04:00
Sean Macfarlane
057e7c2d0a new version 2020-08-04 15:02:01 -04:00
Sean Macfarlane
7911c630b4 cleanup 2020-08-04 14:42:37 -04:00
Sean Macfarlane
0108229ddb cleanup 2020-08-04 14:36:40 -04:00
Sean Macfarlane
51750b83c8 fixed typo 2020-08-04 12:04:53 -04:00
Alidev123
aaf14b0d0a Merge branch 'master' of https://github.com/Telecominfraproject/wlan-cloud-ui into feature/network-page-reload-function 2020-08-04 11:45:06 -04:00
Alidev123
b2bee67551 fixed error and loading message display for NetworkTable component 2020-08-04 11:44:50 -04:00
Sean Macfarlane
2dd3bff53c Merge branch 'master' into feature/network-page-reload-function 2020-08-01 13:18:02 -04:00
Alidev123
ad0a6d299b refactor code for network table and its corresponding buttons 2020-07-29 16:10:41 -04:00
Alidev123
bcadd1f8d4 fixed reload button functionality for APs and Client Devices components 2020-07-28 12:04:10 -04:00
Alidev123
af809974b6 added reload functionality to network page 2020-07-27 14:24:38 -04:00
Alidev123
573718bc1e added reload functionality to network page 2020-07-27 14:15:36 -04:00
Alidev123
c7a1ec1dc3 Merge branch 'master' of https://github.com/Telecominfraproject/wlan-cloud-ui into feature/TW-917 2020-07-27 11:28:54 -04:00
Alidev123
6ea3c778cd Merge branch 'master' of https://github.com/Telecominfraproject/wlan-cloud-ui into feature/TW-917 2020-07-24 11:17:22 -04:00
Alidev123
3b6d1a57ca updated Add Location button to top of TreeView 2020-07-24 11:16:58 -04:00
Alidev123
6498e2a984 Add Location Button to top of TreeView to create root location 2020-07-23 15:18:35 -04:00
42 changed files with 7315 additions and 9422 deletions

View File

@@ -5,6 +5,7 @@ on:
# Publish `master` as Docker `latest` image. # Publish `master` as Docker `latest` image.
branches: branches:
- master - master
- 'release/**'
# Publish `v1.2.3` tags as releases. # Publish `v1.2.3` tags as releases.
tags: tags:
@@ -13,6 +14,10 @@ on:
# Run tests for any PRs. # Run tests for any PRs.
pull_request: pull_request:
schedule:
# runs nightly build at 5AM
- cron: '00 09 * * *'
env: env:
IMAGE_NAME: wlan-cloud-ui IMAGE_NAME: wlan-cloud-ui
DOCKER_REPO: tip-tip-wlan-cloud-docker-repo.jfrog.io DOCKER_REPO: tip-tip-wlan-cloud-docker-repo.jfrog.io
@@ -39,11 +44,31 @@ jobs:
needs: test needs: test
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name == 'push' if: github.event_name == 'push' || github.event_name == 'schedule'
steps: steps:
- uses: actions/checkout@v2 - 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//')
# Create a release snapshot if we are on release branch
[[ "${{ github.ref }}" == "refs/heads/release/"* ]] && VERSION=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\/release\/[v]//' | awk '{print $1"-SNAPSHOT"}')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=1.1.0-SNAPSHOT
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 - name: Build image
run: docker build . -f Dockerfile -t image --build-arg NPM_TOKEN=${{secrets.NPM_REPO_AUTH_TOKEN}} run: docker build . -f Dockerfile -t image --build-arg NPM_TOKEN=${{secrets.NPM_REPO_AUTH_TOKEN}}
@@ -56,6 +81,7 @@ jobs:
- name: Push image - name: Push image
run: | run: |
IMAGE_ID=$DOCKER_REPO/$IMAGE_NAME IMAGE_ID=$DOCKER_REPO/$IMAGE_NAME
TIMESTAMP=$(date +'%Y-%m-%d')
# Change all uppercase to lowercase # Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
@@ -66,11 +92,18 @@ jobs:
# Strip "v" prefix from tag name # Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Create a release snapshot if we are on release branch
[[ "${{ github.ref }}" == "refs/heads/release/"* ]] && VERSION=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\/release\/[v]//' | awk '{print $1"-SNAPSHOT"}')
# Use Docker `latest` tag convention # Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest [ "$VERSION" == "master" ] && VERSION=1.1.0-SNAPSHOT
echo IMAGE_ID=$IMAGE_ID echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION echo VERSION=$VERSION
echo TIMESTAMP=$TIMESTAMP
docker tag image $IMAGE_ID:$VERSION docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION docker push $IMAGE_ID:$VERSION
docker tag image $IMAGE_ID:$VERSION-$TIMESTAMP
docker push $IMAGE_ID:$VERSION-$TIMESTAMP

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@
/node_modules /node_modules
/.pnp /.pnp
.pnp.js .pnp.js
package-lock.json
# testing # testing
/coverage /coverage

View File

@@ -13,6 +13,7 @@ ENV PATH /app/node_modules/.bin:$PATH
# where available (npm@5+) # where available (npm@5+)
COPY package*.json ./ COPY package*.json ./
#RUN npm install #RUN npm install
# If you are building your code for production # 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 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
@@ -28,7 +29,8 @@ RUN apk add --no-cache jq
COPY --from=build /app/dist /usr/share/nginx/html COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY docker_entrypoint.sh generate_config_js.sh / COPY docker_entrypoint.sh generate_config_js.sh /
COPY app/commit.properties /
RUN chmod +x docker_entrypoint.sh generate_config_js.sh RUN chmod +x docker_entrypoint.sh generate_config_js.sh
EXPOSE 80 EXPOSE 80
ENTRYPOINT ["/docker_entrypoint.sh"] ENTRYPOINT ["/docker_entrypoint.sh"]

View File

@@ -2,12 +2,30 @@
## Set up environment: ## Set up environment:
Delete from package.json (undo this delete after all steps) Install Dependencies:
`"@tip-wlan/wlan-cloud-ui-library": X.X.X,`
Install Dependencies
`npm install` `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 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 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: ## 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` `npm start`
### Tests ### Tests
`npm run test` `npm test`
### Production ### Production

4
app/commit.properties Normal file
View File

@@ -0,0 +1,4 @@
#This file will be used when running the docker locally
date=${date}
commitId=${commit.id}
projectVersion=${project.version}

View File

@@ -1 +0,0 @@
window.REACT_APP_API = undefined;

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,5 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import gql from 'graphql-tag'; import { useQuery, useMutation, gql } from '@apollo/client';
import { useQuery, useMutation } from '@apollo/react-hooks';
import { Alert, notification } from 'antd'; import { Alert, notification } from 'antd';
import { Accounts as AccountsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { Accounts as AccountsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
@@ -8,28 +7,25 @@ import { Accounts as AccountsPage, Loading } from '@tip-wlan/wlan-cloud-ui-libra
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
const GET_ALL_USERS = gql` const GET_ALL_USERS = gql`
query GetAllUsers($customerId: ID!, $cursor: String) { query GetAllUsers($customerId: ID!, $context: JSONObject) {
getAllUsers(customerId: $customerId, cursor: $cursor) { getAllUsers(customerId: $customerId, context: $context) {
items { items {
id id
email: username email: username
role roles
lastModifiedTimestamp lastModifiedTimestamp
customerId customerId
} }
context { context
cursor
lastPage
}
} }
} }
`; `;
const CREATE_USER = gql` const CREATE_USER = gql`
mutation CreateUser($username: String!, $password: String!, $role: String!, $customerId: ID!) { mutation CreateUser($username: String!, $password: String!, $roles: [String], $customerId: ID!) {
createUser(username: $username, password: $password, role: $role, customerId: $customerId) { createUser(username: $username, password: $password, roles: $roles, customerId: $customerId) {
username username
role roles
customerId customerId
} }
} }
@@ -40,7 +36,7 @@ const UPDATE_USER = gql`
$id: ID! $id: ID!
$username: String! $username: String!
$password: String! $password: String!
$role: String! $roles: [String]
$customerId: ID! $customerId: ID!
$lastModifiedTimestamp: String $lastModifiedTimestamp: String
) { ) {
@@ -48,13 +44,13 @@ const UPDATE_USER = gql`
id: $id id: $id
username: $username username: $username
password: $password password: $password
role: $role roles: $roles
customerId: $customerId customerId: $customerId
lastModifiedTimestamp: $lastModifiedTimestamp lastModifiedTimestamp: $lastModifiedTimestamp
) { ) {
id id
username username
role roles
customerId customerId
lastModifiedTimestamp lastModifiedTimestamp
} }
@@ -70,7 +66,7 @@ const DELETE_USER = gql`
`; `;
const Accounts = () => { const Accounts = () => {
const { customerId } = useContext(UserContext); const { customerId, id: currentUserId } = useContext(UserContext);
const { data, loading, error, refetch, fetchMore } = useQuery(GET_ALL_USERS, { const { data, loading, error, refetch, fetchMore } = useQuery(GET_ALL_USERS, {
variables: { customerId }, variables: { customerId },
@@ -82,7 +78,7 @@ const Accounts = () => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!data.getAllUsers.context.lastPage) { if (!data.getAllUsers.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: data.getAllUsers.context.cursor }, variables: { context: data.getAllUsers.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.getAllUsers; const previousEntry = previousResult.getAllUsers;
const newItems = fetchMoreResult.getAllUsers.items; const newItems = fetchMoreResult.getAllUsers.items;
@@ -99,12 +95,12 @@ const Accounts = () => {
} }
}; };
const handleCreateUser = (email, password, role) => { const handleCreateUser = (email, password, roles) => {
createUser({ createUser({
variables: { variables: {
username: email, username: email,
password, password,
role, roles: [roles],
customerId, customerId,
}, },
}) })
@@ -123,13 +119,13 @@ const Accounts = () => {
); );
}; };
const handleEditUser = (id, email, password, role, lastModifiedTimestamp) => { const handleEditUser = (id, email, password, roles, lastModifiedTimestamp) => {
updateUser({ updateUser({
variables: { variables: {
id, id,
username: email, username: email,
password, password,
role, roles: [roles],
customerId, customerId,
lastModifiedTimestamp, lastModifiedTimestamp,
}, },
@@ -177,6 +173,7 @@ const Accounts = () => {
return ( return (
<AccountsPage <AccountsPage
data={data.getAllUsers.items} data={data.getAllUsers.items}
currentUserId={currentUserId}
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
onCreateUser={handleCreateUser} onCreateUser={handleCreateUser}
onEditUser={handleEditUser} onEditUser={handleEditUser}

View File

@@ -1,11 +1,13 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { AddProfile as AddProfilePage } from '@tip-wlan/wlan-cloud-ui-library'; import { AddProfile as AddProfilePage } from '@tip-wlan/wlan-cloud-ui-library';
import gql from 'graphql-tag'; import { useMutation, useQuery, gql } from '@apollo/client';
import { useMutation, useQuery } from '@apollo/react-hooks';
import { notification } from 'antd'; import { notification } from 'antd';
import { useHistory } from 'react-router-dom';
import { ROUTES } from 'constants/index';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import { GET_ALL_PROFILES } from 'graphql/queries'; import { GET_ALL_PROFILES } from 'graphql/queries';
import { fetchMoreProfiles } from 'graphql/functions';
const CREATE_PROFILE = gql` const CREATE_PROFILE = gql`
mutation CreateProfile( mutation CreateProfile(
@@ -33,10 +35,48 @@ const CREATE_PROFILE = gql`
const AddProfile = () => { const AddProfile = () => {
const { customerId } = useContext(UserContext); const { customerId } = useContext(UserContext);
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES, { const { data: ssidProfiles, fetchMore } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'ssid' }, variables: { customerId, type: 'ssid' },
fetchPolicy: 'network-only',
});
const { data: radiusProfiles, fetchMore: fetchMoreRadiusProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'radius' },
fetchPolicy: 'network-only',
}
);
const { data: captiveProfiles, fetchMore: fetchMoreCaptiveProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'captive_portal' },
fetchPolicy: 'network-only',
}
);
const { data: venueProfiles, fetchMore: fetchMoreVenueProfiles } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'passpoint_venue' },
fetchPolicy: 'network-only',
});
const { data: operatorProfiles, fetchMore: fetchMoreOperatorProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'passpoint_operator' },
fetchPolicy: 'network-only',
}
);
const { data: idProviderProfiles, fetchMore: fetchMoreIdProviderProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'passpoint_osu_id_provider' },
fetchPolicy: 'network-only',
}
);
const { data: rfProfiles, fetchMore: fetchMoreRfProfiles } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'rf' },
fetchPolicy: 'network-only',
}); });
const [createProfile] = useMutation(CREATE_PROFILE); const [createProfile] = useMutation(CREATE_PROFILE);
const history = useHistory();
const handleAddProfile = (profileType, name, details, childProfileIds = []) => { const handleAddProfile = (profileType, name, details, childProfileIds = []) => {
createProfile({ createProfile({
@@ -53,6 +93,7 @@ const AddProfile = () => {
message: 'Success', message: 'Success',
description: 'Profile successfully created.', description: 'Profile successfully created.',
}); });
history.push(ROUTES.profiles, { refetch: true });
}) })
.catch(() => .catch(() =>
notification.error({ notification.error({
@@ -62,12 +103,30 @@ const AddProfile = () => {
); );
}; };
const handleFetchMoreProfiles = (e, key) => {
if (key === 'radius') fetchMoreProfiles(e, radiusProfiles, fetchMoreRadiusProfiles);
else if (key === 'captive_portal')
fetchMoreProfiles(e, captiveProfiles, fetchMoreCaptiveProfiles);
else if (key === 'rf') fetchMoreProfiles(e, rfProfiles, fetchMoreRfProfiles);
else if (key === 'passpoint_venue') fetchMoreProfiles(e, venueProfiles, fetchMoreVenueProfiles);
else if (key === 'passpoint_operator')
fetchMoreProfiles(e, operatorProfiles, fetchMoreOperatorProfiles);
else if (key === 'passpoint_osu_id_provider')
fetchMoreProfiles(e, idProviderProfiles, fetchMoreIdProviderProfiles);
else fetchMoreProfiles(e, ssidProfiles, fetchMore);
};
return ( return (
<AddProfilePage <AddProfilePage
onCreateProfile={handleAddProfile} onCreateProfile={handleAddProfile}
ssidProfiles={ ssidProfiles={ssidProfiles?.getAllProfiles?.items}
(ssidProfiles && ssidProfiles.getAllProfiles && ssidProfiles.getAllProfiles.items) || [] radiusProfiles={radiusProfiles?.getAllProfiles?.items}
} captiveProfiles={captiveProfiles?.getAllProfiles?.items}
venueProfiles={venueProfiles?.getAllProfiles?.items}
operatorProfiles={operatorProfiles?.getAllProfiles?.items}
idProviderProfiles={idProviderProfiles?.getAllProfiles?.items}
rfProfiles={rfProfiles?.getAllProfiles?.items}
onFetchMoreProfiles={handleFetchMoreProfiles}
/> />
); );
}; };

View File

@@ -1,14 +1,13 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import gql from 'graphql-tag'; import { useQuery, gql } from '@apollo/client';
import { useQuery } from '@apollo/react-hooks';
import { Alert, notification } from 'antd'; import { Alert, notification } from 'antd';
import { Alarms as AlarmsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { Alarms as AlarmsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
const GET_ALL_ALARMS = gql` const GET_ALL_ALARMS = gql`
query GetAllAlarms($customerId: ID!, $cursor: String) { query GetAllAlarms($customerId: ID!, $context: JSONObject) {
getAllAlarms(customerId: $customerId, cursor: $cursor) { getAllAlarms(customerId: $customerId, context: $context) {
items { items {
severity severity
alarmCode alarmCode
@@ -19,10 +18,7 @@ const GET_ALL_ALARMS = gql`
name name
} }
} }
context { context
cursor
lastPage
}
} }
} }
`; `;
@@ -53,7 +49,7 @@ const Alarms = () => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!data.getAllAlarms.context.lastPage) { if (!data.getAllAlarms.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: data.getAllAlarms.context.cursor }, variables: { context: data.getAllAlarms.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.getAllAlarms; const previousEntry = previousResult.getAllAlarms;
const newItems = fetchMoreResult.getAllAlarms.items; const newItems = fetchMoreResult.getAllAlarms.items;

View File

@@ -2,12 +2,12 @@ import React, { useState } from 'react';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { Switch, Redirect } from 'react-router-dom'; import { Switch, Redirect } from 'react-router-dom';
import { ThemeProvider } from '@tip-wlan/wlan-cloud-ui-library'; import { ThemeProvider, GenericNotFound } from '@tip-wlan/wlan-cloud-ui-library';
import logo from 'images/tip-logo.png'; import logo from 'images/tip-logo.png';
import logoMobile from 'images/tip-logo-mobile.png'; import logoMobile from 'images/tip-logo-mobile.png';
import { AUTH_TOKEN, COMPANY } from 'constants/index'; import { AUTH_TOKEN, COMPANY, ROUTES, USER_FRIENDLY_RADIOS } from 'constants/index';
import Login from 'containers/Login'; import Login from 'containers/Login';
import Network from 'containers/Network'; import Network from 'containers/Network';
@@ -32,7 +32,7 @@ import ProtectedRouteWithLayout from './components/ProtectedRouteWithLayout';
const RedirectToDashboard = () => ( const RedirectToDashboard = () => (
<Redirect <Redirect
to={{ to={{
pathname: '/dashboard', pathname: ROUTES.dashboard,
}} }}
/> />
); );
@@ -42,7 +42,7 @@ const App = () => {
let initialUser = {}; let initialUser = {};
if (token) { if (token) {
const { userId, userName, userRole, customerId } = parseJwt(token.access_token); const { userId, userName, userRole, customerId } = parseJwt(token.access_token);
initialUser = { id: userId, email: userName, role: userRole, customerId }; initialUser = { id: userId, email: userName, roles: userRole, customerId };
} }
const [user, setUser] = useState(initialUser); const [user, setUser] = useState(initialUser);
@@ -50,7 +50,7 @@ const App = () => {
setItem(AUTH_TOKEN, newToken); setItem(AUTH_TOKEN, newToken);
if (newToken) { if (newToken) {
const { userId, userName, userRole, customerId } = parseJwt(newToken.access_token); const { userId, userName, userRole, customerId } = parseJwt(newToken.access_token);
setUser({ id: userId, email: userName, role: userRole, customerId }); setUser({ id: userId, email: userName, roles: userRole, customerId });
} }
}; };
@@ -60,32 +60,45 @@ const App = () => {
<UserProvider <UserProvider
id={user.id} id={user.id}
email={user.email} email={user.email}
role={user.role} roles={user.roles}
customerId={user.customerId} customerId={user.customerId}
updateUser={updateUser} updateUser={updateUser}
updateToken={updateToken} updateToken={updateToken}
> >
<ThemeProvider company={COMPANY} logo={logo} logoMobile={logoMobile}> <ThemeProvider
company={COMPANY}
logo={logo}
logoMobile={logoMobile}
routes={ROUTES}
radioTypes={USER_FRIENDLY_RADIOS}
>
<Helmet titleTemplate={`%s - ${COMPANY}`} defaultTitle={COMPANY}> <Helmet titleTemplate={`%s - ${COMPANY}`} defaultTitle={COMPANY}>
<meta name="description" content={COMPANY} /> <meta name="description" content={COMPANY} />
</Helmet> </Helmet>
<Switch> <Switch>
<UnauthenticatedRoute exact path="/login" component={Login} /> <UnauthenticatedRoute exact path={ROUTES.login} component={Login} />
<ProtectedRouteWithLayout exact path="/" component={RedirectToDashboard} /> <ProtectedRouteWithLayout exact path={ROUTES.root} component={RedirectToDashboard} />
<ProtectedRouteWithLayout exact path="/dashboard" component={Dashboard} /> <ProtectedRouteWithLayout exact path={ROUTES.dashboard} component={Dashboard} />
<ProtectedRouteWithLayout path="/network" component={Network} /> <ProtectedRouteWithLayout path={ROUTES.network} component={Network} />
<ProtectedRouteWithLayout path="/system" component={System} /> <ProtectedRouteWithLayout path={ROUTES.system} component={System} />
<ProtectedRouteWithLayout exact path="/profiles" component={Profiles} /> <ProtectedRouteWithLayout exact path={ROUTES.profiles} component={Profiles} />
<ProtectedRouteWithLayout exact path="/profiles/:id" component={ProfileDetails} /> <ProtectedRouteWithLayout
<ProtectedRouteWithLayout exact path="/addprofile" component={AddProfile} /> exact
path={`${ROUTES.profiles}/:id`}
component={ProfileDetails}
/>
<ProtectedRouteWithLayout exact path={ROUTES.addprofile} component={AddProfile} />
<ProtectedRouteWithLayout exact path="/alarms" component={Alarms} /> <ProtectedRouteWithLayout exact path={ROUTES.alarms} component={Alarms} />
<ProtectedRouteWithLayout exact path="/account/edit" component={EditAccount} /> {user?.id !== 0 && (
{user.role === 'SuperUser' && ( <ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} />
<ProtectedRouteWithLayout exact path="/accounts" component={Accounts} />
)} )}
{user?.roles?.[0] === 'SuperUser' && (
<ProtectedRouteWithLayout exact path={ROUTES.users} component={Accounts} />
)}
<ProtectedRouteWithLayout component={GenericNotFound} />
</Switch> </Switch>
</ThemeProvider> </ThemeProvider>
</UserProvider> </UserProvider>

View File

@@ -1,10 +1,11 @@
import React, { useContext, useEffect, useMemo, useState, useRef } from 'react'; import React, { useContext, useEffect, useMemo, useState, useRef } from 'react';
import { Alert } from 'antd'; import { Alert } from 'antd';
import moment from 'moment'; import moment from 'moment';
import { useQuery } from '@apollo/react-hooks'; import { useQuery } from '@apollo/client';
import { Dashboard as DashboardPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { Dashboard as DashboardPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import { FILTER_SYSTEM_EVENTS, GET_ALL_STATUS } from 'graphql/queries'; import { FILTER_SYSTEM_EVENTS, GET_ALL_STATUS } from 'graphql/queries';
import { USER_FRIENDLY_RADIOS } from 'constants/index';
function formatBytes(bytes, decimals = 2) { function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes'; if (bytes === 0) return '0 Bytes';
@@ -13,14 +14,17 @@ function formatBytes(bytes, decimals = 2) {
const dm = decimals < 0 ? 0 : decimals; const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 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 // eslint-disable-next-line no-restricted-properties
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i] || ''}`; return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i] || ''}`;
} }
function trafficLabelFormatter() { function trafficLabelFormatter(bytes) {
return formatBytes(this.value); if (this?.value) {
return formatBytes(this.value);
}
return formatBytes(bytes);
} }
function trafficTooltipFormatter() { function trafficTooltipFormatter() {
@@ -29,15 +33,8 @@ function trafficTooltipFormatter() {
)}</b><br/>`; )}</b><br/>`;
} }
const USER_FRIENDLY_RADIOS = {
is2dot4GHz: '2.4GHz',
is5GHzL: '5GHz (L)',
is5GHzU: '5GHz (U)',
is5GHz: '5GHz',
};
const lineChartConfig = [ const lineChartConfig = [
{ key: 'inservicesAPs', title: 'Inservice APs (24 hours)' }, { key: 'service', title: 'Inservice APs (24 hours)' },
{ key: 'clientDevices', title: 'Client Devices (24 hours)' }, { key: 'clientDevices', title: 'Client Devices (24 hours)' },
{ {
key: 'traffic', key: 'traffic',
@@ -62,9 +59,11 @@ const Dashboard = () => {
}); });
const [lineChartData, setLineChartData] = useState({ const [lineChartData, setLineChartData] = useState({
inservicesAPs: { service: {
key: 'Inservice APs', inservicesAPs: {
value: [], key: 'Inservice APs',
value: [],
},
}, },
clientDevices: { clientDevices: {
is2dot4GHz: { is2dot4GHz: {
@@ -110,6 +109,8 @@ const Dashboard = () => {
const clientDevices5GHz = []; const clientDevices5GHz = [];
const trafficBytesDownstreamData = []; const trafficBytesDownstreamData = [];
const trafficBytesUpstreamData = []; const trafficBytesUpstreamData = [];
let totalDown = 0;
let totalUp = 0;
list.forEach( list.forEach(
({ ({
@@ -125,23 +126,35 @@ const Dashboard = () => {
}, },
}, },
}) => { }) => {
inservicesAPs.push([eventTimestamp, equipmentInServiceCount]); const timestamp = parseInt(eventTimestamp, 10);
inservicesAPs.push({ timestamp, value: equipmentInServiceCount });
let total5GHz = 0; let total5GHz = 0;
total5GHz += (radios?.is5GHz || 0) + (radios?.is5GHzL || 0) + (radios?.is5GHzU || 0); // combine all 5GHz radios total5GHz += (radios?.is5GHz || 0) + (radios?.is5GHzL || 0) + (radios?.is5GHzU || 0); // combine all 5GHz radios
clientDevices2dot4GHz.push([eventTimestamp, radios.is2dot4GHz || 0]); clientDevices2dot4GHz.push({ timestamp, value: radios.is2dot4GHz || 0 });
clientDevices5GHz.push([eventTimestamp, total5GHz]); clientDevices5GHz.push({ timestamp, value: total5GHz || 0 });
trafficBytesDownstreamData.push([eventTimestamp, trafficBytesDownstream]); trafficBytesDownstreamData.push({
trafficBytesUpstreamData.push([eventTimestamp, trafficBytesUpstream]); timestamp,
value: (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0,
});
trafficBytesUpstreamData.push({
timestamp,
value: (trafficBytesUpstream > 0 && trafficBytesUpstream) || 0,
});
totalDown += (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0;
totalUp += (trafficBytesUpstream > 0 && trafficBytesUpstream) || 0;
} }
); );
return { return {
inservicesAPs: { service: {
...prev.inservicesAPs, inservicesAPs: {
value: [...prev.inservicesAPs.value, ...inservicesAPs], ...prev.service.inservicesAPs,
value: [...prev.service.inservicesAPs.value, ...inservicesAPs],
},
}, },
clientDevices: { clientDevices: {
is2dot4GHz: { is2dot4GHz: {
@@ -163,6 +176,8 @@ const Dashboard = () => {
value: [...prev.traffic.trafficBytesUpstream.value, ...trafficBytesUpstreamData], value: [...prev.traffic.trafficBytesUpstream.value, ...trafficBytesUpstreamData],
}, },
}, },
totalDownstreamTraffic: totalDown,
totalUpstreamTraffic: totalUp,
}; };
}); });
} }
@@ -195,7 +210,7 @@ const Dashboard = () => {
formatLineChartData(metricsData?.filterSystemEvents?.items); formatLineChartData(metricsData?.filterSystemEvents?.items);
}, [metricsData]); }, [metricsData]);
const statsArr = useMemo(() => { const statsData = useMemo(() => {
const status = data?.getAllStatus?.items[0]?.detailsJSON || {}; const status = data?.getAllStatus?.items[0]?.detailsJSON || {};
const { const {
@@ -203,8 +218,6 @@ const Dashboard = () => {
totalProvisionedEquipment, totalProvisionedEquipment,
equipmentInServiceCount, equipmentInServiceCount,
equipmentWithClientsCount, equipmentWithClientsCount,
trafficBytesDownstream,
trafficBytesUpstream,
} = status; } = status;
const clientRadios = {}; const clientRadios = {};
@@ -224,24 +237,13 @@ const Dashboard = () => {
}); });
} }
return [ return {
{ totalProvisionedEquipment,
title: 'Access Point', equipmentInServiceCount,
'Total Provisioned': totalProvisionedEquipment, equipmentWithClientsCount,
'In Service': equipmentInServiceCount, totalAssociated,
'With Clients': equipmentWithClientsCount, clientRadios,
}, };
{
title: 'Client Devices',
'Total Associated': totalAssociated,
...clientRadios,
},
{
title: 'Usage Information',
'Total Traffic (US)': formatBytes(trafficBytesUpstream),
'Total Traffic (DS)': formatBytes(trafficBytesDownstream),
},
];
}, [data]); }, [data]);
const pieChartsData = useMemo(() => { const pieChartsData = useMemo(() => {
@@ -263,7 +265,24 @@ const Dashboard = () => {
return ( return (
<DashboardPage <DashboardPage
statsCardDetails={statsArr} 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} pieChartDetails={pieChartsData}
lineChartData={lineChartData} lineChartData={lineChartData}
lineChartConfig={lineChartConfig} lineChartConfig={lineChartConfig}

View File

@@ -1,6 +1,5 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import gql from 'graphql-tag'; import { useMutation, useQuery, gql } from '@apollo/client';
import { useMutation, useQuery } from '@apollo/react-hooks';
import { notification, Alert } from 'antd'; import { notification, Alert } from 'antd';
import { EditAccount as EditAccountPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { EditAccount as EditAccountPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
@@ -11,7 +10,7 @@ const GET_USER = gql`
getUser(id: $id) { getUser(id: $id) {
id id
username username
role roles
customerId customerId
lastModifiedTimestamp lastModifiedTimestamp
} }
@@ -23,7 +22,7 @@ const UPDATE_USER = gql`
$id: ID! $id: ID!
$username: String! $username: String!
$password: String! $password: String!
$role: String! $roles: [String]
$customerId: ID! $customerId: ID!
$lastModifiedTimestamp: String $lastModifiedTimestamp: String
) { ) {
@@ -31,13 +30,13 @@ const UPDATE_USER = gql`
id: $id id: $id
username: $username username: $username
password: $password password: $password
role: $role roles: $roles
customerId: $customerId customerId: $customerId
lastModifiedTimestamp: $lastModifiedTimestamp lastModifiedTimestamp: $lastModifiedTimestamp
) { ) {
id id
username username
role roles
customerId customerId
lastModifiedTimestamp lastModifiedTimestamp
} }
@@ -50,14 +49,14 @@ const EditAccount = () => {
const [updateUser] = useMutation(UPDATE_USER); const [updateUser] = useMutation(UPDATE_USER);
const handleSubmit = newPassword => { const handleSubmit = newPassword => {
const { role, customerId, lastModifiedTimestamp } = data.getUser; const { roles, customerId, lastModifiedTimestamp } = data.getUser;
updateUser({ updateUser({
variables: { variables: {
id, id,
username: email, username: email,
password: newPassword, password: newPassword,
role, roles,
customerId, customerId,
lastModifiedTimestamp, lastModifiedTimestamp,
}, },

View File

@@ -1,6 +1,5 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import gql from 'graphql-tag'; import { useMutation, useApolloClient, gql } from '@apollo/client';
import { useMutation, useApolloClient } from '@apollo/react-hooks';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { notification } from 'antd'; import { notification } from 'antd';
@@ -27,9 +26,10 @@ const Login = () => {
const handleLogin = (email, password) => { const handleLogin = (email, password) => {
authenticateUser({ variables: { email, password } }) authenticateUser({ variables: { email, password } })
.then(({ data }) => { .then(({ data }) => {
client.resetStore(); client.resetStore().then(() => {
updateToken(data.authenticateUser); updateToken(data.authenticateUser);
history.push('/'); history.push('/');
});
}) })
.catch(() => .catch(() =>
notification.error({ notification.error({

View File

@@ -1,19 +1,19 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useLocation } from 'react-router-dom'; 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 { AppLayout as Layout } from '@tip-wlan/wlan-cloud-ui-library';
import { GET_ALARM_COUNT } from 'graphql/queries'; import { GET_ALARM_COUNT } from 'graphql/queries';
import { AUTH_TOKEN } from 'constants/index'; import { AUTH_TOKEN, ROUTES } from 'constants/index';
import { removeItem } from 'utils/localStorage'; import { removeItem } from 'utils/localStorage';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
const MasterLayout = ({ children }) => { const MasterLayout = ({ children }) => {
const { role, customerId } = useContext(UserContext); const { roles, customerId, id: currentUserId } = useContext(UserContext);
const client = useApolloClient(); const client = useApolloClient();
const location = useLocation(); const location = useLocation();
@@ -30,75 +30,60 @@ const MasterLayout = ({ children }) => {
const menuItems = [ const menuItems = [
{ {
key: 'dashboard', key: 'dashboard',
path: '/dashboard', path: ROUTES.dashboard,
text: 'Dashboard', text: 'Dashboard',
}, },
{ {
key: 'network', key: 'network',
path: '/network', path: ROUTES.network,
text: 'Network', text: 'Network',
}, },
{ {
key: 'profiles', key: 'profiles',
path: '/profiles', path: ROUTES.profiles,
text: 'Profiles', text: 'Profiles',
}, },
{ {
key: 'system', key: 'system',
path: '/system', path: ROUTES.system,
text: 'System', text: 'System',
}, },
]; ];
const mobileMenuItems = [ const mobileMenuItems = [
{ ...menuItems,
key: 'dashboard',
path: '/dashboard',
text: 'Dashboard',
},
{
key: 'network',
path: '/network',
text: 'Network',
},
{
key: 'profiles',
path: '/profiles',
text: 'Profiles',
},
{
key: 'system',
path: '/system',
text: 'System',
},
{ {
key: 'settings', key: 'settings',
text: 'Settings', text: 'Settings',
children: [ children: [
{ ...(currentUserId !== 0
key: 'editAccount', ? [
path: '/account/edit', {
text: 'Edit Account', key: 'editAccount',
}, path: ROUTES.account,
text: 'Edit Account',
},
]
: []),
{ {
key: 'logout', key: 'logout',
path: '/', path: ROUTES.root,
text: 'Log Out', text: 'Log Out',
}, },
], ],
}, },
]; ];
if (role === 'SuperUser') { if (roles?.[0] === 'SuperUser') {
menuItems.push({ menuItems.push({
key: 'accounts', key: 'users',
path: '/accounts', path: ROUTES.users,
text: 'Accounts', text: 'Users',
}); });
mobileMenuItems.push({ mobileMenuItems.push({
key: 'accounts', key: 'users',
path: '/accounts', path: ROUTES.users,
text: 'Accounts', text: 'Users',
}); });
} }
@@ -109,6 +94,7 @@ const MasterLayout = ({ children }) => {
menuItems={menuItems} menuItems={menuItems}
mobileMenuItems={mobileMenuItems} mobileMenuItems={mobileMenuItems}
totalAlarms={data && data.getAlarmCount} totalAlarms={data && data.getAlarmCount}
currentUserId={currentUserId}
> >
{children} {children}
</Layout> </Layout>

View File

@@ -1,177 +1,77 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useParams } from 'react-router-dom'; import { useParams, useHistory } from 'react-router-dom';
import gql from 'graphql-tag'; import { useQuery, useMutation } from '@apollo/client';
import { useQuery, useMutation } from '@apollo/react-hooks'; import { Alert, notification } from 'antd';
import { Alert, Spin, notification } from 'antd';
import moment from 'moment'; import moment from 'moment';
import { AccessPointDetails as AccessPointDetailsPage } from '@tip-wlan/wlan-cloud-ui-library'; import {
AccessPointDetails as AccessPointDetailsPage,
Loading,
} from '@tip-wlan/wlan-cloud-ui-library';
import { FILTER_SERVICE_METRICS } from 'graphql/queries'; import {
import { UPDATE_EQUIPMENT_FIRMWARE } from 'graphql/mutations'; GET_EQUIPMENT,
FILTER_SERVICE_METRICS,
GET_ALL_FIRMWARE,
GET_ALL_PROFILES,
} from 'graphql/queries';
import {
UPDATE_EQUIPMENT,
DELETE_EQUIPMENT,
UPDATE_EQUIPMENT_FIRMWARE,
REQUEST_EQUIPMENT_SWITCH_BANK,
REQUEST_EQUIPMENT_REBOOT,
} from 'graphql/mutations';
import { fetchMoreProfiles } from 'graphql/functions';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
const GET_EQUIPMENT = gql`
query GetEquipment($id: ID!) {
getEquipment(id: $id) {
id
equipmentType
inventoryId
customerId
profileId
locationId
name
latitude
longitude
serial
lastModifiedTimestamp
details
profile {
name
childProfiles {
id
name
details
}
}
status {
firmware {
detailsJSON
}
protocol {
detailsJSON
details {
reportedMacAddr
manufacturer
}
}
radioUtilization {
detailsJSON
}
clientDetails {
detailsJSON
details {
numClientsPerRadio
}
}
osPerformance {
detailsJSON
}
}
model
alarmsCount
alarms {
severity
alarmCode
details
createdTimestamp
}
}
}
`;
export const GET_ALL_FIRMWARE = gql`
query GetAllFirmware {
getAllFirmware {
id
modelId
versionName
description
filename
commit
releaseDate
}
}
`;
const UPDATE_EQUIPMENT = gql`
mutation UpdateEquipment(
$id: ID!
$equipmentType: String!
$inventoryId: String!
$customerId: ID!
$profileId: ID!
$locationId: ID!
$name: String!
$latitude: String
$longitude: String
$serial: String
$lastModifiedTimestamp: String
$details: JSONObject
) {
updateEquipment(
id: $id
equipmentType: $equipmentType
inventoryId: $inventoryId
customerId: $customerId
profileId: $profileId
locationId: $locationId
name: $name
latitude: $latitude
longitude: $longitude
serial: $serial
lastModifiedTimestamp: $lastModifiedTimestamp
details: $details
) {
id
equipmentType
inventoryId
customerId
profileId
locationId
name
latitude
longitude
serial
lastModifiedTimestamp
details
}
}
`;
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 toTime = moment();
const fromTime = moment().subtract(1, 'hour'); const fromTime = moment().subtract(1, 'hour');
const AccessPointDetails = ({ locations }) => { const AccessPointDetails = ({ locations }) => {
const { id } = useParams(); const { id } = useParams();
const { customerId } = useContext(UserContext); const { customerId } = useContext(UserContext);
const history = useHistory();
const { loading, error, data, refetch } = useQuery(GET_EQUIPMENT, { const { loading, error, data, refetch } = useQuery(GET_EQUIPMENT, {
variables: { id }, variables: {
id,
},
fetchPolicy: 'network-only',
errorPolicy: 'all',
}); });
const { data: dataProfiles, error: errorProfiles, loading: landingProfiles } = useQuery(
GET_ALL_PROFILES, const { data: dataFirmware, error: errorFirmware, loading: loadingFirmware } = useQuery(
GET_ALL_FIRMWARE,
{ {
variables: { customerId, type: 'equipment_ap' }, skip: !data?.getEquipment?.model,
variables: { modelId: data?.getEquipment?.model },
errorPolicy: 'all',
} }
); );
const {
data: dataProfiles,
error: errorProfiles,
loading: loadingProfiles,
fetchMore,
} = useQuery(
GET_ALL_PROFILES(`
childProfiles {
id
name
details
}`),
{
variables: { customerId, type: 'equipment_ap' },
fetchPolicy: 'network-only',
}
);
const { const {
loading: metricsLoading, loading: metricsLoading,
error: metricsError, error: metricsError,
data: metricsData, data: metricsData,
refetch: metricsRefetch, fetchMore: fetchMoreServiceMetrics,
} = useQuery(FILTER_SERVICE_METRICS, { } = useQuery(FILTER_SERVICE_METRICS, {
variables: { variables: {
customerId, customerId,
@@ -185,30 +85,52 @@ const AccessPointDetails = ({ locations }) => {
const [updateEquipment] = useMutation(UPDATE_EQUIPMENT); const [updateEquipment] = useMutation(UPDATE_EQUIPMENT);
const [updateEquipmentFirmware] = useMutation(UPDATE_EQUIPMENT_FIRMWARE); const [updateEquipmentFirmware] = useMutation(UPDATE_EQUIPMENT_FIRMWARE);
const [requestEquipmentSwitchBank] = useMutation(REQUEST_EQUIPMENT_SWITCH_BANK);
const { data: dataFirmware, error: errorFirmware, loading: landingFirmware } = useQuery( const [requestEquipmentReboot] = useMutation(REQUEST_EQUIPMENT_REBOOT);
GET_ALL_FIRMWARE const [deleteEquipment] = useMutation(DELETE_EQUIPMENT);
);
const refetchData = () => { const refetchData = () => {
refetch(); refetch();
metricsRefetch(); fetchMoreServiceMetrics({
variables: {
fromTime: moment()
.subtract(2, 'minutes')
.valueOf()
.toString(),
toTime: moment()
.valueOf()
.toString(),
},
updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.filterServiceMetrics;
const newItems = fetchMoreResult.filterServiceMetrics.items;
return {
filterServiceMetrics: {
context: fetchMoreResult.filterServiceMetrics.context,
items: [...previousEntry.items, ...newItems],
__typename: previousEntry.__typename,
},
};
},
});
}; };
const handleUpdateEquipment = ( const handleUpdateEquipment = ({
equipmentId, id: equipmentId,
equipmentType, equipmentType,
inventoryId, inventoryId,
custId, customerId: custId,
profileId, profileId,
locationId, locationId,
name, name,
baseMacAddress,
latitude, latitude,
longitude, longitude,
serial, serial,
lastModifiedTimestamp, lastModifiedTimestamp,
details formattedData,
) => { }) => {
updateEquipment({ updateEquipment({
variables: { variables: {
id: equipmentId, id: equipmentId,
@@ -218,11 +140,12 @@ const AccessPointDetails = ({ locations }) => {
profileId, profileId,
locationId, locationId,
name, name,
baseMacAddress,
latitude, latitude,
longitude, longitude,
serial, serial,
lastModifiedTimestamp, lastModifiedTimestamp,
details, details: formattedData,
}, },
}) })
.then(() => { .then(() => {
@@ -240,19 +163,38 @@ const AccessPointDetails = ({ locations }) => {
); );
}; };
const handleDeleteEquipment = () => {
deleteEquipment({
variables: { id },
})
.then(() => {
history.push('/network/access-points');
notification.success({
message: 'Success',
description: 'Equipment successfully deleted',
});
})
.catch(() =>
notification.error({
message: 'Error',
description: 'Equipment could not be deleted.',
})
);
};
const handleUpdateEquipmentFirmware = (equipmentId, firmwareVersionId) => const handleUpdateEquipmentFirmware = (equipmentId, firmwareVersionId) =>
updateEquipmentFirmware({ variables: { equipmentId, firmwareVersionId } }) updateEquipmentFirmware({ variables: { equipmentId, firmwareVersionId } })
.then(firmwareResp => { .then(firmwareResp => {
if (firmwareResp && firmwareResp.updateEquipmentFirmware.success === false) { if (firmwareResp?.data?.updateEquipmentFirmware?.success === true) {
notification.error({
message: 'Error',
description: 'Equipment Firmware Upgrade could not be updated.',
});
} else {
notification.success({ notification.success({
message: 'Success', message: 'Success',
description: 'Equipment Firmware Upgrade in progress', description: 'Equipment Firmware Upgrade in progress',
}); });
} else {
notification.error({
message: 'Error',
description: 'Equipment Firmware Upgrade could not be updated.',
});
} }
}) })
.catch(() => .catch(() =>
@@ -262,11 +204,59 @@ const AccessPointDetails = ({ locations }) => {
}) })
); );
if (loading || landingProfiles || landingFirmware) { const handleRequestEquipmentSwitchBank = equipmentId =>
return <Spin size="large" />; 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.',
})
);
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 => {
fetchMoreProfiles(e, dataProfiles, fetchMore);
};
if (loading) {
return <Loading />;
} }
if (error) { if (error && !data?.getEquipment) {
return ( return (
<Alert <Alert
message="Error" message="Error"
@@ -277,42 +267,29 @@ const AccessPointDetails = ({ locations }) => {
); );
} }
if (errorProfiles) {
return (
<Alert
message="Error"
description="Failed to load Access Point profiles."
type="error"
showIcon
/>
);
}
if (errorFirmware) {
return (
<Alert
message="Error"
description="Failed to load Access Point firmware."
type="error"
showIcon
/>
);
}
return ( return (
<AccessPointDetailsPage <AccessPointDetailsPage
handleRefresh={refetchData} handleRefresh={refetchData}
onUpdateEquipment={handleUpdateEquipment} onUpdateEquipment={handleUpdateEquipment}
data={data.getEquipment} onDeleteEquipment={handleDeleteEquipment}
profiles={dataProfiles.getAllProfiles.items} data={data?.getEquipment}
profiles={dataProfiles?.getAllProfiles?.items}
osData={{ osData={{
loading: metricsLoading, loading: metricsLoading,
error: metricsError, error: metricsError,
data: metricsData && metricsData.filterServiceMetrics.items, data: metricsData && metricsData.filterServiceMetrics.items,
}} }}
firmware={dataFirmware.getAllFirmware} firmware={dataFirmware?.getAllFirmware}
locations={locations} locations={locations}
onUpdateEquipmentFirmware={handleUpdateEquipmentFirmware} onUpdateEquipmentFirmware={handleUpdateEquipmentFirmware}
onRequestEquipmentSwitchBank={handleRequestEquipmentSwitchBank}
onRequestEquipmentReboot={handleRequestEquipmentReboot}
loadingProfiles={loadingProfiles}
errorProfiles={errorProfiles}
loadingFirmware={loadingFirmware}
errorFirmware={errorFirmware}
onFetchMoreProfiles={handleFetchProfiles}
isLastProfilesPage={dataProfiles?.getAllProfiles?.context?.lastPage}
/> />
); );
}; };

View File

@@ -1,28 +1,32 @@
import React, { useEffect, useContext } from 'react'; import React, { useEffect, useContext } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import moment from 'moment'; import moment from 'moment';
import { useLazyQuery } from '@apollo/react-hooks'; import { useLazyQuery } from '@apollo/client';
import { Alert } from 'antd'; import { notification } from 'antd';
import { floor, padStart } from 'lodash'; import { floor, padStart } from 'lodash';
import { NetworkTable, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { NetworkTableContainer } from '@tip-wlan/wlan-cloud-ui-library';
import { ROUTES } from 'constants/index';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import { FILTER_EQUIPMENT } from 'graphql/queries'; import { FILTER_EQUIPMENT } from 'graphql/queries';
import styles from './index.module.scss'; import styles from './index.module.scss';
const renderTableCell = tabCell => { const renderTableCell = (text, _record, _index, defaultValue = 'N/A') => {
if (Array.isArray(tabCell)) { if (Array.isArray(text)) {
if (text.length < 1) {
return defaultValue;
}
return ( return (
<div className={styles.tabColumn}> <div className={styles.tabColumn}>
{tabCell.map((i, key) => ( {text.map((i, key) => (
// eslint-disable-next-line react/no-array-index-key // eslint-disable-next-line react/no-array-index-key
<span key={key}>{i}</span> <span key={key}>{i}</span>
))} ))}
</div> </div>
); );
} }
return tabCell; return text !== null ? text : defaultValue;
}; };
const durationToString = duration => const durationToString = duration =>
@@ -55,12 +59,17 @@ const accessPointsTableColumns = [
}, },
{ {
title: 'MAC', title: 'MAC',
dataIndex: ['status', 'protocol', 'details', 'reportedMacAddr'], dataIndex: 'baseMacAddress',
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'MANUFACTURER', title: 'MANUFACTURER',
dataIndex: ['status', 'protocol', 'details', 'manufacturer'], dataIndex: 'manufacturer',
render: renderTableCell,
},
{
title: 'FIRMWARE',
dataIndex: ['status', 'firmware', 'detailsJSON', 'activeSwVersion'],
render: renderTableCell, render: renderTableCell,
}, },
{ {
@@ -80,8 +89,8 @@ const accessPointsTableColumns = [
}, },
{ {
title: 'CHANNEL', title: 'CHANNEL',
dataIndex: 'channel', dataIndex: ['status', 'channel', 'detailsJSON', 'channelNumberStatusDataMap'],
render: renderTableCell, render: text => renderTableCell(Object.values(text ?? [])),
}, },
{ {
title: 'OCCUPANCY', title: 'OCCUPANCY',
@@ -96,23 +105,39 @@ const accessPointsTableColumns = [
{ {
title: 'DEVICES', title: 'DEVICES',
dataIndex: ['status', 'clientDetails', 'details', 'numClientsPerRadio'], dataIndex: ['status', 'clientDetails', 'details', 'numClientsPerRadio'],
render: renderTableCell, render: (text, record, index) => renderTableCell(text, record, index, 0),
}, },
]; ];
const AccessPoints = ({ checkedLocations }) => { const AccessPoints = ({ checkedLocations }) => {
const { customerId } = useContext(UserContext); const { customerId } = useContext(UserContext);
const [filterEquipment, { loading, error, data: equipData, fetchMore }] = useLazyQuery( const [filterEquipment, { loading, error, data: equipData, refetch, fetchMore }] = useLazyQuery(
FILTER_EQUIPMENT, FILTER_EQUIPMENT,
{ {
errorPolicy: 'all', 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 = () => { const handleLoadMore = () => {
if (!equipData.filterEquipment.context.lastPage) { if (!equipData.filterEquipment.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: equipData.filterEquipment.context.cursor }, variables: { context: equipData.filterEquipment.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.filterEquipment; const previousEntry = previousResult.filterEquipment;
const newItems = fetchMoreResult.filterEquipment.items; const newItems = fetchMoreResult.filterEquipment.items;
@@ -139,22 +164,18 @@ const AccessPoints = ({ checkedLocations }) => {
fetchFilterEquipment(); fetchFilterEquipment();
}, [checkedLocations]); }, [checkedLocations]);
if (loading) {
return <Loading />;
}
if (error && !equipData?.filterEquipment?.items) {
return <Alert message="Error" description="Failed to load equipment." type="error" showIcon />;
}
return ( return (
<NetworkTable <NetworkTableContainer
activeTab={ROUTES.accessPoints}
onRefresh={handleOnRefresh}
tableColumns={accessPointsTableColumns} tableColumns={accessPointsTableColumns}
tableData={equipData && equipData.filterEquipment && equipData.filterEquipment.items} tableData={equipData && equipData.filterEquipment && equipData.filterEquipment.items}
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
isLastPage={ isLastPage={
equipData && equipData.filterEquipment && equipData.filterEquipment.context.lastPage equipData && equipData.filterEquipment && equipData.filterEquipment.context.lastPage
} }
loading={loading}
error={error && !equipData?.filterEquipment?.items && 'Failed to load equipment.'}
/> />
); );
}; };

View File

@@ -1,5 +1,4 @@
.tabColumn { .tabColumn {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 0 30px;
} }

View File

@@ -2,7 +2,7 @@ import React, { useContext, useMemo } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Alert, notification } from 'antd'; import { Alert, notification } from 'antd';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import { useQuery, useMutation } from '@apollo/react-hooks'; import { useQuery, useMutation } from '@apollo/client';
import { BulkEditAccessPoints, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { BulkEditAccessPoints, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import { FILTER_EQUIPMENT_BULK_EDIT_APS } from 'graphql/queries'; import { FILTER_EQUIPMENT_BULK_EDIT_APS } from 'graphql/queries';
@@ -11,6 +11,8 @@ import { UPDATE_EQUIPMENT_BULK } from 'graphql/mutations';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import styles from './index.module.scss'; import styles from './index.module.scss';
const defaultAppliedRadios = { is5GHzL: 'is5GHzL', is2dot4GHz: 'is2dot4GHz', is5GHzU: 'is5GHzU' };
const renderTableCell = tabCell => { const renderTableCell = tabCell => {
if (Array.isArray(tabCell)) { if (Array.isArray(tabCell)) {
return ( return (
@@ -25,47 +27,63 @@ const renderTableCell = tabCell => {
return <span>{tabCell}</span>; return <span>{tabCell}</span>;
}; };
const accessPointsChannelTableColumns = [ const accessPointsChannelTableColumns = [
{ title: 'NAME', dataIndex: 'name', key: 'name', render: renderTableCell }, { title: 'Name', dataIndex: 'name', key: 'name', width: 250, render: renderTableCell },
{ {
title: 'CHANNEL', title: 'Manual Active Channel',
dataIndex: 'channel', dataIndex: 'manualChannelNumber',
key: 'channel', key: 'manualChannelNumber',
editable: true, editable: true,
width: 200,
render: renderTableCell,
},
{
title: 'Manual Backup Channel',
dataIndex: 'manualBackupChannelNumber',
key: 'manualBackupChannelNumber',
editable: true,
width: 210,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'CELL SIZE', title: 'Cell Size',
dataIndex: 'cellSize', dataIndex: 'cellSize',
key: 'cellSize', key: 'cellSize',
editable: true, editable: true,
width: 150,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'PROB RESPONSE THRESHOLD', title: 'Probe Response Threshold',
dataIndex: 'probeResponseThreshold', dataIndex: 'probeResponseThreshold',
key: 'probeResponseThreshold', key: 'probeResponseThreshold',
editable: true, editable: true,
width: 210,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'CLIENT DISCONNECT THRESHOLD', title: 'Client Disconnect Threshold',
dataIndex: 'clientDisconnectThreshold', dataIndex: 'clientDisconnectThreshold',
key: 'clientDisconnectThreshold', key: 'clientDisconnectThreshold',
editable: true, editable: true,
width: 210,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'SNR (% DROP)', title: 'SNR (% Drop)',
dataIndex: 'snrDrop', dataIndex: 'snrDrop',
key: 'snrDrop', key: 'snrDrop',
editable: true, editable: true,
width: 150,
render: renderTableCell, render: renderTableCell,
}, },
{ {
title: 'MIN LOAD', title: 'Min Load',
dataIndex: 'minLoad', dataIndex: 'minLoad',
key: 'minLoad', key: 'minLoad',
editable: true, editable: true,
width: 150,
render: renderTableCell, render: renderTableCell,
}, },
]; ];
@@ -160,68 +178,84 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
const [updateEquipmentBulk] = useMutation(UPDATE_EQUIPMENT_BULK); const [updateEquipmentBulk] = useMutation(UPDATE_EQUIPMENT_BULK);
const getRadioDetails = (radioDetails, type) => { const getRadioDetails = (radioDetails, type) => {
if (type === 'manualChannelNumber') {
const manualChannelNumbers = [];
Object.keys(radioDetails?.radioMap || {}).map(i => {
return manualChannelNumbers.push(radioDetails.radioMap[i]?.manualChannelNumber);
});
return manualChannelNumbers;
}
if (type === 'manualBackupChannelNumber') {
const manualBackupChannelNumbers = [];
Object.keys(radioDetails?.radioMap || {}).map(i => {
return manualBackupChannelNumbers.push(radioDetails.radioMap[i]?.manualBackupChannelNumber);
});
return manualBackupChannelNumbers;
}
if (type === 'cellSize') { if (type === 'cellSize') {
const cellSizeValues = []; const cellSizeValues = [];
Object.keys(radioDetails.radioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return cellSizeValues.push(radioDetails.radioMap[i].rxCellSizeDb.value); return cellSizeValues.push(radioDetails.radioMap[i]?.rxCellSizeDb?.value);
}); });
return cellSizeValues; return cellSizeValues;
} }
if (type === 'probeResponseThreshold') { if (type === 'probeResponseThreshold') {
const probeResponseThresholdValues = []; const probeResponseThresholdValues = [];
Object.keys(radioDetails.radioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return probeResponseThresholdValues.push( return probeResponseThresholdValues.push(
radioDetails.radioMap[i].probeResponseThresholdDb.value radioDetails.radioMap[i]?.probeResponseThresholdDb?.value
); );
}); });
return probeResponseThresholdValues; return probeResponseThresholdValues;
} }
if (type === 'clientDisconnectThreshold') { if (type === 'clientDisconnectThreshold') {
const clientDisconnectThresholdValues = []; const clientDisconnectThresholdValues = [];
Object.keys(radioDetails.radioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return clientDisconnectThresholdValues.push( return clientDisconnectThresholdValues.push(
radioDetails.radioMap[i].clientDisconnectThresholdDb.value radioDetails.radioMap[i]?.clientDisconnectThresholdDb?.value
); );
}); });
return clientDisconnectThresholdValues; return clientDisconnectThresholdValues;
} }
if (type === 'snrDrop') { if (type === 'snrDrop') {
const snrDropValues = []; const snrDropValues = [];
Object.keys(radioDetails.advancedRadioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return snrDropValues.push( return snrDropValues.push(
radioDetails.advancedRadioMap[i].bestApSettings.dropInSnrPercentage radioDetails.advancedRadioMap[i]?.bestApSettings?.value?.dropInSnrPercentage
); );
}); });
return snrDropValues; return snrDropValues;
} }
const minLoadValue = []; const minLoadValue = [];
Object.keys(radioDetails.advancedRadioMap).map(i => { Object.keys(radioDetails?.radioMap || {}).map(i => {
return minLoadValue.push(radioDetails.advancedRadioMap[i].bestApSettings.minLoadFactor); return minLoadValue.push(
radioDetails.advancedRadioMap[i]?.bestApSettings?.value?.minLoadFactor
);
}); });
return minLoadValue; return minLoadValue;
}; };
const setAccessPointsBulkEditTableData = (dataSource = []) => { const setAccessPointsBulkEditTableData = (dataSource = []) =>
const tableData = dataSource.items.map(({ id: key, name, channel, details }) => { dataSource.items.map(({ id: key, name, details }) => ({
return { key,
key, id: key,
id: key, name,
name, manualChannelNumber: getRadioDetails(details, 'manualChannelNumber'),
channel, manualBackupChannelNumber: getRadioDetails(details, 'manualBackupChannelNumber'),
cellSize: getRadioDetails(details, 'cellSize'), cellSize: getRadioDetails(details, 'cellSize'),
probeResponseThreshold: getRadioDetails(details, 'probeResponseThreshold'), probeResponseThreshold: getRadioDetails(details, 'probeResponseThreshold'),
clientDisconnectThreshold: getRadioDetails(details, 'clientDisconnectThreshold'), clientDisconnectThreshold: getRadioDetails(details, 'clientDisconnectThreshold'),
snrDrop: getRadioDetails(details, 'snrDrop'), snrDrop: getRadioDetails(details, 'snrDrop'),
minLoad: getRadioDetails(details, 'minLoad'), minLoad: getRadioDetails(details, 'minLoad'),
}; radioMap: Object.keys(details?.radioMap || {}),
}); }));
return tableData;
};
const setUpdatedBulkEditTableData = ( const setUpdatedBulkEditTableData = (
equipmentId, equipmentId,
channel, manualChannelNumber,
manualBackupChannelNumber,
cellSize, cellSize,
probeResponseThreshold, probeResponseThreshold,
clientDisconnectThreshold, clientDisconnectThreshold,
@@ -234,13 +268,14 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
let minLoadFactor; let minLoadFactor;
dataSource.items.forEach(({ id: itemId, details }) => { dataSource.items.forEach(({ id: itemId, details }) => {
if (equipmentId === itemId) { if (equipmentId === itemId) {
Object.keys(details.radioMap).forEach((i, dataIndex) => { Object.keys(details?.radioMap || defaultAppliedRadios).forEach((i, dataIndex) => {
const frequencies = {}; const frequencies = {};
dropInSnrPercentage = snrDrop[dataIndex]; dropInSnrPercentage = snrDrop[dataIndex];
minLoadFactor = minLoad[dataIndex]; minLoadFactor = minLoad[dataIndex];
frequencies[`${i}`] = { frequencies[`${i}`] = {
channelNumber: channel[dataIndex], channelNumber: manualChannelNumber[dataIndex],
backupChannelNumber: manualBackupChannelNumber[dataIndex],
rxCellSizeDb: { rxCellSizeDb: {
auto: true, auto: true,
value: cellSize[dataIndex], value: cellSize[dataIndex],
@@ -286,48 +321,47 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
const handleSaveChanges = updatedRows => { const handleSaveChanges = updatedRows => {
const editedRowsArr = []; const editedRowsArr = [];
if (updatedRows.length > 0) { Object.keys(updatedRows).forEach(key => {
updatedRows.map( const {
({ id: equipmentId,
id: equipmentId, manualChannelNumber,
channel, manualBackupChannelNumber,
cellSize, cellSize,
probeResponseThreshold, probeResponseThreshold,
clientDisconnectThreshold, clientDisconnectThreshold,
snrDrop, snrDrop,
minLoad, minLoad,
}) => { } = updatedRows[key];
const updatedEuips = setUpdatedBulkEditTableData( const updatedEuips = setUpdatedBulkEditTableData(
equipmentId, equipmentId,
channel, manualChannelNumber,
cellSize, manualBackupChannelNumber,
probeResponseThreshold, cellSize,
clientDisconnectThreshold, probeResponseThreshold,
snrDrop, clientDisconnectThreshold,
minLoad, snrDrop,
equipData && equipData.filterEquipment minLoad,
); equipData && equipData.filterEquipment
const tempObj = {
equipmentId,
perRadioDetails: {},
};
updatedEuips.map(item => {
Object.keys(item).forEach(i => {
tempObj.perRadioDetails[i] = item[i];
});
return tempObj;
});
return editedRowsArr.push(tempObj);
}
); );
updateEquipments(editedRowsArr); const tempObj = {
} equipmentId,
perRadioDetails: {},
};
updatedEuips.map(item => {
Object.keys(item).forEach(i => {
tempObj.perRadioDetails[i] = item[i];
});
return tempObj;
});
return editedRowsArr.push(tempObj);
});
updateEquipments(editedRowsArr);
}; };
const handleLoadMore = () => { const handleLoadMore = () => {
if (!equipData.filterEquipment.context.lastPage) { if (!equipData.filterEquipment.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: equipData.filterEquipment.context.cursor }, variables: { context: equipData.filterEquipment.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.filterEquipment; const previousEntry = previousResult.filterEquipment;
const newItems = fetchMoreResult.filterEquipment.items; const newItems = fetchMoreResult.filterEquipment.items;
@@ -356,18 +390,9 @@ const BulkEditAPs = ({ locations, checkedLocations }) => {
return ( return (
<BulkEditAccessPoints <BulkEditAccessPoints
tableColumns={accessPointsChannelTableColumns} tableColumns={accessPointsChannelTableColumns}
tableData={ tableData={setAccessPointsBulkEditTableData(equipData?.filterEquipment)}
equipData &&
equipData.filterEquipment &&
setAccessPointsBulkEditTableData(equipData && equipData.filterEquipment)
}
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
isLastPage={ isLastPage={equipData?.filterEquipment?.context?.lastPage}
equipData &&
equipData.filterEquipment &&
equipData.filterEquipment.context &&
equipData.filterEquipment.context.lastPage
}
onSaveChanges={handleSaveChanges} onSaveChanges={handleSaveChanges}
breadcrumbPath={getBreadcrumbPath(id, locations)} breadcrumbPath={getBreadcrumbPath(id, locations)}
/> />

View File

@@ -1,5 +1,4 @@
.tabColumn { .tabColumn {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 0 30px;
} }

View File

@@ -1,6 +1,6 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import { useQuery } from '@apollo/react-hooks'; import { useQuery } from '@apollo/client';
import moment from 'moment'; import moment from 'moment';
import { Alert, notification } from 'antd'; import { Alert, notification } from 'antd';
import { import {

View File

@@ -1,9 +1,11 @@
import React, { useEffect, useContext } from 'react'; import React, { useEffect, useContext } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useLazyQuery } from '@apollo/react-hooks'; import { useLazyQuery } from '@apollo/client';
import { Alert } from 'antd'; import { notification } from 'antd';
import { NetworkTable, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import { NetworkTableContainer } from '@tip-wlan/wlan-cloud-ui-library';
import { ROUTES, USER_FRIENDLY_RADIOS } from 'constants/index';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import { FILTER_CLIENT_SESSIONS } from 'graphql/queries'; import { FILTER_CLIENT_SESSIONS } from 'graphql/queries';
@@ -21,14 +23,30 @@ const clientDevicesTableColumns = [
{ title: 'HOST NAME', dataIndex: 'hostname' }, { title: 'HOST NAME', dataIndex: 'hostname' },
{ title: 'ACCESS POINT', dataIndex: ['equipment', 'name'] }, { title: 'ACCESS POINT', dataIndex: ['equipment', 'name'] },
{ title: 'SSID', dataIndex: 'ssid' }, { title: 'SSID', dataIndex: 'ssid' },
{ title: 'BAND', dataIndex: 'radioType' }, {
title: 'BAND',
dataIndex: 'radioType',
render: band => USER_FRIENDLY_RADIOS[band],
},
{ title: 'SIGNAL', dataIndex: 'signal' }, { 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 ClientDevices = ({ checkedLocations }) => {
const { customerId } = useContext(UserContext); const { customerId } = useContext(UserContext);
const [filterClientSessions, { loading, error, data, fetchMore }] = useLazyQuery( const [filterClientSessions, { loading, error, data, refetch, fetchMore }] = useLazyQuery(
FILTER_CLIENT_SESSIONS, FILTER_CLIENT_SESSIONS,
{ {
errorPolicy: 'all', errorPolicy: 'all',
@@ -38,7 +56,7 @@ const ClientDevices = ({ checkedLocations }) => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!data.filterClientSessions.context.lastPage) { if (!data.filterClientSessions.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: data.filterClientSessions.context.cursor }, variables: { context: data.filterClientSessions.context },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const previousEntry = previousResult.filterClientSessions; const previousEntry = previousResult.filterClientSessions;
const newItems = fetchMoreResult.filterClientSessions.items; const newItems = fetchMoreResult.filterClientSessions.items;
@@ -61,26 +79,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(() => { useEffect(() => {
fetchFilterClientSessions(); fetchFilterClientSessions();
}, [checkedLocations]); }, [checkedLocations]);
if (loading) {
return <Loading />;
}
if (error && !data?.filterClientSessions?.items) {
return (
<Alert message="Error" description="Failed to load client devices." type="error" showIcon />
);
}
return ( return (
<NetworkTable <NetworkTableContainer
activeTab={ROUTES.clientDevices}
tableColumns={clientDevicesTableColumns} tableColumns={clientDevicesTableColumns}
tableData={data && data.filterClientSessions && data.filterClientSessions.items} tableData={data?.filterClientSessions?.items}
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
onRefresh={handleOnRefresh}
isLastPage={data && data.filterClientSessions && data.filterClientSessions.context.lastPage} isLastPage={data && data.filterClientSessions && data.filterClientSessions.context.lastPage}
loading={loading}
error={error && !data?.filterClientSessions?.items && 'Failed to load client devices.'}
/> />
); );
}; };

View File

@@ -1,6 +1,6 @@
import React, { useMemo, useContext, useState } from 'react'; import React, { useMemo, useContext, useState } from 'react';
import { useLocation, Switch, Route, useRouteMatch, Redirect } from 'react-router-dom'; import { Switch, Route, useRouteMatch, Redirect } from 'react-router-dom';
import { useQuery, useMutation, useLazyQuery } from '@apollo/react-hooks'; import { useQuery, useMutation, useLazyQuery } from '@apollo/client';
import { Alert, notification } from 'antd'; import { Alert, notification } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
import { Network as NetworkPage, PopoverMenu, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { Network as NetworkPage, PopoverMenu, Loading } from '@tip-wlan/wlan-cloud-ui-library';
@@ -12,23 +12,28 @@ import ClientDeviceDetails from 'containers/Network/containers/ClientDeviceDetai
import BulkEditAccessPoints from 'containers/Network/containers/BulkEditAccessPoints'; import BulkEditAccessPoints from 'containers/Network/containers/BulkEditAccessPoints';
import UserContext from 'contexts/UserContext'; 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 { import {
CREATE_LOCATION, CREATE_LOCATION,
UPDATE_LOCATION, UPDATE_LOCATION,
DELETE_LOCATION, DELETE_LOCATION,
CREATE_EQUIPMENT, CREATE_EQUIPMENT,
} from 'graphql/mutations'; } from 'graphql/mutations';
import { updateQueryGetAllProfiles } from 'graphql/functions';
const Network = () => { const Network = () => {
const { path } = useRouteMatch(); const { path } = useRouteMatch();
const { customerId } = useContext(UserContext); const { customerId } = useContext(UserContext);
const location = useLocation();
const { loading, error, refetch, data } = useQuery(GET_ALL_LOCATIONS, { const { loading, error, refetch, data } = useQuery(GET_ALL_LOCATIONS, {
variables: { customerId }, variables: { customerId },
}); });
const { loading: loadingProfile, error: errorProfile, data: apProfiles } = useQuery( const { loading: loadingProfile, error: errorProfile, data: apProfiles, fetchMore } = useQuery(
GET_ALL_PROFILES, GET_ALL_PROFILES(),
{ {
variables: { customerId, type: 'equipment_ap' }, variables: { customerId, type: 'equipment_ap' },
} }
@@ -38,13 +43,21 @@ const Network = () => {
const [createLocation] = useMutation(CREATE_LOCATION); const [createLocation] = useMutation(CREATE_LOCATION);
const [updateLocation] = useMutation(UPDATE_LOCATION); const [updateLocation] = useMutation(UPDATE_LOCATION);
const [deleteLocation] = useMutation(DELETE_LOCATION); const [deleteLocation] = useMutation(DELETE_LOCATION);
const [createEquipment] = useMutation(CREATE_EQUIPMENT);
const [checkedLocations, setCheckedLocations] = useState([]); const [checkedLocations, setCheckedLocations] = useState([]);
const [deleteModal, setDeleteModal] = useState(false); const [deleteModal, setDeleteModal] = useState(false);
const [editModal, setEditModal] = useState(false); const [editModal, setEditModal] = useState(false);
const [addModal, setAddModal] = useState(false); const [addModal, setAddModal] = useState(false);
const [apModal, setApModal] = 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 => { const handleGetSingleLocation = id => {
getLocation({ getLocation({
variables: { id }, variables: { id },
@@ -52,7 +65,7 @@ const Network = () => {
}; };
const formatLocationListForTree = (list = []) => { const formatLocationListForTree = (list = []) => {
const checkedTreeLocations = []; const checkedTreeLocations = ['0'];
list.forEach(ele => { list.forEach(ele => {
checkedTreeLocations.push(ele.id); checkedTreeLocations.push(ele.id);
}); });
@@ -92,26 +105,38 @@ const Network = () => {
return [ return [
{ {
title: ( title: (
<PopoverMenu locationType="NETWORK" setAddModal={setAddModal}> <PopoverMenu locationId="0" locationType="NETWORK" setAddModal={setAddModal}>
Network Network
</PopoverMenu> </PopoverMenu>
), ),
id: '0', id: '0',
value: '0',
key: '0', key: '0',
value: '0',
children: unflatten(list), children: unflatten(list),
}, },
]; ];
}; };
const handleAddLocation = (name, parentId, locationType) => { const handleAddLocation = ({ location }) => {
setAddModal(false); 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({ createLocation({
variables: { variables: {
locationType, locationType,
customerId, customerId,
parentId, parentId: id,
name, name: location,
}, },
}) })
.then(() => { .then(() => {
@@ -129,8 +154,10 @@ const Network = () => {
); );
}; };
const handleEditLocation = (id, parentId, name, locationType, lastModifiedTimestamp) => { const handleEditLocation = ({ name }) => {
setEditModal(false); setEditModal(false);
const { id, parentId, locationType, lastModifiedTimestamp } = selectedLocation.getLocation;
updateLocation({ updateLocation({
variables: { variables: {
customerId, customerId,
@@ -156,8 +183,10 @@ const Network = () => {
); );
}; };
const handleDeleteLocation = id => { const handleDeleteLocation = () => {
setDeleteModal(false); setDeleteModal(false);
const { id } = selectedLocation.getLocation;
deleteLocation({ variables: { id } }) deleteLocation({ variables: { id } })
.then(() => { .then(() => {
notification.success({ notification.success({
@@ -174,8 +203,10 @@ const Network = () => {
); );
}; };
const handleCreateEquipment = (inventoryId, locationId, name, profileId) => { const handleCreateEquipment = ({ inventoryId, name, profileId }) => {
setApModal(false); setApModal(false);
const { id: locationId } = selectedLocation.getLocation;
createEquipment({ variables: { customerId, inventoryId, locationId, name, profileId } }) createEquipment({ variables: { customerId, inventoryId, locationId, name, profileId } })
.then(() => { .then(() => {
notification.success({ notification.success({
@@ -201,10 +232,27 @@ const Network = () => {
setCheckedLocations(checkedKeys.checked); setCheckedLocations(checkedKeys.checked);
}; };
const locationsTree = useMemo( const handleFetchProfiles = e => {
() => formatLocationListForTree(data && data.getAllLocations)[0].children, if (apProfiles.getAllProfiles.context.lastPage) {
[data] return false;
); }
e.persist();
const { target } = e;
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
fetchMore({
variables: { context: { ...apProfiles.getAllProfiles.context } },
updateQuery: updateQueryGetAllProfiles,
});
}
return true;
};
const locationsTree = useMemo(() => formatLocationListForTree(data && data.getAllLocations), [
data,
]);
if (loading) { if (loading) {
return <Loading />; return <Loading />;
@@ -220,7 +268,6 @@ const Network = () => {
onCheck={onCheck} onCheck={onCheck}
checkedLocations={checkedLocations} checkedLocations={checkedLocations}
locations={locationsTree} locations={locationsTree}
activeTab={location.pathname}
selectedLocation={selectedLocation && selectedLocation.getLocation} selectedLocation={selectedLocation && selectedLocation.getLocation}
addModal={addModal} addModal={addModal}
editModal={editModal} editModal={editModal}
@@ -237,6 +284,8 @@ const Network = () => {
profiles={(apProfiles && apProfiles.getAllProfiles && apProfiles.getAllProfiles.items) || []} profiles={(apProfiles && apProfiles.getAllProfiles && apProfiles.getAllProfiles.items) || []}
loadingProfile={loadingProfile} loadingProfile={loadingProfile}
errorProfile={errorProfile} errorProfile={errorProfile}
onFetchMoreProfiles={handleFetchProfiles}
isLastProfilesPage={apProfiles?.getAllProfiles?.context?.lastPage}
> >
<Switch> <Switch>
<Route <Route
@@ -257,15 +306,17 @@ const Network = () => {
/> />
<Route <Route
exact exact
path={`${path}/access-points/:id`} path={`${path}/access-points/:id/:tab`}
render={props => <AccessPointDetails locations={locationsTree} {...props} />} render={props => <AccessPointDetails locations={locationsTree} {...props} />}
/> />
<Route <Route
exact exact
path={`${path}/client-devices`} path={`${path}/client-devices`}
render={props => <ClientDevices checkedLocations={checkedLocations} {...props} />} render={props => <ClientDevices checkedLocations={checkedLocations} {...props} />}
/> />
<Route exact path={`${path}/client-devices/:id`} component={ClientDeviceDetails} /> <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`} /> <Redirect from={path} to={`${path}/access-points`} />
</Switch> </Switch>
</NetworkPage> </NetworkPage>

View File

@@ -1,13 +1,14 @@
import React, { useState, useContext } from 'react'; import React, { useState, useContext } from 'react';
import { useParams, Redirect } from 'react-router-dom'; import { useParams, Redirect } from 'react-router-dom';
import gql from 'graphql-tag'; import { useQuery, useMutation, gql } from '@apollo/client';
import { useQuery, useMutation } from '@apollo/react-hooks'; import { Alert, notification } from 'antd';
import { Alert, Spin, notification } from 'antd'; import { ProfileDetails as ProfileDetailsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import { ProfileDetails as ProfileDetailsPage } from '@tip-wlan/wlan-cloud-ui-library';
import { ROUTES, AUTH_TOKEN } from 'constants/index';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import { GET_ALL_PROFILES } from 'graphql/queries'; import { GET_ALL_PROFILES, GET_API_URL } from 'graphql/queries';
import { FILE_UPLOAD } from 'graphql/mutations'; import { fetchMoreProfiles } from 'graphql/functions';
import { getItem } from 'utils/localStorage';
const GET_PROFILE = gql` const GET_PROFILE = gql`
query GetProfile($id: ID!) { query GetProfile($id: ID!) {
@@ -22,6 +23,16 @@ const GET_PROFILE = gql`
profileType profileType
details details
} }
associatedSsidProfiles {
id
name
profileType
details
}
osuSsidProfile {
id
name
}
childProfileIds childProfileIds
createdTimestamp createdTimestamp
lastModifiedTimestamp lastModifiedTimestamp
@@ -74,23 +85,63 @@ const ProfileDetails = () => {
const [redirect, setRedirect] = useState(false); const [redirect, setRedirect] = useState(false);
const { data: apiUrl } = useQuery(GET_API_URL);
const { loading, error, data } = useQuery(GET_PROFILE, { const { loading, error, data } = useQuery(GET_PROFILE, {
variables: { id }, variables: { id },
fetchPolicy: 'network-only',
}); });
const { data: ssidProfiles } = useQuery(GET_ALL_PROFILES, { const { data: ssidProfiles, fetchMore } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'ssid' }, variables: { customerId, type: 'ssid' },
fetchPolicy: 'network-only',
}); });
const { data: radiusProfiles } = useQuery(GET_ALL_PROFILES, { const { data: radiusProfiles, fetchMore: fetchMoreRadiusProfiles } = useQuery(
variables: { customerId, type: 'radius' }, GET_ALL_PROFILES(),
{
variables: { customerId, type: 'radius' },
fetchPolicy: 'network-only',
}
);
const { data: captiveProfiles, fetchMore: fetchMoreCaptiveProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'captive_portal' },
fetchPolicy: 'network-only',
}
);
const { data: venueProfiles, fetchMore: fetchMoreVenueProfiles } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'passpoint_venue' },
fetchPolicy: 'network-only',
});
const { data: operatorProfiles, fetchMore: fetchMoreOperatorProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'passpoint_operator' },
fetchPolicy: 'network-only',
}
);
const { data: idProviderProfiles, fetchMore: fetchMoreIdProviderProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'passpoint_osu_id_provider' },
fetchPolicy: 'network-only',
}
);
const { data: rfProfiles, fetchMore: fetchMoreRfProfiles } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'rf' },
fetchPolicy: 'network-only',
}); });
const [updateProfile] = useMutation(UPDATE_PROFILE); const [updateProfile] = useMutation(UPDATE_PROFILE);
const [deleteProfile] = useMutation(DELETE_PROFILE); const [deleteProfile] = useMutation(DELETE_PROFILE);
const [fileUpload] = useMutation(FILE_UPLOAD);
const handleDeleteProfile = () => { const handleDeleteProfile = () => {
deleteProfile({ variables: { id } }) deleteProfile({ variables: { id } })
.then(() => { .then(() => {
@@ -136,23 +187,93 @@ const ProfileDetails = () => {
); );
}; };
const handleFileUpload = (fileName, file) => const handleFileUpload = async (fileName, file) => {
fileUpload({ variables: { fileName, file } }) const token = getItem(AUTH_TOKEN);
.then(() => {
notification.success({ if (apiUrl?.getApiUrl) {
message: 'Success', fetch(`${apiUrl?.getApiUrl}filestore/${fileName}`, {
description: 'File successfully uploaded.', method: 'POST',
}); headers: {
Authorization: token ? `Bearer ${token.access_token}` : '',
'Content-Type': 'application/octet-stream',
},
body: file,
}) })
.catch(() => .then(response => response.json())
notification.error({ .then(resp => {
message: 'Error', if (resp?.success) {
description: 'File could not be uploaded.', 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.',
});
});
} else {
notification.error({
message: 'Error',
description: 'File could not be uploaded.',
});
}
};
const handleDownloadFile = async name => {
const token = getItem(AUTH_TOKEN);
if (apiUrl?.getApiUrl) {
return fetch(`${apiUrl?.getApiUrl}filestore/${encodeURIComponent(name)}`, {
method: 'GET',
headers: {
'Content-Type': 'application/octet-stream',
Authorization: token ? `Bearer ${token.access_token}` : '',
},
})
.then(response => response.blob())
.then(blob => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
})
.catch(() => {
notification.error({
message: 'Error',
description: 'File could not be retrieved.',
});
});
}
return notification.error({
message: 'Error',
description: 'File could not be retrieved.',
});
};
const handleFetchMoreProfiles = (e, key) => {
if (key === 'radius') fetchMoreProfiles(e, radiusProfiles, fetchMoreRadiusProfiles);
else if (key === 'captive_portal')
fetchMoreProfiles(e, captiveProfiles, fetchMoreCaptiveProfiles);
else if (key === 'rf') fetchMoreProfiles(e, rfProfiles, fetchMoreRfProfiles);
else if (key === 'passpoint_venue') fetchMoreProfiles(e, venueProfiles, fetchMoreVenueProfiles);
else if (key === 'passpoint_operator')
fetchMoreProfiles(e, operatorProfiles, fetchMoreOperatorProfiles);
else if (key === 'passpoint_osu_id_provider')
fetchMoreProfiles(e, idProviderProfiles, fetchMoreIdProviderProfiles);
else fetchMoreProfiles(e, ssidProfiles, fetchMore);
};
if (loading) { if (loading) {
return <Spin size="large" />; return <Loading />;
} }
if (error) { if (error) {
@@ -162,7 +283,7 @@ const ProfileDetails = () => {
} }
if (redirect) { if (redirect) {
return <Redirect to="/profiles" />; return <Redirect to={ROUTES.profiles} />;
} }
return ( return (
@@ -170,14 +291,22 @@ const ProfileDetails = () => {
name={data.getProfile.name} name={data.getProfile.name}
profileType={data.getProfile.profileType} profileType={data.getProfile.profileType}
details={data.getProfile.details} details={data.getProfile.details}
childProfiles={data.getProfile.childProfiles}
childProfileIds={data.getProfile.childProfileIds} childProfileIds={data.getProfile.childProfileIds}
onDeleteProfile={handleDeleteProfile} onDeleteProfile={handleDeleteProfile}
onUpdateProfile={handleUpdateProfile} onUpdateProfile={handleUpdateProfile}
ssidProfiles={ ssidProfiles={ssidProfiles?.getAllProfiles?.items}
(ssidProfiles && ssidProfiles.getAllProfiles && ssidProfiles.getAllProfiles.items) || [] rfProfiles={rfProfiles?.getAllProfiles?.items}
}
radiusProfiles={radiusProfiles?.getAllProfiles?.items} radiusProfiles={radiusProfiles?.getAllProfiles?.items}
captiveProfiles={captiveProfiles?.getAllProfiles?.items}
venueProfiles={venueProfiles?.getAllProfiles?.items}
operatorProfiles={operatorProfiles?.getAllProfiles?.items}
idProviderProfiles={idProviderProfiles?.getAllProfiles?.items}
associatedSsidProfiles={data.getProfile?.associatedSsidProfiles}
osuSsidProfile={data.getProfile?.osuSsidProfile}
fileUpload={handleFileUpload} fileUpload={handleFileUpload}
onFetchMoreProfiles={handleFetchMoreProfiles}
onDownloadFile={handleDownloadFile}
/> />
); );
}; };

View File

@@ -1,29 +1,13 @@
import React, { useContext } from 'react'; import React, { useContext, useEffect } from 'react';
import gql from 'graphql-tag'; import { useQuery, useMutation, gql } from '@apollo/client';
import { useQuery, useMutation } from '@apollo/react-hooks'; import { useLocation } from 'react-router-dom';
import { Alert, notification } from 'antd';
import { Profile as ProfilePage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import { Alert, Spin, notification } from 'antd'; import { GET_ALL_PROFILES } from 'graphql/queries';
import { updateQueryGetAllProfiles } from 'graphql/functions';
import { Profile as ProfilePage } from '@tip-wlan/wlan-cloud-ui-library';
import UserContext from 'contexts/UserContext'; 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
}
}
}
`;
const DELETE_PROFILE = gql` const DELETE_PROFILE = gql`
mutation DeleteProfile($id: ID!) { mutation DeleteProfile($id: ID!) {
deleteProfile(id: $id) { deleteProfile(id: $id) {
@@ -34,13 +18,28 @@ const DELETE_PROFILE = gql`
const Profiles = () => { const Profiles = () => {
const { customerId } = useContext(UserContext); const { customerId } = useContext(UserContext);
const { loading, error, data, refetch, fetchMore } = useQuery(GET_ALL_PROFILES, { const { loading, error, data, refetch, fetchMore } = useQuery(
variables: { customerId }, GET_ALL_PROFILES(`equipmentCount`),
}); {
variables: { customerId },
fetchPolicy: 'network-only',
}
);
const [deleteProfile] = useMutation(DELETE_PROFILE); const [deleteProfile] = useMutation(DELETE_PROFILE);
const location = useLocation();
useEffect(() => {
if (location.state && location.state.refetch) {
refetch({
variables: { refresh: Date.now() },
});
}
}, []);
const reloadTable = () => { const reloadTable = () => {
refetch() refetch({
variables: { refresh: Date.now() },
})
.then(() => { .then(() => {
notification.success({ notification.success({
message: 'Success', message: 'Success',
@@ -58,25 +57,22 @@ const Profiles = () => {
const handleLoadMore = () => { const handleLoadMore = () => {
if (!data.getAllProfiles.context.lastPage) { if (!data.getAllProfiles.context.lastPage) {
fetchMore({ fetchMore({
variables: { cursor: data.getAllProfiles.context.cursor }, variables: { context: { ...data.getAllProfiles.context } },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: updateQueryGetAllProfiles,
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 => { const handleDeleteProfile = id => {
deleteProfile({ variables: { id } }) deleteProfile({
variables: { id },
refetchQueries: [
{
query: GET_ALL_PROFILES(`equipmentCount`),
variables: { customerId },
},
],
})
.then(() => { .then(() => {
notification.success({ notification.success({
message: 'Success', message: 'Success',
@@ -92,7 +88,7 @@ const Profiles = () => {
}; };
if (loading) { if (loading) {
return <Spin size="large" />; return <Loading />;
} }
if (error) { if (error) {
@@ -103,7 +99,7 @@ const Profiles = () => {
<ProfilePage <ProfilePage
data={data.getAllProfiles.items} data={data.getAllProfiles.items}
onReload={reloadTable} onReload={reloadTable}
isLastPage={data.getAllProfiles.context.lastPage} isLastPage={data?.getAllProfiles?.context?.lastPage}
onDeleteProfile={handleDeleteProfile} onDeleteProfile={handleDeleteProfile}
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
/> />

View File

@@ -1,11 +1,12 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { useQuery, useMutation } from '@apollo/react-hooks'; import { useQuery, useMutation } from '@apollo/client';
import { Alert, notification } from 'antd'; import { Alert, notification } from 'antd';
import { AutoProvision as AutoProvisionPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { AutoProvision as AutoProvisionPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
import { GET_CUSTOMER, GET_ALL_LOCATIONS, GET_ALL_PROFILES } from 'graphql/queries'; import { GET_CUSTOMER, GET_ALL_LOCATIONS, GET_ALL_PROFILES } from 'graphql/queries';
import { UPDATE_CUSTOMER } from 'graphql/mutations'; import { UPDATE_CUSTOMER } from 'graphql/mutations';
import { fetchMoreProfiles } from 'graphql/functions';
const AutoProvision = () => { const AutoProvision = () => {
const { customerId } = useContext(UserContext); const { customerId } = useContext(UserContext);
@@ -14,16 +15,16 @@ const AutoProvision = () => {
}); });
const [updateCustomer] = useMutation(UPDATE_CUSTOMER); const [updateCustomer] = useMutation(UPDATE_CUSTOMER);
const { data: dataLocation, loading: loadingLoaction, error: errorLocation } = useQuery( const { data: dataLocation, loading: loadingLocation, error: errorLocation } = useQuery(
GET_ALL_LOCATIONS, GET_ALL_LOCATIONS,
{ {
variables: { customerId }, variables: { customerId },
} }
); );
const { data: dataProfile, loading: loadingProfile, error: errorProfile } = useQuery( const { data: dataProfile, loading: loadingProfile, error: errorProfile, fetchMore } = useQuery(
GET_ALL_PROFILES, GET_ALL_PROFILES(),
{ {
variables: { customerId, type: 'equipment_ap' }, variables: { customerId, type: 'equipment_ap', limit: 100 },
} }
); );
@@ -60,6 +61,10 @@ const AutoProvision = () => {
); );
}; };
const handleFetchMoreProfiles = e => {
fetchMoreProfiles(e, dataProfile, fetchMore);
};
if (loading) { if (loading) {
return <Loading />; return <Loading />;
} }
@@ -75,11 +80,12 @@ const AutoProvision = () => {
data={data && data.getCustomer} data={data && data.getCustomer}
dataLocation={dataLocation && dataLocation.getAllLocations} dataLocation={dataLocation && dataLocation.getAllLocations}
dataProfile={dataProfile && dataProfile.getAllProfiles.items} dataProfile={dataProfile && dataProfile.getAllProfiles.items}
loadingLoaction={loadingLoaction} loadingLocation={loadingLocation}
loadingProfile={loadingProfile} loadingProfile={loadingProfile}
errorLocation={errorLocation} errorLocation={errorLocation}
errorProfile={errorProfile} errorProfile={errorProfile}
onUpdateCustomer={handleUpdateCustomer} onUpdateCustomer={handleUpdateCustomer}
onFetchMoreProfiles={handleFetchMoreProfiles}
/> />
); );
}; };

View File

@@ -1,5 +1,5 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { useQuery, useMutation } from '@apollo/react-hooks'; import { useQuery, useMutation } from '@apollo/client';
import { Alert, notification } from 'antd'; import { Alert, notification } from 'antd';
import { BlockedList as BlockedListPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; import { BlockedList as BlockedListPage, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import { GET_BLOCKED_CLIENTS } from 'graphql/queries'; import { GET_BLOCKED_CLIENTS } from 'graphql/queries';

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { useQuery, useMutation, useLazyQuery } from '@apollo/react-hooks'; import { useQuery, useMutation, useLazyQuery } from '@apollo/client';
import { notification } from 'antd'; import { notification } from 'antd';
import { import {
GET_ALL_FIRMWARE, GET_ALL_FIRMWARE,
@@ -22,7 +22,7 @@ const Firmware = () => {
const [ const [
getAllFirmware, getAllFirmware,
{ data: firmwareVersionData, loading: firmwareVersionLoading }, { data: firmwareVersionData, loading: firmwareVersionLoading },
] = useLazyQuery(GET_ALL_FIRMWARE); ] = useLazyQuery(GET_ALL_FIRMWARE, { fetchPolicy: 'network-only' });
const { const {
data: trackAssignmentData, data: trackAssignmentData,
@@ -83,8 +83,18 @@ const Firmware = () => {
firmwareVersionRecordId, firmwareVersionRecordId,
modelId, modelId,
createdTimestamp, createdTimestamp,
lastModifiedTimestamp lastModifiedTimestamp,
prevFirmwareVersionRecordId
) => { ) => {
if (prevFirmwareVersionRecordId !== firmwareVersionRecordId) {
deleteTrackAssignment({
variables: {
firmwareTrackId: firmwareTrackData.getFirmwareTrack.recordId,
firmwareVersionId: prevFirmwareVersionRecordId,
},
});
}
updateTrackAssignment({ updateTrackAssignment({
variables: { variables: {
trackRecordId: firmwareTrackData.getFirmwareTrack.recordId, trackRecordId: firmwareTrackData.getFirmwareTrack.recordId,
@@ -130,6 +140,7 @@ const Firmware = () => {
}) })
); );
}; };
const handleCreateFirmware = ( const handleCreateFirmware = (
modelId, modelId,
versionName, versionName,
@@ -237,7 +248,7 @@ const Firmware = () => {
onCreateTrackAssignment={handleCreateTrackAssignment} onCreateTrackAssignment={handleCreateTrackAssignment}
onUpdateTrackAssignment={handleUpdateTrackAssignment} onUpdateTrackAssignment={handleUpdateTrackAssignment}
onDeleteTrackAssignment={handleDeleteTrackAssignment} onDeleteTrackAssignment={handleDeleteTrackAssignment}
onCreateFirnware={handleCreateFirmware} onCreateFirmware={handleCreateFirmware}
onUpdateFirmware={handleUpdateFirmware} onUpdateFirmware={handleUpdateFirmware}
onDeleteFirmware={handleDeleteFirmware} onDeleteFirmware={handleDeleteFirmware}
firmwareError={error} firmwareError={error}

View File

@@ -1,9 +1,11 @@
import React from 'react'; import React, { useState } from 'react';
import gql from 'graphql-tag'; import { useQuery, useMutation, useLazyQuery, gql } from '@apollo/client';
import { useMutation, useLazyQuery } from '@apollo/react-hooks';
import { notification } from 'antd'; import { notification } from 'antd';
import { Manufacturer as ManufacturerPage } from '@tip-wlan/wlan-cloud-ui-library'; 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` const GET_OUI = gql`
query GetOui($oui: String!) { query GetOui($oui: String!) {
@@ -28,7 +30,12 @@ const UPDATE_OUI = gql`
} }
} }
`; `;
const System = () => { 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 [updateOUI] = useMutation(UPDATE_OUI);
const [searchOUI, { data }] = useLazyQuery(GET_OUI, { const [searchOUI, { data }] = useLazyQuery(GET_OUI, {
onError: () => { onError: () => {
@@ -37,8 +44,16 @@ const System = () => {
description: 'No matching manufacturer found for OUI', 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) => { const handleUpdateOUI = (oui, manufacturerAlias, manufacturerName) => {
updateOUI({ updateOUI({
@@ -66,33 +81,54 @@ const System = () => {
searchOUI({ variables: { oui } }); searchOUI({ variables: { oui } });
}; };
const handleFileUpload = (fileName, file) => const handleFileUpload = (fileName, file) => {
fileUpload({ variables: { fileName, file } }) if (apiUrl?.getApiUrl) {
.then(resp => { setLoadingFileUpload(true);
if (resp?.ouiUpload?.success) {
notification.success({ fetch(`${apiUrl?.getApiUrl}portal/manufacturer/oui/upload?fileName=${fileName}`, {
message: 'Success', method: 'POST',
description: 'File successfully uploaded.', headers: {
}); Authorization: token ? `Bearer ${token.access_token}` : '',
} else { '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({ notification.error({
message: 'Error', message: 'Error',
description: 'File could not be uploaded.', 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 ( return (
<ManufacturerPage <ManufacturerPage
onSearchOUI={handleSearchOUI} onSearchOUI={handleSearchOUI}
onUpdateOUI={handleUpdateOUI} onUpdateOUI={handleUpdateOUI}
returnedOUI={data && data.getOui} returnedOUI={data && data.getOui}
fileUpload={handleFileUpload} fileUpload={handleFileUpload}
loadingFileUpload={loadingFileUpload}
/> />
); );
}; };

View File

@@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
const UserProvider = ({ children, id, email, role, customerId, updateUser, updateToken }) => ( const UserProvider = ({ children, id, email, roles, customerId, updateUser, updateToken }) => (
<UserContext.Provider value={{ id, email, role, customerId, updateUser, updateToken }}> <UserContext.Provider value={{ id, email, roles, customerId, updateUser, updateToken }}>
{children} {children}
</UserContext.Provider> </UserContext.Provider>
); );
@@ -15,14 +15,14 @@ UserProvider.propTypes = {
updateToken: PropTypes.func.isRequired, updateToken: PropTypes.func.isRequired,
id: PropTypes.number, id: PropTypes.number,
email: PropTypes.string, email: PropTypes.string,
role: PropTypes.string, roles: PropTypes.instanceOf(Array),
customerId: PropTypes.number, customerId: PropTypes.number,
}; };
UserProvider.defaultProps = { UserProvider.defaultProps = {
id: null, id: null,
email: null, email: null,
role: null, roles: [],
customerId: null, customerId: null,
}; };

30
app/graphql/functions.js Normal file
View File

@@ -0,0 +1,30 @@
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,
},
};
};
export const fetchMoreProfiles = (e, profile, fetchMore) => {
if (profile.getAllProfiles.context.lastPage) {
return false;
}
e.persist();
const { target } = e;
if (target.scrollTop + target.offsetHeight + 10 >= target.scrollHeight) {
fetchMore({
variables: { context: { ...profile.getAllProfiles.context } },
updateQuery: updateQueryGetAllProfiles,
});
}
return true;
};

View File

@@ -1,4 +1,4 @@
import gql from 'graphql-tag'; import { gql } from '@apollo/client';
export const REFRESH_TOKEN = gql` export const REFRESH_TOKEN = gql`
mutation UpdateToken($refreshToken: String!) { 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` export const UPDATE_TRACK_ASSIGNMENT = gql`
mutation UpdateFirmwareTrackAssignment( mutation UpdateFirmwareTrackAssignment(
$trackRecordId: ID! $trackRecordId: ID!
@@ -239,6 +255,62 @@ export const CREATE_EQUIPMENT = gql`
} }
`; `;
export const UPDATE_EQUIPMENT = gql`
mutation UpdateEquipment(
$id: ID!
$equipmentType: String!
$inventoryId: String!
$customerId: ID!
$profileId: ID!
$locationId: ID!
$name: String!
$baseMacAddress: String
$latitude: String
$longitude: String
$serial: String
$lastModifiedTimestamp: String
$details: JSONObject
) {
updateEquipment(
id: $id
equipmentType: $equipmentType
inventoryId: $inventoryId
customerId: $customerId
profileId: $profileId
locationId: $locationId
name: $name
baseMacAddress: $baseMacAddress
latitude: $latitude
longitude: $longitude
serial: $serial
lastModifiedTimestamp: $lastModifiedTimestamp
details: $details
) {
id
equipmentType
inventoryId
customerId
profileId
locationId
name
baseMacAddress
latitude
longitude
serial
lastModifiedTimestamp
details
}
}
`;
export const DELETE_EQUIPMENT = gql`
mutation DeleteEquipment($id: ID!) {
deleteEquipment(id: $id) {
id
}
}
`;
export const UPDATE_CUSTOMER = gql` export const UPDATE_CUSTOMER = gql`
mutation UpdateCustomer( mutation UpdateCustomer(
$id: ID! $id: ID!

View File

@@ -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` export const GET_ALL_LOCATIONS = gql`
query GetAllLocations($customerId: ID!) { query GetAllLocations($customerId: ID!) {
@@ -16,13 +22,13 @@ export const FILTER_EQUIPMENT = gql`
$locationIds: [ID] $locationIds: [ID]
$customerId: ID! $customerId: ID!
$equipmentType: String $equipmentType: String
$cursor: String $context: JSONObject
) { ) {
filterEquipment( filterEquipment(
customerId: $customerId customerId: $customerId
locationIds: $locationIds locationIds: $locationIds
equipmentType: $equipmentType equipmentType: $equipmentType
cursor: $cursor context: $context
) { ) {
items { items {
name name
@@ -36,12 +42,12 @@ export const FILTER_EQUIPMENT = gql`
profile { profile {
name name
} }
baseMacAddress
manufacturer
status { status {
protocol { protocol {
details { details {
reportedIpV4Addr reportedIpV4Addr
reportedMacAddr
manufacturer
} }
} }
osPerformance { osPerformance {
@@ -61,11 +67,75 @@ export const FILTER_EQUIPMENT = gql`
numClientsPerRadio numClientsPerRadio
} }
} }
firmware {
detailsJSON
}
channel {
detailsJSON
}
} }
} }
context { context
lastPage }
cursor }
`;
export const GET_EQUIPMENT = gql`
query GetEquipment($id: ID!) {
getEquipment(id: $id) {
id
equipmentType
inventoryId
customerId
profileId
locationId
name
latitude
longitude
serial
lastModifiedTimestamp
details
profile {
id
name
childProfiles {
id
name
details
}
}
baseMacAddress
manufacturer
status {
firmware {
detailsJSON
}
protocol {
detailsJSON
}
radioUtilization {
detailsJSON
}
clientDetails {
detailsJSON
details {
numClientsPerRadio
}
}
osPerformance {
detailsJSON
}
channel {
detailsJSON
}
}
model
alarmsCount
alarms {
severity
alarmCode
details
createdTimestamp
} }
} }
} }
@@ -76,13 +146,13 @@ export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql`
$locationIds: [ID] $locationIds: [ID]
$customerId: ID! $customerId: ID!
$equipmentType: String $equipmentType: String
$cursor: String $context: JSONObject
) { ) {
filterEquipment( filterEquipment(
customerId: $customerId customerId: $customerId
locationIds: $locationIds locationIds: $locationIds
equipmentType: $equipmentType equipmentType: $equipmentType
cursor: $cursor context: $context
) { ) {
items { items {
name name
@@ -91,10 +161,7 @@ export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql`
channel channel
details details
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
@@ -112,8 +179,8 @@ export const GET_LOCATION = gql`
`; `;
export const FILTER_CLIENT_SESSIONS = gql` export const FILTER_CLIENT_SESSIONS = gql`
query FilterClientSessions($customerId: ID!, $locationIds: [ID], $cursor: String) { query FilterClientSessions($customerId: ID!, $locationIds: [ID], $context: JSONObject) {
filterClientSessions(customerId: $customerId, locationIds: $locationIds, cursor: $cursor) { filterClientSessions(customerId: $customerId, locationIds: $locationIds, context: $context) {
items { items {
id id
macAddress macAddress
@@ -123,14 +190,12 @@ export const FILTER_CLIENT_SESSIONS = gql`
radioType radioType
signal signal
manufacturer manufacturer
details
equipment { equipment {
name name
} }
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
@@ -157,7 +222,7 @@ export const GET_CLIENT_SESSION = gql`
export const FILTER_SERVICE_METRICS = gql` export const FILTER_SERVICE_METRICS = gql`
query FilterServiceMetrics( query FilterServiceMetrics(
$customerId: ID! $customerId: ID!
$cursor: String $context: JSONObject
$fromTime: String! $fromTime: String!
$toTime: String! $toTime: String!
$clientMacs: [String] $clientMacs: [String]
@@ -167,7 +232,7 @@ export const FILTER_SERVICE_METRICS = gql`
) { ) {
filterServiceMetrics( filterServiceMetrics(
customerId: $customerId customerId: $customerId
cursor: $cursor context: $context
fromTime: $fromTime fromTime: $fromTime
toTime: $toTime toTime: $toTime
clientMacs: $clientMacs clientMacs: $clientMacs
@@ -183,27 +248,34 @@ export const FILTER_SERVICE_METRICS = gql`
txBytes txBytes
detailsJSON detailsJSON
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
export const GET_ALL_PROFILES = gql` export const GET_ALL_PROFILES = (fields = '') => gql`
query GetAllProfiles($customerId: ID!, $cursor: String, $type: String) { query GetAllProfiles(
getAllProfiles(customerId: $customerId, cursor: $cursor, type: $type) { $customerId: ID!
$cursor: String
$limit: Int
$type: String
$context: JSONObject
) {
getAllProfiles(
customerId: $customerId
cursor: $cursor
limit: $limit
type: $type
context: $context
) {
items { items {
id id
name name
profileType profileType
details details
${fields}
} }
context { context
cursor
lastPage
}
} }
} }
`; `;
@@ -219,10 +291,7 @@ export const GET_ALL_STATUS = gql`
clientCountPerOui clientCountPerOui
} }
} }
context { context
lastPage
cursor
}
} }
} }
`; `;
@@ -298,7 +367,7 @@ export const FILTER_SYSTEM_EVENTS = gql`
$toTime: String! $toTime: String!
$equipmentIds: [ID] $equipmentIds: [ID]
$dataTypes: [String] $dataTypes: [String]
$cursor: String $context: JSONObject
$limit: Int $limit: Int
) { ) {
filterSystemEvents( filterSystemEvents(
@@ -307,14 +376,11 @@ export const FILTER_SYSTEM_EVENTS = gql`
toTime: $toTime toTime: $toTime
dataTypes: $dataTypes dataTypes: $dataTypes
equipmentIds: $equipmentIds equipmentIds: $equipmentIds
cursor: $cursor context: $context
limit: $limit limit: $limit
) { ) {
items items
context { context
lastPage
cursor
}
} }
} }
`; `;

View File

@@ -1,12 +1,10 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { Router } from 'react-router-dom'; import { Router } from 'react-router-dom';
import { ApolloClient } from 'apollo-client'; import { ApolloClient, ApolloProvider, ApolloLink, Observable } from '@apollo/client';
import { InMemoryCache } from 'apollo-cache-inmemory'; import { InMemoryCache } from '@apollo/client/cache';
import { onError } from 'apollo-link-error'; import { onError } from '@apollo/client/link/error';
import { createUploadLink } from 'apollo-upload-client'; import { createUploadLink } from 'apollo-upload-client';
import { ApolloLink, Observable } from 'apollo-link';
import { ApolloProvider } from '@apollo/react-hooks';
import 'styles/antd.less'; import 'styles/antd.less';
import 'styles/index.scss'; import 'styles/index.scss';
@@ -17,14 +15,13 @@ import { REFRESH_TOKEN } from 'graphql/mutations';
import { getItem, setItem, removeItem } from 'utils/localStorage'; import { getItem, setItem, removeItem } from 'utils/localStorage';
import history from 'utils/history'; import history from 'utils/history';
const API_URI = const API_URI = process.env.NODE_ENV === 'production' ? window.REACT_APP_API : process.env.API;
process.env.NODE_ENV === 'development' ? 'http://localhost:4000/' : window.REACT_APP_API;
const MOUNT_NODE = document.getElementById('root'); const MOUNT_NODE = document.getElementById('root');
const cache = new InMemoryCache(); const cache = new InMemoryCache();
const uploadLink = createUploadLink({ const uploadLink = createUploadLink({
uri: API_URI, uri: `${API_URI}/graphql`,
}); });
const request = async operation => { const request = async operation => {

View File

@@ -1,4 +1,4 @@
$sidebar-width: 234px; $sidebar-width: 234px;
$sidebar-collapsed-width: 80px; $sidebar-collapsed-width: 80px;
$header-height: 64px; $header-height: 64px;

13026
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "wlan-cloud-ui", "name": "wlan-cloud-ui",
"version": "0.2.7", "version": "1.1.8",
"author": "ConnectUs", "author": "ConnectUs",
"description": "React Portal", "description": "React Portal",
"engines": { "engines": {
@@ -9,50 +9,38 @@
}, },
"scripts": { "scripts": {
"test": "jest --passWithNoTests --coverage", "test": "jest --passWithNoTests --coverage",
"start": "cross-env NODE_ENV=development webpack-dev-server", "start": "cross-env NODE_ENV=development webpack serve --mode development",
"start:bare": "cross-env API=https://wlan-ui.tip-sdk.lab.netexperience.com NODE_ENV=bare webpack serve --mode development",
"start:dev": "cross-env API=https://wlan-ui.tip-sdk.lab.netexperience.com NODE_ENV=development webpack serve --mode development",
"build": "webpack --mode=production", "build": "webpack --mode=production",
"format": "prettier --write \"app/**/*.js\"", "format": "prettier --write 'app/**/*{.js,.scss}'",
"eslint-fix": "eslint --fix \"app/**/*.js\"", "eslint-fix": "eslint --fix 'app/**/*.js'",
"eslint": "eslint \"app/**/*.js\" --max-warnings=0" "eslint": "eslint 'app/**/*.js' --max-warnings=0"
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@ant-design/icons": "^4.2.1", "@ant-design/icons": "^4.2.1",
"@apollo/react-hoc": "^3.1.4", "@apollo/client": "^3.1.3",
"@apollo/react-hooks": "^3.1.3", "@tip-wlan/wlan-cloud-ui-library": "^1.1.14",
"@tip-wlan/wlan-cloud-ui-library": "^0.2.7", "antd": "^4.5.2",
"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-upload-client": "^13.0.0", "apollo-upload-client": "^13.0.0",
"clean-webpack-plugin": "^3.0.0", "graphql": "^15.5.0",
"graphql": "^14.6.0",
"graphql-tag": "^2.10.3",
"highcharts": "^8.1.1",
"highcharts-react-official": "^3.0.0",
"history": "^4.10.1", "history": "^4.10.1",
"html-webpack-plugin": "^3.2.0",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"mini-css-extract-plugin": "^0.9.0",
"moment": "^2.26.0", "moment": "^2.26.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"react": "^16.13.0", "react": "^16.13.0",
"react-dom": "^16.13.0", "react-dom": "^16.13.0",
"react-helmet": "^5.2.1", "react-helmet": "^5.2.1",
"react-jsx-highcharts": "^4.1.0",
"react-jsx-highstock": "^4.1.0",
"react-router-dom": "^5.1.2", "react-router-dom": "^5.1.2",
"terser-webpack-plugin": "^2.3.5" "recharts": "^2.0.9"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.8.7", "@babel/core": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3", "@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "^7.8.7", "@babel/preset-env": "^7.8.7",
"@babel/preset-react": "^7.8.3", "@babel/preset-react": "^7.8.3",
"@babel/runtime": "^7.13.10",
"@testing-library/react": "^10.0.3", "@testing-library/react": "^10.0.3",
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
@@ -60,8 +48,10 @@
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"babel-plugin-root-import": "^6.4.1", "babel-plugin-root-import": "^6.4.1",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"clean-webpack-plugin": "^3.0.0",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"css-loader": "^3.4.2", "css-loader": "^3.4.2",
"css-minimizer-webpack-plugin": "^1.3.0",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-config-airbnb": "^18.0.1", "eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.10.0", "eslint-config-prettier": "^6.10.0",
@@ -73,38 +63,38 @@
"eslint-plugin-react": "^7.19.0", "eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.0", "eslint-plugin-react-hooks": "^2.5.0",
"file-loader": "^5.1.0", "file-loader": "^5.1.0",
"html-webpack-plugin": "^5.3.1",
"husky": "^4.2.3", "husky": "^4.2.3",
"jest": "^25.4.0", "jest": "^25.4.0",
"less": "^3.11.1", "less": "^3.11.1",
"less-loader": "^5.0.0", "less-loader": "^6.2.0",
"lint-staged": "^10.0.8", "lint-staged": "^10.0.8",
"mini-css-extract-plugin": "^1.3.9",
"node-sass": "^4.13.1", "node-sass": "^4.13.1",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"pretty-quick": "^2.0.1",
"react-test-renderer": "^16.13.1", "react-test-renderer": "^16.13.1",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"style-loader": "^1.1.3", "style-loader": "^1.1.3",
"webpack": "^4.42.0", "terser-webpack-plugin": "^5.1.1",
"webpack-cli": "^3.3.11", "webpack": "^5.28.0",
"webpack-dev-server": "^3.11.0", "webpack-cli": "^4.5.0",
"webpack-merge": "^4.2.2" "webpack-dev-server": "^3.11.2",
"webpack-merge": "^5.7.3"
}, },
"precommit": "NODE_ENV=production lint-staged",
"browserslist": [ "browserslist": [
"last 2 versions", "last 2 versions",
"> 1%", "> 1%",
"IE 10" "IE 10"
], ],
"lint-staged": {
"*.{js,jsx}": [
"pretty-quick --staged",
"eslint . --fix \"app/**/*.js\" --max-warnings=0",
"git add"
]
},
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "lint-staged" "pre-commit": "lint-staged"
} }
},
"lint-staged": {
"*.{js,jsx}": [
"eslint --fix 'app/**/*.js' --max-warnings=0",
"prettier --write"
]
} }
} }

View File

@@ -1,11 +1,13 @@
const webpackMerge = require('webpack-merge'); /* eslint-disable import/no-extraneous-dependencies */
const { merge } = require('webpack-merge');
const common = require('./webpack/webpack.common'); const common = require('./webpack/webpack.common');
const envs = { const envs = {
development: 'dev', development: 'dev',
production: 'prod', production: 'prod',
bare: 'bare',
}; };
/* eslint-disable global-require,import/no-dynamic-require */ /* eslint-disable global-require,import/no-dynamic-require */
const env = envs[process.env.NODE_ENV || 'production']; const env = envs[process.env.NODE_ENV || 'production'];
const envConfig = require(`./webpack/webpack.${env}.js`); const envConfig = require(`./webpack/webpack.${env}.js`);
module.exports = webpackMerge(common, envConfig); module.exports = merge(common, envConfig);

73
webpack/webpack.bare.js Normal file
View 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'),
},
},
};

View File

@@ -1,4 +1,3 @@
const HtmlWebPackPlugin = require('html-webpack-plugin');
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
const webpack = require('webpack'); const webpack = require('webpack');
@@ -22,32 +21,11 @@ module.exports = {
exclude: /node_modules/, exclude: /node_modules/,
use: ['babel-loader', 'eslint-loader'], use: ['babel-loader', 'eslint-loader'],
}, },
{
test: /\.less$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
{
loader: 'less-loader',
options: {
javascriptEnabled: true,
},
},
],
},
], ],
}, },
plugins: [ plugins: [
new HtmlWebPackPlugin({
template: commonPaths.templatePath,
favicon: './app/images/favicon.ico',
}),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env.GRAPHQL_URL': JSON.stringify(process.env.GRAPHQL_URL), 'process.env.API': JSON.stringify(process.env.API || 'http://localhost:4000'),
}), }),
], ],
}; };

View File

@@ -1,4 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path'); const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const commonPaths = require('./paths'); const commonPaths = require('./paths');
@@ -34,6 +36,28 @@ module.exports = {
}, },
{ {
loader: 'sass-loader', 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,
},
},
}, },
], ],
}, },
@@ -59,4 +83,11 @@ module.exports = {
), ),
}, },
}, },
plugins: [
new HtmlWebpackPlugin({
template: commonPaths.templatePath,
favicon: './app/images/favicon.ico',
}),
],
}; };

View File

@@ -1,6 +1,8 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); /* eslint-disable import/no-extraneous-dependencies */
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin');
const path = require('path'); const path = require('path');
@@ -8,44 +10,50 @@ const commonPaths = require('./paths');
module.exports = { module.exports = {
output: { output: {
filename: `${commonPaths.jsFolder}/[name].[hash].js`,
path: commonPaths.outputPath, path: commonPaths.outputPath,
publicPath: '/', publicPath: '/',
chunkFilename: `${commonPaths.jsFolder}/[name].[chunkhash].js`, filename: `${commonPaths.jsFolder}/[name].[chunkhash].js`,
chunkFilename: `${commonPaths.jsFolder}/[id].[chunkhash].js`,
}, },
optimization: { optimization: {
minimize: true,
minimizer: [ minimizer: [
new TerserPlugin({ new TerserPlugin({
// Use multi-process parallel running to improve the build speed terserOptions: {
// Default number of concurrent runs: os.cpus().length - 1 warnings: false,
parallel: true, compress: {
// Enable file caching comparisons: false,
cache: true, },
sourceMap: true, parse: {},
}), mangle: true,
new OptimizeCSSAssetsPlugin(), output: {
], comments: false,
// Automatically split vendor and commons ascii_only: true,
// https://twitter.com/wSokra/status/969633336732905474 },
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'initial',
}, },
async: { parallel: true,
}),
new CssMinimizerPlugin(),
],
nodeEnv: 'production',
sideEffects: true,
concatenateModules: true,
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: 10,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
name: 'async', name(module) {
chunks: 'async', const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
minChunks: 4, return `npm.${packageName.replace('@', '')}`;
},
}, },
}, },
}, },
// Keep the runtime chunk seperated to enable long term caching
// https://twitter.com/wSokra/status/969679223278505985
runtimeChunk: true,
}, },
module: { module: {
@@ -67,20 +75,58 @@ module.exports = {
'sass-loader', 'sass-loader',
], ],
}, },
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
},
{
loader: 'less-loader', // compiles Less to CSS
options: {
lessOptions: {
javascriptEnabled: true,
},
},
},
],
},
], ],
}, },
resolve: { resolve: {
modules: ['node_modules', 'app'], modules: ['node_modules', 'app'],
alias: { alias: {
app: path.resolve(__dirname, '../', 'app'), app: path.resolve(__dirname, '../', 'app'),
}, },
}, },
plugins: [ plugins: [
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
// Minify and optimize the index.html
new HtmlWebpackPlugin({
template: commonPaths.templatePath,
favicon: './app/images/favicon.ico',
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
inject: true,
}),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: `${commonPaths.cssFolder}/[name].css`, filename: `${commonPaths.cssFolder}/[name].css`,
chunkFilename: `${commonPaths.cssFolder}/[name].css`, chunkFilename: `${commonPaths.cssFolder}/[id].css`,
}), }),
], ],
devtool: 'source-map',
}; };