Merge pull request 'Eventanzeige: Events im Modal auf den aktuellen Tag filtern' (#101) from fds2610-bot/monitor:main into main
Reviewed-on: https://codeberg.org/fds2610/monitor/pulls/101
This commit is contained in:
commit
8f6af53bbd
3 changed files with 50 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ import {
|
||||||
formatEventLineText,
|
formatEventLineText,
|
||||||
truncateToWidth,
|
truncateToWidth,
|
||||||
buildEventModalContent,
|
buildEventModalContent,
|
||||||
|
filterEventsForToday,
|
||||||
buildSystemModalContent,
|
buildSystemModalContent,
|
||||||
buildKpiTiles,
|
buildKpiTiles,
|
||||||
buildKpiModalContent,
|
buildKpiModalContent,
|
||||||
|
|
@ -2386,7 +2387,7 @@ export function renderOfficeScene(container, data = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const wallGroup = renderMonitorWall(systems, events, displayKpis, {
|
const wallGroup = renderMonitorWall(systems, events, displayKpis, {
|
||||||
onEventsClick: () => openModal(buildEventModalContent(events), renderEventModalBody),
|
onEventsClick: () => openModal(buildEventModalContent(filterEventsForToday(events)), renderEventModalBody),
|
||||||
onSystemsClick: () => openModal(buildSystemModalContent(systems), renderSystemModalBody),
|
onSystemsClick: () => openModal(buildSystemModalContent(systems), renderSystemModalBody),
|
||||||
// Issue #70: die aktuell gezeigten Systeme wandern mit ins Modal - daran erkennt es,
|
// Issue #70: die aktuell gezeigten Systeme wandern mit ins Modal - daran erkennt es,
|
||||||
// welche Kacheln zu keinem konfigurierten Host mehr gehoeren.
|
// welche Kacheln zu keinem konfigurierten Host mehr gehoeren.
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,31 @@ export function truncateToWidth(value, availableWidth, charWidth = EVENT_LINE_CH
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inhaltsmodell fuer das Event-Monitor-Modal: volle Liste (kein MAX_EVENT_LINES-Limit).
|
* Filtert Events auf den aktuellen Kalendertag (Issue #100: die volle Eventliste im Modal
|
||||||
|
* lief sonst unbegrenzt zurueck und wurde dadurch unuebersichtlich lang). "Aktueller Tag"
|
||||||
|
* meint wie bei formatEventTime() die lokale Zeitzone des Browsers (F16), nicht UTC.
|
||||||
|
*
|
||||||
|
* @param {Array<{occurred_at: string}>} events
|
||||||
|
* @param {Date} [now]
|
||||||
|
* @returns {Array<object>}
|
||||||
|
*/
|
||||||
|
export function filterEventsForToday(events = [], now = new Date()) {
|
||||||
|
return events.filter((event) => {
|
||||||
|
const occurredAt = new Date(event.occurred_at);
|
||||||
|
if (Number.isNaN(occurredAt.getTime())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
occurredAt.getFullYear() === now.getFullYear() &&
|
||||||
|
occurredAt.getMonth() === now.getMonth() &&
|
||||||
|
occurredAt.getDate() === now.getDate()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inhaltsmodell fuer das Event-Monitor-Modal: volle Liste des aktuellen Tages (kein
|
||||||
|
* MAX_EVENT_LINES-Limit, aber auf heute gefiltert, siehe filterEventsForToday()).
|
||||||
*
|
*
|
||||||
* @param {Array<object>} events
|
* @param {Array<object>} events
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import {
|
||||||
truncateToWidth,
|
truncateToWidth,
|
||||||
EVENT_LINE_CHAR_WIDTH,
|
EVENT_LINE_CHAR_WIDTH,
|
||||||
buildEventModalContent,
|
buildEventModalContent,
|
||||||
|
filterEventsForToday,
|
||||||
buildSystemModalContent,
|
buildSystemModalContent,
|
||||||
systemsWithoutHostConfig,
|
systemsWithoutHostConfig,
|
||||||
formatSystemCheckTime,
|
formatSystemCheckTime,
|
||||||
|
|
@ -350,6 +351,28 @@ test("buildEventModalContent zeigt die volle Liste (kein MAX_EVENT_LINES-Limit)"
|
||||||
assert.equal(content.items[0].systemId, "srv1");
|
assert.equal(content.items[0].systemId, "srv1");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("filterEventsForToday behaelt nur Events vom aktuellen Kalendertag (lokale Zeitzone, F16)", () => {
|
||||||
|
const now = new Date("2026-07-27T10:00:00");
|
||||||
|
const events = [
|
||||||
|
{ id: "heute-frueh", occurred_at: "2026-07-27T00:05:00" },
|
||||||
|
{ id: "heute-spaet", occurred_at: "2026-07-27T23:55:00" },
|
||||||
|
{ id: "gestern", occurred_at: "2026-07-26T23:59:00" },
|
||||||
|
{ id: "morgen", occurred_at: "2026-07-28T00:00:00" },
|
||||||
|
{ id: "ungueltig", occurred_at: "nicht-valide" },
|
||||||
|
];
|
||||||
|
const filtered = filterEventsForToday(events, now);
|
||||||
|
assert.deepEqual(
|
||||||
|
filtered.map((e) => e.id),
|
||||||
|
["heute-frueh", "heute-spaet"]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("filterEventsForToday liefert eine leere Liste, wenn kein Event von heute ist", () => {
|
||||||
|
const now = new Date("2026-07-27T10:00:00");
|
||||||
|
const events = [{ id: "gestern", occurred_at: "2026-07-26T10:00:00" }];
|
||||||
|
assert.deepEqual(filterEventsForToday(events, now), []);
|
||||||
|
});
|
||||||
|
|
||||||
test("buildSystemModalContent uebernimmt Status/Detail je System", () => {
|
test("buildSystemModalContent uebernimmt Status/Detail je System", () => {
|
||||||
const content = buildSystemModalContent([
|
const content = buildSystemModalContent([
|
||||||
{ id: "srv1", name: "Webserver", status: "ok", type: "host", detail: null, last_check_at: "t" },
|
{ id: "srv1", name: "Webserver", status: "ok", type: "host", detail: null, last_check_at: "t" },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue