Port queue page

This commit is contained in:
Joscha 2023-08-14 12:10:05 +02:00
parent 123c27e5a2
commit 2b6c339c70
7 changed files with 44 additions and 19 deletions

View file

@ -4,7 +4,6 @@ mod base;
mod link;
mod pages;
pub mod paths;
mod queue;
mod r#static;
use axum::{routing::get, Router};
@ -19,10 +18,12 @@ use self::{
post_api_worker_status,
},
pages::{
commit::get_commit_by_hash, index::get_index, run::get_run_by_id,
commit::get_commit_by_hash,
index::get_index,
queue::{get_queue, get_queue_inner},
run::get_run_by_id,
worker::get_worker_by_name,
},
queue::{get_queue, get_queue_inner},
};
use super::Server;

View file

@ -1,4 +1,5 @@
pub mod commit;
pub mod index;
pub mod queue;
pub mod run;
pub mod worker;

View file

@ -12,19 +12,21 @@ use crate::{
config::Config,
server::{
util,
web::{
base::{Base, Link, Tab},
link::{LinkCommit, LinkRunShort, LinkWorker},
paths::{
PathAdminQueueDecrease, PathAdminQueueDelete, PathAdminQueueIncrease, PathQueue,
PathQueueInner,
},
r#static::QUEUE_JS,
},
workers::{WorkerInfo, Workers},
},
shared::WorkerStatus,
somehow,
};
use super::{
base::{Base, Link, Tab},
link::{LinkCommit, LinkRunShort, LinkWorker},
paths::{PathQueue, PathQueueInner},
r#static::QUEUE_JS,
};
enum Status {
Idle,
Busy,
@ -37,6 +39,10 @@ struct Worker {
}
struct Task {
link_delete: Link,
link_increase: Link,
link_decrease: Link,
hash: String,
commit: LinkCommit,
since: String,
priority: i64,
@ -121,6 +127,10 @@ async fn get_queue_data(
)
.fetch(db)
.map_ok(|r| Task {
link_delete: base.link(PathAdminQueueDelete {}),
link_increase: base.link(PathAdminQueueIncrease {}),
link_decrease: base.link(PathAdminQueueDecrease {}),
hash: r.hash.clone(),
workers: workers_by_commit.remove(&r.hash).unwrap_or_default(),
commit: LinkCommit::new(base, r.hash, &r.message, r.reachable),
since: util::format_delta_from_now(r.date),
@ -144,7 +154,7 @@ async fn get_queue_data(
}
#[derive(Template)]
#[template(path = "queue_inner.html")]
#[template(path = "pages/queue_inner.html")]
struct QueueInnerTemplate {
workers: Vec<Worker>,
tasks: Vec<Task>,
@ -163,7 +173,7 @@ pub async fn get_queue_inner(
Ok(QueueInnerTemplate { workers, tasks })
}
#[derive(Template)]
#[template(path = "queue.html")]
#[template(path = "pages/queue.html")]
struct QueueTemplate {
link_queue_js: Link,
base: Base,

View file

@ -10,7 +10,7 @@ use serde::Deserialize;
pub struct PathIndex {}
#[derive(Deserialize, TypedPath)]
#[typed_path("/queue")]
#[typed_path("/queue/")]
pub struct PathQueue {}
#[derive(Deserialize, TypedPath)]