Polish device registry identity displays

This commit is contained in:
Wira Basalamah
2026-06-08 16:09:24 +07:00
parent 67dc286c1a
commit 4bbe3f6807
4 changed files with 48 additions and 12 deletions

View File

@ -212,7 +212,7 @@
</p>
<p class="text-body-md text-on-surface-variant flex items-center gap-1.5">
<span class="material-symbols-outlined text-sm">tag</span>
<span id="device-serial-number">SN: -</span>
<span id="device-serial-number">Code: -</span>
</p>
<p class="text-body-md text-on-surface-variant flex items-center gap-1.5">
<span class="material-symbols-outlined text-sm">schedule</span>
@ -405,6 +405,13 @@ Loading
</div>
<span class="material-symbols-outlined text-slate-300">chevron_right</span>
</button>
<button id="poweroff-device" class="w-full flex items-center justify-between p-3 border border-danger/20 bg-danger/5 rounded-lg hover:bg-danger/10 transition-all group">
<div class="flex items-center gap-3">
<span class="material-symbols-outlined text-danger">power_settings_new</span>
<span class="font-body-md font-bold text-danger">Power Off Device</span>
</div>
<span class="material-symbols-outlined text-danger/50">chevron_right</span>
</button>
<button id="update-device-firmware" class="w-full flex items-center justify-between p-3 border border-slate-200 rounded-lg hover:bg-slate-50 transition-all group">
<div class="flex items-center gap-3">
<span class="material-symbols-outlined text-on-surface-variant group-hover:text-primary">system_update</span>
@ -596,6 +603,7 @@ Copy Command
const calendarButton = document.getElementById("detail-calendar-button");
const copyPayloadButton = document.getElementById("copy-payload-stream");
const rebootButton = document.getElementById("reboot-device");
const poweroffButton = document.getElementById("poweroff-device");
const updateFirmwareButton = document.getElementById("update-device-firmware");
const unbindButton = document.getElementById("unbind-device");
const decommissionButton = document.getElementById("decommission-device");
@ -1327,11 +1335,12 @@ Copy Command
showingAllEvents = false;
}
const modelCode = device.device_code || device.code || device.serial_number || device.id || "Unknown Device";
setText(els.breadcrumbCode, modelCode);
setText(els.title, modelCode);
const serialNumber = device.serial_number || device.device_code || device.code || device.id || "Unknown Device";
const deviceCode = device.device_code || device.code || device.id || "-";
setText(els.breadcrumbCode, serialNumber);
setText(els.title, serialNumber);
setText(els.model, device.model || device.device_model || "Unknown model");
setText(els.serialNumber, `SN: ${device.serial_number || "-"}`);
setText(els.serialNumber, `Code: ${deviceCode}`);
setText(els.location, device.location || device.last_known_city || "Unknown");
const latest = Array.isArray(heartbeats) && heartbeats.length ? heartbeats[0] : null;
@ -1440,6 +1449,17 @@ Copy Command
viewAllEventsBtn.textContent = showingAllEvents ? "Show Recent Events" : "View All Events";
});
rebootButton?.addEventListener("click", () => sendDeviceCommand("device.reboot", { requested_from: "device_detail" }, rebootButton));
poweroffButton?.addEventListener("click", async () => {
const confirmed = await confirmAction({
title: "Power off device",
message: `This will send a power-off command to ${currentDevice?.serial_number || activeDeviceId || "this device"}. The device may stop reporting until manually powered on again.`,
buttonLabel: "Power Off"
});
if (!confirmed) {
return;
}
await sendDeviceCommand("device.poweroff", { requested_from: "device_detail" }, poweroffButton);
});
updateFirmwareButton?.addEventListener("click", () => sendDeviceCommand("firmware.update", {
requested_from: "device_detail",
target_version: currentDevice?.firmware_version || "latest"