mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-11-01 18:57:46 +00:00
Testing trace downloads
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
|||||||
} 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';
|
||||||
import { cilSync } from '@coreui/icons';
|
import { cilCloudDownload, cilSync } from '@coreui/icons';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { faClipboardCheck } from '@fortawesome/free-solid-svg-icons';
|
import { faClipboardCheck } from '@fortawesome/free-solid-svg-icons';
|
||||||
@@ -111,6 +111,25 @@ const DeviceCommands = ({ selectedDeviceId }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const downloadTrace = (uuid) => {
|
||||||
|
const options = {
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/octet-stream',
|
||||||
|
Authorization: `Bearer ${getToken()}`,
|
||||||
|
},
|
||||||
|
responseType: 'arraybuffer'
|
||||||
|
};
|
||||||
|
|
||||||
|
axiosInstance.get(`/file/${uuid}?serialNumber=${selectedDeviceId}`, options)
|
||||||
|
.then((response) => {
|
||||||
|
const blob = new Blob([response.data], { type: 'application/octet-stream' })
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = window.URL.createObjectURL(blob)
|
||||||
|
link.download = 'Report.pdf'
|
||||||
|
link.click()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const deleteCommand = async () => {
|
const deleteCommand = async () => {
|
||||||
if (uuidDelete === '') {
|
if (uuidDelete === '') {
|
||||||
return false;
|
return false;
|
||||||
@@ -135,7 +154,15 @@ const DeviceCommands = ({ selectedDeviceId }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const toggleDetails = (item, index) => {
|
const toggleDetails = (item, index) => {
|
||||||
if (item.command !== 'wifiscan' || !item.results.status) {
|
if (item.command === 'wifiscan') {
|
||||||
|
setChosenWifiScan(item.results.status.scan);
|
||||||
|
setScanDate(item.completed);
|
||||||
|
setShowScanModal(true);
|
||||||
|
}
|
||||||
|
else if (item.command === 'trace') {
|
||||||
|
downloadTrace(item.UUID);
|
||||||
|
}
|
||||||
|
else {
|
||||||
const position = details.indexOf(index);
|
const position = details.indexOf(index);
|
||||||
let newDetails = details.slice();
|
let newDetails = details.slice();
|
||||||
|
|
||||||
@@ -145,10 +172,6 @@ const DeviceCommands = ({ selectedDeviceId }) => {
|
|||||||
newDetails = [...details, index];
|
newDetails = [...details, index];
|
||||||
}
|
}
|
||||||
setDetails(newDetails);
|
setDetails(newDetails);
|
||||||
} else {
|
|
||||||
setChosenWifiScan(item.results.status.scan);
|
|
||||||
setScanDate(item.completed);
|
|
||||||
setShowScanModal(true);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -323,11 +346,16 @@ const DeviceCommands = ({ selectedDeviceId }) => {
|
|||||||
toggleDetails(item, index);
|
toggleDetails(item, index);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon
|
{
|
||||||
icon={faClipboardCheck}
|
item.command === 'trace' ?
|
||||||
className="c-icon c-icon-lg"
|
<CIcon content={cilCloudDownload}/>
|
||||||
style={{ height: '19px' }}
|
:
|
||||||
/>
|
<FontAwesomeIcon
|
||||||
|
icon={faClipboardCheck}
|
||||||
|
className="c-icon c-icon-lg"
|
||||||
|
style={{ height: '19px' }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</CButton>
|
</CButton>
|
||||||
</CPopover>
|
</CPopover>
|
||||||
</CCol>
|
</CCol>
|
||||||
|
|||||||
Reference in New Issue
Block a user