From d6f390d7d42b7884d61a50075f6305866a2e8734 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 27 Jan 2022 20:28:12 +0100 Subject: [PATCH 1/3] 2.5.34: wifi scan can now use the override_dfs option, shows alert if error code = 1 --- package-lock.json | 4 ++-- package.json | 2 +- 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/WifiScanModal/index.js | 27 +++++++++++++++++++-------- 8 files changed, 32 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index fcc864d..b019cb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "2.5.33", + "version": "2.5.34", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "2.5.33", + "version": "2.5.34", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index 630fd79..dcaa5a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "2.5.33", + "version": "2.5.34", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index fc3178d..278ed8b 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -804,7 +804,9 @@ "associations": "Verbände", "mode": "Modus", "network_diagram": "Netzwerkdiagramm", + "override_dfs": "DFS überschreiben", "radios": "Radios", + "scan_warning": "Ihr 5G-Funkgerät befindet sich auf einem Radarkanal, Sie müssen „Override DFS“ aktivieren, um das Scannen aller 5G-Kanäle zu ermöglichen", "title": "WLAN-Analyse", "vendor": "Verkäufer" } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index b60384c..a209086 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -804,7 +804,9 @@ "associations": "Associations", "mode": "Mode", "network_diagram": "Network Diagram", + "override_dfs": "Override DFS", "radios": "Radios", + "scan_warning": "Your 5G radio is on a radar channel, you must enable “Override DFS” to allow scanning of all 5G channels", "title": "Wi-Fi Analysis", "vendor": "Vendor" } diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index b18372f..8cb2e5d 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -804,7 +804,9 @@ "associations": "Asociaciones", "mode": "Modo", "network_diagram": "Diagrama de Red", + "override_dfs": "Anular DFS", "radios": "Radios", + "scan_warning": "Su radio 5G está en un canal de radar, debe habilitar \"Anular DFS\" para permitir el escaneo de todos los canales 5G", "title": "Análisis de Wi-Fi", "vendor": "Vendedor" } diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index 4a4a204..d3316c0 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -804,7 +804,9 @@ "associations": "Les associations", "mode": "Mode", "network_diagram": "Diagramme de réseau", + "override_dfs": "Remplacer DFS", "radios": "Radios", + "scan_warning": "Votre radio 5G est sur un canal radar, vous devez activer \"Override DFS\" pour permettre le balayage de tous les canaux 5G", "title": "Analyse Wi-Fi", "vendor": "vendeur" } diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index 6e03c9a..7734c6e 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -804,7 +804,9 @@ "associations": "Associações", "mode": "Modo", "network_diagram": "Diagrama de rede", + "override_dfs": "Substituir DFS", "radios": "Rádios", + "scan_warning": "Seu rádio 5G está em um canal de radar, você deve habilitar “Override DFS” para permitir a varredura de todos os canais 5G", "title": "Análise de Wi-Fi", "vendor": "fornecedor" } diff --git a/src/components/WifiScanModal/index.js b/src/components/WifiScanModal/index.js index 3ec159b..a992b2f 100644 --- a/src/components/WifiScanModal/index.js +++ b/src/components/WifiScanModal/index.js @@ -1,4 +1,5 @@ import { + CAlert, CButton, CModal, CModalHeader, @@ -29,14 +30,15 @@ const WifiScanModal = ({ show, toggleModal }) => { const { deviceSerialNumber } = useDevice(); const [hadSuccess, setHadSuccess] = useState(false); const [hadFailure, setHadFailure] = useState(false); + const [errorCode, setErrorCode] = useState(0); const [waiting, setWaiting] = useState(false); - const [choseVerbose, setVerbose] = useState(true); + const [dfs, setDfs] = useState(true); const [activeScan, setActiveScan] = useState(false); const [hideOptions, setHideOptions] = useState(false); const [channelList, setChannelList] = useState([]); - const toggleVerbose = () => { - setVerbose(!choseVerbose); + const toggleDfs = () => { + setDfs(!dfs); }; const toggleActiveScan = () => { @@ -48,9 +50,10 @@ const WifiScanModal = ({ show, toggleModal }) => { setHadFailure(false); setWaiting(false); setChannelList([]); - setVerbose(true); + setDfs(true); setActiveScan(false); setHideOptions(false); + setErrorCode(0); }, [show]); const parseThroughList = (scanList) => { @@ -91,7 +94,7 @@ const WifiScanModal = ({ show, toggleModal }) => { const parameters = { serialNumber: deviceSerialNumber, - verbose: choseVerbose, + override_dfs: dfs, activeScan, }; const headers = { @@ -110,6 +113,7 @@ const WifiScanModal = ({ show, toggleModal }) => { if (scanList) { setChannelList(parseThroughList(scanList)); + setErrorCode(response.data.errorCode ?? 0); setHideOptions(true); setHadSuccess(true); } else { @@ -142,14 +146,14 @@ const WifiScanModal = ({ show, toggleModal }) => {
{t('scan.directions')}
-

Verbose:

+

{t('wifi_analysis.override_dfs')}:

@@ -191,6 +195,13 @@ const WifiScanModal = ({ show, toggleModal }) => {
{t('scan.result_directions')}
+ {errorCode === 1 && ( + + + {t('wifi_analysis.scan_warning')} + + + )} From 60a072809bd942b486ab6f387d2b8df279c2e911 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 28 Jan 2022 14:58:01 +0100 Subject: [PATCH 2/3] 2.5.35: now displaying 'waiting for update' when lastStats arent fetched yet on device status card --- package-lock.json | 4 +- package.json | 2 +- public/locales/de/translation.json | 1 + public/locales/en/translation.json | 1 + public/locales/es/translation.json | 1 + public/locales/fr/translation.json | 1 + public/locales/pt/translation.json | 1 + .../DevicePage/DeviceStatusCard/index.js | 102 ++++++++++-------- 8 files changed, 68 insertions(+), 45 deletions(-) diff --git a/package-lock.json b/package-lock.json index b019cb2..d65655b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "2.5.34", + "version": "2.5.35", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "2.5.34", + "version": "2.5.35", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index dcaa5a2..d4dbfd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "2.5.34", + "version": "2.5.35", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 278ed8b..f8fc5a6 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -206,6 +206,7 @@ "vendors": "Anbieter", "view_more": "Mehr anzeigen", "visibility": "Sichtweite", + "waiting_for_update": "Warten auf Aktualisierung", "yes": "Ja" }, "configuration": { diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index a209086..005b353 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -206,6 +206,7 @@ "vendors": "Vendors", "view_more": "View more", "visibility": "Visibility", + "waiting_for_update": "Waiting for Update", "yes": "Yes" }, "configuration": { diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index 8cb2e5d..b6964e5 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -206,6 +206,7 @@ "vendors": "Vendedores", "view_more": "Ver más", "visibility": "Visibilidad", + "waiting_for_update": "Esperando actualización", "yes": "Sí" }, "configuration": { diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index d3316c0..2a1643a 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -206,6 +206,7 @@ "vendors": "Vendeurs", "view_more": "Afficher plus", "visibility": "Visibilité", + "waiting_for_update": "En attente de mise à jour", "yes": "Oui" }, "configuration": { diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index 7734c6e..e84e905 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -206,6 +206,7 @@ "vendors": "Vendedores", "view_more": "Veja mais", "visibility": "visibilidade", + "waiting_for_update": "Aguardando atualização", "yes": "sim" }, "configuration": { diff --git a/src/pages/DevicePage/DeviceStatusCard/index.js b/src/pages/DevicePage/DeviceStatusCard/index.js index 13e97f9..fe249ad 100644 --- a/src/pages/DevicePage/DeviceStatusCard/index.js +++ b/src/pages/DevicePage/DeviceStatusCard/index.js @@ -21,11 +21,32 @@ import { prettyDate, compactSecondsToDetailed, cleanBytesString } from 'utils/he import styles from './index.module.scss'; const errorField = (t) => ( - + {t('status.error')} ); +const stats = (lastStats) => ( +
+ {lastStats?.unit?.load[0] !== undefined ? (lastStats?.unit?.load[0] * 100).toFixed(2) : '-'}% + {' / '} + {lastStats?.unit?.load[1] !== undefined ? (lastStats?.unit?.load[1] * 100).toFixed(2) : '-'}% + {' / '} + {lastStats?.unit?.load[2] !== undefined ? (lastStats?.unit?.load[2] * 100).toFixed(2) : '-'}% +
+); + +const waitingForUpdateField = (t) => ( + + {t('common.waiting_for_update')} + +); + +const displayInfo = (value, toDisplay, t) => { + if (value !== undefined) return toDisplay; + return waitingForUpdateField(t); +}; + const getMemoryColor = (memTotal, memFree) => { let memoryUsed = 0; if (memTotal > 0) memoryUsed = Math.floor(((memTotal - memFree) / memTotal) * 100); @@ -40,6 +61,16 @@ const getMemoryPercentage = (memTotal, memFree) => { return `${Math.floor(((memTotal - memFree) / memTotal) * 100)}%`; }; +const memory = (lastStats) => ( + + {getMemoryPercentage(lastStats?.unit?.memory?.total ?? 0, lastStats?.unit?.memory?.free ?? 0)} + +); + const DeviceStatusCard = ({ t, loading, @@ -113,11 +144,15 @@ const DeviceStatusCard = ({ {error ? errorField(t) - : compactSecondsToDetailed( + : displayInfo( lastStats?.unit?.uptime, - t('common.day'), - t('common.days'), - t('common.seconds'), + compactSecondsToDetailed( + lastStats?.unit?.uptime, + t('common.day'), + t('common.days'), + t('common.seconds'), + ), + t, )} @@ -130,7 +165,13 @@ const DeviceStatusCard = ({ {t('status.localtime')}: - {error ? errorField(t) : prettyDate(lastStats?.unit?.localtime)} + {error + ? errorField(t) + : displayInfo( + lastStats?.unit?.localtime, + prettyDate(lastStats?.unit?.localtime), + t, + )} {t('firmware.revision')}: @@ -150,52 +191,29 @@ const DeviceStatusCard = ({ {t('status.load_averages')}: - {error ? ( - errorField(t) - ) : ( -
- {lastStats?.unit?.load[0] !== undefined - ? (lastStats?.unit?.load[0] * 100).toFixed(2) - : '-'} - %{' / '} - {lastStats?.unit?.load[1] !== undefined - ? (lastStats?.unit?.load[1] * 100).toFixed(2) - : '-'} - %{' / '} - {lastStats?.unit?.load[2] !== undefined - ? (lastStats?.unit?.load[2] * 100).toFixed(2) - : '-'} - % -
- )} + {error + ? errorField(t) + : displayInfo(lastStats?.unit?.memory?.total, stats(lastStats), t)}
{t('status.total_memory')}: - {error ? errorField(t) : cleanBytesString(lastStats?.unit?.memory?.total)} + {error + ? errorField(t) + : displayInfo( + lastStats?.unit?.memory?.total, + cleanBytesString(lastStats?.unit?.memory?.total), + t, + )} {t('status.memory')}: - {error ? ( - errorField(t) - ) : ( - - {getMemoryPercentage( - lastStats?.unit?.memory?.total ?? 0, - lastStats?.unit?.memory?.free ?? 0, - )} - - )} + {error + ? errorField(t) + : displayInfo(lastStats?.unit?.memory?.total, memory(lastStats), t)} From d9ea2abf1acdd1e933ccd94108a079b6218398e5 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 3 Feb 2022 20:30:02 +0100 Subject: [PATCH 3/3] 2.5.36: fix for device statistics version 1 --- package-lock.json | 4 +-- package.json | 2 +- .../StatisticsChartList.js | 32 +++++++++++++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index d65655b..8583137 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ucentral-client", - "version": "2.5.35", + "version": "2.5.36", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ucentral-client", - "version": "2.5.35", + "version": "2.5.36", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/package.json b/package.json index d4dbfd9..47618c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ucentral-client", - "version": "2.5.35", + "version": "2.5.36", "dependencies": { "@coreui/coreui": "^3.4.0", "@coreui/icons": "^2.0.1", diff --git a/src/components/InterfaceStatistics/StatisticsChartList.js b/src/components/InterfaceStatistics/StatisticsChartList.js index 182f5f1..189a43c 100644 --- a/src/components/InterfaceStatistics/StatisticsChartList.js +++ b/src/components/InterfaceStatistics/StatisticsChartList.js @@ -114,8 +114,11 @@ const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) => } // Looping through all the data + let prevTx = 0; + let prevRx = 0; for (const log of sortedData) { // Looping through the interfaces of the log + const version = log.data.version ?? 0; for (const inter of log.data.interfaces) { if (inter.ssids?.length > 0) { let totalTx = 0; @@ -123,12 +126,19 @@ const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) => for (const ssid of inter.ssids) { if (ssid.associations) { for (const assoc of ssid.associations) { - if (assoc.deltas) { - totalTx += assoc.deltas?.tx_bytes ?? 0; - totalRx += assoc.deltas?.rx_bytes ?? 0; + if (version === 0) { + if (assoc.deltas) { + totalTx += assoc.deltas?.tx_bytes ?? 0; + totalRx += assoc.deltas?.rx_bytes ?? 0; + } else { + totalTx += assoc.tx_bytes ?? 0; + totalRx += assoc.rx_bytes ?? 0; + } } else { - totalTx += assoc.tx_bytes ?? 0; - totalRx += assoc.rx_bytes ?? 0; + totalTx += assoc.tx_bytes - prevTx ?? 0; + totalRx += assoc.rx_bytes - prevRx ?? 0; + prevTx = assoc.tx_bytes; + prevRx = assoc.rx_bytes; } } } @@ -146,6 +156,16 @@ const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) => } } + for (let y = 0; y < interfaceList.length; y += 1) { + for (let z = 0; z < interfaceList[y].length; z += 1) { + const newArray = interfaceList[y][z].data; + if (newArray.length > 0) newArray.shift(); + interfaceList[y][z].data = newArray; + } + } + + const newCategories = categories; + if (newCategories.length > 0) newCategories.shift(); const interfaceOptions = { chart: { id: 'chart', @@ -160,7 +180,7 @@ const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) => fontSize: '15px', }, }, - categories, + categories: newCategories, tickAmount: areSameDay ? 15 : 10, }, yaxis: {