Add graph tab
This commit is contained in:
parent
9caf664b10
commit
b0eb94a02a
7 changed files with 56 additions and 1 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
pub mod commit;
|
||||
pub mod graph;
|
||||
pub mod index;
|
||||
pub mod queue;
|
||||
pub mod run;
|
||||
|
|
|
|||
30
src/server/web/pages/graph.rs
Normal file
30
src/server/web/pages/graph.rs
Normal 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,
|
||||
})
|
||||
}
|
||||
|
|
@ -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 {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue