From 6593be8bdf90f819593493c5e8cd7885545a0ed9 Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Wed, 30 Jun 2021 08:24:01 -0400 Subject: [PATCH 01/42] Health title made biggest on tile --- src/components/DeviceHealth/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/DeviceHealth/index.js b/src/components/DeviceHealth/index.js index 9fd47fd..0d8851e 100644 --- a/src/components/DeviceHealth/index.js +++ b/src/components/DeviceHealth/index.js @@ -185,8 +185,8 @@ const DeviceHealth = ({ selectedDeviceId }) => { return ( Date: Wed, 30 Jun 2021 08:24:19 -0400 Subject: [PATCH 02/42] Trace download now a button instead of a link --- .../TraceModal/WaitingForTraceBody.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/TraceModal/WaitingForTraceBody.js b/src/components/TraceModal/WaitingForTraceBody.js index abd65f8..c351035 100644 --- a/src/components/TraceModal/WaitingForTraceBody.js +++ b/src/components/TraceModal/WaitingForTraceBody.js @@ -81,16 +81,15 @@ const WaitingForTraceBody = ({serialNumber, commandUuid, toggle}) => {

{t('trace.waiting_directions')}

- From 84de2595b9705ebfdcd48f31196ba2ae42fdbcbe Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Wed, 30 Jun 2021 08:24:36 -0400 Subject: [PATCH 03/42] Changed button label in blink modal --- 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/BlinkModal/index.js | 2 +- 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 2e540f9..25e543a 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -15,6 +15,7 @@ "blink": "LEDs Blinken", "device_leds": "LEDs", "pattern": "Wählen Sie das Muster, das Sie verwenden möchten:", + "set_leds": "LEDs einstellen", "when_blink_leds": "Wann möchten Sie die LEDs blinken lassen?" }, "commands": { diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index cc0eff3..2a8278b 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -15,6 +15,7 @@ "blink": "Blink", "device_leds": "Device LEDs", "pattern": "Choose the pattern you would like to use: ", + "set_leds": "Set LEDs", "when_blink_leds": "When would you like to make the device LEDs blink?" }, "commands": { diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index 6931936..94613d6 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -15,6 +15,7 @@ "blink": "Parpadeo", "device_leds": "LED de dispositivo", "pattern": "Elija el patrón que le gustaría usar:", + "set_leds": "Establecer LED", "when_blink_leds": "¿Cuándo desea que los LED del dispositivo parpadeen?" }, "commands": { diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index 58db11d..4be56a7 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -15,6 +15,7 @@ "blink": "Cligner", "device_leds": "LED de l'appareil", "pattern": "Choisissez le modèle que vous souhaitez utiliser :", + "set_leds": "Définir les LED", "when_blink_leds": "Quand souhaitez-vous faire clignoter les LED de l'appareil ?" }, "commands": { diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index 0b82af7..2fb3498 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -15,6 +15,7 @@ "blink": "Piscar", "device_leds": "LEDs do dispositivo", "pattern": "Escolha o padrão que deseja usar:", + "set_leds": "Definir LEDs", "when_blink_leds": "Quando você gostaria de fazer os LEDs do dispositivo piscarem?" }, "commands": { diff --git a/src/components/BlinkModal/index.js b/src/components/BlinkModal/index.js index a2d9f41..0b2aa85 100644 --- a/src/components/BlinkModal/index.js +++ b/src/components/BlinkModal/index.js @@ -173,7 +173,7 @@ const BlinkModal = ({ show, toggleModal }) => { Date: Wed, 30 Jun 2021 08:25:19 -0400 Subject: [PATCH 04/42] Version 0.9.6 --- package-lock.json | 4 ++-- package.json | 2 +- src/layout/Footer/index.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7c29ab7..8abd3b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "0.9.5", + "version": "0.9.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "0.9.5", + "version": "0.9.6", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index d11fbcb..a5f2c15 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "0.9.5", + "version": "0.9.6", "private": true, "dependencies": { "@coreui/coreui": "^3.4.0", diff --git a/src/layout/Footer/index.js b/src/layout/Footer/index.js index 009bc31..142f08d 100644 --- a/src/layout/Footer/index.js +++ b/src/layout/Footer/index.js @@ -6,7 +6,7 @@ const TheFooter = () => ( {(t) => ( -
{t('footer.version')} 0.9.5
+
{t('footer.version')} 0.9.6
{t('footer.powered_by')} From c83b8eb8aa07b2f8731668d4dd671ccf970a59e0 Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Wed, 30 Jun 2021 15:16:06 -0400 Subject: [PATCH 05/42] Device configuration CSS cleanup --- src/components/BlinkModal/index.js | 2 +- src/components/CopyToClipboardButton/index.js | 21 +- src/components/DeviceActionCard/index.js | 4 +- src/components/DeviceConfiguration/index.js | 202 +++++++++--------- .../DeviceConfiguration/index.module.scss | 5 + 5 files changed, 119 insertions(+), 115 deletions(-) diff --git a/src/components/BlinkModal/index.js b/src/components/BlinkModal/index.js index 0b2aa85..ee6a13a 100644 --- a/src/components/BlinkModal/index.js +++ b/src/components/BlinkModal/index.js @@ -39,7 +39,7 @@ const BlinkModal = ({ show, toggleModal }) => { const toggleNow = () => { setIsNow(!isNow); - } + }; const setDate = (date) => { if (date) { diff --git a/src/components/CopyToClipboardButton/index.js b/src/components/CopyToClipboardButton/index.js index a584e81..b81371c 100644 --- a/src/components/CopyToClipboardButton/index.js +++ b/src/components/CopyToClipboardButton/index.js @@ -5,28 +5,29 @@ import { cilClone } from '@coreui/icons'; import PropTypes from 'prop-types'; import { CButton, CPopover } from '@coreui/react'; -const CopyToClipboardButton = ({content, size}) => { +const CopyToClipboardButton = ({ content, size }) => { const { t } = useTranslation(); const [result, setResult] = useState(''); const copyToClipboard = () => { navigator.clipboard.writeText(content); setResult(t('common.copied')); - } + }; return ( - - - - {' '}{result || ''} - - + + + + {' '} + {result || ''} + + ); -} +}; CopyToClipboardButton.propTypes = { content: PropTypes.string.isRequired, - size: PropTypes.string + size: PropTypes.string, }; CopyToClipboardButton.defaultProps = { diff --git a/src/components/DeviceActionCard/index.js b/src/components/DeviceActionCard/index.js index e5327db..93c86a3 100644 --- a/src/components/DeviceActionCard/index.js +++ b/src/components/DeviceActionCard/index.js @@ -78,7 +78,9 @@ const DeviceActions = ({ selectedDeviceId }) => { return ( -
{t('actions.title')}
+ +
{t('actions.title')}
+
diff --git a/src/components/DeviceConfiguration/index.js b/src/components/DeviceConfiguration/index.js index ee4c0f4..8df373d 100644 --- a/src/components/DeviceConfiguration/index.js +++ b/src/components/DeviceConfiguration/index.js @@ -4,10 +4,8 @@ import { CCard, CCardHeader, CCardBody, - CFormGroup, CCol, CLabel, - CForm, CInput, CCollapse, CCardFooter, @@ -66,7 +64,9 @@ const DeviceConfiguration = ({ selectedDeviceId }) => { -
{t('configuration.title')}
+ +
{t('configuration.title')}
+
@@ -79,122 +79,118 @@ const DeviceConfiguration = ({ selectedDeviceId }) => { - - + + + {t('common.uuid')} : + + + {device.UUID} + + + + + {t('common.serial_number')} : + + + {device.serialNumber} + + + + + + {t('configuration.type')} : + + + {device.deviceType} + + + + + {t('configuration.last_configuration_change')} : + + + {prettyDate(device.lastConfigurationChange)} + + + + + {t('common.mac')} : + + + {device.macAddress} + + + + + {t('configuration.created')} : + + + {prettyDate(device.createdTimestamp)} + + + + + {t('configuration.last_configuration_download')} : + + + {prettyDate(device.lastConfigurationDownload)} + + + + + {t('configuration.device_password')} : + + + {device.devicePassword === '' ? 'openwifi' : device.devicePassword} + + + + + - {t('common.uuid')} : + {t('common.manufacturer')} : - {device.UUID} + {device.manufacturer} - - + + - {t('common.serial_number')} : + {t('configuration.notes')} : - {device.serialNumber} - + - - + + - {t('configuration.type')} : + {t('configuration.owner')} : - {device.deviceType} + {device.owner} - - + + - {t('configuration.last_configuration_change')} : + {t('configuration.location')} : - {prettyDate(device.lastConfigurationChange)} + {device.location} - - - - {t('common.mac')} : - - - {device.macAddress} - - - - - {t('configuration.created')} : - - - {prettyDate(device.createdTimestamp)} - - - - - {t('configuration.last_configuration_download')} : - - - {prettyDate(device.lastConfigurationDownload)} - - - - - {t('configuration.device_password')} : - - - {device.devicePassword === '' ? 'openwifi' : device.devicePassword} - - - - - - - {t('common.manufacturer')} : - - - {device.manufacturer} - - - - - {t('configuration.notes')} : - - - - - - - - {t('configuration.owner')} : - - - {device.owner} - - - - - {t('configuration.location')} : - - - {device.location} - - - - - - - - - + + + + + + + diff --git a/src/components/DeviceConfiguration/index.module.scss b/src/components/DeviceConfiguration/index.module.scss index 364d894..6c9025c 100644 --- a/src/components/DeviceConfiguration/index.module.scss +++ b/src/components/DeviceConfiguration/index.module.scss @@ -13,3 +13,8 @@ .topPadding { padding-top: 5px; } + +.spacedRow { + margin-top: 5px; + margin-bottom: 5px; +} From 97b3716dc9bfab182d618b4a5996f690861a7b81 Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Wed, 30 Jun 2021 15:17:09 -0400 Subject: [PATCH 06/42] Prettier run --- src/components/DeviceListTable/index.js | 12 ++++-- .../FirmwareUpgradeModal/UpgradeFooter.js | 11 ++++- src/components/FirmwareUpgradeModal/index.js | 13 +++--- .../StatisticsChartList.js | 42 +++++++++---------- src/components/InterfaceStatistics/index.js | 4 +- src/components/RebootModal/index.js | 2 +- .../TraceModal/WaitingForTraceBody.js | 23 +++++----- src/components/TraceModal/index.js | 25 ++++++----- src/components/WifiScanModal/index.js | 6 +-- 9 files changed, 77 insertions(+), 61 deletions(-) diff --git a/src/components/DeviceListTable/index.js b/src/components/DeviceListTable/index.js index 44dafdc..dfd36e4 100644 --- a/src/components/DeviceListTable/index.js +++ b/src/components/DeviceListTable/index.js @@ -337,7 +337,9 @@ const DeviceListDisplay = ({ content={item.firmware ? item.firmware : t('common.na')} placement="top" > -

{item.firmware}

+

+ {item.firmware} +

), @@ -347,7 +349,9 @@ const DeviceListDisplay = ({ content={item.compatible ? item.compatible : t('common.na')} placement="top" > -

{item.compatible}

+

+ {item.compatible} +

), @@ -359,7 +363,9 @@ const DeviceListDisplay = ({ content={item.ipAddress ? item.ipAddress : t('common.na')} placement="top" > -

{item.ipAddress}

+

+ {item.ipAddress} +

), diff --git a/src/components/FirmwareUpgradeModal/UpgradeFooter.js b/src/components/FirmwareUpgradeModal/UpgradeFooter.js index b4a3077..cf067e6 100644 --- a/src/components/FirmwareUpgradeModal/UpgradeFooter.js +++ b/src/components/FirmwareUpgradeModal/UpgradeFooter.js @@ -3,7 +3,16 @@ import { useTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; import { CButton, CSpinner, CModalFooter } from '@coreui/react'; -const UpgradeFooter = ({ isNow, isShown, isLoading, action, color, variant, block, toggleParent }) => { +const UpgradeFooter = ({ + isNow, + isShown, + isLoading, + action, + color, + variant, + block, + toggleParent, +}) => { const { t } = useTranslation(); const [askingIfSure, setAskingIfSure] = useState(false); diff --git a/src/components/FirmwareUpgradeModal/index.js b/src/components/FirmwareUpgradeModal/index.js index 51182cf..b8ee19b 100644 --- a/src/components/FirmwareUpgradeModal/index.js +++ b/src/components/FirmwareUpgradeModal/index.js @@ -42,11 +42,10 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { const selectedDeviceId = useSelector((state) => state.selectedDeviceId); const toggleNow = () => { - if(isNow){ + if (isNow) { setWaitForUpgrade(false); setDisableWaiting(true); - } - else{ + } else { setDisableWaiting(false); } @@ -114,8 +113,7 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { setShowWaitingConsole(true); } }) - .catch(() => { - }) + .catch(() => {}) .finally(() => { setBlockFields(false); setWaitingForUpgrade(false); @@ -198,7 +196,10 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { {t('common.need_date')} -
-
{t('trace.waiting_seconds', {seconds: secondsElapsed})}
+
{t('trace.waiting_seconds', { seconds: secondsElapsed })}

{t('trace.waiting_directions')}

- ); -} +}; WaitingForTraceBody.propTypes = { serialNumber: PropTypes.string.isRequired, commandUuid: PropTypes.string.isRequired, - toggle: PropTypes.func.isRequired + toggle: PropTypes.func.isRequired, }; export default WaitingForTraceBody; diff --git a/src/components/TraceModal/index.js b/src/components/TraceModal/index.js index f274d2f..1060120 100644 --- a/src/components/TraceModal/index.js +++ b/src/components/TraceModal/index.js @@ -47,7 +47,7 @@ const TraceModal = ({ show, toggleModal }) => { const toggleWaitForTrace = () => { setWaitForTrace(!waitForTrace); - } + }; useEffect(() => { setWaitForTrace(false); @@ -88,7 +88,7 @@ const TraceModal = ({ show, toggleModal }) => { .post(`/device/${encodeURIComponent(selectedDeviceId)}/trace`, parameters, { headers }) .then((response) => { setHadSuccess(true); - if(waitForTrace) { + if (waitForTrace) { setCommandUuid(response.data.UUID); setWaitingForTrace(true); } @@ -114,17 +114,18 @@ const TraceModal = ({ show, toggleModal }) => { } }, [show]); - const getBody = () => { - if(waitingForTrace){ + if (waitingForTrace) { return ( - + ); } - if(hadSuccess){ - return( - - ); + if (hadSuccess) { + return ; } return (
@@ -221,9 +222,7 @@ const TraceModal = ({ show, toggleModal }) => {
); - } + }; return ( diff --git a/src/components/WifiScanModal/index.js b/src/components/WifiScanModal/index.js index a3d51a9..738285a 100644 --- a/src/components/WifiScanModal/index.js +++ b/src/components/WifiScanModal/index.js @@ -9,7 +9,7 @@ import { CForm, CSwitch, CCol, - CSpinner + CSpinner, } from '@coreui/react'; import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; @@ -186,7 +186,7 @@ const WifiScanModal = ({ show, toggleModal }) => {
{ disabled={waiting} /> - {(!hadSuccess && !hadFailure) ? t('common.cancel') : t('common.exit')} + {!hadSuccess && !hadFailure ? t('common.cancel') : t('common.exit')} From 87b345022123efa3800109187138819f173a8935 Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Wed, 30 Jun 2021 15:17:36 -0400 Subject: [PATCH 07/42] First version of device status card --- public/locales/de/translation.json | 21 ++ public/locales/en/translation.json | 21 ++ public/locales/es/translation.json | 21 ++ public/locales/fr/translation.json | 21 ++ public/locales/pt/translation.json | 21 ++ src/components/DeviceStatusCard/MemoryBar.js | 36 ++++ src/components/DeviceStatusCard/index.js | 193 ++++++++++++++++++ .../DeviceStatusCard/index.module.scss | 29 +++ src/pages/DevicePage/index.js | 4 +- src/utils/helper.js | 44 ++++ 10 files changed, 410 insertions(+), 1 deletion(-) create mode 100644 src/components/DeviceStatusCard/MemoryBar.js create mode 100644 src/components/DeviceStatusCard/index.js create mode 100644 src/components/DeviceStatusCard/index.module.scss diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 25e543a..7e9eb73 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -38,6 +38,8 @@ "copied": "kopiert!", "copy_to_clipboard": "In die Zwischenablage kopieren", "date": "Datum", + "day": "tag", + "days": "tage", "delete": "Löschen", "details": "Einzelheiten", "device_list": "Liste der Geräte", @@ -53,6 +55,8 @@ "exit": "Ausgang", "firmware": "Firmware", "from": "Von", + "hour": "stunde", + "hours": "std", "id": "ID", "ip_address": "IP Adresse", "later_tonight": "Später am Abend", @@ -61,6 +65,8 @@ "logout": "Ausloggen", "mac": "MAC-Adresse", "manufacturer": "Hersteller", + "minute": "Minute", + "minutes": "protokoll", "na": "(unbekannt)", "need_date": "Du brauchst ein Datum...", "no": "Nein", @@ -74,6 +80,8 @@ "save": "Sparen", "saving": "Speichern ...", "schedule": "Zeitplan", + "second": "zweite", + "seconds": "sekunden", "seconds_elapsed": "Sekunden verstrichen", "serial_number": "Seriennummer", "start": "Start", @@ -168,6 +176,19 @@ "show_latest": "Neueste Statistiken anzeigen JSON", "title": "Statistiken" }, + "status": { + "connection_status": "Verbindungsstatus", + "error": "Statusdaten sind nicht verfügbar", + "last_contact": "Letzter Kontakt", + "load_averages": "Belastung (Durchschnitt 1 / 5 / 15 Minuten)", + "localtime": "Ortszeit", + "memory": "Verwendeter Speicher", + "percentage_free": "{{percentage}}% von {{total}} kostenlos", + "percentage_used": "{{percentage}}% von {{total}} verwendet", + "title": "#{{serialNumber}} Status", + "uptime": "Betriebszeit", + "used_total_memory": "{{used}} verwendet / {{total}} insgesamt" + }, "trace": { "choose_network": "Netzwerk auswählen", "directions": "Starten Sie eine Tcpdump auf diesem Geräts für eine bestimmte Dauer oder eine Anzahl von Paketen", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 2a8278b..327694c 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -38,6 +38,8 @@ "copied": "Copied!", "copy_to_clipboard": "Copy to clipboard", "date": "Date", + "day": "day", + "days": "days", "delete": "Delete", "details": "Details", "device_list": "List of Devices", @@ -53,6 +55,8 @@ "exit": "Exit", "firmware": "Firmware", "from": "From", + "hour": "hour", + "hours": "hours", "id": "Id", "ip_address": "Ip Address", "later_tonight": "Later tonight", @@ -61,6 +65,8 @@ "logout": "Logout", "mac": "MAC Address", "manufacturer": "Manufacturer", + "minute": "minute", + "minutes": "minutes", "na": "N/A", "need_date": "You need a date...", "no": "No", @@ -74,6 +80,8 @@ "save": "Save", "saving": "Saving... ", "schedule": "Schedule", + "second": "second", + "seconds": "seconds", "seconds_elapsed": "Seconds elapsed", "serial_number": "Serial Number", "start": "Start", @@ -168,6 +176,19 @@ "show_latest": "Show latest statistics JSON", "title": "Statistics" }, + "status": { + "connection_status": "Connection Status", + "error": "Status data is unavailable", + "last_contact": "Last Contact", + "load_averages": "Load ( 1 / 5 / 15 minute average)", + "localtime": "Localtime", + "memory": "Memory Used", + "percentage_free": "{{percentage}}% of {{total}} free", + "percentage_used": "{{percentage}}% of {{total}} used", + "title": "#{{serialNumber}} Status", + "uptime": "Uptime", + "used_total_memory": "{{used}} used / {{total}} total " + }, "trace": { "choose_network": "Choose network", "directions": "Launch a remote trace of this device for either a specific duration or a number of packets", diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index 94613d6..407f465 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -38,6 +38,8 @@ "copied": "Copiado!", "copy_to_clipboard": "Copiar al portapapeles", "date": "Fecha", + "day": "día", + "days": "días", "delete": "Borrar", "details": "Detalles", "device_list": "Listado de dispositivos", @@ -53,6 +55,8 @@ "exit": "salida", "firmware": "Firmware", "from": "Desde", + "hour": "hora", + "hours": "horas", "id": "Carné de identidad", "ip_address": "Dirección IP", "later_tonight": "Más tarde esta noche", @@ -61,6 +65,8 @@ "logout": "Cerrar sesión", "mac": "Dirección MAC", "manufacturer": "Fabricante", + "minute": "minuto", + "minutes": "minutos", "na": "N / A", "need_date": "Necesitas una cita ...", "no": "No", @@ -74,6 +80,8 @@ "save": "Salvar", "saving": "Ahorro...", "schedule": "Programar", + "second": "segundo", + "seconds": "segundos", "seconds_elapsed": "Segundos transcurridos", "serial_number": "Número de serie", "start": "comienzo", @@ -168,6 +176,19 @@ "show_latest": "Mostrar las últimas estadísticas JSON", "title": "estadística" }, + "status": { + "connection_status": "Estado de conexión", + "error": "Los datos de estado no están disponibles", + "last_contact": "Último contacto", + "load_averages": "Carga (promedio de 1/5/15 minutos)", + "localtime": "Hora local", + "memory": "Memoria usada", + "percentage_free": "{{percentage}}% de {{total}} gratis", + "percentage_used": "{{percentage}}% de {{total}} utilizado", + "title": "#{{serialNumber}} Estado", + "uptime": "Tiempo de actividad", + "used_total_memory": "{{used}} usado / {{total}} total" + }, "trace": { "choose_network": "Elija la red", "directions": "Lanzar un rastreo remoto de este dispositivo por una duración específica o por una cantidad de paquetes", diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index 4be56a7..e2eba9d 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -38,6 +38,8 @@ "copied": "Copié!", "copy_to_clipboard": "Copier dans le presse-papier", "date": "Rendez-vous amoureux", + "day": "journée", + "days": "journées", "delete": "Effacer", "details": "Détails", "device_list": "Liste des appareils", @@ -53,6 +55,8 @@ "exit": "Sortie", "firmware": "Micrologiciel", "from": "De", + "hour": "heure", + "hours": "heures", "id": "Id", "ip_address": "Adresse IP", "later_tonight": "Plus tard ce soir", @@ -61,6 +65,8 @@ "logout": "Connectez - Out", "mac": "ADRESSE MAC", "manufacturer": "fabricant", + "minute": "minute", + "minutes": "minutes", "na": "N / A", "need_date": "Vous avez besoin d'un rendez-vous...", "no": "Non", @@ -74,6 +80,8 @@ "save": "Sauvegarder", "saving": "Économie...", "schedule": "Programme", + "second": "seconde", + "seconds": "secondes", "seconds_elapsed": "Secondes écoulées", "serial_number": "Numéro de série", "start": "Début", @@ -168,6 +176,19 @@ "show_latest": "Afficher les dernières statistiques JSON", "title": "statistiques" }, + "status": { + "connection_status": "Statut de connexion", + "error": "Les données d'état ne sont pas disponibles", + "last_contact": "Dernier contact", + "load_averages": "Charge (moyenne 1 / 5 / 15 minutes)", + "localtime": "heure locale", + "memory": "Mémoire utilisée", + "percentage_free": "{{percentage}}% de {{total}} gratuit", + "percentage_used": "{{percentage}}% de {{total}} utilisé", + "title": "#{{serialNumber}} état", + "uptime": "La disponibilité", + "used_total_memory": "{{used}} utilisé / {{total}} total" + }, "trace": { "choose_network": "Choisir le réseau", "directions": "Lancer une trace à distance de cet appareil pour une durée spécifique ou un nombre de paquets", diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index 2fb3498..1e45a27 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -38,6 +38,8 @@ "copied": "Copiado!", "copy_to_clipboard": "Copiar para área de transferência", "date": "Encontro", + "day": "dia", + "days": "dias", "delete": "Excluir", "details": "Detalhes", "device_list": "Lista de Dispositivos", @@ -53,6 +55,8 @@ "exit": "Saída", "firmware": "Firmware", "from": "De", + "hour": "hora", + "hours": "horas", "id": "identidade", "ip_address": "Endereço de IP", "later_tonight": "Logo à noite", @@ -61,6 +65,8 @@ "logout": "Sair", "mac": "Endereço MAC", "manufacturer": "Fabricante", + "minute": "minuto", + "minutes": "minutos", "na": "N / D", "need_date": "Você precisa de um encontro ...", "no": "Não", @@ -74,6 +80,8 @@ "save": "Salve", "saving": "Salvando ...", "schedule": "Cronograma", + "second": "segundo", + "seconds": "segundos", "seconds_elapsed": "Segundos decorridos", "serial_number": "Número de série", "start": "Começar", @@ -168,6 +176,19 @@ "show_latest": "Mostrar estatísticas mais recentes JSON", "title": "Estatisticas" }, + "status": { + "connection_status": "Status da conexão", + "error": "Dados de status indisponíveis", + "last_contact": "Último contato", + "load_averages": "Carga (1/5/15 minutos em média)", + "localtime": "Horário local", + "memory": "Memória Usada", + "percentage_free": "{{percentage}}% de {{total}} grátis", + "percentage_used": "{{percentage}}% de {{total}} usado", + "title": "#{{serialNumber}} status", + "uptime": "Tempo de atividade", + "used_total_memory": "{{used}} usado / {{total}} total" + }, "trace": { "choose_network": "Escolha a rede", "directions": "Lançar um rastreamento remoto deste dispositivo para uma duração específica ou um número de pacotes", diff --git a/src/components/DeviceStatusCard/MemoryBar.js b/src/components/DeviceStatusCard/MemoryBar.js new file mode 100644 index 0000000..be957db --- /dev/null +++ b/src/components/DeviceStatusCard/MemoryBar.js @@ -0,0 +1,36 @@ +import React from 'react'; +import { CPopover, CProgress, CProgressBar } from '@coreui/react'; +import PropTypes from 'prop-types'; +import { useTranslation } from 'react-i18next'; +import { cleanBytesString } from 'utils/helper'; + +const MemoryBar = ({ usedBytes, totalBytes }) => { + const { t } = useTranslation(); + const used = cleanBytesString(usedBytes); + const total = cleanBytesString(totalBytes); + const percentage = Math.floor((usedBytes / totalBytes) * 100); + + return ( + + + + {percentage >= 25 ? t('status.percentage_used', { percentage, total }) : ''} + + +
+ {percentage < 25 + ? t('status.percentage_free', { percentage: 100 - percentage, total }) + : ''} +
+
+
+
+ ); +}; + +MemoryBar.propTypes = { + usedBytes: PropTypes.number.isRequired, + totalBytes: PropTypes.number.isRequired, +}; + +export default React.memo(MemoryBar); diff --git a/src/components/DeviceStatusCard/index.js b/src/components/DeviceStatusCard/index.js new file mode 100644 index 0000000..1f89fde --- /dev/null +++ b/src/components/DeviceStatusCard/index.js @@ -0,0 +1,193 @@ +import React, { useState, useEffect } from 'react'; +import { + CCard, + CCardHeader, + CRow, + CCol, + CCardBody, + CBadge, + CModalBody, + CAlert, + CPopover, + CButton, + CSpinner, +} from '@coreui/react'; +import CIcon from '@coreui/icons-react'; +import { cilSync } from '@coreui/icons'; +import { useTranslation } from 'react-i18next'; +import PropTypes from 'prop-types'; +import axiosInstance from 'utils/axiosInstance'; +import { getToken } from 'utils/authHelper'; +import { prettyDate, secondsToDetailed } from 'utils/helper'; +import MemoryBar from './MemoryBar'; + +import styles from './index.module.scss'; + +const DeviceStatusCard = ({ selectedDeviceId }) => { + const { t } = useTranslation(); + const [lastStats, setLastStats] = useState(null); + const [status, setStatus] = useState(null); + const [error, setError] = useState(false); + const [loading, setLoading] = useState(false); + + const transformLoad = (load) => { + if (load === undefined) return t('common.na'); + return `${((load / 65536) * 100).toFixed(2)}%`; + }; + + const getData = () => { + setLoading(true); + const options = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${getToken()}`, + }, + }; + + const lastStatsRequest = axiosInstance.get( + `/device/${encodeURIComponent(selectedDeviceId)}/statistics?lastOnly=true`, + options, + ); + const statusRequest = axiosInstance.get( + `/device/${encodeURIComponent(selectedDeviceId)}/status`, + options, + ); + + Promise.all([lastStatsRequest, statusRequest]) + .then(([newStats, newStatus]) => { + setLastStats(newStats.data); + setStatus(newStatus.data); + }) + .catch(() => { + setError(true); + }) + .finally(() => { + setLoading(false); + }); + }; + + useEffect(() => { + setError(false); + if (selectedDeviceId) getData(); + }, [selectedDeviceId]); + + if (!error) { + return ( + + + + +
+ {t('status.title', { serialNumber: selectedDeviceId })} +
+
+ +
+ + + + + +
+
+
+
+ + {(!lastStats || !status) && loading ? ( +
+ +
+ ) : ( +
+ + + {t('status.connection_status')} : + + {status?.connected ? ( + {t('common.connected')} + ) : ( + {t('common.not_connected')} + )} + + + + {t('status.uptime')} : + + {secondsToDetailed( + lastStats?.unit?.uptime, + t('common.day'), + t('common.days'), + t('common.hour'), + t('common.hours'), + t('common.minute'), + t('common.minutes'), + t('common.second'), + t('common.seconds'), + )} + + + + {t('status.last_contact')} : + + {prettyDate(status?.lastContact)} + + + + {t('status.localtime')} : + + {prettyDate(lastStats?.unit?.localtime)} + + + + {t('status.load_averages')} : + + {transformLoad(lastStats?.unit?.load[0])} + {' / '} + {transformLoad(lastStats?.unit?.load[1])} + {' / '} + {transformLoad(lastStats?.unit?.load[2])} + + + + {t('status.memory')} : + + + + +
+ )} +
+
+ ); + } + + return ( + + + + +
+ {t('status.title', { serialNumber: selectedDeviceId })} +
+
+
+
+ + + +
+ ); +}; + +DeviceStatusCard.propTypes = { + selectedDeviceId: PropTypes.string.isRequired, +}; + +export default React.memo(DeviceStatusCard); diff --git a/src/components/DeviceStatusCard/index.module.scss b/src/components/DeviceStatusCard/index.module.scss new file mode 100644 index 0000000..a8d4f04 --- /dev/null +++ b/src/components/DeviceStatusCard/index.module.scss @@ -0,0 +1,29 @@ +.centerContainer { + display: flex; + justify-content: center; + align-items: center; + position: relative; +} + +.overlayContainer { + display: flex; + justify-content: center; + align-items: center; + position: absolute; + width: 100%; + height: 100%; +} + +.spacedRow { + margin-top: 5px; + margin-bottom: 5px; +} + +.alignRight { + float: right; +} + +.spinner { + height: 50px; + width: 50px; +} diff --git a/src/pages/DevicePage/index.js b/src/pages/DevicePage/index.js index b760fef..293dcf9 100644 --- a/src/pages/DevicePage/index.js +++ b/src/pages/DevicePage/index.js @@ -7,7 +7,8 @@ import DeviceConfiguration from 'components/DeviceConfiguration'; import CommandHistory from 'components/CommandHistory'; import DeviceLogs from 'components/DeviceLogs'; import DeviceStatisticsCard from 'components/InterfaceStatistics'; -import DeviceActionCard from '../../components/DeviceActionCard'; +import DeviceActionCard from 'components/DeviceActionCard'; +import DeviceStatusCard from 'components/DeviceStatusCard'; const DevicePage = () => { const dispatch = useDispatch(); @@ -25,6 +26,7 @@ const DevicePage = () => {
+ diff --git a/src/utils/helper.js b/src/utils/helper.js index 7683b9b..db85adb 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -66,3 +66,47 @@ export const checkIfJson = (string) => { } return true; }; + +export const secondsToDetailed = ( + seconds, + dayLabel, + daysLabel, + hourLabel, + hoursLabel, + minuteLabel, + minutesLabel, + secondLabel, + secondsLabel, +) => { + if (!seconds || seconds === 0) return `0 ${secondsLabel}`; + let secondsLeft = seconds; + const days = Math.floor(secondsLeft / (3600 * 24)); + secondsLeft -= days * (3600 * 24); + const hours = Math.floor(secondsLeft / 3600); + secondsLeft -= hours * 3600; + const minutes = Math.floor(secondsLeft / 60); + secondsLeft -= minutes * 60; + + let finalString = ''; + + if (days > 0) + finalString = + days === 1 ? `${finalString}${days} ${dayLabel}, ` : `${finalString}${days} ${daysLabel}, `; + if (hours > 0) + finalString = + hours === 1 + ? `${finalString}${hours} ${hourLabel}, ` + : `${finalString}${hours} ${hoursLabel}, `; + if (minutes > 0) + finalString = + minutes === 1 + ? `${finalString}${minutes} ${minuteLabel}, ` + : `${finalString}${minutes} ${minutesLabel}, `; + if (secondsLeft > 0) + finalString = + secondsLeft === 1 + ? `${finalString}${secondsLeft} ${secondLabel}` + : `${finalString}${secondsLeft} ${secondsLabel}`; + + return finalString; +}; From 0b142b06586c9d8b145b9f0c48f099bb05722411 Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Wed, 30 Jun 2021 15:19:47 -0400 Subject: [PATCH 08/42] Version 0.9.7 --- package-lock.json | 4 ++-- package.json | 2 +- src/layout/Footer/index.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8abd3b1..9ece482 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "0.9.6", + "version": "0.9.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "0.9.6", + "version": "0.9.7", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index a5f2c15..eb08e42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "0.9.6", + "version": "0.9.7", "private": true, "dependencies": { "@coreui/coreui": "^3.4.0", diff --git a/src/layout/Footer/index.js b/src/layout/Footer/index.js index 142f08d..9d9eee3 100644 --- a/src/layout/Footer/index.js +++ b/src/layout/Footer/index.js @@ -6,7 +6,7 @@ const TheFooter = () => ( {(t) => ( -
{t('footer.version')} 0.9.6
+
{t('footer.version')} 0.9.7
{t('footer.powered_by')} From 895301edd3be680042a66b64a1e5148139249d70 Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Wed, 30 Jun 2021 15:59:13 -0400 Subject: [PATCH 09/42] Dependency cleanup --- package-lock.json | 587 ------------------------- package.json | 6 - src/components/CommandHistory/index.js | 11 +- 3 files changed, 2 insertions(+), 602 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9ece482..ccdf4d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,12 +12,6 @@ "@coreui/icons": "^2.0.1", "@coreui/icons-react": "^1.1.0", "@coreui/react": "^3.4.6", - "@fortawesome/fontawesome-svg-core": "^1.2.35", - "@fortawesome/free-solid-svg-icons": "^5.15.3", - "@fortawesome/react-fontawesome": "^0.1.14", - "@testing-library/jest-dom": "^5.14.1", - "@testing-library/react": "^11.2.7", - "@testing-library/user-event": "^13.1.9", "apexcharts": "^3.27.1", "axios": "^0.21.1", "axios-retry": "^3.1.9", @@ -2033,44 +2027,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@fortawesome/fontawesome-common-types": { - "version": "0.2.35", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.35.tgz", - "integrity": "sha512-IHUfxSEDS9dDGqYwIW7wTN6tn/O8E0n5PcAHz9cAaBoZw6UpG20IG/YM3NNLaGPwPqgjBAFjIURzqoQs3rrtuw==", - "engines": { - "node": ">=6" - } - }, - "node_modules/@fortawesome/fontawesome-svg-core": { - "version": "1.2.35", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.35.tgz", - "integrity": "sha512-uLEXifXIL7hnh2sNZQrIJWNol7cTVIzwI+4qcBIq9QWaZqUblm0IDrtSqbNg+3SQf8SMGHkiSigD++rHmCHjBg==", - "dependencies": { - "@fortawesome/fontawesome-common-types": "^0.2.35" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@fortawesome/free-solid-svg-icons": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.15.3.tgz", - "integrity": "sha512-XPeeu1IlGYqz4VWGRAT5ukNMd4VHUEEJ7ysZ7pSSgaEtNvSo+FLurybGJVmiqkQdK50OkSja2bfZXOeyMGRD8Q==", - "dependencies": { - "@fortawesome/fontawesome-common-types": "^0.2.35" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@fortawesome/react-fontawesome": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.14.tgz", - "integrity": "sha512-4wqNb0gRLVaBm/h+lGe8UfPPivcbuJ6ecI4hIgW0LjI7kzpYB9FkN0L9apbVzg+lsBdcTf0AlBtODjcSX5mmKA==", - "dependencies": { - "prop-types": "^15.7.2" - } - }, "node_modules/@hapi/address": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz", @@ -3173,228 +3129,6 @@ "url": "https://github.com/sponsors/gregberge" } }, - "node_modules/@testing-library/dom": { - "version": "7.31.2", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-7.31.2.tgz", - "integrity": "sha512-3UqjCpey6HiTZT92vODYLPxTBWlM8ZOOjr3LX5F37/VRipW2M1kX6I/Cm4VXzteZqfGfagg8yXywpcOgQBlNsQ==", - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^4.2.0", - "aria-query": "^4.2.2", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.6", - "lz-string": "^1.4.4", - "pretty-format": "^26.6.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@testing-library/dom/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/dom/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@testing-library/dom/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/dom/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/jest-dom": { - "version": "5.14.1", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.14.1.tgz", - "integrity": "sha512-dfB7HVIgTNCxH22M1+KU6viG5of2ldoA5ly8Ar8xkezKHKXjRvznCdbMbqjYGgO2xjRbwnR+rR8MLUIqF3kKbQ==", - "dependencies": { - "@babel/runtime": "^7.9.2", - "@types/testing-library__jest-dom": "^5.9.1", - "aria-query": "^4.2.2", - "chalk": "^3.0.0", - "css": "^3.0.0", - "css.escape": "^1.5.1", - "dom-accessibility-api": "^0.5.6", - "lodash": "^4.17.15", - "redent": "^3.0.0" - }, - "engines": { - "node": ">=8", - "npm": ">=6", - "yarn": ">=1" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@testing-library/jest-dom/node_modules/css": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/css/-/css-3.0.0.tgz", - "integrity": "sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ==", - "dependencies": { - "inherits": "^2.0.4", - "source-map": "^0.6.1", - "source-map-resolve": "^0.6.0" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/source-map-resolve": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.6.0.tgz", - "integrity": "sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w==", - "dependencies": { - "atob": "^2.1.2", - "decode-uri-component": "^0.2.0" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/react": { - "version": "11.2.7", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-11.2.7.tgz", - "integrity": "sha512-tzRNp7pzd5QmbtXNG/mhdcl7Awfu/Iz1RaVHY75zTdOkmHCuzMhRL83gWHSgOAcjS3CCbyfwUHMZgRJb4kAfpA==", - "dependencies": { - "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^7.28.1" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "react": "*", - "react-dom": "*" - } - }, - "node_modules/@testing-library/user-event": { - "version": "13.1.9", - "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-13.1.9.tgz", - "integrity": "sha512-NZr0zL2TMOs2qk+dNlqrAdbaRW5dAmYwd1yuQ4r7HpkVEOj0MWuUjDWwKhcLd/atdBy8ZSMHSKp+kXSQe47ezg==", - "dependencies": { - "@babel/runtime": "^7.12.5" - }, - "engines": { - "node": ">=10", - "npm": ">=6" - }, - "peerDependencies": { - "@testing-library/dom": ">=7.21.4" - } - }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -3403,11 +3137,6 @@ "node": ">= 6" } }, - "node_modules/@types/aria-query": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.1.tgz", - "integrity": "sha512-S6oPal772qJZHoRZLFc/XoZW2gFvwXusYUmXPXkgxJLuEk2vOt7jc4Yo6z/vtI0EBkbPBVrJJ0B+prLIKiWqHg==" - }, "node_modules/@types/babel__core": { "version": "7.1.14", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.14.tgz", @@ -3516,15 +3245,6 @@ "@types/istanbul-lib-report": "*" } }, - "node_modules/@types/jest": { - "version": "26.0.23", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.23.tgz", - "integrity": "sha512-ZHLmWMJ9jJ9PTiT58juykZpL7KjwJywFN3Rr2pTSkyQfydf/rk22yS7W8p5DaVUMQ2BQC7oYiU3FjbTM/mYrOA==", - "dependencies": { - "jest-diff": "^26.0.0", - "pretty-format": "^26.0.0" - } - }, "node_modules/@types/json-schema": { "version": "7.0.7", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", @@ -3627,14 +3347,6 @@ "resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.7.tgz", "integrity": "sha512-0VBprVqfgFD7Ehb2vd8Lh9TG3jP98gvr8rgehQqzztZNI7o8zS8Ad4jyZneKELphpuE212D8J70LnSNQSyO6bQ==" }, - "node_modules/@types/testing-library__jest-dom": { - "version": "5.14.0", - "resolved": "https://registry.npmjs.org/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.0.tgz", - "integrity": "sha512-l2P2GO+hFF4Liye+fAajT1qBqvZOiL79YMpEvgGs1xTK7hECxBI8Wz4J7ntACJNiJ9r0vXQqYovroXRLPDja6A==", - "dependencies": { - "@types/jest": "*" - } - }, "node_modules/@types/uglify-js": { "version": "3.13.0", "resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.13.0.tgz", @@ -6583,11 +6295,6 @@ "url": "https://github.com/sponsors/fb55" } }, - "node_modules/css.escape": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", - "integrity": "sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=" - }, "node_modules/css/node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -7269,11 +6976,6 @@ "node": ">=6.0.0" } }, - "node_modules/dom-accessibility-api": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.6.tgz", - "integrity": "sha512-DplGLZd8L1lN64jlT27N9TVSESFR5STaEJvX+thCby7fuCHonfPpAlodYc3vuUYbDuDec5w8AMP7oCM5TWFsqw==" - }, "node_modules/dom-converter": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", @@ -13656,14 +13358,6 @@ "node": ">=10" } }, - "node_modules/lz-string": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz", - "integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=", - "bin": { - "lz-string": "bin/bin.js" - } - }, "node_modules/magic-string": { "version": "0.25.7", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", @@ -13862,14 +13556,6 @@ "node": ">=6" } }, - "node_modules/min-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", - "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", - "engines": { - "node": ">=4" - } - }, "node_modules/mini-create-react-context": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz", @@ -17470,18 +17156,6 @@ "node": ">=0.10.0" } }, - "node_modules/redent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", - "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", - "dependencies": { - "indent-string": "^4.0.0", - "strip-indent": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/redux": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/redux/-/redux-4.1.0.tgz", @@ -19476,17 +19150,6 @@ "node": ">=6" } }, - "node_modules/strip-indent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", - "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", - "dependencies": { - "min-indent": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -23981,35 +23644,6 @@ } } }, - "@fortawesome/fontawesome-common-types": { - "version": "0.2.35", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.35.tgz", - "integrity": "sha512-IHUfxSEDS9dDGqYwIW7wTN6tn/O8E0n5PcAHz9cAaBoZw6UpG20IG/YM3NNLaGPwPqgjBAFjIURzqoQs3rrtuw==" - }, - "@fortawesome/fontawesome-svg-core": { - "version": "1.2.35", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.35.tgz", - "integrity": "sha512-uLEXifXIL7hnh2sNZQrIJWNol7cTVIzwI+4qcBIq9QWaZqUblm0IDrtSqbNg+3SQf8SMGHkiSigD++rHmCHjBg==", - "requires": { - "@fortawesome/fontawesome-common-types": "^0.2.35" - } - }, - "@fortawesome/free-solid-svg-icons": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.15.3.tgz", - "integrity": "sha512-XPeeu1IlGYqz4VWGRAT5ukNMd4VHUEEJ7ysZ7pSSgaEtNvSo+FLurybGJVmiqkQdK50OkSja2bfZXOeyMGRD8Q==", - "requires": { - "@fortawesome/fontawesome-common-types": "^0.2.35" - } - }, - "@fortawesome/react-fontawesome": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.14.tgz", - "integrity": "sha512-4wqNb0gRLVaBm/h+lGe8UfPPivcbuJ6ecI4hIgW0LjI7kzpYB9FkN0L9apbVzg+lsBdcTf0AlBtODjcSX5mmKA==", - "requires": { - "prop-types": "^15.7.2" - } - }, "@hapi/address": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz", @@ -24807,178 +24441,11 @@ "loader-utils": "^2.0.0" } }, - "@testing-library/dom": { - "version": "7.31.2", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-7.31.2.tgz", - "integrity": "sha512-3UqjCpey6HiTZT92vODYLPxTBWlM8ZOOjr3LX5F37/VRipW2M1kX6I/Cm4VXzteZqfGfagg8yXywpcOgQBlNsQ==", - "requires": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^4.2.0", - "aria-query": "^4.2.2", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.6", - "lz-string": "^1.4.4", - "pretty-format": "^26.6.2" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "@testing-library/jest-dom": { - "version": "5.14.1", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.14.1.tgz", - "integrity": "sha512-dfB7HVIgTNCxH22M1+KU6viG5of2ldoA5ly8Ar8xkezKHKXjRvznCdbMbqjYGgO2xjRbwnR+rR8MLUIqF3kKbQ==", - "requires": { - "@babel/runtime": "^7.9.2", - "@types/testing-library__jest-dom": "^5.9.1", - "aria-query": "^4.2.2", - "chalk": "^3.0.0", - "css": "^3.0.0", - "css.escape": "^1.5.1", - "dom-accessibility-api": "^0.5.6", - "lodash": "^4.17.15", - "redent": "^3.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "css": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/css/-/css-3.0.0.tgz", - "integrity": "sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ==", - "requires": { - "inherits": "^2.0.4", - "source-map": "^0.6.1", - "source-map-resolve": "^0.6.0" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" - }, - "source-map-resolve": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.6.0.tgz", - "integrity": "sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w==", - "requires": { - "atob": "^2.1.2", - "decode-uri-component": "^0.2.0" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "@testing-library/react": { - "version": "11.2.7", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-11.2.7.tgz", - "integrity": "sha512-tzRNp7pzd5QmbtXNG/mhdcl7Awfu/Iz1RaVHY75zTdOkmHCuzMhRL83gWHSgOAcjS3CCbyfwUHMZgRJb4kAfpA==", - "requires": { - "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^7.28.1" - } - }, - "@testing-library/user-event": { - "version": "13.1.9", - "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-13.1.9.tgz", - "integrity": "sha512-NZr0zL2TMOs2qk+dNlqrAdbaRW5dAmYwd1yuQ4r7HpkVEOj0MWuUjDWwKhcLd/atdBy8ZSMHSKp+kXSQe47ezg==", - "requires": { - "@babel/runtime": "^7.12.5" - } - }, "@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==" }, - "@types/aria-query": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.1.tgz", - "integrity": "sha512-S6oPal772qJZHoRZLFc/XoZW2gFvwXusYUmXPXkgxJLuEk2vOt7jc4Yo6z/vtI0EBkbPBVrJJ0B+prLIKiWqHg==" - }, "@types/babel__core": { "version": "7.1.14", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.14.tgz", @@ -25087,15 +24554,6 @@ "@types/istanbul-lib-report": "*" } }, - "@types/jest": { - "version": "26.0.23", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.23.tgz", - "integrity": "sha512-ZHLmWMJ9jJ9PTiT58juykZpL7KjwJywFN3Rr2pTSkyQfydf/rk22yS7W8p5DaVUMQ2BQC7oYiU3FjbTM/mYrOA==", - "requires": { - "jest-diff": "^26.0.0", - "pretty-format": "^26.0.0" - } - }, "@types/json-schema": { "version": "7.0.7", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", @@ -25198,14 +24656,6 @@ "resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.7.tgz", "integrity": "sha512-0VBprVqfgFD7Ehb2vd8Lh9TG3jP98gvr8rgehQqzztZNI7o8zS8Ad4jyZneKELphpuE212D8J70LnSNQSyO6bQ==" }, - "@types/testing-library__jest-dom": { - "version": "5.14.0", - "resolved": "https://registry.npmjs.org/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.0.tgz", - "integrity": "sha512-l2P2GO+hFF4Liye+fAajT1qBqvZOiL79YMpEvgGs1xTK7hECxBI8Wz4J7ntACJNiJ9r0vXQqYovroXRLPDja6A==", - "requires": { - "@types/jest": "*" - } - }, "@types/uglify-js": { "version": "3.13.0", "resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.13.0.tgz", @@ -27583,11 +27033,6 @@ "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.1.tgz", "integrity": "sha512-FYDTSHb/7KXsWICVsxdmiExPjCfRC4qRFBdVwv7Ax9hMnvMmEjP9RfxTEZ3qPZGmADDn2vAKSo9UcN1jKVYscg==" }, - "css.escape": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", - "integrity": "sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=" - }, "cssdb": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/cssdb/-/cssdb-4.4.0.tgz", @@ -28129,11 +27574,6 @@ "esutils": "^2.0.2" } }, - "dom-accessibility-api": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.6.tgz", - "integrity": "sha512-DplGLZd8L1lN64jlT27N9TVSESFR5STaEJvX+thCby7fuCHonfPpAlodYc3vuUYbDuDec5w8AMP7oCM5TWFsqw==" - }, "dom-converter": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", @@ -33008,11 +32448,6 @@ "yallist": "^4.0.0" } }, - "lz-string": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz", - "integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=" - }, "magic-string": { "version": "0.25.7", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", @@ -33170,11 +32605,6 @@ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" }, - "min-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", - "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==" - }, "mini-create-react-context": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz", @@ -36052,15 +35482,6 @@ "minimatch": "3.0.4" } }, - "redent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", - "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", - "requires": { - "indent-string": "^4.0.0", - "strip-indent": "^3.0.0" - } - }, "redux": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/redux/-/redux-4.1.0.tgz", @@ -37677,14 +37098,6 @@ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" }, - "strip-indent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", - "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", - "requires": { - "min-indent": "^1.0.0" - } - }, "strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", diff --git a/package.json b/package.json index eb08e42..6838da0 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,6 @@ "@coreui/icons": "^2.0.1", "@coreui/icons-react": "^1.1.0", "@coreui/react": "^3.4.6", - "@fortawesome/fontawesome-svg-core": "^1.2.35", - "@fortawesome/free-solid-svg-icons": "^5.15.3", - "@fortawesome/react-fontawesome": "^0.1.14", - "@testing-library/jest-dom": "^5.14.1", - "@testing-library/react": "^11.2.7", - "@testing-library/user-event": "^13.1.9", "apexcharts": "^3.27.1", "axios": "^0.21.1", "axios-retry": "^3.1.9", diff --git a/src/components/CommandHistory/index.js b/src/components/CommandHistory/index.js index 2f04360..f48fda1 100644 --- a/src/components/CommandHistory/index.js +++ b/src/components/CommandHistory/index.js @@ -13,10 +13,8 @@ import { } from '@coreui/react'; import CIcon from '@coreui/icons-react'; import DatePicker from 'react-widgets/DatePicker'; -import { cilCloudDownload, cilSync } from '@coreui/icons'; +import { cilCloudDownload, cilSync, cilCalendarCheck } from '@coreui/icons'; import PropTypes from 'prop-types'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faClipboardCheck } from '@fortawesome/free-solid-svg-icons'; import { prettyDate, dateToUnix } from 'utils/helper'; import axiosInstance from 'utils/axiosInstance'; import { getToken } from 'utils/authHelper'; @@ -363,12 +361,7 @@ const DeviceCommands = ({ selectedDeviceId }) => { {item.command === 'trace' ? ( ) : ( - + )} From 9695a3ba716d8f3d0f9708ebfb196580a6a37b6f Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Thu, 1 Jul 2021 09:12:27 -0400 Subject: [PATCH 10/42] Adjustment to column width --- src/components/DeviceStatusCard/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/DeviceStatusCard/index.js b/src/components/DeviceStatusCard/index.js index 1f89fde..74a8ba5 100644 --- a/src/components/DeviceStatusCard/index.js +++ b/src/components/DeviceStatusCard/index.js @@ -103,8 +103,8 @@ const DeviceStatusCard = ({ selectedDeviceId }) => {
- {t('status.connection_status')} : - + {t('status.connection_status')} : + {status?.connected ? ( {t('common.connected')} ) : ( @@ -113,8 +113,8 @@ const DeviceStatusCard = ({ selectedDeviceId }) => { - {t('status.uptime')} : - + {t('status.uptime')} : + {secondsToDetailed( lastStats?.unit?.uptime, t('common.day'), @@ -129,20 +129,20 @@ const DeviceStatusCard = ({ selectedDeviceId }) => { - {t('status.last_contact')} : - + {t('status.last_contact')} : + {prettyDate(status?.lastContact)} - {t('status.localtime')} : - + {t('status.localtime')} : + {prettyDate(lastStats?.unit?.localtime)} - {t('status.load_averages')} : - + {t('status.load_averages')} : + {transformLoad(lastStats?.unit?.load[0])} {' / '} {transformLoad(lastStats?.unit?.load[1])} @@ -151,7 +151,7 @@ const DeviceStatusCard = ({ selectedDeviceId }) => { - {t('status.memory')} : + {t('status.memory')} : Date: Thu, 1 Jul 2021 09:14:50 -0400 Subject: [PATCH 11/42] Alignment adjustment for MemoryBar placement --- src/components/DeviceStatusCard/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/DeviceStatusCard/index.js b/src/components/DeviceStatusCard/index.js index 74a8ba5..df96a2b 100644 --- a/src/components/DeviceStatusCard/index.js +++ b/src/components/DeviceStatusCard/index.js @@ -152,7 +152,7 @@ const DeviceStatusCard = ({ selectedDeviceId }) => { {t('status.memory')} : - + Date: Thu, 1 Jul 2021 09:50:02 -0400 Subject: [PATCH 12/42] Simplified RebootModal component --- public/locales/de/translation.json | 2 ++ public/locales/en/translation.json | 2 ++ public/locales/es/translation.json | 2 ++ public/locales/fr/translation.json | 2 ++ public/locales/pt/translation.json | 2 ++ src/components/RebootModal/index.js | 9 ++++----- src/components/RebootModal/index.module.scss | 6 +++++- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 7e9eb73..649f9ce 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -37,6 +37,7 @@ "connected": "Verbindung wurde hergestellt", "copied": "kopiert!", "copy_to_clipboard": "In die Zwischenablage kopieren", + "custom_date": "Benutzerdefiniertes Datum", "date": "Datum", "day": "tag", "days": "tage", @@ -157,6 +158,7 @@ }, "reboot": { "directions": "Wann möchten Sie dieses Gerät neu starten?", + "now": "Möchten Sie dieses Gerät jetzt neu starten?", "title": "Gerät neustarten" }, "scan": { diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 327694c..f61a456 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -37,6 +37,7 @@ "connected": "Connected", "copied": "Copied!", "copy_to_clipboard": "Copy to clipboard", + "custom_date": "Custom Date", "date": "Date", "day": "day", "days": "days", @@ -157,6 +158,7 @@ }, "reboot": { "directions": "When would you like to reboot this device?", + "now": "Would you like to reboot this device now?", "title": "Reboot" }, "scan": { diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index 407f465..c68f14f 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -37,6 +37,7 @@ "connected": "Conectado", "copied": "Copiado!", "copy_to_clipboard": "Copiar al portapapeles", + "custom_date": "Fecha personalizada", "date": "Fecha", "day": "día", "days": "días", @@ -157,6 +158,7 @@ }, "reboot": { "directions": "¿Cuándo le gustaría reiniciar este dispositivo?", + "now": "¿Le gustaría reiniciar este dispositivo ahora?", "title": "Reiniciar" }, "scan": { diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index e2eba9d..fbd393a 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -37,6 +37,7 @@ "connected": "Connecté", "copied": "Copié!", "copy_to_clipboard": "Copier dans le presse-papier", + "custom_date": "Date personnalisée", "date": "Rendez-vous amoureux", "day": "journée", "days": "journées", @@ -157,6 +158,7 @@ }, "reboot": { "directions": "Quand souhaitez-vous redémarrer cet appareil ?", + "now": "Souhaitez-vous redémarrer cet appareil maintenant ?", "title": "Redémarrer" }, "scan": { diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index 1e45a27..da7550e 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -37,6 +37,7 @@ "connected": "Conectado", "copied": "Copiado!", "copy_to_clipboard": "Copiar para área de transferência", + "custom_date": "Data personalizada", "date": "Encontro", "day": "dia", "days": "dias", @@ -157,6 +158,7 @@ }, "reboot": { "directions": "Quando você gostaria de reinicializar este dispositivo?", + "now": "Você gostaria de reiniciar este dispositivo agora?", "title": "Reiniciar" }, "scan": { diff --git a/src/components/RebootModal/index.js b/src/components/RebootModal/index.js index 51341a4..cdecb7d 100644 --- a/src/components/RebootModal/index.js +++ b/src/components/RebootModal/index.js @@ -89,10 +89,9 @@ const ActionModal = ({ show, toggleModal }) => { ) : (
-
{t('reboot.directions')}
- - -

{t('common.execute_now')}

+ + +
{t('reboot.now')}
{
-
{t('blink.when_blink_leds')}
- - {t('blink.pattern')} + + + {t('blink.pattern')} + - - setPattern('on')}> + setPattern('on')} inline> - + {t('common.on')} - setPattern('off')}> + setPattern('off')} inline> - + {t('common.off')} - setPattern('blink')}> + setPattern('blink')} inline> - + {t('blink.blink')} - - + -

{t('common.execute_now')}

+

{t('blink.execute_now')}

{
- -
{t('reboot.now')}
+ +

{t('reboot.now')}

{
{t('footer.powered_by')} From ae7200815dd588a316860dc246bccf2093c976f9 Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Thu, 1 Jul 2021 16:42:51 -0400 Subject: [PATCH 15/42] Migrated from redux to context API --- package-lock.json | 78 ----------------- package.json | 1 - public/locales/de/translation.json | 2 +- public/locales/en/translation.json | 2 +- public/locales/es/translation.json | 2 +- public/locales/fr/translation.json | 2 +- public/locales/pt/translation.json | 2 +- src/App.js | 40 +++------ src/components/BlinkModal/index.js | 87 +++++++++---------- src/components/CommandHistory/index.js | 35 ++++---- src/components/ConfigureModal/index.js | 16 ++-- src/components/DeleteLogModal/index.js | 12 +-- src/components/DeviceActionCard/index.js | 16 ++-- src/components/DeviceConfiguration/index.js | 20 ++--- src/components/DeviceHealth/index.js | 28 +++--- src/components/DeviceListTable/index.js | 12 ++- src/components/DeviceLogs/index.js | 28 +++--- src/components/DeviceStatusCard/index.js | 36 ++++---- src/components/FactoryResetModal/index.js | 13 +-- .../UpgradeWaitingBody.js | 7 +- src/components/FirmwareUpgradeModal/index.js | 21 ++--- .../LatestStatisticsModal.js | 12 +-- .../StatisticsChartList.js | 20 ++--- src/components/InterfaceStatistics/index.js | 15 +--- src/components/RebootModal/index.js | 14 +-- .../TraceModal/WaitingForTraceBody.js | 7 +- src/components/TraceModal/index.js | 22 +++-- src/components/WifiScanModal/index.js | 15 ++-- src/contexts/AuthProvider/index.js | 21 +++++ src/contexts/DeviceProvider/index.js | 21 +++++ src/index.js | 6 +- src/layout/Header/index.js | 19 ++-- src/layout/Sidebar/index.js | 13 +-- src/layout/index.js | 24 ++--- src/pages/DevicePage/index.js | 34 +++----- src/pages/LoginPage/index.js | 6 +- src/router/index.js | 20 +++++ src/routes.js | 4 +- src/store.js | 19 ---- src/utils/deviceHelper.js | 5 +- 40 files changed, 337 insertions(+), 420 deletions(-) create mode 100644 src/contexts/AuthProvider/index.js create mode 100644 src/contexts/DeviceProvider/index.js create mode 100644 src/router/index.js delete mode 100644 src/store.js diff --git a/package-lock.json b/package-lock.json index 7251cb4..a92a661 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,6 @@ "react-dom": "^17.0.2", "react-i18next": "^11.11.0", "react-paginate": "^7.1.3", - "react-redux": "^7.2.4", "react-router-dom": "^5.2.0", "react-scripts": "^4.0.3", "react-select": "^4.3.1", @@ -3210,15 +3209,6 @@ "@types/node": "*" } }, - "node_modules/@types/hoist-non-react-statics": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", - "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", - "dependencies": { - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0" - } - }, "node_modules/@types/html-minifier-terser": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz", @@ -3300,17 +3290,6 @@ "csstype": "^3.0.2" } }, - "node_modules/@types/react-redux": { - "version": "7.1.16", - "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.16.tgz", - "integrity": "sha512-f/FKzIrZwZk7YEO9E1yoxIuDNRiDducxkFlkw/GNMGEnK9n4K8wJzlJBghpSuOVDgEUHoDkDF7Gi9lHNQR4siw==", - "dependencies": { - "@types/hoist-non-react-statics": "^3.3.0", - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0", - "redux": "^4.0.0" - } - }, "node_modules/@types/react-transition-group": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.1.tgz", @@ -16717,30 +16696,6 @@ "react": "^16.0.0 || ^17.0.0" } }, - "node_modules/react-redux": { - "version": "7.2.4", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.2.4.tgz", - "integrity": "sha512-hOQ5eOSkEJEXdpIKbnRyl04LhaWabkDPV+Ix97wqQX3T3d2NQ8DUblNXXtNMavc7DpswyQM6xfaN4HQDKNY2JA==", - "dependencies": { - "@babel/runtime": "^7.12.1", - "@types/react-redux": "^7.1.16", - "hoist-non-react-statics": "^3.3.2", - "loose-envify": "^1.4.0", - "prop-types": "^15.7.2", - "react-is": "^16.13.1" - }, - "peerDependencies": { - "react": "^16.8.3 || ^17" - }, - "peerDependenciesMeta": { - "react-dom": { - "optional": true - }, - "react-native": { - "optional": true - } - } - }, "node_modules/react-refresh": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz", @@ -24519,15 +24474,6 @@ "@types/node": "*" } }, - "@types/hoist-non-react-statics": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", - "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", - "requires": { - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0" - } - }, "@types/html-minifier-terser": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz", @@ -24609,17 +24555,6 @@ "csstype": "^3.0.2" } }, - "@types/react-redux": { - "version": "7.1.16", - "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.16.tgz", - "integrity": "sha512-f/FKzIrZwZk7YEO9E1yoxIuDNRiDducxkFlkw/GNMGEnK9n4K8wJzlJBghpSuOVDgEUHoDkDF7Gi9lHNQR4siw==", - "requires": { - "@types/hoist-non-react-statics": "^3.3.0", - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0", - "redux": "^4.0.0" - } - }, "@types/react-transition-group": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.1.tgz", @@ -35151,19 +35086,6 @@ "prop-types": "^15.6.1" } }, - "react-redux": { - "version": "7.2.4", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.2.4.tgz", - "integrity": "sha512-hOQ5eOSkEJEXdpIKbnRyl04LhaWabkDPV+Ix97wqQX3T3d2NQ8DUblNXXtNMavc7DpswyQM6xfaN4HQDKNY2JA==", - "requires": { - "@babel/runtime": "^7.12.1", - "@types/react-redux": "^7.1.16", - "hoist-non-react-statics": "^3.3.2", - "loose-envify": "^1.4.0", - "prop-types": "^15.7.2", - "react-is": "^16.13.1" - } - }, "react-refresh": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz", diff --git a/package.json b/package.json index b10918b..6a74b69 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "react-dom": "^17.0.2", "react-i18next": "^11.11.0", "react-paginate": "^7.1.3", - "react-redux": "^7.2.4", "react-router-dom": "^5.2.0", "react-scripts": "^4.0.3", "react-select": "^4.3.1", diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 3f34dc2..471edcd 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -195,7 +195,7 @@ "trace": { "choose_network": "Netzwerk auswählen", "directions": "Starten Sie eine Tcpdump auf diesem Geräts für eine bestimmte Dauer oder eine Anzahl von Paketen", - "download_trace": "Klicke hier zum herunterladen", + "download_trace": "Trace-Datei herunterladen", "packets": "Pakete", "title": "Tcpdump", "trace": "Spur", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index d10ce47..803c3f8 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -195,7 +195,7 @@ "trace": { "choose_network": "Choose network", "directions": "Launch a remote trace of this device for either a specific duration or a number of packets", - "download_trace": "Click here to download", + "download_trace": "Download Trace File", "packets": "Packets", "title": "Trace", "trace": "Trace", diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index 894d388..ed0248e 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -195,7 +195,7 @@ "trace": { "choose_network": "Elija la red", "directions": "Lanzar un rastreo remoto de este dispositivo por una duración específica o por una cantidad de paquetes", - "download_trace": "Haga click aquí para descargar", + "download_trace": "Descargar archivo de seguimiento", "packets": "Paquetes", "title": "Rastro", "trace": "Rastro", diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index 04b5faa..7d00e6c 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -195,7 +195,7 @@ "trace": { "choose_network": "Choisir le réseau", "directions": "Lancer une trace à distance de cet appareil pour une durée spécifique ou un nombre de paquets", - "download_trace": "Cliquez ici pour télécharger", + "download_trace": "Télécharger le fichier de trace", "packets": "Paquets", "title": "Trace", "trace": "Trace", diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index c5641f9..bc0025c 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -195,7 +195,7 @@ "trace": { "choose_network": "Escolha a rede", "directions": "Lançar um rastreamento remoto deste dispositivo para uma duração específica ou um número de pacotes", - "download_trace": "Clique aqui para baixar", + "download_trace": "Baixar arquivo de rastreamento", "packets": "Pacotes", "title": "Vestígio", "trace": "Vestígio", diff --git a/src/App.js b/src/App.js index 985f39e..32f0cad 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,8 @@ -import React, { useEffect } from 'react'; -import { HashRouter, Route, Switch } from 'react-router-dom'; +import React from 'react'; +import { HashRouter, Switch } from 'react-router-dom'; import 'scss/style.scss'; -import { useSelector, useDispatch } from 'react-redux'; +import Router from 'router'; +import { AuthProvider } from 'contexts/AuthProvider'; const loading = (
@@ -9,32 +10,19 @@ const loading = (
); -const TheLayout = React.lazy(() => import('layout')); -const Login = React.lazy(() => import('pages/LoginPage')); - const App = () => { - const isLoggedIn = useSelector((state) => state.connected); - const dispatch = useDispatch(); - - useEffect(() => { - const token = sessionStorage.getItem('access_token'); - if (token !== undefined && token !== null) { - dispatch({ type: 'set', connected: true }); - } - }, [dispatch]); + const storageToken = sessionStorage.getItem('access_token'); return ( - - - - (isLoggedIn ? : )} - /> - - - + + + + + + + + + ); }; diff --git a/src/components/BlinkModal/index.js b/src/components/BlinkModal/index.js index 67937bf..3780f7a 100644 --- a/src/components/BlinkModal/index.js +++ b/src/components/BlinkModal/index.js @@ -16,10 +16,10 @@ import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import DatePicker from 'react-widgets/DatePicker'; import PropTypes from 'prop-types'; -import { useSelector } from 'react-redux'; import { dateToUnix } from 'utils/helper'; import 'react-widgets/styles.css'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import axiosInstance from 'utils/axiosInstance'; import eventBus from 'utils/eventBus'; import SuccessfulActionModalBody from 'components/SuccessfulActionModalBody'; @@ -29,12 +29,13 @@ import styles from './index.module.scss'; const BlinkModal = ({ show, toggleModal }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [isNow, setIsNow] = useState(false); const [waiting, setWaiting] = useState(false); const [chosenDate, setChosenDate] = useState(new Date().toString()); const [chosenPattern, setPattern] = useState('on'); const [result, setResult] = useState(null); - const selectedDeviceId = useSelector((state) => state.selectedDeviceId); const toggleNow = () => { setIsNow(!isNow); @@ -57,12 +58,10 @@ const BlinkModal = ({ show, toggleModal }) => { const doAction = () => { setWaiting(true); - - const token = getToken(); const utcDate = new Date(chosenDate); const parameters = { - serialNumber: selectedDeviceId, + serialNumber: deviceSerialNumber, when: isNow ? 0 : dateToUnix(utcDate), pattern: chosenPattern, duration: 30, @@ -70,11 +69,11 @@ const BlinkModal = ({ show, toggleModal }) => { const headers = { Accept: 'application/json', - Authorization: `Bearer ${token}`, + Authorization: `Bearer ${currentToken}`, }; axiosInstance - .post(`/device/${encodeURIComponent(selectedDeviceId)}/leds`, parameters, { headers }) + .post(`/device/${encodeURIComponent(deviceSerialNumber)}/leds`, parameters, { headers }) .then(() => { setResult('success'); }) @@ -102,42 +101,42 @@ const BlinkModal = ({ show, toggleModal }) => { {t('blink.pattern')} - setPattern('on')} inline> - - - {t('common.on')} - - - setPattern('off')} inline> - - - {t('common.off')} - - - setPattern('blink')} inline> - - - {t('blink.blink')} - - + setPattern('on')} inline> + + + {t('common.on')} + + + setPattern('off')} inline> + + + {t('common.off')} + + + setPattern('blink')} inline> + + + {t('blink.blink')} + + diff --git a/src/components/CommandHistory/index.js b/src/components/CommandHistory/index.js index f48fda1..d4bd7d9 100644 --- a/src/components/CommandHistory/index.js +++ b/src/components/CommandHistory/index.js @@ -14,10 +14,10 @@ import { import CIcon from '@coreui/icons-react'; import DatePicker from 'react-widgets/DatePicker'; import { cilCloudDownload, cilSync, cilCalendarCheck } from '@coreui/icons'; -import PropTypes from 'prop-types'; import { prettyDate, dateToUnix } from 'utils/helper'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import eventBus from 'utils/eventBus'; import ConfirmModal from 'components/ConfirmModal'; import LoadingButton from 'components/LoadingButton'; @@ -25,8 +25,10 @@ import WifiScanResultModalWidget from 'components/WifiScanResultModal'; import DeviceCommandsCollapse from './DeviceCommandsCollapse'; import styles from './index.module.scss'; -const DeviceCommands = ({ selectedDeviceId }) => { +const DeviceCommands = () => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); // Wifiscan result related const [chosenWifiScan, setChosenWifiScan] = useState(null); const [showScanModal, setShowScanModal] = useState(false); @@ -90,7 +92,7 @@ const DeviceCommands = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, params: { limit: commandLimit, @@ -107,7 +109,10 @@ const DeviceCommands = ({ selectedDeviceId }) => { } axiosInstance - .get(`/commands?serialNumber=${encodeURIComponent(selectedDeviceId)}${extraParams}`, options) + .get( + `/commands?serialNumber=${encodeURIComponent(deviceSerialNumber)}${extraParams}`, + options, + ) .then((response) => { setCommands(response.data.commands); }) @@ -122,13 +127,13 @@ const DeviceCommands = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/octet-stream', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, responseType: 'arraybuffer', }; axiosInstance - .get(`/file/${uuid}?serialNumber=${selectedDeviceId}`, options) + .get(`/file/${uuid}?serialNumber=${deviceSerialNumber}`, options) .then((response) => { const blob = new Blob([response.data], { type: 'application/octet-stream' }); const link = document.createElement('a'); @@ -145,7 +150,7 @@ const DeviceCommands = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, }; return axiosInstance @@ -231,12 +236,12 @@ const DeviceCommands = ({ selectedDeviceId }) => { ]; useEffect(() => { - if (selectedDeviceId && start !== '' && end !== '') { + if (deviceSerialNumber && start !== '' && end !== '') { getCommands(); - } else if (selectedDeviceId && start === '' && end === '') { + } else if (deviceSerialNumber && start === '' && end === '') { getCommands(); } - }, [selectedDeviceId, start, end]); + }, [deviceSerialNumber, start, end]); useEffect(() => { eventBus.on('actionCompleted', () => refreshCommands()); @@ -247,7 +252,7 @@ const DeviceCommands = ({ selectedDeviceId }) => { }, []); useEffect(() => { - if (selectedDeviceId) { + if (deviceSerialNumber) { setCommandLimit(25); setLoadingMore(false); setShowLoadingMore(true); @@ -255,7 +260,7 @@ const DeviceCommands = ({ selectedDeviceId }) => { setEnd(''); getCommands(); } - }, [selectedDeviceId]); + }, [deviceSerialNumber]); useEffect(() => { if (commandLimit !== 25) { @@ -446,8 +451,4 @@ const DeviceCommands = ({ selectedDeviceId }) => { ); }; -DeviceCommands.propTypes = { - selectedDeviceId: PropTypes.string.isRequired, -}; - export default DeviceCommands; diff --git a/src/components/ConfigureModal/index.js b/src/components/ConfigureModal/index.js index dcb7396..e588d4d 100644 --- a/src/components/ConfigureModal/index.js +++ b/src/components/ConfigureModal/index.js @@ -16,9 +16,9 @@ import { import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; -import { useSelector } from 'react-redux'; import 'react-widgets/styles.css'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import { checkIfJson } from 'utils/helper'; import axiosInstance from 'utils/axiosInstance'; import eventBus from 'utils/eventBus'; @@ -27,6 +27,8 @@ import styles from './index.module.scss'; const ConfigureModal = ({ show, toggleModal }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); const [doingNow, setDoingNow] = useState(false); @@ -36,7 +38,7 @@ const ConfigureModal = ({ show, toggleModal }) => { const [checkingIfSure, setCheckingIfSure] = useState(false); const [errorJson, setErrorJson] = useState(false); const [inputKey, setInputKey] = useState(0); - const selectedDeviceId = useSelector((state) => state.selectedDeviceId); + let fileReader; const confirmingIfSure = () => { @@ -69,10 +71,8 @@ const ConfigureModal = ({ show, toggleModal }) => { setHadSuccess(false); setWaiting(true); - const token = getToken(); - const parameters = { - serialNumber: selectedDeviceId, + serialNumber: deviceSerialNumber, when: 0, UUID: 1, configuration: JSON.parse(newConfig), @@ -80,11 +80,11 @@ const ConfigureModal = ({ show, toggleModal }) => { const headers = { Accept: 'application/json', - Authorization: `Bearer ${token}`, + Authorization: `Bearer ${currentToken}`, }; axiosInstance - .post(`/device/${encodeURIComponent(selectedDeviceId)}/configure`, parameters, { headers }) + .post(`/device/${encodeURIComponent(deviceSerialNumber)}/configure`, parameters, { headers }) .then(() => { setHadSuccess(true); }) diff --git a/src/components/DeleteLogModal/index.js b/src/components/DeleteLogModal/index.js index 8f2b704..25bc76f 100644 --- a/src/components/DeleteLogModal/index.js +++ b/src/components/DeleteLogModal/index.js @@ -6,12 +6,15 @@ import PropTypes from 'prop-types'; import ConfirmFooter from 'components/ConfirmFooter'; import { dateToUnix } from 'utils/helper'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; +import { useDevice } from 'contexts/DeviceProvider'; +import { useAuth } from 'contexts/AuthProvider'; import eventBus from 'utils/eventBus'; import styles from './index.module.scss'; -const DeleteLogModal = ({ serialNumber, show, toggle, object }) => { +const DeleteLogModal = ({ show, toggle, object }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [loading, setLoading] = useState(false); const [maxDate, setMaxDate] = useState(new Date().toString()); @@ -27,14 +30,14 @@ const DeleteLogModal = ({ serialNumber, show, toggle, object }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, params: { endDate: dateToUnix(maxDate), }, }; return axiosInstance - .delete(`/device/${serialNumber}/${object}`, options) + .delete(`/device/${deviceSerialNumber}/${object}`, options) .then(() => {}) .catch(() => {}) .finally(() => { @@ -94,7 +97,6 @@ DeleteLogModal.propTypes = { show: PropTypes.bool.isRequired, toggle: PropTypes.func.isRequired, object: PropTypes.string.isRequired, - serialNumber: PropTypes.string.isRequired, }; export default DeleteLogModal; diff --git a/src/components/DeviceActionCard/index.js b/src/components/DeviceActionCard/index.js index 93c86a3..f0b17f9 100644 --- a/src/components/DeviceActionCard/index.js +++ b/src/components/DeviceActionCard/index.js @@ -1,9 +1,9 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import PropTypes from 'prop-types'; import { CButton, CCard, CCardHeader, CCardBody, CRow, CCol } from '@coreui/react'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import LoadingButton from 'components/LoadingButton'; import RebootModal from 'components/RebootModal'; import FirmwareUpgradeModal from 'components/FirmwareUpgradeModal'; @@ -15,8 +15,10 @@ import FactoryResetModal from 'components/FactoryResetModal'; import styles from './index.module.scss'; -const DeviceActions = ({ selectedDeviceId }) => { +const DeviceActions = () => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [showRebootModal, setShowRebootModal] = useState(false); const [showBlinkModal, setShowBlinkModal] = useState(false); const [showUpgradeModal, setShowUpgradeModal] = useState(false); @@ -59,12 +61,12 @@ const DeviceActions = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, }; axiosInstance - .get(`/device/${encodeURIComponent(selectedDeviceId)}/rtty`, options) + .get(`/device/${encodeURIComponent(deviceSerialNumber)}/rtty`, options) .then((response) => { const url = `https://${response.data.server}:${response.data.viewport}/connect/${response.data.connectionId}`; const newWindow = window.open(url, '_blank', 'noopener,noreferrer'); @@ -145,8 +147,4 @@ const DeviceActions = ({ selectedDeviceId }) => { ); }; -DeviceActions.propTypes = { - selectedDeviceId: PropTypes.string.isRequired, -}; - export default DeviceActions; diff --git a/src/components/DeviceConfiguration/index.js b/src/components/DeviceConfiguration/index.js index 8df373d..b448438 100644 --- a/src/components/DeviceConfiguration/index.js +++ b/src/components/DeviceConfiguration/index.js @@ -14,17 +14,19 @@ import { CPopover, } from '@coreui/react'; import CIcon from '@coreui/icons-react'; -import PropTypes from 'prop-types'; import { cilWindowMaximize } from '@coreui/icons'; import { prettyDate } from 'utils/helper'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import CopyToClipboardButton from 'components/CopyToClipboardButton'; import DeviceConfigurationModal from './DeviceConfigurationModal'; import styles from './index.module.scss'; -const DeviceConfiguration = ({ selectedDeviceId }) => { +const DeviceConfiguration = () => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [collapse, setCollapse] = useState(false); const [showModal, setShowModal] = useState(false); const [device, setDevice] = useState(null); @@ -42,12 +44,12 @@ const DeviceConfiguration = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, }; axiosInstance - .get(`/device/${encodeURIComponent(selectedDeviceId)}`, options) + .get(`/device/${encodeURIComponent(deviceSerialNumber)}`, options) .then((response) => { setDevice(response.data); }) @@ -55,8 +57,8 @@ const DeviceConfiguration = ({ selectedDeviceId }) => { }; useEffect(() => { - if (selectedDeviceId) getDevice(); - }, [selectedDeviceId]); + if (deviceSerialNumber) getDevice(); + }, [deviceSerialNumber]); if (device) { return ( @@ -206,8 +208,4 @@ const DeviceConfiguration = ({ selectedDeviceId }) => { ); }; -DeviceConfiguration.propTypes = { - selectedDeviceId: PropTypes.string.isRequired, -}; - export default DeviceConfiguration; diff --git a/src/components/DeviceHealth/index.js b/src/components/DeviceHealth/index.js index 0d8851e..2743191 100644 --- a/src/components/DeviceHealth/index.js +++ b/src/components/DeviceHealth/index.js @@ -15,17 +15,19 @@ import { import CIcon from '@coreui/icons-react'; import { useTranslation } from 'react-i18next'; import DatePicker from 'react-widgets/DatePicker'; -import PropTypes from 'prop-types'; import { prettyDate, dateToUnix } from 'utils/helper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; import eventBus from 'utils/eventBus'; import LoadingButton from 'components/LoadingButton'; import DeleteLogModal from 'components/DeleteLogModal'; import styles from './index.module.scss'; -const DeviceHealth = ({ selectedDeviceId }) => { +const DeviceHealth = () => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [collapse, setCollapse] = useState(false); const [details, setDetails] = useState([]); const [loading, setLoading] = useState(false); @@ -68,7 +70,7 @@ const DeviceHealth = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, params: { limit: logLimit, @@ -85,7 +87,7 @@ const DeviceHealth = ({ selectedDeviceId }) => { } axiosInstance - .get(`/device/${encodeURIComponent(selectedDeviceId)}/healthchecks${extraParams}`, options) + .get(`/device/${encodeURIComponent(deviceSerialNumber)}/healthchecks${extraParams}`, options) .then((response) => { setHealthChecks(response.data.values); }) @@ -128,7 +130,7 @@ const DeviceHealth = ({ selectedDeviceId }) => { ]; useEffect(() => { - if (selectedDeviceId) { + if (deviceSerialNumber) { setLogLimit(25); setLoadingMore(false); setShowLoadingMore(true); @@ -136,7 +138,7 @@ const DeviceHealth = ({ selectedDeviceId }) => { setEnd(''); getDeviceHealth(); } - }, [selectedDeviceId]); + }, [deviceSerialNumber]); useEffect(() => { if (logLimit !== 25) { @@ -168,12 +170,12 @@ const DeviceHealth = ({ selectedDeviceId }) => { }, [healthChecks]); useEffect(() => { - if (selectedDeviceId && start !== '' && end !== '') { + if (deviceSerialNumber && start !== '' && end !== '') { getDeviceHealth(); - } else if (selectedDeviceId && start === '' && end === '') { + } else if (deviceSerialNumber && start === '' && end === '') { getDeviceHealth(); } - }, [start, end, selectedDeviceId]); + }, [start, end, deviceSerialNumber]); useEffect(() => { eventBus.on('deletedHealth', () => getDeviceHealth()); @@ -281,7 +283,7 @@ const DeviceHealth = ({ selectedDeviceId }) => { /> { ); }; -DeviceHealth.propTypes = { - selectedDeviceId: PropTypes.string.isRequired, -}; - export default DeviceHealth; diff --git a/src/components/DeviceListTable/index.js b/src/components/DeviceListTable/index.js index dfd36e4..4a74939 100644 --- a/src/components/DeviceListTable/index.js +++ b/src/components/DeviceListTable/index.js @@ -17,7 +17,7 @@ import Select from 'react-select'; import PropTypes from 'prop-types'; import { cilSync, cilInfo, cilBadge, cilBan } from '@coreui/icons'; import CIcon from '@coreui/icons-react'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; import axiosInstance from 'utils/axiosInstance'; import { cleanBytesString } from 'utils/helper'; import meshIcon from 'assets/icons/Mesh.png'; @@ -29,6 +29,7 @@ import styles from './index.module.scss'; const DeviceList = () => { const { t } = useTranslation(); + const { currentToken } = useAuth(); const [loadedSerials, setLoadedSerials] = useState(false); const [serialNumbers, setSerialNumbers] = useState([]); const [page, setPage] = useState(0); @@ -38,12 +39,11 @@ const DeviceList = () => { const [loading, setLoading] = useState(true); const getSerialNumbers = () => { - const token = getToken(); setLoading(true); const headers = { Accept: 'application/json', - Authorization: `Bearer ${token}`, + Authorization: `Bearer ${currentToken}`, }; axiosInstance @@ -60,12 +60,11 @@ const DeviceList = () => { }; const getDeviceInformation = () => { - const token = getToken(); setLoading(true); const headers = { Accept: 'application/json', - Authorization: `Bearer ${token}`, + Authorization: `Bearer ${currentToken}`, }; const startIndex = page * devicesPerPage; @@ -89,12 +88,11 @@ const DeviceList = () => { }; const refreshDevice = (serialNumber) => { - const token = getToken(); setLoading(true); const headers = { Accept: 'application/json', - Authorization: `Bearer ${token}`, + Authorization: `Bearer ${currentToken}`, }; axiosInstance diff --git a/src/components/DeviceLogs/index.js b/src/components/DeviceLogs/index.js index 8050f54..e41f71f 100644 --- a/src/components/DeviceLogs/index.js +++ b/src/components/DeviceLogs/index.js @@ -14,17 +14,19 @@ import { import CIcon from '@coreui/icons-react'; import { useTranslation } from 'react-i18next'; import DatePicker from 'react-widgets/DatePicker'; -import PropTypes from 'prop-types'; import { prettyDate, dateToUnix } from 'utils/helper'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import eventBus from 'utils/eventBus'; import LoadingButton from 'components/LoadingButton'; import DeleteLogModal from 'components/DeleteLogModal'; import styles from './index.module.scss'; -const DeviceLogs = ({ selectedDeviceId }) => { +const DeviceLogs = () => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [collapse, setCollapse] = useState(false); const [details, setDetails] = useState([]); const [loading, setLoading] = useState(false); @@ -65,7 +67,7 @@ const DeviceLogs = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, params: { limit: logLimit, @@ -82,7 +84,7 @@ const DeviceLogs = ({ selectedDeviceId }) => { } axiosInstance - .get(`/device/${encodeURIComponent(selectedDeviceId)}/logs${extraParams}`, options) + .get(`/device/${encodeURIComponent(deviceSerialNumber)}/logs${extraParams}`, options) .then((response) => { setLogs(response.data.values); }) @@ -125,7 +127,7 @@ const DeviceLogs = ({ selectedDeviceId }) => { ]; useEffect(() => { - if (selectedDeviceId) { + if (deviceSerialNumber) { setLogLimit(25); setLoadingMore(false); setShowLoadingMore(true); @@ -133,7 +135,7 @@ const DeviceLogs = ({ selectedDeviceId }) => { setEnd(''); getLogs(); } - }, [selectedDeviceId]); + }, [deviceSerialNumber]); useEffect(() => { if (logLimit !== 25) { @@ -150,12 +152,12 @@ const DeviceLogs = ({ selectedDeviceId }) => { }, [logs]); useEffect(() => { - if (selectedDeviceId && start !== '' && end !== '') { + if (deviceSerialNumber && start !== '' && end !== '') { getLogs(); - } else if (selectedDeviceId && start === '' && end === '') { + } else if (deviceSerialNumber && start === '' && end === '') { getLogs(); } - }, [start, end, selectedDeviceId]); + }, [start, end, deviceSerialNumber]); useEffect(() => { eventBus.on('deletedLogs', () => getLogs()); @@ -258,7 +260,7 @@ const DeviceLogs = ({ selectedDeviceId }) => { } /> { ); }; -DeviceLogs.propTypes = { - selectedDeviceId: PropTypes.string.isRequired, -}; - export default DeviceLogs; diff --git a/src/components/DeviceStatusCard/index.js b/src/components/DeviceStatusCard/index.js index df96a2b..7e151d2 100644 --- a/src/components/DeviceStatusCard/index.js +++ b/src/components/DeviceStatusCard/index.js @@ -13,18 +13,20 @@ import { CSpinner, } from '@coreui/react'; import CIcon from '@coreui/icons-react'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import { cilSync } from '@coreui/icons'; import { useTranslation } from 'react-i18next'; -import PropTypes from 'prop-types'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; import { prettyDate, secondsToDetailed } from 'utils/helper'; import MemoryBar from './MemoryBar'; import styles from './index.module.scss'; -const DeviceStatusCard = ({ selectedDeviceId }) => { +const DeviceStatusCard = () => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [lastStats, setLastStats] = useState(null); const [status, setStatus] = useState(null); const [error, setError] = useState(false); @@ -40,16 +42,16 @@ const DeviceStatusCard = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, }; const lastStatsRequest = axiosInstance.get( - `/device/${encodeURIComponent(selectedDeviceId)}/statistics?lastOnly=true`, + `/device/${encodeURIComponent(deviceSerialNumber)}/statistics?lastOnly=true`, options, ); const statusRequest = axiosInstance.get( - `/device/${encodeURIComponent(selectedDeviceId)}/status`, + `/device/${encodeURIComponent(deviceSerialNumber)}/status`, options, ); @@ -68,8 +70,8 @@ const DeviceStatusCard = ({ selectedDeviceId }) => { useEffect(() => { setError(false); - if (selectedDeviceId) getData(); - }, [selectedDeviceId]); + if (deviceSerialNumber) getData(); + }, [deviceSerialNumber]); if (!error) { return ( @@ -78,7 +80,7 @@ const DeviceStatusCard = ({ selectedDeviceId }) => {
- {t('status.title', { serialNumber: selectedDeviceId })} + {t('status.title', { serialNumber: deviceSerialNumber })}
@@ -152,10 +154,14 @@ const DeviceStatusCard = ({ selectedDeviceId }) => {
{t('status.memory')} : - + @@ -172,7 +178,7 @@ const DeviceStatusCard = ({ selectedDeviceId }) => {
- {t('status.title', { serialNumber: selectedDeviceId })} + {t('status.title', { serialNumber: deviceSerialNumber })}
@@ -186,8 +192,4 @@ const DeviceStatusCard = ({ selectedDeviceId }) => { ); }; -DeviceStatusCard.propTypes = { - selectedDeviceId: PropTypes.string.isRequired, -}; - export default React.memo(DeviceStatusCard); diff --git a/src/components/FactoryResetModal/index.js b/src/components/FactoryResetModal/index.js index 61f09f1..978f0b4 100644 --- a/src/components/FactoryResetModal/index.js +++ b/src/components/FactoryResetModal/index.js @@ -14,15 +14,17 @@ import { import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; -import { useSelector } from 'react-redux'; import 'react-widgets/styles.css'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import axiosInstance from 'utils/axiosInstance'; import SuccessfulActionModalBody from 'components/SuccessfulActionModalBody'; import styles from './index.module.scss'; const ConfigureModal = ({ show, toggleModal }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); const [doingNow, setDoingNow] = useState(false); @@ -30,7 +32,6 @@ const ConfigureModal = ({ show, toggleModal }) => { const [keepRedirector, setKeepRedirector] = useState(true); const [responseBody, setResponseBody] = useState(''); const [checkingIfSure, setCheckingIfSure] = useState(false); - const selectedDeviceId = useSelector((state) => state.selectedDeviceId); const toggleRedirector = () => { setKeepRedirector(!keepRedirector); @@ -54,17 +55,17 @@ const ConfigureModal = ({ show, toggleModal }) => { setWaiting(true); const parameters = { - serialNumber: selectedDeviceId, + serialNumber: deviceSerialNumber, keepRedirector, }; const headers = { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }; axiosInstance - .post(`/device/${encodeURIComponent(selectedDeviceId)}/factory`, parameters, { headers }) + .post(`/device/${encodeURIComponent(deviceSerialNumber)}/factory`, parameters, { headers }) .then(() => { setHadSuccess(true); }) diff --git a/src/components/FirmwareUpgradeModal/UpgradeWaitingBody.js b/src/components/FirmwareUpgradeModal/UpgradeWaitingBody.js index b94ad25..4df7abe 100644 --- a/src/components/FirmwareUpgradeModal/UpgradeWaitingBody.js +++ b/src/components/FirmwareUpgradeModal/UpgradeWaitingBody.js @@ -3,11 +3,12 @@ import { useTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; import { CModalBody } from '@coreui/react'; import { v4 as createUuid } from 'uuid'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; import axiosInstance from 'utils/axiosInstance'; const UpgradeWaitingBody = ({ serialNumber }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); const [currentStep, setCurrentStep] = useState(0); const [secondsElapsed, setSecondsElapsed] = useState(0); const [labelsToShow, setLabelsToShow] = useState(['upgrade.command_submitted']); @@ -16,7 +17,7 @@ const UpgradeWaitingBody = ({ serialNumber }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, }; @@ -30,7 +31,7 @@ const UpgradeWaitingBody = ({ serialNumber }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, }; diff --git a/src/components/FirmwareUpgradeModal/index.js b/src/components/FirmwareUpgradeModal/index.js index b8ee19b..97b27dc 100644 --- a/src/components/FirmwareUpgradeModal/index.js +++ b/src/components/FirmwareUpgradeModal/index.js @@ -15,10 +15,10 @@ import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import DatePicker from 'react-widgets/DatePicker'; import PropTypes from 'prop-types'; -import { useSelector } from 'react-redux'; import { dateToUnix } from 'utils/helper'; import 'react-widgets/styles.css'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import axiosInstance from 'utils/axiosInstance'; import eventBus from 'utils/eventBus'; import getDeviceConnection from 'utils/deviceHelper'; @@ -28,6 +28,8 @@ import UpgradeWaitingBody from './UpgradeWaitingBody'; const FirmwareUpgradeModal = ({ show, toggleModal }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [isNow, setIsNow] = useState(true); const [waitForUpgrade, setWaitForUpgrade] = useState(false); const [date, setDate] = useState(new Date().toString()); @@ -39,7 +41,6 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { const [waitingForUpgrade, setWaitingForUpgrade] = useState(false); const [showWaitingConsole, setShowWaitingConsole] = useState(false); const [deviceConnected, setDeviceConnected] = useState(true); - const selectedDeviceId = useSelector((state) => state.selectedDeviceId); const toggleNow = () => { if (isNow) { @@ -81,9 +82,9 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { }, [firmware, date]); useEffect(() => { - if (selectedDeviceId !== null && show) { + if (deviceSerialNumber !== null && show) { const asyncGet = async () => { - const isConnected = await getDeviceConnection(selectedDeviceId); + const isConnected = await getDeviceConnection(deviceSerialNumber, currentToken); setDisableWaiting(!isConnected); setDeviceConnected(isConnected); }; @@ -97,17 +98,17 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { setBlockFields(true); const headers = { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, - serialNumber: selectedDeviceId, + Authorization: `Bearer ${currentToken}`, + serialNumber: deviceSerialNumber, }; const parameters = { - serialNumber: selectedDeviceId, + serialNumber: deviceSerialNumber, when: isNow ? 0 : dateToUnix(date), uri: firmware, }; axiosInstance - .post(`/device/${encodeURIComponent(selectedDeviceId)}/upgrade`, parameters, { headers }) + .post(`/device/${encodeURIComponent(deviceSerialNumber)}/upgrade`, parameters, { headers }) .then(() => { if (waitForUpgrade) { setShowWaitingConsole(true); @@ -129,7 +130,7 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { {t('upgrade.title')} - + diff --git a/src/components/InterfaceStatistics/LatestStatisticsModal.js b/src/components/InterfaceStatistics/LatestStatisticsModal.js index ae66563..4552554 100644 --- a/src/components/InterfaceStatistics/LatestStatisticsModal.js +++ b/src/components/InterfaceStatistics/LatestStatisticsModal.js @@ -10,23 +10,26 @@ import { import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import styles from './index.module.scss'; -const LatestStatisticsModal = ({ show, toggle, serialNumber }) => { +const LatestStatisticsModal = ({ show, toggle }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [latestStats, setLatestStats] = useState(''); const getLatestStats = () => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, }; axiosInstance - .get(`/device/${serialNumber}/statistics?lastOnly=true`, options) + .get(`/device/${deviceSerialNumber}/statistics?lastOnly=true`, options) .then((response) => { setLatestStats(response.data); }) @@ -57,7 +60,6 @@ const LatestStatisticsModal = ({ show, toggle, serialNumber }) => { }; LatestStatisticsModal.propTypes = { - serialNumber: PropTypes.string.isRequired, toggle: PropTypes.func.isRequired, show: PropTypes.bool.isRequired, }; diff --git a/src/components/InterfaceStatistics/StatisticsChartList.js b/src/components/InterfaceStatistics/StatisticsChartList.js index 80b8518..74229a5 100644 --- a/src/components/InterfaceStatistics/StatisticsChartList.js +++ b/src/components/InterfaceStatistics/StatisticsChartList.js @@ -1,15 +1,17 @@ import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import PropTypes from 'prop-types'; import { v4 as createUuid } from 'uuid'; import axiosInstance from 'utils/axiosInstance'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import { unixToTime, capitalizeFirstLetter } from 'utils/helper'; import eventBus from 'utils/eventBus'; import DeviceStatisticsChart from './DeviceStatisticsChart'; -const StatisticsChartList = ({ selectedDeviceId }) => { +const StatisticsChartList = () => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [statOptions, setStatOptions] = useState({ interfaceList: [], settings: {}, @@ -118,7 +120,7 @@ const StatisticsChartList = ({ selectedDeviceId }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, params: { serialNumber: '24f5a207a130', @@ -126,7 +128,7 @@ const StatisticsChartList = ({ selectedDeviceId }) => { }; axiosInstance - .get(`/device/${selectedDeviceId}/statistics?newest=true&limit=50`, options) + .get(`/device/${deviceSerialNumber}/statistics?newest=true&limit=50`, options) .then((response) => { transformIntoDataset(response.data.data); }) @@ -134,10 +136,10 @@ const StatisticsChartList = ({ selectedDeviceId }) => { }; useEffect(() => { - if (selectedDeviceId) { + if (deviceSerialNumber) { getStatistics(); } - }, [selectedDeviceId]); + }, [deviceSerialNumber]); useEffect(() => { eventBus.on('refreshInterfaceStatistics', () => getStatistics()); @@ -173,8 +175,4 @@ const StatisticsChartList = ({ selectedDeviceId }) => { ); }; -StatisticsChartList.propTypes = { - selectedDeviceId: PropTypes.string.isRequired, -}; - export default React.memo(StatisticsChartList); diff --git a/src/components/InterfaceStatistics/index.js b/src/components/InterfaceStatistics/index.js index 644f902..6383de4 100644 --- a/src/components/InterfaceStatistics/index.js +++ b/src/components/InterfaceStatistics/index.js @@ -1,6 +1,5 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import PropTypes from 'prop-types'; import { CDropdown, CDropdownToggle, @@ -19,7 +18,7 @@ import StatisticsChartList from './StatisticsChartList'; import LatestStatisticsModal from './LatestStatisticsModal'; import styles from './index.module.scss'; -const DeviceStatisticsCard = ({ selectedDeviceId }) => { +const DeviceStatisticsCard = () => { const { t } = useTranslation(); const [showLatestModal, setShowLatestModal] = useState(false); @@ -57,20 +56,12 @@ const DeviceStatisticsCard = ({ selectedDeviceId }) => {
- + - +
); }; -DeviceStatisticsCard.propTypes = { - selectedDeviceId: PropTypes.string.isRequired, -}; - export default DeviceStatisticsCard; diff --git a/src/components/RebootModal/index.js b/src/components/RebootModal/index.js index 622084d..3d3175f 100644 --- a/src/components/RebootModal/index.js +++ b/src/components/RebootModal/index.js @@ -13,10 +13,10 @@ import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import DatePicker from 'react-widgets/DatePicker'; import PropTypes from 'prop-types'; -import { useSelector } from 'react-redux'; import { dateToUnix } from 'utils/helper'; import 'react-widgets/styles.css'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import axiosInstance from 'utils/axiosInstance'; import eventBus from 'utils/eventBus'; import LoadingButton from 'components/LoadingButton'; @@ -25,11 +25,12 @@ import styles from './index.module.scss'; const ActionModal = ({ show, toggleModal }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [waiting, setWaiting] = useState(false); const [result, setResult] = useState(null); const [chosenDate, setChosenDate] = useState(new Date().toString()); const [isNow, setIsNow] = useState(false); - const selectedDeviceId = useSelector((state) => state.selectedDeviceId); const toggleNow = () => { setIsNow(!isNow); @@ -52,21 +53,20 @@ const ActionModal = ({ show, toggleModal }) => { const doAction = () => { setWaiting(true); - const token = getToken(); const utcDate = new Date(chosenDate); const parameters = { - serialNumber: selectedDeviceId, + serialNumber: deviceSerialNumber, when: isNow ? 0 : dateToUnix(utcDate), }; const headers = { Accept: 'application/json', - Authorization: `Bearer ${token}`, + Authorization: `Bearer ${currentToken}`, }; axiosInstance - .post(`/device/${encodeURIComponent(selectedDeviceId)}/reboot`, parameters, { headers }) + .post(`/device/${encodeURIComponent(deviceSerialNumber)}/reboot`, parameters, { headers }) .then(() => { setResult('success'); }) diff --git a/src/components/TraceModal/WaitingForTraceBody.js b/src/components/TraceModal/WaitingForTraceBody.js index 7195f2e..a472944 100644 --- a/src/components/TraceModal/WaitingForTraceBody.js +++ b/src/components/TraceModal/WaitingForTraceBody.js @@ -2,13 +2,14 @@ import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; import { CModalBody, CButton, CSpinner, CModalFooter } from '@coreui/react'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; import axiosInstance from 'utils/axiosInstance'; import styles from './index.module.scss'; const WaitingForTraceBody = ({ serialNumber, commandUuid, toggle }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); const [secondsElapsed, setSecondsElapsed] = useState(0); const [waitingForFile, setWaitingForFile] = useState(true); @@ -16,7 +17,7 @@ const WaitingForTraceBody = ({ serialNumber, commandUuid, toggle }) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, }; @@ -34,7 +35,7 @@ const WaitingForTraceBody = ({ serialNumber, commandUuid, toggle }) => { const options = { headers: { Accept: 'application/octet-stream', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${currentToken}`, }, responseType: 'arraybuffer', }; diff --git a/src/components/TraceModal/index.js b/src/components/TraceModal/index.js index 1060120..e47875d 100644 --- a/src/components/TraceModal/index.js +++ b/src/components/TraceModal/index.js @@ -17,9 +17,9 @@ import { import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; -import { useSelector } from 'react-redux'; import 'react-widgets/styles.css'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import axiosInstance from 'utils/axiosInstance'; import eventBus from 'utils/eventBus'; import getDeviceConnection from 'utils/deviceHelper'; @@ -30,6 +30,8 @@ import styles from './index.module.scss'; const TraceModal = ({ show, toggleModal }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); const [blockFields, setBlockFields] = useState(false); @@ -43,8 +45,6 @@ const TraceModal = ({ show, toggleModal }) => { const [waitingForTrace, setWaitingForTrace] = useState(false); const [commandUuid, setCommandUuid] = useState(null); - const selectedDeviceId = useSelector((state) => state.selectedDeviceId); - const toggleWaitForTrace = () => { setWaitForTrace(!waitForTrace); }; @@ -65,10 +65,8 @@ const TraceModal = ({ show, toggleModal }) => { setHadFailure(false); setHadSuccess(false); - const token = getToken(); - const parameters = { - serialNumber: selectedDeviceId, + serialNumber: deviceSerialNumber, when: 0, network: chosenInterface, }; @@ -81,11 +79,11 @@ const TraceModal = ({ show, toggleModal }) => { const headers = { Accept: 'application/json', - Authorization: `Bearer ${token}`, + Authorization: `Bearer ${currentToken}`, }; axiosInstance - .post(`/device/${encodeURIComponent(selectedDeviceId)}/trace`, parameters, { headers }) + .post(`/device/${encodeURIComponent(deviceSerialNumber)}/trace`, parameters, { headers }) .then((response) => { setHadSuccess(true); if (waitForTrace) { @@ -105,9 +103,9 @@ const TraceModal = ({ show, toggleModal }) => { }; useEffect(() => { - if (selectedDeviceId !== null && show) { + if (deviceSerialNumber !== null && show) { const asyncGet = async () => { - const isConnected = await getDeviceConnection(selectedDeviceId); + const isConnected = await getDeviceConnection(deviceSerialNumber, currentToken); setIsDeviceConnected(isConnected); }; asyncGet(); @@ -119,7 +117,7 @@ const TraceModal = ({ show, toggleModal }) => { return ( ); diff --git a/src/components/WifiScanModal/index.js b/src/components/WifiScanModal/index.js index 738285a..fa59949 100644 --- a/src/components/WifiScanModal/index.js +++ b/src/components/WifiScanModal/index.js @@ -13,9 +13,9 @@ import { } from '@coreui/react'; import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { useSelector } from 'react-redux'; import PropTypes from 'prop-types'; -import { getToken } from 'utils/authHelper'; +import { useAuth } from 'contexts/AuthProvider'; +import { useDevice } from 'contexts/DeviceProvider'; import axiosInstance from 'utils/axiosInstance'; import eventBus from 'utils/eventBus'; import LoadingButton from 'components/LoadingButton'; @@ -25,6 +25,8 @@ import styles from './index.module.scss'; const WifiScanModal = ({ show, toggleModal }) => { const { t } = useTranslation(); + const { currentToken } = useAuth(); + const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); const [waiting, setWaiting] = useState(false); @@ -32,7 +34,6 @@ const WifiScanModal = ({ show, toggleModal }) => { const [activeScan, setActiveScan] = useState(false); const [hideOptions, setHideOptions] = useState(false); const [channelList, setChannelList] = useState([]); - const selectedDeviceId = useSelector((state) => state.selectedDeviceId); const toggleVerbose = () => { setVerbose(!choseVerbose); @@ -88,20 +89,18 @@ const WifiScanModal = ({ show, toggleModal }) => { setHadSuccess(false); setWaiting(true); - const token = getToken(); - const parameters = { - serialNumber: selectedDeviceId, + serialNumber: deviceSerialNumber, verbose: choseVerbose, activeScan, }; const headers = { Accept: 'application/json', - Authorization: `Bearer ${token}`, + Authorization: `Bearer ${currentToken}`, }; axiosInstance - .post(`/device/${encodeURIComponent(selectedDeviceId)}/wifiscan`, parameters, { headers }) + .post(`/device/${encodeURIComponent(deviceSerialNumber)}/wifiscan`, parameters, { headers }) .then((response) => { const scanList = response?.data?.results?.status?.scan; diff --git a/src/contexts/AuthProvider/index.js b/src/contexts/AuthProvider/index.js new file mode 100644 index 0000000..195fdba --- /dev/null +++ b/src/contexts/AuthProvider/index.js @@ -0,0 +1,21 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; + +const AuthContext = React.createContext(); + +export const AuthProvider = ({ token, children }) => { + const [currentToken, setCurrentToken] = useState(token); + + return ( + + {children} + + ); +}; + +AuthProvider.propTypes = { + token: PropTypes.string.isRequired, + children: PropTypes.node.isRequired, +}; + +export const useAuth = () => React.useContext(AuthContext); diff --git a/src/contexts/DeviceProvider/index.js b/src/contexts/DeviceProvider/index.js new file mode 100644 index 0000000..3194d65 --- /dev/null +++ b/src/contexts/DeviceProvider/index.js @@ -0,0 +1,21 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; + +const DeviceContext = React.createContext(); + +export const DeviceProvider = ({ serialNumber, children }) => { + const [deviceSerialNumber, setDeviceSerialNumber] = useState(serialNumber); + + return ( + + {children} + + ); +}; + +DeviceProvider.propTypes = { + serialNumber: PropTypes.string.isRequired, + children: PropTypes.node.isRequired, +}; + +export const useDevice = () => React.useContext(DeviceContext); diff --git a/src/index.js b/src/index.js index 8f47296..78079d7 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import 'index.css'; -import { Provider } from 'react-redux'; import App from 'App'; -import store from 'store'; import { icons } from 'assets/icons'; import 'i18n'; @@ -11,9 +9,7 @@ React.icons = icons; ReactDOM.render( - - - + , document.getElementById('root'), ); diff --git a/src/layout/Header/index.js b/src/layout/Header/index.js index 19e733f..7dbbbf3 100644 --- a/src/layout/Header/index.js +++ b/src/layout/Header/index.js @@ -1,5 +1,4 @@ import React, { useState, useEffect } from 'react'; -import { useSelector, useDispatch } from 'react-redux'; import { useTranslation } from 'react-i18next'; import { CHeader, @@ -11,26 +10,25 @@ import { CLink, CPopover, } from '@coreui/react'; +import PropTypes from 'prop-types'; import CIcon from '@coreui/icons-react'; import { cilAccountLogout } from '@coreui/icons'; import { logout } from 'utils/authHelper'; import routes from 'routes'; import LanguageSwitcher from 'components/LanguageSwitcher'; -const TheHeader = () => { +const TheHeader = ({ showSidebar, setShowSidebar }) => { const { t, i18n } = useTranslation(); - const dispatch = useDispatch(); const [translatedRoutes, setTranslatedRoutes] = useState(routes); - const sidebarShow = useSelector((state) => state.sidebarShow); const toggleSidebar = () => { - const val = [true, 'responsive'].includes(sidebarShow) ? false : 'responsive'; - dispatch({ type: 'set', sidebarShow: val }); + const val = [true, 'responsive'].includes(showSidebar) ? false : 'responsive'; + setShowSidebar(val); }; const toggleSidebarMobile = () => { - const val = [false, 'responsive'].includes(sidebarShow) ? true : 'responsive'; - dispatch({ type: 'set', sidebarShow: val }); + const val = [false, 'responsive'].includes(showSidebar) ? true : 'responsive'; + setShowSidebar(val); }; useEffect(() => { @@ -69,4 +67,9 @@ const TheHeader = () => { ); }; +TheHeader.propTypes = { + showSidebar: PropTypes.string.isRequired, + setShowSidebar: PropTypes.func.isRequired, +}; + export default TheHeader; diff --git a/src/layout/Sidebar/index.js b/src/layout/Sidebar/index.js index 90b59ab..3a647fd 100644 --- a/src/layout/Sidebar/index.js +++ b/src/layout/Sidebar/index.js @@ -1,5 +1,4 @@ import React from 'react'; -import { useSelector, useDispatch } from 'react-redux'; import { CCreateElement, CSidebar, @@ -11,14 +10,13 @@ import { CSidebarNavDropdown, CSidebarNavItem, } from '@coreui/react'; +import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import logoBar from 'assets/OpenWiFi_LogoLockup_WhiteColour.svg'; import styles from './index.module.scss'; -const TheSidebar = () => { +const TheSidebar = ({ showSidebar, setShowSidebar }) => { const { t } = useTranslation(); - const dispatch = useDispatch(); - const show = useSelector((state) => state.sidebarShow); const navigation = [ { @@ -30,7 +28,7 @@ const TheSidebar = () => { ]; return ( - dispatch({ type: 'set', sidebarShow: val })}> + setShowSidebar(val)}> { ); }; +TheSidebar.propTypes = { + showSidebar: PropTypes.string.isRequired, + setShowSidebar: PropTypes.func.isRequired, +}; + export default React.memo(TheSidebar); diff --git a/src/layout/index.js b/src/layout/index.js index d5599d8..32de36e 100644 --- a/src/layout/index.js +++ b/src/layout/index.js @@ -1,21 +1,17 @@ -import React from 'react'; -import { useSelector } from 'react-redux'; -import PropTypes from 'prop-types'; +import React, { useState } from 'react'; import TheContent from './Content'; import TheSidebar from './Sidebar'; import TheFooter from './Footer'; import TheHeader from './Header'; -const TheLayout = (props) => { - const { isLoggedIn } = useSelector((state) => state.connected); - if (isLoggedIn) { - return
{props.children}
; - } +const TheLayout = () => { + const [showSidebar, setShowSidebar] = useState('responsive'); + return (
- +
- +
@@ -25,12 +21,4 @@ const TheLayout = (props) => { ); }; -TheLayout.propTypes = { - children: PropTypes.instanceOf(Object), -}; - -TheLayout.defaultProps = { - children: {}, -}; - export default TheLayout; diff --git a/src/pages/DevicePage/index.js b/src/pages/DevicePage/index.js index 293dcf9..01a870f 100644 --- a/src/pages/DevicePage/index.js +++ b/src/pages/DevicePage/index.js @@ -1,5 +1,4 @@ -import React, { useEffect } from 'react'; -import { useDispatch, useSelector } from 'react-redux'; +import React from 'react'; import { useParams } from 'react-router-dom'; import { CRow, CCol } from '@coreui/react'; import DeviceHealth from 'components/DeviceHealth'; @@ -9,40 +8,33 @@ import DeviceLogs from 'components/DeviceLogs'; import DeviceStatisticsCard from 'components/InterfaceStatistics'; import DeviceActionCard from 'components/DeviceActionCard'; import DeviceStatusCard from 'components/DeviceStatusCard'; +import { DeviceProvider } from 'contexts/DeviceProvider'; const DevicePage = () => { - const dispatch = useDispatch(); - const { deviceId } = useParams(); - const previouslySelectedDeviceId = useSelector((state) => state.selectedDeviceId); - - useEffect(() => { - if (deviceId && deviceId !== previouslySelectedDeviceId) - dispatch({ type: 'set', selectedDeviceId: deviceId }); - }, [deviceId]); return ( - <> -
+
+ - - + + - - - + + + - - + + -
- + +
); }; diff --git a/src/pages/LoginPage/index.js b/src/pages/LoginPage/index.js index a94a0ff..37120f1 100644 --- a/src/pages/LoginPage/index.js +++ b/src/pages/LoginPage/index.js @@ -18,8 +18,8 @@ import { CInvalidFeedback, } from '@coreui/react'; import CIcon from '@coreui/icons-react'; +import { useAuth } from 'contexts/AuthProvider'; import { cilUser, cilLockLocked, cilLink } from '@coreui/icons'; -import { useDispatch } from 'react-redux'; import axiosInstance from 'utils/axiosInstance'; import logo from 'assets/OpenWiFi_LogoLockup_DarkGreyColour.svg'; import LanguageSwitcher from 'components/LanguageSwitcher'; @@ -27,7 +27,7 @@ import styles from './index.module.scss'; const Login = () => { const { t } = useTranslation(); - const dispatch = useDispatch(); + const { setCurrentToken } = useAuth(); const [userId, setUsername] = useState(''); const [password, setPassword] = useState(''); const [gatewayUrl, setGatewayUrl] = useState(''); @@ -87,7 +87,7 @@ const Login = () => { .then((response) => { sessionStorage.setItem('gw_url', `${gatewayUrlToUse}/api/v1`); sessionStorage.setItem('access_token', response.data.access_token); - dispatch({ type: 'set', connected: true }); + setCurrentToken(response.data.access_token); }) .catch(() => { setHadError(true); diff --git a/src/router/index.js b/src/router/index.js new file mode 100644 index 0000000..dae0eda --- /dev/null +++ b/src/router/index.js @@ -0,0 +1,20 @@ +import { useAuth } from 'contexts/AuthProvider'; +import { Route } from 'react-router-dom'; +import React from 'react'; + +const TheLayout = React.lazy(() => import('layout')); +const Login = React.lazy(() => import('pages/LoginPage')); + +const Routes = () => { + const { currentToken } = useAuth(); + + return ( + (currentToken !== '' ? : )} + /> + ); +}; + +export default Routes; diff --git a/src/routes.js b/src/routes.js index 9cf19d4..345e867 100644 --- a/src/routes.js +++ b/src/routes.js @@ -3,9 +3,7 @@ import React from 'react'; const DevicePage = React.lazy(() => import('pages/DevicePage')); const DeviceListPage = React.lazy(() => import('pages/DeviceListPage')); -const routes = [ +export default [ { path: '/devices', exact: true, name: 'common.devices', component: DeviceListPage }, { path: '/devices/:deviceId', name: 'common.device_page', component: DevicePage }, ]; - -export default routes; diff --git a/src/store.js b/src/store.js deleted file mode 100644 index cc7b3fd..0000000 --- a/src/store.js +++ /dev/null @@ -1,19 +0,0 @@ -import { createStore } from 'redux'; - -const initialState = { - sidebarShow: 'responsive', - connected: false, - selectedDeviceId: null, -}; - -const changeState = (state = initialState, { type, ...rest }) => { - switch (type) { - case 'set': - return { ...state, ...rest }; - default: - return state; - } -}; - -const store = createStore(changeState); -export default store; diff --git a/src/utils/deviceHelper.js b/src/utils/deviceHelper.js index 7fd318d..44f755f 100644 --- a/src/utils/deviceHelper.js +++ b/src/utils/deviceHelper.js @@ -1,11 +1,10 @@ -import { getToken } from 'utils/authHelper'; import axiosInstance from 'utils/axiosInstance'; -export default async (deviceId) => { +export default async (deviceId, token) => { const options = { headers: { Accept: 'application/json', - Authorization: `Bearer ${getToken()}`, + Authorization: `Bearer ${token}`, }, }; From 908a0344332f935b8302fe4b63c2aa517fe5bd0f Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Thu, 1 Jul 2021 16:45:32 -0400 Subject: [PATCH 16/42] Version 0.9.9 --- package-lock.json | 4 ++-- package.json | 2 +- src/layout/Footer/index.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index a92a661..4e88dd4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "0.9.8", + "version": "0.9.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "0.9.8", + "version": "0.9.9", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index 6a74b69..5362ec2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "0.9.8", + "version": "0.9.9", "private": true, "dependencies": { "@coreui/coreui": "^3.4.0", diff --git a/src/layout/Footer/index.js b/src/layout/Footer/index.js index 0e5136b..769cb40 100644 --- a/src/layout/Footer/index.js +++ b/src/layout/Footer/index.js @@ -6,7 +6,7 @@ const TheFooter = () => ( {(t) => ( -
{t('footer.version')} 0.9.8
+
{t('footer.version')} 0.9.9
{t('footer.powered_by')} From c017fe0774322dbcd92628e669621ff77c9d3658 Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Fri, 2 Jul 2021 17:34:13 -0400 Subject: [PATCH 17/42] Now using endpoints returned from the gateway sec --- package-lock.json | 4 +-- package.json | 2 +- public/config.json | 2 +- src/App.js | 4 ++- src/components/BlinkModal/index.js | 4 +-- src/components/CommandHistory/index.js | 8 ++--- src/components/ConfigureModal/index.js | 4 +-- src/components/DeleteLogModal/index.js | 4 +-- src/components/DeviceActionCard/index.js | 4 +-- src/components/DeviceConfiguration/index.js | 4 +-- src/components/DeviceHealth/index.js | 4 +-- src/components/DeviceListTable/index.js | 8 ++--- src/components/DeviceLogs/index.js | 4 +-- src/components/DeviceStatusCard/index.js | 6 ++-- src/components/FactoryResetModal/index.js | 4 +-- .../UpgradeWaitingBody.js | 6 ++-- src/components/FirmwareUpgradeModal/index.js | 6 ++-- .../LatestStatisticsModal.js | 4 +-- .../StatisticsChartList.js | 4 +-- src/components/RebootModal/index.js | 4 +-- .../TraceModal/WaitingForTraceBody.js | 6 ++-- src/components/TraceModal/index.js | 6 ++-- src/components/WifiScanModal/index.js | 4 +-- src/contexts/AuthProvider/index.js | 10 ++++-- src/layout/Footer/index.js | 2 +- src/layout/Header/index.js | 4 ++- src/pages/LoginPage/index.js | 32 ++++++++++++++----- src/router/index.js | 4 +-- src/utils/authHelper.js | 19 +++++++++-- src/utils/axiosInstance.js | 9 ------ src/utils/deviceHelper.js | 4 +-- 31 files changed, 110 insertions(+), 80 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e88dd4..4e5cfe6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "0.9.9", + "version": "0.9.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "0.9.9", + "version": "0.9.10", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index 5362ec2..ac98d83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "0.9.9", + "version": "0.9.10", "private": true, "dependencies": { "@coreui/coreui": "^3.4.0", diff --git a/public/config.json b/public/config.json index c9d97c3..2939ef8 100644 --- a/public/config.json +++ b/public/config.json @@ -1,4 +1,4 @@ { - "DEFAULT_GATEWAY_URL": "https://ucentral.dpaas.arilia.com:16001", + "DEFAULT_UCENTRALSEC_URL": "https://ucentral.dpaas.arilia.com:16001", "ALLOW_GATEWAY_CHANGE": false } diff --git a/src/App.js b/src/App.js index 32f0cad..5bd0b1d 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import { HashRouter, Switch } from 'react-router-dom'; import 'scss/style.scss'; import Router from 'router'; import { AuthProvider } from 'contexts/AuthProvider'; +import { checkIfJson } from 'utils/helper'; const loading = (
@@ -12,9 +13,10 @@ const loading = ( const App = () => { const storageToken = sessionStorage.getItem('access_token'); + const apiEndpoints = checkIfJson(sessionStorage.getItem('gateway_endpoints')) ? JSON.parse(sessionStorage.getItem('gateway_endpoints')) : {}; return ( - + diff --git a/src/components/BlinkModal/index.js b/src/components/BlinkModal/index.js index 3780f7a..6eae13d 100644 --- a/src/components/BlinkModal/index.js +++ b/src/components/BlinkModal/index.js @@ -29,7 +29,7 @@ import styles from './index.module.scss'; const BlinkModal = ({ show, toggleModal }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [isNow, setIsNow] = useState(false); const [waiting, setWaiting] = useState(false); @@ -73,7 +73,7 @@ const BlinkModal = ({ show, toggleModal }) => { }; axiosInstance - .post(`/device/${encodeURIComponent(deviceSerialNumber)}/leds`, parameters, { headers }) + .post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/leds`, parameters, { headers }) .then(() => { setResult('success'); }) diff --git a/src/components/CommandHistory/index.js b/src/components/CommandHistory/index.js index d4bd7d9..664f2d2 100644 --- a/src/components/CommandHistory/index.js +++ b/src/components/CommandHistory/index.js @@ -27,7 +27,7 @@ import styles from './index.module.scss'; const DeviceCommands = () => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); // Wifiscan result related const [chosenWifiScan, setChosenWifiScan] = useState(null); @@ -110,7 +110,7 @@ const DeviceCommands = () => { axiosInstance .get( - `/commands?serialNumber=${encodeURIComponent(deviceSerialNumber)}${extraParams}`, + `${endpoints.ucentralgw}/api/v1/commands?serialNumber=${encodeURIComponent(deviceSerialNumber)}${extraParams}`, options, ) .then((response) => { @@ -133,7 +133,7 @@ const DeviceCommands = () => { }; axiosInstance - .get(`/file/${uuid}?serialNumber=${deviceSerialNumber}`, options) + .get(`${endpoints.ucentralgw}/api/v1/file/${uuid}?serialNumber=${deviceSerialNumber}`, options) .then((response) => { const blob = new Blob([response.data], { type: 'application/octet-stream' }); const link = document.createElement('a'); @@ -154,7 +154,7 @@ const DeviceCommands = () => { }, }; return axiosInstance - .delete(`/command/${uuidDelete}`, options) + .delete(`${endpoints.ucentralgw}/api/v1/command/${uuidDelete}`, options) .then(() => { deleteCommandFromList(uuidDelete); setUuidDelete(''); diff --git a/src/components/ConfigureModal/index.js b/src/components/ConfigureModal/index.js index e588d4d..456638a 100644 --- a/src/components/ConfigureModal/index.js +++ b/src/components/ConfigureModal/index.js @@ -27,7 +27,7 @@ import styles from './index.module.scss'; const ConfigureModal = ({ show, toggleModal }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); @@ -84,7 +84,7 @@ const ConfigureModal = ({ show, toggleModal }) => { }; axiosInstance - .post(`/device/${encodeURIComponent(deviceSerialNumber)}/configure`, parameters, { headers }) + .post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/configure`, parameters, { headers }) .then(() => { setHadSuccess(true); }) diff --git a/src/components/DeleteLogModal/index.js b/src/components/DeleteLogModal/index.js index 25bc76f..2096505 100644 --- a/src/components/DeleteLogModal/index.js +++ b/src/components/DeleteLogModal/index.js @@ -13,7 +13,7 @@ import styles from './index.module.scss'; const DeleteLogModal = ({ show, toggle, object }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [loading, setLoading] = useState(false); const [maxDate, setMaxDate] = useState(new Date().toString()); @@ -37,7 +37,7 @@ const DeleteLogModal = ({ show, toggle, object }) => { }, }; return axiosInstance - .delete(`/device/${deviceSerialNumber}/${object}`, options) + .delete(`${endpoints.ucentralgw}/api/v1/device/${deviceSerialNumber}/${object}`, options) .then(() => {}) .catch(() => {}) .finally(() => { diff --git a/src/components/DeviceActionCard/index.js b/src/components/DeviceActionCard/index.js index f0b17f9..3c2713c 100644 --- a/src/components/DeviceActionCard/index.js +++ b/src/components/DeviceActionCard/index.js @@ -17,7 +17,7 @@ import styles from './index.module.scss'; const DeviceActions = () => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [showRebootModal, setShowRebootModal] = useState(false); const [showBlinkModal, setShowBlinkModal] = useState(false); @@ -66,7 +66,7 @@ const DeviceActions = () => { }; axiosInstance - .get(`/device/${encodeURIComponent(deviceSerialNumber)}/rtty`, options) + .get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/rtty`, options) .then((response) => { const url = `https://${response.data.server}:${response.data.viewport}/connect/${response.data.connectionId}`; const newWindow = window.open(url, '_blank', 'noopener,noreferrer'); diff --git a/src/components/DeviceConfiguration/index.js b/src/components/DeviceConfiguration/index.js index b448438..3644a3b 100644 --- a/src/components/DeviceConfiguration/index.js +++ b/src/components/DeviceConfiguration/index.js @@ -25,7 +25,7 @@ import styles from './index.module.scss'; const DeviceConfiguration = () => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [collapse, setCollapse] = useState(false); const [showModal, setShowModal] = useState(false); @@ -49,7 +49,7 @@ const DeviceConfiguration = () => { }; axiosInstance - .get(`/device/${encodeURIComponent(deviceSerialNumber)}`, options) + .get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}`, options) .then((response) => { setDevice(response.data); }) diff --git a/src/components/DeviceHealth/index.js b/src/components/DeviceHealth/index.js index 2743191..ff4df40 100644 --- a/src/components/DeviceHealth/index.js +++ b/src/components/DeviceHealth/index.js @@ -26,7 +26,7 @@ import styles from './index.module.scss'; const DeviceHealth = () => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [collapse, setCollapse] = useState(false); const [details, setDetails] = useState([]); @@ -87,7 +87,7 @@ const DeviceHealth = () => { } axiosInstance - .get(`/device/${encodeURIComponent(deviceSerialNumber)}/healthchecks${extraParams}`, options) + .get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/healthchecks${extraParams}`, options) .then((response) => { setHealthChecks(response.data.values); }) diff --git a/src/components/DeviceListTable/index.js b/src/components/DeviceListTable/index.js index 4a74939..127d3ec 100644 --- a/src/components/DeviceListTable/index.js +++ b/src/components/DeviceListTable/index.js @@ -29,7 +29,7 @@ import styles from './index.module.scss'; const DeviceList = () => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const [loadedSerials, setLoadedSerials] = useState(false); const [serialNumbers, setSerialNumbers] = useState([]); const [page, setPage] = useState(0); @@ -47,7 +47,7 @@ const DeviceList = () => { }; axiosInstance - .get('/devices?serialOnly=true', { + .get(`${endpoints.ucentralgw}/api/v1/devices?serialOnly=true`, { headers, }) .then((response) => { @@ -75,7 +75,7 @@ const DeviceList = () => { .join(','); axiosInstance - .get(`/devices?deviceWithStatus=true&select=${serialsToGet}`, { + .get(`${endpoints.ucentralgw}/api/v1/devices?deviceWithStatus=true&select=${serialsToGet}`, { headers, }) .then((response) => { @@ -96,7 +96,7 @@ const DeviceList = () => { }; axiosInstance - .get(`/devices?deviceWithStatus=true&select=${encodeURIComponent(serialNumber)}`, { + .get(`${endpoints.ucentralgw}/api/v1/devices?deviceWithStatus=true&select=${encodeURIComponent(serialNumber)}`, { headers, }) .then((response) => { diff --git a/src/components/DeviceLogs/index.js b/src/components/DeviceLogs/index.js index e41f71f..3af663c 100644 --- a/src/components/DeviceLogs/index.js +++ b/src/components/DeviceLogs/index.js @@ -25,7 +25,7 @@ import styles from './index.module.scss'; const DeviceLogs = () => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [collapse, setCollapse] = useState(false); const [details, setDetails] = useState([]); @@ -84,7 +84,7 @@ const DeviceLogs = () => { } axiosInstance - .get(`/device/${encodeURIComponent(deviceSerialNumber)}/logs${extraParams}`, options) + .get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/logs${extraParams}`, options) .then((response) => { setLogs(response.data.values); }) diff --git a/src/components/DeviceStatusCard/index.js b/src/components/DeviceStatusCard/index.js index 7e151d2..fbaa90d 100644 --- a/src/components/DeviceStatusCard/index.js +++ b/src/components/DeviceStatusCard/index.js @@ -25,7 +25,7 @@ import styles from './index.module.scss'; const DeviceStatusCard = () => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [lastStats, setLastStats] = useState(null); const [status, setStatus] = useState(null); @@ -47,11 +47,11 @@ const DeviceStatusCard = () => { }; const lastStatsRequest = axiosInstance.get( - `/device/${encodeURIComponent(deviceSerialNumber)}/statistics?lastOnly=true`, + `${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/statistics?lastOnly=true`, options, ); const statusRequest = axiosInstance.get( - `/device/${encodeURIComponent(deviceSerialNumber)}/status`, + `${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/status`, options, ); diff --git a/src/components/FactoryResetModal/index.js b/src/components/FactoryResetModal/index.js index 978f0b4..03da2d1 100644 --- a/src/components/FactoryResetModal/index.js +++ b/src/components/FactoryResetModal/index.js @@ -23,7 +23,7 @@ import styles from './index.module.scss'; const ConfigureModal = ({ show, toggleModal }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); @@ -65,7 +65,7 @@ const ConfigureModal = ({ show, toggleModal }) => { }; axiosInstance - .post(`/device/${encodeURIComponent(deviceSerialNumber)}/factory`, parameters, { headers }) + .post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/factory`, parameters, { headers }) .then(() => { setHadSuccess(true); }) diff --git a/src/components/FirmwareUpgradeModal/UpgradeWaitingBody.js b/src/components/FirmwareUpgradeModal/UpgradeWaitingBody.js index 4df7abe..b7d3b4d 100644 --- a/src/components/FirmwareUpgradeModal/UpgradeWaitingBody.js +++ b/src/components/FirmwareUpgradeModal/UpgradeWaitingBody.js @@ -8,7 +8,7 @@ import axiosInstance from 'utils/axiosInstance'; const UpgradeWaitingBody = ({ serialNumber }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const [currentStep, setCurrentStep] = useState(0); const [secondsElapsed, setSecondsElapsed] = useState(0); const [labelsToShow, setLabelsToShow] = useState(['upgrade.command_submitted']); @@ -22,7 +22,7 @@ const UpgradeWaitingBody = ({ serialNumber }) => { }; axiosInstance - .get(`/device/${encodeURIComponent(serialNumber)}/status`, options) + .get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(serialNumber)}/status`, options) .then((response) => response.data.connected) .catch(() => {}); }; @@ -36,7 +36,7 @@ const UpgradeWaitingBody = ({ serialNumber }) => { }; axiosInstance - .get(`/device/${encodeURIComponent(serialNumber)}`, options) + .get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(serialNumber)}`, options) .then((response) => response.data.firmware) .catch(() => {}); }; diff --git a/src/components/FirmwareUpgradeModal/index.js b/src/components/FirmwareUpgradeModal/index.js index 97b27dc..26ef6fb 100644 --- a/src/components/FirmwareUpgradeModal/index.js +++ b/src/components/FirmwareUpgradeModal/index.js @@ -28,7 +28,7 @@ import UpgradeWaitingBody from './UpgradeWaitingBody'; const FirmwareUpgradeModal = ({ show, toggleModal }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [isNow, setIsNow] = useState(true); const [waitForUpgrade, setWaitForUpgrade] = useState(false); @@ -84,7 +84,7 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { useEffect(() => { if (deviceSerialNumber !== null && show) { const asyncGet = async () => { - const isConnected = await getDeviceConnection(deviceSerialNumber, currentToken); + const isConnected = await getDeviceConnection(deviceSerialNumber, currentToken, endpoints.ucentralgw); setDisableWaiting(!isConnected); setDeviceConnected(isConnected); }; @@ -108,7 +108,7 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => { uri: firmware, }; axiosInstance - .post(`/device/${encodeURIComponent(deviceSerialNumber)}/upgrade`, parameters, { headers }) + .post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/upgrade`, parameters, { headers }) .then(() => { if (waitForUpgrade) { setShowWaitingConsole(true); diff --git a/src/components/InterfaceStatistics/LatestStatisticsModal.js b/src/components/InterfaceStatistics/LatestStatisticsModal.js index 4552554..9ae2f1e 100644 --- a/src/components/InterfaceStatistics/LatestStatisticsModal.js +++ b/src/components/InterfaceStatistics/LatestStatisticsModal.js @@ -16,7 +16,7 @@ import styles from './index.module.scss'; const LatestStatisticsModal = ({ show, toggle }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [latestStats, setLatestStats] = useState(''); @@ -29,7 +29,7 @@ const LatestStatisticsModal = ({ show, toggle }) => { }; axiosInstance - .get(`/device/${deviceSerialNumber}/statistics?lastOnly=true`, options) + .get(`${endpoints.ucentralgw}/api/v1/device/${deviceSerialNumber}/statistics?lastOnly=true`, options) .then((response) => { setLatestStats(response.data); }) diff --git a/src/components/InterfaceStatistics/StatisticsChartList.js b/src/components/InterfaceStatistics/StatisticsChartList.js index 74229a5..52d5be1 100644 --- a/src/components/InterfaceStatistics/StatisticsChartList.js +++ b/src/components/InterfaceStatistics/StatisticsChartList.js @@ -10,7 +10,7 @@ import DeviceStatisticsChart from './DeviceStatisticsChart'; const StatisticsChartList = () => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [statOptions, setStatOptions] = useState({ interfaceList: [], @@ -128,7 +128,7 @@ const StatisticsChartList = () => { }; axiosInstance - .get(`/device/${deviceSerialNumber}/statistics?newest=true&limit=50`, options) + .get(`${endpoints.ucentralgw}/api/v1/device/${deviceSerialNumber}/statistics?newest=true&limit=50`, options) .then((response) => { transformIntoDataset(response.data.data); }) diff --git a/src/components/RebootModal/index.js b/src/components/RebootModal/index.js index 3d3175f..a09299c 100644 --- a/src/components/RebootModal/index.js +++ b/src/components/RebootModal/index.js @@ -25,7 +25,7 @@ import styles from './index.module.scss'; const ActionModal = ({ show, toggleModal }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [waiting, setWaiting] = useState(false); const [result, setResult] = useState(null); @@ -66,7 +66,7 @@ const ActionModal = ({ show, toggleModal }) => { }; axiosInstance - .post(`/device/${encodeURIComponent(deviceSerialNumber)}/reboot`, parameters, { headers }) + .post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/reboot`, parameters, { headers }) .then(() => { setResult('success'); }) diff --git a/src/components/TraceModal/WaitingForTraceBody.js b/src/components/TraceModal/WaitingForTraceBody.js index a472944..557bdc4 100644 --- a/src/components/TraceModal/WaitingForTraceBody.js +++ b/src/components/TraceModal/WaitingForTraceBody.js @@ -9,7 +9,7 @@ import styles from './index.module.scss'; const WaitingForTraceBody = ({ serialNumber, commandUuid, toggle }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const [secondsElapsed, setSecondsElapsed] = useState(0); const [waitingForFile, setWaitingForFile] = useState(true); @@ -22,7 +22,7 @@ const WaitingForTraceBody = ({ serialNumber, commandUuid, toggle }) => { }; axiosInstance - .get(`/command/${encodeURIComponent(commandUuid)}`, options) + .get(`${endpoints.ucentralgw}/api/v1/command/${encodeURIComponent(commandUuid)}`, options) .then((response) => { if (response.data.waitingForFile === 0) { setWaitingForFile(false); @@ -41,7 +41,7 @@ const WaitingForTraceBody = ({ serialNumber, commandUuid, toggle }) => { }; axiosInstance - .get(`/file/${commandUuid}?serialNumber=${serialNumber}`, options) + .get(`${endpoints.ucentralgw}/api/v1/file/${commandUuid}?serialNumber=${serialNumber}`, options) .then((response) => { const blob = new Blob([response.data], { type: 'application/octet-stream' }); const link = document.createElement('a'); diff --git a/src/components/TraceModal/index.js b/src/components/TraceModal/index.js index e47875d..54ea015 100644 --- a/src/components/TraceModal/index.js +++ b/src/components/TraceModal/index.js @@ -30,7 +30,7 @@ import styles from './index.module.scss'; const TraceModal = ({ show, toggleModal }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); @@ -83,7 +83,7 @@ const TraceModal = ({ show, toggleModal }) => { }; axiosInstance - .post(`/device/${encodeURIComponent(deviceSerialNumber)}/trace`, parameters, { headers }) + .post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/trace`, parameters, { headers }) .then((response) => { setHadSuccess(true); if (waitForTrace) { @@ -105,7 +105,7 @@ const TraceModal = ({ show, toggleModal }) => { useEffect(() => { if (deviceSerialNumber !== null && show) { const asyncGet = async () => { - const isConnected = await getDeviceConnection(deviceSerialNumber, currentToken); + const isConnected = await getDeviceConnection(deviceSerialNumber, currentToken, endpoints.ucentralgw); setIsDeviceConnected(isConnected); }; asyncGet(); diff --git a/src/components/WifiScanModal/index.js b/src/components/WifiScanModal/index.js index fa59949..9e4214a 100644 --- a/src/components/WifiScanModal/index.js +++ b/src/components/WifiScanModal/index.js @@ -25,7 +25,7 @@ import styles from './index.module.scss'; const WifiScanModal = ({ show, toggleModal }) => { const { t } = useTranslation(); - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); @@ -100,7 +100,7 @@ const WifiScanModal = ({ show, toggleModal }) => { }; axiosInstance - .post(`/device/${encodeURIComponent(deviceSerialNumber)}/wifiscan`, parameters, { headers }) + .post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/wifiscan`, parameters, { headers }) .then((response) => { const scanList = response?.data?.results?.status?.scan; diff --git a/src/contexts/AuthProvider/index.js b/src/contexts/AuthProvider/index.js index 195fdba..5f294cf 100644 --- a/src/contexts/AuthProvider/index.js +++ b/src/contexts/AuthProvider/index.js @@ -3,11 +3,12 @@ import PropTypes from 'prop-types'; const AuthContext = React.createContext(); -export const AuthProvider = ({ token, children }) => { +export const AuthProvider = ({ token, apiEndpoints, children }) => { const [currentToken, setCurrentToken] = useState(token); + const [endpoints, setEndpoints] = useState(apiEndpoints); return ( - + {children} ); @@ -16,6 +17,11 @@ export const AuthProvider = ({ token, children }) => { AuthProvider.propTypes = { token: PropTypes.string.isRequired, children: PropTypes.node.isRequired, + apiEndpoints: PropTypes.instanceOf(Object) }; +AuthProvider.defaultProps = { + apiEndpoints: {} +} + export const useAuth = () => React.useContext(AuthContext); diff --git a/src/layout/Footer/index.js b/src/layout/Footer/index.js index 769cb40..df04d39 100644 --- a/src/layout/Footer/index.js +++ b/src/layout/Footer/index.js @@ -6,7 +6,7 @@ const TheFooter = () => ( {(t) => ( -
{t('footer.version')} 0.9.9
+
{t('footer.version')} 0.9.10
{t('footer.powered_by')} diff --git a/src/layout/Header/index.js b/src/layout/Header/index.js index 7dbbbf3..a0857c4 100644 --- a/src/layout/Header/index.js +++ b/src/layout/Header/index.js @@ -16,9 +16,11 @@ import { cilAccountLogout } from '@coreui/icons'; import { logout } from 'utils/authHelper'; import routes from 'routes'; import LanguageSwitcher from 'components/LanguageSwitcher'; +import { useAuth } from 'contexts/AuthProvider'; const TheHeader = ({ showSidebar, setShowSidebar }) => { const { t, i18n } = useTranslation(); + const { currentToken, endpoints} = useAuth(); const [translatedRoutes, setTranslatedRoutes] = useState(routes); const toggleSidebar = () => { @@ -52,7 +54,7 @@ const TheHeader = ({ showSidebar, setShowSidebar }) => { - + logout(currentToken, endpoints.ucentralsec)} /> diff --git a/src/pages/LoginPage/index.js b/src/pages/LoginPage/index.js index 37120f1..102dde2 100644 --- a/src/pages/LoginPage/index.js +++ b/src/pages/LoginPage/index.js @@ -17,6 +17,7 @@ import { CAlert, CInvalidFeedback, } from '@coreui/react'; + import CIcon from '@coreui/icons-react'; import { useAuth } from 'contexts/AuthProvider'; import { cilUser, cilLockLocked, cilLink } from '@coreui/icons'; @@ -27,7 +28,7 @@ import styles from './index.module.scss'; const Login = () => { const { t } = useTranslation(); - const { setCurrentToken } = useAuth(); + const { setCurrentToken, setEndpoints } = useAuth(); const [userId, setUsername] = useState(''); const [password, setPassword] = useState(''); const [gatewayUrl, setGatewayUrl] = useState(''); @@ -36,7 +37,7 @@ const Login = () => { const [emptyPassword, setEmptyPassword] = useState(false); const [emptyGateway, setEmptyGateway] = useState(false); const [defaultConfig, setDefaultConfig] = useState({ - DEFAULT_GATEWAY_URL: '', + DEFAULT_UCENTRALSEC_URL: '', ALLOW_GATEWAY_CHANGE: true, }); const placeholderUrl = 'Gateway URL (ex: https://your-url:port)'; @@ -78,16 +79,31 @@ const Login = () => { }; const SignIn = (credentials) => { - const gatewayUrlToUse = defaultConfig.ALLOW_GATEWAY_CHANGE + let token = ''; + const uCentralSecUrl = defaultConfig.ALLOW_GATEWAY_CHANGE ? gatewayUrl - : defaultConfig.DEFAULT_GATEWAY_URL; + : defaultConfig.DEFAULT_UCENTRALSEC_URL; axiosInstance - .post(`${gatewayUrlToUse}/api/v1/oauth2`, credentials) + .post(`${uCentralSecUrl}/api/v1/oauth2`, credentials) .then((response) => { - sessionStorage.setItem('gw_url', `${gatewayUrlToUse}/api/v1`); sessionStorage.setItem('access_token', response.data.access_token); - setCurrentToken(response.data.access_token); + token = response.data.access_token; + return axiosInstance.get(`${uCentralSecUrl}/api/v1/systemEndpoints`, { headers: { + Accept: 'application/json', + Authorization: `Bearer ${response.data.access_token}`, + }}); + }) + .then ((response) => { + const endpoints = { + ucentralsec: uCentralSecUrl + }; + for (const endpoint of response.data.endpoints){ + endpoints[endpoint.type] = endpoint.uri; + } + sessionStorage.setItem('gateway_endpoints', JSON.stringify(endpoints)); + setEndpoints(endpoints); + setCurrentToken(token); }) .catch(() => { setHadError(true); @@ -113,7 +129,7 @@ const Login = () => { getDefaultConfig(); }, []); useEffect(() => { - setGatewayUrl(defaultConfig.DEFAULT_GATEWAY_URL); + setGatewayUrl(defaultConfig.DEFAULT_UCENTRALSEC_URL); }, [defaultConfig]); return ( diff --git a/src/router/index.js b/src/router/index.js index dae0eda..90746e8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -6,13 +6,13 @@ const TheLayout = React.lazy(() => import('layout')); const Login = React.lazy(() => import('pages/LoginPage')); const Routes = () => { - const { currentToken } = useAuth(); + const { currentToken, endpoints } = useAuth(); return ( (currentToken !== '' ? : )} + render={(props) => (currentToken !== '' && Object.keys(endpoints).length !== 0 ? : )} /> ); }; diff --git a/src/utils/authHelper.js b/src/utils/authHelper.js index 8ab0ee6..9fe7edb 100644 --- a/src/utils/authHelper.js +++ b/src/utils/authHelper.js @@ -1,6 +1,19 @@ -export const logout = () => { - sessionStorage.clear(); - window.location.replace('/'); +import axiosInstance from "./axiosInstance"; + +export const logout = (token, endpoint) => { + axiosInstance + .delete(`${endpoint}/api/v1/oauth2/${token}`, { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}`, + }, + }) + .then(() => {}) + .catch(() => {}) + .finally(() => { + sessionStorage.clear(); + window.location.replace('/'); + }) }; export const getToken = () => { diff --git a/src/utils/axiosInstance.js b/src/utils/axiosInstance.js index 2a4b342..b228240 100644 --- a/src/utils/axiosInstance.js +++ b/src/utils/axiosInstance.js @@ -16,15 +16,6 @@ axiosInstance.defaults.timeout = 30000; axiosInstance.defaults.headers.get.Accept = 'application/json'; axiosInstance.defaults.headers.post.Accept = 'application/json'; -axiosInstance.interceptors.request.use((config) => { - const newConfig = config; - const url = sessionStorage.getItem('gw_url'); - if (url !== undefined && url !== null && !newConfig.url.includes(url)) { - newConfig.url = url + newConfig.url; - } - return newConfig; -}); - axiosInstance.interceptors.response.use( // Success actions undefined, diff --git a/src/utils/deviceHelper.js b/src/utils/deviceHelper.js index 44f755f..03c302e 100644 --- a/src/utils/deviceHelper.js +++ b/src/utils/deviceHelper.js @@ -1,6 +1,6 @@ import axiosInstance from 'utils/axiosInstance'; -export default async (deviceId, token) => { +export default async (deviceId, token, endpoint) => { const options = { headers: { Accept: 'application/json', @@ -9,7 +9,7 @@ export default async (deviceId, token) => { }; return axiosInstance - .get(`/device/${encodeURIComponent(deviceId)}/status`, options) + .get(`${endpoint}/api/v1/device/${encodeURIComponent(deviceId)}/status`, options) .then((response) => response.data.connected) .catch(() => false); }; From e8960368a5725b5f3e36a65e425e74c3b3a6e44f Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 2 Jul 2021 17:38:40 -0400 Subject: [PATCH 18/42] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ac32871..033eb3a 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,12 @@ npm run build Once the build is done, you can move the `build` folder on your server. ### Configuration -You must change the `config.json` file in `public` directory to point to your gateway URL. You may also limit the ability for users to change the default gateway. If you do not allow a gateway change, the gateway URL will not appear on the login screen. +You must change the `config.json` file in `public` directory to point to your uCentral Security Service URL (uCentralSec). You may also limit the ability for users to change the default uCentralSec. If you do not allow a uCentralSec change, the uCentralSec URL will not appear on the login screen. Here are the current default values: ``` { - "DEFAULT_GATEWAY_URL": "https://ucentral.dpaas.arilia.com:16001", - "ALLOW_GATEWAY_CHANGE": false + "DEFAULT_UCENTRALSEC_URL": "https://ucentral.dpaas.arilia.com:16001", + "ALLOW_UCENTRALSEC_CHANGE": false } ``` From 2056482179d3b2effa8a1304cde6dec4b83fe90e Mon Sep 17 00:00:00 2001 From: bourquecharles Date: Fri, 2 Jul 2021 17:42:09 -0400 Subject: [PATCH 19/42] Changed variables for UCENTRALSEC --- package-lock.json | 4 ++-- package.json | 2 +- public/config.json | 2 +- src/layout/Footer/index.js | 2 +- src/pages/LoginPage/index.js | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e5cfe6..d962d2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "0.9.10", + "version": "0.9.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "0.9.10", + "version": "0.9.11", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index ac98d83..a8113df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "0.9.10", + "version": "0.9.11", "private": true, "dependencies": { "@coreui/coreui": "^3.4.0", diff --git a/public/config.json b/public/config.json index 2939ef8..2fbdc16 100644 --- a/public/config.json +++ b/public/config.json @@ -1,4 +1,4 @@ { "DEFAULT_UCENTRALSEC_URL": "https://ucentral.dpaas.arilia.com:16001", - "ALLOW_GATEWAY_CHANGE": false + "ALLOW_UCENTRALSEC_CHANGE": false } diff --git a/src/layout/Footer/index.js b/src/layout/Footer/index.js index df04d39..4a43b8f 100644 --- a/src/layout/Footer/index.js +++ b/src/layout/Footer/index.js @@ -6,7 +6,7 @@ const TheFooter = () => ( {(t) => ( -
{t('footer.version')} 0.9.10
+
{t('footer.version')} 0.9.11
{t('footer.powered_by')} diff --git a/src/pages/LoginPage/index.js b/src/pages/LoginPage/index.js index 102dde2..7388506 100644 --- a/src/pages/LoginPage/index.js +++ b/src/pages/LoginPage/index.js @@ -38,7 +38,7 @@ const Login = () => { const [emptyGateway, setEmptyGateway] = useState(false); const [defaultConfig, setDefaultConfig] = useState({ DEFAULT_UCENTRALSEC_URL: '', - ALLOW_GATEWAY_CHANGE: true, + ALLOW_UCENTRALSEC_CHANGE: true, }); const placeholderUrl = 'Gateway URL (ex: https://your-url:port)'; @@ -80,7 +80,7 @@ const Login = () => { const SignIn = (credentials) => { let token = ''; - const uCentralSecUrl = defaultConfig.ALLOW_GATEWAY_CHANGE + const uCentralSecUrl = defaultConfig.ALLOW_UCENTRALSEC_CHANGE ? gatewayUrl : defaultConfig.DEFAULT_UCENTRALSEC_URL; @@ -189,7 +189,7 @@ const Login = () => { {t('login.please_enter_password')} -