@@ -593,6 +593,25 @@ const UsageModal = ({ open, onClose, username }: UsageModalProps) => {
593593 setChartData ( processedChartData )
594594 } , [ processedChartData ] )
595595
596+ // Calculate total usage during period
597+ const totalUsageDuringPeriod = useMemo ( ( ) => {
598+ if ( ! processedChartData || processedChartData . length === 0 ) return 0
599+
600+ const getTotalUsage = ( dataPoint : any ) => {
601+ if ( selectedNodeId === undefined && is_sudo ) {
602+ // All nodes selected - sum all node usages
603+ return Object . keys ( dataPoint )
604+ . filter ( key => ! key . startsWith ( '_' ) && key !== 'time' && key !== 'usage' && ( dataPoint [ key ] || 0 ) > 0 )
605+ . reduce ( ( sum , nodeName ) => sum + ( dataPoint [ nodeName ] || 0 ) , 0 )
606+ } else {
607+ // Single node selected - use usage field
608+ return dataPoint . usage || 0
609+ }
610+ }
611+
612+ return processedChartData . reduce ( ( sum , dataPoint ) => sum + getTotalUsage ( dataPoint ) , 0 )
613+ } , [ processedChartData , selectedNodeId , is_sudo ] )
614+
596615 // Calculate trend (simple: compare last and previous usage)
597616 const trend = useMemo ( ( ) => {
598617 if ( ! processedChartData || processedChartData . length < 2 ) return null
@@ -806,6 +825,11 @@ const UsageModal = ({ open, onClose, username }: UsageModalProps) => {
806825 { t ( 'usersTable.trendingDown' , { defaultValue : 'Trending down by' } ) } { Math . abs ( trend ) . toFixed ( 1 ) } %
807826 </ div >
808827 ) }
828+ { processedChartData . length > 0 && (
829+ < div className = "leading-none text-muted-foreground" >
830+ { t ( 'statistics.usageDuringPeriod' , { defaultValue : 'Usage During Period' } ) } : < span dir = "ltr" className = "font-mono" > { totalUsageDuringPeriod . toFixed ( 2 ) } GB</ span >
831+ </ div >
832+ ) }
809833 < div className = "leading-none text-muted-foreground" > { t ( 'usersTable.usageSummary' , { defaultValue : 'Showing total usage for the selected period.' } ) } </ div >
810834 </ CardFooter >
811835 </ Card >
0 commit comments