mirror of
				https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
				synced 2025-10-31 18:27:45 +00:00 
			
		
		
		
	Merge pull request #206 from stephb9959/main
[WIFI-13256] Now displaying warnings if a device is blacklisted
This commit is contained in:
		
							
								
								
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,12 +1,12 @@ | |||||||
| { | { | ||||||
|   "name": "ucentral-client", |   "name": "ucentral-client", | ||||||
|   "version": "3.0.0(5)", |   "version": "3.0.0(6)", | ||||||
|   "lockfileVersion": 3, |   "lockfileVersion": 3, | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "packages": { |   "packages": { | ||||||
|     "": { |     "": { | ||||||
|       "name": "ucentral-client", |       "name": "ucentral-client", | ||||||
|       "version": "3.0.0(5)", |       "version": "3.0.0(6)", | ||||||
|       "license": "ISC", |       "license": "ISC", | ||||||
|       "dependencies": { |       "dependencies": { | ||||||
|         "@chakra-ui/anatomy": "^2.1.1", |         "@chakra-ui/anatomy": "^2.1.1", | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "ucentral-client", |   "name": "ucentral-client", | ||||||
|   "version": "3.0.0(5)", |   "version": "3.0.0(6)", | ||||||
|   "description": "", |   "description": "", | ||||||
|   "private": true, |   "private": true, | ||||||
|   "main": "index.tsx", |   "main": "index.tsx", | ||||||
|   | |||||||
| @@ -42,6 +42,7 @@ export type DeviceWithStatus = { | |||||||
|   associations_2G: number; |   associations_2G: number; | ||||||
|   associations_5G: number; |   associations_5G: number; | ||||||
|   associations_6G: number; |   associations_6G: number; | ||||||
|  |   blackListed?: boolean; | ||||||
|   compatible: string; |   compatible: string; | ||||||
|   connected: boolean; |   connected: boolean; | ||||||
|   connectReason?: string; |   connectReason?: string; | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ import { Note } from './Note'; | |||||||
|  |  | ||||||
| export interface GatewayDevice { | export interface GatewayDevice { | ||||||
|   UUID: number; |   UUID: number; | ||||||
|  |   blackListed?: boolean; | ||||||
|   certificateExpiryDate: number; |   certificateExpiryDate: number; | ||||||
|   compatible: string; |   compatible: string; | ||||||
|   configuration: unknown; |   configuration: unknown; | ||||||
|   | |||||||
| @@ -129,9 +129,7 @@ const DeviceSummary = ({ serialNumber }: Props) => { | |||||||
|               <Heading size="sm">{t('controller.stats.load')}:</Heading> |               <Heading size="sm">{t('controller.stats.load')}:</Heading> | ||||||
|             </GridItem> |             </GridItem> | ||||||
|             <GridItem colSpan={1}> |             <GridItem colSpan={1}> | ||||||
|               {getStats.data?.unit?.load |               {getStats.data?.unit?.load?.map((l) => `${l.toFixed(2)}`).join(' | ') ?? ''} | ||||||
|                 ? getStats.data?.unit.load.map((l) => `${(l * 100).toFixed(2)}%`).join(' | ') |  | ||||||
|                 : ''} |  | ||||||
|             </GridItem> |             </GridItem> | ||||||
|             <GridItem colSpan={1} alignContent="center" alignItems="center"> |             <GridItem colSpan={1} alignContent="center" alignItems="center"> | ||||||
|               <Heading size="sm">{t('controller.devices.localtime')}:</Heading> |               <Heading size="sm">{t('controller.devices.localtime')}:</Heading> | ||||||
|   | |||||||
| @@ -108,6 +108,17 @@ const DevicePageWrapper = ({ serialNumber }: Props) => { | |||||||
|   const connectedTag = React.useMemo(() => { |   const connectedTag = React.useMemo(() => { | ||||||
|     if (!getStatus.data) return null; |     if (!getStatus.data) return null; | ||||||
|  |  | ||||||
|  |     if (getDevice.data?.blackListed) { | ||||||
|  |       return ( | ||||||
|  |         <ResponsiveTag | ||||||
|  |           label="Blacklisted" | ||||||
|  |           tooltip="This device is blacklisted, it will not be able to connect to the network. Please visit the Blacklist page if you wish to remove it from the blacklist." | ||||||
|  |           colorScheme="red" | ||||||
|  |           icon={LockSimple} | ||||||
|  |         /> | ||||||
|  |       ); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     return ( |     return ( | ||||||
|       <ResponsiveTag |       <ResponsiveTag | ||||||
|         label={getStatus?.data?.connected ? t('common.connected') : t('common.disconnected')} |         label={getStatus?.data?.connected ? t('common.connected') : t('common.disconnected')} | ||||||
| @@ -115,7 +126,7 @@ const DevicePageWrapper = ({ serialNumber }: Props) => { | |||||||
|         icon={getStatus.data.connected ? WifiHigh : WifiSlash} |         icon={getStatus.data.connected ? WifiHigh : WifiSlash} | ||||||
|       /> |       /> | ||||||
|     ); |     ); | ||||||
|   }, [getStatus.data]); |   }, [getStatus.data, getDevice.data]); | ||||||
|  |  | ||||||
|   const healthTag = React.useMemo(() => { |   const healthTag = React.useMemo(() => { | ||||||
|     if (!getStatus.data || !getStatus.data.connected || !getHealth.data || getHealth.data?.values?.length === 0) |     if (!getStatus.data || !getStatus.data.connected || !getHealth.data || getHealth.data?.values?.length === 0) | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import { | |||||||
|   ThermometerCold, |   ThermometerCold, | ||||||
|   ThermometerHot, |   ThermometerHot, | ||||||
|   WarningCircle, |   WarningCircle, | ||||||
|  |   XCircle, | ||||||
| } from '@phosphor-icons/react'; | } from '@phosphor-icons/react'; | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
| import { useNavigate } from 'react-router-dom'; | import { useNavigate } from 'react-router-dom'; | ||||||
| @@ -63,6 +64,7 @@ const BADGE_COLORS: Record<string, string> = { | |||||||
|   NO_CERTIFICATE: 'red', |   NO_CERTIFICATE: 'red', | ||||||
|   MISMATCH_SERIAL: 'yellow', |   MISMATCH_SERIAL: 'yellow', | ||||||
|   VERIFIED: 'green', |   VERIFIED: 'green', | ||||||
|  |   BLACKLISTED: 'white', | ||||||
|   SIMULATED: 'purple', |   SIMULATED: 'purple', | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -159,12 +161,32 @@ const DeviceListCard = () => { | |||||||
|         h="35px" |         h="35px" | ||||||
|         w="35px" |         w="35px" | ||||||
|         borderRadius="50em" |         borderRadius="50em" | ||||||
|         bgColor={BADGE_COLORS[device.simulated ? 'SIMULATED' : device.verifiedCertificate] ?? 'red'} |         bgColor={ | ||||||
|  |           BADGE_COLORS[ | ||||||
|  |             device.simulated ? 'SIMULATED' : device.blackListed ? 'BLACKLISTED' : device.verifiedCertificate | ||||||
|  |           ] ?? 'red' | ||||||
|  |         } | ||||||
|         alignItems="center" |         alignItems="center" | ||||||
|         display="inline-flex" |         display="inline-flex" | ||||||
|         justifyContent="center" |         justifyContent="center" | ||||||
|         position="relative" |         position="relative" | ||||||
|       > |       > | ||||||
|  |         {device.blackListed ? ( | ||||||
|  |           <Tooltip label="This device is blacklisted. If this was done by mistake, please visit the Blacklist page to correct."> | ||||||
|  |             <XCircle | ||||||
|  |               size={44} | ||||||
|  |               color="#ff2600" | ||||||
|  |               weight="duotone" | ||||||
|  |               style={{ | ||||||
|  |                 position: 'absolute', | ||||||
|  |                 // Center vertically and horizontally | ||||||
|  |                 top: '50%', | ||||||
|  |                 left: '50%', | ||||||
|  |                 transform: 'translate(-50%, -50%)', | ||||||
|  |               }} | ||||||
|  |             /> | ||||||
|  |           </Tooltip> | ||||||
|  |         ) : null} | ||||||
|         <Tooltip |         <Tooltip | ||||||
|           label={`${device.simulated ? 'SIMULATED' : device.verifiedCertificate} - ${ |           label={`${device.simulated ? 'SIMULATED' : device.verifiedCertificate} - ${ | ||||||
|             device.connected ? t('common.connected') : t('common.disconnected') |             device.connected ? t('common.connected') : t('common.disconnected') | ||||||
| @@ -182,6 +204,7 @@ const DeviceListCard = () => { | |||||||
|           bottom={0} |           bottom={0} | ||||||
|           borderColor="gray.200" |           borderColor="gray.200" | ||||||
|           borderWidth={1} |           borderWidth={1} | ||||||
|  |           hidden={device.blackListed} | ||||||
|         /> |         /> | ||||||
|         {device.restrictedDevice && ( |         {device.restrictedDevice && ( | ||||||
|           <Box |           <Box | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Charles Bourque
					Charles Bourque