Add Proxmox platform detection, preserve expanded card state across auto-refresh
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="refresh" content="60">
|
||||
<title>Infrastructure Map</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
@@ -44,6 +43,7 @@
|
||||
{% endif %}
|
||||
|
||||
<div class="server-card {% if not server.is_online %}offline{% endif %}"
|
||||
data-server-id="{{ server.id }}"
|
||||
onclick="toggleDetails(this)">
|
||||
<div class="card-summary">
|
||||
<div class="card-header">
|
||||
@@ -54,7 +54,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="server-ip">{{ server.primary_ip or 'No IP' }}</div>
|
||||
<div class="server-os">{{ sys.get('os_pretty', '') }}</div>
|
||||
<div class="server-os">{% if sys.get('platform') %}{{ sys.get('platform')|capitalize }} {{ sys.get('platform_version', '') }} / {% endif %}{{ sys.get('os_pretty', '') }}</div>
|
||||
{% if server.is_online and (cpu.get('model') or mem.get('total_mb')) %}
|
||||
<div class="server-hw">
|
||||
{%- if cpu.get('model') %}{{ cpu.get('model') }}{% endif %}
|
||||
@@ -117,6 +117,9 @@
|
||||
<table>
|
||||
<tr><td>Hostname</td><td>{{ sys.get('hostname', '-') }}</td></tr>
|
||||
<tr><td>OS</td><td>{{ sys.get('os_pretty', '-') }}</td></tr>
|
||||
{% if sys.get('platform') %}
|
||||
<tr><td>Platform</td><td>{{ sys.get('platform')|capitalize }} {{ sys.get('platform_version', '') }}</td></tr>
|
||||
{% endif %}
|
||||
<tr><td>Kernel</td><td>{{ sys.get('kernel', '-') }}</td></tr>
|
||||
<tr><td>Arch</td><td>{{ sys.get('arch', '-') }}</td></tr>
|
||||
<tr><td>Uptime</td><td>{{ sys.get('uptime_seconds', '')|format_uptime }}</td></tr>
|
||||
@@ -355,9 +358,12 @@
|
||||
if (!isOpen) {
|
||||
details.style.display = 'block';
|
||||
card.classList.add('expanded');
|
||||
location.hash = card.dataset.serverId;
|
||||
// Auto-resize notes textarea
|
||||
const ta = details.querySelector('.notes-input');
|
||||
if (ta) autoResizeNotes(ta);
|
||||
} else {
|
||||
history.replaceState(null, '', location.pathname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,6 +387,28 @@
|
||||
body: JSON.stringify({notes: ta.value})
|
||||
});
|
||||
}
|
||||
|
||||
// Restore expanded card from URL hash after reload
|
||||
function restoreExpanded() {
|
||||
const id = location.hash.slice(1);
|
||||
if (!id) return;
|
||||
const card = document.querySelector('.server-card[data-server-id="' + id + '"]');
|
||||
if (card) toggleDetails(card);
|
||||
}
|
||||
|
||||
// Auto-refresh without full page reload if a card is expanded,
|
||||
// otherwise do a simple reload
|
||||
setInterval(function() {
|
||||
if (document.querySelector('.server-card.expanded')) {
|
||||
// A card is open - reload page preserving hash
|
||||
location.reload();
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}, 60000);
|
||||
|
||||
// Restore state on load
|
||||
restoreExpanded();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user