Style the UI on the FLARE unified rail
Follows the rebuild's design rather than inventing a palette: the 232px navy rail from portal.css (#192858), its 44px head and appbar, cyan-400 for the current page and its 2px left marker, 18px stroke icons, 11px uppercase headings with 2px tracking, and the navy surface/border steps from tokens.css. Behaviour comes from the same place: one native <details> per group so the tree opens without a script and the current page's path renders open, a one-item group rendered as a plain link, aria-current instead of a class, inward focus rings because the rail scrolls, and an off-canvas rail below 901px reopened by a :target fragment. A collapse toggle shrinks it to the 40px icon cell and remembers the choice. Verified on the bench S21 Pro: the page on port 80 renders the rail with icons and the open Mining section.
This commit is contained in:
@@ -189,42 +189,124 @@ pub fn validate_deck(text: &str) -> Result<Value, String> {
|
||||
}
|
||||
|
||||
/// Render one page inside the shell.
|
||||
///
|
||||
/// The rail follows the FLARE/Warden console: a 232px navy column with a 44px
|
||||
/// head, one native `<details>` per group so the tree opens and closes with no
|
||||
/// script, and the current page marked with `aria-current` rather than a class
|
||||
/// alone. Below 901px it slides off-canvas and comes back as a `:target`
|
||||
/// fragment, which is the one disclosure a locked-down page can still use.
|
||||
pub fn page(active: &str, title: &str, body: &str) -> String {
|
||||
format!(
|
||||
"<!doctype html>\n<html lang=\"en\"><head><meta charset=\"utf-8\">\
|
||||
<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\
|
||||
<title>{title} - Alkane</title><style>{CSS}</style></head><body>\
|
||||
<nav class=\"side\">{nav}</nav><main><header><h1>{title}</h1><span id=\"live\" class=\"pill\">connecting</span></header>{body}</main>\
|
||||
<title>{title} - Alkane</title><style>{CSS}</style></head>\
|
||||
<body class=\"shell\"><aside class=\"rail\" id=\"rail\">{rail_head}{nav}</aside>\
|
||||
<main class=\"content\"><header class=\"appbar\">\
|
||||
<a class=\"appbar__menu\" href=\"#rail\" aria-label=\"Menu\">Menu</a>\
|
||||
<h1 class=\"page-title\">{title}</h1><span id=\"live\" class=\"pill\">connecting</span></header>\
|
||||
<div class=\"frame\">{body}</div></main>\
|
||||
<script>{JS}</script></body></html>",
|
||||
title = escape(title),
|
||||
rail_head = rail_head(),
|
||||
nav = sidebar(active),
|
||||
)
|
||||
}
|
||||
|
||||
fn sidebar(active: &str) -> String {
|
||||
let mut out = String::from("<div class=\"brand\">Alkane</div>");
|
||||
for group in NAV.iter() {
|
||||
out.push_str(&format!(
|
||||
"<div class=\"group\">{}</div><ul>",
|
||||
escape(group.label)
|
||||
));
|
||||
for item in group.items {
|
||||
let class = if item.path == active {
|
||||
" class=\"on\""
|
||||
} else {
|
||||
""
|
||||
};
|
||||
out.push_str(&format!(
|
||||
"<li><a href=\"#{}\"{class}>{}</a></li>",
|
||||
item.path,
|
||||
escape(item.label)
|
||||
));
|
||||
}
|
||||
out.push_str("</ul>");
|
||||
fn rail_head() -> String {
|
||||
"<div class=\"rail__head\"><span class=\"rail__brand\">Alkane</span>\
|
||||
<button class=\"rail__toggle\" type=\"button\" aria-label=\"Collapse sidebar\" title=\"Collapse sidebar\">☰</button></div>"
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// An 18px stroke icon for a destination, matching the rail's icon column.
|
||||
fn icon(path: &str) -> &'static str {
|
||||
let body = match path {
|
||||
"/" => "<rect x=\"3\" y=\"3\" width=\"7\" height=\"7\" rx=\"1\"/><rect x=\"14\" y=\"3\" width=\"7\" height=\"7\" rx=\"1\"/><rect x=\"3\" y=\"14\" width=\"7\" height=\"7\" rx=\"1\"/><rect x=\"14\" y=\"14\" width=\"7\" height=\"7\" rx=\"1\"/>",
|
||||
"/mining" => "<path d=\"M4 20V10M10 20V4M16 20v-7M22 20H2\"/>",
|
||||
"/mining/hashboards" => "<rect x=\"5\" y=\"5\" width=\"14\" height=\"14\" rx=\"2\"/><path d=\"M9 2v3M15 2v3M9 19v3M15 19v3M2 9h3M2 15h3M19 9h3M19 15h3\"/>",
|
||||
"/mining/power" => "<path d=\"M13 2 4 14h7l-1 8 9-12h-7z\"/>",
|
||||
"/mining/fans" => "<circle cx=\"12\" cy=\"12\" r=\"2\"/><path d=\"M12 10c0-4 1-7 4-7 2 0 3 2 3 4 0 3-3 5-7 5M14 12c4 0 7 1 7 4 0 2-2 3-4 3-3 0-5-3-5-7M12 14c0 4-1 7-4 7-2 0-3-2-3-4 0-3 3-5 7-5M10 12c-4 0-7-1-7-4 0-2 2-3 4-3 3 0 5 3 5 7\"/>",
|
||||
"/settings/system" => "<rect x=\"3\" y=\"4\" width=\"18\" height=\"6\" rx=\"1\"/><rect x=\"3\" y=\"14\" width=\"18\" height=\"6\" rx=\"1\"/><path d=\"M7 7h.01M7 17h.01\"/>",
|
||||
"/settings/drivers" => "<rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\"/><path d=\"M9 9h6v6H9z\"/>",
|
||||
"/settings/security" => "<rect x=\"4\" y=\"10\" width=\"16\" height=\"10\" rx=\"2\"/><path d=\"M8 10V7a4 4 0 0 1 8 0v3\"/>",
|
||||
"/settings/services" => "<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M10 8l6 4-6 4z\"/>",
|
||||
"/settings/monitor" => "<path d=\"M2 12h4l3-8 4 16 3-8h6\"/>",
|
||||
"/settings/logs" => "<path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\"/><path d=\"M14 2v6h6M8 13h8M8 17h5\"/>",
|
||||
"/settings/files" => "<path d=\"M3 7a2 2 0 0 1 2-2h5l2 2h7a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\"/>",
|
||||
"/settings/terminal" => "<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\"/><path d=\"M7 9l3 3-3 3M13 15h4\"/>",
|
||||
_ => "<circle cx=\"12\" cy=\"12\" r=\"9\"/>",
|
||||
};
|
||||
// The strings above are static markup, never user input.
|
||||
let html = format!(
|
||||
"<svg class=\"rail__icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" \
|
||||
stroke-width=\"1.7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">{body}</svg>"
|
||||
);
|
||||
Box::leak(html.into_boxed_str())
|
||||
}
|
||||
|
||||
fn group_icon_svg(label: &str) -> &'static str {
|
||||
let body = match label {
|
||||
"Mining" => "<rect x=\"5\" y=\"5\" width=\"14\" height=\"14\" rx=\"2\"/><path d=\"M9 2v3M15 2v3M9 19v3M15 19v3M2 9h3M2 15h3M19 9h3M19 15h3\"/>",
|
||||
"Settings" => "<circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.9-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.9 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1A1.7 1.7 0 0 0 4.6 9a1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.9.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z\"/>",
|
||||
_ => "",
|
||||
};
|
||||
if body.is_empty() {
|
||||
return "";
|
||||
}
|
||||
let html = format!(
|
||||
"<svg class=\"rail__icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" \
|
||||
stroke-width=\"1.7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">{body}</svg>"
|
||||
);
|
||||
Box::leak(html.into_boxed_str())
|
||||
}
|
||||
|
||||
fn sidebar(active: &str) -> String {
|
||||
let mut out = String::from("<nav class=\"rail__nav\">");
|
||||
let mut first = true;
|
||||
for group in NAV.iter() {
|
||||
// A one-item group is a plain link, exactly as the FLARE rail renders
|
||||
// Dashboard: a disclosure around a single leaf is a control that only
|
||||
// hides the thing it names.
|
||||
if group.items.len() == 1 {
|
||||
let item = &group.items[0];
|
||||
out.push_str(&rail_link(item, active, "rail__link"));
|
||||
} else {
|
||||
let open = group.items.iter().any(|item| item.path == active);
|
||||
out.push_str(&format!(
|
||||
"<details class=\"tree\"{open}>\
|
||||
<summary class=\"rail__link tree__summary\">{icon}<span class=\"rail__label\">{label}</span><span class=\"rail__chevron\" aria-hidden=\"true\"></span></summary>\
|
||||
<ul class=\"tree__list\">",
|
||||
open = if open { " open" } else { "" },
|
||||
label = escape(group.label),
|
||||
icon = group_icon_svg(group.label),
|
||||
));
|
||||
for item in group.items {
|
||||
out.push_str(&rail_link(item, active, "rail__link tree__leaf"));
|
||||
}
|
||||
out.push_str("</ul></details>");
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
let _ = first;
|
||||
out.push_str("</nav>");
|
||||
out
|
||||
}
|
||||
|
||||
fn rail_link(item: &Item, active: &str, class: &str) -> String {
|
||||
let current = if item.path == active {
|
||||
" aria-current=\"page\""
|
||||
} else {
|
||||
""
|
||||
};
|
||||
format!(
|
||||
"<a class=\"{class}\" href=\"#{path}\"{current}>{icon}<span class=\"rail__label\">{label}</span></a>",
|
||||
class = class,
|
||||
path = item.path,
|
||||
label = escape(item.label),
|
||||
icon = icon(item.path),
|
||||
)
|
||||
}
|
||||
|
||||
/// A dashboard page: the editor chrome plus the document the client loads.
|
||||
pub fn dashboard_page(deck: &str, editable: bool) -> String {
|
||||
let deck = escape(deck);
|
||||
@@ -296,40 +378,120 @@ pub fn table_page(headers: &[&str], rows: &[Vec<String>]) -> String {
|
||||
}
|
||||
|
||||
const CSS: &str = r#"
|
||||
:root{color-scheme:dark}*{box-sizing:border-box}
|
||||
body{margin:0;display:grid;grid-template-columns:220px 1fr;min-height:100vh;background:#0d1117;color:#e6edf3;font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,sans-serif}
|
||||
.side{background:#11161d;border-right:1px solid #222c37;padding:14px 0;position:sticky;top:0;height:100vh;overflow:auto}
|
||||
.brand{font-weight:700;font-size:17px;padding:0 16px 12px;letter-spacing:.3px}
|
||||
.group{padding:14px 16px 4px;font-size:11px;text-transform:uppercase;letter-spacing:.8px;color:#7d8b9a}
|
||||
.side ul{list-style:none;margin:0;padding:0}
|
||||
.side a{display:block;padding:7px 16px;color:#c3cfdb;text-decoration:none;border-left:2px solid transparent}
|
||||
.side a:hover{background:#161d26;color:#fff}
|
||||
.side a.on{background:#161d26;color:#fff;border-left-color:#3b82f6;font-weight:600}
|
||||
main{padding:18px 22px;min-width:0}
|
||||
header{display:flex;align-items:center;gap:12px;margin-bottom:14px}
|
||||
h1{font-size:19px;margin:0;font-weight:650}
|
||||
.pill{font-size:11px;padding:3px 9px;border-radius:999px;background:#1c2530;color:#9fb0c0;border:1px solid #263241}
|
||||
.pill.ok{color:#7ee787;border-color:#1f4d2c;background:#10231a}
|
||||
.pill.bad{color:#ff9b9b;border-color:#552323;background:#261013}
|
||||
.bar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:14px}
|
||||
button{background:#1b2431;color:#dbe6f1;border:1px solid #2a3949;border-radius:7px;padding:7px 11px;font:inherit;cursor:pointer}
|
||||
button:hover:not(:disabled){background:#233043}
|
||||
:root{
|
||||
color-scheme:dark;
|
||||
/* FLARE tokens: navy scale, cyan action, the same steps portal.css uses. */
|
||||
--navy-900:#070D1D; --navy-800:#0B1020; --navy-700:#192858; --navy-600:#1E4E90;
|
||||
--cyan-400:#3ABCF8; --cyan-500:#31A2D6; --orange-500:#F26522;
|
||||
--text:#FFFFFF; --text-muted:#BABABA;
|
||||
--border:#192858;
|
||||
--space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-6:24px;
|
||||
--font-display:'Creato Display','Sora','Segoe UI','Selawik',system-ui,-apple-system,sans-serif;
|
||||
--font-body:'Segoe UI','Selawik',system-ui,-apple-system,sans-serif;
|
||||
--text-xs:12px; --text-sm:14px; --text-base:16px;
|
||||
}
|
||||
*{box-sizing:border-box}
|
||||
body.shell{margin:0;display:flex;min-height:100vh;background:var(--navy-900);color:var(--text);
|
||||
font:var(--text-sm)/1.45 var(--font-body)}
|
||||
a{color:var(--cyan-400);text-decoration:none}
|
||||
:focus-visible{outline:2px solid var(--cyan-400);outline-offset:2px}
|
||||
|
||||
/* --- rail: the Warden console's sidebar ------------------------------- */
|
||||
.rail{flex:none;width:232px;background:var(--navy-700);border-right:1px solid #1E2A4E;
|
||||
display:flex;flex-direction:column;position:sticky;top:0;height:100vh;overflow-y:auto;
|
||||
overscroll-behavior:contain}
|
||||
.rail__head{display:flex;align-items:center;gap:var(--space-2);min-height:44px;
|
||||
padding:0 var(--space-3);border-bottom:1px solid #1E2A4E}
|
||||
.rail__brand{font-family:var(--font-display);font-weight:700;font-size:var(--text-base);
|
||||
letter-spacing:.02em}
|
||||
.rail__nav{padding:var(--space-2) 0;display:flex;flex-direction:column}
|
||||
.rail__link{display:flex;align-items:center;gap:var(--space-3);min-height:36px;
|
||||
padding:var(--space-2) var(--space-4);color:#E6ECF5;font-size:var(--text-sm);font-weight:600;
|
||||
border-left:2px solid transparent;min-width:0}
|
||||
.rail__link:hover{background:rgba(255,255,255,.06)}
|
||||
.rail__link[aria-current='page']{border-left-color:var(--cyan-400);color:var(--cyan-400);
|
||||
background:rgba(255,255,255,.06)}
|
||||
.tree>summary{list-style:none;cursor:pointer}
|
||||
.tree>summary::-webkit-details-marker{display:none}
|
||||
.rail__chevron{margin-left:auto;width:0;height:0;border-left:4px solid transparent;
|
||||
border-right:4px solid transparent;border-top:5px solid #9AA5BB}
|
||||
.tree[open]>summary .rail__chevron{transform:rotate(180deg)}
|
||||
.tree__list{list-style:none;margin:0;padding:0}
|
||||
.tree__leaf{font-weight:400;color:#9AA5BB;min-height:32px;
|
||||
padding-left:calc(var(--space-4) + var(--space-3))}
|
||||
.tree__leaf:hover{color:#E6ECF5}
|
||||
.tree__leaf[aria-current='page']{color:var(--cyan-400);font-weight:600}
|
||||
.rail a:focus-visible,.rail summary:focus-visible{outline-offset:-2px}
|
||||
.rail__icon{width:18px;height:18px;flex:none}
|
||||
.rail__label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.rail__toggle{margin-left:auto;background:transparent;border:0;color:#9AA5BB;cursor:pointer;
|
||||
padding:4px;font-size:14px;line-height:1}
|
||||
.rail__toggle:hover{color:#E6ECF5}
|
||||
|
||||
/* Collapsed: icons only, and only where the rail is docked. Labels are clipped
|
||||
rather than removed so they keep their accessible name. */
|
||||
@media (min-width:901px){
|
||||
.shell--collapsed .rail{width:41px}
|
||||
.shell--collapsed .rail__label,
|
||||
.shell--collapsed .rail__brand{position:absolute;width:1px;height:1px;overflow:hidden;
|
||||
clip-path:inset(50%);white-space:nowrap}
|
||||
.shell--collapsed .tree__list,
|
||||
.shell--collapsed .rail__chevron{display:none}
|
||||
.shell--collapsed .rail__link{justify-content:center;padding-left:0;padding-right:2px}
|
||||
.shell--collapsed .rail__head{justify-content:center;padding-inline:0}
|
||||
}
|
||||
|
||||
/* --- content column ---------------------------------------------------- */
|
||||
.content{flex:1;min-width:0;display:flex;flex-direction:column}
|
||||
.appbar{display:flex;align-items:center;gap:var(--space-4);min-height:44px;
|
||||
padding:0 var(--space-6);border-bottom:1px solid var(--border);
|
||||
position:sticky;top:0;z-index:40;background:var(--navy-900)}
|
||||
.page-title{font-family:var(--font-display);font-size:22px;font-weight:700;line-height:1.1;
|
||||
margin:0;letter-spacing:-.01em}
|
||||
.appbar__menu{display:none;font-size:var(--text-sm);color:var(--cyan-400)}
|
||||
.pill{margin-left:auto;font-size:var(--text-xs);padding:3px 9px;border-radius:999px;
|
||||
background:var(--navy-800);color:var(--text-muted);border:1px solid var(--border)}
|
||||
.pill.ok{color:#7EE787;border-color:#1F4D2C}
|
||||
.pill.bad{color:#FF9B9B;border-color:#552323}
|
||||
.frame{padding:var(--space-6);display:flex;flex-direction:column;gap:var(--space-6)}
|
||||
|
||||
/* --- blocks ------------------------------------------------------------ */
|
||||
.bar{display:flex;gap:var(--space-3);align-items:center;flex-wrap:wrap}
|
||||
h2,.card h2{font-family:var(--font-display);font-size:11px;font-weight:600;line-height:1.15;
|
||||
text-transform:uppercase;letter-spacing:2px;color:var(--text-muted);margin:0 0 var(--space-2)}
|
||||
button{font:inherit;cursor:pointer;border-radius:6px;padding:7px 12px;
|
||||
background:var(--navy-700);color:var(--text);border:1px solid #1E2A4E}
|
||||
button:hover:not(:disabled){background:var(--navy-600)}
|
||||
button:disabled{opacity:.4;cursor:default}
|
||||
select{background:#1b2431;color:#dbe6f1;border:1px solid #2a3949;border-radius:7px;padding:6px 8px;font:inherit}
|
||||
.grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
|
||||
.card{background:#11161d;border:1px solid #222c37;border-radius:10px;padding:12px 14px;min-height:96px}
|
||||
.card.drag{outline:1px dashed #3b82f6}
|
||||
.card h2{font-size:12px;margin:0 0 8px;color:#8fa2b5;font-weight:600;text-transform:uppercase;letter-spacing:.6px}
|
||||
.card .big{font-size:28px;font-weight:650;letter-spacing:-.5px}
|
||||
.card .unit{font-size:12px;color:#7d8b9a;margin-left:4px}
|
||||
table{width:100%;border-collapse:collapse;font-size:13px}
|
||||
th,td{text-align:left;padding:7px 9px;border-bottom:1px solid #1d2733}
|
||||
th{color:#8fa2b5;font-weight:600;font-size:11px;text-transform:uppercase;letter-spacing:.5px}
|
||||
table.kv th{width:220px}
|
||||
.muted{color:#7d8b9a}
|
||||
select,input[type=text]{font:inherit;color:var(--text);background:var(--navy-900);
|
||||
border:1px solid #1E2A4E;border-radius:6px;padding:6px 8px}
|
||||
input[type=text]{min-width:320px;padding:8px 10px}
|
||||
.grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:var(--space-4)}
|
||||
.card{background:var(--navy-800);border:1px solid var(--border);border-radius:8px;
|
||||
padding:var(--space-4);min-height:96px}
|
||||
.card.drag{outline:1px dashed var(--cyan-400);outline-offset:2px}
|
||||
.card .big{font-family:var(--font-display);font-size:28px;font-weight:700;letter-spacing:-.5px}
|
||||
.card .unit{font-size:var(--text-xs);color:var(--text-muted);margin-left:var(--space-1)}
|
||||
.span2{grid-column:span 2}.span3{grid-column:span 3}.span4{grid-column:span 4}
|
||||
pre{background:#0b0f14;border:1px solid #1d2733;border-radius:8px;padding:12px;overflow:auto;max-height:60vh;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}
|
||||
input[type=text]{background:#0b0f14;border:1px solid #2a3949;border-radius:7px;color:#e6edf3;padding:8px 10px;font:inherit;min-width:320px}
|
||||
table{width:100%;border-collapse:collapse;font-size:var(--text-sm)}
|
||||
th,td{text-align:left;padding:8px 10px;border-bottom:1px solid #14203C}
|
||||
th{font-family:var(--font-display);font-size:11px;font-weight:600;text-transform:uppercase;
|
||||
letter-spacing:2px;color:var(--text-muted)}
|
||||
table.kv th{width:220px;color:var(--text-muted);font-weight:600;text-transform:none;
|
||||
letter-spacing:0;font-family:var(--font-body);font-size:var(--text-sm)}
|
||||
.muted{color:var(--text-muted)}
|
||||
pre{background:var(--navy-900);border:1px solid var(--border);border-radius:8px;
|
||||
padding:var(--space-4);overflow:auto;max-height:60vh;
|
||||
font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}
|
||||
|
||||
/* Off-canvas below 901px, reopened by the fragment so it works without a
|
||||
script, exactly as portal.css does it. */
|
||||
@media (max-width:900px){
|
||||
.shell{display:block}
|
||||
.rail{position:fixed;inset:0 auto 0 0;transform:translateX(-100%);z-index:60}
|
||||
.rail:target{transform:none}
|
||||
.appbar__menu{display:inline-flex}
|
||||
}
|
||||
"#;
|
||||
|
||||
const JS: &str = r#"
|
||||
@@ -345,6 +507,18 @@ function poll(){fetch("/api/summary").then(function(r){return r.json()}).then(fu
|
||||
}).catch(function(){var el=$("live"); if(el){el.textContent="offline"; el.className="pill bad"}})}
|
||||
setInterval(poll,5000); poll();
|
||||
|
||||
// Rail collapse. The state is remembered so a reload keeps the operator's
|
||||
// choice; the button is the only control that needs a script.
|
||||
(function(){
|
||||
var key="alkane.rail.collapsed";
|
||||
try{if(localStorage.getItem(key)==="1")document.body.classList.add("shell--collapsed")}catch(e){}
|
||||
var toggle=document.querySelector(".rail__toggle");
|
||||
if(toggle)toggle.addEventListener("click",function(){
|
||||
var on=document.body.classList.toggle("shell--collapsed");
|
||||
try{localStorage.setItem(key,on?"1":"0")}catch(e){}
|
||||
});
|
||||
})();
|
||||
|
||||
var grid=$("grid");
|
||||
if(grid){
|
||||
var deck=grid.dataset.deck, editable=grid.dataset.editable==="1", doc=null, dragId=null;
|
||||
@@ -481,10 +655,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sidebar_marks_the_active_page() {
|
||||
fn sidebar_marks_the_active_page_and_opens_its_group() {
|
||||
let html = page("/mining/fans", "Fans", "");
|
||||
assert!(html.contains("href=\"#/mining/fans\" class=\"on\""));
|
||||
assert!(html.contains("href=\"#/mining/fans\" aria-current=\"page\""));
|
||||
// Exactly the group holding the current page is open; the other is not.
|
||||
assert_eq!(html.matches("<details class=\"tree\" open>").count(), 1);
|
||||
assert!(html.contains("Power Supply"));
|
||||
assert!(html.contains("href=\"#/settings/terminal\""));
|
||||
// A one-item group is a plain link, not a disclosure around a leaf.
|
||||
assert!(html.contains("class=\"rail__link\" href=\"#/\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user