Skip to content

Commit f7ae78e

Browse files
committed
Fix live resource display on server detail page
- Correct nested resources path (data.attributes.resources) - Use PTERO_URL config instead of hardcoded panel URL - Fix current_state access on frontend
1 parent 4740836 commit f7ae78e

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

public/js/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,7 @@ async function fetchLiveResources(identifier) {
17311731
}
17321732

17331733
const res = data.resources;
1734+
const currentState = data.current_state;
17341735
const cpuPct = Math.round(res.cpu_absolute || 0);
17351736
const memUsed = res.memory_bytes ? Math.round(res.memory_bytes / (1024 * 1024)) : 0;
17361737
const memLimit = res.memory_limit_bytes ? Math.round(res.memory_limit_bytes / (1024 * 1024)) : 512;
@@ -1768,7 +1769,7 @@ async function fetchLiveResources(identifier) {
17681769
</div>
17691770
<div style="margin-top:12px;text-align:center;font-size:0.72rem;color:var(--text-muted)">
17701771
Updated ${formatRelativeTime(new Date().toISOString())} ·
1771-
${res.current_state ? html`Status: <strong>${res.current_state}</strong>` : ''}
1772+
${currentState ? html`Status: <strong>${currentState}</strong>` : ''}
17721773
</div>
17731774
`;
17741775

routes/servers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ router.get('/resources/:identifier', authenticateToken, async (req, res) => {
354354
}
355355

356356
const apiKey = users[0].ptero_client_api_key;
357-
const pteroRes = await fetch(`https://panel.zero-host.org/api/client/servers/${identifier}/resources`, {
357+
const pteroRes = await fetch(`${PTERO_URL}/api/client/servers/${identifier}/resources`, {
358358
headers: {
359359
'Authorization': `Bearer ${apiKey}`,
360360
'Accept': 'application/json',
@@ -367,7 +367,7 @@ router.get('/resources/:identifier', authenticateToken, async (req, res) => {
367367
}
368368

369369
const data = await pteroRes.json();
370-
res.json({ resources: data.attributes });
370+
res.json({ resources: data.attributes.resources, current_state: data.attributes.current_state });
371371
} catch (err) {
372372
console.error('Resources error:', err.message);
373373
res.status(500).json({ error: 'Failed to fetch server resources' });

0 commit comments

Comments
 (0)