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