mirror of
				https://github.com/Telecominfraproject/wlan-cloud-ui.git
				synced 2025-10-31 10:48:01 +00:00 
			
		
		
		
	Compare commits
	
		
			112 Commits
		
	
	
		
			feature/NE
			...
			v1.2.0-RC1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 8b4d15d0b2 | ||
|   | 716b5e227e | ||
|   | 27a2548c71 | ||
|   | 6e7d857bbe | ||
|   | 6cd475ea8e | ||
|   | 66c7d629a3 | ||
|   | 5c84362777 | ||
|   | 29a66613c1 | ||
|   | 10adeeeba3 | ||
|   | 8938b9a800 | ||
|   | 9592450d5f | ||
|   | d4b12c614f | ||
|   | a952a40eb5 | ||
|   | 6c0e5f959d | ||
|   | 4450a01397 | ||
|   | 5d3192e314 | ||
|   | 7ccebb107a | ||
|   | 42eaa86893 | ||
|   | 48f6a64790 | ||
|   | 879c97f44d | ||
|   | 01599ca670 | ||
|   | 1be788925e | ||
|   | 3697d0b4a9 | ||
|   | a9655e25aa | ||
|   | 6bd8beb436 | ||
|   | e023ef0569 | ||
|   | 8d93cf4f73 | ||
|   | 87b056967f | ||
|   | d6d207c058 | ||
|   | 0017541d82 | ||
|   | eab3476dbe | ||
|   | ff5b6dc1fc | ||
|   | 40033efb61 | ||
|   | 516fb50817 | ||
|   | 4449465edc | ||
|   | 57f91633c2 | ||
|   | aa559971d8 | ||
|   | 84c8dc19ce | ||
|   | 77dd63ea43 | ||
|   | adcffb5b73 | ||
|   | 2c0171fe7a | ||
|   | debd0712b3 | ||
|   | 0c39ad4d52 | ||
|   | 23574b0970 | ||
|   | 177b41dc8d | ||
|   | 9b5340dfcd | ||
|   | d3be117c5b | ||
|   | f317b2869a | ||
|   | 3cf5c9e732 | ||
|   | 170d62aee8 | ||
|   | ca7acd6e80 | ||
|   | 2bd5601443 | ||
|   | eecae86de6 | ||
|   | 90c4e5bedc | ||
|   | f6fbe3a52a | ||
|   | a526b70fc2 | ||
|   | 8ed817256f | ||
|   | eab121730c | ||
|   | b73d547223 | ||
|   | 08b8038c60 | ||
|   | 9d9938fb4a | ||
|   | e7cb25a398 | ||
|   | 7810f51baf | ||
|   | 300f00cc85 | ||
|   | 0b83cce523 | ||
|   | 5de121330e | ||
|   | 252047aad4 | ||
|   | a7c7b0f295 | ||
|   | 8d14212702 | ||
|   | 70d609643c | ||
|   | a6e2f9b5c7 | ||
|   | 569ce9d5f9 | ||
|   | a0506eaf07 | ||
|   | 31074ac42e | ||
|   | 2eebd4ac3d | ||
|   | 153e4f7dcf | ||
|   | 325f86ff42 | ||
|   | 5bff3379d5 | ||
|   | a2cf42e90c | ||
|   | 0fd5803584 | ||
|   | af98ac522a | ||
|   | 6baf3785da | ||
|   | 36682cd207 | ||
|   | 63ac433ad8 | ||
|   | 2ed09f903c | ||
|   | 2c0fa53896 | ||
|   | 9bf737c1eb | ||
|   | cf5be15402 | ||
|   | f3ee2f5a7c | ||
|   | 6ddd9b30f3 | ||
|   | 8acdd0ca4a | ||
|   | 8670e74b77 | ||
|   | c8798dd6b3 | ||
|   | 82b5688503 | ||
|   | fadb618c6a | ||
|   | dbf54d26b6 | ||
|   | 11e7b92902 | ||
|   | cb8364b1ab | ||
|   | 796bf24ef9 | ||
|   | 444a9a929d | ||
|   | efea725ce9 | ||
|   | 7a3bcbb2cb | ||
|   | a3e304323d | ||
|   | af182c93c6 | ||
|   | 78fde75678 | ||
|   | 7eda2074b2 | ||
|   | ded1b2d088 | ||
|   | e1f0357c1f | ||
|   | b84e156f74 | ||
|   | cae23638ee | ||
|   | 569154ff95 | ||
|   | 78146969f3 | 
							
								
								
									
										21
									
								
								.github/workflows/dockerpublish.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								.github/workflows/dockerpublish.yml
									
									
									
									
										vendored
									
									
								
							| @@ -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: | ||||||
