mirror of
https://github.com/zaphar/Heracles.git
synced 2025-07-23 04:29:48 -04:00
feat: you can embed log tables now.
This commit is contained in:
parent
c830d1530d
commit
e44d2087c8
@ -96,6 +96,10 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
"/embed/dash/:dash_idx/graph/:graph_idx",
|
"/embed/dash/:dash_idx/graph/:graph_idx",
|
||||||
get(routes::graph_embed).with_state(State(config.clone())),
|
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("/dash/:dash_idx", get(routes::dashboard_direct))
|
||||||
.route("/", get(routes::index).with_state(State(config.clone())))
|
.route("/", get(routes::index).with_state(State(config.clone())))
|
||||||
.layer(TraceLayer::new_for_http())
|
.layer(TraceLayer::new_for_http())
|
||||||
|
@ -163,6 +163,21 @@ pub async fn graph_ui(
|
|||||||
graph_component(dash_idx, graph_idx, graph)
|
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 {
|
pub async fn dash_ui(State(config): State<Config>, Path(dash_idx): Path<usize>) -> Markup {
|
||||||
// TODO(zaphar): Should do better http error reporting here.
|
// TODO(zaphar): Should do better http error reporting here.
|
||||||
dash_elements(config, dash_idx)
|
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 {
|
async fn index_html(config: Config, dash_idx: Option<usize>) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
html {
|
html {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user