@@ -3273,10 +3273,6 @@ async function renderServerDetail(serverId) {
32733273 </ div >
32743274 ` ;
32753275
3276- if ( activeTab === 'resources' ) {
3277- fetchLiveResources ( s . identifier ) ;
3278- }
3279-
32803276 // Disable transition for initial position to prevent sliding from 0
32813277 const indicator = $ ( '#tab-indicator' ) ;
32823278 const activeTabEl = $ ( '#server-detail-tabs .tab.active' ) ;
@@ -3305,89 +3301,6 @@ async function renderServerDetail(serverId) {
33053301 }
33063302}
33073303
3308- async function fetchLiveResources ( identifier ) {
3309- const container = $ ( '#live-resources-container' ) ;
3310- if ( ! container ) return ;
3311-
3312- try {
3313- const data = await api ( `/servers/resources/${ identifier } ` ) ;
3314-
3315- if ( ! data . resources ) {
3316- container . innerHTML = html `
3317- < div class ="empty-state " style ="padding:24px ">
3318- < div class ="empty-state-title " style ="font-size:0.95rem "> No live data</ div >
3319- < div class ="empty-state-desc " style ="font-size:0.82rem ">
3320- ${ data . error || 'Add your Pyrodactyl API key in Account → Account Info to enable live monitoring.' }
3321- </ div >
3322- < button class ="btn btn-primary btn-sm " onclick ="navigateTo('account/info') " style ="margin-top:8px;width:auto "> Configure API Key</ button >
3323- </ div >
3324- ` ;
3325- return ;
3326- }
3327-
3328- const res = data . resources ;
3329- const currentState = data . current_state ;
3330- const cpuPct = Math . round ( res . cpu_absolute || 0 ) ;
3331- const memUsed = res . memory_bytes ? Math . round ( res . memory_bytes / ( 1024 * 1024 ) ) : 0 ;
3332- const memLimit = res . memory_limit_bytes ? Math . round ( res . memory_limit_bytes / ( 1024 * 1024 ) ) : 512 ;
3333- const memPct = memLimit > 0 ? Math . min ( 100 , Math . round ( ( memUsed / memLimit ) * 100 ) ) : 0 ;
3334- const diskUsed = res . disk_bytes ? Math . round ( res . disk_bytes / ( 1024 * 1024 ) ) : 0 ;
3335- const diskLimit = 3072 ;
3336- const diskPct = diskLimit > 0 ? Math . min ( 100 , Math . round ( ( diskUsed / diskLimit ) * 100 ) ) : 0 ;
3337-
3338- function usageClass ( pct ) {
3339- if ( pct >= 80 ) return 'usage-high' ;
3340- if ( pct >= 50 ) return 'usage-mid' ;
3341- return 'usage-low' ;
3342- }
3343-
3344- container . innerHTML = html `
3345- < div class ="resource-gauges ">
3346- < div class ="resource-gauge ">
3347- < div class ="resource-gauge-value " style ="color: ${ cpuPct >= 80 ? 'var(--accent-red)' : cpuPct >= 50 ? 'var(--accent-orange)' : 'var(--accent-cyan)' } "> ${ cpuPct } %</ div >
3348- < div class ="resource-gauge-label "> CPU</ div >
3349- < div class ="resource-gauge-bar "> < div class ="resource-gauge-fill ${ usageClass ( cpuPct ) } " style ="width:${ cpuPct } % "> </ div > </ div >
3350- < div class ="resource-gauge-sub "> ${ cpuPct >= 80 ? 'High load' : cpuPct >= 50 ? 'Moderate' : 'Idle' } </ div >
3351- </ div >
3352- < div class ="resource-gauge ">
3353- < div class ="resource-gauge-value " style ="color: ${ memPct >= 80 ? 'var(--accent-red)' : memPct >= 50 ? 'var(--accent-orange)' : 'var(--accent-1)' } "> ${ memUsed } / ${ memLimit } MB</ div >
3354- < div class ="resource-gauge-label "> Memory</ div >
3355- < div class ="resource-gauge-bar "> < div class ="resource-gauge-fill ${ usageClass ( memPct ) } " style ="width:${ memPct } % "> </ div > </ div >
3356- < div class ="resource-gauge-sub "> ${ memPct } % used</ div >
3357- </ div >
3358- < div class ="resource-gauge ">
3359- < div class ="resource-gauge-value " style ="color: ${ diskPct >= 80 ? 'var(--accent-red)' : diskPct >= 50 ? 'var(--accent-orange)' : 'var(--accent-green)' } "> ${ ( diskUsed / 1024 ) . toFixed ( 1 ) } / ${ ( diskLimit / 1024 ) . toFixed ( 1 ) } GB</ div >
3360- < div class ="resource-gauge-label "> Disk</ div >
3361- < div class ="resource-gauge-bar "> < div class ="resource-gauge-fill ${ usageClass ( diskPct ) } " style ="width:${ diskPct } % "> </ div > </ div >
3362- < div class ="resource-gauge-sub "> ${ diskPct } % used</ div >
3363- </ div >
3364- </ div >
3365- < div style ="margin-top:12px;text-align:center;font-size:0.72rem;color:var(--text-muted) ">
3366- Updated ${ formatRelativeTime ( new Date ( ) . toISOString ( ) ) } ·
3367- ${ currentState ? html `Status: < strong > ${ currentState } </ strong > ` : '' }
3368- </ div >
3369- ` ;
3370-
3371- const refreshBtn = $ ( '#refresh-resources-btn' ) ;
3372- if ( refreshBtn && ! refreshBtn . dataset . listenerAttached ) {
3373- refreshBtn . dataset . listenerAttached = '1' ;
3374- refreshBtn . addEventListener ( 'click' , ( ) => {
3375- container . innerHTML = '<div style="text-align:center;padding:32px;color:var(--text-secondary)" id="live-resources-loading"><span class="spinner"></span> Fetching live data...</div>' ;
3376- fetchLiveResources ( identifier ) ;
3377- } ) ;
3378- }
3379-
3380- } catch ( err ) {
3381- if ( container ) {
3382- container . innerHTML = html `
3383- < div style ="text-align:center;padding:24px;color:var(--text-muted);font-size:0.88rem ">
3384- Could not load live resources: ${ err . message }
3385- </ div >
3386- ` ;
3387- }
3388- }
3389- }
3390-
33913304// ===== TAB SWITCHING =====
33923305function switchTab ( tabBtn ) {
33933306 if ( ! $ ( '#tab-indicator' ) ) return ;
@@ -3407,13 +3320,6 @@ function switchTab(tabBtn) {
34073320 indicator . style . width = tabBtn . offsetWidth + 'px' ;
34083321 }
34093322
3410- if ( tabName === 'resources' ) {
3411- const container = $ ( '#live-resources-container' ) ;
3412- if ( container && container . querySelector ( '.resource-gauge' ) === null ) {
3413- fetchLiveResources ( state . serverIdentifier ) ;
3414- }
3415- }
3416-
34173323 const newUrl = `/server/${ state . serverId } /${ tabName } ` ;
34183324 history . pushState ( { page : 'server' , serverId : state . serverId , tab : tabName } , '' , newUrl ) ;
34193325}
0 commit comments