@@ -4,24 +4,11 @@ import { useState } from 'react'
44import InfoInterfaces from './InfoInterfaces'
55import GpuCard from './GpuCard'
66import UsersLine from './UsersLine'
7- // import DisplayPercent from './DisplayPercent'
8- // import DisplayRAM from './DisplayRAM'
97import CopyableText from './CopyableText'
108import InfoCPU from './InfoCPU'
119
1210const MachineCard = props => {
1311
14- // const secondsToHms = (d) => {
15- // d = Number(d);
16- // let h = Math.floor(d / 3600);
17- // let m = Math.floor(d % 3600 / 60);
18- // let s = Math.floor(d % 3600 % 60);
19-
20- // let hDisplay = h > 0 ? h + (h === 1 ? " hour, " : " hours, ") : "";
21- // let mDisplay = m > 0 ? m + (m === 1 ? " minute, " : " minutes, ") : "";
22- // let sDisplay = s > 0 ? s + (s === 1 ? " second" : " seconds") : "";
23- // return hDisplay + mDisplay + sDisplay;
24- // }
2512
2613 const secondsToShortString = ( x ) => {
2714 x = Number ( x ) ;
@@ -77,8 +64,35 @@ const MachineCard = props => {
7764 }
7865
7966 const [ showDetails , SetShowDetails ] = useState ( false )
67+ const [ showGPUs , SetShowGPUs ] = useState ( false )
68+ const [ showActiveGCP , SetShowActiveGCP ] = useState ( false ) // GCP: GPU Compute Processes
69+
8070 const handleShowDetails = ( ) => {
8171 SetShowDetails ( ( state ) => {
72+ if ( state ) {
73+ SetShowGPUs ( false )
74+ SetShowActiveGCP ( false )
75+ return false
76+ } else {
77+ SetShowGPUs ( true )
78+ SetShowActiveGCP ( true )
79+ return true
80+ }
81+ } )
82+ }
83+
84+ const handleShowGPUs = ( ) => {
85+ SetShowGPUs ( ( state ) => {
86+ if ( state ) {
87+ return false
88+ } else {
89+ return true
90+ }
91+ } )
92+ }
93+
94+ const handleShowActiveGCP = ( ) => {
95+ SetShowActiveGCP ( ( state ) => {
8296 if ( state ) {
8397 return false
8498 } else {
@@ -157,13 +171,27 @@ const MachineCard = props => {
157171 ONLINE
158172 </ span >
159173 ) : (
160- < span className = "hacker-badge danger" > OFFLINE</ span >
174+ < span className = "hacker-badge danger" >
175+ OFFLINE
176+ </ span >
161177 ) }
162178
163179 { isEmpty ( props . data . gpu_status ) ? (
164180 < span className = "hacker-badge" > GPU N/A</ span >
165181 ) : (
166- < span className = "hacker-badge info" > GPU x{ numItems ( props . data . gpu_status ) } </ span >
182+ < button className = "hacker-badge info" onClick = { ( e ) => {
183+ e . stopPropagation ( )
184+ handleShowGPUs ( )
185+ } } > GPU x{ numItems ( props . data . gpu_status ) } </ button >
186+ ) }
187+
188+ { isEmpty ( props . data . gpu_compute_processes ) ? (
189+ < span className = "hacker-badge" > AGC: 0</ span >
190+ ) : (
191+ < button className = "hacker-badge success" onClick = { ( e ) => {
192+ e . stopPropagation ( )
193+ handleShowActiveGCP ( )
194+ } } > AGC: { numItems ( props . data . gpu_compute_processes ) } </ button >
167195 ) }
168196
169197 < button
@@ -252,15 +280,13 @@ const MachineCard = props => {
252280 </ div >
253281 </ div >
254282
255- { isEmpty ( props . data . gpu_status ) || ! showDetails ? null :
283+ { isEmpty ( props . data . gpu_status ) || ! showGPUs ? null :
256284 < div className = "gpu-section mt-2" >
257285 { props . data . gpu_status . map ( ( gpu_data , idx ) => < GpuCard key = { idx } data = { gpu_data } /> ) }
258286 </ div >
259287 }
260288
261- { /* {isEmpty(props.data.gpu_compute_processes) || showDetails || (!isOnline() && !showDetails) ? null : */ }
262- { /* {isEmpty(props.data.gpu_compute_processes) || !showDetails || (!isOnline() && showDetails) ? null : */ }
263- { isEmpty ( props . data . gpu_compute_processes ) || ! isOnline ( ) ? null :
289+ { isEmpty ( props . data . gpu_compute_processes ) || ! showActiveGCP ? null :
264290 < div className = "processes-section mt-2" style = { {
265291 borderTop : '1px solid var(--hacker-border)' ,
266292 paddingTop : '0.75rem'
0 commit comments