Files
automations-calendar-OPEN/templates/automations-results.template.html
T

97 lines
10 KiB
HTML
Raw Normal View History

2026-09-22 07:50:20 -06:00
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Automation Run Results</title>
<style>
:root { --ink:#172033; --muted:#64748b; --line:#dfe7f1; --panel:#fff; --bg:#f3f6fb; --success:#15803d; --success-soft:#dcfce7; --failure:#dc2626; --failure-soft:#fee2e2; --unknown:#64748b; --unknown-soft:#eef2f7; --brand:#175cd3; --shadow:0 14px 38px rgba(30,51,88,.09); }
* { box-sizing:border-box; }
body { margin:0; color:var(--ink); background:var(--bg); font:14px/1.45 Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
button,input,select { font:inherit; }
.shell { max-width:1560px; margin:0 auto; padding:28px; }
.hero { display:flex; justify-content:space-between; align-items:flex-start; gap:24px; margin-bottom:20px; }
h1 { margin:0 0 6px; font-size:clamp(28px,4vw,44px); letter-spacing:-.04em; line-height:1.05; }
.sub { max-width:760px; color:var(--muted); }
.source { margin-top:8px; color:#7c8aa0; font-size:12px; overflow-wrap:anywhere; }
.nav { display:flex; gap:8px; margin-top:12px; }
.nav a { color:#1649a5; background:#e8f0ff; border-radius:9px; padding:7px 10px; text-decoration:none; font-weight:700; }
.stats { display:grid; grid-template-columns:repeat(4,minmax(110px,1fr)); gap:10px; }
.stat { padding:13px 15px; border:1px solid var(--line); border-radius:14px; background:var(--panel); box-shadow:0 5px 18px rgba(30,51,88,.04); }
.stat strong { display:block; font-size:23px; line-height:1; margin-bottom:5px; }
.stat span { color:var(--muted); font-size:12px; }
.toolbar { position:sticky; top:0; z-index:20; display:grid; grid-template-columns:minmax(220px,1.5fr) repeat(5,minmax(135px,.7fr)); gap:10px; padding:12px; margin-bottom:14px; background:rgba(243,246,251,.95); border:1px solid var(--line); border-radius:16px; backdrop-filter:blur(12px); }
input,select { width:100%; padding:10px 12px; border:1px solid #cdd8e7; border-radius:10px; background:#fff; color:var(--ink); }
.panel { overflow:auto; border:1px solid var(--line); border-radius:16px; background:#fff; box-shadow:var(--shadow); }
.table-head,.row { min-width:1380px; display:grid; grid-template-columns:minmax(240px,1.3fr) 110px 175px 190px 150px 150px minmax(260px,1.4fr); gap:12px; align-items:start; }
.table-head { position:relative; z-index:2; padding:12px 16px; color:#fff; background:#172033; font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:.06em; }
.row { padding:14px 16px; border-bottom:1px solid var(--line); }
.row:last-child { border-bottom:0; }
.row:hover { background:#f8fafc; }
.day-heading { min-width:1380px; grid-column:1/-1; padding:11px 16px; color:#fff; background:#587b91; border-bottom:1px solid #84a2b2; font-size:13px; font-weight:800; letter-spacing:.04em; }
.name { font-weight:800; }
.meta { margin-top:3px; color:var(--muted); font-size:12px; overflow-wrap:anywhere; }
.result { display:inline-flex; align-items:center; gap:7px; width:fit-content; border-radius:999px; padding:5px 9px; font-weight:800; font-size:12px; }
.result.success { color:#166534; background:var(--success-soft); }
.result.failure { color:#991b1b; background:var(--failure-soft); }
.result.unknown { color:#475569; background:var(--unknown-soft); }
.mark { display:inline-flex; align-items:center; justify-content:center; width:18px; height:18px; color:#fff; border-radius:50%; line-height:1; }
.success .mark { background:var(--success); } .failure .mark { background:var(--failure); } .unknown .mark { background:var(--unknown); }
.empty { padding:36px; text-align:center; color:var(--muted); }
.foot { margin:12px 2px 0; color:var(--muted); font-size:12px; }
.embed-mode .shell { max-width:none; padding:0; }
.embed-mode .hero, .embed-mode .toolbar, .embed-mode .foot { display:none; }
.embed-mode .panel { border:0; border-radius:0; box-shadow:none; }
@media (max-width:1050px) { .hero{flex-direction:column}.stats{width:100%}.toolbar{grid-template-columns:1fr 1fr}.toolbar input{grid-column:1/-1}.panel{overflow:auto}.table-head,.row{min-width:1380px} }
@media (max-width:600px) { .stats{grid-template-columns:repeat(2,minmax(0,1fr))} }
</style>
</head>
<body>
<main class="shell">
<section class="hero">
<div>
<h1>Automation Run Results</h1>
<div class="sub">A reusable operational view of the canonical automation status registry. The list retains a rolling three-day history, newest first. Managed automations are linked to the workbook; collected evidence exposes every available scheduler result.</div>
<div class="source" id="source"></div>
<nav class="nav"><a href="automations-calendar.html">Open calendar</a></nav>
</div>
<div class="stats" id="stats"></div>
</section>
<section class="toolbar" aria-label="Result filters">
<input id="search" type="search" placeholder="Search automation, source, detail…" aria-label="Search run results">
<select id="scope"><option value="managed">Managed automations</option><option value="unlinked">Unlinked evidence</option><option value="all">All records</option></select>
<select id="outcome"><option value="">All outcomes</option><option value="success">Successful</option><option value="failure">Failed</option><option value="unknown">Unknown</option></select>
<select id="sourceFilter"><option value="">All sources</option></select>
<select id="project"><option value="">All projects</option></select>
<select id="opsSegment"><option value="">All ops segments</option></select>
</section>
<section class="panel">
<div class="table-head"><div>Automation</div><div>Result</div><div>Last run</div><div>Source</div><div>Project</div><div>Ops segment</div><div>Detail</div></div>
<div id="rows"></div>
</section>
<div class="foot" id="foot"></div>
</main>
<script>
if (new URLSearchParams(location.search).get("embed") === "table") document.body.classList.add("embed-mode");
const data = __AUTOMATION_RESULTS_DATA__;
const state = {search:"",scope:"managed",outcome:"",sourceFilter:"",project:"",opsSegment:""};
const esc = value => String(value ?? "").replace(/[&<>"']/g,ch=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[ch]));
const mark = outcome => outcome === "success" ? "✓" : outcome === "failure" ? "×" : "?";
const dateText = value => { if(!value)return "Never / unavailable"; const date=new Date(value); return Number.isNaN(date.valueOf())?String(value):date.toLocaleString([], {dateStyle:"medium",timeStyle:"short"}); };
const normalize = day => { const managed = day.managed.map(item=>({...item,outcome:item.run.outcome,lastRun:item.run.lastRun,detail:item.run.detail,source:item.run.source,linked:true})); const unlinked = day.evidence.filter(item=>!item.linked).map(item=>({...item,project:"",opsSegment:"",machine:"",location:"",automationStatus:""})); return {managed,unlinked,all:[...managed,...unlinked]}; };
const days = (data.days||[]).map(day=>({...day,...normalize(day)}));
const allDays = days.length ? days : [{date:"",generatedAt:data.generatedAt,managed:[],unlinked:[],all:[]}];
const allRecords = allDays.flatMap(day=>day.all);
const fill = (id,values) => { const select=document.getElementById(id); [...new Set(values.filter(Boolean))].sort((a,b)=>a.localeCompare(b)).forEach(value=>select.insertAdjacentHTML("beforeend",`<option>${esc(value)}</option>`)); };
fill("sourceFilter",allRecords.map(item=>item.source)); fill("project",allDays.flatMap(day=>day.managed.map(item=>item.project))); fill("opsSegment",allDays.flatMap(day=>day.managed.map(item=>item.opsSegment)));
function scoped(day){ return state.scope === "managed" ? day.managed : state.scope === "unlinked" ? day.unlinked : day.all; }
function filtered(day){ const q=state.search.toLowerCase(); return scoped(day).filter(item=>(!state.outcome||item.outcome===state.outcome)&&(!state.sourceFilter||item.source===state.sourceFilter)&&(!state.project||item.project===state.project)&&(!state.opsSegment||item.opsSegment===state.opsSegment)&&(!q||[item.name,item.source,item.detail,item.project,item.opsSegment,item.machine,...(item.aliases||[])].join(" ").toLowerCase().includes(q))).sort((a,b)=>(b.lastRun?Date.parse(b.lastRun)||0:0)-(a.lastRun?Date.parse(a.lastRun)||0:0)||a.name.localeCompare(b.name)); }
function renderStats(items){ const count=o=>items.filter(item=>item.outcome===o).length; document.getElementById("stats").innerHTML=`<div class="stat"><strong>${items.length}</strong><span>records across ${allDays.length} days</span></div><div class="stat"><strong>${count("success")}</strong><span>successful</span></div><div class="stat"><strong>${count("failure")}</strong><span>failed</span></div><div class="stat"><strong>${count("unknown")}</strong><span>unknown</span></div>`; }
const rowHtml = item => `<article class="row"><div><div class="name">${esc(item.name)}</div><div class="meta">${esc(item.machine||item.location||((item.aliases||[]).join(", ")))}</div></div><div><span class="result ${item.outcome}"><i class="mark">${mark(item.outcome)}</i>${esc(item.outcome)}</span></div><div>${esc(dateText(item.lastRun))}</div><div>${esc(item.source)}</div><div>${esc(item.project||"—")}</div><div>${esc(item.opsSegment||"—")}</div><div>${esc(item.detail||"—")}</div></article>`;
function render(){ const sections=allDays.map(day=>{ const items=filtered(day); return items.length?`<div class="day-heading">${esc(day.date)} · ${esc(dateText(day.generatedAt))}</div>${items.map(rowHtml).join("")}`:""; }).join(""); const visible=allDays.flatMap(day=>filtered(day)); renderStats(allRecords); document.getElementById("rows").innerHTML=sections||'<div class="empty">No results match these filters.</div>'; document.getElementById("foot").textContent=`Showing ${visible.length} of ${allRecords.length} records across ${allDays.length} days. Newest day appears first; history is retained for three days.`; }
document.getElementById("source").textContent=`Registry: ${data.statusRegistry} · ${data.workbookRange} · Generated ${dateText(data.generatedAt)}`;
document.getElementById("search").addEventListener("input",e=>{state.search=e.target.value;render()}); ["scope","outcome","sourceFilter","project","opsSegment"].forEach(id=>document.getElementById(id).addEventListener("change",e=>{state[id]=e.target.value;render()})); render();
</script>
</body>
</html>