From c1dcfc5a37aa4f39fd86d394b35f08657a03f8b8 Mon Sep 17 00:00:00 2001 From: Radek Davidek Date: Fri, 27 Mar 2026 23:49:25 +0100 Subject: [PATCH] fixed dashboard --- java-api/META-INF/MANIFEST.MF | 5 + java-api/dashboard.html | 475 ++++++++++++++++++ java-api/pom.xml | 4 +- .../src/main/resources/application.properties | 4 +- java-api/src/main/resources/dashboard.html | 26 +- 5 files changed, 505 insertions(+), 9 deletions(-) create mode 100644 java-api/META-INF/MANIFEST.MF create mode 100644 java-api/dashboard.html diff --git a/java-api/META-INF/MANIFEST.MF b/java-api/META-INF/MANIFEST.MF new file mode 100644 index 0000000..abd8718 --- /dev/null +++ b/java-api/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Created-By: Maven JAR Plugin 3.4.1 +Build-Jdk-Spec: 21 +Main-Class: cz.kamma.processmonitor.Main + diff --git a/java-api/dashboard.html b/java-api/dashboard.html new file mode 100644 index 0000000..59ca4d2 --- /dev/null +++ b/java-api/dashboard.html @@ -0,0 +1,475 @@ + + + + + + Process Monitor - Dashboard + + + + + +
+
+

📊 Process Monitor Dashboard

+

Real-time monitoring of processes across machines

+
+ +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+

Celkem záznamů

+
-
+
+
+

Procesy UP

+
-
+
+
+

Procesy DOWN

+
-
+
+
+

Dostupnost

+
-
+
+
+ +
+
+

Stav procesů

+
+ +
+
+
+

Stavy podle strojů

+
+ +
+
+
+

Dostupnost v čase

+
+ +
+
+
+
+ + + + diff --git a/java-api/pom.xml b/java-api/pom.xml index 6c1aae1..dfea96b 100644 --- a/java-api/pom.xml +++ b/java-api/pom.xml @@ -6,8 +6,8 @@ process-monitor-api 0.1.0 - 15 - 15 + 11 + 11 UTF-8 diff --git a/java-api/src/main/resources/application.properties b/java-api/src/main/resources/application.properties index a666091..ce8867e 100644 --- a/java-api/src/main/resources/application.properties +++ b/java-api/src/main/resources/application.properties @@ -5,5 +5,5 @@ dashboard.apiKey=652f9h56gf32659twitf db.url=jdbc:mariadb://10.0.0.147:3306/process_monitor?useUnicode=true&characterEncoding=utf8 # Change these credentials before running. -db.user=process_monitor -db.password=process_monitor_secret +db.user=processmon +db.password=process621420mon diff --git a/java-api/src/main/resources/dashboard.html b/java-api/src/main/resources/dashboard.html index 0833a08..59ca4d2 100644 --- a/java-api/src/main/resources/dashboard.html +++ b/java-api/src/main/resources/dashboard.html @@ -244,6 +244,16 @@ let statusChart, machineChart, timelineChart; const apiKey = '%API_KEY%'; + function normalizeStatus(status) { + const normalized = status.toUpperCase(); + if (normalized === 'UP' || normalized === 'RUNNING' || normalized === 'ACTIVE' || normalized === 'OK') { + return 'UP'; + } else if (normalized === 'DOWN' || normalized === 'STOPPED' || normalized === 'INACTIVE' || normalized === 'ERROR' || normalized === 'FAILED') { + return 'DOWN'; + } + return normalized; + } + async function loadFilters() { try { const response = await axios.get('/api/data?type=filters&apiKey=' + encodeURIComponent(apiKey)); @@ -314,8 +324,8 @@ function updateStats(data) { const total = data.records.length; - const up = data.records.filter(r => r.status === 'UP').length; - const down = data.records.filter(r => r.status === 'DOWN').length; + const up = data.records.filter(r => normalizeStatus(r.status) === 'UP').length; + const down = data.records.filter(r => normalizeStatus(r.status) === 'DOWN').length; const availability = total > 0 ? ((up / total) * 100).toFixed(1) : 0; document.getElementById('statTotal').textContent = total; @@ -329,7 +339,8 @@ const statusCounts = {}; records.forEach(r => { - statusCounts[r.status] = (statusCounts[r.status] || 0) + 1; + const normalized = normalizeStatus(r.status); + statusCounts[normalized] = (statusCounts[normalized] || 0) + 1; }); if (statusChart) statusChart.destroy(); @@ -356,10 +367,15 @@ const statusByMachine = {}; records.forEach(r => { + const normalized = normalizeStatus(r.status); if (!statusByMachine[r.machine_name]) { statusByMachine[r.machine_name] = { UP: 0, DOWN: 0 }; } - statusByMachine[r.machine_name][r.status]++; + if (normalized === 'UP') { + statusByMachine[r.machine_name].UP++; + } else if (normalized === 'DOWN') { + statusByMachine[r.machine_name].DOWN++; + } }); if (machineChart) machineChart.destroy(); @@ -401,7 +417,7 @@ const upCounts = []; let upCount = 0; sortedRecords.forEach(r => { - if (r.status === 'UP') upCount++; + if (normalizeStatus(r.status) === 'UP') upCount++; upCounts.push(upCount); });