From 6f5d2170c2ba7df80fcb5fc10436205b50c13279 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 28 Sep 2021 11:23:22 -0400 Subject: [PATCH] Fixing device list if we receive 0 devices --- package-lock.json | 4 ++-- package.json | 2 +- public/locales/de/translation.json | 1 + public/locales/en/translation.json | 1 + public/locales/es/translation.json | 1 + public/locales/fr/translation.json | 1 + public/locales/pt/translation.json | 1 + src/components/DeviceListTable/index.js | 31 ++++++++++++++----------- 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 91d9e97..b0e104a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "2.2.0", + "version": "2.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "2.2.0", + "version": "2.2.1", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index 4f1afc6..5e19459 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "2.2.0", + "version": "2.2.1", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index e8008b4..a3d45ab 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -170,6 +170,7 @@ "configuration": { "add_configuration": "Konfiguration hinzufügen", "add_new_block": "Neuen Konfigurationsblock hinzufügen", + "add_or_link": "Verlinken oder hinzufügen", "cannot_delete": "Diese Konfiguration kann nicht gelöscht werden, da sie von mindestens einer Entität, einem Veranstaltungsort oder einem Gerät verwendet wird", "choose_section": "Welchen Abschnitt soll dieser Block enthalten?", "configuration_browser": "Konfigurationsbrowser", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 7607a3f..838fb20 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -170,6 +170,7 @@ "configuration": { "add_configuration": "Add Configuration", "add_new_block": "Add new Configuration Block", + "add_or_link": "Link or Add", "cannot_delete": "This configuration cannot be deleted because it is being used by at least one entity, venue or device", "choose_section": "Which section you would like this block to contain?", "configuration_browser": "Configuration Browser", diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index 98a9459..89fc458 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -170,6 +170,7 @@ "configuration": { "add_configuration": "Agregar configuración", "add_new_block": "Agregar nuevo bloque de configuración", + "add_or_link": "Vincular o agregar", "cannot_delete": "Esta configuración no se puede eliminar porque está siendo utilizada por al menos una entidad, lugar o dispositivo", "choose_section": "Qué sección le gustaría que contenga este bloque?", "configuration_browser": "Navegador de configuración", diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index 6e2e162..f7af7dd 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -170,6 +170,7 @@ "configuration": { "add_configuration": "Ajouter une configuration", "add_new_block": "Ajouter un nouveau bloc de configuration", + "add_or_link": "Lier ou ajouter", "cannot_delete": "Cette configuration ne peut pas être supprimée car elle est utilisée par au moins une entité, un lieu ou un appareil", "choose_section": "Quelle section souhaitez-vous que ce bloc contienne?", "configuration_browser": "Navigateur de configuration", diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index 15ec18e..9cefbf8 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -170,6 +170,7 @@ "configuration": { "add_configuration": "Adicionar configuração", "add_new_block": "Adicionar novo bloco de configuração", + "add_or_link": "Link ou adicionar", "cannot_delete": "Esta configuração não pode ser excluída porque está sendo usada por pelo menos uma entidade, local ou dispositivo", "choose_section": "Qual seção você gostaria que este bloco contivesse?", "configuration_browser": "Navegador de configuração", diff --git a/src/components/DeviceListTable/index.js b/src/components/DeviceListTable/index.js index ffd972d..fe36bd0 100644 --- a/src/components/DeviceListTable/index.js +++ b/src/components/DeviceListTable/index.js @@ -77,25 +77,30 @@ const DeviceList = () => { fullDevices = response.data.devicesWithStatus; const serialsToGet = fullDevices.map((device) => device.serialNumber); + if (serialsToGet.length === 0) { + return null; + } return axiosInstance.get( `${endpoints.owfms}/api/v1/firmwareAge?select=${serialsToGet}`, options, ); }) .then((response) => { - fullDevices = fullDevices.map((device, index) => { - const foundAgeDate = response.data.ages[index].age !== undefined; - if (foundAgeDate) { - return { - ...device, - firmwareInfo: { - age: response.data.ages[index].age, - latest: response.data.ages[index].latest, - }, - }; - } - return device; - }); + if (response !== null) { + fullDevices = fullDevices.map((device, index) => { + const foundAgeDate = response.data.ages[index].age !== undefined; + if (foundAgeDate) { + return { + ...device, + firmwareInfo: { + age: response.data.ages[index].age, + latest: response.data.ages[index].latest, + }, + }; + } + return device; + }); + } setDevices(fullDevices); setLoading(false); })