aboutsummaryrefslogtreecommitdiff
path: root/src/webui.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-05-17 18:27:00 +0200
committermetamuffin <metamuffin@disroot.org>2025-05-17 18:27:00 +0200
commit0c4cb405f9b166398a2bf7e128c47fa56dfa2d71 (patch)
tree06db763a47dcfa9c975f3d797d8ee2534d37b1be /src/webui.rs
parent1c27a83409a7f51c5d07098cb6ca65bcee870d9c (diff)
downloadisda-0c4cb405f9b166398a2bf7e128c47fa56dfa2d71.tar
isda-0c4cb405f9b166398a2bf7e128c47fa56dfa2d71.tar.bz2
isda-0c4cb405f9b166398a2bf7e128c47fa56dfa2d71.tar.zst
enqueue works
Diffstat (limited to 'src/webui.rs')
-rw-r--r--src/webui.rs63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/webui.rs b/src/webui.rs
new file mode 100644
index 0000000..9e8b9c3
--- /dev/null
+++ b/src/webui.rs
@@ -0,0 +1,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 }
+ }
+ }
+);