Add the support Home mockup with a Status section

D-025: the support side gets the site's home page (one tile per
station: name, last voltage, curve) with a Status section on top. It
holds one notification per station whose last day of the window is
Orange or Red (src/day_color.py), the most serious first; Green
notifies nothing. Each notification, like the station tile, links to
the station's client view (out/maquette_user_energy.html).
maquettes/support/home.py writes out/maquette_support_home.html with
the standard library only (inline SVG, no plotly). Only VERMONT has
data; the other tiles keep the site's names and stay empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-10-12 16:32:11 +02:00
1 parent 5f260d9830
commit 77c8f24d2f
5 files changed
+204 -2

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
"""Maquette côté support « Home » : page d'accueil du site de monitoring (toutes les stations), avec en haut une section
Status. Elle porte une notification par station dont le dernier jour de la fenêtre est Orange ou Red (src/day_color.py, D-020).
La notification, comme la vignette de la station, mène à la vue client de la station (son menu principal) :
out/maquette_user_energy.html, écrite par maquettes/user/energy.py (à lancer avec les mêmes dates).
Données réelles : VERMONT seule (data/). Les autres stations, noms repris du site, n'ont pas de données dans la maquette.
Écrit out/maquette_support_home.html et l'ouvre dans le navigateur.
Usage : python3 maquettes/support/home.py [AAAA-MM-JJ début] [AAAA-MM-JJ fin] (défaut : 2026-09-18 à 2026-09-28)
"""
import sys
from datetime import date, datetime, time, timedelta, timezone
from pathlib import Path
HERE = Path(__file__).resolve().parent
ROOT = HERE.parent.parent
sys.path.insert(0, str(ROOT / "src"))
from analyse_01 import open_html # noqa: E402
import day_color as dc # noqa: E402
import energy_check as ec # noqa: E402
START = date.fromisoformat(sys.argv[1]) if len(sys.argv) > 1 else date(2026, 9, 18)
END = date.fromisoformat(sys.argv[2]) if len(sys.argv) > 2 else date(2026, 9, 28)
# Stations de la page d'accueil du site, dans son ordre (capture du 2026-10-12).
STATIONS = ["ALLALINHORN", "BREITHORN", "CASTOR", "CLARIDEN", "DOM", "FINSTERAARHORN", "FLORIDA", "GRAMMONT", "JUNGFRAU",
"LENZSPITZE", "LINDENBERG", "LISKAMM", "MICHIGAN", "MISSISSIPPI", "NEBRASKA", "NIEDERHORN", "NORDEND",
"PIZBERNINA", "PIZBUIN", "POLLUX", "RINGELSPITZ", "VERMONT", "WEISSHORN", "ADULA", "ALASKA", "DAMMASTOCK",
"FAULHORN", "GRANDCOMBIN", "MARYLAND", "MONTANA", "NADELHORN", "PONT_TREMBLEX-01", "SNCF01", "WILDSTRUBEL",
"WYOMING"]
USER_VIEW = {"VERMONT": "maquette_user_energy.html"} # vue client de la station (maquettes/user/)
NAME = {"RED": "Red", "ORANGE": "Orange"} # couleurs notifiées, la plus grave d'abord ; Green ne notifie rien
HEADLINE = {"RED": "The station is not receiving enough energy.", # mêmes phrases que la vue client
"ORANGE": "The station's energy supply is uncertain."}
series = ec.load_stations([str(ROOT / "data")])
def spark(v):
"""Vignette : BusVoltage horaire de la fenêtre en SVG (coupé aux heures sans mesure), et sa dernière valeur."""
pts = [(t, x) for t, x in sorted(v.items()) if START <= t.date() <= END and x is not None]
lo, hi = min(x for _, x in pts), max(x for _, x in pts)
t0, span = datetime.combine(START, time(), timezone.utc), ((END - START).days + 1) * 86400
d, prev = "", None
for t, x in pts:
pen = "L" if prev and t - prev <= timedelta(hours=1) else "M"
d += f"{pen}{(t - t0).total_seconds() / span * 200:.1f},{38 - (x - lo) / (hi - lo or 1) * 36:.1f}"
prev = t
return f'<svg viewBox="0 0 200 40" preserveAspectRatio="none"><path d="{d}"/></svg>', pts[-1][1]
tiles = []
for name in STATIONS:
if "BusVoltage" not in series.get(name, {}):
tiles.append(f'<div class="tile none" title="No data in this mockup"><div class="tile-head">{name}<span>—</span>'
f'</div><svg></svg></div>')
continue
svg, last = spark(series[name]["BusVoltage"])
tiles.append(f'<a class="tile" href="{USER_VIEW.get(name, "#")}"><div class="tile-head">{name}<span>{last:.2f}[V]</span>'
f'</div>{svg}</a>')
notes = []
for name in series:
color = {p["t"].date(): p["facts"]["color"] for p in dc.run(series[name])["points"]}.get(END)
if color in NAME:
notes.append((list(NAME).index(color), name,
f'<li><span class="status {color}">{NAME[color]}</span><b>{name}</b><span>Energy</span>'
f'<span class="meta">{END.strftime("%a %d %b %Y")}</span><span>{HEADLINE[color]}</span>'
f'<a href="{USER_VIEW.get(name, "#")}">Open {name} →</a></li>'))
status = "".join(n[2] for n in sorted(notes)) or '<li class="empty">No problem or point of attention.</li>'
html = (HERE / "home_template.html").read_text()
for key, value in (("<!--COUNT-->", f"{len(notes)} notification{'s' * (len(notes) != 1)}"),
("<!--STATUS-->", status), ("<!--TILES-->", "\n".join(tiles))):
html = html.replace(key, value)
out = ROOT / "out" / "maquette_support_home.html"
out.parent.mkdir(exist_ok=True)
out.write_text(html)
print(out)
if not (out.parent / USER_VIEW["VERMONT"]).exists():
print("Vue client absente : lancer python3 maquettes/user/energy.py avec les mêmes dates.")
open_html(out)
+107
View File
@@ -0,0 +1,107 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AIMsight Home</title>
<style>
/* Maquette côté support : page d'accueil (toutes les stations) + section Status. Contenu injecté par home.py. */
:root {
--sidebar: #2a3f54; --topbar: #ededed; --page: #f7f7f7; --panel-border: #e6e9ed;
--muted: #73879c; --text: #333; --line: #dee2e6;
--green: #008300; --orange: #eda100; --red: #d03b3b; --spark: #26b99a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--muted);
font: 13px/1.47 "Helvetica Neue", Roboto, Arial, "Droid Sans", sans-serif; }
svg.i { width: 15px; height: 15px; fill: currentColor; vertical-align: -2px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 230px; background: var(--sidebar); color: #fff; }
.brand { height: 57px; padding: 0 10px; display: flex; align-items: center; font-size: 22px; }
.profile { display: flex; align-items: center; gap: 22px; padding: 18px 12px 24px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: #9b59b6; border: 3px solid #fff;
display: grid; place-items: center; font-size: 19px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.profile small { display: block; color: #bab8b8; font-size: 13px; }
.profile span { font-size: 14px; }
.section { padding: 0 23px 18px; font-size: 11px; font-weight: bold; letter-spacing: .3px; }
.nav a { display: flex; align-items: center; gap: 4px; padding: 13px 15px; color: #e7e7e7;
text-decoration: none; font-weight: bold; }
.nav a.active { background: #34495e; border-right: 5px solid #1abb9c; }
.nav a .chev { margin-left: auto; }
.topbar { margin-left: 230px; height: 52px; background: var(--topbar); border-bottom: 1px solid #d9dee4;
display: flex; align-items: center; justify-content: space-between; padding: 0 15px; }
.topbar .burger { color: #5a738e; width: 26px; height: 26px; }
.user { display: flex; align-items: center; gap: 10px; color: #515356; }
.user .avatar { width: 29px; height: 29px; border-width: 0; font-size: 11px; box-shadow: none; }
main { margin-left: 230px; padding: 10px 20px; }
.panel { background: #fff; border: 1px solid var(--panel-border); padding: 10px 17px 20px; margin-bottom: 20px; }
.panel-title { border-bottom: 2px solid var(--panel-border); padding: 4px 6px 12px; }
.panel-title h2 { margin: 0; font-size: 18px; font-weight: 400; }
.panel-title h2 small { font-size: 14px; margin-left: 10px; }
/* Ajout : section Status, une notification par station Orange ou Red, avec le lien vers sa vue client. */
.notes { list-style: none; margin: 12px 6px 0; padding: 0; }
.notes li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 14px;
border: 1px solid var(--line); border-radius: 4px; color: var(--text); font-size: 15px; }
.notes li + li { margin-top: 8px; }
.notes li.empty { color: var(--muted); }
.notes a { margin-left: auto; color: #2a78d6; text-decoration: none; font-weight: bold; }
.notes a:hover { text-decoration: underline; }
.status { padding: 2px 12px; border-radius: 999px; font-size: 13px; font-weight: bold; color: #fff; }
.status.ORANGE { background: var(--orange); color: #1a1a1a; } .status.RED { background: var(--red); }
.meta { color: var(--muted); font-size: 13px; }
/* Vignettes des stations, comme sur le site : nom, dernière tension, courbe de la fenêtre. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 0; margin-bottom: 20px; }
.tile { display: block; padding: 2px 12px 2px 18px; border-left: 2px solid #ddd; color: var(--muted); text-decoration: none; }
a.tile:hover { background: #eef1f4; }
.tile-head { display: flex; justify-content: space-between; }
.tile-head span { font-weight: bold; }
.tile svg { display: block; width: 100%; height: 40px; margin-top: 6px; background: #ececec; }
.tile path { fill: none; stroke: var(--spark); stroke-width: 2; vector-effect: non-scaling-stroke; }
.tile.none { opacity: .5; }
.rows div { padding: 14px 6px; border-bottom: 2px solid var(--panel-border); font-size: 18px; }
</style>
</head>
<body>
<svg style="display:none">
<symbol id="home" viewBox="0 0 20 20"><path d="M10 2 1 10h3v8h5v-5h2v5h5v-8h3z"/></symbol>
<symbol id="list" viewBox="0 0 20 20"><path d="M1 3h3v3H1zm5 0h13v3H6zM1 8.5h3v3H1zm5 0h13v3H6zM1 14h3v3H1zm5 0h13v3H6z"/></symbol>
<symbol id="chev" viewBox="0 0 20 20"><path d="M4 7l6 6 6-6" fill="none" stroke="currentColor" stroke-width="2.2"/></symbol>
<symbol id="burger" viewBox="0 0 20 20"><path d="M2 4h16v2.4H2zm0 4.8h16v2.4H2zm0 4.8h16V16H2z"/></symbol>
</svg>
<aside class="sidebar">
<div class="brand">AIMsight monitoring</div>
<div class="profile"><div class="avatar">MP</div><div><small>Welcome,</small><span>Maxime Pasquier</span></div></div>
<div class="section">GENERAL</div>
<nav class="nav">
<a class="active"><svg class="i"><use href="#home"/></svg>Home</a>
<a><svg class="i"><use href="#list"/></svg>Explore<svg class="i chev"><use href="#chev"/></svg></a>
</nav>
</aside>
<header class="topbar">
<svg class="burger"><use href="#burger"/></svg>
<div class="user"><div class="avatar">MP</div>Maxime Pasquier ▾</div>
</header>
<main>
<section class="panel">
<div class="panel-title"><h2>Status<small><!--COUNT--></small></h2></div>
<ul class="notes"><!--STATUS--></ul>
</section>
<div class="grid">
<!--TILES-->
</div>
<section class="panel rows">
<div>Projects</div>
<div>Archive</div>
</section>
</main>
</body>
</html>