mirror of
				https://github.com/Telecominfraproject/wlan-cloud-ui.git
				synced 2025-10-31 18:57:59 +00:00 
			
		
		
		
	Compare commits
	
		
			12 Commits
		
	
	
		
			v1.2.0-rc2
			...
			v1.0.1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 196a8607cc | ||
|   | e38c672f91 | ||
|   | cf7ed39120 | ||
|   | eba4850ae1 | ||
|   | 3cfdcf15c6 | ||
|   | 1f018cbd04 | ||
|   | bc57402aa9 | ||
|   | 2692e6527f | ||
|   | f6d03b7a1b | ||
|   | 3f1a85a9c0 | ||
|   | f1b0c54fc3 | ||
|   | 7659407562 | 
							
								
								
									
										4
									
								
								.github/workflows/dockerpublish.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/dockerpublish.yml
									
									
									
									
										vendored
									
									
								
							| @@ -61,7 +61,7 @@ jobs: | ||||
|           [[ "${{ github.ref }}" == "refs/heads/release/"* ]] && VERSION=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\/release\/[v]//' | awk '{print $1"-SNAPSHOT"}') | ||||
|  | ||||
|           # Use Docker `latest` tag convention | ||||
|           [ "$VERSION" == "master" ] && VERSION=1.2.0-SNAPSHOT | ||||
|           [ "$VERSION" == "master" ] && VERSION=0.0.1-SNAPSHOT | ||||
|  | ||||
|           TIMESTAMP=$(date +'%Y-%m-%d') | ||||
|  | ||||
| @@ -96,7 +96,7 @@ jobs: | ||||
|           [[ "${{ github.ref }}" == "refs/heads/release/"* ]] && VERSION=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\/release\/[v]//' | awk '{print $1"-SNAPSHOT"}') | ||||
|  | ||||
|           # Use Docker `latest` tag convention | ||||
|           [ "$VERSION" == "master" ] && VERSION=1.2.0-SNAPSHOT | ||||
|           [ "$VERSION" == "master" ] && VERSION=0.0.1-SNAPSHOT | ||||
|  | ||||
|           echo IMAGE_ID=$IMAGE_ID | ||||
|           echo VERSION=$VERSION | ||||
|   | ||||
| @@ -3,9 +3,9 @@ export const COMPANY = 'Telecom Infra Project'; | ||||
|  | ||||
| export const USER_FRIENDLY_RADIOS = { | ||||
|   is2dot4GHz: '2.4GHz', | ||||
|   is5GHz: '5GHz', | ||||
|   is5GHzL: '5GHz (L)', | ||||
|   is5GHzU: '5GHz (U)', | ||||
|   is5GHz: '5GHz', | ||||
| }; | ||||
|  | ||||
| export const ROUTES = { | ||||
|   | ||||
| @@ -95,7 +95,7 @@ const Accounts = () => { | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   const handleCreateUser = ({ email, password, roles }) => { | ||||
|   const handleCreateUser = (email, password, roles) => { | ||||
|     createUser({ | ||||
|       variables: { | ||||
|         username: email, | ||||
| @@ -119,7 +119,7 @@ const Accounts = () => { | ||||
|       ); | ||||
|   }; | ||||
|  | ||||
|   const handleEditUser = ({ id, email, password, roles, lastModifiedTimestamp }) => { | ||||
|   const handleEditUser = (id, email, password, roles, lastModifiedTimestamp) => { | ||||
|     updateUser({ | ||||
|       variables: { | ||||
|         id, | ||||
|   | ||||
| @@ -4,11 +4,10 @@ import { useMutation, useQuery, gql } from '@apollo/client'; | ||||
| import { notification } from 'antd'; | ||||
| import { useHistory } from 'react-router-dom'; | ||||
|  | ||||
| import { ROUTES, AUTH_TOKEN } from 'constants/index'; | ||||
| import { ROUTES } from 'constants/index'; | ||||
| import UserContext from 'contexts/UserContext'; | ||||
| import { GET_ALL_PROFILES, GET_API_URL } from 'graphql/queries'; | ||||
| import { GET_ALL_PROFILES } from 'graphql/queries'; | ||||
| import { fetchMoreProfiles } from 'graphql/functions'; | ||||
| import { getItem } from 'utils/localStorage'; | ||||
|  | ||||
| const CREATE_PROFILE = gql` | ||||
|   mutation CreateProfile( | ||||
| @@ -36,9 +35,6 @@ const CREATE_PROFILE = gql` | ||||
|  | ||||
| const AddProfile = () => { | ||||
|   const { customerId } = useContext(UserContext); | ||||
|  | ||||
|   const { data: apiUrl } = useQuery(GET_API_URL); | ||||
|  | ||||
|   const { data: ssidProfiles, fetchMore } = useQuery(GET_ALL_PROFILES(), { | ||||
|     variables: { customerId, type: 'ssid' }, | ||||
|     fetchPolicy: 'network-only', | ||||
| @@ -120,46 +116,6 @@ const AddProfile = () => { | ||||
|     else fetchMoreProfiles(e, ssidProfiles, fetchMore); | ||||
|   }; | ||||
|  | ||||
|   const handleFileUpload = async (fileName, file) => { | ||||
|     const token = getItem(AUTH_TOKEN); | ||||
|  | ||||
|     if (apiUrl?.getApiUrl) { | ||||
|       fetch(`${apiUrl?.getApiUrl}filestore/${fileName}`, { | ||||
|         method: 'POST', | ||||
|         headers: { | ||||
|           Authorization: token ? `Bearer ${token.access_token}` : '', | ||||
|           'Content-Type': 'application/octet-stream', | ||||
|         }, | ||||
|         body: file, | ||||
|       }) | ||||
|         .then(response => response.json()) | ||||
|         .then(resp => { | ||||
|           if (resp?.success) { | ||||
|             notification.success({ | ||||
|               message: 'Success', | ||||
|               description: 'File successfully uploaded.', | ||||
|             }); | ||||
|           } else { | ||||
|             notification.error({ | ||||
|               message: 'Error', | ||||
|               description: 'File could not be uploaded.', | ||||
|             }); | ||||
|           } | ||||
|         }) | ||||
|         .catch(() => { | ||||
|           notification.error({ | ||||
|             message: 'Error', | ||||
|             description: 'File could not be uploaded.', | ||||
|           }); | ||||
|         }); | ||||
|     } else { | ||||
|       notification.error({ | ||||
|         message: 'Error', | ||||
|         description: 'File could not be uploaded.', | ||||
|       }); | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   return ( | ||||
|     <AddProfilePage | ||||
|       onCreateProfile={handleAddProfile} | ||||
| @@ -171,7 +127,6 @@ const AddProfile = () => { | ||||
|       idProviderProfiles={idProviderProfiles?.getAllProfiles?.items} | ||||
|       rfProfiles={rfProfiles?.getAllProfiles?.items} | ||||
|       onFetchMoreProfiles={handleFetchMoreProfiles} | ||||
|       fileUpload={handleFileUpload} | ||||
|     /> | ||||
|   ); | ||||
| }; | ||||
|   | ||||
| @@ -75,6 +75,7 @@ const App = () => { | ||||
|         <Helmet titleTemplate={`%s - ${COMPANY}`} defaultTitle={COMPANY}> | ||||
|           <meta name="description" content={COMPANY} /> | ||||
|         </Helmet> | ||||
|  | ||||
|         <Switch> | ||||
|           <UnauthenticatedRoute exact path={ROUTES.login} component={Login} /> | ||||
|           <ProtectedRouteWithLayout exact path={ROUTES.root} component={RedirectToDashboard} /> | ||||
|   | ||||
| @@ -20,11 +20,8 @@ function formatBytes(bytes, decimals = 2) { | ||||
|   return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i] || ''}`; | ||||
| } | ||||
|  | ||||
| function trafficLabelFormatter(bytes) { | ||||
|   if (this?.value) { | ||||
|     return formatBytes(this.value); | ||||
|   } | ||||
|   return formatBytes(bytes); | ||||
| function trafficLabelFormatter() { | ||||
|   return formatBytes(this.value); | ||||
| } | ||||
|  | ||||
| function trafficTooltipFormatter() { | ||||
| @@ -34,27 +31,12 @@ function trafficTooltipFormatter() { | ||||
| } | ||||
|  | ||||
| const lineChartConfig = [ | ||||
|   { | ||||
|     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: 'inservicesAPs', title: 'Inservice APs (24 hours)' }, | ||||
|   { key: 'clientDevices', title: 'Client Devices (24 hours)' }, | ||||
|   { | ||||
|     key: 'traffic', | ||||
|     title: 'Traffic - 5 min intervals (24 hours)', | ||||
|     lines: [ | ||||
|       { key: 'trafficBytesDownstreamData', name: 'Downstream' }, | ||||
|       { key: 'trafficBytesUpstreamData', name: 'Upstream' }, | ||||
|     ], | ||||
|     options: { formatter: trafficLabelFormatter, trafficTooltipFormatter }, | ||||
|     title: 'Traffic (24 hours)', | ||||
|     options: { formatter: trafficLabelFormatter, tooltipFormatter: trafficTooltipFormatter }, | ||||
|   }, | ||||
| ]; | ||||
|  | ||||
| @@ -73,8 +55,32 @@ const Dashboard = () => { | ||||
|     variables: { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] }, | ||||
|   }); | ||||
|  | ||||
|   const [lineChartData, setLineChartData] = useState([]); | ||||
|   const [trafficBytesData, setTrafficBytesData] = useState(); | ||||
|   const [lineChartData, setLineChartData] = useState({ | ||||
|     inservicesAPs: { | ||||
|       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( | ||||
|     FILTER_SYSTEM_EVENTS, | ||||
| @@ -92,65 +98,80 @@ const Dashboard = () => { | ||||
|  | ||||
|   const formatLineChartData = (list = []) => { | ||||
|     if (list.length) { | ||||
|       const chartData = []; | ||||
|       setLineChartData(prev => { | ||||
|         const inservicesAPs = []; | ||||
|         const clientDevices2dot4GHz = []; | ||||
|         const clientDevices5GHz = []; | ||||
|         const trafficBytesDownstreamData = []; | ||||
|         const trafficBytesUpstreamData = []; | ||||
|         let totalDown = 0; | ||||
|         let totalUp = 0; | ||||
|  | ||||
|       let inServiceAps = 0; | ||||
|       let clientDevices2dot4GHz = 0; | ||||
|       let clientDevices5GHz = 0; | ||||
|       let trafficBytesDownstreamData = 0; | ||||
|       let trafficBytesUpstreamData = 0; | ||||
|       let totalDown = 0; | ||||
|       let totalUp = 0; | ||||
|  | ||||
|       list.forEach( | ||||
|         ({ | ||||
|           eventTimestamp, | ||||
|           details: { | ||||
|             payload: { | ||||
|               details: { | ||||
|                 equipmentInServiceCount, | ||||
|                 associatedClientsCountPerRadio: radios, | ||||
|                 trafficBytesDownstream, | ||||
|                 trafficBytesUpstream, | ||||
|         list.forEach( | ||||
|           ({ | ||||
|             eventTimestamp, | ||||
|             details: { | ||||
|               payload: { | ||||
|                 details: { | ||||
|                   equipmentInServiceCount, | ||||
|                   associatedClientsCountPerRadio: radios, | ||||
|                   trafficBytesDownstream, | ||||
|                   trafficBytesUpstream, | ||||
|                 }, | ||||
|               }, | ||||
|             }, | ||||
|           }, | ||||
|         }) => { | ||||
|           const timestamp = parseInt(eventTimestamp, 10); | ||||
|           inServiceAps = equipmentInServiceCount; | ||||
|           }) => { | ||||
|             inservicesAPs.push([eventTimestamp, equipmentInServiceCount]); | ||||
|  | ||||
|           let total5GHz = 0; | ||||
|           total5GHz += (radios?.is5GHz || 0) + (radios?.is5GHzL || 0) + (radios?.is5GHzU || 0); // combine all 5GHz radios | ||||
|             let total5GHz = 0; | ||||
|             total5GHz += (radios?.is5GHz || 0) + (radios?.is5GHzL || 0) + (radios?.is5GHzU || 0); // combine all 5GHz radios | ||||
|  | ||||
|           clientDevices2dot4GHz = radios.is2dot4GHz || 0; | ||||
|           clientDevices5GHz = total5GHz || 0; | ||||
|             clientDevices2dot4GHz.push([eventTimestamp, radios.is2dot4GHz || 0]); | ||||
|             clientDevices5GHz.push([eventTimestamp, total5GHz || 0]); | ||||
|  | ||||
|           trafficBytesDownstreamData = (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0; | ||||
|           trafficBytesUpstreamData = (trafficBytesUpstream > 0 && trafficBytesUpstream) || 0; | ||||
|             trafficBytesDownstreamData.push([ | ||||
|               eventTimestamp, | ||||
|               (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0, | ||||
|             ]); | ||||
|             trafficBytesUpstreamData.push([ | ||||
|               eventTimestamp, | ||||
|               (trafficBytesUpstream > 0 && trafficBytesUpstream) || 0, | ||||
|             ]); | ||||
|  | ||||
|           totalDown += (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0; | ||||
|           totalUp += (trafficBytesUpstream > 0 && trafficBytesUpstream) || 0; | ||||
|           chartData.push({ | ||||
|             timestamp, | ||||
|             inServiceAps, | ||||
|             clientDevices2dot4GHz, | ||||
|             clientDevices5GHz, | ||||
|             trafficBytesDownstreamData, | ||||
|             trafficBytesUpstreamData, | ||||
|           }); | ||||
|         } | ||||
|       ); | ||||
|             totalDown += (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0; | ||||
|             totalUp += (trafficBytesUpstream > 0 && trafficBytesUpstream) || 0; | ||||
|           } | ||||
|         ); | ||||
|  | ||||
|       setTrafficBytesData(prev => { | ||||
|         return { | ||||
|           totalUpstreamTraffic: (prev?.totalUpstreamTraffic || 0) + totalUp, | ||||
|           totalDownstreamTraffic: (prev?.totalDownstreamTraffic || 0) + totalDown, | ||||
|           inservicesAPs: { | ||||
|             ...prev.inservicesAPs, | ||||
|             value: [...prev.inservicesAPs.value, ...inservicesAPs], | ||||
|           }, | ||||
|           clientDevices: { | ||||
|             is2dot4GHz: { | ||||
|               ...prev.clientDevices.is2dot4GHz, | ||||
|               value: [...prev.clientDevices.is2dot4GHz.value, ...clientDevices2dot4GHz], | ||||
|             }, | ||||
|             is5GHz: { | ||||
|               ...prev.clientDevices.is5GHz, | ||||
|               value: [...prev.clientDevices.is5GHz.value, ...clientDevices5GHz], | ||||
|             }, | ||||
|           }, | ||||
|           traffic: { | ||||
|             trafficBytesDownstream: { | ||||
|               ...prev.traffic.trafficBytesDownstream, | ||||
|               value: [...prev.traffic.trafficBytesDownstream.value, ...trafficBytesDownstreamData], | ||||
|             }, | ||||
|             trafficBytesUpstream: { | ||||
|               ...prev.traffic.trafficBytesUpstream, | ||||
|               value: [...prev.traffic.trafficBytesUpstream.value, ...trafficBytesUpstreamData], | ||||
|             }, | ||||
|           }, | ||||
|           totalDownstreamTraffic: totalDown, | ||||
|           totalUpstreamTraffic: totalUp, | ||||
|         }; | ||||
|       }); | ||||
|  | ||||
|       setLineChartData(prev => { | ||||
|         return [...prev, ...chartData]; | ||||
|       }); | ||||
|     } | ||||
|   }; | ||||
|  | ||||
| @@ -250,8 +271,8 @@ const Dashboard = () => { | ||||
|         }, | ||||
|         { | ||||
|           title: 'Usage Information (24 hours)', | ||||
|           'Total Traffic (Downstream)': formatBytes(trafficBytesData?.totalDownstreamTraffic), | ||||
|           'Total Traffic (Upstream)': formatBytes(trafficBytesData?.totalUpstreamTraffic), | ||||
|           'Total Traffic (US)': formatBytes(lineChartData?.totalUpstreamTraffic), | ||||
|           'Total Traffic (DS)': formatBytes(lineChartData?.totalDownstreamTraffic), | ||||
|         }, | ||||
|       ]} | ||||
|       pieChartDetails={pieChartsData} | ||||
|   | ||||
| @@ -63,7 +63,6 @@ const AccessPointDetails = ({ locations }) => { | ||||
|     }`), | ||||
|     { | ||||
|       variables: { customerId, type: 'equipment_ap' }, | ||||
|       fetchPolicy: 'network-only', | ||||
|     } | ||||
|   ); | ||||
|  | ||||
| @@ -71,7 +70,7 @@ const AccessPointDetails = ({ locations }) => { | ||||
|     loading: metricsLoading, | ||||
|     error: metricsError, | ||||
|     data: metricsData, | ||||
|     fetchMore: fetchMoreServiceMetrics, | ||||
|     refetch: metricsRefetch, | ||||
|   } = useQuery(FILTER_SERVICE_METRICS, { | ||||
|     variables: { | ||||
|       customerId, | ||||
| @@ -91,29 +90,7 @@ const AccessPointDetails = ({ locations }) => { | ||||
|  | ||||
|   const refetchData = () => { | ||||
|     refetch(); | ||||
|     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, | ||||
|           }, | ||||
|         }; | ||||
|       }, | ||||
|     }); | ||||
|     metricsRefetch(); | ||||
|   }; | ||||
|  | ||||
|   const handleUpdateEquipment = ({ | ||||
|   | ||||
| @@ -1,12 +1,9 @@ | ||||
| import React, { useContext, useMemo, useEffect } from 'react'; | ||||
| import React, { useContext, useMemo } from 'react'; | ||||
| import PropTypes from 'prop-types'; | ||||
| import { Alert, notification } from 'antd'; | ||||
| import { useParams } from 'react-router-dom'; | ||||
| import { useLazyQuery, useMutation } from '@apollo/client'; | ||||
| import { BulkEditAccessPoints, sortRadioTypes } from '@tip-wlan/wlan-cloud-ui-library'; | ||||
| import { USER_FRIENDLY_RADIOS } from 'constants/index'; | ||||
|  | ||||
| import { getBreadcrumbPath, getLocationPath } from 'utils/locations'; | ||||
| import { useQuery, useMutation } from '@apollo/client'; | ||||
| import { BulkEditAccessPoints, Loading } from '@tip-wlan/wlan-cloud-ui-library'; | ||||
|  | ||||
| import { FILTER_EQUIPMENT_BULK_EDIT_APS } from 'graphql/queries'; | ||||
| import { UPDATE_EQUIPMENT_BULK } from 'graphql/mutations'; | ||||
| @@ -14,6 +11,8 @@ import { UPDATE_EQUIPMENT_BULK } from 'graphql/mutations'; | ||||
| import UserContext from 'contexts/UserContext'; | ||||
| import styles from './index.module.scss'; | ||||
|  | ||||
| const defaultAppliedRadios = { is5GHzL: 'is5GHzL', is2dot4GHz: 'is2dot4GHz', is5GHzU: 'is5GHzU' }; | ||||
|  | ||||
| const renderTableCell = tabCell => { | ||||
|   if (Array.isArray(tabCell)) { | ||||
|     return ( | ||||
| @@ -29,13 +28,6 @@ const renderTableCell = tabCell => { | ||||
| }; | ||||
| const accessPointsChannelTableColumns = [ | ||||
|   { title: 'Name', dataIndex: 'name', key: 'name', width: 250, render: renderTableCell }, | ||||
|  | ||||
|   { | ||||
|     title: 'Radios', | ||||
|     dataIndex: 'radioMap', | ||||
|     width: 150, | ||||
|     render: text => renderTableCell(text.map(i => USER_FRIENDLY_RADIOS[i])), | ||||
|   }, | ||||
|   { | ||||
|     title: 'Manual Active Channel', | ||||
|     dataIndex: 'manualChannelNumber', | ||||
| @@ -96,132 +88,215 @@ const accessPointsChannelTableColumns = [ | ||||
|   }, | ||||
| ]; | ||||
|  | ||||
| const getRadioDetails = (radioDetails, type) => { | ||||
|   const sortedRadios = sortRadioTypes(Object.keys(radioDetails?.radioMap || {})); | ||||
| 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; | ||||
|   }; | ||||
|  | ||||
|   if (type === 'manualChannelNumber') { | ||||
|     return sortedRadios.map(i => radioDetails.radioMap[i]?.manualChannelNumber); | ||||
|   } | ||||
|   treeRecurse(id, { | ||||
|     id: 0, | ||||
|     children: locations, | ||||
|   }); | ||||
|  | ||||
|   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; | ||||
|   return locationsPath; | ||||
| }; | ||||
|  | ||||
| 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 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; | ||||
| }; | ||||
|  | ||||
| const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|   const { id } = useParams(); | ||||
|   const { customerId } = useContext(UserContext); | ||||
|  | ||||
|   const locationIds = useMemo(() => { | ||||
|     const locationPath = getLocationPath(id, locations); | ||||
|     return locationPath.filter(f => checkedLocations.includes(f)); | ||||
|   }, [id, locations, checkedLocations]); | ||||
|  | ||||
|   const [ | ||||
|     filterEquipment, | ||||
|     { | ||||
|       loading: filterEquipmentLoading, | ||||
|       error: filterEquipmentError, | ||||
|       refetch, | ||||
|       data: equipData, | ||||
|       fetchMore, | ||||
|     }, | ||||
|   ] = useLazyQuery(FILTER_EQUIPMENT_BULK_EDIT_APS, { | ||||
|     errorPolicy: 'all', | ||||
|     fetchPolicy: 'cache-first', | ||||
|   const { | ||||
|     loading: filterEquipmentLoading, | ||||
|     error: filterEquipmentError, | ||||
|     refetch, | ||||
|     data: equipData, | ||||
|     fetchMore, | ||||
|   } = useQuery(FILTER_EQUIPMENT_BULK_EDIT_APS, { | ||||
|     variables: { customerId, locationIds, equipmentType: 'AP' }, | ||||
|   }); | ||||
|  | ||||
|   const fetchFilterEquipment = async () => { | ||||
|     filterEquipment({ | ||||
|       variables: { | ||||
|         customerId, | ||||
|         locationIds, | ||||
|         equipmentType: 'AP', | ||||
|       }, | ||||
|     }); | ||||
|   }; | ||||
|   const [updateEquipmentBulk] = useMutation(UPDATE_EQUIPMENT_BULK); | ||||
|  | ||||
|   const formattedTableData = useMemo( | ||||
|     () => | ||||
|       equipData?.filterEquipment?.items?.map(({ id: key, name, details = {} }) => ({ | ||||
|         key, | ||||
|         id: key, | ||||
|         name, | ||||
|         manualChannelNumber: getRadioDetails(details, 'manualChannelNumber'), | ||||
|         manualBackupChannelNumber: getRadioDetails(details, 'manualBackupChannelNumber'), | ||||
|         cellSize: getRadioDetails(details, 'cellSize'), | ||||
|         probeResponseThreshold: getRadioDetails(details, 'probeResponseThreshold'), | ||||
|         clientDisconnectThreshold: getRadioDetails(details, 'clientDisconnectThreshold'), | ||||
|         snrDrop: getRadioDetails(details, 'snrDrop'), | ||||
|         minLoad: getRadioDetails(details, 'minLoad'), | ||||
|         radioMap: getRadioDetails(details, 'radioMap'), | ||||
|         allowedChannels: getRadioDetails(details, 'allowedChannels'), | ||||
|       })), | ||||
|     [equipData?.filterEquipment?.items] | ||||
|   ); | ||||
|   const getRadioDetails = (radioDetails, type) => { | ||||
|     if (type === 'manualChannelNumber') { | ||||
|       const manualChannelNumbers = []; | ||||
|       Object.keys(radioDetails?.radioMap || {}).map(i => { | ||||
|         return manualChannelNumbers.push(radioDetails.radioMap[i]?.manualChannelNumber); | ||||
|       }); | ||||
|       return manualChannelNumbers; | ||||
|     } | ||||
|  | ||||
|     if (type === 'manualBackupChannelNumber') { | ||||
|       const manualBackupChannelNumbers = []; | ||||
|       Object.keys(radioDetails?.radioMap || {}).map(i => { | ||||
|         return manualBackupChannelNumbers.push(radioDetails.radioMap[i]?.manualBackupChannelNumber); | ||||
|       }); | ||||
|       return manualBackupChannelNumbers; | ||||
|     } | ||||
|     if (type === 'cellSize') { | ||||
|       const cellSizeValues = []; | ||||
|       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?.radioMap || {}).map(i => { | ||||
|         return snrDropValues.push( | ||||
|           radioDetails.advancedRadioMap[i]?.bestApSettings?.value?.dropInSnrPercentage | ||||
|         ); | ||||
|       }); | ||||
|       return snrDropValues; | ||||
|     } | ||||
|  | ||||
|     const minLoadValue = []; | ||||
|     Object.keys(radioDetails?.radioMap || {}).map(i => { | ||||
|       return minLoadValue.push( | ||||
|         radioDetails.advancedRadioMap[i]?.bestApSettings?.value?.minLoadFactor | ||||
|       ); | ||||
|     }); | ||||
|     return minLoadValue; | ||||
|   }; | ||||
|  | ||||
|   const setAccessPointsBulkEditTableData = (dataSource = []) => | ||||
|     dataSource.items.map(({ id: key, name, details }) => ({ | ||||
|       key, | ||||
|       id: key, | ||||
|       name, | ||||
|       manualChannelNumber: getRadioDetails(details, 'manualChannelNumber'), | ||||
|       manualBackupChannelNumber: getRadioDetails(details, 'manualBackupChannelNumber'), | ||||
|       cellSize: getRadioDetails(details, 'cellSize'), | ||||
|       probeResponseThreshold: getRadioDetails(details, 'probeResponseThreshold'), | ||||
|       clientDisconnectThreshold: getRadioDetails(details, 'clientDisconnectThreshold'), | ||||
|       snrDrop: getRadioDetails(details, 'snrDrop'), | ||||
|       minLoad: getRadioDetails(details, 'minLoad'), | ||||
|       radioMap: Object.keys(details?.radioMap || {}), | ||||
|     })); | ||||
|  | ||||
|   const setUpdatedBulkEditTableData = ( | ||||
|     equipmentId, | ||||
|     manualChannelNumber, | ||||
|     manualBackupChannelNumber, | ||||
|     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 || defaultAppliedRadios).forEach((i, dataIndex) => { | ||||
|           const frequencies = {}; | ||||
|           dropInSnrPercentage = snrDrop[dataIndex]; | ||||
|           minLoadFactor = minLoad[dataIndex]; | ||||
|  | ||||
|           frequencies[`${i}`] = { | ||||
|             channelNumber: manualChannelNumber[dataIndex], | ||||
|             backupChannelNumber: manualBackupChannelNumber[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 => { | ||||
|     updateEquipmentBulk({ | ||||
| @@ -247,10 +322,38 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|   const handleSaveChanges = updatedRows => { | ||||
|     const editedRowsArr = []; | ||||
|     Object.keys(updatedRows).forEach(key => { | ||||
|       return editedRowsArr.push({ | ||||
|         equipmentId: updatedRows[key].id, | ||||
|         perRadioDetails: formatRadioFrequencies(updatedRows[key]), | ||||
|       const { | ||||
|         id: equipmentId, | ||||
|         manualChannelNumber, | ||||
|         manualBackupChannelNumber, | ||||
|         cellSize, | ||||
|         probeResponseThreshold, | ||||
|         clientDisconnectThreshold, | ||||
|         snrDrop, | ||||
|         minLoad, | ||||
|       } = updatedRows[key]; | ||||
|       const updatedEuips = setUpdatedBulkEditTableData( | ||||
|         equipmentId, | ||||
|         manualChannelNumber, | ||||
|         manualBackupChannelNumber, | ||||
|         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); | ||||
|   }; | ||||
| @@ -274,30 +377,24 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   useEffect(() => { | ||||
|     fetchFilterEquipment(); | ||||
|   }, [locationIds]); | ||||
|   if (filterEquipmentLoading) { | ||||
|     return <Loading />; | ||||
|   } | ||||
|  | ||||
|   if (filterEquipmentError) { | ||||
|     return ( | ||||
|       <Alert | ||||
|         message="Error" | ||||
|         description="Failed to load equipment(s) data." | ||||
|         type="error" | ||||
|         showIcon | ||||
|       /> | ||||
|       <Alert message="Error" description="Failed to load equipments data." type="error" showIcon /> | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   return ( | ||||
|     <BulkEditAccessPoints | ||||
|       tableColumns={accessPointsChannelTableColumns} | ||||
|       tableData={formattedTableData} | ||||
|       tableData={setAccessPointsBulkEditTableData(equipData?.filterEquipment)} | ||||
|       onLoadMore={handleLoadMore} | ||||
|       isLastPage={equipData?.filterEquipment?.context?.lastPage} | ||||
|       onSaveChanges={handleSaveChanges} | ||||
|       breadcrumbPath={getBreadcrumbPath(id, locations)} | ||||
|       loading={filterEquipmentLoading} | ||||
|     /> | ||||
|   ); | ||||
| }; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import React, { useContext, useMemo } from 'react'; | ||||
| import React, { useContext } from 'react'; | ||||
| import { useQuery, useMutation } from '@apollo/client'; | ||||
| import { Alert, notification } from 'antd'; | ||||
| import { AutoProvision as AutoProvisionPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; | ||||
| @@ -6,8 +6,6 @@ import { AutoProvision as AutoProvisionPage, Loading } from '@tip-wlan/wlan-clou | ||||
| import UserContext from 'contexts/UserContext'; | ||||
| import { GET_CUSTOMER, GET_ALL_LOCATIONS, GET_ALL_PROFILES } from 'graphql/queries'; | ||||
| import { UPDATE_CUSTOMER } from 'graphql/mutations'; | ||||
| import { fetchMoreProfiles } from 'graphql/functions'; | ||||
| import { formatLocations } from 'utils/locations'; | ||||
|  | ||||
| const AutoProvision = () => { | ||||
|   const { customerId } = useContext(UserContext); | ||||
| @@ -16,13 +14,13 @@ const AutoProvision = () => { | ||||
|   }); | ||||
|   const [updateCustomer] = useMutation(UPDATE_CUSTOMER); | ||||
|  | ||||
|   const { data: dataLocation, loading: loadingLocation, error: errorLocation } = useQuery( | ||||
|   const { data: dataLocation, loading: loadingLoaction, error: errorLocation } = useQuery( | ||||
|     GET_ALL_LOCATIONS, | ||||
|     { | ||||
|       variables: { customerId }, | ||||
|     } | ||||
|   ); | ||||
|   const { data: dataProfile, loading: loadingProfile, error: errorProfile, fetchMore } = useQuery( | ||||
|   const { data: dataProfile, loading: loadingProfile, error: errorProfile } = useQuery( | ||||
|     GET_ALL_PROFILES(), | ||||
|     { | ||||
|       variables: { customerId, type: 'equipment_ap', limit: 100 }, | ||||
| @@ -62,14 +60,6 @@ const AutoProvision = () => { | ||||
|       ); | ||||
|   }; | ||||
|  | ||||
|   const handleFetchMoreProfiles = e => { | ||||
|     fetchMoreProfiles(e, dataProfile, fetchMore); | ||||
|   }; | ||||
|  | ||||
|   const locationsTree = useMemo(() => { | ||||
|     return formatLocations(dataLocation?.getAllLocations, true); | ||||
|   }, [dataLocation?.getAllLocations]); | ||||
|  | ||||
|   if (loading) { | ||||
|     return <Loading />; | ||||
|   } | ||||
| @@ -82,15 +72,14 @@ const AutoProvision = () => { | ||||
|  | ||||
|   return ( | ||||
|     <AutoProvisionPage | ||||
|       data={data?.getCustomer} | ||||
|       locationsTree={locationsTree} | ||||
|       dataProfile={dataProfile?.getAllProfiles?.items} | ||||
|       loadingLocation={loadingLocation} | ||||
|       data={data && data.getCustomer} | ||||
|       dataLocation={dataLocation && dataLocation.getAllLocations} | ||||
|       dataProfile={dataProfile && dataProfile.getAllProfiles.items} | ||||
|       loadingLoaction={loadingLoaction} | ||||
|       loadingProfile={loadingProfile} | ||||
|       errorLocation={errorLocation} | ||||
|       errorProfile={errorProfile} | ||||
|       onUpdateCustomer={handleUpdateCustomer} | ||||
|       onFetchMoreProfiles={handleFetchMoreProfiles} | ||||
|     /> | ||||
|   ); | ||||
| }; | ||||
|   | ||||
| @@ -1,12 +1,11 @@ | ||||
| import React from 'react'; | ||||
| import PropTypes from 'prop-types'; | ||||
| import { RolesProvider } from '@tip-wlan/wlan-cloud-ui-library'; | ||||
|  | ||||
| import UserContext from 'contexts/UserContext'; | ||||
|  | ||||
| const UserProvider = ({ children, id, email, roles, customerId, updateUser, updateToken }) => ( | ||||
|   <UserContext.Provider value={{ id, email, roles, customerId, updateUser, updateToken }}> | ||||
|     <RolesProvider role={roles}>{children}</RolesProvider> | ||||
|     {children} | ||||
|   </UserContext.Provider> | ||||
| ); | ||||
|  | ||||
|   | ||||
| @@ -14,7 +14,6 @@ import { AUTH_TOKEN } from 'constants/index'; | ||||
| import { REFRESH_TOKEN } from 'graphql/mutations'; | ||||
| import { getItem, setItem, removeItem } from 'utils/localStorage'; | ||||
| 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 MOUNT_NODE = document.getElementById('root'); | ||||
| @@ -103,7 +102,6 @@ const render = () => { | ||||
|   ReactDOM.render( | ||||
|     <Router history={history}> | ||||
|       <ApolloProvider client={client}> | ||||
|         <ScrollToTop /> | ||||
|         <App /> | ||||
|       </ApolloProvider> | ||||
|     </Router>, | ||||
|   | ||||
| @@ -1,14 +1,3 @@ | ||||
| body { | ||||
|   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; | ||||
| } | ||||
|   | ||||
| @@ -1,110 +0,0 @@ | ||||
| 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; | ||||
| }; | ||||
							
								
								
									
										5885
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5885
									
								
								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", | ||||
|   "version": "1.2.0", | ||||
|   "version": "1.0.7", | ||||
|   "author": "ConnectUs", | ||||
|   "description": "React Portal", | ||||
|   "engines": { | ||||
| @@ -9,9 +9,9 @@ | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "test": "jest --passWithNoTests --coverage", | ||||
|     "start": "cross-env NODE_ENV=development webpack serve --mode development", | ||||
|     "start:bare": "cross-env API=https://wlan-ui.tip-sdk.lab.netexperience.com NODE_ENV=bare webpack serve --mode development", | ||||
|     "start:dev": "cross-env API=https://wlan-ui.tip-sdk.lab.netexperience.com NODE_ENV=development webpack serve --mode development", | ||||
|     "start": "cross-env NODE_ENV=development webpack-dev-server", | ||||
|     "start:bare": "cross-env API=ttps://portal.rtl.lab.netexperience.com NODE_ENV=bare webpack-dev-server", | ||||
|     "start:dev": "cross-env API=https://portal.rtl.lab.netexperience.com NODE_ENV=development webpack-dev-server", | ||||
|     "build": "webpack --mode=production", | ||||
|     "format": "prettier --write 'app/**/*{.js,.scss}'", | ||||
|     "eslint-fix": "eslint --fix 'app/**/*.js'", | ||||
| @@ -21,26 +21,33 @@ | ||||
|   "dependencies": { | ||||
|     "@ant-design/icons": "^4.2.1", | ||||
|     "@apollo/client": "^3.1.3", | ||||
|     "@tip-wlan/wlan-cloud-ui-library": "^1.2.2", | ||||
|     "@tip-wlan/wlan-cloud-ui-library": "^1.0.10", | ||||
|     "antd": "^4.5.2", | ||||
|     "apollo-upload-client": "^13.0.0", | ||||
|     "graphql": "^15.5.0", | ||||
|     "clean-webpack-plugin": "^3.0.0", | ||||
|     "graphql": "^14.6.0", | ||||
|     "highcharts": "^8.1.0", | ||||
|     "highcharts-react-official": "^3.0.0", | ||||
|     "history": "^4.10.1", | ||||
|     "html-webpack-plugin": "^3.2.0", | ||||
|     "lodash": "^4.17.15", | ||||
|     "mini-css-extract-plugin": "^0.9.0", | ||||
|     "moment": "^2.26.0", | ||||
|     "optimize-css-assets-webpack-plugin": "^5.0.3", | ||||
|     "prop-types": "^15.7.2", | ||||
|     "react": "^16.13.0", | ||||
|     "react-dom": "^16.13.0", | ||||
|     "react-helmet": "^5.2.1", | ||||
|     "react-jsx-highcharts": "^4.1.0", | ||||
|     "react-jsx-highstock": "^4.1.0", | ||||
|     "react-router-dom": "^5.1.2", | ||||
|     "recharts": "^2.0.9" | ||||
|     "terser-webpack-plugin": "^2.3.5" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@babel/core": "^7.8.7", | ||||
|     "@babel/plugin-proposal-class-properties": "^7.8.3", | ||||
|     "@babel/preset-env": "^7.8.7", | ||||
|     "@babel/preset-react": "^7.8.3", | ||||
|     "@babel/runtime": "^7.13.10", | ||||
|     "@testing-library/react": "^10.0.3", | ||||
|     "babel-core": "^6.26.3", | ||||
|     "babel-eslint": "^10.1.0", | ||||
| @@ -48,10 +55,8 @@ | ||||
|     "babel-loader": "^8.0.6", | ||||
|     "babel-plugin-root-import": "^6.4.1", | ||||
|     "babel-polyfill": "^6.26.0", | ||||
|     "clean-webpack-plugin": "^3.0.0", | ||||
|     "cross-env": "^7.0.2", | ||||
|     "css-loader": "^3.4.2", | ||||
|     "css-minimizer-webpack-plugin": "^1.3.0", | ||||
|     "eslint": "^6.8.0", | ||||
|     "eslint-config-airbnb": "^18.0.1", | ||||
|     "eslint-config-prettier": "^6.10.0", | ||||
| @@ -63,23 +68,20 @@ | ||||
|     "eslint-plugin-react": "^7.19.0", | ||||
|     "eslint-plugin-react-hooks": "^2.5.0", | ||||
|     "file-loader": "^5.1.0", | ||||
|     "html-webpack-plugin": "^5.3.1", | ||||
|     "husky": "^4.2.3", | ||||
|     "jest": "^25.4.0", | ||||
|     "less": "^3.11.1", | ||||
|     "less-loader": "^6.2.0", | ||||
|     "less-loader": "^5.0.0", | ||||
|     "lint-staged": "^10.0.8", | ||||
|     "mini-css-extract-plugin": "^1.3.9", | ||||
|     "node-sass": "^4.13.1", | ||||
|     "prettier": "^1.19.1", | ||||
|     "react-test-renderer": "^16.13.1", | ||||
|     "sass-loader": "^8.0.2", | ||||
|     "style-loader": "^1.1.3", | ||||
|     "terser-webpack-plugin": "^5.1.1", | ||||
|     "webpack": "^5.28.0", | ||||
|     "webpack-cli": "^4.5.0", | ||||
|     "webpack-dev-server": "^3.11.2", | ||||
|     "webpack-merge": "^5.7.3" | ||||
|     "webpack": "^4.42.0", | ||||
|     "webpack-cli": "^3.3.11", | ||||
|     "webpack-dev-server": "^3.11.0", | ||||
|     "webpack-merge": "^4.2.2" | ||||
|   }, | ||||
|   "browserslist": [ | ||||
|     "last 2 versions", | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| /* eslint-disable import/no-extraneous-dependencies */ | ||||
| const { merge } = require('webpack-merge'); | ||||
| const webpackMerge = require('webpack-merge'); | ||||
| const common = require('./webpack/webpack.common'); | ||||
|  | ||||
| const envs = { | ||||
| @@ -10,4 +9,4 @@ const envs = { | ||||
| /* eslint-disable global-require,import/no-dynamic-require */ | ||||
| const env = envs[process.env.NODE_ENV || 'production']; | ||||
| const envConfig = require(`./webpack/webpack.${env}.js`); | ||||
| module.exports = merge(common, envConfig); | ||||
| module.exports = webpackMerge(common, envConfig); | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| const HtmlWebPackPlugin = require('html-webpack-plugin'); | ||||
| /* eslint-disable import/no-extraneous-dependencies */ | ||||
| const webpack = require('webpack'); | ||||
|  | ||||
| @@ -24,6 +25,10 @@ module.exports = { | ||||
|     ], | ||||
|   }, | ||||
|   plugins: [ | ||||
|     new HtmlWebPackPlugin({ | ||||
|       template: commonPaths.templatePath, | ||||
|       favicon: './app/images/favicon.ico', | ||||
|     }), | ||||
|     new webpack.DefinePlugin({ | ||||
|       'process.env.API': JSON.stringify(process.env.API || 'http://localhost:4000'), | ||||
|     }), | ||||
|   | ||||
| @@ -1,6 +1,4 @@ | ||||
| /* eslint-disable import/no-extraneous-dependencies */ | ||||
| const path = require('path'); | ||||
| const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||||
|  | ||||
| const commonPaths = require('./paths'); | ||||
|  | ||||
| @@ -54,9 +52,7 @@ module.exports = { | ||||
|           { | ||||
|             loader: 'less-loader', // compiles Less to CSS | ||||
|             options: { | ||||
|               lessOptions: { | ||||
|                 javascriptEnabled: true, | ||||
|               }, | ||||
|               javascriptEnabled: true, | ||||
|             }, | ||||
|           }, | ||||
|         ], | ||||
| @@ -83,11 +79,4 @@ module.exports = { | ||||
|       ), | ||||
|     }, | ||||
|   }, | ||||
|  | ||||
|   plugins: [ | ||||
|     new HtmlWebpackPlugin({ | ||||
|       template: commonPaths.templatePath, | ||||
|       favicon: './app/images/favicon.ico', | ||||
|     }), | ||||
|   ], | ||||
| }; | ||||
|   | ||||
| @@ -1,8 +1,6 @@ | ||||
| /* eslint-disable import/no-extraneous-dependencies */ | ||||
| const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||||
| const { CleanWebpackPlugin } = require('clean-webpack-plugin'); | ||||
| const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||||
| const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); | ||||
| const { CleanWebpackPlugin } = require('clean-webpack-plugin'); | ||||
| const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); | ||||
| const TerserPlugin = require('terser-webpack-plugin'); | ||||
| const path = require('path'); | ||||
|  | ||||
| @@ -10,50 +8,45 @@ const commonPaths = require('./paths'); | ||||
|  | ||||
| module.exports = { | ||||
|   output: { | ||||
|     filename: `${commonPaths.jsFolder}/[name].[hash].js`, | ||||
|     path: commonPaths.outputPath, | ||||
|     publicPath: '/', | ||||
|     filename: `${commonPaths.jsFolder}/[name].[chunkhash].js`, | ||||
|     chunkFilename: `${commonPaths.jsFolder}/[id].[chunkhash].js`, | ||||
|     chunkFilename: `${commonPaths.jsFolder}/[name].[chunkhash].js`, | ||||
|   }, | ||||
|  | ||||
|   optimization: { | ||||
|     minimize: true, | ||||
|     minimizer: [ | ||||
|       new TerserPlugin({ | ||||
|         terserOptions: { | ||||
|           warnings: false, | ||||
|           compress: { | ||||
|             comparisons: false, | ||||
|           }, | ||||
|           parse: {}, | ||||
|           mangle: true, | ||||
|           output: { | ||||
|             comments: false, | ||||
|             ascii_only: true, | ||||
|           }, | ||||
|         }, | ||||
|         // Use multi-process parallel running to improve the build speed | ||||
|         // Default number of concurrent runs: os.cpus().length - 1 | ||||
|         parallel: true, | ||||
|         // Enable file caching | ||||
|         cache: true, | ||||
|         sourceMap: true, | ||||
|       }), | ||||
|       new CssMinimizerPlugin(), | ||||
|       new OptimizeCSSAssetsPlugin(), | ||||
|     ], | ||||
|     nodeEnv: 'production', | ||||
|     sideEffects: true, | ||||
|     concatenateModules: true, | ||||
|     runtimeChunk: 'single', | ||||
|     // Automatically split vendor and commons | ||||
|     // https://twitter.com/wSokra/status/969633336732905474 | ||||
|     // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366 | ||||
|     splitChunks: { | ||||
|       chunks: 'all', | ||||
|       maxInitialRequests: 10, | ||||
|       minSize: 0, | ||||
|       cacheGroups: { | ||||
|         vendor: { | ||||
|         vendors: { | ||||
|           test: /[\\/]node_modules[\\/]/, | ||||
|           name(module) { | ||||
|             const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]; | ||||
|             return `npm.${packageName.replace('@', '')}`; | ||||
|           }, | ||||
|           name: 'vendors', | ||||
|           chunks: 'initial', | ||||
|         }, | ||||
|         async: { | ||||
|           test: /[\\/]node_modules[\\/]/, | ||||
|           name: 'async', | ||||
|           chunks: 'async', | ||||
|           minChunks: 4, | ||||
|         }, | ||||
|       }, | ||||
|     }, | ||||
|     // Keep the runtime chunk seperated to enable long term caching | ||||
|     // https://twitter.com/wSokra/status/969679223278505985 | ||||
|     runtimeChunk: true, | ||||
|   }, | ||||
|  | ||||
|   module: { | ||||
| @@ -85,48 +78,25 @@ module.exports = { | ||||
|           { | ||||
|             loader: 'less-loader', // compiles Less to CSS | ||||
|             options: { | ||||
|               lessOptions: { | ||||
|                 javascriptEnabled: true, | ||||
|               }, | ||||
|               javascriptEnabled: true, | ||||
|             }, | ||||
|           }, | ||||
|         ], | ||||
|       }, | ||||
|     ], | ||||
|   }, | ||||
|  | ||||
|   resolve: { | ||||
|     modules: ['node_modules', 'app'], | ||||
|     alias: { | ||||
|       app: path.resolve(__dirname, '../', 'app'), | ||||
|     }, | ||||
|   }, | ||||
|  | ||||
|   plugins: [ | ||||
|     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({ | ||||
|       filename: `${commonPaths.cssFolder}/[name].css`, | ||||
|       chunkFilename: `${commonPaths.cssFolder}/[id].css`, | ||||
|       chunkFilename: `${commonPaths.cssFolder}/[name].css`, | ||||
|     }), | ||||
|   ], | ||||
|   devtool: 'source-map', | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user