| @@ -14,8 +15,8 @@ on: | |||||||
|   pull_request: |   pull_request: | ||||||
|  |  | ||||||
|   schedule: |   schedule: | ||||||
|       # runs nightly build at 5AM |     # runs nightly build at 5AM | ||||||
|       - cron:  '00 09 * * *' |     - cron: '00 09 * * *' | ||||||
|  |  | ||||||
| env: | env: | ||||||
|   IMAGE_NAME: wlan-cloud-ui |   IMAGE_NAME: wlan-cloud-ui | ||||||
| @@ -48,7 +49,7 @@ jobs: | |||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v2 |       - uses: actions/checkout@v2 | ||||||
|  |  | ||||||
|       - name: Adding property file with component version and commit hash  |       - name: Adding property file with component version and commit hash | ||||||
|         run: | |         run: | | ||||||
|           # Strip git ref prefix from version |           # Strip git ref prefix from version | ||||||
|           VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') |           VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||||||
| @@ -56,8 +57,11 @@ 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.2.0-SNAPSHOT | ||||||
|  |  | ||||||
|           TIMESTAMP=$(date +'%Y-%m-%d') |           TIMESTAMP=$(date +'%Y-%m-%d') | ||||||
|  |  | ||||||
| @@ -88,8 +92,11 @@ 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.2.0-SNAPSHOT | ||||||
|  |  | ||||||
|           echo IMAGE_ID=$IMAGE_ID |           echo IMAGE_ID=$IMAGE_ID | ||||||
|           echo VERSION=$VERSION |           echo VERSION=$VERSION | ||||||
| @@ -97,6 +104,6 @@ jobs: | |||||||
|  |  | ||||||
|           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 tag image $IMAGE_ID:$VERSION-$TIMESTAMP | ||||||
|           docker push $IMAGE_ID:$VERSION-$TIMESTAMP           |           docker push $IMAGE_ID:$VERSION-$TIMESTAMP | ||||||
|   | |||||||
| @@ -3,9 +3,9 @@ export const COMPANY = 'Telecom Infra Project'; | |||||||
|  |  | ||||||
| export const USER_FRIENDLY_RADIOS = { | export const USER_FRIENDLY_RADIOS = { | ||||||
|   is2dot4GHz: '2.4GHz', |   is2dot4GHz: '2.4GHz', | ||||||
|  |   is5GHz: '5GHz', | ||||||
|   is5GHzL: '5GHz (L)', |   is5GHzL: '5GHz (L)', | ||||||
|   is5GHzU: '5GHz (U)', |   is5GHzU: '5GHz (U)', | ||||||
|   is5GHz: '5GHz', |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| export const ROUTES = { | export const ROUTES = { | ||||||
|   | |||||||
| @@ -95,7 +95,7 @@ const Accounts = () => { | |||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   const handleCreateUser = (email, password, roles) => { |   const handleCreateUser = ({ email, password, roles }) => { | ||||||
|     createUser({ |     createUser({ | ||||||
|       variables: { |       variables: { | ||||||
|         username: email, |         username: email, | ||||||
| @@ -119,7 +119,7 @@ const Accounts = () => { | |||||||
|       ); |       ); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   const handleEditUser = (id, email, password, roles, lastModifiedTimestamp) => { |   const handleEditUser = ({ id, email, password, roles, lastModifiedTimestamp }) => { | ||||||
|     updateUser({ |     updateUser({ | ||||||
|       variables: { |       variables: { | ||||||
|         id, |         id, | ||||||
|   | |||||||
| @@ -4,10 +4,11 @@ import { useMutation, useQuery, gql } from '@apollo/client'; | |||||||
| import { notification } from 'antd'; | import { notification } from 'antd'; | ||||||
| import { useHistory } from 'react-router-dom'; | import { useHistory } from 'react-router-dom'; | ||||||
|  |  | ||||||
| import { ROUTES } from 'constants/index'; | 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 { updateQueryGetAllProfiles } from 'graphql/functions'; | import { fetchMoreProfiles } from 'graphql/functions'; | ||||||
|  | import { getItem } from 'utils/localStorage'; | ||||||
|  |  | ||||||
| const CREATE_PROFILE = gql` | const CREATE_PROFILE = gql` | ||||||
|   mutation CreateProfile( |   mutation CreateProfile( | ||||||
| @@ -35,26 +36,48 @@ const CREATE_PROFILE = gql` | |||||||
|  |  | ||||||
| const AddProfile = () => { | const AddProfile = () => { | ||||||
|   const { customerId } = useContext(UserContext); |   const { customerId } = useContext(UserContext); | ||||||
|  |  | ||||||
|  |   const { data: apiUrl } = useQuery(GET_API_URL); | ||||||
|  |  | ||||||
|   const { data: ssidProfiles, fetchMore } = 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(), { |   const { data: venueProfiles, fetchMore: fetchMoreVenueProfiles } = useQuery(GET_ALL_PROFILES(), { | ||||||
|     variables: { customerId, type: 'passpoint_venue' }, |     variables: { customerId, type: 'passpoint_venue' }, | ||||||
|  |     fetchPolicy: 'network-only', | ||||||
|   }); |   }); | ||||||
|   const { data: operatorProfiles, fetchMore: fetchMoreOperatorProfiles } = useQuery( |   const { data: operatorProfiles, fetchMore: fetchMoreOperatorProfiles } = useQuery( | ||||||
|     GET_ALL_PROFILES(), |     GET_ALL_PROFILES(), | ||||||
|     { |     { | ||||||
|       variables: { customerId, type: 'passpoint_operator' }, |       variables: { customerId, type: 'passpoint_operator' }, | ||||||
|  |       fetchPolicy: 'network-only', | ||||||
|     } |     } | ||||||
|   ); |   ); | ||||||
|   const { data: idProviderProfiles, fetchMore: fetchMoreIdProviderProfiles } = useQuery( |   const { data: idProviderProfiles, fetchMore: fetchMoreIdProviderProfiles } = useQuery( | ||||||
|     GET_ALL_PROFILES(), |     GET_ALL_PROFILES(), | ||||||
|     { |     { | ||||||
|       variables: { customerId, type: 'passpoint_osu_id_provider' }, |       variables: { customerId, type: 'passpoint_osu_id_provider' }, | ||||||
|  |       fetchPolicy: 'network-only', | ||||||
|     } |     } | ||||||
|   ); |   ); | ||||||
|   const { data: rfProfiles, fetchMore: fetchMoreRfProfiles } = useQuery(GET_ALL_PROFILES(), { |   const { data: rfProfiles, fetchMore: fetchMoreRfProfiles } = useQuery(GET_ALL_PROFILES(), { | ||||||
|     variables: { customerId, type: 'rf' }, |     variables: { customerId, type: 'rf' }, | ||||||
|  |     fetchPolicy: 'network-only', | ||||||
|   }); |   }); | ||||||
|   const [createProfile] = useMutation(CREATE_PROFILE); |   const [createProfile] = useMutation(CREATE_PROFILE); | ||||||
|   const history = useHistory(); |   const history = useHistory(); | ||||||
| @@ -84,111 +107,71 @@ const AddProfile = () => { | |||||||
|       ); |       ); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   const handleFetchProfiles = e => { |   const handleFetchMoreProfiles = (e, key) => { | ||||||
|     if (ssidProfiles.getAllProfiles.context.lastPage) { |     if (key === 'radius') fetchMoreProfiles(e, radiusProfiles, fetchMoreRadiusProfiles); | ||||||
|       return false; |     else if (key === 'captive_portal') | ||||||
|     } |       fetchMoreProfiles(e, captiveProfiles, fetchMoreCaptiveProfiles); | ||||||
|  |     else if (key === 'rf') fetchMoreProfiles(e, rfProfiles, fetchMoreRfProfiles); | ||||||
|     e.persist(); |     else if (key === 'passpoint_venue') fetchMoreProfiles(e, venueProfiles, fetchMoreVenueProfiles); | ||||||
|     const { target } = e; |     else if (key === 'passpoint_operator') | ||||||
|  |       fetchMoreProfiles(e, operatorProfiles, fetchMoreOperatorProfiles); | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |     else if (key === 'passpoint_osu_id_provider') | ||||||
|       fetchMore({ |       fetchMoreProfiles(e, idProviderProfiles, fetchMoreIdProviderProfiles); | ||||||
|         variables: { context: { ...ssidProfiles.getAllProfiles.context } }, |     else fetchMoreProfiles(e, ssidProfiles, fetchMore); | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   const handleFetchVenueProfiles = e => { |   const handleFileUpload = async (fileName, file) => { | ||||||
|     if (venueProfiles.getAllProfiles.context.lastPage) { |     const token = getItem(AUTH_TOKEN); | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |     if (apiUrl?.getApiUrl) { | ||||||
|     const { target } = e; |       fetch(`${apiUrl?.getApiUrl}filestore/${fileName}`, { | ||||||
|  |         method: 'POST', | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |         headers: { | ||||||
|       fetchMoreVenueProfiles({ |           Authorization: token ? `Bearer ${token.access_token}` : '', | ||||||
|         variables: { context: { ...venueProfiles.getAllProfiles.context } }, |           'Content-Type': 'application/octet-stream', | ||||||
|         updateQuery: updateQueryGetAllProfiles, |         }, | ||||||
|  |         body: file, | ||||||
|  |       }) | ||||||
|  |         .then(response => response.json()) | ||||||
|  |         .then(resp => { | ||||||
|  |           if (resp?.success) { | ||||||
|  |             notification.success({ | ||||||
|  |               message: 'Success', | ||||||
|  |               description: 'File successfully uploaded.', | ||||||
|  |             }); | ||||||
|  |           } else { | ||||||
|  |             notification.error({ | ||||||
|  |               message: 'Error', | ||||||
|  |               description: 'File could not be uploaded.', | ||||||
|  |             }); | ||||||
|  |           } | ||||||
|  |         }) | ||||||
|  |         .catch(() => { | ||||||
|  |           notification.error({ | ||||||
|  |             message: 'Error', | ||||||
|  |             description: 'File could not be uploaded.', | ||||||
|  |           }); | ||||||
|  |         }); | ||||||
|  |     } else { | ||||||
|  |       notification.error({ | ||||||
|  |         message: 'Error', | ||||||
|  |         description: 'File could not be uploaded.', | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const handleFetchRfProfiles = e => { |  | ||||||
|     if (rfProfiles.getAllProfiles.context.lastPage) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |  | ||||||
|     const { target } = e; |  | ||||||
|  |  | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMoreRfProfiles({ |  | ||||||
|         variables: { context: { ...rfProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const handleFetchOperatorProfiles = e => { |  | ||||||
|     if (operatorProfiles.getAllProfiles.context.lastPage) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |  | ||||||
|     const { target } = e; |  | ||||||
|  |  | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMoreOperatorProfiles({ |  | ||||||
|         variables: { context: { ...operatorProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const handleFetchIdProviderProfiles = e => { |  | ||||||
|     if (idProviderProfiles.getAllProfiles.context.lastPage) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |  | ||||||
|     const { target } = e; |  | ||||||
|  |  | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMoreIdProviderProfiles({ |  | ||||||
|         variables: { context: { ...idProviderProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   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} |       venueProfiles={venueProfiles?.getAllProfiles?.items} | ||||||
|       operatorProfiles={operatorProfiles?.getAllProfiles?.items} |       operatorProfiles={operatorProfiles?.getAllProfiles?.items} | ||||||
|       idProviderProfiles={idProviderProfiles?.getAllProfiles?.items} |       idProviderProfiles={idProviderProfiles?.getAllProfiles?.items} | ||||||
|       rfProfiles={rfProfiles?.getAllProfiles?.items} |       rfProfiles={rfProfiles?.getAllProfiles?.items} | ||||||
|       onFetchMoreProfiles={handleFetchProfiles} |       onFetchMoreProfiles={handleFetchMoreProfiles} | ||||||
|       onFetchMoreVenueProfiles={handleFetchVenueProfiles} |       fileUpload={handleFileUpload} | ||||||
|       onFetchMoreOperatorProfiles={handleFetchOperatorProfiles} |  | ||||||
|       onFetchMoreIdProviderProfiles={handleFetchIdProviderProfiles} |  | ||||||
|       onFetchMoreRfProfiles={handleFetchRfProfiles} |  | ||||||
|     /> |     /> | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -75,7 +75,6 @@ const App = () => { | |||||||
|         <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={ROUTES.login} component={Login} /> |           <UnauthenticatedRoute exact path={ROUTES.login} component={Login} /> | ||||||
|           <ProtectedRouteWithLayout exact path={ROUTES.root} component={RedirectToDashboard} /> |           <ProtectedRouteWithLayout exact path={ROUTES.root} component={RedirectToDashboard} /> | ||||||
| @@ -92,7 +91,9 @@ const App = () => { | |||||||
|           <ProtectedRouteWithLayout exact path={ROUTES.addprofile} component={AddProfile} /> |           <ProtectedRouteWithLayout exact path={ROUTES.addprofile} component={AddProfile} /> | ||||||
|  |  | ||||||
|           <ProtectedRouteWithLayout exact path={ROUTES.alarms} component={Alarms} /> |           <ProtectedRouteWithLayout exact path={ROUTES.alarms} component={Alarms} /> | ||||||
|           <ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} /> |           {user?.id !== 0 && ( | ||||||
|  |             <ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} /> | ||||||
|  |           )} | ||||||
|           {user?.roles?.[0] === 'SuperUser' && ( |           {user?.roles?.[0] === 'SuperUser' && ( | ||||||
|             <ProtectedRouteWithLayout exact path={ROUTES.users} component={Accounts} /> |             <ProtectedRouteWithLayout exact path={ROUTES.users} component={Accounts} /> | ||||||
|           )} |           )} | ||||||
|   | |||||||
| @@ -20,8 +20,11 @@ function formatBytes(bytes, decimals = 2) { | |||||||
|   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() { | ||||||
| @@ -31,12 +34,27 @@ function trafficTooltipFormatter() { | |||||||
| } | } | ||||||
|  |  | ||||||
| const lineChartConfig = [ | const lineChartConfig = [ | ||||||
|   { key: 'inservicesAPs', title: 'Inservice APs (24 hours)' }, |   { | ||||||
|   { key: 'clientDevices', title: 'Client Devices (24 hours)' }, |     key: 'service', | ||||||
|  |     title: 'Inservice APs (24 hours)', | ||||||
|  |     lines: [{ key: 'inServiceAps', name: 'Inservice APs' }], | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     key: 'clientDevices', | ||||||
|  |     title: 'Client Devices (24 hours)', | ||||||
|  |     lines: [ | ||||||
|  |       { key: 'clientDevices2dot4GHz', name: '2.4GHz' }, | ||||||
|  |       { key: 'clientDevices5GHz', name: '5GHz' }, | ||||||
|  |     ], | ||||||
|  |   }, | ||||||
|   { |   { | ||||||
|     key: 'traffic', |     key: 'traffic', | ||||||
|     title: 'Traffic (24 hours)', |     title: 'Traffic - 5 min intervals (24 hours)', | ||||||
|     options: { formatter: trafficLabelFormatter, tooltipFormatter: trafficTooltipFormatter }, |     lines: [ | ||||||
|  |       { key: 'trafficBytesDownstreamData', name: 'Downstream' }, | ||||||
|  |       { key: 'trafficBytesUpstreamData', name: 'Upstream' }, | ||||||
|  |     ], | ||||||
|  |     options: { formatter: trafficLabelFormatter, trafficTooltipFormatter }, | ||||||
|   }, |   }, | ||||||
| ]; | ]; | ||||||
|  |  | ||||||
| @@ -55,32 +73,8 @@ const Dashboard = () => { | |||||||
|     variables: { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] }, |     variables: { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] }, | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   const [lineChartData, setLineChartData] = useState({ |   const [lineChartData, setLineChartData] = useState([]); | ||||||
|     inservicesAPs: { |   const [trafficBytesData, setTrafficBytesData] = useState(); | ||||||
|       key: 'Inservice APs', |  | ||||||
|       value: [], |  | ||||||
|     }, |  | ||||||
|     clientDevices: { |  | ||||||
|       is2dot4GHz: { |  | ||||||
|         key: USER_FRIENDLY_RADIOS.is2dot4GHz, |  | ||||||
|         value: [], |  | ||||||
|       }, |  | ||||||
|       is5GHz: { |  | ||||||
|         key: USER_FRIENDLY_RADIOS.is5GHz, |  | ||||||
|         value: [], |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|     traffic: { |  | ||||||
|       trafficBytesDownstream: { |  | ||||||
|         key: 'Down Stream', |  | ||||||
|         value: [], |  | ||||||
|       }, |  | ||||||
|       trafficBytesUpstream: { |  | ||||||
|         key: 'Up Stream', |  | ||||||
|         value: [], |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   const { loading: metricsLoading, error: metricsError, data: metricsData, fetchMore } = useQuery( |   const { loading: metricsLoading, error: metricsError, data: metricsData, fetchMore } = useQuery( | ||||||
|     FILTER_SYSTEM_EVENTS, |     FILTER_SYSTEM_EVENTS, | ||||||
| @@ -98,74 +92,65 @@ const Dashboard = () => { | |||||||
|  |  | ||||||
|   const formatLineChartData = (list = []) => { |   const formatLineChartData = (list = []) => { | ||||||
|     if (list.length) { |     if (list.length) { | ||||||
|       setLineChartData(prev => { |       const chartData = []; | ||||||
|         const inservicesAPs = []; |  | ||||||
|         const clientDevices2dot4GHz = []; |  | ||||||
|         const clientDevices5GHz = []; |  | ||||||
|         const trafficBytesDownstreamData = []; |  | ||||||
|         const trafficBytesUpstreamData = []; |  | ||||||
|         let totalDown = 0; |  | ||||||
|         let totalUp = 0; |  | ||||||
|  |  | ||||||
|         list.forEach( |       let inServiceAps = 0; | ||||||
|           ({ |       let clientDevices2dot4GHz = 0; | ||||||
|             eventTimestamp, |       let clientDevices5GHz = 0; | ||||||
|             details: { |       let trafficBytesDownstreamData = 0; | ||||||
|               payload: { |       let trafficBytesUpstreamData = 0; | ||||||
|                 details: { |       let totalDown = 0; | ||||||
|                   equipmentInServiceCount, |       let totalUp = 0; | ||||||
|                   associatedClientsCountPerRadio: radios, |  | ||||||
|                   trafficBytesDownstream, |       list.forEach( | ||||||
|                   trafficBytesUpstream, |         ({ | ||||||
|                 }, |           eventTimestamp, | ||||||
|  |           details: { | ||||||
|  |             payload: { | ||||||
|  |               details: { | ||||||
|  |                 equipmentInServiceCount, | ||||||
|  |                 associatedClientsCountPerRadio: radios, | ||||||
|  |                 trafficBytesDownstream, | ||||||
|  |                 trafficBytesUpstream, | ||||||
|               }, |               }, | ||||||
|             }, |             }, | ||||||
|           }) => { |           }, | ||||||
|             inservicesAPs.push([eventTimestamp, equipmentInServiceCount]); |         }) => { | ||||||
|  |           const timestamp = parseInt(eventTimestamp, 10); | ||||||
|  |           inServiceAps = 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 = radios.is2dot4GHz || 0; | ||||||
|             clientDevices5GHz.push([eventTimestamp, total5GHz || 0]); |           clientDevices5GHz = total5GHz || 0; | ||||||
|  |  | ||||||
|             trafficBytesDownstreamData.push([eventTimestamp, trafficBytesDownstream || 0]); |           trafficBytesDownstreamData = (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0; | ||||||
|             trafficBytesUpstreamData.push([eventTimestamp, trafficBytesUpstream || 0]); |           trafficBytesUpstreamData = (trafficBytesUpstream > 0 && trafficBytesUpstream) || 0; | ||||||
|  |  | ||||||
|             totalDown += trafficBytesDownstream || 0; |           totalDown += (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0; | ||||||
|             totalUp += trafficBytesUpstream || 0; |           totalUp += (trafficBytesUpstream > 0 && trafficBytesUpstream) || 0; | ||||||
|           } |           chartData.push({ | ||||||
|         ); |             timestamp, | ||||||
|  |             inServiceAps, | ||||||
|  |             clientDevices2dot4GHz, | ||||||
|  |             clientDevices5GHz, | ||||||
|  |             trafficBytesDownstreamData, | ||||||
|  |             trafficBytesUpstreamData, | ||||||
|  |           }); | ||||||
|  |         } | ||||||
|  |       ); | ||||||
|  |  | ||||||
|  |       setTrafficBytesData(prev => { | ||||||
|         return { |         return { | ||||||
|           inservicesAPs: { |           totalUpstreamTraffic: (prev?.totalUpstreamTraffic || 0) + totalUp, | ||||||
|             ...prev.inservicesAPs, |           totalDownstreamTraffic: (prev?.totalDownstreamTraffic || 0) + totalDown, | ||||||
|             value: [...prev.inservicesAPs.value, ...inservicesAPs], |  | ||||||
|           }, |  | ||||||
|           clientDevices: { |  | ||||||
|             is2dot4GHz: { |  | ||||||
|               ...prev.clientDevices.is2dot4GHz, |  | ||||||
|               value: [...prev.clientDevices.is2dot4GHz.value, ...clientDevices2dot4GHz], |  | ||||||
|             }, |  | ||||||
|             is5GHz: { |  | ||||||
|               ...prev.clientDevices.is5GHz, |  | ||||||
|               value: [...prev.clientDevices.is5GHz.value, ...clientDevices5GHz], |  | ||||||
|             }, |  | ||||||
|           }, |  | ||||||
|           traffic: { |  | ||||||
|             trafficBytesDownstream: { |  | ||||||
|               ...prev.traffic.trafficBytesDownstream, |  | ||||||
|               value: [...prev.traffic.trafficBytesDownstream.value, ...trafficBytesDownstreamData], |  | ||||||
|             }, |  | ||||||
|             trafficBytesUpstream: { |  | ||||||
|               ...prev.traffic.trafficBytesUpstream, |  | ||||||
|               value: [...prev.traffic.trafficBytesUpstream.value, ...trafficBytesUpstreamData], |  | ||||||
|             }, |  | ||||||
|           }, |  | ||||||
|           totalDownstreamTraffic: totalDown, |  | ||||||
|           totalUpstreamTraffic: totalUp, |  | ||||||
|         }; |         }; | ||||||
|       }); |       }); | ||||||
|  |  | ||||||
|  |       setLineChartData(prev => { | ||||||
|  |         return [...prev, ...chartData]; | ||||||
|  |       }); | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
| @@ -265,8 +250,8 @@ const Dashboard = () => { | |||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|           title: 'Usage Information (24 hours)', |           title: 'Usage Information (24 hours)', | ||||||
|           'Total Traffic (US)': formatBytes(lineChartData?.totalUpstreamTraffic), |           'Total Traffic (Downstream)': formatBytes(trafficBytesData?.totalDownstreamTraffic), | ||||||
|           'Total Traffic (DS)': formatBytes(lineChartData?.totalDownstreamTraffic), |           'Total Traffic (Upstream)': formatBytes(trafficBytesData?.totalUpstreamTraffic), | ||||||
|         }, |         }, | ||||||
|       ]} |       ]} | ||||||
|       pieChartDetails={pieChartsData} |       pieChartDetails={pieChartsData} | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ import { removeItem } from 'utils/localStorage'; | |||||||
| import UserContext from 'contexts/UserContext'; | import UserContext from 'contexts/UserContext'; | ||||||
|  |  | ||||||
| const MasterLayout = ({ children }) => { | const MasterLayout = ({ children }) => { | ||||||
|   const { roles, customerId } = useContext(UserContext); |   const { roles, customerId, id: currentUserId } = useContext(UserContext); | ||||||
|  |  | ||||||
|   const client = useApolloClient(); |   const client = useApolloClient(); | ||||||
|   const location = useLocation(); |   const location = useLocation(); | ||||||
| @@ -56,11 +56,15 @@ const MasterLayout = ({ children }) => { | |||||||
|       key: 'settings', |       key: 'settings', | ||||||
|       text: 'Settings', |       text: 'Settings', | ||||||
|       children: [ |       children: [ | ||||||
|         { |         ...(currentUserId !== 0 | ||||||
|           key: 'editAccount', |           ? [ | ||||||
|           path: ROUTES.account, |               { | ||||||
|           text: 'Edit Account', |                 key: 'editAccount', | ||||||
|         }, |                 path: ROUTES.account, | ||||||
|  |                 text: 'Edit Account', | ||||||
|  |               }, | ||||||
|  |             ] | ||||||
|  |           : []), | ||||||
|         { |         { | ||||||
|           key: 'logout', |           key: 'logout', | ||||||
|           path: ROUTES.root, |           path: ROUTES.root, | ||||||
| @@ -90,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> | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| import React, { useContext } from 'react'; | import React, { useContext } from 'react'; | ||||||
| import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||||
| import { useParams, useHistory } from 'react-router-dom'; | import { useParams, useHistory } from 'react-router-dom'; | ||||||
| import { useQuery, useMutation, gql } from '@apollo/client'; | import { useQuery, useMutation } from '@apollo/client'; | ||||||
| import { Alert, notification } from 'antd'; | import { Alert, notification } from 'antd'; | ||||||
| import moment from 'moment'; | import moment from 'moment'; | ||||||
| import { | import { | ||||||
| @@ -9,126 +9,22 @@ import { | |||||||
|   Loading, |   Loading, | ||||||
| } from '@tip-wlan/wlan-cloud-ui-library'; | } from '@tip-wlan/wlan-cloud-ui-library'; | ||||||
|  |  | ||||||
| import { FILTER_SERVICE_METRICS, GET_ALL_FIRMWARE, GET_ALL_PROFILES } from 'graphql/queries'; |  | ||||||
| import { | import { | ||||||
|  |   GET_EQUIPMENT, | ||||||
|  |   FILTER_SERVICE_METRICS, | ||||||
|  |   GET_ALL_FIRMWARE, | ||||||
|  |   GET_ALL_PROFILES, | ||||||
|  | } from 'graphql/queries'; | ||||||
|  | import { | ||||||
|  |   UPDATE_EQUIPMENT, | ||||||
|  |   DELETE_EQUIPMENT, | ||||||
|   UPDATE_EQUIPMENT_FIRMWARE, |   UPDATE_EQUIPMENT_FIRMWARE, | ||||||
|   REQUEST_EQUIPMENT_SWITCH_BANK, |   REQUEST_EQUIPMENT_SWITCH_BANK, | ||||||
|   REQUEST_EQUIPMENT_REBOOT, |   REQUEST_EQUIPMENT_REBOOT, | ||||||
| } from 'graphql/mutations'; | } from 'graphql/mutations'; | ||||||
| import { updateQueryGetAllProfiles } from 'graphql/functions'; | 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 { |  | ||||||
|         id |  | ||||||
|         name |  | ||||||
|         childProfiles { |  | ||||||
|           id |  | ||||||
|           name |  | ||||||
|           details |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|       baseMacAddress |  | ||||||
|       manufacturer |  | ||||||
|       status { |  | ||||||
|         firmware { |  | ||||||
|           detailsJSON |  | ||||||
|         } |  | ||||||
|         protocol { |  | ||||||
|           detailsJSON |  | ||||||
|         } |  | ||||||
|         radioUtilization { |  | ||||||
|           detailsJSON |  | ||||||
|         } |  | ||||||
|         clientDetails { |  | ||||||
|           detailsJSON |  | ||||||
|           details { |  | ||||||
|             numClientsPerRadio |  | ||||||
|           } |  | ||||||
|         } |  | ||||||
|         osPerformance { |  | ||||||
|           detailsJSON |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|       model |  | ||||||
|       alarmsCount |  | ||||||
|       alarms { |  | ||||||
|         severity |  | ||||||
|         alarmCode |  | ||||||
|         details |  | ||||||
|         createdTimestamp |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| `; |  | ||||||
|  |  | ||||||
| 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 |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| `; |  | ||||||
|  |  | ||||||
| const DELETE_EQUIPMENT = gql` |  | ||||||
|   mutation DeleteEquipment($id: ID!) { |  | ||||||
|     deleteEquipment(id: $id) { |  | ||||||
|       id |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| `; |  | ||||||
|  |  | ||||||
| const toTime = moment(); | const toTime = moment(); | ||||||
| const fromTime = moment().subtract(1, 'hour'); | const fromTime = moment().subtract(1, 'hour'); | ||||||
|  |  | ||||||
| @@ -142,6 +38,7 @@ const AccessPointDetails = ({ locations }) => { | |||||||
|       id, |       id, | ||||||
|     }, |     }, | ||||||
|     fetchPolicy: 'network-only', |     fetchPolicy: 'network-only', | ||||||
|  |     errorPolicy: 'all', | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   const { data: dataFirmware, error: errorFirmware, loading: loadingFirmware } = useQuery( |   const { data: dataFirmware, error: errorFirmware, loading: loadingFirmware } = useQuery( | ||||||
| @@ -149,9 +46,9 @@ const AccessPointDetails = ({ locations }) => { | |||||||
|     { |     { | ||||||
|       skip: !data?.getEquipment?.model, |       skip: !data?.getEquipment?.model, | ||||||
|       variables: { modelId: data?.getEquipment?.model }, |       variables: { modelId: data?.getEquipment?.model }, | ||||||
|  |       errorPolicy: 'all', | ||||||
|     } |     } | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|   const { |   const { | ||||||
|     data: dataProfiles, |     data: dataProfiles, | ||||||
|     error: errorProfiles, |     error: errorProfiles, | ||||||
| @@ -166,6 +63,7 @@ const AccessPointDetails = ({ locations }) => { | |||||||
|     }`), |     }`), | ||||||
|     { |     { | ||||||
|       variables: { customerId, type: 'equipment_ap' }, |       variables: { customerId, type: 'equipment_ap' }, | ||||||
|  |       fetchPolicy: 'network-only', | ||||||
|     } |     } | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
| @@ -173,7 +71,7 @@ const AccessPointDetails = ({ locations }) => { | |||||||
|     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, | ||||||
| @@ -193,23 +91,46 @@ const AccessPointDetails = ({ locations }) => { | |||||||
|  |  | ||||||
|   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, | ||||||
| @@ -219,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(() => { | ||||||
| @@ -327,28 +249,14 @@ const AccessPointDetails = ({ locations }) => { | |||||||
|       ); |       ); | ||||||
|  |  | ||||||
|   const handleFetchProfiles = e => { |   const handleFetchProfiles = e => { | ||||||
|     if (dataProfiles.getAllProfiles.context.lastPage) { |     fetchMoreProfiles(e, dataProfiles, fetchMore); | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |  | ||||||
|     const { target } = e; |  | ||||||
|  |  | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMore({ |  | ||||||
|         variables: { context: { ...dataProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   if (loading) { |   if (loading) { | ||||||
|     return <Loading />; |     return <Loading />; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if (error) { |   if (error && !data?.getEquipment) { | ||||||
|     return ( |     return ( | ||||||
|       <Alert |       <Alert | ||||||
|         message="Error" |         message="Error" | ||||||
|   | |||||||
| @@ -89,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', | ||||||
|   | |||||||
| @@ -1,9 +1,12 @@ | |||||||
| import React, { useContext, useMemo } from 'react'; | import React, { useContext, useMemo, useEffect } 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/client'; | import { useLazyQuery, useMutation } from '@apollo/client'; | ||||||
| import { BulkEditAccessPoints, Loading } from '@tip-wlan/wlan-cloud-ui-library'; | import { BulkEditAccessPoints, sortRadioTypes } from '@tip-wlan/wlan-cloud-ui-library'; | ||||||
|  | import { USER_FRIENDLY_RADIOS } from 'constants/index'; | ||||||
|  |  | ||||||
|  | import { getBreadcrumbPath, getLocationPath } from 'utils/locations'; | ||||||
|  |  | ||||||
| import { FILTER_EQUIPMENT_BULK_EDIT_APS } from 'graphql/queries'; | import { FILTER_EQUIPMENT_BULK_EDIT_APS } from 'graphql/queries'; | ||||||
| import { UPDATE_EQUIPMENT_BULK } from 'graphql/mutations'; | import { UPDATE_EQUIPMENT_BULK } from 'graphql/mutations'; | ||||||
| @@ -25,243 +28,200 @@ 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: 'Radios', | ||||||
|     dataIndex: 'channel', |     dataIndex: 'radioMap', | ||||||
|     key: 'channel', |     width: 150, | ||||||
|  |     render: text => renderTableCell(text.map(i => USER_FRIENDLY_RADIOS[i])), | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     title: 'Manual Active Channel', | ||||||
|  |     dataIndex: 'manualChannelNumber', | ||||||
|  |     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, | ||||||
|   }, |   }, | ||||||
| ]; | ]; | ||||||
|  |  | ||||||
| const getBreadcrumbPath = (id, locations) => { | const getRadioDetails = (radioDetails, type) => { | ||||||
|   const locationsPath = []; |   const sortedRadios = sortRadioTypes(Object.keys(radioDetails?.radioMap || {})); | ||||||
|   const treeRecurse = (parentNodeId, node) => { |  | ||||||
|     if (node.id === parentNodeId) { |  | ||||||
|       locationsPath.unshift(node); |  | ||||||
|       return node; |  | ||||||
|     } |  | ||||||
|     if (node.children) { |  | ||||||
|       let parent; |  | ||||||
|       node.children.some(i => { |  | ||||||
|         parent = treeRecurse(parentNodeId, i); |  | ||||||
|         return parent; |  | ||||||
|       }); |  | ||||||
|       if (parent) { |  | ||||||
|         locationsPath.unshift(node); |  | ||||||
|       } |  | ||||||
|       return parent; |  | ||||||
|     } |  | ||||||
|     return null; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   treeRecurse(id, { |   if (type === 'manualChannelNumber') { | ||||||
|     id: 0, |     return sortedRadios.map(i => radioDetails.radioMap[i]?.manualChannelNumber); | ||||||
|     children: locations, |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   return locationsPath; |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| const getLocationPath = (selectedId, locations) => { |  | ||||||
|   const locationsPath = []; |  | ||||||
|  |  | ||||||
|   const treeRecurse = (parentNodeId, node) => { |  | ||||||
|     if (node.id === parentNodeId) { |  | ||||||
|       locationsPath.unshift(node.id); |  | ||||||
|  |  | ||||||
|       if (node.children) { |  | ||||||
|         const flatten = children => { |  | ||||||
|           children.forEach(i => { |  | ||||||
|             locationsPath.unshift(i.id); |  | ||||||
|             if (i.children) { |  | ||||||
|               flatten(i.children); |  | ||||||
|             } |  | ||||||
|           }); |  | ||||||
|         }; |  | ||||||
|  |  | ||||||
|         flatten(node.children); |  | ||||||
|       } |  | ||||||
|       return node; |  | ||||||
|     } |  | ||||||
|     if (node.children) { |  | ||||||
|       let parent; |  | ||||||
|       node.children.some(i => { |  | ||||||
|         parent = treeRecurse(parentNodeId, i); |  | ||||||
|         return parent; |  | ||||||
|       }); |  | ||||||
|       return parent; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return null; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   if (selectedId) { |  | ||||||
|     treeRecurse(selectedId, { id: 0, children: locations }); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   return locationsPath; |   if (type === 'manualBackupChannelNumber') { | ||||||
|  |     return sortedRadios.map(i => radioDetails.radioMap[i]?.manualBackupChannelNumber); | ||||||
|  |   } | ||||||
|  |   if (type === 'snrDrop') { | ||||||
|  |     return sortedRadios.map( | ||||||
|  |       i => radioDetails.advancedRadioMap[i]?.bestApSettings?.value?.dropInSnrPercentage | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  |   if (type === 'allowedChannels') { | ||||||
|  |     return sortedRadios.map(i => radioDetails.radioMap[i]?.allowedChannelsPowerLevels); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if (type === 'minLoad') { | ||||||
|  |     return sortedRadios.map( | ||||||
|  |       i => radioDetails.advancedRadioMap[i]?.bestApSettings?.value?.minLoadFactor | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if (type === 'cellSize') { | ||||||
|  |     return sortedRadios.map(i => radioDetails.radioMap[i]?.rxCellSizeDb?.value); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if (type === 'probeResponseThreshold') { | ||||||
|  |     return sortedRadios.map(i => radioDetails.radioMap[i]?.probeResponseThresholdDb?.value); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if (type === 'clientDisconnectThreshold') { | ||||||
|  |     return sortedRadios.map(i => radioDetails.radioMap[i]?.clientDisconnectThresholdDb?.value); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return sortedRadios; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | const formatRadioFrequencies = ({ | ||||||
|  |   manualChannelNumber, | ||||||
|  |   manualBackupChannelNumber, | ||||||
|  |   snrDrop, | ||||||
|  |   minLoad, | ||||||
|  |   cellSize, | ||||||
|  |   probeResponseThreshold, | ||||||
|  |   clientDisconnectThreshold, | ||||||
|  |   radioMap = [], | ||||||
|  | }) => { | ||||||
|  |   const frequencies = {}; | ||||||
|  |   radioMap.forEach((i, index) => { | ||||||
|  |     frequencies[i] = { | ||||||
|  |       channelNumber: manualChannelNumber[index], | ||||||
|  |       backupChannelNumber: manualBackupChannelNumber[index], | ||||||
|  |       dropInSnrPercentage: snrDrop[index], | ||||||
|  |       minLoadFactor: minLoad[index], | ||||||
|  |       rxCellSizeDb: { | ||||||
|  |         auto: true, | ||||||
|  |         value: cellSize[index], | ||||||
|  |       }, | ||||||
|  |       probeResponseThresholdDb: { | ||||||
|  |         auto: true, | ||||||
|  |         value: probeResponseThreshold[index], | ||||||
|  |       }, | ||||||
|  |       clientDisconnectThresholdDb: { | ||||||
|  |         auto: true, | ||||||
|  |         value: clientDisconnectThreshold[index], | ||||||
|  |       }, | ||||||
|  |     }; | ||||||
|  |   }); | ||||||
|  |   return frequencies; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| const BulkEditAPs = ({ locations, checkedLocations }) => { | const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||||
|   const { id } = useParams(); |   const { id } = useParams(); | ||||||
|   const { customerId } = useContext(UserContext); |   const { customerId } = useContext(UserContext); | ||||||
|  |  | ||||||
|   const locationIds = useMemo(() => { |   const locationIds = useMemo(() => { | ||||||
|     const locationPath = getLocationPath(id, locations); |     const locationPath = getLocationPath(id, locations); | ||||||
|     return locationPath.filter(f => checkedLocations.includes(f)); |     return locationPath.filter(f => checkedLocations.includes(f)); | ||||||
|   }, [id, locations, checkedLocations]); |   }, [id, locations, checkedLocations]); | ||||||
|  |  | ||||||
|   const { |   const [ | ||||||
|     loading: filterEquipmentLoading, |     filterEquipment, | ||||||
|     error: filterEquipmentError, |     { | ||||||
|     refetch, |       loading: filterEquipmentLoading, | ||||||
|     data: equipData, |       error: filterEquipmentError, | ||||||
|     fetchMore, |       refetch, | ||||||
|   } = useQuery(FILTER_EQUIPMENT_BULK_EDIT_APS, { |       data: equipData, | ||||||
|     variables: { customerId, locationIds, equipmentType: 'AP' }, |       fetchMore, | ||||||
|  |     }, | ||||||
|  |   ] = useLazyQuery(FILTER_EQUIPMENT_BULK_EDIT_APS, { | ||||||
|  |     errorPolicy: 'all', | ||||||
|  |     fetchPolicy: 'cache-first', | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|  |   const fetchFilterEquipment = async () => { | ||||||
|  |     filterEquipment({ | ||||||
|  |       variables: { | ||||||
|  |         customerId, | ||||||
|  |         locationIds, | ||||||
|  |         equipmentType: 'AP', | ||||||
|  |       }, | ||||||
|  |     }); | ||||||
|  |   }; | ||||||
|   const [updateEquipmentBulk] = useMutation(UPDATE_EQUIPMENT_BULK); |   const [updateEquipmentBulk] = useMutation(UPDATE_EQUIPMENT_BULK); | ||||||
|  |  | ||||||
|   const getRadioDetails = (radioDetails, type) => { |   const formattedTableData = useMemo( | ||||||
|     if (type === 'cellSize') { |     () => | ||||||
|       const cellSizeValues = []; |       equipData?.filterEquipment?.items?.map(({ id: key, name, details = {} }) => ({ | ||||||
|       Object.keys(radioDetails.radioMap).map(i => { |  | ||||||
|         return cellSizeValues.push(radioDetails.radioMap[i].rxCellSizeDb.value); |  | ||||||
|       }); |  | ||||||
|       return cellSizeValues; |  | ||||||
|     } |  | ||||||
|     if (type === 'probeResponseThreshold') { |  | ||||||
|       const probeResponseThresholdValues = []; |  | ||||||
|       Object.keys(radioDetails.radioMap).map(i => { |  | ||||||
|         return probeResponseThresholdValues.push( |  | ||||||
|           radioDetails.radioMap[i].probeResponseThresholdDb.value |  | ||||||
|         ); |  | ||||||
|       }); |  | ||||||
|       return probeResponseThresholdValues; |  | ||||||
|     } |  | ||||||
|     if (type === 'clientDisconnectThreshold') { |  | ||||||
|       const clientDisconnectThresholdValues = []; |  | ||||||
|       Object.keys(radioDetails.radioMap).map(i => { |  | ||||||
|         return clientDisconnectThresholdValues.push( |  | ||||||
|           radioDetails.radioMap[i].clientDisconnectThresholdDb.value |  | ||||||
|         ); |  | ||||||
|       }); |  | ||||||
|       return clientDisconnectThresholdValues; |  | ||||||
|     } |  | ||||||
|     if (type === 'snrDrop') { |  | ||||||
|       const snrDropValues = []; |  | ||||||
|       Object.keys(radioDetails.advancedRadioMap).map(i => { |  | ||||||
|         return snrDropValues.push( |  | ||||||
|           radioDetails.advancedRadioMap[i].bestApSettings.dropInSnrPercentage |  | ||||||
|         ); |  | ||||||
|       }); |  | ||||||
|       return snrDropValues; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     const minLoadValue = []; |  | ||||||
|     Object.keys(radioDetails.advancedRadioMap).map(i => { |  | ||||||
|       return minLoadValue.push(radioDetails.advancedRadioMap[i].bestApSettings.minLoadFactor); |  | ||||||
|     }); |  | ||||||
|     return minLoadValue; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const setAccessPointsBulkEditTableData = (dataSource = []) => { |  | ||||||
|     const tableData = dataSource.items.map(({ id: key, name, channel, details }) => { |  | ||||||
|       return { |  | ||||||
|         key, |         key, | ||||||
|         id: key, |         id: key, | ||||||
|         name, |         name, | ||||||
|         channel, |         manualChannelNumber: getRadioDetails(details, 'manualChannelNumber'), | ||||||
|  |         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: getRadioDetails(details, 'radioMap'), | ||||||
|     }); |         allowedChannels: getRadioDetails(details, 'allowedChannels'), | ||||||
|     return tableData; |       })), | ||||||
|   }; |     [equipData?.filterEquipment?.items] | ||||||
|  |   ); | ||||||
|   const setUpdatedBulkEditTableData = ( |  | ||||||
|     equipmentId, |  | ||||||
|     channel, |  | ||||||
|     cellSize, |  | ||||||
|     probeResponseThreshold, |  | ||||||
|     clientDisconnectThreshold, |  | ||||||
|     snrDrop, |  | ||||||
|     minLoad, |  | ||||||
|     dataSource = [] |  | ||||||
|   ) => { |  | ||||||
|     const updatedItems = []; |  | ||||||
|     let dropInSnrPercentage; |  | ||||||
|     let minLoadFactor; |  | ||||||
|     dataSource.items.forEach(({ id: itemId, details }) => { |  | ||||||
|       if (equipmentId === itemId) { |  | ||||||
|         Object.keys(details.radioMap).forEach((i, dataIndex) => { |  | ||||||
|           const frequencies = {}; |  | ||||||
|           dropInSnrPercentage = snrDrop[dataIndex]; |  | ||||||
|           minLoadFactor = minLoad[dataIndex]; |  | ||||||
|  |  | ||||||
|           frequencies[`${i}`] = { |  | ||||||
|             channelNumber: channel[dataIndex], |  | ||||||
|             rxCellSizeDb: { |  | ||||||
|               auto: true, |  | ||||||
|               value: cellSize[dataIndex], |  | ||||||
|             }, |  | ||||||
|             probeResponseThresholdDb: { |  | ||||||
|               auto: true, |  | ||||||
|               value: probeResponseThreshold[dataIndex], |  | ||||||
|             }, |  | ||||||
|             clientDisconnectThresholdDb: { |  | ||||||
|               auto: true, |  | ||||||
|               value: clientDisconnectThreshold[dataIndex], |  | ||||||
|             }, |  | ||||||
|             dropInSnrPercentage, |  | ||||||
|             minLoadFactor, |  | ||||||
|           }; |  | ||||||
|           updatedItems.push(frequencies); |  | ||||||
|         }); |  | ||||||
|       } |  | ||||||
|     }); |  | ||||||
|     return updatedItems; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const updateEquipments = editedRowsArr => { |   const updateEquipments = editedRowsArr => { | ||||||
|     updateEquipmentBulk({ |     updateEquipmentBulk({ | ||||||
| @@ -286,42 +246,13 @@ 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( |       return editedRowsArr.push({ | ||||||
|         ({ |         equipmentId: updatedRows[key].id, | ||||||
|           id: equipmentId, |         perRadioDetails: formatRadioFrequencies(updatedRows[key]), | ||||||
|           channel, |       }); | ||||||
|           cellSize, |     }); | ||||||
|           probeResponseThreshold, |     updateEquipments(editedRowsArr); | ||||||
|           clientDisconnectThreshold, |  | ||||||
|           snrDrop, |  | ||||||
|           minLoad, |  | ||||||
|         }) => { |  | ||||||
|           const updatedEuips = setUpdatedBulkEditTableData( |  | ||||||
|             equipmentId, |  | ||||||
|             channel, |  | ||||||
|             cellSize, |  | ||||||
|             probeResponseThreshold, |  | ||||||
|             clientDisconnectThreshold, |  | ||||||
|             snrDrop, |  | ||||||
|             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 handleLoadMore = () => { |   const handleLoadMore = () => { | ||||||
| @@ -343,33 +274,30 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | |||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   if (filterEquipmentLoading) { |   useEffect(() => { | ||||||
|     return <Loading />; |     fetchFilterEquipment(); | ||||||
|   } |   }, [locationIds]); | ||||||
|  |  | ||||||
|   if (filterEquipmentError) { |   if (filterEquipmentError) { | ||||||
|     return ( |     return ( | ||||||
|       <Alert message="Error" description="Failed to load equipments data." type="error" showIcon /> |       <Alert | ||||||
|  |         message="Error" | ||||||
|  |         description="Failed to load equipment(s) data." | ||||||
|  |         type="error" | ||||||
|  |         showIcon | ||||||
|  |       /> | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|     <BulkEditAccessPoints |     <BulkEditAccessPoints | ||||||
|       tableColumns={accessPointsChannelTableColumns} |       tableColumns={accessPointsChannelTableColumns} | ||||||
|       tableData={ |       tableData={formattedTableData} | ||||||
|         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)} | ||||||
|  |       loading={filterEquipmentLoading} | ||||||
|     /> |     /> | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -1,5 +1,4 @@ | |||||||
| .tabColumn { | .tabColumn { | ||||||
|   display: flex; |   display: flex; | ||||||
|   flex-direction: column; |   flex-direction: column; | ||||||
|   padding: 0 30px; |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -4,11 +4,11 @@ import { useQuery, useMutation, gql } from '@apollo/client'; | |||||||
| import { Alert, notification } from 'antd'; | import { Alert, notification } from 'antd'; | ||||||
| import { ProfileDetails as ProfileDetailsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; | import { ProfileDetails as ProfileDetailsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; | ||||||
|  |  | ||||||
| import { ROUTES } from 'constants/index'; | 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 { updateQueryGetAllProfiles } from 'graphql/functions'; | import { getItem } from 'utils/localStorage'; | ||||||
|  |  | ||||||
| const GET_PROFILE = gql` | const GET_PROFILE = gql` | ||||||
|   query GetProfile($id: ID!) { |   query GetProfile($id: ID!) { | ||||||
| @@ -23,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 | ||||||
| @@ -75,6 +85,8 @@ 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', |     fetchPolicy: 'network-only', | ||||||
| @@ -82,12 +94,14 @@ const ProfileDetails = () => { | |||||||
|  |  | ||||||
|   const { data: ssidProfiles, fetchMore } = 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( |   const { data: radiusProfiles, fetchMore: fetchMoreRadiusProfiles } = useQuery( | ||||||
|     GET_ALL_PROFILES(), |     GET_ALL_PROFILES(), | ||||||
|     { |     { | ||||||
|       variables: { customerId, type: 'radius' }, |       variables: { customerId, type: 'radius' }, | ||||||
|  |       fetchPolicy: 'network-only', | ||||||
|     } |     } | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
| @@ -95,17 +109,20 @@ const ProfileDetails = () => { | |||||||
|     GET_ALL_PROFILES(), |     GET_ALL_PROFILES(), | ||||||
|     { |     { | ||||||
|       variables: { customerId, type: 'captive_portal' }, |       variables: { customerId, type: 'captive_portal' }, | ||||||
|  |       fetchPolicy: 'network-only', | ||||||
|     } |     } | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|   const { data: venueProfiles, fetchMore: fetchMoreVenueProfiles } = useQuery(GET_ALL_PROFILES(), { |   const { data: venueProfiles, fetchMore: fetchMoreVenueProfiles } = useQuery(GET_ALL_PROFILES(), { | ||||||
|     variables: { customerId, type: 'passpoint_venue' }, |     variables: { customerId, type: 'passpoint_venue' }, | ||||||
|  |     fetchPolicy: 'network-only', | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   const { data: operatorProfiles, fetchMore: fetchMoreOperatorProfiles } = useQuery( |   const { data: operatorProfiles, fetchMore: fetchMoreOperatorProfiles } = useQuery( | ||||||
|     GET_ALL_PROFILES(), |     GET_ALL_PROFILES(), | ||||||
|     { |     { | ||||||
|       variables: { customerId, type: 'passpoint_operator' }, |       variables: { customerId, type: 'passpoint_operator' }, | ||||||
|  |       fetchPolicy: 'network-only', | ||||||
|     } |     } | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
| @@ -113,18 +130,18 @@ const ProfileDetails = () => { | |||||||
|     GET_ALL_PROFILES(), |     GET_ALL_PROFILES(), | ||||||
|     { |     { | ||||||
|       variables: { customerId, type: 'passpoint_osu_id_provider' }, |       variables: { customerId, type: 'passpoint_osu_id_provider' }, | ||||||
|  |       fetchPolicy: 'network-only', | ||||||
|     } |     } | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|   const { data: rfProfiles, fetchMore: fetchMoreRfProfiles } = useQuery(GET_ALL_PROFILES(), { |   const { data: rfProfiles, fetchMore: fetchMoreRfProfiles } = useQuery(GET_ALL_PROFILES(), { | ||||||
|     variables: { customerId, type: 'rf' }, |     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(() => { | ||||||
| @@ -170,145 +187,89 @@ 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({ | ||||||
|   const handleFetchProfiles = e => { |             message: 'Error', | ||||||
|     if (ssidProfiles.getAllProfiles.context.lastPage) { |             description: 'File could not be uploaded.', | ||||||
|       return false; |           }); | ||||||
|     } |         }); | ||||||
|  |     } else { | ||||||
|     e.persist(); |       notification.error({ | ||||||
|     const { target } = e; |         message: 'Error', | ||||||
|  |         description: 'File could not be uploaded.', | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMore({ |  | ||||||
|         variables: { context: { ...ssidProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   const handleFetchRadiusProfiles = e => { |   const handleDownloadFile = async name => { | ||||||
|     if (radiusProfiles.getAllProfiles.context.lastPage) { |     const token = getItem(AUTH_TOKEN); | ||||||
|       return false; |     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({ | ||||||
|     e.persist(); |       message: 'Error', | ||||||
|     const { target } = e; |       description: 'File could not be retrieved.', | ||||||
|  |     }); | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMoreRadiusProfiles({ |  | ||||||
|         variables: { context: { ...radiusProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   const handleFetchCaptiveProfiles = e => { |   const handleFetchMoreProfiles = (e, key) => { | ||||||
|     if (captiveProfiles.getAllProfiles.context.lastPage) { |     if (key === 'radius') fetchMoreProfiles(e, radiusProfiles, fetchMoreRadiusProfiles); | ||||||
|       return false; |     else if (key === 'captive_portal') | ||||||
|     } |       fetchMoreProfiles(e, captiveProfiles, fetchMoreCaptiveProfiles); | ||||||
|  |     else if (key === 'rf') fetchMoreProfiles(e, rfProfiles, fetchMoreRfProfiles); | ||||||
|     e.persist(); |     else if (key === 'passpoint_venue') fetchMoreProfiles(e, venueProfiles, fetchMoreVenueProfiles); | ||||||
|     const { target } = e; |     else if (key === 'passpoint_operator') | ||||||
|  |       fetchMoreProfiles(e, operatorProfiles, fetchMoreOperatorProfiles); | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |     else if (key === 'passpoint_osu_id_provider') | ||||||
|       fetchMoreCaptiveProfiles({ |       fetchMoreProfiles(e, idProviderProfiles, fetchMoreIdProviderProfiles); | ||||||
|         variables: { context: { ...captiveProfiles.getAllProfiles.context } }, |     else fetchMoreProfiles(e, ssidProfiles, fetchMore); | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const handleFetchVenueProfiles = e => { |  | ||||||
|     if (venueProfiles.getAllProfiles.context.lastPage) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |  | ||||||
|     const { target } = e; |  | ||||||
|  |  | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMoreVenueProfiles({ |  | ||||||
|         variables: { context: { ...venueProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const handleFetchRfProfiles = e => { |  | ||||||
|     if (rfProfiles.getAllProfiles.context.lastPage) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |  | ||||||
|     const { target } = e; |  | ||||||
|  |  | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMoreRfProfiles({ |  | ||||||
|         variables: { context: { ...rfProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const handleFetchOperatorProfiles = e => { |  | ||||||
|     if (operatorProfiles.getAllProfiles.context.lastPage) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |  | ||||||
|     const { target } = e; |  | ||||||
|  |  | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMoreOperatorProfiles({ |  | ||||||
|         variables: { context: { ...operatorProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   const handleFetchIdProviderProfiles = e => { |  | ||||||
|     if (idProviderProfiles.getAllProfiles.context.lastPage) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     e.persist(); |  | ||||||
|     const { target } = e; |  | ||||||
|  |  | ||||||
|     if (target.scrollTop + target.offsetHeight === target.scrollHeight) { |  | ||||||
|       fetchMoreIdProviderProfiles({ |  | ||||||
|         variables: { context: { ...idProviderProfiles.getAllProfiles.context } }, |  | ||||||
|         updateQuery: updateQueryGetAllProfiles, |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   if (loading) { |   if (loading) { | ||||||
| @@ -341,14 +302,11 @@ const ProfileDetails = () => { | |||||||
|       venueProfiles={venueProfiles?.getAllProfiles?.items} |       venueProfiles={venueProfiles?.getAllProfiles?.items} | ||||||
|       operatorProfiles={operatorProfiles?.getAllProfiles?.items} |       operatorProfiles={operatorProfiles?.getAllProfiles?.items} | ||||||
|       idProviderProfiles={idProviderProfiles?.getAllProfiles?.items} |       idProviderProfiles={idProviderProfiles?.getAllProfiles?.items} | ||||||
|  |       associatedSsidProfiles={data.getProfile?.associatedSsidProfiles} | ||||||
|  |       osuSsidProfile={data.getProfile?.osuSsidProfile} | ||||||
|       fileUpload={handleFileUpload} |       fileUpload={handleFileUpload} | ||||||
|       onFetchMoreProfiles={handleFetchProfiles} |       onFetchMoreProfiles={handleFetchMoreProfiles} | ||||||
|       onFetchMoreRfProfiles={handleFetchRfProfiles} |       onDownloadFile={handleDownloadFile} | ||||||
|       onFetchMoreRadiusProfiles={handleFetchRadiusProfiles} |  | ||||||
|       onFetchMoreCaptiveProfiles={handleFetchCaptiveProfiles} |  | ||||||
|       onFetchMoreVenueProfiles={handleFetchVenueProfiles} |  | ||||||
|       onFetchMoreOperatorProfiles={handleFetchOperatorProfiles} |  | ||||||
|       onFetchMoreIdProviderProfiles={handleFetchIdProviderProfiles} |  | ||||||
|     /> |     /> | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| import React, { useContext } from 'react'; | import React, { useContext, useMemo } from 'react'; | ||||||
| import { useQuery, useMutation } from '@apollo/client'; | 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'; | ||||||
| @@ -6,6 +6,8 @@ import { AutoProvision as AutoProvisionPage, Loading } from '@tip-wlan/wlan-clou | |||||||
| 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'; | ||||||
|  | import { formatLocations } from 'utils/locations'; | ||||||
|  |  | ||||||
| const AutoProvision = () => { | const AutoProvision = () => { | ||||||
|   const { customerId } = useContext(UserContext); |   const { customerId } = useContext(UserContext); | ||||||
| @@ -14,13 +16,13 @@ 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', limit: 100 }, |       variables: { customerId, type: 'equipment_ap', limit: 100 }, | ||||||
| @@ -60,6 +62,14 @@ const AutoProvision = () => { | |||||||
|       ); |       ); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|  |   const handleFetchMoreProfiles = e => { | ||||||
|  |     fetchMoreProfiles(e, dataProfile, fetchMore); | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   const locationsTree = useMemo(() => { | ||||||
|  |     return formatLocations(dataLocation?.getAllLocations, true); | ||||||
|  |   }, [dataLocation?.getAllLocations]); | ||||||
|  |  | ||||||
|   if (loading) { |   if (loading) { | ||||||
|     return <Loading />; |     return <Loading />; | ||||||
|   } |   } | ||||||
| @@ -72,14 +82,15 @@ const AutoProvision = () => { | |||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|     <AutoProvisionPage |     <AutoProvisionPage | ||||||
|       data={data && data.getCustomer} |       data={data?.getCustomer} | ||||||
|       dataLocation={dataLocation && dataLocation.getAllLocations} |       locationsTree={locationsTree} | ||||||
|       dataProfile={dataProfile && dataProfile.getAllProfiles.items} |       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} | ||||||
|     /> |     /> | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -1,11 +1,12 @@ | |||||||
| import React from 'react'; | import React from 'react'; | ||||||
| import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||||
|  | import { RolesProvider } from '@tip-wlan/wlan-cloud-ui-library'; | ||||||
|  |  | ||||||
| import UserContext from 'contexts/UserContext'; | import UserContext from 'contexts/UserContext'; | ||||||
|  |  | ||||||
| const UserProvider = ({ children, id, email, roles, customerId, updateUser, updateToken }) => ( | const UserProvider = ({ children, id, email, roles, customerId, updateUser, updateToken }) => ( | ||||||
|   <UserContext.Provider value={{ id, email, roles, customerId, updateUser, updateToken }}> |   <UserContext.Provider value={{ id, email, roles, customerId, updateUser, updateToken }}> | ||||||
|     {children} |     <RolesProvider role={roles}>{children}</RolesProvider> | ||||||
|   </UserContext.Provider> |   </UserContext.Provider> | ||||||
| ); | ); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,3 +10,21 @@ export const updateQueryGetAllProfiles = (previousResult, { fetchMoreResult }) = | |||||||
|     }, |     }, | ||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | 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; | ||||||
|  | }; | ||||||
|   | |||||||
| @@ -255,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! | ||||||
|   | |||||||
| @@ -70,6 +70,9 @@ export const FILTER_EQUIPMENT = gql` | |||||||
|           firmware { |           firmware { | ||||||
|             detailsJSON |             detailsJSON | ||||||
|           } |           } | ||||||
|  |           channel { | ||||||
|  |             detailsJSON | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|       context |       context | ||||||
| @@ -77,6 +80,67 @@ export const FILTER_EQUIPMENT = gql` | |||||||
|   } |   } | ||||||
| `; | `; | ||||||
|  |  | ||||||
|  | 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 | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | `; | ||||||
|  |  | ||||||
| export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql` | export const FILTER_EQUIPMENT_BULK_EDIT_APS = gql` | ||||||
|   query FilterEquipment( |   query FilterEquipment( | ||||||
|     $locationIds: [ID] |     $locationIds: [ID] | ||||||
|   | |||||||
| @@ -14,6 +14,7 @@ import { AUTH_TOKEN } from 'constants/index'; | |||||||
| import { REFRESH_TOKEN } from 'graphql/mutations'; | 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'; | ||||||
|  | import { ScrollToTop } from '@tip-wlan/wlan-cloud-ui-library'; | ||||||
|  |  | ||||||
| const API_URI = process.env.NODE_ENV === 'production' ? window.REACT_APP_API : process.env.API; | const API_URI = process.env.NODE_ENV === 'production' ? window.REACT_APP_API : process.env.API; | ||||||
| const MOUNT_NODE = document.getElementById('root'); | const MOUNT_NODE = document.getElementById('root'); | ||||||
| @@ -102,6 +103,7 @@ const render = () => { | |||||||
|   ReactDOM.render( |   ReactDOM.render( | ||||||
|     <Router history={history}> |     <Router history={history}> | ||||||
|       <ApolloProvider client={client}> |       <ApolloProvider client={client}> | ||||||
|  |         <ScrollToTop /> | ||||||
|         <App /> |         <App /> | ||||||
|       </ApolloProvider> |       </ApolloProvider> | ||||||
|     </Router>, |     </Router>, | ||||||
|   | |||||||
| @@ -1,3 +1,14 @@ | |||||||
| body { | body { | ||||||
|   font-family: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif; |   font-family: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | input:-webkit-autofill, | ||||||
|  | input:-webkit-autofill:hover, | ||||||
|  | input:-webkit-autofill:focus, | ||||||
|  | input:-webkit-autofill:active, | ||||||
|  | input:-webkit-autofill::first-line { | ||||||
|  |   -webkit-transition: color 9999s ease-out, background-color 9999s ease-out; | ||||||
|  |   transition: color 9999s ease-out, background-color 9999s ease-out; | ||||||
|  |   font-size: 14px !important; | ||||||
|  |   font-family: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif !important; | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										110
									
								
								app/utils/locations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								app/utils/locations.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | |||||||
|  | import { filter, isEmpty, each } from 'lodash'; | ||||||
|  |  | ||||||
|  | export const NETWORK_NODE = { | ||||||
|  |   title: 'Network', | ||||||
|  |   id: '0', | ||||||
|  |   key: '0', | ||||||
|  |   value: '0', | ||||||
|  |   name: 'Network', | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | export const formatLocations = (list = [], disableRoot = false) => { | ||||||
|  |   function unflatten(array, p) { | ||||||
|  |     let tree = []; | ||||||
|  |     const parent = typeof p !== 'undefined' ? p : { id: '0' }; | ||||||
|  |     let children = filter(array, child => child.parentId === parent.id); | ||||||
|  |     children = children.map(c => ({ | ||||||
|  |       title: c.name, | ||||||
|  |       value: `${c.id}`, | ||||||
|  |       key: c.id, | ||||||
|  |       isLeaf: false, | ||||||
|  |       ...c, | ||||||
|  |     })); | ||||||
|  |     if (!isEmpty(children)) { | ||||||
|  |       if (parent.id === '0') { | ||||||
|  |         tree = children; | ||||||
|  |       } else { | ||||||
|  |         parent.children = children; | ||||||
|  |       } | ||||||
|  |       each(children, child => unflatten(array, child)); | ||||||
|  |     } | ||||||
|  |     return tree; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return [ | ||||||
|  |     { | ||||||
|  |       ...NETWORK_NODE, | ||||||
|  |       ...(disableRoot && { disabled: true }), | ||||||
|  |       children: unflatten(list), | ||||||
|  |     }, | ||||||
|  |   ]; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | export const getBreadcrumbPath = (id, locations) => { | ||||||
|  |   const locationsPath = []; | ||||||
|  |   const treeRecurse = (parentNodeId, node) => { | ||||||
|  |     if (node.id === parentNodeId) { | ||||||
|  |       locationsPath.unshift(node); | ||||||
|  |       return node; | ||||||
|  |     } | ||||||
|  |     if (node.children) { | ||||||
|  |       let parent; | ||||||
|  |       node.children.some(i => { | ||||||
|  |         parent = treeRecurse(parentNodeId, i); | ||||||
|  |         return parent; | ||||||
|  |       }); | ||||||
|  |       if (parent) { | ||||||
|  |         locationsPath.unshift(node); | ||||||
|  |       } | ||||||
|  |       return parent; | ||||||
|  |     } | ||||||
|  |     return null; | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   treeRecurse(id, { | ||||||
|  |     id: 0, | ||||||
|  |     children: locations, | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   return locationsPath; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | export const getLocationPath = (selectedId, locations) => { | ||||||
|  |   const locationsPath = []; | ||||||
|  |  | ||||||
|  |   const treeRecurse = (parentNodeId, node) => { | ||||||
|  |     if (node.id === parentNodeId) { | ||||||
|  |       locationsPath.unshift(node.id); | ||||||
|  |  | ||||||
|  |       if (node.children) { | ||||||
|  |         const flatten = children => { | ||||||
|  |           children.forEach(i => { | ||||||
|  |             locationsPath.unshift(i.id); | ||||||
|  |             if (i.children) { | ||||||
|  |               flatten(i.children); | ||||||
|  |             } | ||||||
|  |           }); | ||||||
|  |         }; | ||||||
|  |  | ||||||
|  |         flatten(node.children); | ||||||
|  |       } | ||||||
|  |       return node; | ||||||
|  |     } | ||||||
|  |     if (node.children) { | ||||||
|  |       let parent; | ||||||
|  |       node.children.some(i => { | ||||||
|  |         parent = treeRecurse(parentNodeId, i); | ||||||
|  |         return parent; | ||||||
|  |       }); | ||||||
|  |       return parent; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return null; | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   if (selectedId) { | ||||||
|  |     treeRecurse(selectedId, { id: 0, children: locations }); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return locationsPath; | ||||||
|  | }; | ||||||
							
								
								
									
										10781
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10781
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										38
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "wlan-cloud-ui", |   "name": "wlan-cloud-ui", | ||||||
|   "version": "0.7.5", |   "version": "1.2.0", | ||||||
|   "author": "ConnectUs", |   "author": "ConnectUs", | ||||||
|   "description": "React Portal", |   "description": "React Portal", | ||||||
|   "engines": { |   "engines": { | ||||||
| @@ -9,9 +9,9 @@ | |||||||
|   }, |   }, | ||||||
|   "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-graphql.qa.lab.wlan.tip.build NODE_ENV=bare webpack-dev-server", |     "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-graphql.qa.lab.wlan.tip.build NODE_ENV=development webpack-dev-server", |     "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,.scss}'", |     "format": "prettier --write 'app/**/*{.js,.scss}'", | ||||||
|     "eslint-fix": "eslint --fix 'app/**/*.js'", |     "eslint-fix": "eslint --fix 'app/**/*.js'", | ||||||
| @@ -21,33 +21,26 @@ | |||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@ant-design/icons": "^4.2.1", |     "@ant-design/icons": "^4.2.1", | ||||||
|     "@apollo/client": "^3.1.3", |     "@apollo/client": "^3.1.3", | ||||||
|     "@tip-wlan/wlan-cloud-ui-library": "^0.7.6", |     "@tip-wlan/wlan-cloud-ui-library": "^1.2.2", | ||||||
|     "antd": "^4.5.2", |     "antd": "^4.5.2", | ||||||
|     "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", |  | ||||||
|     "highcharts": "^8.1.0", |  | ||||||
|     "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", | ||||||
| @@ -55,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", | ||||||
| @@ -68,20 +63,23 @@ | |||||||
|     "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", | ||||||
|     "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" | ||||||
|   }, |   }, | ||||||
|   "browserslist": [ |   "browserslist": [ | ||||||
|     "last 2 versions", |     "last 2 versions", | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| 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 = { | ||||||
| @@ -9,4 +10,4 @@ const envs = { | |||||||
| /* 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); | ||||||
|   | |||||||
| @@ -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'); | ||||||
|  |  | ||||||
| @@ -25,10 +24,6 @@ module.exports = { | |||||||
|     ], |     ], | ||||||
|   }, |   }, | ||||||
|   plugins: [ |   plugins: [ | ||||||
|     new HtmlWebPackPlugin({ |  | ||||||
|       template: commonPaths.templatePath, |  | ||||||
|       favicon: './app/images/favicon.ico', |  | ||||||
|     }), |  | ||||||
|     new webpack.DefinePlugin({ |     new webpack.DefinePlugin({ | ||||||
|       'process.env.API': JSON.stringify(process.env.API || 'http://localhost:4000'), |       'process.env.API': JSON.stringify(process.env.API || 'http://localhost:4000'), | ||||||
|     }), |     }), | ||||||
|   | |||||||
| @@ -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'); | ||||||
|  |  | ||||||
| @@ -52,7 +54,9 @@ module.exports = { | |||||||
|           { |           { | ||||||
|             loader: 'less-loader', // compiles Less to CSS |             loader: 'less-loader', // compiles Less to CSS | ||||||
|             options: { |             options: { | ||||||
|               javascriptEnabled: true, |               lessOptions: { | ||||||
|  |                 javascriptEnabled: true, | ||||||
|  |               }, | ||||||
|             }, |             }, | ||||||
|           }, |           }, | ||||||
|         ], |         ], | ||||||
| @@ -79,4 +83,11 @@ module.exports = { | |||||||
|       ), |       ), | ||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|  |   plugins: [ | ||||||
|  |     new HtmlWebpackPlugin({ | ||||||
|  |       template: commonPaths.templatePath, | ||||||
|  |       favicon: './app/images/favicon.ico', | ||||||
|  |     }), | ||||||
|  |   ], | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -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,45 +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, |     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: { | ||||||
| @@ -78,25 +85,48 @@ module.exports = { | |||||||
|           { |           { | ||||||
|             loader: 'less-loader', // compiles Less to CSS |             loader: 'less-loader', // compiles Less to CSS | ||||||
|             options: { |             options: { | ||||||
|               javascriptEnabled: true, |               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', |  | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user