@@ -38,7 +38,7 @@ function HistoryExportButtonWrapper({
3838 try {
3939 // Get data to export - use existing exportData or fetch from API
4040 let dataToExport = exportData ;
41-
41+
4242 if ( ! dataToExport ) {
4343 setIsLoading ( true ) ;
4444 try {
@@ -48,10 +48,10 @@ function HistoryExportButtonWrapper({
4848 throw new Error ( 'Failed to fetch results' ) ;
4949 }
5050 const data = await response . json ( ) ;
51-
51+
5252 // Also trigger parent's loadResults to update state
5353 await onLoadResults ( ) ;
54-
54+
5555 // Extract all results from the response
5656 const allResults : unknown [ ] = [ ] ;
5757 data . forEach ( ( result : { result_data ?: unknown } ) => {
@@ -230,7 +230,7 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
230230 // Extract hosts from result data
231231 const extractHostsFromResult = useCallback ( ( resultData : unknown ) : string [ ] => {
232232 const hosts : string [ ] = [ ] ;
233-
233+
234234 if ( resultData && typeof resultData === 'object' && resultData !== null ) {
235235 if ( 'results' in resultData && Array . isArray ( resultData . results ) ) {
236236 resultData . results . forEach ( ( row : unknown ) => {
@@ -239,17 +239,15 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
239239 hostValue = String ( row [ 0 ] ?? '' ) . trim ( ) ;
240240 } else if ( typeof row === 'object' && row !== null ) {
241241 const rowObj = row as Record < string , unknown > ;
242- hostValue = String (
243- rowObj . host ?? rowObj . HOST ?? rowObj . Host ?? rowObj [ 0 ] ?? ''
244- ) . trim ( ) ;
242+ hostValue = String ( rowObj . host ?? rowObj . HOST ?? rowObj . Host ?? rowObj [ 0 ] ?? '' ) . trim ( ) ;
245243 }
246244 if ( hostValue && ! hosts . includes ( hostValue ) ) {
247245 hosts . push ( hostValue ) ;
248246 }
249247 } ) ;
250248 }
251249 }
252-
250+
253251 return hosts ;
254252 } , [ ] ) ;
255253
@@ -283,7 +281,7 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
283281 const batch = hosts . slice ( i , i + batchSize ) ;
284282 const batchResults = await checkHostsHealth ( batch , { timeout : 5000 } ) ;
285283
286- batchResults . forEach ( ( checkResult ) => {
284+ batchResults . forEach ( checkResult => {
287285 resultsMap [ checkResult . host ] = checkResult ;
288286 if ( checkResult . alive ) {
289287 aliveCount ++ ;
@@ -425,15 +423,21 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
425423 { checkSummary [ item . id ] && (
426424 < div className = "query-results-summary" >
427425 < div className = "summary-item summary-total" >
428- < span className = "summary-label" > { t ( 'query.results.summary.total' ) } :</ span >
426+ < span className = "summary-label" >
427+ { t ( 'query.results.summary.total' ) } :
428+ </ span >
429429 < span className = "summary-value" > { checkSummary [ item . id ] . total } </ span >
430430 </ div >
431431 < div className = "summary-item summary-alive" >
432- < span className = "summary-label" > { t ( 'query.results.summary.alive' ) } :</ span >
432+ < span className = "summary-label" >
433+ { t ( 'query.results.summary.alive' ) } :
434+ </ span >
433435 < span className = "summary-value" > { checkSummary [ item . id ] . alive } </ span >
434436 </ div >
435437 < div className = "summary-item summary-dead" >
436- < span className = "summary-label" > { t ( 'query.results.summary.dead' ) } :</ span >
438+ < span className = "summary-label" >
439+ { t ( 'query.results.summary.dead' ) } :
440+ </ span >
437441 < span className = "summary-value" > { checkSummary [ item . id ] . dead } </ span >
438442 </ div >
439443 </ div >
@@ -444,7 +448,8 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
444448 < thead >
445449 < tr >
446450 { ( ( ) => {
447- const resultsArray = ( resultData as { results : unknown [ ] } ) . results ;
451+ const resultsArray = ( resultData as { results : unknown [ ] } )
452+ . results ;
448453 const firstResult = resultsArray [ 0 ] ;
449454 if ( Array . isArray ( firstResult ) ) {
450455 return (
@@ -473,56 +478,60 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
473478 </ tr >
474479 </ thead >
475480 < tbody >
476- { ( resultData as { results : unknown [ ] } ) . results . map ( ( row : unknown , rowIdx : number ) => {
477- let hostValue = '' ;
478- if ( Array . isArray ( row ) && row . length > 0 ) {
479- hostValue = String ( row [ 0 ] ?? '' ) . trim ( ) ;
480- } else if ( typeof row === 'object' && row !== null ) {
481- const rowObj = row as Record < string , unknown > ;
482- hostValue = String (
483- rowObj . host ?? rowObj . HOST ?? rowObj . Host ?? rowObj [ 0 ] ?? ''
484- ) . trim ( ) ;
485- }
481+ { ( resultData as { results : unknown [ ] } ) . results . map (
482+ ( row : unknown , rowIdx : number ) => {
483+ let hostValue = '' ;
484+ if ( Array . isArray ( row ) && row . length > 0 ) {
485+ hostValue = String ( row [ 0 ] ?? '' ) . trim ( ) ;
486+ } else if ( typeof row === 'object' && row !== null ) {
487+ const rowObj = row as Record < string , unknown > ;
488+ hostValue = String (
489+ rowObj . host ?? rowObj . HOST ?? rowObj . Host ?? rowObj [ 0 ] ?? ''
490+ ) . trim ( ) ;
491+ }
486492
487- if ( Array . isArray ( row ) ) {
488- return (
489- < tr key = { rowIdx } >
490- { row . map ( ( cell : unknown , cellIdx : number ) => (
491- < td key = { cellIdx } > { String ( cell ?? '-' ) } </ td >
492- ) ) }
493- < td className = "health-check-cell" >
494- { hostValue ? (
495- < HealthCheckStatus
496- host = { hostValue }
497- externalResult = { checkResults [ item . id ] ?. [ hostValue ] }
498- />
499- ) : (
500- '-'
501- ) }
502- </ td >
503- </ tr >
504- ) ;
505- } else if ( typeof row === 'object' && row !== null ) {
506- return (
507- < tr key = { rowIdx } >
508- { Object . values ( row ) . map ( ( cell : unknown , cellIdx : number ) => (
509- < td key = { cellIdx } > { String ( cell ?? '-' ) } </ td >
510- ) ) }
511- < td className = "health-check-cell" >
512- { hostValue ? (
513- < HealthCheckStatus
514- host = { hostValue }
515- externalResult = { checkResults [ item . id ] ?. [ hostValue ] }
516- />
517- ) : (
518- '-'
493+ if ( Array . isArray ( row ) ) {
494+ return (
495+ < tr key = { rowIdx } >
496+ { row . map ( ( cell : unknown , cellIdx : number ) => (
497+ < td key = { cellIdx } > { String ( cell ?? '-' ) } </ td >
498+ ) ) }
499+ < td className = "health-check-cell" >
500+ { hostValue ? (
501+ < HealthCheckStatus
502+ host = { hostValue }
503+ externalResult = { checkResults [ item . id ] ?. [ hostValue ] }
504+ />
505+ ) : (
506+ '-'
507+ ) }
508+ </ td >
509+ </ tr >
510+ ) ;
511+ } else if ( typeof row === 'object' && row !== null ) {
512+ return (
513+ < tr key = { rowIdx } >
514+ { Object . values ( row ) . map (
515+ ( cell : unknown , cellIdx : number ) => (
516+ < td key = { cellIdx } > { String ( cell ?? '-' ) } </ td >
517+ )
519518 ) }
520- </ td >
521- </ tr >
522- ) ;
519+ < td className = "health-check-cell" >
520+ { hostValue ? (
521+ < HealthCheckStatus
522+ host = { hostValue }
523+ externalResult = { checkResults [ item . id ] ?. [ hostValue ] }
524+ />
525+ ) : (
526+ '-'
527+ ) }
528+ </ td >
529+ </ tr >
530+ ) ;
531+ }
532+ return null ;
523533 }
524- return null ;
525- } ) }
534+ ) }
526535 </ tbody >
527536 </ table >
528537 </ div >
0 commit comments