Port run page to Page
This commit is contained in:
parent
5c3ec1122e
commit
d7c6a5beee
1 changed files with 56 additions and 57 deletions
|
|
@ -4,18 +4,14 @@ use axum::{
|
|||
response::{IntoResponse, Response},
|
||||
};
|
||||
use futures::TryStreamExt;
|
||||
use maud::html;
|
||||
use maud::{html, Markup};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
server::{
|
||||
util,
|
||||
web::{
|
||||
base::{Base, Tab},
|
||||
components,
|
||||
paths::PathRunById,
|
||||
},
|
||||
web::{components, page::Page, paths::PathRunById},
|
||||
},
|
||||
somehow,
|
||||
};
|
||||
|
|
@ -35,7 +31,7 @@ async fn from_finished_run(
|
|||
id: &str,
|
||||
config: &'static ServerConfig,
|
||||
db: &SqlitePool,
|
||||
) -> somehow::Result<Option<Response>> {
|
||||
) -> somehow::Result<Option<Markup>> {
|
||||
let Some(run) = sqlx::query!(
|
||||
"\
|
||||
SELECT \
|
||||
|
|
@ -96,15 +92,14 @@ async fn from_finished_run(
|
|||
.try_collect::<Vec<_>>()
|
||||
.await?;
|
||||
|
||||
let base = Base::new(config, Tab::None);
|
||||
|
||||
let commit = components::link_commit(config, run.hash, &run.message, run.reachable);
|
||||
|
||||
Ok(Some(
|
||||
base.html(
|
||||
&format!("Run of {}", util::format_commit_summary(&run.message)),
|
||||
html! {},
|
||||
html! {
|
||||
let html = Page::new(config)
|
||||
.title(format!(
|
||||
"Run of {}",
|
||||
util::format_commit_summary(&run.message)
|
||||
))
|
||||
.body(html! {
|
||||
h2 { "Run" }
|
||||
div .commit-like .run {
|
||||
span .title { "run " (run.id) }
|
||||
|
|
@ -128,6 +123,8 @@ async fn from_finished_run(
|
|||
dd { (run.exit_code) }
|
||||
}
|
||||
}
|
||||
})
|
||||
.body(html! {
|
||||
h2 { "Measurements" }
|
||||
table {
|
||||
thead {
|
||||
|
|
@ -145,16 +142,18 @@ async fn from_finished_run(
|
|||
} }
|
||||
}
|
||||
}
|
||||
})
|
||||
.body(html! {
|
||||
h2 { "Output" }
|
||||
div .run-output {
|
||||
@for line in output {
|
||||
pre { (line.text) }
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.into_response(),
|
||||
))
|
||||
})
|
||||
.build();
|
||||
|
||||
Ok(Some(html))
|
||||
}
|
||||
|
||||
pub async fn get_run_by_id(
|
||||
|
|
@ -162,8 +161,8 @@ pub async fn get_run_by_id(
|
|||
State(config): State<&'static ServerConfig>,
|
||||
State(db): State<SqlitePool>,
|
||||
) -> somehow::Result<Response> {
|
||||
if let Some(response) = from_finished_run(&path.id, config, &db).await? {
|
||||
Ok(response)
|
||||
if let Some(markup) = from_finished_run(&path.id, config, &db).await? {
|
||||
Ok(markup.into_response())
|
||||
} else {
|
||||
// TODO Show unfinished runs
|
||||
Ok(StatusCode::NOT_FOUND.into_response())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue