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