Add graph tab

This commit is contained in:
Joscha 2023-08-14 17:49:21 +02:00
parent 9caf664b10
commit b0eb94a02a
7 changed files with 56 additions and 1 deletions

View file

@ -22,6 +22,7 @@ use self::{
},
pages::{
commit::get_commit_by_hash,
graph::get_graph,
index::get_index,
queue::{get_queue, get_queue_delete, get_queue_inner},
run::get_run_by_id,
@ -42,6 +43,7 @@ pub async fn run(server: Server) -> somehow::Result<()> {
.typed_get(get_api_worker_bench_repo_by_hash_tree_tar_gz)
.typed_get(get_api_worker_repo_by_hash_tree_tar_gz)
.typed_get(get_commit_by_hash)
.typed_get(get_graph)
.typed_get(get_index)
.typed_get(get_queue)
.typed_get(get_queue_delete)

View file

@ -3,13 +3,14 @@ use std::fmt;
use crate::config::Config;
use super::{
paths::{PathIndex, PathQueue},
paths::{PathGraph, PathIndex, PathQueue},
r#static::{BASE_CSS, LOGO_SVG},
};
pub enum Tab {
None,
Index,
Graph,
Queue,
}
@ -18,6 +19,7 @@ pub struct Base {
pub link_logo_svg: Link,
pub link_base_css: Link,
pub link_index: Link,
pub link_graph: Link,
pub link_queue: Link,
pub web_base: String,
pub repo_name: String,
@ -29,12 +31,14 @@ impl Base {
let tab = match tab {
Tab::None => "",
Tab::Index => "index",
Tab::Graph => "graph",
Tab::Queue => "queue",
};
Self {
link_logo_svg: Self::link_with_config(config, LOGO_SVG),
link_base_css: Self::link_with_config(config, BASE_CSS),
link_index: Self::link_with_config(config, PathIndex {}),
link_graph: Self::link_with_config(config, PathGraph {}),
link_queue: Self::link_with_config(config, PathQueue {}),
web_base: config.web_base.clone(),
repo_name: config.repo_name.clone(),

View file

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

View file

@ -0,0 +1,30 @@
use askama::Template;
use axum::{extract::State, response::IntoResponse};
use crate::{
config::Config,
server::web::{
base::{Base, Link, Tab},
paths::PathGraph,
r#static::GRAPH_JS,
},
somehow,
};
#[derive(Template)]
#[template(path = "pages/graph.html")]
struct Page {
link_graph_js: Link,
base: Base,
}
pub async fn get_graph(
_path: PathGraph,
State(config): State<&'static Config>,
) -> somehow::Result<impl IntoResponse> {
let base = Base::new(config, Tab::Graph);
Ok(Page {
link_graph_js: base.link(GRAPH_JS),
base,
})
}

View file

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