mirror of
				https://github.com/Telecominfraproject/wlan-cloud-ui.git
				synced 2025-10-31 10:48:01 +00:00 
			
		
		
		
	Compare commits
	
		
			7 Commits
		
	
	
		
			v1.1.0-rc2
			...
			v1.0.0-rc1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 1f018cbd04 | ||
|   | bc57402aa9 | ||
|   | 2692e6527f | ||
|   | f6d03b7a1b | ||
|   | 3f1a85a9c0 | ||
|   | f1b0c54fc3 | ||
|   | 7659407562 | 
							
								
								
									
										8
									
								
								.github/workflows/dockerpublish.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/dockerpublish.yml
									
									
									
									
										vendored
									
									
								
							| @@ -15,8 +15,8 @@ on: | ||||
|   pull_request: | ||||
|  | ||||
|   schedule: | ||||
|     # runs nightly build at 5AM | ||||
|     - cron: '00 09 * * *' | ||||
|       # runs nightly build at 5AM | ||||
|       - cron:  '00 09 * * *' | ||||
|  | ||||
| env: | ||||
|   IMAGE_NAME: wlan-cloud-ui | ||||
| @@ -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.1.0-SNAPSHOT | ||||
|           [ "$VERSION" == "master" ] && VERSION=1.0.0-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.1.0-SNAPSHOT | ||||
|           [ "$VERSION" == "master" ] && VERSION=1.0.0-SNAPSHOT | ||||
|  | ||||
|           echo IMAGE_ID=$IMAGE_ID | ||||
|           echo VERSION=$VERSION | ||||
|   | ||||
| @@ -92,9 +92,7 @@ const App = () => { | ||||
|           <ProtectedRouteWithLayout exact path={ROUTES.addprofile} component={AddProfile} /> | ||||
|  | ||||
|           <ProtectedRouteWithLayout exact path={ROUTES.alarms} component={Alarms} /> | ||||
|           {user?.id !== 0 && ( | ||||
|             <ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} /> | ||||
|           )} | ||||
|           <ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} /> | ||||
|           {user?.roles?.[0] === 'SuperUser' && ( | ||||
|             <ProtectedRouteWithLayout exact path={ROUTES.users} component={Accounts} /> | ||||
|           )} | ||||
|   | ||||
| @@ -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,7 +31,7 @@ function trafficTooltipFormatter() { | ||||
| } | ||||
|  | ||||
| const lineChartConfig = [ | ||||
|   { key: 'service', title: 'Inservice APs (24 hours)' }, | ||||
|   { key: 'inservicesAPs', title: 'Inservice APs (24 hours)' }, | ||||
|   { key: 'clientDevices', title: 'Client Devices (24 hours)' }, | ||||
|   { | ||||
|     key: 'traffic', | ||||
| @@ -59,11 +56,9 @@ const Dashboard = () => { | ||||
|   }); | ||||
|  | ||||
|   const [lineChartData, setLineChartData] = useState({ | ||||
|     service: { | ||||
|       inservicesAPs: { | ||||
|         key: 'Inservice APs', | ||||
|         value: [], | ||||
|       }, | ||||
|     inservicesAPs: { | ||||
|       key: 'Inservice APs', | ||||
|       value: [], | ||||
|     }, | ||||
|     clientDevices: { | ||||
|       is2dot4GHz: { | ||||
| @@ -126,23 +121,22 @@ const Dashboard = () => { | ||||
|               }, | ||||
|             }, | ||||
|           }) => { | ||||
|             const timestamp = parseInt(eventTimestamp, 10); | ||||
|             inservicesAPs.push({ timestamp, value: equipmentInServiceCount }); | ||||
|             inservicesAPs.push([eventTimestamp, equipmentInServiceCount]); | ||||
|  | ||||
|             let total5GHz = 0; | ||||
|             total5GHz += (radios?.is5GHz || 0) + (radios?.is5GHzL || 0) + (radios?.is5GHzU || 0); // combine all 5GHz radios | ||||
|  | ||||
|             clientDevices2dot4GHz.push({ timestamp, value: radios.is2dot4GHz || 0 }); | ||||
|             clientDevices5GHz.push({ timestamp, value: total5GHz || 0 }); | ||||
|             clientDevices2dot4GHz.push([eventTimestamp, radios.is2dot4GHz || 0]); | ||||
|             clientDevices5GHz.push([eventTimestamp, total5GHz || 0]); | ||||
|  | ||||
|             trafficBytesDownstreamData.push({ | ||||
|               timestamp, | ||||
|               value: (trafficBytesDownstream > 0 && trafficBytesDownstream) || 0, | ||||
|             }); | ||||
|             trafficBytesUpstreamData.push({ | ||||
|               timestamp, | ||||
|               value: (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; | ||||
| @@ -150,11 +144,9 @@ const Dashboard = () => { | ||||
|         ); | ||||
|  | ||||
|         return { | ||||
|           service: { | ||||
|             inservicesAPs: { | ||||
|               ...prev.service.inservicesAPs, | ||||
|               value: [...prev.service.inservicesAPs.value, ...inservicesAPs], | ||||
|             }, | ||||
|           inservicesAPs: { | ||||
|             ...prev.inservicesAPs, | ||||
|             value: [...prev.inservicesAPs.value, ...inservicesAPs], | ||||
|           }, | ||||
|           clientDevices: { | ||||
|             is2dot4GHz: { | ||||
|   | ||||
| @@ -13,7 +13,7 @@ import { removeItem } from 'utils/localStorage'; | ||||
| import UserContext from 'contexts/UserContext'; | ||||
|  | ||||
| const MasterLayout = ({ children }) => { | ||||
|   const { roles, customerId, id: currentUserId } = useContext(UserContext); | ||||
|   const { roles, customerId } = useContext(UserContext); | ||||
|  | ||||
|   const client = useApolloClient(); | ||||
|   const location = useLocation(); | ||||
| @@ -56,15 +56,11 @@ const MasterLayout = ({ children }) => { | ||||
|       key: 'settings', | ||||
|       text: 'Settings', | ||||
|       children: [ | ||||
|         ...(currentUserId !== 0 | ||||
|           ? [ | ||||
|               { | ||||
|                 key: 'editAccount', | ||||
|                 path: ROUTES.account, | ||||
|                 text: 'Edit Account', | ||||
|               }, | ||||
|             ] | ||||
|           : []), | ||||
|         { | ||||
|           key: 'editAccount', | ||||
|           path: ROUTES.account, | ||||
|           text: 'Edit Account', | ||||
|         }, | ||||
|         { | ||||
|           key: 'logout', | ||||
|           path: ROUTES.root, | ||||
| @@ -94,7 +90,6 @@ const MasterLayout = ({ children }) => { | ||||
|       menuItems={menuItems} | ||||
|       mobileMenuItems={mobileMenuItems} | ||||
|       totalAlarms={data && data.getAlarmCount} | ||||
|       currentUserId={currentUserId} | ||||
|     > | ||||
|       {children} | ||||
|     </Layout> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import React, { useContext } from 'react'; | ||||
| import PropTypes from 'prop-types'; | ||||
| import { useParams, useHistory } from 'react-router-dom'; | ||||
| import { useQuery, useMutation } from '@apollo/client'; | ||||
| import { useQuery, useMutation, gql } from '@apollo/client'; | ||||
| import { Alert, notification } from 'antd'; | ||||
| import moment from 'moment'; | ||||
| import { | ||||
| @@ -9,15 +9,8 @@ import { | ||||
|   Loading, | ||||
| } from '@tip-wlan/wlan-cloud-ui-library'; | ||||
|  | ||||
| import { FILTER_SERVICE_METRICS, GET_ALL_FIRMWARE, GET_ALL_PROFILES } from 'graphql/queries'; | ||||
| import { | ||||
|   GET_EQUIPMENT, | ||||
|   FILTER_SERVICE_METRICS, | ||||
|   GET_ALL_FIRMWARE, | ||||
|   GET_ALL_PROFILES, | ||||
| } from 'graphql/queries'; | ||||
| import { | ||||
|   UPDATE_EQUIPMENT, | ||||
|   DELETE_EQUIPMENT, | ||||
|   UPDATE_EQUIPMENT_FIRMWARE, | ||||
|   REQUEST_EQUIPMENT_SWITCH_BANK, | ||||
|   REQUEST_EQUIPMENT_REBOOT, | ||||
| @@ -25,6 +18,120 @@ import { | ||||
| import { fetchMoreProfiles } from 'graphql/functions'; | ||||
| 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! | ||||
|     $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 | ||||
|     } | ||||
|   } | ||||
| `; | ||||
|  | ||||
| const DELETE_EQUIPMENT = gql` | ||||
|   mutation DeleteEquipment($id: ID!) { | ||||
|     deleteEquipment(id: $id) { | ||||
|       id | ||||
|     } | ||||
|   } | ||||
| `; | ||||
|  | ||||
| const toTime = moment(); | ||||
| const fromTime = moment().subtract(1, 'hour'); | ||||
|  | ||||
| @@ -63,7 +170,6 @@ const AccessPointDetails = ({ locations }) => { | ||||
|     }`), | ||||
|     { | ||||
|       variables: { customerId, type: 'equipment_ap' }, | ||||
|       fetchPolicy: 'network-only', | ||||
|     } | ||||
|   ); | ||||
|  | ||||
| @@ -71,7 +177,7 @@ const AccessPointDetails = ({ locations }) => { | ||||
|     loading: metricsLoading, | ||||
|     error: metricsError, | ||||
|     data: metricsData, | ||||
|     fetchMore: fetchMoreServiceMetrics, | ||||
|     refetch: metricsRefetch, | ||||
|   } = useQuery(FILTER_SERVICE_METRICS, { | ||||
|     variables: { | ||||
|       customerId, | ||||
| @@ -91,29 +197,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 = ({ | ||||
|   | ||||
| @@ -89,8 +89,8 @@ const accessPointsTableColumns = [ | ||||
|   }, | ||||
|   { | ||||
|     title: 'CHANNEL', | ||||
|     dataIndex: ['status', 'channel', 'detailsJSON', 'channelNumberStatusDataMap'], | ||||
|     render: text => renderTableCell(Object.values(text ?? [])), | ||||
|     dataIndex: 'channel', | ||||
|     render: renderTableCell, | ||||
|   }, | ||||
|   { | ||||
|     title: 'OCCUPANCY', | ||||
|   | ||||
| @@ -27,22 +27,13 @@ const renderTableCell = tabCell => { | ||||
|   return <span>{tabCell}</span>; | ||||
| }; | ||||
| const accessPointsChannelTableColumns = [ | ||||
|   { title: 'Name', dataIndex: 'name', key: 'name', width: 250, render: renderTableCell }, | ||||
|   { title: 'Name', dataIndex: 'name', key: 'name', width: 150, render: renderTableCell }, | ||||
|   { | ||||
|     title: 'Manual Active Channel', | ||||
|     dataIndex: 'manualChannelNumber', | ||||
|     key: 'manualChannelNumber', | ||||
|     title: 'Channel', | ||||
|     dataIndex: 'channel', | ||||
|     key: 'channel', | ||||
|     editable: true, | ||||
|     width: 200, | ||||
|     render: renderTableCell, | ||||
|   }, | ||||
|  | ||||
|   { | ||||
|     title: 'Manual Backup Channel', | ||||
|     dataIndex: 'manualBackupChannelNumber', | ||||
|     key: 'manualBackupChannelNumber', | ||||
|     editable: true, | ||||
|     width: 210, | ||||
|     width: 150, | ||||
|     render: renderTableCell, | ||||
|   }, | ||||
|   { | ||||
| @@ -58,7 +49,7 @@ const accessPointsChannelTableColumns = [ | ||||
|     dataIndex: 'probeResponseThreshold', | ||||
|     key: 'probeResponseThreshold', | ||||
|     editable: true, | ||||
|     width: 210, | ||||
|     width: 200, | ||||
|     render: renderTableCell, | ||||
|   }, | ||||
|   { | ||||
| @@ -66,7 +57,7 @@ const accessPointsChannelTableColumns = [ | ||||
|     dataIndex: 'clientDisconnectThreshold', | ||||
|     key: 'clientDisconnectThreshold', | ||||
|     editable: true, | ||||
|     width: 210, | ||||
|     width: 200, | ||||
|  | ||||
|     render: renderTableCell, | ||||
|   }, | ||||
| @@ -75,7 +66,7 @@ const accessPointsChannelTableColumns = [ | ||||
|     dataIndex: 'snrDrop', | ||||
|     key: 'snrDrop', | ||||
|     editable: true, | ||||
|     width: 150, | ||||
|     width: 175, | ||||
|     render: renderTableCell, | ||||
|   }, | ||||
|   { | ||||
| @@ -178,21 +169,6 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|   const [updateEquipmentBulk] = useMutation(UPDATE_EQUIPMENT_BULK); | ||||
|  | ||||
|   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 => { | ||||
| @@ -237,25 +213,26 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|     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 setAccessPointsBulkEditTableData = (dataSource = []) => { | ||||
|     const tableData = dataSource.items.map(({ id: key, name, channel, details }) => { | ||||
|       return { | ||||
|         key, | ||||
|         id: key, | ||||
|         name, | ||||
|         channel, | ||||
|         cellSize: getRadioDetails(details, 'cellSize'), | ||||
|         probeResponseThreshold: getRadioDetails(details, 'probeResponseThreshold'), | ||||
|         clientDisconnectThreshold: getRadioDetails(details, 'clientDisconnectThreshold'), | ||||
|         snrDrop: getRadioDetails(details, 'snrDrop'), | ||||
|         minLoad: getRadioDetails(details, 'minLoad'), | ||||
|       }; | ||||
|     }); | ||||
|     return tableData; | ||||
|   }; | ||||
|  | ||||
|   const setUpdatedBulkEditTableData = ( | ||||
|     equipmentId, | ||||
|     manualChannelNumber, | ||||
|     manualBackupChannelNumber, | ||||
|     channel, | ||||
|     cellSize, | ||||
|     probeResponseThreshold, | ||||
|     clientDisconnectThreshold, | ||||
| @@ -274,8 +251,7 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|           minLoadFactor = minLoad[dataIndex]; | ||||
|  | ||||
|           frequencies[`${i}`] = { | ||||
|             channelNumber: manualChannelNumber[dataIndex], | ||||
|             backupChannelNumber: manualBackupChannelNumber[dataIndex], | ||||
|             channelNumber: channel[dataIndex], | ||||
|             rxCellSizeDb: { | ||||
|               auto: true, | ||||
|               value: cellSize[dataIndex], | ||||
| @@ -324,8 +300,7 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|     Object.keys(updatedRows).forEach(key => { | ||||
|       const { | ||||
|         id: equipmentId, | ||||
|         manualChannelNumber, | ||||
|         manualBackupChannelNumber, | ||||
|         channel, | ||||
|         cellSize, | ||||
|         probeResponseThreshold, | ||||
|         clientDisconnectThreshold, | ||||
| @@ -334,8 +309,7 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|       } = updatedRows[key]; | ||||
|       const updatedEuips = setUpdatedBulkEditTableData( | ||||
|         equipmentId, | ||||
|         manualChannelNumber, | ||||
|         manualBackupChannelNumber, | ||||
|         channel, | ||||
|         cellSize, | ||||
|         probeResponseThreshold, | ||||
|         clientDisconnectThreshold, | ||||
| @@ -390,9 +364,18 @@ const BulkEditAPs = ({ locations, checkedLocations }) => { | ||||
|   return ( | ||||
|     <BulkEditAccessPoints | ||||
|       tableColumns={accessPointsChannelTableColumns} | ||||
|       tableData={setAccessPointsBulkEditTableData(equipData?.filterEquipment)} | ||||
|       tableData={ | ||||
|         equipData && | ||||
|         equipData.filterEquipment && | ||||
|         setAccessPointsBulkEditTableData(equipData && equipData.filterEquipment) | ||||
|       } | ||||
|       onLoadMore={handleLoadMore} | ||||
|       isLastPage={equipData?.filterEquipment?.context?.lastPage} | ||||
|       isLastPage={ | ||||
|         equipData && | ||||
|         equipData.filterEquipment && | ||||
|         equipData.filterEquipment.context && | ||||
|         equipData.filterEquipment.context.lastPage | ||||
|       } | ||||
|       onSaveChanges={handleSaveChanges} | ||||
|       breadcrumbPath={getBreadcrumbPath(id, locations)} | ||||
|     /> | ||||
|   | ||||
| @@ -4,11 +4,11 @@ import { useQuery, useMutation, gql } from '@apollo/client'; | ||||
| import { Alert, notification } from 'antd'; | ||||
| import { ProfileDetails as ProfileDetailsPage, Loading } from '@tip-wlan/wlan-cloud-ui-library'; | ||||
|  | ||||
| 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 { FILE_UPLOAD } from 'graphql/mutations'; | ||||
| import { fetchMoreProfiles } from 'graphql/functions'; | ||||
| import { getItem } from 'utils/localStorage'; | ||||
|  | ||||
| const GET_PROFILE = gql` | ||||
|   query GetProfile($id: ID!) { | ||||
| @@ -23,16 +23,6 @@ const GET_PROFILE = gql` | ||||
|         profileType | ||||
|         details | ||||
|       } | ||||
|       associatedSsidProfiles { | ||||
|         id | ||||
|         name | ||||
|         profileType | ||||
|         details | ||||
|       } | ||||
|       osuSsidProfile { | ||||
|         id | ||||
|         name | ||||
|       } | ||||
|       childProfileIds | ||||
|       createdTimestamp | ||||
|       lastModifiedTimestamp | ||||
| @@ -85,8 +75,6 @@ const ProfileDetails = () => { | ||||
|  | ||||
|   const [redirect, setRedirect] = useState(false); | ||||
|  | ||||
|   const { data: apiUrl } = useQuery(GET_API_URL); | ||||
|  | ||||
|   const { loading, error, data } = useQuery(GET_PROFILE, { | ||||
|     variables: { id }, | ||||
|     fetchPolicy: 'network-only', | ||||
| @@ -142,6 +130,8 @@ const ProfileDetails = () => { | ||||
|   const [updateProfile] = useMutation(UPDATE_PROFILE); | ||||
|   const [deleteProfile] = useMutation(DELETE_PROFILE); | ||||
|  | ||||
|   const [fileUpload] = useMutation(FILE_UPLOAD); | ||||
|  | ||||
|   const handleDeleteProfile = () => { | ||||
|     deleteProfile({ variables: { id } }) | ||||
|       .then(() => { | ||||
| @@ -187,77 +177,20 @@ const ProfileDetails = () => { | ||||
|       ); | ||||
|   }; | ||||
|  | ||||
|   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.', | ||||
|           }); | ||||
|   const handleFileUpload = (fileName, file) => | ||||
|     fileUpload({ variables: { fileName, file } }) | ||||
|       .then(() => { | ||||
|         notification.success({ | ||||
|           message: 'Success', | ||||
|           description: 'File successfully uploaded.', | ||||
|         }); | ||||
|     } else { | ||||
|       notification.error({ | ||||
|         message: 'Error', | ||||
|         description: 'File could not be uploaded.', | ||||
|       }); | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   const handleDownloadFile = async name => { | ||||
|     const token = getItem(AUTH_TOKEN); | ||||
|     if (apiUrl?.getApiUrl) { | ||||
|       return fetch(`${apiUrl?.getApiUrl}filestore/${encodeURIComponent(name)}`, { | ||||
|         method: 'GET', | ||||
|         headers: { | ||||
|           'Content-Type': 'application/octet-stream', | ||||
|           Authorization: token ? `Bearer ${token.access_token}` : '', | ||||
|         }, | ||||
|       }) | ||||
|         .then(response => response.blob()) | ||||
|         .then(blob => { | ||||
|           return new Promise((resolve, reject) => { | ||||
|             const reader = new FileReader(); | ||||
|             reader.onloadend = () => resolve(reader.result); | ||||
|             reader.onerror = reject; | ||||
|             reader.readAsDataURL(blob); | ||||
|           }); | ||||
|       .catch(() => | ||||
|         notification.error({ | ||||
|           message: 'Error', | ||||
|           description: 'File could not be uploaded.', | ||||
|         }) | ||||
|         .catch(() => { | ||||
|           notification.error({ | ||||
|             message: 'Error', | ||||
|             description: 'File could not be retrieved.', | ||||
|           }); | ||||
|         }); | ||||
|     } | ||||
|     return notification.error({ | ||||
|       message: 'Error', | ||||
|       description: 'File could not be retrieved.', | ||||
|     }); | ||||
|   }; | ||||
|       ); | ||||
|  | ||||
|   const handleFetchMoreProfiles = (e, key) => { | ||||
|     if (key === 'radius') fetchMoreProfiles(e, radiusProfiles, fetchMoreRadiusProfiles); | ||||
| @@ -302,11 +235,8 @@ const ProfileDetails = () => { | ||||
|       venueProfiles={venueProfiles?.getAllProfiles?.items} | ||||
|       operatorProfiles={operatorProfiles?.getAllProfiles?.items} | ||||
|       idProviderProfiles={idProviderProfiles?.getAllProfiles?.items} | ||||
|       associatedSsidProfiles={data.getProfile?.associatedSsidProfiles} | ||||
|       osuSsidProfile={data.getProfile?.osuSsidProfile} | ||||
|       fileUpload={handleFileUpload} | ||||
|       onFetchMoreProfiles={handleFetchMoreProfiles} | ||||
|       onDownloadFile={handleDownloadFile} | ||||
|     /> | ||||
|   ); | ||||
| }; | ||||
|   | ||||
| @@ -6,7 +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'; | ||||
|  | ||||
| const AutoProvision = () => { | ||||
|   const { customerId } = useContext(UserContext); | ||||
| @@ -15,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 }, | ||||
| @@ -61,10 +60,6 @@ const AutoProvision = () => { | ||||
|       ); | ||||
|   }; | ||||
|  | ||||
|   const handleFetchMoreProfiles = e => { | ||||
|     fetchMoreProfiles(e, dataProfile, fetchMore); | ||||
|   }; | ||||
|  | ||||
|   if (loading) { | ||||
|     return <Loading />; | ||||
|   } | ||||
| @@ -80,12 +75,11 @@ const AutoProvision = () => { | ||||
|       data={data && data.getCustomer} | ||||
|       dataLocation={dataLocation && dataLocation.getAllLocations} | ||||
|       dataProfile={dataProfile && dataProfile.getAllProfiles.items} | ||||
|       loadingLocation={loadingLocation} | ||||
|       loadingLoaction={loadingLoaction} | ||||
|       loadingProfile={loadingProfile} | ||||
|       errorLocation={errorLocation} | ||||
|       errorProfile={errorProfile} | ||||
|       onUpdateCustomer={handleUpdateCustomer} | ||||
|       onFetchMoreProfiles={handleFetchMoreProfiles} | ||||
|     /> | ||||
|   ); | ||||
| }; | ||||
|   | ||||
| @@ -255,62 +255,6 @@ 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` | ||||
|   mutation UpdateCustomer( | ||||
|     $id: ID! | ||||
|   | ||||
| @@ -70,9 +70,6 @@ export const FILTER_EQUIPMENT = gql` | ||||
|           firmware { | ||||
|             detailsJSON | ||||
|           } | ||||
|           channel { | ||||
|             detailsJSON | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       context | ||||
| @@ -80,67 +77,6 @@ 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` | ||||
|   query FilterEquipment( | ||||
|     $locationIds: [ID] | ||||
|   | ||||
							
								
								
									
										10807
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10807
									
								
								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.1.8", | ||||
|   "version": "0.10.2", | ||||
|   "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.1.14", | ||||
|     "@tip-wlan/wlan-cloud-ui-library": "^0.13.3", | ||||
|     "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