Add Loki and Sentinel utility classes for web API endpoints

- Implemented LokiUtils class with GET and POST endpoints for managing scripts, jobs, and payloads.
- Added SentinelUtils class with GET and POST endpoints for managing events, rules, devices, and notifications.
- Both classes include error handling and JSON response formatting.
This commit is contained in:
infinition
2026-03-14 22:33:10 +01:00
parent eb20b168a6
commit aac77a3e76
525 changed files with 29400 additions and 13136 deletions

View File

@@ -41,6 +41,8 @@ const LEVEL_CLASSES = {
let evtSource = null;
let reconnectCount = 0;
let reconnectTimer = null;
let healthyMessageCount = 0;
const HEALTHY_THRESHOLD = 5; // messages needed before resetting reconnect counter
let isUserScrolling = false;
let autoScroll = true;
@@ -364,7 +366,11 @@ function connectSSE() {
evtSource = new EventSource('/stream_logs');
evtSource.onmessage = (evt) => {
reconnectCount = 0; // healthy connection resets counter
// Only reset reconnect counter after sustained healthy connection
healthyMessageCount++;
if (healthyMessageCount >= HEALTHY_THRESHOLD) {
reconnectCount = 0;
}
const raw = evt.data;
if (!raw) return;
@@ -405,6 +411,7 @@ function connectSSE() {
};
evtSource.onerror = () => {
healthyMessageCount = 0;
disconnectSSE();
scheduleReconnect();
};