添加刷新按钮

This commit is contained in:
CN-JS-HuiBai
2026-04-06 23:13:50 +08:00
parent 1bfee2026f
commit c94b697319
4 changed files with 55 additions and 10 deletions

View File

@@ -110,6 +110,7 @@
partitionHeader: document.getElementById('partitionHeader'),
globeCard: document.getElementById('globeCard'),
btnExpandGlobe: document.getElementById('btnExpandGlobe'),
btnRefreshNetwork: document.getElementById('btnRefreshNetwork'),
// Footer & Filing
icpFilingInput: document.getElementById('icpFilingInput'),
psFilingInput: document.getElementById('psFilingInput'),
@@ -353,6 +354,25 @@
});
}
if (dom.btnRefreshNetwork) {
dom.btnRefreshNetwork.addEventListener('click', async () => {
const icon = dom.btnRefreshNetwork.querySelector('svg');
if (icon) icon.style.animation = 'spin 0.8s ease-in-out';
// Force refresh all Prometheus 24h data and overview
await Promise.all([
fetchNetworkHistory(true),
fetchMetrics(true)
]);
if (icon) {
setTimeout(() => {
icon.style.animation = '';
}, 800);
}
});
}
// Keyboard shortcut
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
@@ -693,9 +713,10 @@
}
// ---- Fetch Metrics ----
async function fetchMetrics() {
async function fetchMetrics(force = false) {
try {
const response = await fetch('/api/metrics/overview');
const url = `/api/metrics/overview${force ? '?force=true' : ''}`;
const response = await fetch(url);
const data = await response.json();
allServersData = data.servers || [];
updateDashboard(data);
@@ -1619,9 +1640,10 @@
};
// ---- Network History ----
async function fetchNetworkHistory() {
async function fetchNetworkHistory(force = false) {
try {
const response = await fetch('/api/metrics/network-history');
const url = `/api/metrics/network-history${force ? '?force=true' : ''}`;
const response = await fetch(url);
const data = await response.json();
networkChart.setData(data);
if (dom.trafficP95 && networkChart.p95) {