231 lines
13 KiB
HTML
231 lines
13 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title><!--PLATFORM--> · Explore</title>
|
||
<script src="https://cdn.plot.ly/plotly-4.1.1.min.js"></script>
|
||
<style>
|
||
/* Maquette de la page Explore avec l'onglet Diagnosis (D-053, vues-deplacements/maquette/spec.md). Données injectées
|
||
par explore.py. Habillage repris de maquettes/user/summary_template.html. */
|
||
:root {
|
||
--sidebar: #2a3f54; --topbar: #ededed; --page: #f7f7f7; --panel-border: #e6e9ed;
|
||
--muted: #73879c; --text: #333; --line: #dee2e6; --blue: #2a78d6;
|
||
}
|
||
* { 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 .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 28px; }
|
||
.panel { background: #fff; border: 1px solid var(--panel-border); padding: 10px 17px 20px; }
|
||
.panel-title { display: flex; align-items: center; 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; }
|
||
.panel-title .tools { margin-left: auto; color: #c5c7cb; }
|
||
|
||
/* Période (inerte) et onglets, comme la page Explore de la plateforme. */
|
||
.period { display: flex; margin: 22px 22px 0; }
|
||
.period span { border: 1px solid #ced4da; border-radius: 4px 0 0 4px; padding: 7px 12px; color: var(--text); font-size: 15px; }
|
||
.period b { background: #6c757d; color: #fff; padding: 7px 12px; font-weight: normal; font-size: 15px; border-radius: 0 4px 4px 0; }
|
||
.tabs { display: flex; margin: 18px 22px 0; border-bottom: 1px solid var(--line); }
|
||
.tabs button { border: 1px solid transparent; border-bottom: 0; background: none; padding: 7px 16px; margin-bottom: -1px;
|
||
font: inherit; font-size: 15px; color: var(--blue); cursor: pointer; border-radius: 4px 4px 0 0; }
|
||
.tabs button.active { color: var(--text); background: #fff; border-color: var(--line); }
|
||
.pane { display: none; margin: 0 22px; padding-top: 14px; }
|
||
.pane.active { display: block; }
|
||
.pane > img { display: block; width: 100%; margin-bottom: 8px; border: 1px solid var(--line); }
|
||
.empty { padding: 30px 0; color: var(--muted); }
|
||
|
||
/* Onglet Diagnosis (spec §1 à §3). */
|
||
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--text); font-size: 14px; }
|
||
.toolbar button { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 4px 10px;
|
||
font: inherit; cursor: pointer; }
|
||
.toolbar button.active { background: var(--blue); border-color: var(--blue); color: #fff; }
|
||
.toolbar .meta { margin-left: auto; color: var(--muted); }
|
||
</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="cog" viewBox="0 0 20 20"><circle cx="10" cy="10" r="6" fill="none" stroke="currentColor" stroke-width="4" stroke-dasharray="2.4 2.3"/><circle cx="10" cy="10" r="5" fill="none" stroke="currentColor" stroke-width="3"/></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>
|
||
<symbol id="wrench" viewBox="0 0 20 20"><path d="M13.5 1.5a5 5 0 0 0-4.6 6.9L2 15.3 4.7 18l6.9-6.9a5 5 0 0 0 6.9-4.6l-3 3-2.8-.6-.6-2.8z"/></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><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>
|
||
<a><svg class="i"><use href="#cog"/></svg>Settings<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><!--PLATFORM--><small>Explore</small></h2>
|
||
<span class="tools"><svg class="i"><use href="#wrench"/></svg> ▾</span>
|
||
</div>
|
||
<div class="period"><span id="period"></span><b>Apply</b></div>
|
||
<nav class="tabs">
|
||
<button type="button" data-pane="time_series">Time Series</button>
|
||
<button type="button" data-pane="advanced">Advanced</button>
|
||
<button type="button" data-pane="diagnosis" class="active">Diagnosis</button>
|
||
</nav>
|
||
<div class="pane" id="time_series"></div>
|
||
<div class="pane" id="advanced"></div>
|
||
<div class="pane active" id="diagnosis">
|
||
<div class="toolbar">Color <span id="columns"></span><span class="meta" id="instant"></span></div>
|
||
<div id="image"></div>
|
||
<div id="grid"></div>
|
||
<div id="details"></div>
|
||
</div>
|
||
</section>
|
||
</main>
|
||
|
||
<script>
|
||
const D = /*DATA*/null;
|
||
const day = t => `${+t.slice(8, 10)}/${+t.slice(5, 7)}/${t.slice(0, 4)}`;
|
||
document.getElementById("period").textContent = `${day(D.times[0])} → ${day(D.times[D.times.length - 1])}`;
|
||
|
||
// Onglets : un seul volet visible ; Plotly recalcule la taille des graphiques du volet qui s'affiche.
|
||
for (const b of document.querySelectorAll(".tabs button")) b.addEventListener("click", () => {
|
||
document.querySelectorAll(".tabs button, .pane").forEach(e => e.classList.remove("active"));
|
||
b.classList.add("active");
|
||
const pane = document.getElementById(b.dataset.pane);
|
||
pane.classList.add("active");
|
||
pane.querySelectorAll(".js-plotly-plot").forEach(p => Plotly.Plots.resize(p));
|
||
});
|
||
|
||
// Time Series et Advanced : les captures de la plateforme, telles quelles (décor, spec « La page »).
|
||
for (const [tab, srcs] of Object.entries(D.captures)) {
|
||
const pane = document.getElementById(tab);
|
||
if (!srcs.length) pane.innerHTML = '<p class="empty">No capture of this page.</p>';
|
||
for (const src of srcs) pane.insertAdjacentHTML("beforeend", `<img src="${src}" alt="">`);
|
||
}
|
||
|
||
// Onglet Diagnosis (spec §1 à §3) : image à l'instant T et grille capteurs × temps, reliées.
|
||
const S = D.sensors, NAMES = S.map(s => s.name);
|
||
const COLUMNS = ["corr_x", "corr_y", "error_value"]; // grandeurs de la grille (spec §2)
|
||
const CAP = 10; // plafond de l'échelle de couleur, ±10 pas : choix d'affichage, pas un seuil (spec §2)
|
||
const TOL = 10 * 60e3; // image la plus proche de T, à 10 min près (spec §1)
|
||
const SCALE = [[0, "#2166ac"], [0.5, "#ffffff"], [1, "#b2182b"]]; // linéaire : négatif en bleu, positif en rouge,
|
||
// blanc au niveau des 24 premières heures, distinct du gris
|
||
const GAP = "#c8c8c8"; // case sans valeur, ligne sans niveau (spec §2)
|
||
const CONFIG = { responsive: true, scrollZoom: true, displaylogo: false };
|
||
const ASKED = new URLSearchParams(location.hash.slice(1)); // état de départ lu dans l'adresse (spec §3)
|
||
let col = COLUMNS.includes(ASKED.get("col")) ? ASKED.get("col") : "corr_y";
|
||
let T = D.times.includes(ASKED.get("t")) ? D.times.indexOf(ASKED.get("t")) : D.times.length - 1;
|
||
let W = 0, H = 0; // taille des images de la caméra, lue sur la première
|
||
const utc = t => t.replace("T", " ").replace("Z", " UTC");
|
||
const tLine = () => ({ type: "line", xref: "x", yref: "paper", x0: D.times[T], x1: D.times[T], y0: 0, y1: 1,
|
||
line: { color: "#111", width: 1.5 } });
|
||
|
||
function nearestImage() {
|
||
const t = Date.parse(D.times[T]);
|
||
let best = null, gap = Infinity;
|
||
for (const im of D.images) {
|
||
const g = Math.abs(Date.parse(im.t) - t);
|
||
if (g < gap) { gap = g; best = im; }
|
||
}
|
||
return gap <= TOL ? best : null;
|
||
}
|
||
|
||
function drawGrid() {
|
||
return Plotly.react("grid", [{
|
||
type: "heatmap", x: D.times, y: NAMES, z: S.map(s => s.dev[col]), customdata: S.map(s => s.values[col]),
|
||
zmin: -CAP, zmax: CAP, colorscale: SCALE, hoverongaps: false, colorbar: { title: { text: "steps" }, thickness: 12 },
|
||
hovertemplate: `%{y} · %{x|%d %b %H:%M} UTC<br>${col} %{customdata:.4g} · %{z:.1f} steps<extra></extra>`,
|
||
}], {
|
||
height: 80 + 18 * S.length, margin: { l: 60, r: 10, t: 10, b: 40 }, plot_bgcolor: GAP, uirevision: "grid",
|
||
xaxis: { type: "date" }, yaxis: { autorange: "reversed", fixedrange: true, dtick: 1 }, shapes: [tLine()],
|
||
}, CONFIG);
|
||
}
|
||
|
||
function drawImage() {
|
||
const im = nearestImage();
|
||
const seen = S.map((s, i) => i).filter(i => S[i].x[T] !== null && S[i].y[T] !== null);
|
||
const markers = (ids, marker) => ({
|
||
type: "scatter", mode: "markers+text", x: ids.map(i => S[i].x[T]), y: ids.map(i => S[i].y[T]),
|
||
text: ids.map(i => NAMES[i]), customdata: ids, textposition: "top center", textfont: { color: "#fff", size: 11 },
|
||
marker: { size: 13, line: { color: "#fff", width: 1 }, ...marker }, hovertemplate: "%{text}<extra></extra>",
|
||
showlegend: false,
|
||
});
|
||
const valued = seen.filter(i => S[i].dev[col][T] !== null), blank = seen.filter(i => S[i].dev[col][T] === null);
|
||
const v = D.view || { x: [0, W || 1], y: [0, H || 1] };
|
||
return Plotly.react("image", [
|
||
markers(valued, { color: valued.map(i => S[i].dev[col][T]), cmin: -CAP, cmax: CAP, colorscale: SCALE }),
|
||
markers(blank, { color: GAP }),
|
||
], {
|
||
height: 520, margin: { l: 10, r: 10, t: 34, b: 10 }, plot_bgcolor: "#000", uirevision: "image",
|
||
title: { text: im ? `Image ${utc(im.t)}` : "", font: { size: 13 } },
|
||
xaxis: { range: v.x, showgrid: false, zeroline: false, showticklabels: false },
|
||
yaxis: { range: [v.y[1], v.y[0]], showgrid: false, zeroline: false, showticklabels: false, scaleanchor: "x" },
|
||
images: im && W ? [{ source: im.src, xref: "x", yref: "y", x: 0, y: 0, sizex: W, sizey: H,
|
||
xanchor: "left", yanchor: "top", sizing: "stretch", layer: "below" }] : [],
|
||
annotations: im ? [] : [{ text: "No image at this time", xref: "paper", yref: "paper", x: 0.5, y: 0.97,
|
||
showarrow: false, font: { color: "#fff", size: 15 } }],
|
||
}, CONFIG);
|
||
}
|
||
|
||
function setT(j) {
|
||
T = j;
|
||
document.getElementById("instant").textContent = `T = ${utc(D.times[T])}`;
|
||
Plotly.relayout("grid", { shapes: [tLine()] });
|
||
drawImage();
|
||
}
|
||
|
||
const columns = document.getElementById("columns");
|
||
columns.innerHTML = COLUMNS.map(c => `<button type="button" data-col="${c}">${c}</button>`).join("");
|
||
const markColumn = () => columns.querySelectorAll("button").forEach(b => b.classList.toggle("active", b.dataset.col === col));
|
||
columns.addEventListener("click", ev => {
|
||
if (!ev.target.dataset.col) return;
|
||
col = ev.target.dataset.col;
|
||
markColumn();
|
||
drawGrid();
|
||
drawImage();
|
||
});
|
||
|
||
markColumn();
|
||
document.getElementById("instant").textContent = `T = ${utc(D.times[T])}`;
|
||
Promise.all([drawGrid(), drawImage()]).then(() => {
|
||
document.getElementById("grid").on("plotly_click", ev => setT(ev.points[0].pointNumber[1]));
|
||
});
|
||
if (D.images.length) { // la taille de l'image, lue sur la première, place la photo sous les marqueurs
|
||
const probe = new Image();
|
||
probe.onload = () => { W = probe.naturalWidth; H = probe.naturalHeight; drawImage(); };
|
||
probe.src = D.images[0].src;
|
||
}
|
||
</script>
|
||
</body>
|
||
</html>
|