Added EonaCat.LogStack.Status
Updated EonaCat.LogStack.LogClient to support EonaCat.LogStack.Status
This commit is contained in:
70
EonaCat.LogStack.Status/wwwroot/js/site.js
Normal file
70
EonaCat.LogStack.Status/wwwroot/js/site.js
Normal file
@@ -0,0 +1,70 @@
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
function updateClock() {
|
||||
const now = new Date();
|
||||
const h = String(now.getHours()).padStart(2, '0');
|
||||
const m = String(now.getMinutes()).padStart(2, '0');
|
||||
const s = String(now.getSeconds()).padStart(2, '0');
|
||||
const el = document.getElementById('clock');
|
||||
if (el) el.textContent = `${h}:${m}:${s}`;
|
||||
}
|
||||
updateClock();
|
||||
setInterval(updateClock, 1000);
|
||||
|
||||
function toggleSidebar() {
|
||||
document.getElementById('sidebar').classList.toggle('collapsed');
|
||||
}
|
||||
|
||||
function openModal(id) {
|
||||
document.getElementById(id).classList.add('open');
|
||||
}
|
||||
function closeModal(id) {
|
||||
document.getElementById(id).classList.remove('open');
|
||||
}
|
||||
|
||||
// Refresh dashboard every 30s
|
||||
if (document.body.dataset.autorefresh) {
|
||||
setTimeout(() => location.reload(), 30000);
|
||||
}
|
||||
|
||||
// Scroll to bottom
|
||||
function scrollLogsToBottom() {
|
||||
const el = document.getElementById('log-stream');
|
||||
if (el) el.scrollTop = el.scrollHeight;
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', scrollLogsToBottom);
|
||||
|
||||
// Filtering debounce
|
||||
(function() {
|
||||
const searchInput = document.getElementById('log-search');
|
||||
if (!searchInput) return;
|
||||
let timer;
|
||||
searchInput.addEventListener('input', function() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
const form = searchInput.closest('form');
|
||||
if (form) form.submit();
|
||||
}, 400);
|
||||
});
|
||||
})();
|
||||
|
||||
// Summary
|
||||
fetch('/api/status/summary')
|
||||
.then(r => r.json())
|
||||
.then(d => {
|
||||
const dot = document.getElementById('overall-dot');
|
||||
if (!dot) return;
|
||||
if (d.downCount > 0) dot.style.background = 'var(--down)';
|
||||
else if (d.warnCount > 0) dot.style.background = 'var(--warn)';
|
||||
else if (d.upCount > 0) dot.style.background = 'var(--up)';
|
||||
}).catch(() => {});
|
||||
|
||||
// Notifications
|
||||
function showToast(msg, type = 'info') {
|
||||
const toast = document.createElement('div');
|
||||
toast.className = `alert alert-${type}`;
|
||||
toast.style.cssText = 'position:fixed;bottom:20px;right:20px;z-index:9999;min-width:250px;animation:slideIn 0.3s ease';
|
||||
toast.textContent = msg;
|
||||
document.body.appendChild(toast);
|
||||
setTimeout(() => toast.remove(), 4000);
|
||||
}
|
||||
Reference in New Issue
Block a user