Port graph page to maud

This commit is contained in:
Joscha 2024-05-11 23:03:24 +02:00
parent 67960e08fa
commit ae81831bdd
2 changed files with 17 additions and 34 deletions

View file

@ -1,9 +1,9 @@
use std::collections::HashMap; use std::collections::HashMap;
use askama::Template;
use axum::{extract::State, response::IntoResponse, Json}; use axum::{extract::State, response::IntoResponse, Json};
use axum_extra::extract::Query; use axum_extra::extract::Query;
use futures::TryStreamExt; use futures::TryStreamExt;
use maud::html;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{Acquire, SqlitePool}; use sqlx::{Acquire, SqlitePool};
@ -12,7 +12,7 @@ use crate::{
server::{ server::{
util, util,
web::{ web::{
base::{Base, Link, Tab}, base::{Base, Tab},
paths::{PathGraph, PathGraphCommits, PathGraphMeasurements, PathGraphMetrics}, paths::{PathGraph, PathGraphCommits, PathGraphMeasurements, PathGraphMetrics},
r#static::{GRAPH_JS, UPLOT_CSS}, r#static::{GRAPH_JS, UPLOT_CSS},
}, },
@ -20,24 +20,26 @@ use crate::{
somehow, somehow,
}; };
#[derive(Template)]
#[template(path = "pages/graph.html")]
struct Page {
link_uplot_css: Link,
link_graph_js: Link,
base: Base,
}
pub async fn get_graph( pub async fn get_graph(
_path: PathGraph, _path: PathGraph,
State(config): State<&'static ServerConfig>, State(config): State<&'static ServerConfig>,
) -> somehow::Result<impl IntoResponse> { ) -> somehow::Result<impl IntoResponse> {
let base = Base::new(config, Tab::Graph); let base = Base::new(config, Tab::Graph);
Ok(Page {
link_uplot_css: base.link(UPLOT_CSS), Ok(base.html(
link_graph_js: base.link(GRAPH_JS), "graph",
base, html! {
}) link rel="stylesheet" href=(base.link(UPLOT_CSS));
script type="module" src=(base.link(GRAPH_JS)) {}
},
html! {
h2 { "Graph" }
div .graph-container {
div #plot {}
div #metrics .metrics-list { "Loading metrics..." }
}
},
))
} }
#[derive(Serialize)] #[derive(Serialize)]

View file

@ -1,19 +0,0 @@
{% extends "base.html" %}
{% block title %}graph{% endblock %}
{% block head %}
<link rel="stylesheet" href="{{ link_uplot_css }}" />
<script type="module" src="{{ link_graph_js }}"></script>
{% endblock %}
{% block body %}
<h2>Graph</h2>
<div class="graph-container">
<div id="plot"></div>
<div id="metrics" class="metrics-list">Loading metrics...</div>
</div>
{% endblock %}