Port queue page
This commit is contained in:
parent
123c27e5a2
commit
2b6c339c70
7 changed files with 44 additions and 19 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
const COUNT = document.getElementById("count")!;
|
|
||||||
const INNER = document.getElementById("inner")!;
|
const INNER = document.getElementById("inner")!;
|
||||||
const REFRESH_SECONDS = 10;
|
const REFRESH_SECONDS = 10;
|
||||||
|
|
||||||
|
|
@ -7,7 +6,7 @@ function update() {
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(text => {
|
.then(text => {
|
||||||
INNER.innerHTML = text;
|
INNER.innerHTML = text;
|
||||||
let count = INNER.querySelector<HTMLElement>("#queue")?.dataset["count"]!;
|
let count = document.getElementById("queue")?.dataset["count"]!;
|
||||||
document.title = document.title.replace(/^queue \(\d+\)/, `queue (${count})`);
|
document.title = document.title.replace(/^queue \(\d+\)/, `queue (${count})`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ mod base;
|
||||||
mod link;
|
mod link;
|
||||||
mod pages;
|
mod pages;
|
||||||
pub mod paths;
|
pub mod paths;
|
||||||
mod queue;
|
|
||||||
mod r#static;
|
mod r#static;
|
||||||
|
|
||||||
use axum::{routing::get, Router};
|
use axum::{routing::get, Router};
|
||||||
|
|
@ -19,10 +18,12 @@ use self::{
|
||||||
post_api_worker_status,
|
post_api_worker_status,
|
||||||
},
|
},
|
||||||
pages::{
|
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,
|
worker::get_worker_by_name,
|
||||||
},
|
},
|
||||||
queue::{get_queue, get_queue_inner},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::Server;
|
use super::Server;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod commit;
|
pub mod commit;
|
||||||
pub mod index;
|
pub mod index;
|
||||||
|
pub mod queue;
|
||||||
pub mod run;
|
pub mod run;
|
||||||
pub mod worker;
|
pub mod worker;
|
||||||
|
|
|
||||||
|
|
@ -12,19 +12,21 @@ use crate::{
|
||||||
config::Config,
|
config::Config,
|
||||||
server::{
|
server::{
|
||||||
util,
|
util,
|
||||||
|
web::{
|
||||||
|
base::{Base, Link, Tab},
|
||||||
|
link::{LinkCommit, LinkRunShort, LinkWorker},
|
||||||
|
paths::{
|
||||||
|
PathAdminQueueDecrease, PathAdminQueueDelete, PathAdminQueueIncrease, PathQueue,
|
||||||
|
PathQueueInner,
|
||||||
|
},
|
||||||
|
r#static::QUEUE_JS,
|
||||||
|
},
|
||||||
workers::{WorkerInfo, Workers},
|
workers::{WorkerInfo, Workers},
|
||||||
},
|
},
|
||||||
shared::WorkerStatus,
|
shared::WorkerStatus,
|
||||||
somehow,
|
somehow,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
|
||||||
base::{Base, Link, Tab},
|
|
||||||
link::{LinkCommit, LinkRunShort, LinkWorker},
|
|
||||||
paths::{PathQueue, PathQueueInner},
|
|
||||||
r#static::QUEUE_JS,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Status {
|
enum Status {
|
||||||
Idle,
|
Idle,
|
||||||
Busy,
|
Busy,
|
||||||
|
|
@ -37,6 +39,10 @@ struct Worker {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Task {
|
struct Task {
|
||||||
|
link_delete: Link,
|
||||||
|
link_increase: Link,
|
||||||
|
link_decrease: Link,
|
||||||
|
hash: String,
|
||||||
commit: LinkCommit,
|
commit: LinkCommit,
|
||||||
since: String,
|
since: String,
|
||||||
priority: i64,
|
priority: i64,
|
||||||
|
|
@ -121,6 +127,10 @@ async fn get_queue_data(
|
||||||
)
|
)
|
||||||
.fetch(db)
|
.fetch(db)
|
||||||
.map_ok(|r| Task {
|
.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(),
|
workers: workers_by_commit.remove(&r.hash).unwrap_or_default(),
|
||||||
commit: LinkCommit::new(base, r.hash, &r.message, r.reachable),
|
commit: LinkCommit::new(base, r.hash, &r.message, r.reachable),
|
||||||
since: util::format_delta_from_now(r.date),
|
since: util::format_delta_from_now(r.date),
|
||||||
|
|
@ -144,7 +154,7 @@ async fn get_queue_data(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "queue_inner.html")]
|
#[template(path = "pages/queue_inner.html")]
|
||||||
struct QueueInnerTemplate {
|
struct QueueInnerTemplate {
|
||||||
workers: Vec<Worker>,
|
workers: Vec<Worker>,
|
||||||
tasks: Vec<Task>,
|
tasks: Vec<Task>,
|
||||||
|
|
@ -163,7 +173,7 @@ pub async fn get_queue_inner(
|
||||||
Ok(QueueInnerTemplate { workers, tasks })
|
Ok(QueueInnerTemplate { workers, tasks })
|
||||||
}
|
}
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "queue.html")]
|
#[template(path = "pages/queue.html")]
|
||||||
struct QueueTemplate {
|
struct QueueTemplate {
|
||||||
link_queue_js: Link,
|
link_queue_js: Link,
|
||||||
base: Base,
|
base: Base,
|
||||||
|
|
@ -10,7 +10,7 @@ use serde::Deserialize;
|
||||||
pub struct PathIndex {}
|
pub struct PathIndex {}
|
||||||
|
|
||||||
#[derive(Deserialize, TypedPath)]
|
#[derive(Deserialize, TypedPath)]
|
||||||
#[typed_path("/queue")]
|
#[typed_path("/queue/")]
|
||||||
pub struct PathQueue {}
|
pub struct PathQueue {}
|
||||||
|
|
||||||
#[derive(Deserialize, TypedPath)]
|
#[derive(Deserialize, TypedPath)]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
{% import "util.html" as util %}
|
|
||||||
|
|
||||||
<h2>Workers</h2>
|
<h2>Workers</h2>
|
||||||
|
|
||||||
{% if workers.is_empty() %}
|
{% if workers.is_empty() %}
|
||||||
<p>No workers connected</p>
|
<p>No workers connected</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
@ -30,6 +29,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2>Queue ({{ tasks.len() }})</h2>
|
<h2>Queue ({{ tasks.len() }})</h2>
|
||||||
|
|
||||||
<table id="queue" data-count="{{ tasks.len() }}">
|
<table id="queue" data-count="{{ tasks.len() }}">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
@ -43,8 +43,21 @@
|
||||||
{% for task in tasks %}
|
{% for task in tasks %}
|
||||||
<tr {% if task.odd %} class="odd" {% endif %}>
|
<tr {% if task.odd %} class="odd" {% endif %}>
|
||||||
<td>{{ task.commit|safe }}</td>
|
<td>{{ task.commit|safe }}</td>
|
||||||
<td>{{ task.since }}</td>
|
<td>
|
||||||
<td>{{ task.priority }}</td>
|
{{ task.since }}
|
||||||
|
[<a href="{{ task.link_delete }}" title="Delete from queue">del</a>]
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ task.priority }}
|
||||||
|
[<form method="post" action="{{ task.link_increase }}">
|
||||||
|
<input type="hidden" name="hash" value="{{ task.hash }}">
|
||||||
|
<button title="Increase priority by 1">inc</button>
|
||||||
|
</form>,
|
||||||
|
<form method="post" action="{{ task.link_decrease }}">
|
||||||
|
<input type="hidden" name="hash" value="{{ task.hash }}">
|
||||||
|
<button title="Decrease priority by 1">dec</button>
|
||||||
|
</form>]
|
||||||
|
</td>
|
||||||
{% if task.workers.is_empty() %}
|
{% if task.workers.is_empty() %}
|
||||||
<td>-</td>
|
<td>-</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
@ -53,4 +66,5 @@
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue