@@ -16,6 +16,8 @@ import { Modal } from 'components/Modals/Modal';
1616import { useGetDevice , useGetDeviceHealthChecks , useGetDeviceStatus } from 'hooks/Network/Devices' ;
1717import { useGetDeviceLastStats , useGetDeviceNewestStats } from 'hooks/Network/Statistics' ;
1818import { useGetTag } from 'hooks/Network/Inventory' ;
19+ import { useGetCommandHistory } from 'hooks/Network/Commands' ;
20+ import { useGetDeviceLogs } from 'hooks/Network/DeviceLogs' ;
1921
2022type Props = {
2123 serialNumber : string ;
@@ -42,6 +44,10 @@ const ExportStatsModal = ({ serialNumber, modalProps }: Props) => {
4244 const getNewestStats = useGetDeviceNewestStats ( { serialNumber, limit : 30 } ) ;
4345 const getHealth = useGetDeviceHealthChecks ( { serialNumber, limit : 50 } ) ;
4446 const getTag = useGetTag ( { serialNumber } ) ;
47+ const getCommands = useGetCommandHistory ( { serialNumber, limit : 100 } ) ;
48+ const getLogs = useGetDeviceLogs ( { serialNumber, limit : 100 , logType : 0 } ) ;
49+ const getCrashes = useGetDeviceLogs ( { serialNumber, limit : 100 , logType : 1 } ) ;
50+ const getReboots = useGetDeviceLogs ( { serialNumber, limit : 100 , logType : 2 } ) ;
4551
4652 const onToggle = ( value : string ) => ( e : { target : { checked : boolean } } ) => {
4753 if ( e . target . checked ) {
@@ -134,8 +140,24 @@ const ExportStatsModal = ({ serialNumber, modalProps }: Props) => {
134140 } ;
135141 }
136142
143+ if ( selectedOptions . includes ( 'commands' ) && getCommands . data ?. commands ) {
144+ exportData . commands = getCommands . data . commands ;
145+ }
146+
147+ if ( selectedOptions . includes ( 'logs' ) && getLogs . data ?. values ) {
148+ exportData . logs = getLogs . data . values ;
149+ }
150+
151+ if ( selectedOptions . includes ( 'crashes' ) && getCrashes . data ?. values ) {
152+ exportData . crashes = getCrashes . data . values ;
153+ }
154+
155+ if ( selectedOptions . includes ( 'reboots' ) && getReboots . data ?. values ) {
156+ exportData . reboots = getReboots . data . values ;
157+ }
158+
137159 return exportData ;
138- } , [ selectedOptions , getDevice . data , getStatus . data , getStats . data , getNewestStats . data , getHealth . data , getTag . data , serialNumber ] ) ;
160+ } , [ selectedOptions , getDevice . data , getStatus . data , getStats . data , getNewestStats . data , getHealth . data , getTag . data , getCommands . data , getLogs . data , getCrashes . data , getReboots . data , serialNumber ] ) ;
139161
140162 const handleExport = ( ) => {
141163 if ( selectedOptions . length === 0 ) {
@@ -196,7 +218,11 @@ const ExportStatsModal = ({ serialNumber, modalProps }: Props) => {
196218 getStats . isFetching ||
197219 getNewestStats . isFetching ||
198220 getHealth . isFetching ||
199- getTag . isFetching ;
221+ getTag . isFetching ||
222+ getCommands . isFetching ||
223+ getLogs . isFetching ||
224+ getCrashes . isFetching ||
225+ getReboots . isFetching ;
200226
201227 return (
202228 < Modal
@@ -226,14 +252,14 @@ const ExportStatsModal = ({ serialNumber, modalProps }: Props) => {
226252 < Stack spacing = { 3 } mt = { 2 } >
227253 < Box >
228254 < Checkbox
229- colorScheme = "blue "
230- isChecked = { selectedOptions . includes ( 'deviceInfo ' ) }
231- onChange = { onToggle ( 'deviceInfo ' ) }
255+ colorScheme = "pink "
256+ isChecked = { selectedOptions . includes ( 'commands ' ) }
257+ onChange = { onToggle ( 'commands ' ) }
232258 >
233- { t ( 'common.details ' ) }
259+ { t ( 'controller.devices.commands ' ) }
234260 </ Checkbox >
235261 < Text fontSize = "xs" color = "gray.500" ml = { 6 } >
236- { t ( 'export.device_info_desc ' ) }
262+ { t ( 'export.commands_desc ' ) }
237263 </ Text >
238264 </ Box >
239265 < Box >
@@ -250,26 +276,26 @@ const ExportStatsModal = ({ serialNumber, modalProps }: Props) => {
250276 </ Box >
251277 < Box >
252278 < Checkbox
253- colorScheme = "green "
254- isChecked = { selectedOptions . includes ( 'status ' ) }
255- onChange = { onToggle ( 'status ' ) }
279+ colorScheme = "red "
280+ isChecked = { selectedOptions . includes ( 'crashes ' ) }
281+ onChange = { onToggle ( 'crashes ' ) }
256282 >
257- { t ( 'common.status ' ) }
283+ { t ( 'devices.crash_logs ' ) }
258284 </ Checkbox >
259285 < Text fontSize = "xs" color = "gray.500" ml = { 6 } >
260- { t ( 'export.status_desc ' ) }
286+ { t ( 'export.crashes_desc ' ) }
261287 </ Text >
262288 </ Box >
263289 < Box >
264290 < Checkbox
265- colorScheme = "teal "
266- isChecked = { selectedOptions . includes ( 'statistics ' ) }
267- onChange = { onToggle ( 'statistics ' ) }
291+ colorScheme = "blue "
292+ isChecked = { selectedOptions . includes ( 'deviceInfo ' ) }
293+ onChange = { onToggle ( 'deviceInfo ' ) }
268294 >
269- { t ( 'configurations.statistics ' ) }
295+ { t ( 'common.details ' ) }
270296 </ Checkbox >
271297 < Text fontSize = "xs" color = "gray.500" ml = { 6 } >
272- { t ( 'export.statistics_desc ' ) }
298+ { t ( 'export.device_info_desc ' ) }
273299 </ Text >
274300 </ Box >
275301 < Box >
@@ -284,6 +310,18 @@ const ExportStatsModal = ({ serialNumber, modalProps }: Props) => {
284310 { t ( 'export.health_checks_desc' ) }
285311 </ Text >
286312 </ Box >
313+ < Box >
314+ < Checkbox
315+ colorScheme = "yellow"
316+ isChecked = { selectedOptions . includes ( 'logs' ) }
317+ onChange = { onToggle ( 'logs' ) }
318+ >
319+ { t ( 'controller.devices.logs' ) }
320+ </ Checkbox >
321+ < Text fontSize = "xs" color = "gray.500" ml = { 6 } >
322+ { t ( 'export.logs_desc' ) }
323+ </ Text >
324+ </ Box >
287325 < Box >
288326 < Checkbox
289327 colorScheme = "cyan"
@@ -296,6 +334,42 @@ const ExportStatsModal = ({ serialNumber, modalProps }: Props) => {
296334 { t ( 'export.provisioning_desc' ) }
297335 </ Text >
298336 </ Box >
337+ < Box >
338+ < Checkbox
339+ colorScheme = "gray"
340+ isChecked = { selectedOptions . includes ( 'reboots' ) }
341+ onChange = { onToggle ( 'reboots' ) }
342+ >
343+ { t ( 'devices.reboot_logs' ) }
344+ </ Checkbox >
345+ < Text fontSize = "xs" color = "gray.500" ml = { 6 } >
346+ { t ( 'export.reboots_desc' ) }
347+ </ Text >
348+ </ Box >
349+ < Box >
350+ < Checkbox
351+ colorScheme = "teal"
352+ isChecked = { selectedOptions . includes ( 'statistics' ) }
353+ onChange = { onToggle ( 'statistics' ) }
354+ >
355+ { t ( 'configurations.statistics' ) }
356+ </ Checkbox >
357+ < Text fontSize = "xs" color = "gray.500" ml = { 6 } >
358+ { t ( 'export.statistics_desc' ) }
359+ </ Text >
360+ </ Box >
361+ < Box >
362+ < Checkbox
363+ colorScheme = "green"
364+ isChecked = { selectedOptions . includes ( 'status' ) }
365+ onChange = { onToggle ( 'status' ) }
366+ >
367+ { t ( 'common.status' ) }
368+ </ Checkbox >
369+ < Text fontSize = "xs" color = "gray.500" ml = { 6 } >
370+ { t ( 'export.status_desc' ) }
371+ </ Text >
372+ </ Box >
299373 </ Stack >
300374 </ Box >
301375 ) }
0 commit comments