Merge pull request #106 from stephb9959/main

[WIFI-10850] Error descriptions on command failures
This commit is contained in:
Charles Bourque
2022-09-15 12:46:01 +01:00
committed by GitHub
17 changed files with 141 additions and 45 deletions

4
package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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(() => {

View File

@@ -103,12 +103,17 @@ const ConfigureModal = ({ show, toggleModal }) => {
}) })
.catch((e) => { .catch((e) => {
setResponseBody('Error while submitting command!'); setResponseBody('Error while submitting command!');
if (e.response?.data?.ErrorDescription !== undefined) {
const split = e.response?.data?.ErrorDescription.split(':');
if (split !== undefined && split.length >= 2) {
addToast({ addToast({
title: t('common.error'), title: t('common.error'),
body: `${t('common.general_error')}: ${e.response?.data?.ErrorDescription}`, body: split[1],
color: 'danger', color: 'danger',
autohide: true, autohide: true,
}); });
}
}
setHadFailure(true); setHadFailure(true);
}) })
.finally(() => { .finally(() => {

View File

@@ -54,12 +54,17 @@ const DeviceActions = ({ device }) => {
if (newWindow) newWindow.opener = null; if (newWindow) newWindow.opener = null;
}) })
.catch((e) => { .catch((e) => {
if (e.response?.data?.ErrorDescription !== undefined) {
const split = e.response?.data?.ErrorDescription.split(':');
if (split !== undefined && split.length >= 2) {
addToast({ addToast({
title: t('common.error'), title: t('common.error'),
body: t('connect.error_trying_to_connect', { error: e.response?.data?.ErrorDescription }), body: split[1],
color: 'danger', color: 'danger',
autohide: true, autohide: true,
}); });
}
}
}) })
.finally(() => { .finally(() => {
setConnectLoading(false); setConnectLoading(false);
@@ -68,6 +73,7 @@ const DeviceActions = ({ device }) => {
useEffect(() => { useEffect(() => {
if (upgradeStatus.result !== undefined) { if (upgradeStatus.result !== undefined) {
if (upgradeStatus.result.success) {
addToast({ addToast({
title: upgradeStatus.result.success ? t('common.success') : t('common.error'), title: upgradeStatus.result.success ? t('common.success') : t('common.error'),
body: upgradeStatus.result.success body: upgradeStatus.result.success
@@ -76,10 +82,11 @@ const DeviceActions = ({ device }) => {
color: upgradeStatus.result.success ? 'success' : 'danger', color: upgradeStatus.result.success ? 'success' : 'danger',
autohide: true, autohide: true,
}); });
setShowUpgradeModal(false);
}
setUpgradeStatus({ setUpgradeStatus({
loading: false, loading: false,
}); });
setShowUpgradeModal(false);
} }
}, [upgradeStatus]); }, [upgradeStatus]);

View File

@@ -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: {

View File

@@ -34,12 +34,17 @@ const EventQueueModal = ({ show, toggle }) => {
setResult(response.data); setResult(response.data);
}) })
.catch((e) => { .catch((e) => {
if (e.response?.data?.ErrorDescription !== undefined) {
const split = e.response?.data?.ErrorDescription.split(':');
if (split !== undefined && split.length >= 2) {
addToast({ addToast({
title: t('common.error'), title: t('common.error'),
body: t('commands.unable_queue', { error: e.response?.data?.ErrorDescription }), body: split[1],
color: 'danger', color: 'danger',
autohide: true, autohide: true,
}); });
}
}
}) })
.finally(() => { .finally(() => {
setLoading(false); setLoading(false);

View File

@@ -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);
}) })

View File

@@ -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(() => {

View File

@@ -105,12 +105,17 @@ const TelemetryModal = ({ show, toggle }) => {
} }
}) })
.catch((e) => { .catch((e) => {
if (e.response?.data?.ErrorDescription !== undefined) {
const split = e.response?.data?.ErrorDescription.split(':');
if (split !== undefined && split.length >= 2) {
addToast({ addToast({
title: t('common.error'), title: t('common.error'),
body: t('telemetry.connection_failed', { error: e.response?.data?.ErrorDescription }), body: split[1],
color: 'danger', color: 'danger',
autohide: true, autohide: true,
}); });
}
}
}) })
.finally(() => setLoading(false)); .finally(() => setLoading(false));
}; };

View File

@@ -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);
}) })

View File

@@ -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(() => {