mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-11-01 02:37:45 +00:00
Prettier run on whole solution
This commit is contained in:
@@ -23,8 +23,18 @@ const TheSidebar = () => {
|
|||||||
return (
|
return (
|
||||||
<CSidebar show={show} onShowChange={(val) => dispatch({ type: 'set', sidebarShow: val })}>
|
<CSidebar show={show} onShowChange={(val) => dispatch({ type: 'set', sidebarShow: val })}>
|
||||||
<CSidebarBrand className="d-md-down-none" to="/devices">
|
<CSidebarBrand className="d-md-down-none" to="/devices">
|
||||||
<img className="c-sidebar-brand-full" src={logoBar} style={{ height: '75px'}} alt="OpenWifi" />
|
<img
|
||||||
<img className="c-sidebar-brand-minimized" src={logoBar} style={{ height: '75px', width: '75px' }} alt="OpenWifi" />
|
className="c-sidebar-brand-full"
|
||||||
|
src={logoBar}
|
||||||
|
style={{ height: '75px' }}
|
||||||
|
alt="OpenWifi"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
className="c-sidebar-brand-minimized"
|
||||||
|
src={logoBar}
|
||||||
|
style={{ height: '75px', width: '75px' }}
|
||||||
|
alt="OpenWifi"
|
||||||
|
/>
|
||||||
</CSidebarBrand>
|
</CSidebarBrand>
|
||||||
<CSidebarNav>
|
<CSidebarNav>
|
||||||
<CCreateElement
|
<CCreateElement
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ const DeviceList = () => {
|
|||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const device = response.data.devicesWithStatus[0];
|
const device = response.data.devicesWithStatus[0];
|
||||||
const foundIndex = devices.findIndex(obj => obj.serialNumber === serialNumber);
|
const foundIndex = devices.findIndex((obj) => obj.serialNumber === serialNumber);
|
||||||
const newList = devices;
|
const newList = devices;
|
||||||
newList[foundIndex] = device;
|
newList[foundIndex] = device;
|
||||||
setDevices(newList);
|
setDevices(newList);
|
||||||
@@ -103,7 +103,7 @@ const DeviceList = () => {
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const updateDevicesPerPage = (value) => {
|
const updateDevicesPerPage = (value) => {
|
||||||
setDevicesPerPage(value);
|
setDevicesPerPage(value);
|
||||||
@@ -143,7 +143,14 @@ const DeviceList = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const DeviceListDisplay = ({ devices, loading, updateDevicesPerPage, pageCount, updatePage, refreshDevice }) => {
|
const DeviceListDisplay = ({
|
||||||
|
devices,
|
||||||
|
loading,
|
||||||
|
updateDevicesPerPage,
|
||||||
|
pageCount,
|
||||||
|
updatePage,
|
||||||
|
refreshDevice,
|
||||||
|
}) => {
|
||||||
const columns = [
|
const columns = [
|
||||||
{ key: 'deviceType', label: '', filter: false, sorter: false, _style: { width: '5%' } },
|
{ key: 'deviceType', label: '', filter: false, sorter: false, _style: { width: '5%' } },
|
||||||
{ key: 'verifiedCertificate', label: 'Certificate', _style: { width: '1%' } },
|
{ key: 'verifiedCertificate', label: 'Certificate', _style: { width: '1%' } },
|
||||||
@@ -191,23 +198,35 @@ const DeviceListDisplay = ({ devices, loading, updateDevicesPerPage, pageCount,
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getCertBadge = (cert) => {
|
const getCertBadge = (cert) => {
|
||||||
if(cert === 'NO_CERTIFICATE') {
|
if (cert === 'NO_CERTIFICATE') {
|
||||||
return (
|
return (
|
||||||
<div style={{position: 'relative'}}>
|
<div style={{ position: 'relative' }}>
|
||||||
<CIcon style={{position: 'absolute', left: '31%', marginTop:'8%'}} name="cil-badge" content={cilBadge} size="2xl" alt="AP" />
|
<CIcon
|
||||||
<CIcon style={{position: 'absolute', zIndex: 99, left: '21%', color: '#e55353'}} name="cil-ban" content={cilBan} size="3xl" alt="AP" />
|
style={{ position: 'absolute', left: '31%', marginTop: '8%' }}
|
||||||
|
name="cil-badge"
|
||||||
|
content={cilBadge}
|
||||||
|
size="2xl"
|
||||||
|
alt="AP"
|
||||||
|
/>
|
||||||
|
<CIcon
|
||||||
|
style={{ position: 'absolute', zIndex: 99, left: '21%', color: '#e55353' }}
|
||||||
|
name="cil-ban"
|
||||||
|
content={cilBan}
|
||||||
|
size="3xl"
|
||||||
|
alt="AP"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let color = 'transparent';
|
let color = 'transparent';
|
||||||
switch(cert) {
|
switch (cert) {
|
||||||
case 'VALID_CERTIFICATE':
|
case 'VALID_CERTIFICATE':
|
||||||
color = 'danger'
|
color = 'danger';
|
||||||
break;
|
break;
|
||||||
case 'MISMATCH_SERIAL':
|
case 'MISMATCH_SERIAL':
|
||||||
return (
|
return (
|
||||||
<CBadge color={color} style={{backgroundColor: '#FFFF5C'}}>
|
<CBadge color={color} style={{ backgroundColor: '#FFFF5C' }}>
|
||||||
<CIcon name="cil-badge" content={cilBadge} size="2xl" alt="AP" />
|
<CIcon name="cil-badge" content={cilBadge} size="2xl" alt="AP" />
|
||||||
</CBadge>
|
</CBadge>
|
||||||
);
|
);
|
||||||
@@ -215,10 +234,22 @@ const DeviceListDisplay = ({ devices, loading, updateDevicesPerPage, pageCount,
|
|||||||
color = 'success';
|
color = 'success';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return(
|
return (
|
||||||
<div style={{position: 'relative'}}>
|
<div style={{ position: 'relative' }}>
|
||||||
<CIcon style={{position: 'absolute', left: '31%', marginTop:'8%'}}name="cil-badge" content={cilBadge} size="2xl" alt="AP" />
|
<CIcon
|
||||||
<CIcon style={{position: 'absolute', zIndex: 99, left: '21%', color: '#e55353'}} name="cil-ban" content={cilBan} size="3xl" alt="AP" />
|
style={{ position: 'absolute', left: '31%', marginTop: '8%' }}
|
||||||
|
name="cil-badge"
|
||||||
|
content={cilBadge}
|
||||||
|
size="2xl"
|
||||||
|
alt="AP"
|
||||||
|
/>
|
||||||
|
<CIcon
|
||||||
|
style={{ position: 'absolute', zIndex: 99, left: '21%', color: '#e55353' }}
|
||||||
|
name="cil-ban"
|
||||||
|
content={cilBan}
|
||||||
|
size="3xl"
|
||||||
|
alt="AP"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -227,8 +258,7 @@ const DeviceListDisplay = ({ devices, loading, updateDevicesPerPage, pageCount,
|
|||||||
<CIcon name="cil-badge" content={cilBadge} size="2xl" alt="AP" />
|
<CIcon name="cil-badge" content={cilBadge} size="2xl" alt="AP" />
|
||||||
</CBadge>
|
</CBadge>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
const getStatusBadge = (status) => {
|
const getStatusBadge = (status) => {
|
||||||
if (status) {
|
if (status) {
|
||||||
@@ -286,10 +316,7 @@ const DeviceListDisplay = ({ devices, loading, updateDevicesPerPage, pageCount,
|
|||||||
),
|
),
|
||||||
verifiedCertificate: (item) => (
|
verifiedCertificate: (item) => (
|
||||||
<td style={{ textAlign: 'center' }}>
|
<td style={{ textAlign: 'center' }}>
|
||||||
<CPopover
|
<CPopover content={item.verifiedCertificate ?? 'Unknown'} placement="top">
|
||||||
content={item.verifiedCertificate ?? 'Unknown'}
|
|
||||||
placement="top"
|
|
||||||
>
|
|
||||||
{getCertBadge(item.verifiedCertificate)}
|
{getCertBadge(item.verifiedCertificate)}
|
||||||
</CPopover>
|
</CPopover>
|
||||||
</td>
|
</td>
|
||||||
@@ -319,7 +346,12 @@ const DeviceListDisplay = ({ devices, loading, updateDevicesPerPage, pageCount,
|
|||||||
),
|
),
|
||||||
refresh: (item) => (
|
refresh: (item) => (
|
||||||
<td className="py-2">
|
<td className="py-2">
|
||||||
<CButton onClick={() => refreshDevice(item.serialNumber)} color="primary" variant="outline" size="sm">
|
<CButton
|
||||||
|
onClick={() => refreshDevice(item.serialNumber)}
|
||||||
|
color="primary"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
<CIcon name="cil-sync" content={cilSync} size="sm" />
|
<CIcon name="cil-sync" content={cilSync} size="sm" />
|
||||||
</CButton>
|
</CButton>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -118,12 +118,7 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra
|
|||||||
<h6>{directions}</h6>
|
<h6>{directions}</h6>
|
||||||
<CRow style={{ marginTop: '20px' }}>
|
<CRow style={{ marginTop: '20px' }}>
|
||||||
<CCol>
|
<CCol>
|
||||||
<CButton
|
<CButton onClick={() => doAction(true)} disabled={waiting} block color="primary">
|
||||||
onClick={() => doAction(true)}
|
|
||||||
disabled={waiting}
|
|
||||||
block
|
|
||||||
color="primary"
|
|
||||||
>
|
|
||||||
{waiting && doingNow ? 'Loading...' : 'Do Now!'}
|
{waiting && doingNow ? 'Loading...' : 'Do Now!'}
|
||||||
<CSpinner hidden={!waiting || !doingNow} component="span" size="sm" />
|
<CSpinner hidden={!waiting || !doingNow} component="span" size="sm" />
|
||||||
</CButton>
|
</CButton>
|
||||||
@@ -155,7 +150,7 @@ const ActionModalWidget = ({ show, toggleModal, title, directions, action, extra
|
|||||||
|
|
||||||
<div hidden={!hadSuccess && !hadFailure}>
|
<div hidden={!hadSuccess && !hadFailure}>
|
||||||
<div>
|
<div>
|
||||||
<pre className='ignore'>{responseBody}</pre>
|
<pre className="ignore">{responseBody}</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CModalBody>
|
</CModalBody>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
CForm,
|
CForm,
|
||||||
CFormGroup,
|
CFormGroup,
|
||||||
CInputRadio,
|
CInputRadio,
|
||||||
CLabel
|
CLabel,
|
||||||
} from '@coreui/react';
|
} from '@coreui/react';
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import DatePicker from 'react-widgets/DatePicker';
|
import DatePicker from 'react-widgets/DatePicker';
|
||||||
@@ -21,7 +21,7 @@ import 'react-widgets/styles.css';
|
|||||||
import { getToken } from '../../utils/authHelper';
|
import { getToken } from '../../utils/authHelper';
|
||||||
import axiosInstance from '../../utils/axiosInstance';
|
import axiosInstance from '../../utils/axiosInstance';
|
||||||
|
|
||||||
const BlinkModalWidget = ({show, toggleModal}) => {
|
const BlinkModalWidget = ({ show, toggleModal }) => {
|
||||||
const [hadSuccess, setHadSuccess] = useState(false);
|
const [hadSuccess, setHadSuccess] = useState(false);
|
||||||
const [hadFailure, setHadFailure] = useState(false);
|
const [hadFailure, setHadFailure] = useState(false);
|
||||||
const [doingNow, setDoingNow] = useState(false);
|
const [doingNow, setDoingNow] = useState(false);
|
||||||
@@ -78,7 +78,7 @@ const BlinkModalWidget = ({show, toggleModal}) => {
|
|||||||
serialNumber: selectedDeviceId,
|
serialNumber: selectedDeviceId,
|
||||||
when: isNow ? '' : utcDateString,
|
when: isNow ? '' : utcDateString,
|
||||||
pattern: chosenPattern,
|
pattern: chosenPattern,
|
||||||
duration: 30
|
duration: 30,
|
||||||
};
|
};
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
@@ -112,12 +112,7 @@ const BlinkModalWidget = ({show, toggleModal}) => {
|
|||||||
<h6>When would you like make the LEDs of this device blink?</h6>
|
<h6>When would you like make the LEDs of this device blink?</h6>
|
||||||
<CRow style={{ marginTop: '20px' }}>
|
<CRow style={{ marginTop: '20px' }}>
|
||||||
<CCol>
|
<CCol>
|
||||||
<CButton
|
<CButton onClick={() => doAction(true)} disabled={waiting} block color="primary">
|
||||||
onClick={() => doAction(true)}
|
|
||||||
disabled={waiting}
|
|
||||||
block
|
|
||||||
color="primary"
|
|
||||||
>
|
|
||||||
{waiting && doingNow ? 'Loading...' : 'Do Now!'}
|
{waiting && doingNow ? 'Loading...' : 'Do Now!'}
|
||||||
<CSpinner hidden={!waiting || !doingNow} component="span" size="sm" />
|
<CSpinner hidden={!waiting || !doingNow} component="span" size="sm" />
|
||||||
</CButton>
|
</CButton>
|
||||||
@@ -145,29 +140,48 @@ const BlinkModalWidget = ({show, toggleModal}) => {
|
|||||||
</CCol>
|
</CCol>
|
||||||
</CRow>
|
</CRow>
|
||||||
<CRow style={{ marginTop: '20px' }}>
|
<CRow style={{ marginTop: '20px' }}>
|
||||||
<CCol md="7">
|
<CCol md="7">Choose a pattern you would like to use:</CCol>
|
||||||
Choose a pattern you would like to use:
|
|
||||||
</CCol>
|
|
||||||
<CCol>
|
<CCol>
|
||||||
<CForm>
|
<CForm>
|
||||||
<CFormGroup variant="checkbox" onClick={() => setPattern('on')}>
|
<CFormGroup variant="checkbox" onClick={() => setPattern('on')}>
|
||||||
<CInputRadio defaultChecked={chosenPattern === 'on'} id="radio1" name="radios" value="option1" />
|
<CInputRadio
|
||||||
<CLabel variant="checkbox" htmlFor="radio1">On</CLabel>
|
defaultChecked={chosenPattern === 'on'}
|
||||||
|
id="radio1"
|
||||||
|
name="radios"
|
||||||
|
value="option1"
|
||||||
|
/>
|
||||||
|
<CLabel variant="checkbox" htmlFor="radio1">
|
||||||
|
On
|
||||||
|
</CLabel>
|
||||||
</CFormGroup>
|
</CFormGroup>
|
||||||
<CFormGroup variant="checkbox" onClick={() => setPattern('off')}>
|
<CFormGroup variant="checkbox" onClick={() => setPattern('off')}>
|
||||||
<CInputRadio defaultChecked={chosenPattern === 'off'} id="radio2" name="radios" value="option2" />
|
<CInputRadio
|
||||||
<CLabel variant="checkbox" htmlFor="radio2">Off</CLabel>
|
defaultChecked={chosenPattern === 'off'}
|
||||||
|
id="radio2"
|
||||||
|
name="radios"
|
||||||
|
value="option2"
|
||||||
|
/>
|
||||||
|
<CLabel variant="checkbox" htmlFor="radio2">
|
||||||
|
Off
|
||||||
|
</CLabel>
|
||||||
</CFormGroup>
|
</CFormGroup>
|
||||||
<CFormGroup variant="checkbox" onClick={() => setPattern('blink')}>
|
<CFormGroup variant="checkbox" onClick={() => setPattern('blink')}>
|
||||||
<CInputRadio defaultChecked={chosenPattern === 'blink'} id="radio2" name="radios" value="option2" />
|
<CInputRadio
|
||||||
<CLabel variant="checkbox" htmlFor="radio2">Blink</CLabel>
|
defaultChecked={chosenPattern === 'blink'}
|
||||||
|
id="radio2"
|
||||||
|
name="radios"
|
||||||
|
value="option2"
|
||||||
|
/>
|
||||||
|
<CLabel variant="checkbox" htmlFor="radio2">
|
||||||
|
Blink
|
||||||
|
</CLabel>
|
||||||
</CFormGroup>
|
</CFormGroup>
|
||||||
</CForm>
|
</CForm>
|
||||||
</CCol>
|
</CCol>
|
||||||
</CRow>
|
</CRow>
|
||||||
<div hidden={!hadSuccess && !hadFailure}>
|
<div hidden={!hadSuccess && !hadFailure}>
|
||||||
<div>
|
<div>
|
||||||
<pre className='ignore'>{responseBody}</pre>
|
<pre className="ignore">{responseBody}</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CModalBody>
|
</CModalBody>
|
||||||
@@ -196,6 +210,6 @@ const BlinkModalWidget = ({show, toggleModal}) => {
|
|||||||
</CModalFooter>
|
</CModalFooter>
|
||||||
</CModal>
|
</CModal>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default BlinkModalWidget;
|
export default BlinkModalWidget;
|
||||||
@@ -82,7 +82,7 @@ const DeviceActions = () => {
|
|||||||
actionLabel="reboot"
|
actionLabel="reboot"
|
||||||
action="reboot"
|
action="reboot"
|
||||||
/>
|
/>
|
||||||
<BlinkModalWidget show={showBlinkModal} toggleModal={toggleBlinkModal}/>
|
<BlinkModalWidget show={showBlinkModal} toggleModal={toggleBlinkModal} />
|
||||||
<FirmwareUpgradeModal show={showUpgradeModal} toggleModal={toggleUpgradeModal} />
|
<FirmwareUpgradeModal show={showUpgradeModal} toggleModal={toggleUpgradeModal} />
|
||||||
<TraceModalWidget show={showTraceModal} toggleModal={toggleTraceModal} />
|
<TraceModalWidget show={showTraceModal} toggleModal={toggleTraceModal} />
|
||||||
<WifiScanModalWidget show={showScanModal} toggleModal={toggleScanModal} />
|
<WifiScanModalWidget show={showScanModal} toggleModal={toggleScanModal} />
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import axiosInstance from '../../utils/axiosInstance';
|
|||||||
import { getToken } from '../../utils/authHelper';
|
import { getToken } from '../../utils/authHelper';
|
||||||
import WifiScanResultModalWidget from './WifiScanResultModal';
|
import WifiScanResultModalWidget from './WifiScanResultModal';
|
||||||
|
|
||||||
const DeviceCommands = ({selectedDeviceId}) => {
|
const DeviceCommands = ({ selectedDeviceId }) => {
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
const [chosenWifiScan, setChosenWifiScan] = useState(null);
|
const [chosenWifiScan, setChosenWifiScan] = useState(null);
|
||||||
const [scanDate, setScanDate] = useState('');
|
const [scanDate, setScanDate] = useState('');
|
||||||
@@ -40,11 +40,11 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
|
|
||||||
const modifyStart = (value) => {
|
const modifyStart = (value) => {
|
||||||
setStart(value);
|
setStart(value);
|
||||||
}
|
};
|
||||||
|
|
||||||
const modifyEnd = (value) => {
|
const modifyEnd = (value) => {
|
||||||
setEnd(value);
|
setEnd(value);
|
||||||
}
|
};
|
||||||
|
|
||||||
const getCommands = () => {
|
const getCommands = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -67,15 +67,14 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
setCommands(response.data.commands);
|
setCommands(response.data.commands);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {})
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleDetails = (item, index) => {
|
const toggleDetails = (item, index) => {
|
||||||
if(item.command !== 'wifiscan' || !item.results.status){
|
if (item.command !== 'wifiscan' || !item.results.status) {
|
||||||
const position = details.indexOf(index);
|
const position = details.indexOf(index);
|
||||||
let newDetails = details.slice();
|
let newDetails = details.slice();
|
||||||
|
|
||||||
@@ -85,8 +84,7 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
newDetails = [...details, index];
|
newDetails = [...details, index];
|
||||||
}
|
}
|
||||||
setDetails(newDetails);
|
setDetails(newDetails);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
setChosenWifiScan(item.results.status.scan.scan);
|
setChosenWifiScan(item.results.status.scan.scan);
|
||||||
setScanDate(item.completed);
|
setScanDate(item.completed);
|
||||||
console.log(scanDate);
|
console.log(scanDate);
|
||||||
@@ -96,20 +94,16 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
|
|
||||||
const refreshCommands = () => {
|
const refreshCommands = () => {
|
||||||
setEnd(new Date());
|
setEnd(new Date());
|
||||||
}
|
};
|
||||||
|
|
||||||
const getDetails = (command, commandDetails) => {
|
const getDetails = (command, commandDetails) => {
|
||||||
if (command === 'reboot' || command === 'leds'){
|
if (command === 'reboot' || command === 'leds') {
|
||||||
const result = commandDetails.results;
|
const result = commandDetails.results;
|
||||||
if(result)
|
if (result) return <pre className="ignore">{JSON.stringify(result, null, 4)}</pre>;
|
||||||
return (
|
|
||||||
<pre className='ignore'>{JSON.stringify(result, null, 4)}</pre>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return <pre className='ignore'>{JSON.stringify(commandDetails, null, 4)}</pre>
|
return <pre className="ignore">{JSON.stringify(commandDetails, null, 4)}</pre>;
|
||||||
|
};
|
||||||
}
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ key: 'UUID', label: 'Id' },
|
{ key: 'UUID', label: 'Id' },
|
||||||
{ key: 'command' },
|
{ key: 'command' },
|
||||||
@@ -124,13 +118,13 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectedDeviceId){
|
if (selectedDeviceId) {
|
||||||
getCommands();
|
getCommands();
|
||||||
}
|
}
|
||||||
}, [selectedDeviceId, start, end]);
|
}, [selectedDeviceId, start, end]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectedDeviceId){
|
if (selectedDeviceId) {
|
||||||
setStart(addDays(new Date(), -3).toString());
|
setStart(addDays(new Date(), -3).toString());
|
||||||
setEnd(new Date().toString());
|
setEnd(new Date().toString());
|
||||||
getCommands();
|
getCommands();
|
||||||
@@ -139,16 +133,16 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<CWidgetDropdown
|
<CWidgetDropdown
|
||||||
inverse='true'
|
inverse="true"
|
||||||
color="gradient-primary"
|
color="gradient-primary"
|
||||||
header="Device Commands"
|
header="Device Commands"
|
||||||
footerSlot={
|
footerSlot={
|
||||||
<div style={{ padding: '20px' }}>
|
<div style={{ padding: '20px' }}>
|
||||||
<CCollapse show={collapse}>
|
<CCollapse show={collapse}>
|
||||||
<CRow>
|
<CRow>
|
||||||
<CCol/>
|
<CCol />
|
||||||
<CCol>
|
<CCol>
|
||||||
<div style={{float: 'right'}}>
|
<div style={{ float: 'right' }}>
|
||||||
<CButton onClick={() => refreshCommands()} size="sm">
|
<CButton onClick={() => refreshCommands()} size="sm">
|
||||||
<CIcon
|
<CIcon
|
||||||
name="cil-sync"
|
name="cil-sync"
|
||||||
@@ -190,12 +184,18 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
border
|
border
|
||||||
sorterValue={{ column: 'completed', desc: 'true' }}
|
sorterValue={{ column: 'completed', desc: 'true' }}
|
||||||
scopedSlots={{
|
scopedSlots={{
|
||||||
completed: (item) => <td>{(item.completed && item.completed !== "") ? prettyDate(item.completed) : 'Pending'}</td>,
|
completed: (item) => (
|
||||||
|
<td>
|
||||||
|
{item.completed && item.completed !== ''
|
||||||
|
? prettyDate(item.completed)
|
||||||
|
: 'Pending'}
|
||||||
|
</td>
|
||||||
|
),
|
||||||
show_details: (item, index) => (
|
show_details: (item, index) => (
|
||||||
<td className="py-2">
|
<td className="py-2">
|
||||||
<CButton
|
<CButton
|
||||||
color="primary"
|
color="primary"
|
||||||
variant={details.includes(index) ? "" : "outline"}
|
variant={details.includes(index) ? '' : 'outline'}
|
||||||
shape="square"
|
shape="square"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -210,9 +210,7 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
<CCollapse show={details.includes(index)}>
|
<CCollapse show={details.includes(index)}>
|
||||||
<CCardBody>
|
<CCardBody>
|
||||||
<h5>Details</h5>
|
<h5>Details</h5>
|
||||||
<div>
|
<div>{getDetails(item.command, item)}</div>
|
||||||
{getDetails(item.command, item)}
|
|
||||||
</div>
|
|
||||||
</CCardBody>
|
</CCardBody>
|
||||||
</CCollapse>
|
</CCollapse>
|
||||||
),
|
),
|
||||||
@@ -231,7 +229,12 @@ const DeviceCommands = ({selectedDeviceId}) => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<WifiScanResultModalWidget show={showModal} toggle={toggleModal} scanResults={chosenWifiScan} date={scanDate}/>
|
<WifiScanResultModalWidget
|
||||||
|
show={showModal}
|
||||||
|
toggle={toggleModal}
|
||||||
|
scanResults={chosenWifiScan}
|
||||||
|
date={scanDate}
|
||||||
|
/>
|
||||||
<CIcon name="cilNotes" style={{ color: 'white' }} size="lg" />
|
<CIcon name="cilNotes" style={{ color: 'white' }} size="lg" />
|
||||||
</CWidgetDropdown>
|
</CWidgetDropdown>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { cleanTimestamp } from '../../utils/helper';
|
|||||||
import axiosInstance from '../../utils/axiosInstance';
|
import axiosInstance from '../../utils/axiosInstance';
|
||||||
import { getToken } from '../../utils/authHelper';
|
import { getToken } from '../../utils/authHelper';
|
||||||
|
|
||||||
const DeviceConfiguration = ({selectedDeviceId}) => {
|
const DeviceConfiguration = ({ selectedDeviceId }) => {
|
||||||
const [collapse, setCollapse] = useState(false);
|
const [collapse, setCollapse] = useState(false);
|
||||||
const [device, setDevice] = useState(null);
|
const [device, setDevice] = useState(null);
|
||||||
|
|
||||||
@@ -39,13 +39,11 @@ const DeviceConfiguration = ({selectedDeviceId}) => {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
setDevice(response.data);
|
setDevice(response.data);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectedDeviceId)
|
if (selectedDeviceId) getDevice();
|
||||||
getDevice();
|
|
||||||
}, [selectedDeviceId]);
|
}, [selectedDeviceId]);
|
||||||
|
|
||||||
if (device) {
|
if (device) {
|
||||||
@@ -145,7 +143,12 @@ const DeviceConfiguration = ({selectedDeviceId}) => {
|
|||||||
</CFormGroup>
|
</CFormGroup>
|
||||||
</CCollapse>
|
</CCollapse>
|
||||||
<CCardFooter>
|
<CCardFooter>
|
||||||
<CButton show={collapse ? 'true' : 'false'} color="transparent" onClick={toggle} block>
|
<CButton
|
||||||
|
show={collapse ? 'true' : 'false'}
|
||||||
|
color="transparent"
|
||||||
|
onClick={toggle}
|
||||||
|
block
|
||||||
|
>
|
||||||
<CIcon name={collapse ? 'cilChevronTop' : 'cilChevronBottom'} size="lg" />
|
<CIcon name={collapse ? 'cilChevronTop' : 'cilChevronBottom'} size="lg" />
|
||||||
</CButton>
|
</CButton>
|
||||||
</CCardFooter>
|
</CCardFooter>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
CCardBody,
|
CCardBody,
|
||||||
CRow,
|
CRow,
|
||||||
CCol,
|
CCol,
|
||||||
CProgress
|
CProgress,
|
||||||
} from '@coreui/react';
|
} from '@coreui/react';
|
||||||
import CIcon from '@coreui/icons-react';
|
import CIcon from '@coreui/icons-react';
|
||||||
import DatePicker from 'react-widgets/DatePicker';
|
import DatePicker from 'react-widgets/DatePicker';
|
||||||
@@ -17,7 +17,7 @@ import { prettyDate, addDays } from '../../utils/helper';
|
|||||||
import axiosInstance from '../../utils/axiosInstance';
|
import axiosInstance from '../../utils/axiosInstance';
|
||||||
import { getToken } from '../../utils/authHelper';
|
import { getToken } from '../../utils/authHelper';
|
||||||
|
|
||||||
const DeviceHealth = ({selectedDeviceId}) => {
|
const DeviceHealth = ({ selectedDeviceId }) => {
|
||||||
const [collapse, setCollapse] = useState(false);
|
const [collapse, setCollapse] = useState(false);
|
||||||
const [details, setDetails] = useState([]);
|
const [details, setDetails] = useState([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -34,11 +34,11 @@ const DeviceHealth = ({selectedDeviceId}) => {
|
|||||||
|
|
||||||
const modifyStart = (value) => {
|
const modifyStart = (value) => {
|
||||||
setStart(value);
|
setStart(value);
|
||||||
}
|
};
|
||||||
|
|
||||||
const modifyEnd = (value) => {
|
const modifyEnd = (value) => {
|
||||||
setEnd(value);
|
setEnd(value);
|
||||||
}
|
};
|
||||||
|
|
||||||
const getDeviceHealth = () => {
|
const getDeviceHealth = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -61,8 +61,7 @@ const DeviceHealth = ({selectedDeviceId}) => {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
setHealthChecks(response.data.values);
|
setHealthChecks(response.data.values);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {})
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
@@ -95,19 +94,17 @@ const DeviceHealth = ({selectedDeviceId}) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectedDeviceId){
|
if (selectedDeviceId) {
|
||||||
getDeviceHealth();
|
getDeviceHealth();
|
||||||
}
|
}
|
||||||
}, [selectedDeviceId, start, end]);
|
}, [selectedDeviceId, start, end]);
|
||||||
|
|
||||||
|
|
||||||
if (healthChecks && healthChecks.length > 0) {
|
if (healthChecks && healthChecks.length > 0) {
|
||||||
sanityLevel = healthChecks[healthChecks.length-1].sanity;
|
sanityLevel = healthChecks[healthChecks.length - 1].sanity;
|
||||||
if (sanityLevel === 100) barColor = 'gradient-success';
|
if (sanityLevel === 100) barColor = 'gradient-success';
|
||||||
else if (sanityLevel >= 90) barColor = 'gradient-warning';
|
else if (sanityLevel >= 90) barColor = 'gradient-warning';
|
||||||
else barColor = 'gradient-danger';
|
else barColor = 'gradient-danger';
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
sanityLevel = 0;
|
sanityLevel = 0;
|
||||||
barColor = 'gradient-dark';
|
barColor = 'gradient-dark';
|
||||||
}
|
}
|
||||||
@@ -121,7 +118,7 @@ const DeviceHealth = ({selectedDeviceId}) => {
|
|||||||
inverse="true"
|
inverse="true"
|
||||||
footerSlot={
|
footerSlot={
|
||||||
<div style={{ padding: '20px' }}>
|
<div style={{ padding: '20px' }}>
|
||||||
<CProgress style={{marginBottom: '20px'}} color="white" value={sanityLevel ?? 0} />
|
<CProgress style={{ marginBottom: '20px' }} color="white" value={sanityLevel ?? 0} />
|
||||||
<CCollapse show={collapse}>
|
<CCollapse show={collapse}>
|
||||||
<CRow style={{ marginBottom: '10px' }}>
|
<CRow style={{ marginBottom: '10px' }}>
|
||||||
<CCol>
|
<CCol>
|
||||||
@@ -163,7 +160,7 @@ const DeviceHealth = ({selectedDeviceId}) => {
|
|||||||
<td className="py-2">
|
<td className="py-2">
|
||||||
<CButton
|
<CButton
|
||||||
color="primary"
|
color="primary"
|
||||||
variant={details.includes(index) ? "" : "outline"}
|
variant={details.includes(index) ? '' : 'outline'}
|
||||||
shape="square"
|
shape="square"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -180,7 +177,7 @@ const DeviceHealth = ({selectedDeviceId}) => {
|
|||||||
<CCardBody>
|
<CCardBody>
|
||||||
<h5>Details</h5>
|
<h5>Details</h5>
|
||||||
<div>
|
<div>
|
||||||
<pre className='ignore'>{JSON.stringify(item.values, null, 4)}</pre>
|
<pre className="ignore">{JSON.stringify(item.values, null, 4)}</pre>
|
||||||
</div>
|
</div>
|
||||||
</CCardBody>
|
</CCardBody>
|
||||||
</CCollapse>
|
</CCollapse>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { addDays, prettyDate } from '../../utils/helper';
|
|||||||
import axiosInstance from '../../utils/axiosInstance';
|
import axiosInstance from '../../utils/axiosInstance';
|
||||||
import { getToken } from '../../utils/authHelper';
|
import { getToken } from '../../utils/authHelper';
|
||||||
|
|
||||||
const DeviceLogs = ({selectedDeviceId}) => {
|
const DeviceLogs = ({ selectedDeviceId }) => {
|
||||||
const [collapse, setCollapse] = useState(false);
|
const [collapse, setCollapse] = useState(false);
|
||||||
const [details, setDetails] = useState([]);
|
const [details, setDetails] = useState([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -31,11 +31,11 @@ const DeviceLogs = ({selectedDeviceId}) => {
|
|||||||
|
|
||||||
const modifyStart = (value) => {
|
const modifyStart = (value) => {
|
||||||
setStart(value);
|
setStart(value);
|
||||||
}
|
};
|
||||||
|
|
||||||
const modifyEnd = (value) => {
|
const modifyEnd = (value) => {
|
||||||
setEnd(value);
|
setEnd(value);
|
||||||
}
|
};
|
||||||
|
|
||||||
const getLogs = () => {
|
const getLogs = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -58,8 +58,7 @@ const DeviceLogs = ({selectedDeviceId}) => {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
setLogs(response.data.values);
|
setLogs(response.data.values);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {})
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
@@ -91,14 +90,14 @@ const DeviceLogs = ({selectedDeviceId}) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectedDeviceId){
|
if (selectedDeviceId) {
|
||||||
getLogs();
|
getLogs();
|
||||||
}
|
}
|
||||||
}, [start, end, selectedDeviceId]);
|
}, [start, end, selectedDeviceId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CWidgetDropdown
|
<CWidgetDropdown
|
||||||
inverse='true'
|
inverse="true"
|
||||||
color="gradient-info"
|
color="gradient-info"
|
||||||
header="Device Logs"
|
header="Device Logs"
|
||||||
footerSlot={
|
footerSlot={
|
||||||
@@ -139,7 +138,7 @@ const DeviceLogs = ({selectedDeviceId}) => {
|
|||||||
<td className="py-2">
|
<td className="py-2">
|
||||||
<CButton
|
<CButton
|
||||||
color="primary"
|
color="primary"
|
||||||
variant={details.includes(index) ? "" : "outline"}
|
variant={details.includes(index) ? '' : 'outline'}
|
||||||
shape="square"
|
shape="square"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -155,7 +154,7 @@ const DeviceLogs = ({selectedDeviceId}) => {
|
|||||||
<CCardBody>
|
<CCardBody>
|
||||||
<h5>Details</h5>
|
<h5>Details</h5>
|
||||||
<div>
|
<div>
|
||||||
<pre className='ignore'>{JSON.stringify(item, null, 4)}</pre>
|
<pre className="ignore">{JSON.stringify(item, null, 4)}</pre>
|
||||||
</div>
|
</div>
|
||||||
</CCardBody>
|
</CCardBody>
|
||||||
</CCollapse>
|
</CCollapse>
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ const DevicePage = () => {
|
|||||||
const { deviceId } = useParams();
|
const { deviceId } = useParams();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(deviceId)
|
if (deviceId) dispatch({ type: 'set', selectedDeviceId: deviceId });
|
||||||
dispatch({ type: 'set', selectedDeviceId: deviceId });
|
|
||||||
}, [deviceId]);
|
}, [deviceId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -23,13 +22,13 @@ const DevicePage = () => {
|
|||||||
<div className="App">
|
<div className="App">
|
||||||
<CRow>
|
<CRow>
|
||||||
<CCol xs="12" sm="6">
|
<CCol xs="12" sm="6">
|
||||||
<DeviceConfiguration selectedDeviceId = {deviceId} />
|
<DeviceConfiguration selectedDeviceId={deviceId} />
|
||||||
<DeviceCommands selectedDeviceId = {deviceId} />
|
<DeviceCommands selectedDeviceId={deviceId} />
|
||||||
</CCol>
|
</CCol>
|
||||||
<CCol xs="12" sm="6">
|
<CCol xs="12" sm="6">
|
||||||
<DeviceLogs selectedDeviceId = {deviceId} />
|
<DeviceLogs selectedDeviceId={deviceId} />
|
||||||
<DeviceHealth selectedDeviceId = {deviceId} />
|
<DeviceHealth selectedDeviceId={deviceId} />
|
||||||
<DeviceActions selectedDeviceId = {deviceId} />
|
<DeviceActions selectedDeviceId={deviceId} />
|
||||||
</CCol>
|
</CCol>
|
||||||
</CRow>
|
</CRow>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => {
|
|||||||
|
|
||||||
const confirmingIfNow = () => {
|
const confirmingIfNow = () => {
|
||||||
setCheckingIfNow(true);
|
setCheckingIfNow(true);
|
||||||
}
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setHadSuccess(false);
|
setHadSuccess(false);
|
||||||
@@ -139,7 +139,7 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => {
|
|||||||
<CCol>
|
<CCol>
|
||||||
<CButton
|
<CButton
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={() => formValidation() ? confirmingIfNow() : null}
|
onClick={() => (formValidation() ? confirmingIfNow() : null)}
|
||||||
disabled={waiting}
|
disabled={waiting}
|
||||||
hidden={checkingIfNow}
|
hidden={checkingIfNow}
|
||||||
block
|
block
|
||||||
@@ -148,7 +148,7 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => {
|
|||||||
</CButton>
|
</CButton>
|
||||||
<CButton
|
<CButton
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={() => formValidation() ? postUpgrade(true) : null}
|
onClick={() => (formValidation() ? postUpgrade(true) : null)}
|
||||||
disabled={waiting}
|
disabled={waiting}
|
||||||
hidden={!checkingIfNow}
|
hidden={!checkingIfNow}
|
||||||
block
|
block
|
||||||
@@ -196,7 +196,7 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => {
|
|||||||
<CInvalidFeedback>You need a url...</CInvalidFeedback>
|
<CInvalidFeedback>You need a url...</CInvalidFeedback>
|
||||||
<div hidden={!hadSuccess && !hadFailure}>
|
<div hidden={!hadSuccess && !hadFailure}>
|
||||||
<div>
|
<div>
|
||||||
<pre className='ignore'>{responseBody}</pre>
|
<pre className="ignore">{responseBody}</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CModalBody>
|
</CModalBody>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
CCol,
|
CCol,
|
||||||
CRow,
|
CRow,
|
||||||
CInvalidFeedback,
|
CInvalidFeedback,
|
||||||
CSelect
|
CSelect,
|
||||||
} from '@coreui/react';
|
} from '@coreui/react';
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import DatePicker from 'react-widgets/DatePicker';
|
import DatePicker from 'react-widgets/DatePicker';
|
||||||
@@ -63,7 +63,7 @@ const TraceModalWidget = ({ show, toggleModal }) => {
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
let utcDateString = dateChosen.toISOString();
|
let utcDateString = dateChosen.toISOString();
|
||||||
|
|
||||||
if(dateChosen <= now){
|
if (dateChosen <= now) {
|
||||||
const newDate = new Date();
|
const newDate = new Date();
|
||||||
newDate.setSeconds(newDate.getSeconds() + 60);
|
newDate.setSeconds(newDate.getSeconds() + 60);
|
||||||
utcDateString = newDate.toISOString();
|
utcDateString = newDate.toISOString();
|
||||||
@@ -72,7 +72,7 @@ const TraceModalWidget = ({ show, toggleModal }) => {
|
|||||||
const parameters = {
|
const parameters = {
|
||||||
serialNumber: selectedDeviceId,
|
serialNumber: selectedDeviceId,
|
||||||
when: dateChosen <= now ? '' : utcDateString,
|
when: dateChosen <= now ? '' : utcDateString,
|
||||||
network: 'lan'
|
network: 'lan',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (usingDuration) {
|
if (usingDuration) {
|
||||||
@@ -140,17 +140,33 @@ const TraceModalWidget = ({ show, toggleModal }) => {
|
|||||||
<CCol xs="12" md="8">
|
<CCol xs="12" md="8">
|
||||||
{usingDuration ? (
|
{usingDuration ? (
|
||||||
<CSelect defaultValue="duration" disabled={waiting}>
|
<CSelect defaultValue="duration" disabled={waiting}>
|
||||||
<option value="20" onClick={() => setDuration(20)}>20s</option>
|
<option value="20" onClick={() => setDuration(20)}>
|
||||||
<option value="40" onClick={() => setDuration(40)}>40s</option>
|
20s
|
||||||
<option value="60" onClick={() => setDuration(60)}>60s</option>
|
</option>
|
||||||
<option value="120" onClick={() => setDuration(120)}>120s</option>
|
<option value="40" onClick={() => setDuration(40)}>
|
||||||
|
40s
|
||||||
|
</option>
|
||||||
|
<option value="60" onClick={() => setDuration(60)}>
|
||||||
|
60s
|
||||||
|
</option>
|
||||||
|
<option value="120" onClick={() => setDuration(120)}>
|
||||||
|
120s
|
||||||
|
</option>
|
||||||
</CSelect>
|
</CSelect>
|
||||||
) : (
|
) : (
|
||||||
<CSelect defaultValue={packets} disabled={waiting}>
|
<CSelect defaultValue={packets} disabled={waiting}>
|
||||||
<option value="100" onClick={() => setPackets(100)}>100</option>
|
<option value="100" onClick={() => setPackets(100)}>
|
||||||
<option value="250" onClick={() => setPackets(250)}>250</option>
|
100
|
||||||
<option value="500" onClick={() => setPackets(500)}>500</option>
|
</option>
|
||||||
<option value="1000" onClick={() => setPackets(1000)}>1000</option>
|
<option value="250" onClick={() => setPackets(250)}>
|
||||||
|
250
|
||||||
|
</option>
|
||||||
|
<option value="500" onClick={() => setPackets(500)}>
|
||||||
|
500
|
||||||
|
</option>
|
||||||
|
<option value="1000" onClick={() => setPackets(1000)}>
|
||||||
|
1000
|
||||||
|
</option>
|
||||||
</CSelect>
|
</CSelect>
|
||||||
)}
|
)}
|
||||||
</CCol>
|
</CCol>
|
||||||
@@ -175,7 +191,7 @@ const TraceModalWidget = ({ show, toggleModal }) => {
|
|||||||
|
|
||||||
<div hidden={!hadSuccess && !hadFailure}>
|
<div hidden={!hadSuccess && !hadFailure}>
|
||||||
<div>
|
<div>
|
||||||
<pre className='ignore'>{responseBody} </pre>
|
<pre className="ignore">{responseBody} </pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CModalBody>
|
</CModalBody>
|
||||||
|
|||||||
@@ -1,37 +1,22 @@
|
|||||||
import {
|
import { CCard, CCardTitle, CCardBody, CDataTable, CCardHeader } from '@coreui/react';
|
||||||
CCard,
|
|
||||||
CCardTitle,
|
|
||||||
CCardBody,
|
|
||||||
CDataTable,
|
|
||||||
CCardHeader
|
|
||||||
} from '@coreui/react';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import 'react-widgets/styles.css';
|
import 'react-widgets/styles.css';
|
||||||
|
|
||||||
const WifiChannelCard = ({ channel }) => {
|
const WifiChannelCard = ({ channel }) => {
|
||||||
const columns = [
|
const columns = [{ key: 'SSID', _style: { width: '70%' } }, { key: 'Signal' }];
|
||||||
{ key: 'SSID', _style: { width: '70%' }},
|
|
||||||
{ key: 'Signal' },
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CCard>
|
<CCard>
|
||||||
<CCardHeader>
|
<CCardHeader>
|
||||||
<CCardTitle style={{color:'black'}}>
|
<CCardTitle style={{ color: 'black' }}>Channel #{channel.channel}</CCardTitle>
|
||||||
Channel #{channel.channel}
|
|
||||||
</CCardTitle>
|
|
||||||
</CCardHeader>
|
</CCardHeader>
|
||||||
<CCardBody>
|
<CCardBody>
|
||||||
<div className="overflow-auto" style={{ height: '250px' }}>
|
<div className="overflow-auto" style={{ height: '250px' }}>
|
||||||
<CDataTable
|
<CDataTable items={channel.devices} fields={columns} style={{ color: 'white' }} />
|
||||||
items={channel.devices}
|
|
||||||
fields={columns}
|
|
||||||
style={{ color: 'white' }}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</CCardBody>
|
</CCardBody>
|
||||||
</CCard>
|
</CCard>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default WifiChannelCard;
|
export default WifiChannelCard;
|
||||||
@@ -1,41 +1,33 @@
|
|||||||
import {
|
import { CCol, CRow } from '@coreui/react';
|
||||||
CCol,
|
|
||||||
CRow
|
|
||||||
} from '@coreui/react';
|
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { v4 as createUuid } from 'uuid';
|
import { v4 as createUuid } from 'uuid';
|
||||||
import WifiChannelCard from './WifiChannelCard';
|
import WifiChannelCard from './WifiChannelCard';
|
||||||
|
|
||||||
const WifiChannelTable = ({channels}) => {
|
const WifiChannelTable = ({ channels }) => {
|
||||||
const sortChannels = () => {
|
const sortChannels = () => {
|
||||||
channels.sort((a, b) => (a.channel > b.channel) ? 1 : -1);
|
channels.sort((a, b) => (a.channel > b.channel ? 1 : -1));
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (channels)
|
if (channels) sortChannels();
|
||||||
sortChannels();
|
|
||||||
}, [channels]);
|
}, [channels]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CRow>
|
<CRow>
|
||||||
<CCol>
|
<CCol>
|
||||||
{
|
{channels.map((channel, index) => {
|
||||||
channels.map((channel, index) => {
|
if (index % 2 === 0) return <WifiChannelCard key={createUuid()} channel={channel} />;
|
||||||
if(index % 2 === 0) return <WifiChannelCard key={createUuid()} channel={channel}/>;
|
return <div key={createUuid()} />;
|
||||||
return <div key={createUuid()}/>
|
})}
|
||||||
})
|
|
||||||
}
|
|
||||||
</CCol>
|
</CCol>
|
||||||
<CCol>
|
<CCol>
|
||||||
{
|
{channels.map((channel, index) => {
|
||||||
channels.map((channel, index) => {
|
if (index % 2 === 1) return <WifiChannelCard key={createUuid()} channel={channel} />;
|
||||||
if(index % 2 === 1) return <WifiChannelCard key={createUuid()} channel={channel}/>;
|
return <div key={createUuid()} />;
|
||||||
return <div key={createUuid()}/>
|
})}
|
||||||
})
|
|
||||||
}
|
|
||||||
</CCol>
|
</CCol>
|
||||||
</CRow>
|
</CRow>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default WifiChannelTable;
|
export default WifiChannelTable;
|
||||||
@@ -10,16 +10,16 @@ import {
|
|||||||
CFormGroup,
|
CFormGroup,
|
||||||
CInputRadio,
|
CInputRadio,
|
||||||
CLabel,
|
CLabel,
|
||||||
CForm
|
CForm,
|
||||||
} from '@coreui/react';
|
} from '@coreui/react';
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import WifiChannelTable from './WifiChannelTable';
|
import WifiChannelTable from './WifiChannelTable';
|
||||||
import 'react-widgets/styles.css';
|
import 'react-widgets/styles.css';
|
||||||
import { getToken } from '../../utils/authHelper';
|
import { getToken } from '../../utils/authHelper';
|
||||||
import axiosInstance from '../../utils/axiosInstance';
|
import axiosInstance from '../../utils/axiosInstance';
|
||||||
|
|
||||||
const WifiScanModalWidget = ({ show, toggleModal }) => {
|
const WifiScanModalWidget = ({ show, toggleModal }) => {
|
||||||
const [hadSuccess, setHadSuccess] = useState(false);
|
const [hadSuccess, setHadSuccess] = useState(false);
|
||||||
const [hadFailure, setHadFailure] = useState(false);
|
const [hadFailure, setHadFailure] = useState(false);
|
||||||
const [waiting, setWaiting] = useState(false);
|
const [waiting, setWaiting] = useState(false);
|
||||||
@@ -46,7 +46,7 @@ import {
|
|||||||
const listOfChannels = [];
|
const listOfChannels = [];
|
||||||
|
|
||||||
scanList.forEach((scan) => {
|
scanList.forEach((scan) => {
|
||||||
if(!listOfChannels.includes(scan.channel)){
|
if (!listOfChannels.includes(scan.channel)) {
|
||||||
listOfChannels.push(scan.channel);
|
listOfChannels.push(scan.channel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -55,11 +55,11 @@ import {
|
|||||||
listOfChannels.forEach((channelNumber) => {
|
listOfChannels.forEach((channelNumber) => {
|
||||||
const channel = {
|
const channel = {
|
||||||
channel: channelNumber,
|
channel: channelNumber,
|
||||||
devices: []
|
devices: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
scanList.forEach((device) => {
|
scanList.forEach((device) => {
|
||||||
if(device.channel === channelNumber){
|
if (device.channel === channelNumber) {
|
||||||
const deviceToAdd = {};
|
const deviceToAdd = {};
|
||||||
deviceToAdd.SSID = device.ssid ?? 'N/A';
|
deviceToAdd.SSID = device.ssid ?? 'N/A';
|
||||||
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
||||||
@@ -70,7 +70,7 @@ import {
|
|||||||
finalList.push(channel);
|
finalList.push(channel);
|
||||||
});
|
});
|
||||||
return finalList;
|
return finalList;
|
||||||
}
|
};
|
||||||
|
|
||||||
const doAction = () => {
|
const doAction = () => {
|
||||||
setHadFailure(false);
|
setHadFailure(false);
|
||||||
@@ -81,7 +81,7 @@ import {
|
|||||||
|
|
||||||
const parameters = {
|
const parameters = {
|
||||||
serialNumber: selectedDeviceId,
|
serialNumber: selectedDeviceId,
|
||||||
verbose: choseVerbose
|
verbose: choseVerbose,
|
||||||
};
|
};
|
||||||
const headers = {
|
const headers = {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
@@ -93,14 +93,12 @@ import {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
const scanList = response.data.results.status.scan.scan;
|
const scanList = response.data.results.status.scan.scan;
|
||||||
|
|
||||||
if(scanList){
|
if (scanList) {
|
||||||
setChannelList(parseThroughList(scanList));
|
setChannelList(parseThroughList(scanList));
|
||||||
setHadSuccess(true);
|
setHadSuccess(true);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
setHadFailure(true);
|
setHadFailure(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setHadFailure(true);
|
setHadFailure(true);
|
||||||
@@ -117,29 +115,41 @@ import {
|
|||||||
<CModalTitle>Wifi Scan</CModalTitle>
|
<CModalTitle>Wifi Scan</CModalTitle>
|
||||||
</CModalHeader>
|
</CModalHeader>
|
||||||
<CModalBody>
|
<CModalBody>
|
||||||
<h6>
|
<h6>Launch a wifi scan of this device, which should take approximately 25 seconds.</h6>
|
||||||
Launch a wifi scan of this device, which should take approximately 25 seconds.
|
|
||||||
</h6>
|
|
||||||
<CRow style={{ marginTop: '20px' }}>
|
<CRow style={{ marginTop: '20px' }}>
|
||||||
<CForm style={{paddingLeft: '5%'}}>
|
<CForm style={{ paddingLeft: '5%' }}>
|
||||||
<CFormGroup variant="checkbox" onClick={() => setVerbose(true)}>
|
<CFormGroup variant="checkbox" onClick={() => setVerbose(true)}>
|
||||||
<CInputRadio defaultChecked={choseVerbose} id="radio1" name="radios" value="option1" />
|
<CInputRadio
|
||||||
<CLabel variant="checkbox" htmlFor="radio1">With verbose</CLabel>
|
defaultChecked={choseVerbose}
|
||||||
|
id="radio1"
|
||||||
|
name="radios"
|
||||||
|
value="option1"
|
||||||
|
/>
|
||||||
|
<CLabel variant="checkbox" htmlFor="radio1">
|
||||||
|
With verbose
|
||||||
|
</CLabel>
|
||||||
</CFormGroup>
|
</CFormGroup>
|
||||||
<CFormGroup variant="checkbox" onClick={() => setVerbose(false)}>
|
<CFormGroup variant="checkbox" onClick={() => setVerbose(false)}>
|
||||||
<CInputRadio defaultChecked={!choseVerbose} id="radio2" name="radios" value="option2" />
|
<CInputRadio
|
||||||
<CLabel variant="checkbox" htmlFor="radio2">Without verbose</CLabel>
|
defaultChecked={!choseVerbose}
|
||||||
|
id="radio2"
|
||||||
|
name="radios"
|
||||||
|
value="option2"
|
||||||
|
/>
|
||||||
|
<CLabel variant="checkbox" htmlFor="radio2">
|
||||||
|
Without verbose
|
||||||
|
</CLabel>
|
||||||
</CFormGroup>
|
</CFormGroup>
|
||||||
</CForm>
|
</CForm>
|
||||||
</CRow>
|
</CRow>
|
||||||
<div style={{marginTop: '3%'}} hidden={!hadSuccess && !hadFailure}>
|
<div style={{ marginTop: '3%' }} hidden={!hadSuccess && !hadFailure}>
|
||||||
<WifiChannelTable channels={channelList}/>
|
<WifiChannelTable channels={channelList} />
|
||||||
</div>
|
</div>
|
||||||
</CModalBody>
|
</CModalBody>
|
||||||
<CModalFooter>
|
<CModalFooter>
|
||||||
<div hidden={!checkingIfSure}>Are you sure?</div>
|
<div hidden={!checkingIfSure}>Are you sure?</div>
|
||||||
<CButton hidden={checkingIfSure} color="primary" onClick={() => confirmingIfSure()}>
|
<CButton hidden={checkingIfSure} color="primary" onClick={() => confirmingIfSure()}>
|
||||||
{(hadSuccess || hadFailure) ? 'Re-Scan' : 'Scan'}
|
{hadSuccess || hadFailure ? 'Re-Scan' : 'Scan'}
|
||||||
</CButton>
|
</CButton>
|
||||||
<CButton
|
<CButton
|
||||||
hidden={!checkingIfSure}
|
hidden={!checkingIfSure}
|
||||||
@@ -156,7 +166,6 @@ import {
|
|||||||
</CModalFooter>
|
</CModalFooter>
|
||||||
</CModal>
|
</CModal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default WifiScanModalWidget;
|
|
||||||
|
|
||||||
|
export default WifiScanModalWidget;
|
||||||
|
|||||||
@@ -6,18 +6,18 @@ import {
|
|||||||
CModalHeader,
|
CModalHeader,
|
||||||
CModalBody,
|
CModalBody,
|
||||||
CModalTitle,
|
CModalTitle,
|
||||||
CModalFooter
|
CModalFooter,
|
||||||
} from '@coreui/react';
|
} from '@coreui/react';
|
||||||
import WifiChannelTable from './WifiChannelTable';
|
import WifiChannelTable from './WifiChannelTable';
|
||||||
import { prettyDate } from '../../utils/helper';
|
import { prettyDate } from '../../utils/helper';
|
||||||
|
|
||||||
const WifiScanResultModalWidget = ({show, toggle, scanResults, date}) => {
|
const WifiScanResultModalWidget = ({ show, toggle, scanResults, date }) => {
|
||||||
const parseThroughList = (scanList) => {
|
const parseThroughList = (scanList) => {
|
||||||
const dbmNumber = 4294967295;
|
const dbmNumber = 4294967295;
|
||||||
const listOfChannels = [];
|
const listOfChannels = [];
|
||||||
|
|
||||||
scanList.forEach((scan) => {
|
scanList.forEach((scan) => {
|
||||||
if(!listOfChannels.includes(scan.channel)){
|
if (!listOfChannels.includes(scan.channel)) {
|
||||||
listOfChannels.push(scan.channel);
|
listOfChannels.push(scan.channel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -26,11 +26,11 @@ const WifiScanResultModalWidget = ({show, toggle, scanResults, date}) => {
|
|||||||
listOfChannels.forEach((channelNumber) => {
|
listOfChannels.forEach((channelNumber) => {
|
||||||
const channel = {
|
const channel = {
|
||||||
channel: channelNumber,
|
channel: channelNumber,
|
||||||
devices: []
|
devices: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
scanList.forEach((device) => {
|
scanList.forEach((device) => {
|
||||||
if(device.channel === channelNumber){
|
if (device.channel === channelNumber) {
|
||||||
const deviceToAdd = {};
|
const deviceToAdd = {};
|
||||||
deviceToAdd.SSID = device.ssid ?? 'N/A';
|
deviceToAdd.SSID = device.ssid ?? 'N/A';
|
||||||
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
deviceToAdd.Signal = (dbmNumber - device.signal) * -1;
|
||||||
@@ -41,14 +41,18 @@ const WifiScanResultModalWidget = ({show, toggle, scanResults, date}) => {
|
|||||||
finalList.push(channel);
|
finalList.push(channel);
|
||||||
});
|
});
|
||||||
return finalList;
|
return finalList;
|
||||||
}
|
};
|
||||||
return (
|
return (
|
||||||
<CModal size="lg" show={show} onClose={toggle}>
|
<CModal size="lg" show={show} onClose={toggle}>
|
||||||
<CModalHeader closeButton>
|
<CModalHeader closeButton>
|
||||||
<CModalTitle style={{color: 'black'}}>{date !== '' ? prettyDate(date) : ''} Wifi Scan Results</CModalTitle>
|
<CModalTitle style={{ color: 'black' }}>
|
||||||
|
{date !== '' ? prettyDate(date) : ''} Wifi Scan Results
|
||||||
|
</CModalTitle>
|
||||||
</CModalHeader>
|
</CModalHeader>
|
||||||
<CModalBody>
|
<CModalBody>
|
||||||
{scanResults === null ? null : <WifiChannelTable channels={parseThroughList(scanResults)}/>}
|
{scanResults === null ? null : (
|
||||||
|
<WifiChannelTable channels={parseThroughList(scanResults)} />
|
||||||
|
)}
|
||||||
</CModalBody>
|
</CModalBody>
|
||||||
<CModalFooter>
|
<CModalFooter>
|
||||||
<CButton color="secondary" onClick={toggle}>
|
<CButton color="secondary" onClick={toggle}>
|
||||||
@@ -57,5 +61,5 @@ const WifiScanResultModalWidget = ({show, toggle, scanResults, date}) => {
|
|||||||
</CModalFooter>
|
</CModalFooter>
|
||||||
</CModal>
|
</CModal>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
export default WifiScanResultModalWidget;
|
export default WifiScanResultModalWidget;
|
||||||
@@ -20,7 +20,7 @@ import CIcon from '@coreui/icons-react';
|
|||||||
import { cilUser, cilLockLocked, cilLink } from '@coreui/icons';
|
import { cilUser, cilLockLocked, cilLink } from '@coreui/icons';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import axiosInstance from '../../utils/axiosInstance';
|
import axiosInstance from '../../utils/axiosInstance';
|
||||||
import logo from '../../assets/OpenWiFi_LogoLockup_DarkGreyColour.svg'
|
import logo from '../../assets/OpenWiFi_LogoLockup_DarkGreyColour.svg';
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -92,7 +92,12 @@ const Login = () => {
|
|||||||
<CContainer>
|
<CContainer>
|
||||||
<CRow className="justify-content-center">
|
<CRow className="justify-content-center">
|
||||||
<CCol md="8">
|
<CCol md="8">
|
||||||
<img className="c-sidebar-brand-full" src={logo} style={{ paddingLeft: '17%', width: '85%'}} alt="OpenWifi" />
|
<img
|
||||||
|
className="c-sidebar-brand-full"
|
||||||
|
src={logo}
|
||||||
|
style={{ paddingLeft: '17%', width: '85%' }}
|
||||||
|
alt="OpenWifi"
|
||||||
|
/>
|
||||||
<CCardGroup>
|
<CCardGroup>
|
||||||
<CCard className="p-4">
|
<CCard className="p-4">
|
||||||
<CCardBody>
|
<CCardBody>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { createStore } from 'redux';
|
|||||||
const initialState = {
|
const initialState = {
|
||||||
sidebarShow: 'responsive',
|
sidebarShow: 'responsive',
|
||||||
connected: false,
|
connected: false,
|
||||||
selectedDeviceId: null
|
selectedDeviceId: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeState = (state = initialState, { type, ...rest }) => {
|
const changeState = (state = initialState, { type, ...rest }) => {
|
||||||
|
|||||||
@@ -4,11 +4,8 @@ import http from 'http';
|
|||||||
import https from 'https';
|
import https from 'https';
|
||||||
|
|
||||||
const httpAgent = new http.Agent({ keepAlive: true });
|
const httpAgent = new http.Agent({ keepAlive: true });
|
||||||
const httpsAgent = new https.Agent({ keepAlive: true});
|
const httpsAgent = new https.Agent({ keepAlive: true });
|
||||||
const axiosInstance = axios.create(
|
const axiosInstance = axios.create(httpAgent, httpsAgent);
|
||||||
httpAgent,
|
|
||||||
httpsAgent
|
|
||||||
);
|
|
||||||
|
|
||||||
axiosRetry(axiosInstance, {
|
axiosRetry(axiosInstance, {
|
||||||
retries: 3,
|
retries: 3,
|
||||||
|
|||||||
@@ -37,14 +37,16 @@ export const addDays = (date, days) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const prettyNumber = (number) => {
|
const prettyNumber = (number) => {
|
||||||
if (number >= 10){
|
if (number >= 10) {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
return `0${number}`;
|
return `0${number}`;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const prettyDate = (dateString) => {
|
export const prettyDate = (dateString) => {
|
||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
return `${date.getFullYear()}-${prettyNumber(date.getMonth() + 1)}-${prettyNumber(date.getDate())}
|
return `${date.getFullYear()}-${prettyNumber(date.getMonth() + 1)}-${prettyNumber(date.getDate())}
|
||||||
${prettyNumber(date.getHours())}:${prettyNumber(date.getMinutes())}:${prettyNumber(date.getSeconds())}`;
|
${prettyNumber(date.getHours())}:${prettyNumber(date.getMinutes())}:${prettyNumber(
|
||||||
}
|
date.getSeconds(),
|
||||||
|
)}`;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user