From ed948bf27cf8bbf454d9894e496dbc03c6fb1e92 Mon Sep 17 00:00:00 2001 From: tab888 Date: Mon, 2 Feb 2026 07:26:04 +0800 Subject: [PATCH] add navigation bar to show dashboard and dva/dca pages --- templates/index.html | 45 +++++++++++++++++++++++++++++++++++++- templates/val_avg_cal.html | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 8b9362a..cdd4447 100644 --- a/templates/index.html +++ b/templates/index.html @@ -115,7 +115,31 @@ - +
@@ -289,6 +313,25 @@ if (loading) loading.style.display = 'none'; } } + // This checks if the Flask server is responding every 30 seconds + async function checkStatus() { + const indicator = document.getElementById('statusIndicator'); + try { + const response = await fetch('/api/summary'); // Or a dedicated /health endpoint + if (response.ok) { + indicator.innerHTML = '● Online'; + indicator.className = 'text-success'; + } else { + throw new Error(); + } + } catch (e) { + indicator.innerHTML = '● Offline'; + indicator.className = 'text-danger'; + } + } + + setInterval(checkStatus, 30000); + checkStatus(); // Initial check // --- 5. Initial Load --- window.addEventListener('load', loadData); diff --git a/templates/val_avg_cal.html b/templates/val_avg_cal.html index cdc6238..ba58bc5 100644 --- a/templates/val_avg_cal.html +++ b/templates/val_avg_cal.html @@ -29,6 +29,31 @@ +

🛠️ Value Averaging Strategy Analysis

@@ -433,6 +458,25 @@ function updateSyncBadge(dateString) { const wb = XLSX.utils.table_to_book(table); XLSX.writeFile(wb, "Investment_Backtest_Results.xlsx"); } + // This checks if the Flask server is responding every 30 seconds + async function checkStatus() { + const indicator = document.getElementById('statusIndicator'); + try { + const response = await fetch('/api/summary'); // Or a dedicated /health endpoint + if (response.ok) { + indicator.innerHTML = '● Online'; + indicator.className = 'text-success'; + } else { + throw new Error(); + } + } catch (e) { + indicator.innerHTML = '● Offline'; + indicator.className = 'text-danger'; + } + } + + setInterval(checkStatus, 30000); + checkStatus(); // Initial check function resetAll() { // 1. Reset Inputs to Defaults (Including Frequency)