more shit.

This commit is contained in:
didier amyot committed 2023-02-05 13:58:47 -05:00
1 parent de51e20181
commit ba7763cbb1
6 files changed
+88 -41

No files matched your search

+2 -1
View File
@@ -69,7 +69,6 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io
notifier.watch_path(&tmpl_path, true);
}
env.set_source(minijinja::Source::from_path(tmpl_path));
println!("boom");
Ok(env)
});
@@ -81,6 +80,8 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io
.service(views::index)
.service(views::actions)
.service(views::overview)
.service(views::overview_submit_button)
.service(views::push_event)
.wrap(ErrorHandlers::new().handler(StatusCode::NOT_FOUND, not_found))
.wrap(Logger::default())
})
+33 -3
View File
@@ -1,8 +1,12 @@
use crate::webui::MiniJinjaRenderer;
use actix_web::{web, Responder};
use actix_web::{HttpRequest, Responder, web};
use actix_web::http::header::q;
use clap::builder::TypedValueParser;
use minijinja::context;
use serde::Deserialize;
use std::collections::HashMap;
use crate::webui::MiniJinjaRenderer;
#[actix_web::get("/")]
pub async fn index(
tmpl_env: MiniJinjaRenderer,
@@ -19,7 +23,6 @@ pub async fn actions(
tmpl_env.render("actions.html", ())
}
#[actix_web::get("/overview")]
pub async fn overview(
tmpl_env: MiniJinjaRenderer,
@@ -27,3 +30,30 @@ pub async fn overview(
) -> actix_web::Result<impl Responder> {
tmpl_env.render("overview.html", ())
}
#[actix_web::get("/partials/overview/submit_button")]
pub async fn overview_submit_button(
req: HttpRequest,
tmpl_env: MiniJinjaRenderer,
query: web::Query<HashMap<String, String>>
) -> actix_web::Result<impl Responder> {
let ctx = context! {
event_type => query.get("event_type").unwrap_or(&"".to_string()),
};
tmpl_env.render("partials/overview/submit_button.html", ctx)
}
#[actix_web::post("/v1/events/{event_type}")]
pub async fn push_event(
req: HttpRequest,
tmpl_env: MiniJinjaRenderer,
query: web::Query<HashMap<String, String>>,
) -> actix_web::Result<impl Responder> {
println!(">> {:?}", req);
let shit = req.match_info().get("event_type").unwrap();
let event = req.match_info().get("event").unwrap();
let ctx = context! {
event_type => shit,
};
tmpl_env.render("partials/v1/event_processed.html", ctx)
}