Runners list is a row per runner with a status dot, a job meter, a compact concurrency stepper and a quiet version line
Browse files at this commit50f6fbedc689df4fc6db7ca1ef1d6ab328865cf5Parent: 7f81083- style
- runners list is a row per runner with a status dot, a job meter, a compact concurrency stepper and a quiet version line
4 changed files +367 -247
- crates/forge-web/assets/nav.js +25 -1
- crates/forge-web/src/i18n/admin.rs +0 -4
- crates/forge-web/src/pages/admin_runners.rs +127 -89
- style/main.scss +215 -153
crates/forge-web/assets/nav.jsmodified+25 -1
| @@ -8,7 +8,8 @@ | |||
| 8 | window.__forgeSoft = true; | 8 | window.__forgeSoft = true; |
| 9 | 9 | ||
| 10 | var root = document.documentElement; | 10 | var root = document.documentElement; |
| 11 | - var latest = 0; // id of the newest request; older responses are dropped | 11 | + root.classList.add('js'); // CSS hides JS-only controls (a Save that shows on change) under html.js |
| 12 | + var latest = 0; // id of the newest request; older responses are dropped | ||
| 12 | var userBusy = 0; // navigations and form posts on the wire (not live refreshes) | 13 | var userBusy = 0; // navigations and form posts on the wire (not live refreshes) |
| 13 | var liveDirty = false; // a live change came while a navigation or a live fetch was on the wire | 14 | var liveDirty = false; // a live change came while a navigation or a live fetch was on the wire |
| 14 | var liveForced = false; // that change re-renders the page even with no stream of its own | 15 | var liveForced = false; // that change re-renders the page even with no stream of its own |
| @@ -755,6 +756,29 @@ | |||
| 755 | searchTimer = setTimeout(function () { searchTimer = null; liveSearch(input); }, 250); | 756 | searchTimer = setTimeout(function () { searchTimer = null; liveSearch(input); }, 250); |
| 756 | }); | 757 | }); |
| 757 | 758 | ||
| 759 | + // A form marked data-dirty-form shows its Save only once a field differs from its rendered value: | ||
| 760 | + // the input sets data-dirty on the form, and the stepper buttons (data-step) move the number field | ||
| 761 | + // inside their form, clamped to its min and max, then fire `input` like typing does. | ||
| 762 | + document.addEventListener('input', function (e) { | ||
| 763 | + var form = e.target && e.target.form ? e.target.form : null; | ||
| 764 | + if (!form || !form.hasAttribute('data-dirty-form')) { return; } | ||
| 765 | + if (e.target.defaultValue !== e.target.value) { form.setAttribute('data-dirty', ''); } | ||
| 766 | + else { form.removeAttribute('data-dirty'); } | ||
| 767 | + }); | ||
| 768 | + document.addEventListener('click', function (e) { | ||
| 769 | + var btn = e.target && e.target.closest ? e.target.closest('[data-step]') : null; | ||
| 770 | + if (!btn || !btn.form) { return; } | ||
| 771 | + var field = btn.form.querySelector('input[type="number"]'); | ||
| 772 | + if (!field) { return; } | ||
| 773 | + var next = (parseFloat(field.value) || 0) + (parseFloat(btn.getAttribute('data-step')) || 0); | ||
| 774 | + var min = parseFloat(field.min); | ||
| 775 | + var max = parseFloat(field.max); | ||
| 776 | + if (!isNaN(min)) { next = Math.max(min, next); } | ||
| 777 | + if (!isNaN(max)) { next = Math.min(max, next); } | ||
| 778 | + field.value = String(next); | ||
| 779 | + field.dispatchEvent(new Event('input', { bubbles: true })); | ||
| 780 | + }); | ||
| 781 | + | ||
| 758 | // A checkbox marked data-select-all="<selector>" ticks or clears every checkbox inside the first | 782 | // A checkbox marked data-select-all="<selector>" ticks or clears every checkbox inside the first |
| 759 | // element that matches the selector (the bulk import list). | 783 | // element that matches the selector (the bulk import list). |
| 760 | document.addEventListener('change', function (e) { | 784 | document.addEventListener('change', function (e) { |
crates/forge-web/src/i18n/admin.rsmodified+0 -4
| @@ -159,7 +159,6 @@ pub enum K { | |||
| 159 | TableError, | 159 | TableError, |
| 160 | TableKind, | 160 | TableKind, |
| 161 | TableLastError, | 161 | TableLastError, |
| 162 | - TableName, | ||
| 163 | TableQueued, | 162 | TableQueued, |
| 164 | TableRepo, | 163 | TableRepo, |
| 165 | TableResult, | 164 | TableResult, |
| @@ -552,8 +551,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 552 | (TableKind, Tr) => "Tür", | 551 | (TableKind, Tr) => "Tür", |
| 553 | (TableLastError, En) => "Last error", | 552 | (TableLastError, En) => "Last error", |
| 554 | (TableLastError, Tr) => "Son hata", | 553 | (TableLastError, Tr) => "Son hata", |
| 555 | - (TableName, En) => "Name", | ||
| 556 | - (TableName, Tr) => "Ad", | ||
| 557 | (TableQueued, En) => "Queued", | 554 | (TableQueued, En) => "Queued", |
| 558 | (TableQueued, Tr) => "Kuyruğa alındı", | 555 | (TableQueued, Tr) => "Kuyruğa alındı", |
| 559 | (TableRepo, En) => "Repo", | 556 | (TableRepo, En) => "Repo", |
| @@ -948,7 +945,6 @@ mod tests { | |||
| 948 | K::TableError, | 945 | K::TableError, |
| 949 | K::TableKind, | 946 | K::TableKind, |
| 950 | K::TableLastError, | 947 | K::TableLastError, |
| 951 | - K::TableName, | ||
| 952 | K::TableQueued, | 948 | K::TableQueued, |
| 953 | K::TableRepo, | 949 | K::TableRepo, |
| 954 | K::TableResult, | 950 | K::TableResult, |
crates/forge-web/src/pages/admin_runners.rsmodified+127 -89
| @@ -9,6 +9,7 @@ | |||
| 9 | use forge_ci::build::{self, Freshness}; | 9 | use forge_ci::build::{self, Freshness}; |
| 10 | use forge_core::AuditAction; | 10 | use forge_core::AuditAction; |
| 11 | use forge_core::ci::{CiRunner, FieldKind, RUNNER_FIELDS, RestartMode, runner_field}; | 11 | use forge_core::ci::{CiRunner, FieldKind, RUNNER_FIELDS, RestartMode, runner_field}; |
| 12 | +use forge_core::store::health::RUNNER_ONLINE_SECS; | ||
| 12 | use serde::Deserialize; | 13 | use serde::Deserialize; |
| 13 | use time::OffsetDateTime; | 14 | use time::OffsetDateTime; |
| 14 | use time::format_description::well_known::Rfc3339; | 15 | use time::format_description::well_known::Rfc3339; |
| @@ -138,7 +139,12 @@ struct DisableForm { | |||
| 138 | /// One runner row, already formatted. | 139 | /// One runner row, already formatted. |
| 139 | struct RunnerRow { | 140 | struct RunnerRow { |
| 140 | name: String, | 141 | name: String, |
| 141 | - labels: Vec<String>, | 142 | + /// The labels as plain text, joined with " · ". |
| 143 | + labels: String, | ||
| 144 | + /// The status dot's class: online, offline or disabled. | ||
| 145 | + dot_class: &'static str, | ||
| 146 | + /// The dot's accessible name and tooltip. | ||
| 147 | + state_text: &'static str, | ||
| 142 | /// "5 minutes ago", or "never". | 148 | /// "5 minutes ago", or "never". |
| 143 | last_seen: String, | 149 | last_seen: String, |
| 144 | /// The absolute time in the viewer's zone, for the `title` tooltip. Empty when never seen. | 150 | /// The absolute time in the viewer's zone, for the `title` tooltip. Empty when never seen. |
| @@ -165,17 +171,42 @@ struct RunnerRow { | |||
| 165 | build: String, | 171 | build: String, |
| 166 | /// Its commit sha alone, for the table and the stat strip; the full string is the tooltip. | 172 | /// Its commit sha alone, for the table and the stat strip; the full string is the tooltip. |
| 167 | build_short: String, | 173 | build_short: String, |
| 168 | - /// "up to date", "outdated" or "unknown", with the `.ci-state` class that colours it. | 174 | + /// "up to date", "outdated" or "unknown", with the `.ci-state` class the detail page colours it with. |
| 169 | build_label: &'static str, | 175 | build_label: &'static str, |
| 170 | build_class: &'static str, | 176 | build_class: &'static str, |
| 177 | + /// "ok", "warn" or "muted": how the version status is coloured on the list. | ||
| 178 | + build_tone: &'static str, | ||
| 179 | + /// The concurrency the admin set or the runner reported, for the load meter's maximum. | ||
| 180 | + /// Empty when the runner has not reported one. | ||
| 181 | + concurrency_max: u32, | ||
| 171 | } | 182 | } |
| 172 | 183 | ||
| 173 | -/// How the runner's reported build compares with this server's, as a badge label and class. | 184 | +/// How the runner's reported build compares with this server's: the label, the `.ci-state` class |
| 174 | -fn build_badge(lang: Lang, runner: &CiRunner) -> (&'static str, &'static str) { | 185 | +/// and the list tone. |
| 186 | +fn build_badge(lang: Lang, runner: &CiRunner) -> (&'static str, &'static str, &'static str) { | ||
| 175 | match build::compare(runner.reported.build.as_deref(), &build::display()) { | 187 | match build::compare(runner.reported.build.as_deref(), &build::display()) { |
| 176 | - Freshness::UpToDate => (s(lang, "up to date", "güncel"), "ci-success"), | 188 | + Freshness::UpToDate => (s(lang, "up to date", "güncel"), "ci-success", "ok"), |
| 177 | - Freshness::Outdated => (s(lang, "outdated", "eski"), "ci-queued"), | 189 | + Freshness::Outdated => (s(lang, "outdated", "eski"), "ci-queued", "warn"), |
| 178 | - Freshness::Unknown => (s(lang, "unknown", "bilinmiyor"), "runner-disabled"), | 190 | + Freshness::Unknown => (s(lang, "unknown", "bilinmiyor"), "runner-disabled", "muted"), |
| 191 | + } | ||
| 192 | +} | ||
| 193 | + | ||
| 194 | +/// The status dot and its word: a disabled runner is a warning, a runner that checked in within | ||
| 195 | +/// the online window is green, and anything else is offline. | ||
| 196 | +fn dot_of(lang: Lang, runner: &CiRunner, now: i64) -> (&'static str, &'static str) { | ||
| 197 | + if runner.disabled { | ||
| 198 | + return ("runner-dot is-disabled", g::t(lang, K::Disabled)); | ||
| 199 | + } | ||
| 200 | + let limit = i64::try_from(RUNNER_ONLINE_SECS).unwrap_or(i64::MAX); | ||
| 201 | + let online = runner | ||
| 202 | + .last_seen_at | ||
| 203 | + .as_deref() | ||
| 204 | + .and_then(|stamp| OffsetDateTime::parse(stamp, &Rfc3339).ok()) | ||
| 205 | + .is_some_and(|at| at.unix_timestamp() >= now.saturating_sub(limit)); | ||
| 206 | + if online { | ||
| 207 | + ("runner-dot is-online", s(lang, "online", "çevrimiçi")) | ||
| 208 | + } else { | ||
| 209 | + ("runner-dot is-offline", s(lang, "offline", "çevrimdışı")) | ||
| 179 | } | 210 | } |
| 180 | } | 211 | } |
| 181 | 212 | ||
| @@ -214,10 +245,14 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { | |||
| 214 | None => (i18n::t(lang, Key::Never).to_owned(), String::new()), | 245 | None => (i18n::t(lang, Key::Never).to_owned(), String::new()), |
| 215 | }; | 246 | }; |
| 216 | let (concurrency, concurrency_source) = concurrency_of(runner); | 247 | let (concurrency, concurrency_source) = concurrency_of(runner); |
| 217 | - let (build_label, build_class) = build_badge(lang, runner); | 248 | + let (build_label, build_class, build_tone) = build_badge(lang, runner); |
| 249 | + let (dot_class, state_text) = dot_of(lang, runner, now); | ||
| 250 | + let concurrency_max = concurrency.parse().unwrap_or(0); | ||
| 218 | RunnerRow { | 251 | RunnerRow { |
| 219 | name: runner.name.clone(), | 252 | name: runner.name.clone(), |
| 220 | - labels: runner.labels.clone(), | 253 | + labels: runner.labels.join(" · "), |
| 254 | + dot_class, | ||
| 255 | + state_text, | ||
| 221 | last_seen, | 256 | last_seen, |
| 222 | last_seen_full, | 257 | last_seen_full, |
| 223 | last_seen_at: runner.last_seen_at.clone().unwrap_or_default(), | 258 | last_seen_at: runner.last_seen_at.clone().unwrap_or_default(), |
| @@ -242,6 +277,8 @@ fn runner_row(runner: &CiRunner, tz: &str, lang: Lang, now: i64) -> RunnerRow { | |||
| 242 | build: runner.reported.build.clone().unwrap_or_default(), | 277 | build: runner.reported.build.clone().unwrap_or_default(), |
| 243 | build_label, | 278 | build_label, |
| 244 | build_class, | 279 | build_class, |
| 280 | + build_tone, | ||
| 281 | + concurrency_max, | ||
| 245 | } | 282 | } |
| 246 | } | 283 | } |
| 247 | 284 | ||
| @@ -298,74 +335,59 @@ async fn runners_view( | |||
| 298 | if rows.is_empty() { | 335 | if rows.is_empty() { |
| 299 | <p class="muted">(g::t(lang, K::NoRunnersYet))</p> | 336 | <p class="muted">(g::t(lang, K::NoRunnersYet))</p> |
| 300 | } else { | 337 | } else { |
| 301 | - <div class="table-wrap runners-wrap"> | 338 | + <ul class="runner-list"> |
| 302 | - <table class="table runners"> | 339 | + for row in rows.iter() { |
| 303 | - <thead> | 340 | + <li class="runner-row"> |
| 304 | - <tr> | 341 | + <div class="runner-id"> |
| 305 | - <th class="runner-name">(g::t(lang, K::TableName))</th> | 342 | + <div class="runner-title"> |
| 306 | - <th class="runner-conc">(s(lang, "Concurrency", "Eşzamanlılık"))</th> | 343 | + <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span> |
| 307 | - <th class="runner-running">(s(lang, "Running", "Çalışan"))</th> | 344 | + <a class="runner-name" href=(row.detail_href.as_str())>(row.name.as_str())</a> |
| 308 | - <th class="runner-build">(s(lang, "Version", "Sürüm"))</th> | 345 | + if row.disabled { |
| 309 | - <th class="runner-seen">(g::t(lang, K::LastSeen))</th> | 346 | + <span class="runner-off">(g::t(lang, K::Disabled))</span> |
| 310 | - <th class="runner-state">(g::t(lang, K::TableState))</th> | 347 | + } |
| 311 | - <th class="runner-actions"><span class="sr-only">(s(lang, "Actions", "İşlemler"))</span></th> | 348 | + </div> |
| 312 | - </tr> | 349 | + <p class="runner-meta muted"> |
| 313 | - </thead> | 350 | + if !row.labels.is_empty() { |
| 314 | - <tbody> | 351 | + <span class="runner-labels">(row.labels.as_str())</span> |
| 315 | - for row in rows.iter() { | 352 | + " · " |
| 316 | - <tr> | 353 | + } |
| 317 | - <td class="runner-name"> | 354 | + (s(lang, "seen", "görüldü"))" "<time data-rel="true" datetime=(row.last_seen_at.as_str()) title=(row.last_seen_full.as_str())>(row.last_seen.as_str())</time> |
| 318 | - <a href=(row.detail_href.as_str())><strong>(row.name.as_str())</strong></a> | 355 | + if row.restart_pending.is_some() { |
| 319 | - <span class="runner-label-list"> | 356 | + " · " |
| 320 | - for label in row.labels.iter() { | 357 | + <span class="runner-off">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> |
| 321 | - <span class="runner-label">(label.as_str())</span> | 358 | + } |
| 322 | - } | 359 | + </p> |
| 323 | - </span> | 360 | + </div> |
| 324 | - </td> | 361 | + concurrency_form(lang: lang, csrf: csrf.as_str(), action: row.config_action.as_str(), key: "concurrency", value: row.concurrency.as_str(), source: row.concurrency_source, has_override: row.has_override, back: "list", running: row.running, max: row.concurrency_max) |
| 325 | - <td class="runner-conc" data-label=(s(lang, "Concurrency", "Eşzamanlılık"))> | 362 | + <div class="runner-version" title=(row.build.as_str())> |
| 326 | - concurrency_form(lang: lang, csrf: csrf.as_str(), action: row.config_action.as_str(), key: "concurrency", value: row.concurrency.as_str(), source: row.concurrency_source, has_override: row.has_override, back: "list") | 363 | + if !row.build_short.is_empty() { |
| 327 | - </td> | 364 | + <code class="runner-hash">(row.build_short.as_str())</code> |
| 328 | - <td class="runner-running small" data-label=(s(lang, "Running", "Çalışan"))>(row.running.to_string())</td> | 365 | + } |
| 329 | - <td class="runner-build small" data-label=(s(lang, "Version", "Sürüm")) title=(row.build.as_str())> | 366 | + if row.build_tone == "ok" { |
| 330 | - if !row.build_short.is_empty() { | 367 | + <span class="runner-status"><span class="runner-tick" aria-hidden="true">"✓"</span>" "(row.build_label)</span> |
| 331 | - <code>(row.build_short.as_str())</code> | 368 | + } else { |
| 332 | - } | 369 | + <span class=(format!("runner-status {}", row.build_tone))>(row.build_label)</span> |
| 333 | - <span class=(format!("ci-state {}", row.build_class))>(row.build_label)</span> | 370 | + } |
| 334 | - </td> | 371 | + </div> |
| 335 | - <td class="runner-seen small" data-label=(g::t(lang, K::LastSeen)) title=(row.last_seen_full.as_str())><time data-rel="true" datetime=(row.last_seen_at.as_str())>(row.last_seen.as_str())</time></td> | 372 | + <details class="row-menu"> |
| 336 | - <td class="runner-state" data-label=(g::t(lang, K::TableState))> | 373 | + <summary class="button row-menu-btn" aria-label=(s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> |
| 337 | - if row.disabled { | 374 | + <div class="row-menu-panel" role="menu"> |
| 338 | - <span class="ci-state runner-disabled">(g::t(lang, K::Disabled))</span> | 375 | + if row.disabled { |
| 339 | - } else { | 376 | + <form method="post" action=(row.toggle_action.as_str()) class="inline-form"> |
| 340 | - <span class="ci-state ci-success">(g::t(lang, K::Enabled))</span> | 377 | + <input type="hidden" name="csrf" value=(csrf.as_str())> |
| 341 | - } | 378 | + <input type="hidden" name="disabled" value="0"> |
| 342 | - if row.restart_pending.is_some() { | 379 | + <button type="submit">(g::t(lang, K::Enable))</button> |
| 343 | - <span class="ci-state runner-disabled">(s(lang, "restart pending", "yeniden başlatma bekliyor"))</span> | 380 | + </form> |
| 344 | - } | 381 | + } else { |
| 345 | - </td> | 382 | + confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), danger: false, fields: vec![("disabled", "1".into())]) |
| 346 | - <td class="runner-actions"> | 383 | + } |
| 347 | - <details class="row-menu"> | 384 | + restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "list", can_restart: row.can_restart, pending: row.restart_pending) |
| 348 | - <summary class="button row-menu-btn" aria-label=(s(lang, "Actions", "İşlemler")) aria-haspopup="menu">"⋯"</summary> | 385 | + confirm_post(lang: lang, csrf: csrf.as_str(), action: row.delete_action.as_str(), label: i18n::t(lang, Key::Delete), message: delete_message(lang, row.name.as_str()), confirm: s(lang, "Yes, delete", "Evet, sil"), danger: true, fields: vec![]) |
| 349 | - <div class="row-menu-panel" role="menu"> | 386 | + </div> |
| 350 | - if row.disabled { | 387 | + </details> |
| 351 | - <form method="post" action=(row.toggle_action.as_str()) class="inline-form"> | 388 | + </li> |
| 352 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | 389 | + } |
| 353 | - <input type="hidden" name="disabled" value="0"> | 390 | + </ul> |
| 354 | - <button type="submit">(g::t(lang, K::Enable))</button> | ||
| 355 | - </form> | ||
| 356 | - } else { | ||
| 357 | - confirm_post(lang: lang, csrf: csrf.as_str(), action: row.toggle_action.as_str(), label: g::t(lang, K::Disable), message: disable_message(lang, row.name.as_str()), confirm: s(lang, "Yes, disable", "Evet, devre dışı bırak"), danger: false, fields: vec![("disabled", "1".into())]) | ||
| 358 | - } | ||
| 359 | - restart_control(lang: lang, csrf: csrf.as_str(), action: row.restart_action.as_str(), back: "list", can_restart: row.can_restart, pending: row.restart_pending) | ||
| 360 | - confirm_post(lang: lang, csrf: csrf.as_str(), action: row.delete_action.as_str(), label: i18n::t(lang, Key::Delete), message: delete_message(lang, row.name.as_str()), confirm: s(lang, "Yes, delete", "Evet, sil"), danger: true, fields: vec![]) | ||
| 361 | - </div> | ||
| 362 | - </details> | ||
| 363 | - </td> | ||
| 364 | - </tr> | ||
| 365 | - } | ||
| 366 | - </tbody> | ||
| 367 | - </table> | ||
| 368 | - </div> | ||
| 369 | } | 391 | } |
| 370 | </section> | 392 | </section> |
| 371 | <section class="card"> | 393 | <section class="card"> |
| @@ -472,7 +494,9 @@ async fn restart_control( | |||
| 472 | }) | 494 | }) |
| 473 | } | 495 | } |
| 474 | 496 | ||
| 475 | -/// The inline number form for concurrency: input, Save, and a reset button while an override is set. | 497 | +/// The load cell of a runner: the jobs running out of the concurrency, a meter of the two, and the |
| 498 | +/// concurrency as a stepper. The − and + buttons step the input (nav.js); Save shows only once the | ||
| 499 | +/// value has changed, and stays visible without JavaScript. A reset button shows while an override is set. | ||
| 476 | #[component] | 500 | #[component] |
| 477 | async fn concurrency_form( | 501 | async fn concurrency_form( |
| 478 | lang: Lang, | 502 | lang: Lang, |
| @@ -483,17 +507,29 @@ async fn concurrency_form( | |||
| 483 | source: &'static str, | 507 | source: &'static str, |
| 484 | has_override: bool, | 508 | has_override: bool, |
| 485 | back: &'static str, | 509 | back: &'static str, |
| 510 | + running: u32, | ||
| 511 | + max: u32, | ||
| 486 | ) -> Result<impl View> { | 512 | ) -> Result<impl View> { |
| 513 | + let running = running.to_string(); | ||
| 514 | + let meter_max = max.max(1).to_string(); | ||
| 487 | Ok(view! { | 515 | Ok(view! { |
| 488 | - <form method="post" action=(action) class="inline-form runner-conc-form"> | 516 | + <form method="post" action=(action) class="runner-load" data-dirty-form=""> |
| 489 | <input type="hidden" name="csrf" value=(csrf)> | 517 | <input type="hidden" name="csrf" value=(csrf)> |
| 490 | <input type="hidden" name="key" value=(key)> | 518 | <input type="hidden" name="key" value=(key)> |
| 491 | <input type="hidden" name="back" value=(back)> | 519 | <input type="hidden" name="back" value=(back)> |
| 492 | - <input type="number" name="value" value=(value) min="1" max="64" step="1" inputmode="numeric" required="required" aria-label=(s(lang, "Concurrency", "Eşzamanlılık")) title=(source_title(lang, source))> | 520 | + <span class="runner-cap muted">(s(lang, "Jobs", "İşler"))</span> |
| 493 | - <button type="submit">(s(lang, "Save", "Kaydet"))</button> | 521 | + <div class="runner-line"> |
| 494 | - if has_override { | 522 | + <span class="runner-count">(running.as_str())</span> |
| 495 | - <button type="submit" name="reset" value="1" formnovalidate="formnovalidate" title=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan")) aria-label=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))>"↺"</button> | 523 | + <span class="muted">"/"</span> |
| 496 | - } | 524 | + <button type="button" class="runner-step" data-step="-1" aria-label=(s(lang, "Fewer", "Azalt"))>"−"</button> |
| 525 | + <input type="number" name="value" value=(value) min="1" max="64" step="1" inputmode="numeric" required="required" aria-label=(s(lang, "Concurrency", "Eşzamanlılık")) title=(source_title(lang, source))> | ||
| 526 | + <button type="button" class="runner-step" data-step="1" aria-label=(s(lang, "More", "Artır"))>"+"</button> | ||
| 527 | + <button type="submit" class="runner-save">(s(lang, "Save", "Kaydet"))</button> | ||
| 528 | + if has_override { | ||
| 529 | + <button type="submit" name="reset" value="1" formnovalidate="formnovalidate" title=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan")) aria-label=(s(lang, "Use the runner.toml value", "runner.toml değerini kullan"))>"↺"</button> | ||
| 530 | + } | ||
| 531 | + </div> | ||
| 532 | + <progress class="runner-meter" value=(running.as_str()) max=(meter_max.as_str()) aria-label=(s(lang, "Running jobs", "Çalışan işler"))></progress> | ||
| 497 | </form> | 533 | </form> |
| 498 | }) | 534 | }) |
| 499 | } | 535 | } |
| @@ -1640,7 +1676,7 @@ mod tests { | |||
| 1640 | // Only the hash is stored, so the list and the database hold no plain token. | 1676 | // Only the hash is stored, so the list and the database hold no plain token. |
| 1641 | assert!(store.list_runners().await.expect("list").is_empty()); | 1677 | assert!(store.list_runners().await.expect("list").is_empty()); |
| 1642 | 1678 | ||
| 1643 | - // Labels are separate chips and the state is a badge that follows disabling. | 1679 | + // Labels are one plain line joined by " · ", and the dot follows disabling. |
| 1644 | store | 1680 | store |
| 1645 | .register_runner( | 1681 | .register_runner( |
| 1646 | &token, | 1682 | &token, |
| @@ -1651,10 +1687,11 @@ mod tests { | |||
| 1651 | .expect("register"); | 1687 | .expect("register"); |
| 1652 | let (status, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 1688 | let (status, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; |
| 1653 | assert_eq!(status, 200); | 1689 | assert_eq!(status, 200); |
| 1654 | - assert!(page.contains(r#"<span class="runner-label">linux</span>"#)); | 1690 | + assert!(page.contains(r#"<span class="runner-labels">linux · x86_64</span>"#)); |
| 1655 | - assert!(page.contains(r#"<span class="runner-label">x86_64</span>"#)); | ||
| 1656 | assert!(!page.contains("linux, x86_64"), "labels are not joined"); | 1691 | assert!(!page.contains("linux, x86_64"), "labels are not joined"); |
| 1657 | - assert!(page.contains(r#"<span class="ci-state ci-success">enabled</span>"#)); | 1692 | + // Never seen, so offline; not disabled, so no disabled word. |
| 1693 | + assert!(page.contains(r#"class="runner-dot is-offline""#)); | ||
| 1694 | + assert!(!page.contains(r#"<span class="runner-off">disabled</span>"#)); | ||
| 1658 | 1695 | ||
| 1659 | let runner = store.list_runners().await.expect("list").remove(0); | 1696 | let runner = store.list_runners().await.expect("list").remove(0); |
| 1660 | store | 1697 | store |
| @@ -1662,7 +1699,8 @@ mod tests { | |||
| 1662 | .await | 1699 | .await |
| 1663 | .expect("disable"); | 1700 | .expect("disable"); |
| 1664 | let (_, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; | 1701 | let (_, page) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await; |
| 1665 | - assert!(page.contains(r#"<span class="ci-state runner-disabled">disabled</span>"#)); | 1702 | + assert!(page.contains(r#"class="runner-dot is-disabled""#)); |
| 1703 | + assert!(page.contains(r#"<span class="runner-off">disabled</span>"#)); | ||
| 1666 | } | 1704 | } |
| 1667 | 1705 | ||
| 1668 | // Scenario: restart is capability-gated and audited, then the runner is disabled, enabled and deleted. | 1706 | // Scenario: restart is capability-gated and audited, then the runner is disabled, enabled and deleted. |
style/main.scssmodified+215 -153
| @@ -5177,85 +5177,6 @@ $ansi-colours: ( | |||
| 5177 | } | 5177 | } |
| 5178 | } | 5178 | } |
| 5179 | 5179 | ||
| 5180 | -// Admin runners table: every column but the actions sizes to its content, and the name is capped and | ||
| 5181 | -// truncates with an ellipsis. The actions column takes the slack, so its menu sits at the right edge | ||
| 5182 | -// of the card and the other columns stay compact. The label chips sit under the name. All text is | ||
| 5183 | -// left aligned and th and td share one padding, so a header sits over its cell. The row actions live | ||
| 5184 | -// in a menu; its panel is absolutely positioned, so the wrapper must not clip it. State reuses `.ci-state`. | ||
| 5185 | -.table-wrap.runners-wrap { | ||
| 5186 | - overflow: visible; | ||
| 5187 | -} | ||
| 5188 | - | ||
| 5189 | -.table.runners { | ||
| 5190 | - // Every header and cell takes the same 16px gap on its right, so each header sits over its | ||
| 5191 | - // content with room to the next column; the last column has none. | ||
| 5192 | - th, | ||
| 5193 | - td { | ||
| 5194 | - padding: 10px 16px 10px 0; | ||
| 5195 | - vertical-align: middle; | ||
| 5196 | - } | ||
| 5197 | - | ||
| 5198 | - th:last-child, | ||
| 5199 | - td:last-child { | ||
| 5200 | - padding-right: 0; | ||
| 5201 | - } | ||
| 5202 | - | ||
| 5203 | - th.runner-name, | ||
| 5204 | - td.runner-name, | ||
| 5205 | - th.runner-conc, | ||
| 5206 | - td.runner-conc, | ||
| 5207 | - th.runner-running, | ||
| 5208 | - td.runner-running, | ||
| 5209 | - th.runner-build, | ||
| 5210 | - td.runner-build, | ||
| 5211 | - th.runner-seen, | ||
| 5212 | - td.runner-seen, | ||
| 5213 | - th.runner-state, | ||
| 5214 | - td.runner-state { | ||
| 5215 | - width: 1%; | ||
| 5216 | - white-space: nowrap; | ||
| 5217 | - } | ||
| 5218 | - | ||
| 5219 | - td.runner-running { | ||
| 5220 | - font-variant-numeric: tabular-nums; | ||
| 5221 | - } | ||
| 5222 | - | ||
| 5223 | - th.runner-actions, | ||
| 5224 | - td.runner-actions { | ||
| 5225 | - padding-right: 0; | ||
| 5226 | - text-align: right; | ||
| 5227 | - white-space: nowrap; | ||
| 5228 | - } | ||
| 5229 | - | ||
| 5230 | - // The name is capped at 28rem and truncates with an ellipsis; the full name is the link text. | ||
| 5231 | - td.runner-name { | ||
| 5232 | - > a { | ||
| 5233 | - display: block; | ||
| 5234 | - max-width: 28rem; | ||
| 5235 | - overflow: hidden; | ||
| 5236 | - text-overflow: ellipsis; | ||
| 5237 | - white-space: nowrap; | ||
| 5238 | - } | ||
| 5239 | - | ||
| 5240 | - .runner-label-list { | ||
| 5241 | - margin-top: 4px; | ||
| 5242 | - } | ||
| 5243 | - } | ||
| 5244 | - | ||
| 5245 | - // The commit hash and its status pill sit on one line with a small gap between them. | ||
| 5246 | - td.runner-build { | ||
| 5247 | - code { | ||
| 5248 | - margin-right: 8px; | ||
| 5249 | - } | ||
| 5250 | - } | ||
| 5251 | - | ||
| 5252 | - td.runner-build > *, | ||
| 5253 | - td.runner-conc > *, | ||
| 5254 | - td.runner-state > * { | ||
| 5255 | - vertical-align: middle; | ||
| 5256 | - } | ||
| 5257 | -} | ||
| 5258 | - | ||
| 5259 | // The row actions menu: a "..." button that opens a small panel of the actions. Each item is a plain | 5180 | // The row actions menu: a "..." button that opens a small panel of the actions. Each item is a plain |
| 5260 | // button or a `confirm-inline` summary; a confirm popover opens in the flow, so the panel grows to hold it. | 5181 | // button or a `confirm-inline` summary; a confirm popover opens in the flow, so the panel grows to hold it. |
| 5261 | .row-menu { | 5182 | .row-menu { |
| @@ -5392,117 +5313,258 @@ $ansi-colours: ( | |||
| 5392 | } | 5313 | } |
| 5393 | } | 5314 | } |
| 5394 | 5315 | ||
| 5395 | -// Phone: each runner is a card, every cell a label and value row, the menu at the card's end. | 5316 | +// Admin runners: a vertical list, one card row per runner. Four columns: identity (dot, name, labels, |
| 5396 | -@media (max-width: 720px) { | 5317 | +// last seen), load (the jobs meter and the concurrency stepper), version, and the actions menu. The |
| 5397 | - .table.runners { | 5318 | +// load cell is the form that saves the concurrency. Its Save shows only once the value changes |
| 5398 | - display: block; | 5319 | +// (nav.js sets data-dirty), and only where nav.js has run (html.js), so without JavaScript it stays. |
| 5320 | +.runner-list { | ||
| 5321 | + margin: 0 -20px; | ||
| 5322 | + padding: 0; | ||
| 5323 | + list-style: none; | ||
| 5324 | +} | ||
| 5399 | 5325 | ||
| 5400 | - thead { | 5326 | +.runner-row { |
| 5401 | - display: none; | 5327 | + display: grid; |
| 5402 | - } | 5328 | + grid-template-columns: minmax(180px, 1.4fr) 1fr 1fr auto; |
| 5329 | + align-items: center; | ||
| 5330 | + column-gap: 16px; | ||
| 5331 | + padding: 14px 20px; | ||
| 5403 | 5332 | ||
| 5404 | - tbody, | 5333 | + &:hover { |
| 5405 | - tr { | 5334 | + background: var(--surface-2); |
| 5406 | - display: block; | 5335 | + } |
| 5407 | - } | ||
| 5408 | 5336 | ||
| 5409 | - tr { | 5337 | + > .row-menu { |
| 5410 | - padding: 12px 0; | 5338 | + justify-self: end; |
| 5411 | - border-bottom: 1px solid var(--border); | 5339 | + } |
| 5412 | - } | 5340 | +} |
| 5413 | 5341 | ||
| 5414 | - th, | 5342 | +.runner-row + .runner-row { |
| 5415 | - td, | 5343 | + border-top: 1px solid var(--border); |
| 5416 | - td[class] { | 5344 | +} |
| 5417 | - display: block; | ||
| 5418 | - width: auto; | ||
| 5419 | - padding: 0; | ||
| 5420 | - border: 0; | ||
| 5421 | - } | ||
| 5422 | 5345 | ||
| 5423 | - tr { | 5346 | +.runner-id, |
| 5424 | - position: relative; | 5347 | +.runner-load, |
| 5425 | - } | 5348 | +.runner-version { |
| 5349 | + min-width: 0; | ||
| 5350 | +} | ||
| 5426 | 5351 | ||
| 5427 | - td.runner-name { | 5352 | +.runner-title { |
| 5428 | - padding-bottom: 8px; | 5353 | + display: flex; |
| 5429 | - } | 5354 | + align-items: center; |
| 5355 | + gap: 8px; | ||
| 5356 | + min-width: 0; | ||
| 5357 | +} | ||
| 5430 | 5358 | ||
| 5431 | - td[data-label] { | 5359 | +// The status dot: green online, muted offline, warning colour when disabled. |
| 5432 | - display: flex; | 5360 | +.runner-dot { |
| 5433 | - align-items: center; | 5361 | + flex: none; |
| 5434 | - justify-content: space-between; | 5362 | + width: 8px; |
| 5435 | - gap: 12px; | 5363 | + height: 8px; |
| 5436 | - min-height: 36px; | 5364 | + border-radius: 50%; |
| 5365 | + background: var(--muted); | ||
| 5437 | 5366 | ||
| 5438 | - &::before { | 5367 | + &.is-online { |
| 5439 | - content: attr(data-label); | 5368 | + background: var(--ok); |
| 5440 | - color: var(--muted); | 5369 | + } |
| 5441 | - font-size: 0.78125rem; | ||
| 5442 | - } | ||
| 5443 | - } | ||
| 5444 | 5370 | ||
| 5445 | - td.runner-name { | 5371 | + &.is-disabled { |
| 5446 | - padding-right: 48px; | 5372 | + background: var(--warn); |
| 5447 | - } | 5373 | + } |
| 5374 | +} | ||
| 5448 | 5375 | ||
| 5449 | - // The menu sits in the card's top right corner, beside the name. | 5376 | +.runner-name { |
| 5450 | - td.runner-actions { | 5377 | + min-width: 0; |
| 5451 | - position: absolute; | 5378 | + overflow: hidden; |
| 5452 | - top: 12px; | 5379 | + color: var(--text); |
| 5453 | - right: 0; | 5380 | + font-size: 0.9375rem; |
| 5454 | - } | 5381 | + font-weight: 600; |
| 5382 | + text-overflow: ellipsis; | ||
| 5383 | + white-space: nowrap; | ||
| 5384 | + | ||
| 5385 | + &:hover { | ||
| 5386 | + text-decoration: underline; | ||
| 5455 | } | 5387 | } |
| 5456 | } | 5388 | } |
| 5457 | 5389 | ||
| 5458 | -.runner-label-list { | 5390 | +.runner-off { |
| 5391 | + flex: none; | ||
| 5392 | + color: var(--warn); | ||
| 5393 | + font-size: 0.75rem; | ||
| 5394 | +} | ||
| 5395 | + | ||
| 5396 | +// The muted line under the name: labels, then when it was last seen. It lines up under the name. | ||
| 5397 | +.runner-meta { | ||
| 5398 | + margin: 4px 0 0 16px; | ||
| 5399 | + font-size: 0.75rem; | ||
| 5400 | + overflow: hidden; | ||
| 5401 | + text-overflow: ellipsis; | ||
| 5402 | + white-space: nowrap; | ||
| 5403 | +} | ||
| 5404 | + | ||
| 5405 | +.runner-labels { | ||
| 5406 | + font-family: var(--mono); | ||
| 5407 | +} | ||
| 5408 | + | ||
| 5409 | +.runner-load { | ||
| 5459 | display: flex; | 5410 | display: flex; |
| 5460 | - flex-wrap: wrap; | 5411 | + flex-direction: column; |
| 5412 | + align-items: flex-start; | ||
| 5461 | gap: 4px; | 5413 | gap: 4px; |
| 5414 | + margin: 0; | ||
| 5462 | } | 5415 | } |
| 5463 | 5416 | ||
| 5464 | -.runner-label { | 5417 | +.runner-cap { |
| 5465 | - display: inline-block; | ||
| 5466 | - padding: 0 8px; | ||
| 5467 | - border: 1px solid var(--border); | ||
| 5468 | - border-radius: var(--radius-full); | ||
| 5469 | - background: var(--code-bg); | ||
| 5470 | - font-family: var(--mono); | ||
| 5471 | font-size: 0.75rem; | 5418 | font-size: 0.75rem; |
| 5472 | - line-height: 20px; | ||
| 5473 | - white-space: nowrap; | ||
| 5474 | } | 5419 | } |
| 5475 | 5420 | ||
| 5476 | -// Runner concurrency form: a compact input, Save and, while an override is set, a small reset icon, | 5421 | +.runner-line { |
| 5477 | -// all on one line. The value's source is the input's tooltip, so nothing else widens the cell. | ||
| 5478 | -form.runner-conc-form { | ||
| 5479 | display: flex; | 5422 | display: flex; |
| 5480 | - flex-wrap: nowrap; | 5423 | + flex-wrap: wrap; |
| 5481 | align-items: center; | 5424 | align-items: center; |
| 5482 | gap: 6px; | 5425 | gap: 6px; |
| 5483 | - margin: 0; | ||
| 5484 | 5426 | ||
| 5485 | - // Room for a three digit value plus the spinner and the input's padding. | ||
| 5486 | input[type="number"] { | 5427 | input[type="number"] { |
| 5487 | - width: calc(3ch + 2.75rem); | 5428 | + box-sizing: border-box; |
| 5488 | - min-width: 0; | 5429 | + flex: none; |
| 5489 | - text-align: left; | 5430 | + width: 44px; |
| 5431 | + height: var(--control-h); | ||
| 5432 | + padding: 0; | ||
| 5433 | + text-align: center; | ||
| 5434 | + font-variant-numeric: tabular-nums; | ||
| 5435 | + -moz-appearance: textfield; | ||
| 5436 | + appearance: textfield; | ||
| 5437 | + | ||
| 5438 | + &::-webkit-inner-spin-button, | ||
| 5439 | + &::-webkit-outer-spin-button { | ||
| 5440 | + -webkit-appearance: none; | ||
| 5441 | + margin: 0; | ||
| 5442 | + } | ||
| 5490 | } | 5443 | } |
| 5491 | 5444 | ||
| 5492 | - input, | 5445 | + .runner-count { |
| 5493 | - select, | 5446 | + font-size: 0.9375rem; |
| 5494 | - button { | 5447 | + font-variant-numeric: tabular-nums; |
| 5448 | + } | ||
| 5449 | + | ||
| 5450 | + .runner-step { | ||
| 5451 | + box-sizing: border-box; | ||
| 5452 | + flex: none; | ||
| 5453 | + width: 32px; | ||
| 5454 | + height: var(--control-h); | ||
| 5455 | + padding: 0; | ||
| 5456 | + font-size: 1rem; | ||
| 5457 | + line-height: 1; | ||
| 5458 | + } | ||
| 5459 | + | ||
| 5460 | + .runner-save { | ||
| 5495 | box-sizing: border-box; | 5461 | box-sizing: border-box; |
| 5496 | height: var(--control-h); | 5462 | height: var(--control-h); |
| 5497 | - margin: 0; | ||
| 5498 | } | 5463 | } |
| 5499 | 5464 | ||
| 5500 | button[name="reset"] { | 5465 | button[name="reset"] { |
| 5466 | + box-sizing: border-box; | ||
| 5501 | min-width: var(--control-h); | 5467 | min-width: var(--control-h); |
| 5468 | + height: var(--control-h); | ||
| 5502 | padding: 0; | 5469 | padding: 0; |
| 5503 | } | 5470 | } |
| 5504 | } | 5471 | } |
| 5505 | 5472 | ||
| 5473 | +html.js form.runner-load[data-dirty-form] .runner-save { | ||
| 5474 | + display: none; | ||
| 5475 | +} | ||
| 5476 | + | ||
| 5477 | +html.js form.runner-load[data-dirty-form][data-dirty] .runner-save { | ||
| 5478 | + display: inline-block; | ||
| 5479 | +} | ||
| 5480 | + | ||
| 5481 | +// The meter: running jobs out of the concurrency, 80 by 4 pixels, accent fill on a surface track. | ||
| 5482 | +progress.runner-meter { | ||
| 5483 | + -webkit-appearance: none; | ||
| 5484 | + appearance: none; | ||
| 5485 | + display: block; | ||
| 5486 | + box-sizing: border-box; | ||
| 5487 | + width: 80px; | ||
| 5488 | + height: 4px; | ||
| 5489 | + margin: 2px 0 0; | ||
| 5490 | + border: 0; | ||
| 5491 | + border-radius: 2px; | ||
| 5492 | + overflow: hidden; | ||
| 5493 | + background: var(--surface-2); | ||
| 5494 | + color: var(--accent); | ||
| 5495 | + | ||
| 5496 | + &::-webkit-progress-bar { | ||
| 5497 | + background: var(--surface-2); | ||
| 5498 | + } | ||
| 5499 | + | ||
| 5500 | + &::-webkit-progress-value { | ||
| 5501 | + background: var(--accent); | ||
| 5502 | + } | ||
| 5503 | + | ||
| 5504 | + &::-moz-progress-bar { | ||
| 5505 | + background: var(--accent); | ||
| 5506 | + } | ||
| 5507 | +} | ||
| 5508 | + | ||
| 5509 | +.runner-version { | ||
| 5510 | + display: flex; | ||
| 5511 | + flex-wrap: wrap; | ||
| 5512 | + align-items: center; | ||
| 5513 | + gap: 8px; | ||
| 5514 | + justify-self: start; | ||
| 5515 | +} | ||
| 5516 | + | ||
| 5517 | +.runner-hash { | ||
| 5518 | + padding: 0; | ||
| 5519 | + background: none; | ||
| 5520 | + font-family: var(--mono); | ||
| 5521 | + font-size: 0.8125rem; | ||
| 5522 | +} | ||
| 5523 | + | ||
| 5524 | +// Version status: muted text with a tick when up to date, the warning colour when outdated. | ||
| 5525 | +.runner-status { | ||
| 5526 | + color: var(--muted); | ||
| 5527 | + font-size: 0.8125rem; | ||
| 5528 | + white-space: nowrap; | ||
| 5529 | + | ||
| 5530 | + &.warn { | ||
| 5531 | + color: var(--warn); | ||
| 5532 | + } | ||
| 5533 | +} | ||
| 5534 | + | ||
| 5535 | +.runner-tick { | ||
| 5536 | + color: var(--ok); | ||
| 5537 | +} | ||
| 5538 | + | ||
| 5539 | +// Phone: each runner is two rows. Identity and the menu, then the load and the version. | ||
| 5540 | +@media (max-width: 700px) { | ||
| 5541 | + .runner-row { | ||
| 5542 | + grid-template-columns: minmax(0, 1fr) auto; | ||
| 5543 | + row-gap: 12px; | ||
| 5544 | + } | ||
| 5545 | + | ||
| 5546 | + .runner-id { | ||
| 5547 | + grid-column: 1; | ||
| 5548 | + grid-row: 1; | ||
| 5549 | + } | ||
| 5550 | + | ||
| 5551 | + .runner-row > .row-menu { | ||
| 5552 | + grid-column: 2; | ||
| 5553 | + grid-row: 1; | ||
| 5554 | + } | ||
| 5555 | + | ||
| 5556 | + .runner-load { | ||
| 5557 | + grid-column: 1; | ||
| 5558 | + grid-row: 2; | ||
| 5559 | + } | ||
| 5560 | + | ||
| 5561 | + .runner-version { | ||
| 5562 | + grid-column: 2; | ||
| 5563 | + grid-row: 2; | ||
| 5564 | + justify-self: end; | ||
| 5565 | + } | ||
| 5566 | +} | ||
| 5567 | + | ||
| 5506 | .runner-facts { | 5568 | .runner-facts { |
| 5507 | display: grid; | 5569 | display: grid; |
| 5508 | grid-template-columns: max-content 1fr; | 5570 | grid-template-columns: max-content 1fr; |