Add graph tab
This commit is contained in:
parent
9caf664b10
commit
b0eb94a02a
7 changed files with 56 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ use self::{
|
||||||
},
|
},
|
||||||
pages::{
|
pages::{
|
||||||
commit::get_commit_by_hash,
|
commit::get_commit_by_hash,
|
||||||
|
graph::get_graph,
|
||||||
index::get_index,
|
index::get_index,
|
||||||
queue::{get_queue, get_queue_delete, get_queue_inner},
|
queue::{get_queue, get_queue_delete, get_queue_inner},
|
||||||
run::get_run_by_id,
|
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_bench_repo_by_hash_tree_tar_gz)
|
||||||
.typed_get(get_api_worker_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_commit_by_hash)
|
||||||
|
.typed_get(get_graph)
|
||||||
.typed_get(get_index)
|
.typed_get(get_index)
|
||||||
.typed_get(get_queue)
|
.typed_get(get_queue)
|
||||||
.typed_get(get_queue_delete)
|
.typed_get(get_queue_delete)
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@ use std::fmt;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
paths::{PathIndex, PathQueue},
|
paths::{PathGraph, PathIndex, PathQueue},
|
||||||
r#static::{BASE_CSS, LOGO_SVG},
|
r#static::{BASE_CSS, LOGO_SVG},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub enum Tab {
|
pub enum Tab {
|
||||||
None,
|
None,
|
||||||
Index,
|
Index,
|
||||||
|
Graph,
|
||||||
Queue,
|
Queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -18,6 +19,7 @@ pub struct Base {
|
||||||
pub link_logo_svg: Link,
|
pub link_logo_svg: Link,
|
||||||
pub link_base_css: Link,
|
pub link_base_css: Link,
|
||||||
pub link_index: Link,
|
pub link_index: Link,
|
||||||
|
pub link_graph: Link,
|
||||||
pub link_queue: Link,
|
pub link_queue: Link,
|
||||||
pub web_base: String,
|
pub web_base: String,
|
||||||
pub repo_name: String,
|
pub repo_name: String,
|
||||||
|
|
@ -29,12 +31,14 @@ impl Base {
|
||||||
let tab = match tab {
|
let tab = match tab {
|
||||||
Tab::None => "",
|
Tab::None => "",
|
||||||
Tab::Index => "index",
|
Tab::Index => "index",
|
||||||
|
Tab::Graph => "graph",
|
||||||
Tab::Queue => "queue",
|
Tab::Queue => "queue",
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
link_logo_svg: Self::link_with_config(config, LOGO_SVG),
|
link_logo_svg: Self::link_with_config(config, LOGO_SVG),
|
||||||
link_base_css: Self::link_with_config(config, BASE_CSS),
|
link_base_css: Self::link_with_config(config, BASE_CSS),
|
||||||
link_index: Self::link_with_config(config, PathIndex {}),
|
link_index: Self::link_with_config(config, PathIndex {}),
|
||||||
|
link_graph: Self::link_with_config(config, PathGraph {}),
|
||||||
link_queue: Self::link_with_config(config, PathQueue {}),
|
link_queue: Self::link_with_config(config, PathQueue {}),
|
||||||
web_base: config.web_base.clone(),
|
web_base: config.web_base.clone(),
|
||||||
repo_name: config.repo_name.clone(),
|
repo_name: config.repo_name.clone(),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod commit;
|
pub mod commit;
|
||||||
|
pub mod graph;
|
||||||
pub mod index;
|
pub mod index;
|
||||||
pub mod queue;
|
pub mod queue;
|
||||||
pub mod run;
|
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("/")]
|
#[typed_path("/")]
|
||||||
pub struct PathIndex {}
|
pub struct PathIndex {}
|
||||||
|
|
||||||
|
#[derive(Deserialize, TypedPath)]
|
||||||
|
#[typed_path("/graph/")]
|
||||||
|
pub struct PathGraph {}
|
||||||
|
|
||||||
#[derive(Deserialize, TypedPath)]
|
#[derive(Deserialize, TypedPath)]
|
||||||
#[typed_path("/queue/")]
|
#[typed_path("/queue/")]
|
||||||
pub struct PathQueue {}
|
pub struct PathQueue {}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@
|
||||||
<a href="{{ base.link_index }}" {% if base.tab=="index" %} class="current" {% endif %}>
|
<a href="{{ base.link_index }}" {% if base.tab=="index" %} class="current" {% endif %}>
|
||||||
<img src="{{ base.link_logo_svg }}" alt="">{{ base.repo_name }}
|
<img src="{{ base.link_logo_svg }}" alt="">{{ base.repo_name }}
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{{ base.link_graph }}" {% if base.tab=="graph" %} class="current" {% endif %}>
|
||||||
|
graph
|
||||||
|
</a>
|
||||||
<a href="{{ base.link_queue }}" {% if base.tab=="queue" %} class="current" {% endif %}>
|
<a href="{{ base.link_queue }}" {% if base.tab=="queue" %} class="current" {% endif %}>
|
||||||
queue
|
queue
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
11
templates/pages/graph.html
Normal file
11
templates/pages/graph.html
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}graph{% endblock %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
<script type="module" src="{{ link_graph_js }}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h2>Graph</h2>
|
||||||
|
{% endblock %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue