mirror of
				https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
				synced 2025-10-31 18:27:45 +00:00 
			
		
		
		
	[WIFI-10850] Error descriptions on command failures
Signed-off-by: Charles <charles.bourque96@gmail.com>
This commit is contained in:
		
							
								
								
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,12 +1,12 @@ | ||||
| { | ||||
|   "name": "ucentral-client", | ||||
|   "version": "2.7.0(5)", | ||||
|   "version": "2.7.0(6)", | ||||
|   "lockfileVersion": 2, | ||||
|   "requires": true, | ||||
|   "packages": { | ||||
|     "": { | ||||
|       "name": "ucentral-client", | ||||
|       "version": "2.7.0(5)", | ||||
|       "version": "2.7.0(6)", | ||||
|       "dependencies": { | ||||
|         "@coreui/coreui": "^3.4.0", | ||||
|         "@coreui/icons": "^2.0.1", | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "ucentral-client", | ||||
|   "version": "2.7.0(5)", | ||||
|   "version": "2.7.0(6)", | ||||
|   "dependencies": { | ||||
|     "@coreui/coreui": "^3.4.0", | ||||
|     "@coreui/icons": "^2.0.1", | ||||
|   | ||||
| @@ -326,6 +326,7 @@ | ||||
| 	"device": { | ||||
| 		"add_to_blacklist": "Gerät zur Blacklist hinzufügen", | ||||
| 		"all_devices": "Alle Geräte", | ||||
| 		"already_running_command": "Gerät führt bereits einen Befehl aus, bitte versuchen Sie es später erneut", | ||||
| 		"blacklisted_on": "Datum", | ||||
| 		"capabilities": "Fähigkeiten", | ||||
| 		"certificate_explanation": "Zertifikate der angeschlossenen Geräte", | ||||
|   | ||||
| @@ -326,6 +326,7 @@ | ||||
| 	"device": { | ||||
| 		"add_to_blacklist": "Add Device To Blacklist", | ||||
| 		"all_devices": "All Devices", | ||||
| 		"already_running_command": "Device is already executing a command, please try later", | ||||
| 		"blacklisted_on": "Date", | ||||
| 		"capabilities": "Capabilities", | ||||
| 		"certificate_explanation": "Certificates of connected devices", | ||||
|   | ||||
| @@ -326,6 +326,7 @@ | ||||
| 	"device": { | ||||
| 		"add_to_blacklist": "Agregar dispositivo a la lista negra", | ||||
| 		"all_devices": "Todos los dispositivos", | ||||
| 		"already_running_command": "El dispositivo ya está ejecutando un comando, intente más tarde", | ||||
| 		"blacklisted_on": "Fecha", | ||||
| 		"capabilities": "capacidades", | ||||
| 		"certificate_explanation": "Certificados de dispositivos conectados", | ||||
|   | ||||
| @@ -326,6 +326,7 @@ | ||||
| 	"device": { | ||||
| 		"add_to_blacklist": "Ajouter un appareil à la liste noire", | ||||
| 		"all_devices": "Tous les dispositifs", | ||||
| 		"already_running_command": "L'appareil exécute déjà une commande, veuillez réessayer plus tard", | ||||
| 		"blacklisted_on": "Rendez-vous amoureux", | ||||
| 		"capabilities": "Capacités", | ||||
| 		"certificate_explanation": "Certificats des appareils connectés", | ||||
|   | ||||
| @@ -326,6 +326,7 @@ | ||||
| 	"device": { | ||||
| 		"add_to_blacklist": "Adicionar dispositivo à lista negra", | ||||
| 		"all_devices": "Todos os dispositivos", | ||||
| 		"already_running_command": "O dispositivo já está executando um comando, tente mais tarde", | ||||
| 		"blacklisted_on": "Encontro", | ||||
| 		"capabilities": "Recursos", | ||||
| 		"certificate_explanation": "Certificados de dispositivos conectados", | ||||
|   | ||||
| @@ -72,7 +72,18 @@ const BlinkModal = ({ show, toggleModal }) => { | ||||
|         } | ||||
|         toggleModal(); | ||||
|       }) | ||||
|       .catch(() => { | ||||
|       .catch((e) => { | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|         setResult('error'); | ||||
|       }) | ||||
|       .finally(() => { | ||||
|   | ||||
| @@ -103,12 +103,17 @@ const ConfigureModal = ({ show, toggleModal }) => { | ||||
|       }) | ||||
|       .catch((e) => { | ||||
|         setResponseBody('Error while submitting command!'); | ||||
|         addToast({ | ||||
|           title: t('common.error'), | ||||
|           body: `${t('common.general_error')}: ${e.response?.data?.ErrorDescription}`, | ||||
|           color: 'danger', | ||||
|           autohide: true, | ||||
|         }); | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|         setHadFailure(true); | ||||
|       }) | ||||
|       .finally(() => { | ||||
|   | ||||
| @@ -54,12 +54,17 @@ const DeviceActions = ({ device }) => { | ||||
|         if (newWindow) newWindow.opener = null; | ||||
|       }) | ||||
|       .catch((e) => { | ||||
|         addToast({ | ||||
|           title: t('common.error'), | ||||
|           body: t('connect.error_trying_to_connect', { error: e.response?.data?.ErrorDescription }), | ||||
|           color: 'danger', | ||||
|           autohide: true, | ||||
|         }); | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }) | ||||
|       .finally(() => { | ||||
|         setConnectLoading(false); | ||||
| @@ -68,18 +73,20 @@ const DeviceActions = ({ device }) => { | ||||
|  | ||||
|   useEffect(() => { | ||||
|     if (upgradeStatus.result !== undefined) { | ||||
|       addToast({ | ||||
|         title: upgradeStatus.result.success ? t('common.success') : t('common.error'), | ||||
|         body: upgradeStatus.result.success | ||||
|           ? t('firmware.upgrade_command_submitted') | ||||
|           : upgradeStatus.result.error, | ||||
|         color: upgradeStatus.result.success ? 'success' : 'danger', | ||||
|         autohide: true, | ||||
|       }); | ||||
|       if (upgradeStatus.result.success) { | ||||
|         addToast({ | ||||
|           title: upgradeStatus.result.success ? t('common.success') : t('common.error'), | ||||
|           body: upgradeStatus.result.success | ||||
|             ? t('firmware.upgrade_command_submitted') | ||||
|             : upgradeStatus.result.error, | ||||
|           color: upgradeStatus.result.success ? 'success' : 'danger', | ||||
|           autohide: true, | ||||
|         }); | ||||
|         setShowUpgradeModal(false); | ||||
|       } | ||||
|       setUpgradeStatus({ | ||||
|         loading: false, | ||||
|       }); | ||||
|       setShowUpgradeModal(false); | ||||
|     } | ||||
|   }, [upgradeStatus]); | ||||
|  | ||||
|   | ||||
| @@ -111,7 +111,18 @@ const DeviceFirmwareModal = ({ | ||||
|           }, | ||||
|         }); | ||||
|       }) | ||||
|       .catch(() => { | ||||
|       .catch((e) => { | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|         setUpgradeStatus({ | ||||
|           loading: false, | ||||
|           result: { | ||||
|   | ||||
| @@ -34,12 +34,17 @@ const EventQueueModal = ({ show, toggle }) => { | ||||
|         setResult(response.data); | ||||
|       }) | ||||
|       .catch((e) => { | ||||
|         addToast({ | ||||
|           title: t('common.error'), | ||||
|           body: t('commands.unable_queue', { error: e.response?.data?.ErrorDescription }), | ||||
|           color: 'danger', | ||||
|           autohide: true, | ||||
|         }); | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }) | ||||
|       .finally(() => { | ||||
|         setLoading(false); | ||||
|   | ||||
| @@ -18,7 +18,7 @@ import React, { useState, useEffect } from 'react'; | ||||
| import { useTranslation } from 'react-i18next'; | ||||
| import PropTypes from 'prop-types'; | ||||
| import 'react-widgets/styles.css'; | ||||
| import { useAuth, useDevice } from 'ucentral-libs'; | ||||
| import { useAuth, useDevice, useToast } from 'ucentral-libs'; | ||||
| import axiosInstance from 'utils/axiosInstance'; | ||||
| import SuccessfulActionModalBody from 'components/SuccessfulActionModalBody'; | ||||
|  | ||||
| @@ -26,6 +26,7 @@ const ConfigureModal = ({ show, toggleModal }) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const { currentToken, endpoints } = useAuth(); | ||||
|   const { deviceSerialNumber } = useDevice(); | ||||
|   const { addToast } = useToast(); | ||||
|   const [hadSuccess, setHadSuccess] = useState(false); | ||||
|   const [hadFailure, setHadFailure] = useState(false); | ||||
|   const [doingNow, setDoingNow] = useState(false); | ||||
| @@ -74,7 +75,18 @@ const ConfigureModal = ({ show, toggleModal }) => { | ||||
|       .then(() => { | ||||
|         setHadSuccess(true); | ||||
|       }) | ||||
|       .catch(() => { | ||||
|       .catch((e) => { | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|         setResponseBody(t('commands.error')); | ||||
|         setHadFailure(true); | ||||
|       }) | ||||
|   | ||||
| @@ -89,7 +89,18 @@ const ActionModal = ({ show, toggleModal }) => { | ||||
|         }); | ||||
|         toggleModal(); | ||||
|       }) | ||||
|       .catch(() => { | ||||
|       .catch((e) => { | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|         setResult('error'); | ||||
|       }) | ||||
|       .finally(() => { | ||||
|   | ||||
| @@ -105,12 +105,17 @@ const TelemetryModal = ({ show, toggle }) => { | ||||
|         } | ||||
|       }) | ||||
|       .catch((e) => { | ||||
|         addToast({ | ||||
|           title: t('common.error'), | ||||
|           body: t('telemetry.connection_failed', { error: e.response?.data?.ErrorDescription }), | ||||
|           color: 'danger', | ||||
|           autohide: true, | ||||
|         }); | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }) | ||||
|       .finally(() => setLoading(false)); | ||||
|   }; | ||||
|   | ||||
| @@ -23,13 +23,14 @@ import PropTypes from 'prop-types'; | ||||
| import 'react-widgets/styles.css'; | ||||
| import axiosInstance from 'utils/axiosInstance'; | ||||
| import eventBus from 'utils/eventBus'; | ||||
| import { LoadingButton, useAuth, useDevice } from 'ucentral-libs'; | ||||
| import { LoadingButton, useAuth, useDevice, useToast } from 'ucentral-libs'; | ||||
| import SuccessfulActionModalBody from 'components/SuccessfulActionModalBody'; | ||||
| import WaitingForTraceBody from './WaitingForTraceBody'; | ||||
|  | ||||
| const TraceModal = ({ show, toggleModal }) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const { currentToken, endpoints } = useAuth(); | ||||
|   const { addToast } = useToast(); | ||||
|   const { deviceSerialNumber, getDeviceConnection } = useDevice(); | ||||
|   const [hadSuccess, setHadSuccess] = useState(false); | ||||
|   const [hadFailure, setHadFailure] = useState(false); | ||||
| @@ -94,7 +95,18 @@ const TraceModal = ({ show, toggleModal }) => { | ||||
|           setWaitingForTrace(true); | ||||
|         } | ||||
|       }) | ||||
|       .catch(() => { | ||||
|       .catch((e) => { | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|         setResponseBody(t('commands.error')); | ||||
|         setHadFailure(true); | ||||
|       }) | ||||
|   | ||||
| @@ -20,7 +20,7 @@ import PropTypes from 'prop-types'; | ||||
| import axiosInstance from 'utils/axiosInstance'; | ||||
| import eventBus from 'utils/eventBus'; | ||||
| import { prettyDateForFile } from 'utils/helper'; | ||||
| import { useAuth, useDevice } from 'ucentral-libs'; | ||||
| import { useAuth, useDevice, useToast } from 'ucentral-libs'; | ||||
| import WifiChannelTable from 'components/WifiScanResultModal/WifiChannelTable'; | ||||
| import 'react-widgets/styles.css'; | ||||
| import { CSVLink } from 'react-csv'; | ||||
| @@ -33,6 +33,7 @@ const WifiScanModal = ({ show, toggleModal }) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const { currentToken, endpoints } = useAuth(); | ||||
|   const { deviceSerialNumber } = useDevice(); | ||||
|   const { addToast } = useToast(); | ||||
|   const [hadSuccess, setHadSuccess] = useState(false); | ||||
|   const [selectedIes, setSelectedIes] = useState(undefined); | ||||
|   const [hadFailure, setHadFailure] = useState(false); | ||||
| @@ -172,7 +173,18 @@ const WifiScanModal = ({ show, toggleModal }) => { | ||||
|           setHadFailure(true); | ||||
|         } | ||||
|       }) | ||||
|       .catch(() => { | ||||
|       .catch((e) => { | ||||
|         if (e.response?.data?.ErrorDescription !== undefined) { | ||||
|           const split = e.response?.data?.ErrorDescription.split(':'); | ||||
|           if (split !== undefined && split.length >= 2) { | ||||
|             addToast({ | ||||
|               title: t('common.error'), | ||||
|               body: split[1], | ||||
|               color: 'danger', | ||||
|               autohide: true, | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|         setHadFailure(true); | ||||
|       }) | ||||
|       .finally(() => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Charles
					Charles