Add per-server notes field and show hardware info on dashboard
This commit is contained in:
@@ -55,6 +55,13 @@
|
||||
</div>
|
||||
<div class="server-ip">{{ server.primary_ip or 'No IP' }}</div>
|
||||
<div class="server-os">{{ 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 %}
|
||||
{%- if cpu.get('cores') %} ({{ cpu.get('cores') }}c){% endif %}
|
||||
{%- if mem.get('total_mb') %} / {{ mem.get('total_mb', '')|format_mb }}{% endif -%}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if server.is_online %}
|
||||
<div class="usage-bars">
|
||||
@@ -96,6 +103,13 @@
|
||||
|
||||
<!-- Expanded Details -->
|
||||
<div class="card-details" style="display: none;">
|
||||
<div class="notes-section">
|
||||
<textarea class="notes-input"
|
||||
data-server-id="{{ server.id }}"
|
||||
placeholder="Add notes..."
|
||||
onclick="event.stopPropagation();"
|
||||
oninput="autoResizeNotes(this); debounceSaveNotes(this);">{{ server.notes or '' }}</textarea>
|
||||
</div>
|
||||
<div class="details-grid">
|
||||
<!-- System Info -->
|
||||
<div class="detail-section">
|
||||
@@ -170,6 +184,7 @@
|
||||
<tr class="table-header"><td>Interface</td><td>IPv4</td><td>IPv6</td><td>MAC</td><td>State</td><td>Speed</td><td>Driver</td></tr>
|
||||
{% set nets = d.get('net', []) if d.get('net') else [] %}
|
||||
{% for iface in nets %}
|
||||
{% if iface.get('ipv4') or iface.get('ipv6') %}
|
||||
<tr>
|
||||
<td>{{ iface.get('name', iface.get('_name', '-')) }}</td>
|
||||
<td>{{ iface.get('ipv4', '-') or '-' }}</td>
|
||||
@@ -179,6 +194,7 @@
|
||||
<td>{% if iface.get('speed_mbps') %}{{ iface.get('speed_mbps') }} Mbps{% else %}-{% endif %}</td>
|
||||
<td>{{ iface.get('driver', '-') or '-' }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
@@ -322,8 +338,32 @@
|
||||
if (!isOpen) {
|
||||
details.style.display = 'block';
|
||||
card.classList.add('expanded');
|
||||
// Auto-resize notes textarea
|
||||
const ta = details.querySelector('.notes-input');
|
||||
if (ta) autoResizeNotes(ta);
|
||||
}
|
||||
}
|
||||
|
||||
function autoResizeNotes(ta) {
|
||||
ta.style.height = 'auto';
|
||||
ta.style.height = ta.scrollHeight + 'px';
|
||||
}
|
||||
|
||||
let _notesTimers = {};
|
||||
function debounceSaveNotes(ta) {
|
||||
const id = ta.dataset.serverId;
|
||||
clearTimeout(_notesTimers[id]);
|
||||
_notesTimers[id] = setTimeout(() => saveNotes(ta), 800);
|
||||
}
|
||||
|
||||
function saveNotes(ta) {
|
||||
const id = ta.dataset.serverId;
|
||||
fetch('/api/servers/' + id + '/notes', {
|
||||
method: 'PUT',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({notes: ta.value})
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user