dashboard: rebuild the page on Bootstrap 5 + jQuery + Chart.js + Font Awesome

One card per timeframe (M5/M15/H1/H4) in a Bootstrap column grid, above a
direction board that charts every timeframe's score as a diverging bar.
Each card carries its own indicator-vote chart, and the newswire gets a
headline-tone bar. Bootstrap Icons and the hand-rolled CSS gauges are gone;
dashboard.css is now the token set plus the app-specific pieces only.

Chart marks use a diverging pair validated on this surface (#0d9f7a /
#e8503a: lightness band, chroma floor, colour-vision separation, contrast).
Lighter steps of the same two hues carry the colour where it has to work as
text, and direction never travels as colour alone -- an arrow icon and the
word ride with it.

Behaviour is unchanged: same snapshot.json / news.json contract, the same
coordinated refresh loop (boundary poll, 60 s fallback, 15 s retry,
in-flight guard, stale-snapshot guard), per-timeframe change detection,
modal state preservation, HTML escaping, the news_summary.php contract and
the warming / scan-failed / weekend states. Nothing on the signal path is
touched, so no book moves.

Verified headlessly against a fixture replayed through the real signal code
(wide / laptop / tablet / mobile, both dialogs, every degraded state): no
console errors, html-validate clean.

Suite 553 -- the old static-UI test splits into one that pins the CDN stack
and one that pins a card and a chart per timeframe against
dashboard_publisher.DASHBOARD_TFS.
This commit is contained in:
Harwinder Sekhon
2026-09-21 19:25:52 -04:00
parent 32ad73c59a
commit 3005e57367
5 changed files with 1638 additions and 892 deletions
+1 -1
View File
@@ -221,7 +221,7 @@ Arrows show who imports whom (generated from the code on 2026-09-15).
| `main.py` | Command-line signal report (`--detail`, `--json`, `--panel`) | pair_signals, signal_aggregator, agent_panel, violent_watch, app_config | dashboard_publisher (formatting helpers) | | `main.py` | Command-line signal report (`--detail`, `--json`, `--panel`) | pair_signals, signal_aggregator, agent_panel, violent_watch, app_config | dashboard_publisher (formatting helpers) |
| `telegram_bot.py` | Owner-locked bot: candle-close scan loops, alerts, breach monitor, heads-ups, `/scan /status /news /autoscan /cache /clearcache /help /start` | pair_signals, signal_aggregator, providers, agent_panel, violent_watch, news_engine, llm_client, signal_log, app_config | nobody (a top-level process) | | `telegram_bot.py` | Owner-locked bot: candle-close scan loops, alerts, breach monitor, heads-ups, `/scan /status /news /autoscan /cache /clearcache /help /start` | pair_signals, signal_aggregator, providers, agent_panel, violent_watch, news_engine, llm_client, signal_log, app_config | nobody (a top-level process) |
| `dashboard_publisher.py` | Static web publisher daemon; writes JSON + HTML into the Apache folder. Its own process with its own news caches and its own DeepSeek daily cap. Never writes `signals.db` or `newsdata.db`: `main()` calls `app_config.set_db_writes_for_process(False)`, a process-wide switch every SQLite writer honours (owner decision 2026-09-17; the bot is the single writer because the dashboard is not always running) | pair_signals, providers, main, agent_panel, violent_watch, news_engine, app_config | nobody. Hard rule: never imports and is never imported by `telegram_bot` (test-enforced) | | `dashboard_publisher.py` | Static web publisher daemon; writes JSON + HTML into the Apache folder. Its own process with its own news caches and its own DeepSeek daily cap. Never writes `signals.db` or `newsdata.db`: `main()` calls `app_config.set_db_writes_for_process(False)`, a process-wide switch every SQLite writer honours (owner decision 2026-09-17; the bot is the single writer because the dashboard is not always running) | pair_signals, providers, main, agent_panel, violent_watch, news_engine, app_config | nobody. Hard rule: never imports and is never imported by `telegram_bot` (test-enforced) |
| `static/dashboard.html`, `.css`, `.js` | The public dashboard page (reads `snapshot.json` / `news.json`) | | copied by the publisher | | `static/dashboard.html`, `.css`, `.js` | The public dashboard page (reads `snapshot.json` / `news.json`). Bootstrap 5 + jQuery + Chart.js + Font Awesome straight from a CDN, no build step; M5/M15/H1/H4 each get a card in one column grid, with a diverging Chart.js bar chart for direction and one per card for the indicator votes | | copied by the publisher |
| `static/news_summary.php` | The one dynamic endpoint: on-demand DeepSeek summary for a clicked headline, whitelist-gated against `news.json`, own fail-closed daily cap, key read from `/etc/gold-dashboard/deepseek.key` (never repo config) | | installed by the publisher | | `static/news_summary.php` | The one dynamic endpoint: on-demand DeepSeek summary for a clicked headline, whitelist-gated against `news.json`, own fail-closed daily cap, key read from `/etc/gold-dashboard/deepseek.key` (never repo config) | | installed by the publisher |
| `docs/user_guide.html`, `docs/beginner_guide.html` | Human guides. Keep them in sync with signal behaviour. There are no PDF builds | | | | `docs/user_guide.html`, `docs/beginner_guide.html` | Human guides. Keep them in sync with signal behaviour. There are no PDF builds | | |
+607 -249
View File
@@ -1,351 +1,709 @@
/* Gold Desk — XAU/USD dashboard styles /* Gold Desk — XAU/USD dashboard styles
* *
* Builds on Bootstrap 5.3 color modes (data-bs-theme). Only app-specific * Bootstrap 5.3 supplies layout, cards, tables, badges, alerts, modals and
* tokens and components live here; layout, typography, tables, badges, * the form switch; this file supplies the desk: the token set, the sticky
* cards, alerts, modals, etc. come from Bootstrap. * ticker bar, the direction board, the four timeframe instruments and the
* chart surfaces Chart.js draws onto.
*
* Colour notes
* Dark only (owner decision 2026-08-16): dark ground, white text, red and
* green reserved for direction.
* --up / --down are the CHART mark colours: a diverging pair validated on
* this surface (lightness band, chroma floor, colour-vision separation,
* contrast). --up-text / --down-text are the lighter steps of the same two
* hues, used wherever the colour has to work as text. Direction is never
* colour alone — an arrow icon and the word BUY or SELL ride with it.
*/ */
:root { :root {
--xau-font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
--xau-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, Menlo, monospace; --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, Menlo, monospace;
--xau-gold: #f5b301;
--desk-bg: #0c0f13;
--panel: #12161c;
--panel-2: #171d25;
--rule: rgba(255, 255, 255, 0.10);
--rule-soft: rgba(255, 255, 255, 0.06);
--gold: #f5b301;
--gold-wash: rgba(245, 179, 1, 0.12);
--up: #0d9f7a;
--down: #e8503a;
--flat: #6b7a8d;
--up-text: #2fd6a3;
--down-text: #ff7d66;
--up-wash: rgba(13, 159, 122, 0.16);
--down-wash: rgba(232, 80, 58, 0.16);
--grid: rgba(255, 255, 255, 0.07);
--zero: rgba(255, 255, 255, 0.30);
--axis: rgba(255, 255, 255, 0.64);
} }
/* Forced dark theme (owner decision 2026-08-16): dark background, pure
* white text (no gray), vivid red/green for data accents. Loaded after
* Bootstrap so these overrides win. */
[data-bs-theme="dark"] { [data-bs-theme="dark"] {
--bs-body-bg: #0a0e14; --bs-body-bg: var(--desk-bg);
--bs-secondary-bg: #111823;
--bs-tertiary-bg: #0e141d;
--bs-body-color: #ffffff; --bs-body-color: #ffffff;
--bs-emphasis-color: #ffffff; --bs-emphasis-color: #ffffff;
--bs-heading-color: #ffffff; --bs-heading-color: #ffffff;
--bs-secondary-color: rgba(255, 255, 255, 0.92); --bs-secondary-color: rgba(255, 255, 255, 0.92);
--bs-tertiary-color: rgba(255, 255, 255, 0.8); --bs-tertiary-color: rgba(255, 255, 255, 0.78);
--bs-border-color: rgba(255, 255, 255, 0.14); --bs-secondary-bg: var(--panel-2);
--bs-card-bg: #0e141d; --bs-tertiary-bg: var(--panel-2);
--bs-card-border-color: rgba(255, 255, 255, 0.12); --bs-border-color: var(--rule);
--bs-modal-bg: #0e141d; --bs-card-bg: var(--panel);
--bs-success: #22c55e; --bs-card-border-color: var(--rule);
--bs-success-rgb: 34, 197, 94; --bs-modal-bg: var(--panel);
--bs-success-text-emphasis: #4ade80; --bs-border-radius: 0.5rem;
--bs-success-bg-subtle: rgba(34, 197, 94, 0.16); --bs-primary: var(--gold);
--bs-success-border-subtle: rgba(34, 197, 94, 0.45); --bs-primary-rgb: 245, 179, 1;
--bs-danger: #ef4444; --bs-success: #0d9f7a;
--bs-danger-rgb: 239, 68, 68; --bs-success-rgb: 13, 159, 122;
--bs-danger-text-emphasis: #f87171; --bs-success-text-emphasis: var(--up-text);
--bs-danger-bg-subtle: rgba(239, 68, 68, 0.16); --bs-success-bg-subtle: var(--up-wash);
--bs-danger-border-subtle: rgba(239, 68, 68, 0.45); --bs-success-border-subtle: rgba(13, 159, 122, 0.45);
--bs-danger: #e8503a;
--bs-danger-rgb: 232, 80, 58;
--bs-danger-text-emphasis: var(--down-text);
--bs-danger-bg-subtle: var(--down-wash);
--bs-danger-border-subtle: rgba(232, 80, 58, 0.45);
--bs-warning: #e9a23b;
--bs-warning-rgb: 233, 162, 59;
--bs-link-color: var(--gold);
--bs-link-hover-color: #ffca3f;
} }
html, body { html, body {
font-family: var(--xau-font-sans); background: var(--desk-bg);
letter-spacing: -0.005em; color: #fff;
font-family: var(--sans);
font-size: 0.9375rem;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
} }
.num, .xau-price, .xau-symbol { h1, h2, h3, h4, h5 { font-weight: 600; }
font-family: var(--xau-font-mono);
.num {
font-family: var(--mono);
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
font-feature-settings: "zero" 1;
} }
.xau-symbol { .up { color: var(--up-text); }
font-size: 0.95rem; .down { color: var(--down-text); }
font-weight: 700; .flat { color: rgba(255, 255, 255, 0.72); }
letter-spacing: 0.08em;
color: var(--xau-gold); .sig-buy { --edge: var(--up); --edge-text: var(--up-text); --edge-wash: var(--up-wash); }
.sig-sell { --edge: var(--down); --edge-text: var(--down-text); --edge-wash: var(--down-wash); }
.sig-neutral { --edge: var(--flat); --edge-text: rgba(255, 255, 255, 0.8); --edge-wash: rgba(255, 255, 255, 0.05); }
.desk-shell {
width: 100%;
max-width: 1560px;
margin: 0 auto;
padding: 0 1rem;
} }
.xau-price { /* ── ticker bar ────────────────────────────────────────────────── */
.desk-bar {
background: rgba(12, 15, 19, 0.94);
backdrop-filter: blur(8px);
border-bottom: 1px solid var(--rule);
padding: 0.55rem 0;
}
.desk-mark { color: var(--gold); font-size: 1rem; }
.desk-symbol {
font-family: var(--mono);
font-weight: 600;
letter-spacing: 0.06em;
color: var(--gold);
font-size: 0.9rem;
}
.desk-price {
font-size: 1.6rem;
font-weight: 600;
line-height: 1; line-height: 1;
color: #ffffff;
} }
.desk-rail { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.rail-chip {
display: inline-flex;
align-items: baseline;
gap: 0.35rem;
border: 1px solid var(--rule);
border-left: 2px solid var(--edge, var(--flat));
border-radius: 0.3rem;
background: var(--panel);
color: #fff;
font-family: var(--mono);
font-size: 0.78rem;
padding: 0.2rem 0.45rem;
}
.rail-chip:hover { background: var(--panel-2); }
.rail-chip .rail-tf { font-weight: 600; }
.rail-chip .rail-score { color: var(--edge-text); }
.desk-status {
display: flex;
align-items: center;
gap: 1rem;
font-size: 0.8rem;
color: var(--bs-secondary-color);
}
.desk-meta { white-space: nowrap; }
.desk-meta i { opacity: 0.55; margin-right: 0.25rem; }
.desk-meta.is-stale { color: var(--bs-warning); font-weight: 600; }
.live-dot { .live-dot {
display: inline-block; display: inline-block;
width: 8px; width: 7px;
height: 8px; height: 7px;
border-radius: 50%; border-radius: 50%;
background: var(--bs-success); background: var(--up-text);
margin-right: 5px; margin-right: 0.4rem;
animation: pulse 2.4s ease-in-out infinite; animation: pulse 2.4s ease-in-out infinite;
} }
.live-dot.closed { .live-dot.closed { background: var(--bs-warning); animation: none; }
background: var(--bs-warning);
animation: none; @keyframes pulse { 50% { opacity: 0.3; } }
/* ── direction board ───────────────────────────────────────────── */
.board {
background: var(--panel);
border: 1px solid var(--rule);
border-radius: 0.6rem;
overflow: hidden;
} }
@keyframes pulse { .board-read {
50% { opacity: 0.35; } display: flex;
flex-direction: column;
padding: 1.5rem 1.6rem;
border-right: 1px solid var(--rule);
} }
/* signal-coloured accents */ .board-headline {
.sig-buy { --xau-signal: var(--bs-success); } font-size: clamp(1.5rem, 2.4vw, 2rem);
.sig-sell { --xau-signal: var(--bs-danger); } font-weight: 600;
.sig-neutral { --xau-signal: var(--bs-secondary); } line-height: 1.15;
margin-bottom: 0.5rem;
.border-signal { max-width: 22ch;
border-left: 3px solid var(--xau-signal, var(--bs-secondary)) !important;
} }
.text-signal { .board-sub {
color: var(--xau-signal, var(--bs-secondary)) !important; color: var(--bs-secondary-color);
max-width: 46ch;
margin-bottom: 1.1rem;
} }
.board-stats {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 0.75rem;
margin-top: auto;
border-top: 1px solid var(--rule);
padding-top: 0.9rem;
}
.board-stats .k {
display: block;
font-size: 0.72rem;
color: rgba(255, 255, 255, 0.7);
margin-bottom: 0.15rem;
}
.board-stats .v { font-size: 1.05rem; font-weight: 600; }
.board-stats .v small { font-weight: 400; font-size: 0.78rem; color: rgba(255, 255, 255, 0.7); }
.board-plot { padding: 1.5rem 1.6rem; }
.plot-title { font-size: 0.95rem; margin-bottom: 0.75rem; }
.plot-note {
font-size: 0.78rem;
color: rgba(255, 255, 255, 0.72);
margin: 0.6rem 0 0;
max-width: 62ch;
}
.chart-wrap { position: relative; }
.chart-direction { height: 190px; }
.chart-ind { height: 158px; margin-bottom: 0.9rem; }
.chart-tone { height: 58px; }
/* ── news voice inside the board ───────────────────────────────── */
.board-news {
border-left: 2px solid var(--gold);
padding-left: 0.85rem;
margin-bottom: 1.2rem;
}
.context-text {
margin: 0 0 0.5rem;
color: var(--bs-secondary-color);
font-size: 0.85rem;
max-width: 60ch;
}
.context-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
display: inline-flex;
align-items: center;
gap: 0.3rem;
font-size: 0.75rem;
padding: 0.2rem 0.5rem;
border-radius: 0.3rem;
border: 1px solid var(--rule);
background: var(--panel-2);
color: var(--bs-secondary-color);
white-space: nowrap;
}
.chip i { opacity: 0.7; }
.chip .num { font-weight: 600; }
.chip-up { border-color: rgba(13, 159, 122, 0.45); background: var(--up-wash); color: var(--up-text); }
.chip-down { border-color: rgba(232, 80, 58, 0.45); background: var(--down-wash); color: var(--down-text); }
.chip-warn { border-color: rgba(233, 162, 59, 0.5); background: rgba(233, 162, 59, 0.14); color: #ffc46b; }
.chip-gold { border-color: rgba(245, 179, 1, 0.5); background: var(--gold-wash); color: var(--gold); }
/* ── section headings ──────────────────────────────────────────── */
.sec-head {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 0.6rem;
margin-bottom: 0.85rem;
}
.sec-title { font-size: 1.05rem; margin: 0; }
.sec-note { font-size: 0.8rem; color: rgba(255, 255, 255, 0.72); }
/* ── timeframe instruments ─────────────────────────────────────── */
.tf-card {
height: 100%;
overflow: hidden;
background: var(--panel);
scroll-margin-top: 5.5rem;
}
.tf-card.is-target { outline: 2px solid var(--gold); outline-offset: 1px; }
.tf-card .card-body { padding: 0.95rem 1.05rem 0.6rem; }
.tf-edge { height: 3px; background: var(--edge, var(--flat)); }
.tf-head { display: flex; align-items: baseline; gap: 0.45rem; margin-bottom: 0.55rem; }
.tf-name { .tf-name {
font-family: var(--xau-font-mono); font-family: var(--mono);
font-weight: 700;
font-size: 1.1rem; font-size: 1.1rem;
color: var(--bs-primary); font-weight: 600;
letter-spacing: 0.05em; letter-spacing: 0.04em;
margin: 0;
color: var(--gold);
} }
.tf-selector { .tf-long { font-size: 0.75rem; color: rgba(255, 255, 255, 0.7); }
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 0.5rem;
margin-bottom: 0.75rem;
}
.tf-select { .tf-clock { font-size: 0.75rem; color: rgba(255, 255, 255, 0.78); white-space: nowrap; }
min-width: 0; .tf-clock i { opacity: 0.55; margin-right: 0.2rem; }
padding: 0.7rem 0.8rem;
border: 1px solid var(--bs-border-color);
border-radius: var(--bs-border-radius);
background: var(--bs-tertiary-bg);
color: var(--bs-body-color);
text-align: left;
transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.tf-select:hover { .tf-signal {
border-color: rgba(var(--bs-primary-rgb), 0.65);
}
.tf-select[aria-pressed="true"] {
border-color: var(--xau-gold);
background: rgba(245, 179, 1, 0.09);
box-shadow: inset 0 0 0 1px rgba(245, 179, 1, 0.16);
}
.tf-select .tf-name {
font-size: 1rem;
}
.workspace-card {
overflow: hidden;
}
.workspace-signal {
font-family: var(--xau-font-mono);
font-size: clamp(1.55rem, 3vw, 2.35rem);
font-weight: 700;
letter-spacing: 0.03em;
line-height: 1;
}
.workspace-meta {
min-width: 0;
}
.workspace-reasons > div + div {
margin-top: 0.35rem;
}
/* score bar: zero-centered diverging with midpoint tick */
.scorebar {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 0.75rem; gap: 0.5rem;
font-size: 1.35rem;
font-weight: 600;
line-height: 1.1;
color: var(--edge-text, #fff);
} }
.scorebar .gauge-container { .tf-signal .fa-solid { font-size: 1.05rem; }
.grade {
font-family: var(--mono);
font-size: 0.72rem;
font-weight: 600;
padding: 0.1rem 0.4rem;
border-radius: 0.25rem;
border: 1px solid var(--rule);
color: rgba(255, 255, 255, 0.85);
align-self: center;
}
.grade.grade-high { border-color: rgba(245, 179, 1, 0.55); background: var(--gold-wash); color: var(--gold); }
.tf-action {
font-size: 0.82rem;
color: var(--bs-secondary-color);
margin: 0.35rem 0 0.8rem;
min-height: 1.1rem;
}
.tf-readouts {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
margin-bottom: 0.8rem;
}
.readout-k { display: block; font-size: 0.72rem; color: rgba(255, 255, 255, 0.7); }
.readout-v { font-size: 1.15rem; font-weight: 600; }
.meter {
position: relative; position: relative;
flex: 1; display: block;
min-width: 60px; height: 5px;
height: 10px; margin-top: 0.35rem;
border-radius: 5px; border-radius: 3px;
background: var(--bs-secondary-bg); background: rgba(255, 255, 255, 0.08);
overflow: hidden; overflow: hidden;
} }
.scorebar .gauge-container::after { .meter::after {
content: ""; content: "";
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 0; top: 0;
bottom: 0; bottom: 0;
width: 2px; width: 1px;
background: var(--bs-secondary); background: var(--zero);
transform: translateX(-1px);
} }
.scorebar .fill { .meter i {
position: absolute; position: absolute;
top: 0; top: 0;
bottom: 0; bottom: 0;
border-radius: 4px; border-radius: 3px;
width: var(--score-width);
transition: width 0.25s ease; transition: width 0.25s ease;
} }
.scorebar .fill.pos { .meter i.pos { left: 50%; background: var(--up); }
left: 50%; .meter i.neg { right: 50%; background: var(--down); }
background: var(--bs-success);
}
.scorebar .fill.neg { .meter-linear::after { display: none; }
right: 50%; .meter-linear i { left: 0; background: rgba(255, 255, 255, 0.55); }
background: var(--bs-danger);
}
.scorebar .val { .tf-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.9rem; }
width: 58px; .tf-chips .chip { font-size: 0.72rem; padding: 0.15rem 0.4rem; }
text-align: right;
font-size: 0.95rem;
font-weight: 500;
}
.scorebar .lbl { .tf-sub {
font-size: 0.8rem; font-size: 0.78rem;
color: var(--bs-secondary);
width: 44px;
}
/* rail chips in hero */
.rail-chip {
border: 1px solid var(--bs-border-color);
border-radius: var(--bs-border-radius);
background: var(--bs-tertiary-bg);
color: var(--bs-body-color);
font-family: var(--xau-font-mono);
font-size: 0.9rem;
line-height: 1.3;
padding: 0.3rem 0.5rem;
}
.rail-chip:hover, .rail-chip[aria-current="true"] {
border-color: var(--xau-gold);
}
.rail-chip:focus-visible, .tf-select:focus-visible, .wire-item:focus-visible,
.cal-event:focus-visible {
outline: 2px solid var(--xau-gold);
outline-offset: 2px;
}
/* detail dialog sections */
.d-stat .k {
display: block;
font-size: 0.7rem;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--bs-secondary);
font-weight: 600; font-weight: 600;
color: rgba(255, 255, 255, 0.82);
margin-bottom: 0.4rem;
} }
.d-stat .v { /* trade plan */
font-size: 1.15rem; .plan {
font-weight: 600; border: 1px solid var(--rule);
border-left: 2px solid var(--edge, var(--flat));
border-radius: 0.4rem;
background: var(--panel-2);
padding: 0.6rem 0.7rem;
} }
.d-table { .plan-head {
font-size: 0.9rem;
}
.detail-table {
overflow-x: auto;
}
.d-table .ind-k {
font-family: var(--xau-font-mono);
font-weight: 600;
white-space: nowrap;
}
.wbar {
display: block;
height: 4px;
border-radius: 2px;
background: var(--bs-secondary-bg);
margin-top: 3px;
}
.wbar > i {
display: block;
height: 100%;
border-radius: 2px;
background: var(--bs-primary);
}
/* news */
.wire-item {
display: flex; display: flex;
width: 100%; align-items: baseline;
border: 0; gap: 0.4rem;
border-radius: var(--bs-border-radius); font-size: 0.82rem;
background: transparent; font-weight: 600;
color: inherit; color: var(--edge-text);
cursor: pointer; margin-bottom: 0.5rem;
font: inherit;
text-align: start;
} }
.wire-item:hover { .plan-strategy {
background: rgba(var(--bs-primary-rgb), 0.08); font-family: var(--mono);
font-size: 0.7rem;
font-weight: 400;
color: rgba(255, 255, 255, 0.7);
} }
.plan-rr { margin-left: auto; font-family: var(--mono); font-size: 0.75rem; color: rgba(255, 255, 255, 0.85); }
/* Two columns in a card, four across the wider dialog — never three,
which would strand Target 2 on a row of its own. */
.plan-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.35rem 1.25rem;
margin: 0;
}
@media (min-width: 768px) {
.d-sec .plan-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.plan-grid > div { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.plan-grid dt { font-size: 0.75rem; font-weight: 400; color: rgba(255, 255, 255, 0.75); }
.plan-grid dt i { width: 0.9rem; opacity: 0.65; margin-right: 0.3rem; }
.plan-grid dd { margin: 0; font-family: var(--mono); font-size: 0.85rem; font-weight: 500; }
.plan-trail {
margin-top: 0.5rem;
padding-top: 0.45rem;
border-top: 1px solid var(--rule-soft);
font-size: 0.74rem;
color: rgba(255, 255, 255, 0.75);
}
.plan-empty {
border-left-color: var(--rule);
color: rgba(255, 255, 255, 0.75);
font-size: 0.8rem;
}
.tf-flags { margin-top: 0.7rem; display: grid; gap: 0.25rem; font-size: 0.76rem; }
.tf-flags i { width: 0.9rem; margin-right: 0.25rem; }
.tf-flags .flag-warn { color: #ffc46b; }
.tf-flags .flag-watch { color: var(--gold); font-weight: 500; }
.tf-card .card-footer {
display: flex;
align-items: center;
gap: 0.6rem;
background: transparent;
border-top: 1px solid var(--rule-soft);
padding: 0.5rem 1.05rem;
}
.tf-scanned { margin-left: auto; font-size: 0.72rem; color: rgba(255, 255, 255, 0.68); }
.btn-desk {
border: 1px solid var(--rule);
color: #fff;
background: var(--panel-2);
font-size: 0.78rem;
}
.btn-desk:hover { border-color: var(--gold); color: var(--gold); background: var(--panel-2); }
.btn-desk i { margin-right: 0.3rem; opacity: 0.8; }
.tf-empty {
padding: 1.6rem 0.4rem 2rem;
text-align: center;
color: rgba(255, 255, 255, 0.78);
font-size: 0.85rem;
}
.tf-empty i { display: block; font-size: 1.4rem; opacity: 0.5; margin-bottom: 0.5rem; }
/* ── calendar + wire ───────────────────────────────────────────── */
.card-head {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 0.6rem;
margin-bottom: 0.8rem;
}
.card-title { font-size: 0.95rem; margin: 0; }
.card-title i { color: var(--gold); margin-right: 0.45rem; }
.card-note { font-size: 0.75rem; color: rgba(255, 255, 255, 0.7); }
.form-check-label { font-size: 0.78rem; }
.form-switch .form-check-input:checked { background-color: var(--gold); border-color: var(--gold); }
.form-check-input:focus { box-shadow: none; border-color: var(--gold); }
/* The calendar fills whatever height the row settles on, then scrolls. */
.card-body:has(.cal-scroll) { display: flex; flex-direction: column; }
.cal-scroll { flex: 1 1 auto; max-height: 30rem; overflow-y: auto; }
.cal-table { font-size: 0.82rem; margin-bottom: 0; }
.cal-table thead th {
position: sticky;
top: 0;
z-index: 1;
background: var(--panel);
font-size: 0.72rem;
font-weight: 500;
color: rgba(255, 255, 255, 0.7);
border-bottom: 1px solid var(--rule);
}
.cal-table td { border-color: var(--rule-soft); }
.cal-table .empty { text-align: center; padding: 1.2rem 0; color: rgba(255, 255, 255, 0.7); }
.cal-day td { padding-top: 0.7rem; font-size: 0.75rem; font-weight: 600; color: var(--gold); }
.cal-past { color: rgba(255, 255, 255, 0.55); }
.cal-next td { background: rgba(245, 179, 1, 0.06); }
.cal-next td:first-child { box-shadow: inset 2px 0 0 var(--gold); }
.cal-event { .cal-event {
display: block; display: block;
width: 100%; width: 100%;
padding: 0; padding: 0;
border: 0; border: 0;
background: transparent; background: none;
color: inherit; color: inherit;
text-align: inherit; text-align: left;
} }
.cal-event:hover { .cal-event:hover { color: var(--gold); text-decoration: underline; }
color: var(--bs-primary);
text-decoration: underline; .impact {
display: inline-block;
font-size: 0.68rem;
padding: 0.1rem 0.35rem;
border-radius: 0.25rem;
border: 1px solid var(--rule);
} }
.impact-high { border-color: rgba(232, 80, 58, 0.5); background: var(--down-wash); color: var(--down-text); }
.impact-medium { border-color: rgba(233, 162, 59, 0.5); background: rgba(233, 162, 59, 0.14); color: #ffc46b; }
.impact-low { color: rgba(255, 255, 255, 0.7); }
.tone { margin-bottom: 0.8rem; }
.tone-legend {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
font-size: 0.74rem;
color: rgba(255, 255, 255, 0.8);
}
.tone-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.tone-key {
width: 9px;
height: 9px;
border-radius: 2px;
display: inline-block;
}
.wire-item {
display: flex;
gap: 0.5rem;
align-items: baseline;
width: 100%;
padding: 0.3rem 0.35rem;
border: 0;
border-radius: 0.3rem;
background: none;
color: inherit;
font: inherit;
text-align: left;
}
button.wire-item:hover { background: rgba(255, 255, 255, 0.05); }
.wire-score { .wire-score {
font-family: var(--xau-font-mono); font-family: var(--mono);
font-size: 0.85rem; font-size: 0.74rem;
font-weight: 700; font-weight: 600;
padding: 2px 7px; padding: 0.05rem 0.35rem;
border-radius: 5px; border-radius: 0.25rem;
white-space: nowrap; white-space: nowrap;
min-width: 2.7rem;
text-align: center;
} }
/* calendar highlight for next upcoming event */ .wire-score.pos { background: var(--up-wash); color: var(--up-text); }
.cal-next-up td:first-child { .wire-score.neg { background: var(--down-wash); color: var(--down-text); }
box-shadow: inset 4px 0 0 var(--bs-primary); .wire-score.zero { background: rgba(255, 255, 255, 0.06); color: rgba(255, 255, 255, 0.75); }
padding-left: 0.75rem !important;
.wire-text { flex: 1 1 auto; font-size: 0.82rem; }
.wire-src { font-size: 0.72rem; color: rgba(255, 255, 255, 0.65); white-space: nowrap; }
.wire-more { font-size: 0.78rem; color: rgba(255, 255, 255, 0.78); cursor: pointer; padding: 0.35rem; }
/* ── modals ────────────────────────────────────────────────────── */
.modal-sub { font-size: 0.8rem; color: rgba(255, 255, 255, 0.78); }
.modal-sub .num { margin-right: 0.4rem; }
.d-sec { margin-bottom: 1.4rem; }
.d-sec > h6 {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.82rem;
font-weight: 600;
margin-bottom: 0.6rem;
}
.d-sec > h6 i { color: var(--gold); }
.d-rule { flex: 1 1 auto; height: 1px; background: var(--rule); }
.d-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: 0.5rem; }
.d-tile {
border: 1px solid var(--rule);
border-radius: 0.35rem;
background: var(--panel-2);
padding: 0.45rem 0.55rem;
}
.d-tile .k { display: block; font-size: 0.7rem; color: rgba(255, 255, 255, 0.7); }
.d-tile .v { font-size: 1.02rem; font-weight: 600; }
.d-table { font-size: 0.82rem; }
.d-table .ind-k { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.d-table td, .d-table th { border-color: var(--rule-soft); }
.detail-scroll { overflow-x: auto; }
.wbar { display: block; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); margin-top: 3px; }
.wbar > i { display: block; height: 100%; border-radius: 2px; background: var(--gold); }
.d-sec details {
border: 1px solid var(--rule);
border-radius: 0.4rem;
padding: 0.5rem 0.65rem;
margin-bottom: 0.5rem;
}
.d-sec summary { cursor: pointer; font-size: 0.85rem; }
.d-sec summary > * { margin-right: 0.4rem; }
.reasons { display: grid; gap: 0.25rem; font-size: 0.82rem; }
.reasons i { width: 1rem; margin-right: 0.3rem; }
.reason-group { font-size: 0.76rem; color: rgba(255, 255, 255, 0.72); margin: 0.6rem 0 0.25rem; }
.desk-foot {
margin-top: 2rem;
padding-top: 1rem;
border-top: 1px solid var(--rule);
font-size: 0.78rem;
color: rgba(255, 255, 255, 0.7);
}
.desk-foot i { color: rgba(255, 255, 255, 0.5); margin-right: 0.35rem; }
/* ── focus, motion, small screens ──────────────────────────────── */
.rail-chip:focus-visible,
.wire-item:focus-visible,
.cal-event:focus-visible,
.btn-desk:focus-visible,
.form-check-input:focus-visible,
summary:focus-visible {
outline: 2px solid var(--gold);
outline-offset: 2px;
border-radius: 0.25rem;
} }
/* reduced motion */
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.live-dot { animation: none; } .live-dot { animation: none; }
.scorebar .fill { transition: none; } *, *::before, *::after { transition: none !important; }
* { transition: none !important; } }
@media (max-width: 991.98px) {
.board-read { border-right: 0; border-bottom: 1px solid var(--rule); }
.board-read, .board-plot { padding: 1.15rem 1.15rem; }
} }
@media (max-width: 575.98px) { @media (max-width: 575.98px) {
.tf-selector { .desk-price { font-size: 1.35rem; }
grid-template-columns: repeat(2, minmax(0, 1fr)); .desk-status { gap: 0.6rem; font-size: 0.75rem; }
} .board-stats { grid-template-columns: 1fr; gap: 0.5rem; }
.desk-shell { padding: 0 0.75rem; }
.workspace-card .card-body {
padding: 1rem;
}
.rail-chip {
flex: 1 1 calc(50% - 0.5rem);
}
} }
+116 -90
View File
@@ -8,142 +8,168 @@
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap">
<link rel="stylesheet" href="dashboard.css"> <link rel="stylesheet" href="dashboard.css">
</head> </head>
<body> <body>
<div class="container-fluid container-xl py-4"> <header class="desk-bar sticky-top">
<div class="desk-shell d-flex align-items-center flex-wrap gap-3">
<header class="card mb-3" id="hero"> <div class="d-flex align-items-baseline gap-2">
<div class="card-body d-flex align-items-center flex-wrap gap-3"> <i class="fa-solid fa-coins desk-mark" aria-hidden="true"></i>
<div> <span class="desk-symbol">XAU/USD</span>
<h1 class="xau-symbol mb-1"><i class="bi bi-coin me-1"></i>XAU/USD</h1> <span class="desk-price num" id="bar-price">—</span>
<div class="display-5 fw-semibold xau-price" id="hero-price">—</div> </div>
</div> <nav class="desk-rail" id="bar-rail" aria-label="Jump to a timeframe"></nav>
<div class="d-flex flex-wrap gap-2" id="hero-rail" aria-label="Select timeframe"></div> <div class="desk-status ms-auto">
<div class="ms-auto text-end"> <span id="bar-market"><span class="live-dot"></span>Connecting</span>
<div id="hero-status" role="status"><span class="live-dot"></span>…</div> <span class="desk-meta"><i class="fa-solid fa-hourglass-half" aria-hidden="true"></i>
<div class="small text-secondary"><i class="bi bi-hourglass-split me-1"></i>M5 close in <span class="num" id="hero-cd">--:--</span></div> 5-minute close <span class="num" id="bar-cd">--:--</span></span>
<div class="small text-secondary" id="hero-updated">updated —</div> <span class="desk-meta" id="bar-updated">waiting for data</span>
</div>
</div> </div>
</header>
<div class="alert alert-warning d-none" id="banner-closed" role="alert">
<i class="bi bi-moon-fill me-2"></i>Market closed (weekend) — showing Friday's last state. Calendar and news stay live.
</div> </div>
<div class="alert alert-danger d-none" id="banner-fail" role="alert"></div> </header>
<main class="desk-shell pb-5">
<div class="alert alert-warning d-none mt-3" id="banner-closed" role="alert">
<i class="fa-solid fa-moon me-2" aria-hidden="true"></i>
Gold is closed for the weekend. The cards below hold Friday's last reading; news and the calendar keep updating.
</div>
<div class="alert alert-danger d-none mt-3" id="banner-fail" role="alert"></div>
<div class="visually-hidden" id="dashboard-live" aria-live="polite"></div> <div class="visually-hidden" id="dashboard-live" aria-live="polite"></div>
<main> <section class="board mt-3" aria-labelledby="board-heading">
<section class="card mb-4 d-none" id="context" aria-label="Market context"> <div class="row g-0">
<div class="card-body d-flex flex-wrap gap-3 align-items-start"> <div class="col-lg-4 board-read">
<div class="flex-grow-1" id="ctx-blurb"><strong>Market context</strong></div> <h1 class="board-headline" id="board-heading">Reading the market</h1>
<div class="d-flex flex-wrap gap-2" id="ctx-chips"></div> <p class="board-sub" id="board-sub">Waiting for the first scan to finish.</p>
<div class="board-news d-none" id="context">
<p class="context-text" id="ctx-blurb"></p>
<div class="context-chips" id="ctx-chips"></div>
</div>
<div class="board-stats" id="board-stats"></div>
</div> </div>
</section> <div class="col-lg-8 board-plot">
<h2 class="plot-title">Direction by timeframe</h2>
<div class="chart-wrap chart-direction">
<canvas id="chart-direction" role="img"
aria-label="Direction score of each timeframe, from minus 100 selling to plus 100 buying"></canvas>
</div>
<p class="plot-note">Bars grow out of the centre line. Right is buying pressure, left is selling
pressure, and the full scale runs to 100 either way.</p>
</div>
</div>
</section>
<section class="mb-4" aria-labelledby="workspace-heading"> <section class="mt-4" aria-labelledby="tf-heading">
<h2 class="text-uppercase text-secondary small fw-bold mb-3 d-flex align-items-center gap-2" id="workspace-heading"> <div class="sec-head">
<i class="bi bi-crosshair text-primary"></i> <h2 class="sec-title" id="tf-heading">Four reads on one market</h2>
Signal workspace <span class="sec-note">Every card is an independent scan. They are allowed to disagree.</span>
<span class="fw-normal text-body-secondary" style="text-transform:none">— select a timeframe</span> </div>
</h2> <div class="row g-3 row-cols-1 row-cols-md-2 row-cols-xxl-4" id="tf-grid"></div>
<div id="tf-grid"></div> </section>
</section>
<section aria-labelledby="fundamentals-heading"> <section class="mt-4" aria-labelledby="fund-heading">
<h2 class="text-uppercase text-secondary small fw-bold mb-3 mt-4 d-flex align-items-center gap-2" id="fundamentals-heading"> <div class="sec-head">
<i class="bi bi-globe2 text-primary"></i>Fundamentals <h2 class="sec-title" id="fund-heading">What else is moving gold</h2>
</h2> <span class="sec-note">Context only. None of it changes a signal.</span>
<div class="row g-3"> </div>
<div class="col-lg-8"> <div class="row g-3">
<div class="card h-100"> <div class="col-xl-7">
<div class="card-body"> <div class="card h-100">
<div class="d-flex align-items-center gap-3 mb-3 flex-wrap"> <div class="card-body">
<h3 class="h5 card-title mb-0"><i class="bi bi-calendar-event me-2 text-primary"></i>Economic calendar</h3> <div class="card-head">
<span class="text-secondary small" id="calendar-note">times local · USD events</span> <h3 class="card-title"><i class="fa-solid fa-calendar-day" aria-hidden="true"></i>Economic calendar</h3>
<div class="form-check form-switch ms-auto"> <span class="card-note" id="calendar-note">loading</span>
<input class="form-check-input" type="checkbox" id="hi-only"> <div class="form-check form-switch ms-auto mb-0">
<label class="form-check-label small" for="hi-only">high impact only</label> <input class="form-check-input" type="checkbox" id="hi-only">
</div> <label class="form-check-label" for="hi-only">High impact only</label>
</div>
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th>Time</th>
<th>Cur</th>
<th>Impact</th>
<th>Event</th>
<th class="text-end">Fcst</th>
<th class="text-end">Prev</th>
<th class="text-end">Actual</th>
</tr>
</thead>
<tbody id="cal-body"><tr><td colspan="7" class="text-secondary text-center py-3">Loading calendar…</td></tr></tbody>
</table>
</div> </div>
</div> </div>
</div> <div class="table-responsive cal-scroll">
</div> <table class="table table-sm align-middle cal-table">
<div class="col-lg-4"> <thead>
<div class="card h-100"> <tr>
<div class="card-body"> <th scope="col">Time</th>
<div class="d-flex align-items-center gap-3 mb-3 flex-wrap"> <th scope="col">Cur</th>
<h3 class="h5 card-title mb-0"><i class="bi bi-newspaper me-2 text-primary"></i>Newswire</h3> <th scope="col">Impact</th>
<span class="text-secondary small" id="wire-note"></span> <th scope="col">Event</th>
</div> <th scope="col" class="text-end">Forecast</th>
<div id="wire-total" class="d-none"></div> <th scope="col" class="text-end">Previous</th>
<div id="wire"></div> <th scope="col" class="text-end">Actual</th>
</tr>
</thead>
<tbody id="cal-body">
<tr><td colspan="7" class="empty">Loading the calendar</td></tr>
</tbody>
</table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section> <div class="col-xl-5">
</main> <div class="card h-100">
<div class="card-body">
<div class="card-head">
<h3 class="card-title"><i class="fa-solid fa-newspaper" aria-hidden="true"></i>Newswire</h3>
<span class="card-note ms-auto" id="wire-note"></span>
</div>
<div id="wire-tone" class="tone d-none">
<div class="chart-wrap chart-tone">
<canvas id="chart-tone" role="img" aria-label="Share of headlines leaning bullish, neutral or bearish for gold"></canvas>
</div>
<div class="tone-legend" id="tone-legend"></div>
</div>
<div id="wire"></div>
</div>
</div>
</div>
</div>
</section>
<footer class="mt-4 pt-3 border-top text-secondary small"> <footer class="desk-foot">
<i class="bi bi-info-circle me-1"></i> <i class="fa-solid fa-circle-info" aria-hidden="true"></i>
Signals are generated on closed candles only and refresh at candle boundaries Every signal is built from closed candles and refreshes when the next candle closes.
(M5/M15/H1/H4). Not financial advice — educational and research use only. Educational and research use, not financial advice.
</footer> </footer>
</div> </main>
<div class="modal fade" id="tf-detail" tabindex="-1" aria-labelledby="detail-title" aria-hidden="true"> <div class="modal fade" id="tf-detail" tabindex="-1" aria-labelledby="detail-title">
<div class="modal-dialog modal-xl modal-dialog-scrollable"> <div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<div> <div>
<h5 class="modal-title mb-0" id="detail-title">—</h5> <h5 class="modal-title" id="detail-title">Timeframe</h5>
<div class="small text-secondary"> <div class="modal-sub">
<span class="num" id="detail-price">—</span> <span class="num" id="detail-price">—</span>
<span id="detail-sub"></span> <span id="detail-sub"></span>
</div> </div>
</div> </div>
<button id="detail-close" type="button" class="btn-close" aria-label="Close detail view"></button> <button id="detail-close" type="button" class="btn-close" aria-label="Close the full analysis"></button>
</div> </div>
<div class="modal-body" id="detail-body"></div> <div class="modal-body" id="detail-body"></div>
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" id="news-detail" tabindex="-1" aria-labelledby="nd-title" aria-hidden="true"> <div class="modal fade" id="news-detail" tabindex="-1" aria-labelledby="nd-title">
<div class="modal-dialog modal-lg modal-dialog-scrollable"> <div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="nd-title">News detail</h5> <h5 class="modal-title" id="nd-title">News detail</h5>
<button id="nd-close" type="button" class="btn-close" aria-label="Close news detail"></button> <button id="nd-close" type="button" class="btn-close" aria-label="Close the news detail"></button>
</div> </div>
<div class="modal-body" id="nd-body"></div> <div class="modal-body" id="nd-body"></div>
</div> </div>
</div> </div>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js" crossorigin="anonymous"></script>
<script src="dashboard.js"></script> <script src="dashboard.js"></script>
</body> </body>
</html> </html>
+883 -548
View File
File diff suppressed because it is too large Load Diff
+31 -4
View File
@@ -5496,18 +5496,45 @@ def _():
["dashboard.css", "dashboard.html", "dashboard.js", "news_summary.php"] # all installed, no .tmp ["dashboard.css", "dashboard.html", "dashboard.js", "news_summary.php"] # all installed, no .tmp
@test("dashboard: static UI uses CSS gauges and a coordinated refresh loop") @test("dashboard: static UI is Bootstrap + jQuery + Chart.js on a CDN")
def _(): def _():
# The page is served as-is (no build step), so its four libraries are
# pinned <script>/<link> tags. Only jsdelivr and cdnjs are allowed.
import re
static_dir = os.path.join(os.path.dirname(__file__), "static")
with open(os.path.join(static_dir, "dashboard.html"), encoding="utf-8") as fh:
html = fh.read()
for needle in ("bootstrap@5.3", "bootstrap.bundle.min.js", "jquery@3.7",
"chart.js@4.4", "font-awesome/6."):
assert needle in html, needle
assert "gauge.js" not in html # no local charting script survives
from urllib.parse import urlsplit
for url in re.findall(r'(?:src|href)="(https?://[^"]+)"', html):
assert urlsplit(url).netloc in {
"cdn.jsdelivr.net", "cdnjs.cloudflare.com",
"fonts.googleapis.com", "fonts.gstatic.com"}, url
@test("dashboard: one card and one chart per timeframe, coordinated refresh")
def _():
import re
static_dir = os.path.join(os.path.dirname(__file__), "static") static_dir = os.path.join(os.path.dirname(__file__), "static")
with open(os.path.join(static_dir, "dashboard.html"), encoding="utf-8") as fh: with open(os.path.join(static_dir, "dashboard.html"), encoding="utf-8") as fh:
html = fh.read() html = fh.read()
with open(os.path.join(static_dir, "dashboard.js"), encoding="utf-8") as fh: with open(os.path.join(static_dir, "dashboard.js"), encoding="utf-8") as fh:
js = fh.read() js = fh.read()
assert "chart.js" not in html.lower() # The four dashboard timeframes render as Bootstrap columns inside one
assert "gauge.js" not in html # row, each card carrying its own indicator canvas.
assert 'id="tf-grid"' in html and "row-cols-" in html
assert 'id="chart-direction"' in html and 'id="chart-tone"' in html
assert 'id="ind-${tf}"' in js and "cardShell" in js
assert [tf.value for tf in dpub.DASHBOARD_TFS] == \
re.search(r'const TF_ORDER = \[([^\]]+)\]', js).group(1) \
.replace('"', "").replace(" ", "").split(",")
# One coordinated refresh loop, never a polling interval.
assert "setInterval(poll" not in js assert "setInterval(poll" not in js
assert "FALLBACK_POLL_MS" in js and "pollInFlight" in js assert "FALLBACK_POLL_MS" in js and "pollInFlight" in js
assert "data-select-tf" in js and "localStorage" in js assert "scheduleBoundaryRefresh" in js and "localStorage" in js
@test("dashboard: publish is atomic and leaves no temp file") @test("dashboard: publish is atomic and leaves no temp file")