mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-11-02 03:07:46 +00:00
2.5.43: download wifi scan button added to wifi scan modal
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "2.5.42",
|
"version": "2.5.43",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "2.5.42",
|
"version": "2.5.43",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coreui/coreui": "^3.4.0",
|
"@coreui/coreui": "^3.4.0",
|
||||||
"@coreui/icons": "^2.0.1",
|
"@coreui/icons": "^2.0.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "2.5.42",
|
"version": "2.5.43",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coreui/coreui": "^3.4.0",
|
"@coreui/coreui": "^3.4.0",
|
||||||
"@coreui/icons": "^2.0.1",
|
"@coreui/icons": "^2.0.1",
|
||||||
|
|||||||
@@ -596,7 +596,7 @@
|
|||||||
"channel": "Kanal",
|
"channel": "Kanal",
|
||||||
"directions": "Starten Sie einen WiFi-Scan dieses Geräts, der ungefähr 25 Sekunden dauern sollte.",
|
"directions": "Starten Sie einen WiFi-Scan dieses Geräts, der ungefähr 25 Sekunden dauern sollte.",
|
||||||
"re_scan": "Erneut scannen",
|
"re_scan": "Erneut scannen",
|
||||||
"result_directions": "Bitte klicken Sie auf die Schaltfläche '$t(scan.re_scan)', wenn Sie einen Scan mit derselben Konfiguration wie beim letzten Scan durchführen möchten.",
|
"result_directions": "Sie können oben rechts auf die Schaltfläche „Scannen“ klicken, um $t(scan.re_scan)",
|
||||||
"results": "Ergebnisse des WiFi-Scans",
|
"results": "Ergebnisse des WiFi-Scans",
|
||||||
"scan": "Scan",
|
"scan": "Scan",
|
||||||
"scanning": "Scannen... ",
|
"scanning": "Scannen... ",
|
||||||
|
|||||||
@@ -596,7 +596,7 @@
|
|||||||
"channel": "Channel",
|
"channel": "Channel",
|
||||||
"directions": "Launch a wifi scan of this device, which should take approximately 25 seconds.",
|
"directions": "Launch a wifi scan of this device, which should take approximately 25 seconds.",
|
||||||
"re_scan": "Re-Scan",
|
"re_scan": "Re-Scan",
|
||||||
"result_directions": "Please click the '$t(scan.re_scan)' button if you would like to do a scan with the same configuration as the last.",
|
"result_directions": "You can click the 'Scan' button at the top right to $t(scan.re_scan)",
|
||||||
"results": "Wi-Fi Scan Results",
|
"results": "Wi-Fi Scan Results",
|
||||||
"scan": "Scan",
|
"scan": "Scan",
|
||||||
"scanning": "Scanning... ",
|
"scanning": "Scanning... ",
|
||||||
|
|||||||
@@ -596,7 +596,7 @@
|
|||||||
"channel": "Canal",
|
"channel": "Canal",
|
||||||
"directions": "Ejecute un escaneo wifi de este dispositivo, que debería tomar aproximadamente 25 segundos.",
|
"directions": "Ejecute un escaneo wifi de este dispositivo, que debería tomar aproximadamente 25 segundos.",
|
||||||
"re_scan": "Vuelva a escanear",
|
"re_scan": "Vuelva a escanear",
|
||||||
"result_directions": "Haga clic en el botón '$ t (scan.re_scan)' si desea realizar un escaneo con la misma configuración que el anterior.",
|
"result_directions": "Puede hacer clic en el botón 'Escanear' en la parte superior derecha para $t(scan.re_scan)",
|
||||||
"results": "Resultados de escaneo Wi-Fi",
|
"results": "Resultados de escaneo Wi-Fi",
|
||||||
"scan": "Escanear",
|
"scan": "Escanear",
|
||||||
"scanning": "Exploración... ",
|
"scanning": "Exploración... ",
|
||||||
|
|||||||
@@ -596,7 +596,7 @@
|
|||||||
"channel": "Canal",
|
"channel": "Canal",
|
||||||
"directions": "Lancez une analyse wifi de cet appareil, ce qui devrait prendre environ 25 secondes.",
|
"directions": "Lancez une analyse wifi de cet appareil, ce qui devrait prendre environ 25 secondes.",
|
||||||
"re_scan": "Nouvelle analyse",
|
"re_scan": "Nouvelle analyse",
|
||||||
"result_directions": "Veuillez cliquer sur le bouton '$t(scan.re_scan)' si vous souhaitez effectuer un scan avec la même configuration que le précédent.",
|
"result_directions": "Vous pouvez cliquer sur le bouton 'Scan' en haut à droite pour $t(scan.re_scan)",
|
||||||
"results": "Résultats de l'analyse Wi-Fi",
|
"results": "Résultats de l'analyse Wi-Fi",
|
||||||
"scan": "Balayage",
|
"scan": "Balayage",
|
||||||
"scanning": "Balayage... ",
|
"scanning": "Balayage... ",
|
||||||
|
|||||||
@@ -596,7 +596,7 @@
|
|||||||
"channel": "Canal",
|
"channel": "Canal",
|
||||||
"directions": "Inicie uma verificação de wi-fi deste dispositivo, o que deve levar aproximadamente 25 segundos.",
|
"directions": "Inicie uma verificação de wi-fi deste dispositivo, o que deve levar aproximadamente 25 segundos.",
|
||||||
"re_scan": "Verificar novamente",
|
"re_scan": "Verificar novamente",
|
||||||
"result_directions": "Clique no botão '$ t (scan.re_scan)' se desejar fazer uma varredura com a mesma configuração da anterior.",
|
"result_directions": "Você pode clicar no botão 'Scan' no canto superior direito para $t(scan.re_scan)",
|
||||||
"results": "Resultados da verificação de Wi-Fi",
|
"results": "Resultados da verificação de Wi-Fi",
|
||||||
"scan": "Varredura",
|
"scan": "Varredura",
|
||||||
"scanning": "Scanning... ",
|
"scanning": "Scanning... ",
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
CModalHeader,
|
CModalHeader,
|
||||||
CModalTitle,
|
CModalTitle,
|
||||||
CModalBody,
|
CModalBody,
|
||||||
CModalFooter,
|
|
||||||
CRow,
|
CRow,
|
||||||
CForm,
|
CForm,
|
||||||
CSwitch,
|
CSwitch,
|
||||||
@@ -14,15 +13,17 @@ import {
|
|||||||
CPopover,
|
CPopover,
|
||||||
} from '@coreui/react';
|
} from '@coreui/react';
|
||||||
import CIcon from '@coreui/icons-react';
|
import CIcon from '@coreui/icons-react';
|
||||||
import { cilX } from '@coreui/icons';
|
import { cilCloudDownload, cilMagnifyingGlass, cilX } from '@coreui/icons';
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useCallback, useState, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import axiosInstance from 'utils/axiosInstance';
|
import axiosInstance from 'utils/axiosInstance';
|
||||||
import eventBus from 'utils/eventBus';
|
import eventBus from 'utils/eventBus';
|
||||||
import { LoadingButton, useAuth, useDevice } from 'ucentral-libs';
|
import { prettyDateForFile } from 'utils/helper';
|
||||||
|
import { useAuth, useDevice } from 'ucentral-libs';
|
||||||
import WifiChannelTable from 'components/WifiScanResultModal/WifiChannelTable';
|
import WifiChannelTable from 'components/WifiScanResultModal/WifiChannelTable';
|
||||||
import 'react-widgets/styles.css';
|
import 'react-widgets/styles.css';
|
||||||
|
import { CSVLink } from 'react-csv';
|
||||||
|
|
||||||
const WifiScanModal = ({ show, toggleModal }) => {
|
const WifiScanModal = ({ show, toggleModal }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -36,6 +37,7 @@ const WifiScanModal = ({ show, toggleModal }) => {
|
|||||||
const [activeScan, setActiveScan] = useState(false);
|
const [activeScan, setActiveScan] = useState(false);
|
||||||
const [hideOptions, setHideOptions] = useState(false);
|
const [hideOptions, setHideOptions] = useState(false);
|
||||||
const [channelList, setChannelList] = useState([]);
|
const [channelList, setChannelList] = useState([]);
|
||||||
|
const [csvData, setCsvData] = useState(null);
|
||||||
|
|
||||||
const toggleDfs = () => {
|
const toggleDfs = () => {
|
||||||
setDfs(!dfs);
|
setDfs(!dfs);
|
||||||
@@ -50,6 +52,7 @@ const WifiScanModal = ({ show, toggleModal }) => {
|
|||||||
setHadFailure(false);
|
setHadFailure(false);
|
||||||
setWaiting(false);
|
setWaiting(false);
|
||||||
setChannelList([]);
|
setChannelList([]);
|
||||||
|
setCsvData(null);
|
||||||
setDfs(true);
|
setDfs(true);
|
||||||
setActiveScan(false);
|
setActiveScan(false);
|
||||||
setHideOptions(false);
|
setHideOptions(false);
|
||||||
@@ -76,7 +79,10 @@ const WifiScanModal = ({ show, toggleModal }) => {
|
|||||||
scanList.forEach((device) => {
|
scanList.forEach((device) => {
|
||||||
if (device.channel === channelNumber) {
|
if (device.channel === channelNumber) {
|
||||||
const deviceToAdd = {};
|
const deviceToAdd = {};
|
||||||
deviceToAdd.SSID = device.ssid ?? 'N/A';
|
if (device.ssid && device.ssid.length > 0) deviceToAdd.SSID = device.ssid;
|
||||||
|
else {
|
||||||
|
deviceToAdd.SSID = device.meshid && device.meshid.length > 0 ? device.meshid : 'N/A';
|
||||||
|
}
|
||||||
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
||||||
channel.devices.push(deviceToAdd);
|
channel.devices.push(deviceToAdd);
|
||||||
}
|
}
|
||||||
@@ -87,6 +93,40 @@ const WifiScanModal = ({ show, toggleModal }) => {
|
|||||||
return finalList;
|
return finalList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getData = useCallback((scanResults) => {
|
||||||
|
if (scanResults === null || scanResults.length === 0) return [];
|
||||||
|
const dbmNumber = 4294967295;
|
||||||
|
const listOfChannels = [];
|
||||||
|
const listCsv = [];
|
||||||
|
|
||||||
|
scanResults.forEach((scan) => {
|
||||||
|
if (!listOfChannels.includes(scan.channel)) {
|
||||||
|
listOfChannels.push(scan.channel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
listOfChannels.forEach((channelNumber) => {
|
||||||
|
const channel = {
|
||||||
|
channel: channelNumber,
|
||||||
|
devices: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
scanResults.forEach((device) => {
|
||||||
|
if (device.channel === channelNumber) {
|
||||||
|
const deviceToAdd = {};
|
||||||
|
if (device.ssid && device.ssid.length > 0) deviceToAdd.SSID = device.ssid;
|
||||||
|
else {
|
||||||
|
deviceToAdd.SSID = device.meshid && device.meshid.length > 0 ? device.meshid : 'N/A';
|
||||||
|
}
|
||||||
|
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
||||||
|
channel.devices.push(deviceToAdd);
|
||||||
|
listCsv.push({ ...deviceToAdd, ...device });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return listCsv;
|
||||||
|
}, []);
|
||||||
|
|
||||||
const doAction = () => {
|
const doAction = () => {
|
||||||
setHadFailure(false);
|
setHadFailure(false);
|
||||||
setHadSuccess(false);
|
setHadSuccess(false);
|
||||||
@@ -113,6 +153,7 @@ const WifiScanModal = ({ show, toggleModal }) => {
|
|||||||
|
|
||||||
if (scanList) {
|
if (scanList) {
|
||||||
setChannelList(parseThroughList(scanList));
|
setChannelList(parseThroughList(scanList));
|
||||||
|
setCsvData(getData(scanList));
|
||||||
setErrorCode(response.data.errorCode ?? 0);
|
setErrorCode(response.data.errorCode ?? 0);
|
||||||
setHideOptions(true);
|
setHideOptions(true);
|
||||||
setHadSuccess(true);
|
setHadSuccess(true);
|
||||||
@@ -134,6 +175,35 @@ const WifiScanModal = ({ show, toggleModal }) => {
|
|||||||
<CModalHeader className="p-1">
|
<CModalHeader className="p-1">
|
||||||
<CModalTitle className="pl-1 pt-1">{t('actions.wifi_scan')}</CModalTitle>
|
<CModalTitle className="pl-1 pt-1">{t('actions.wifi_scan')}</CModalTitle>
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
|
{csvData !== null ? (
|
||||||
|
<CPopover content={t('common.download')}>
|
||||||
|
<CSVLink
|
||||||
|
filename={`wifi_scan_${deviceSerialNumber}_${prettyDateForFile(
|
||||||
|
new Date().getTime() / 1000,
|
||||||
|
)}.csv`}
|
||||||
|
data={csvData}
|
||||||
|
>
|
||||||
|
<CButton color="primary" variant="outline" className="ml-2">
|
||||||
|
<CIcon content={cilCloudDownload} />
|
||||||
|
</CButton>
|
||||||
|
</CSVLink>
|
||||||
|
</CPopover>
|
||||||
|
) : (
|
||||||
|
<CButton color="primary" variant="outline" className="ml-2" disabled>
|
||||||
|
<CIcon content={cilCloudDownload} />
|
||||||
|
</CButton>
|
||||||
|
)}
|
||||||
|
<CPopover content={t('scan.scan')}>
|
||||||
|
<CButton
|
||||||
|
color="primary"
|
||||||
|
variant="outline"
|
||||||
|
className="ml-2"
|
||||||
|
onClick={doAction}
|
||||||
|
disabled={waiting}
|
||||||
|
>
|
||||||
|
<CIcon content={cilMagnifyingGlass} />
|
||||||
|
</CButton>
|
||||||
|
</CPopover>
|
||||||
<CPopover content={t('common.close')}>
|
<CPopover content={t('common.close')}>
|
||||||
<CButton color="primary" variant="outline" className="ml-2" onClick={toggleModal}>
|
<CButton color="primary" variant="outline" className="ml-2" onClick={toggleModal}>
|
||||||
<CIcon content={cilX} />
|
<CIcon content={cilX} />
|
||||||
@@ -205,20 +275,6 @@ const WifiScanModal = ({ show, toggleModal }) => {
|
|||||||
<WifiChannelTable channels={channelList} />
|
<WifiChannelTable channels={channelList} />
|
||||||
</div>
|
</div>
|
||||||
</CModalBody>
|
</CModalBody>
|
||||||
<CModalFooter>
|
|
||||||
<LoadingButton
|
|
||||||
label={!hadSuccess && !hadFailure ? t('scan.scan') : t('scan.re_scan')}
|
|
||||||
isLoadingLabel={t('scan.scanning')}
|
|
||||||
isLoading={waiting}
|
|
||||||
action={doAction}
|
|
||||||
variant="outline"
|
|
||||||
block={false}
|
|
||||||
disabled={waiting}
|
|
||||||
/>
|
|
||||||
<CButton color="secondary" onClick={toggleModal}>
|
|
||||||
{!hadSuccess && !hadFailure ? t('common.cancel') : t('common.exit')}
|
|
||||||
</CButton>
|
|
||||||
</CModalFooter>
|
|
||||||
</CModal>
|
</CModal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ const WifiScanResultModal = ({ show, toggle, scanResults, date }) => {
|
|||||||
const parseThroughList = useCallback(() => {
|
const parseThroughList = useCallback(() => {
|
||||||
const dbmNumber = 4294967295;
|
const dbmNumber = 4294967295;
|
||||||
const listOfChannels = [];
|
const listOfChannels = [];
|
||||||
const listCsv = [];
|
|
||||||
|
|
||||||
scanResults.forEach((scan) => {
|
scanResults.forEach((scan) => {
|
||||||
if (!listOfChannels.includes(scan.channel)) {
|
if (!listOfChannels.includes(scan.channel)) {
|
||||||
@@ -75,7 +74,6 @@ const WifiScanResultModal = ({ show, toggle, scanResults, date }) => {
|
|||||||
}
|
}
|
||||||
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
||||||
channel.devices.push(deviceToAdd);
|
channel.devices.push(deviceToAdd);
|
||||||
listCsv.push({ ...device, ...deviceToAdd });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user