feat: you can embed log tables now.

This commit is contained in:
Jeremy Wall 2024-03-05 20:44:10 -05:00
parent c830d1530d
commit e44d2087c8
2 changed files with 36 additions and 0 deletions

View File

@ -96,6 +96,10 @@ async fn main() -> anyhow::Result<()> {
"/embed/dash/:dash_idx/graph/:graph_idx",
get(routes::graph_embed).with_state(State(config.clone())),
)
.route(
"/embed/dash/:dash_idx/log/:graph_idx",
get(routes::log_embed).with_state(State(config.clone())),
)
.route("/dash/:dash_idx", get(routes::dashboard_direct))
.route("/", get(routes::index).with_state(State(config.clone())))
.layer(TraceLayer::new_for_http())

View File

@ -163,6 +163,21 @@ pub async fn graph_ui(
graph_component(dash_idx, graph_idx, graph)
}
pub async fn log_ui(
State(config): State<Config>,
Path((dash_idx, log_idx)): Path<(usize, usize)>,
) -> Markup {
let log = config
.get(dash_idx)
.expect(&format!("No such dashboard {}", dash_idx))
.logs
.as_ref()
.expect("No graphs in this dashboard")
.get(log_idx)
.expect("No such graph");
log_component(dash_idx, log_idx, log)
}
pub async fn dash_ui(State(config): State<Config>, Path(dash_idx): Path<usize>) -> Markup {
// TODO(zaphar): Should do better http error reporting here.
dash_elements(config, dash_idx)
@ -241,6 +256,23 @@ pub async fn graph_embed(
}
}
pub async fn log_embed(
State(config): State<Config>,
Path((dash_idx, log_idx)): Path<(usize, usize)>,
) -> Markup {
html! {
html {
head {
title { ("Heracles - Prometheus Unshackled") }
}
body {
(graph_lib_prelude())
(log_ui(State(config.clone()), Path((dash_idx, log_idx))).await)
}
}
}
}
async fn index_html(config: Config, dash_idx: Option<usize>) -> Markup {
html! {
html {