Dashboard script: key count and Next check card gone, earliest due in Attention, empty alert list without text (32.7 points 2-4)

This commit is contained in:
ai-bot committed 2026-10-16 17:16:58 +00:00
1 parent 340b14b747
commit 8372e4a678
1 file changed
+19 -26
+19 -26
View File
@@ -1,10 +1,7 @@
"use strict"; "use strict";
const keyList = document.querySelector("#key-list"); const keyList = document.querySelector("#key-list");
const keyCount = document.querySelector("#key-count");
const setupShape = document.querySelector("#setup-shape"); const setupShape = document.querySelector("#setup-shape");
const nextCheckTitle = document.querySelector("#next-check-title");
const nextCheckDetail = document.querySelector("#next-check-detail");
const overdueTitle = document.querySelector("#overdue-title"); const overdueTitle = document.querySelector("#overdue-title");
const overdueDetail = document.querySelector("#overdue-detail"); const overdueDetail = document.querySelector("#overdue-detail");
const alertsList = document.querySelector("#alerts-list"); const alertsList = document.querySelector("#alerts-list");
@@ -226,28 +223,28 @@ function renderSetupHeading(setup) {
} }
function renderSummary(status) { function renderSummary(status) {
const scheduled = status.filter((entry) => entry.next_check_due); // The Attention card is the only summary card now that the Next check card is
if (!scheduled.length) { // gone, so it carries the earliest due date when nothing is overdue
nextCheckTitle.textContent = "Not scheduled"; // (section 32.7 point 3).
nextCheckDetail.textContent = "No key has a next check date yet. Save a health check to schedule one.";
} else {
const earliest = scheduled.reduce((first, entry) => (
entry.next_check_due < first.next_check_due ? entry : first
));
nextCheckTitle.textContent = earliest.next_check_due;
nextCheckDetail.textContent = `Earliest next check, for key ${earliest.key_number}: ${earliest.name}.`;
}
const overdue = status.filter(isOverdue); const overdue = status.filter(isOverdue);
if (!overdue.length) { if (overdue.length) {
overdueTitle.textContent = "Nothing overdue";
overdueDetail.textContent = "No key has passed its next check date.";
} else {
overdueTitle.textContent = overdue.length === 1 ? "1 key overdue" : `${overdue.length} keys overdue`; overdueTitle.textContent = overdue.length === 1 ? "1 key overdue" : `${overdue.length} keys overdue`;
overdueDetail.textContent = overdue overdueDetail.textContent = overdue
.map((entry) => `Key ${entry.key_number}: ${entry.name} (due ${entry.next_check_due})`) .map((entry) => `Key ${entry.key_number}: ${entry.name} (due ${entry.next_check_due})`)
.join(" · "); .join(" · ");
return;
} }
overdueTitle.textContent = "Nothing overdue";
const scheduled = status.filter((entry) => entry.next_check_due);
if (!scheduled.length) {
overdueDetail.textContent = "No key has a next check date yet. Save a health check to schedule one.";
return;
}
const earliest = scheduled.reduce((first, entry) => (
entry.next_check_due < first.next_check_due ? entry : first
));
overdueDetail.textContent = `Earliest next check ${earliest.next_check_due}, for Key ${earliest.key_number}: ${earliest.name}.`;
} }
function createAlertItem(alert) { function createAlertItem(alert) {
@@ -453,15 +450,11 @@ function renderKeyCards() {
keyList.replaceChildren(createEmptyState(unavailableText( keyList.replaceChildren(createEmptyState(unavailableText(
"Key status is unavailable. Please reload the page or contact the service administrator.", "Key status is unavailable. Please reload the page or contact the service administrator.",
))); )));
keyCount.textContent = "Unavailable";
nextCheckTitle.textContent = "Unavailable";
nextCheckDetail.textContent = "The next check dates could not be loaded.";
overdueTitle.textContent = "Unavailable"; overdueTitle.textContent = "Unavailable";
overdueDetail.textContent = "The overdue keys could not be determined."; overdueDetail.textContent = "The overdue keys could not be determined.";
return; return;
} }
keyList.replaceChildren(...keyStatus.map(createKeyCard)); keyList.replaceChildren(...keyStatus.map(createKeyCard));
keyCount.textContent = `${keyStatus.length} keys`;
renderSummary(keyStatus); renderSummary(keyStatus);
} }
@@ -474,9 +467,9 @@ function renderAlerts() {
return; return;
} }
if (!alerts.length) { if (!alerts.length) {
alertsList.replaceChildren(createEmptyState( // An empty list carries no text of its own: the count beside the heading
"No alerts. No saved check has a result that needs follow-up.", // already says that there is nothing to follow up (section 32.7 point 4).
)); alertsList.replaceChildren();
alertCount.textContent = "No alerts"; alertCount.textContent = "No alerts";
return; return;
} }