blob: 9e8b9c3cf3d736bfd2e5417b3075b59134630122 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
use crate::State;
use axum::extract::State as S;
use axum::response::Html;
use serde_json::{Map, Value};
use std::sync::Arc;
use tokio::sync::RwLock;
pub(crate) async fn webui(S(state): S<Arc<RwLock<State>>>) -> Html<String> {
let g = state.read().await;
let doc = markup::new! {
html {
head {
meta[charset="UTF-8"];
title { "" }
}
body {
section {
h2 { "Workers"}
ul { @for (id, w) in &g.workers {
li { div {
h3 { @w.name }
span { "ID: " @id } " "
@if w.accept > 0 {
span { "Accepting Jobs (" @w.accept ")" }
} else {
span { "Idle" }
}
}}
}}
}
section {
h2 { "Queued" }
ul { @for key in &g.queue {
li { @key }
}}
}
section {
h2 { "Loading" }
ul { @for key in &g.loading {
li { @key }
}}
}
section {
h2 { "Completed" }
ul { @for key in &g.complete {
li { @key }
}}
}
}
}
};
Html(doc.to_string())
}
markup::define!(
Task<'a>(key: &'a str, data: &'a Map<String, Value>) {
div.task {
h3 { @data["title"].as_str().unwrap_or(key) }
spawn.key { @key }
}
}
);
|