more shit.
This commit is contained in:
1 parent
de51e20181
commit
ba7763cbb1
6 files changed
+88
-41
No files matched your search
+2
-1
@@ -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
@@ -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)
|
||||
}
|
||||
+24
-25
@@ -8,40 +8,39 @@
|
||||
<form>
|
||||
<fieldset class="uk-fieldset">
|
||||
|
||||
<legend class="uk-legend">Legend</legend>
|
||||
|
||||
<legend class="uk-legend">Create new item</legend>
|
||||
<div class="uk-margin">
|
||||
<input class="uk-input" type="text" placeholder="Input" aria-label="Input">
|
||||
</div>
|
||||
|
||||
<div class="uk-margin">
|
||||
<select class="uk-select" aria-label="Select">
|
||||
<option>Option 01</option>
|
||||
<option>Option 02</option>
|
||||
<select name="event_type"
|
||||
class="uk-select"
|
||||
aria-label="Select"
|
||||
class="uk-button uk-button-default"
|
||||
hx-get="/partials/overview/submit_button"
|
||||
hx-trigger="change,load"
|
||||
hx-target="#submit-button"
|
||||
hx-swap="outerHTML">>
|
||||
<option value="create_user">Create User</option>
|
||||
<option value="create_security">Create Security</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin">
|
||||
<textarea class="uk-textarea" rows="5" placeholder="Textarea" aria-label="Textarea"></textarea>
|
||||
<label class="uk-form-label">Event [JSON5]</label>
|
||||
<textarea class="uk-textarea"
|
||||
name="event"
|
||||
style="font: 0.875rem/1.5 Consolas,monaco,monospace"
|
||||
rows="5"
|
||||
placeholder="JSON"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin uk-grid-small uk-child-width-auto uk-grid">
|
||||
<label><input class="uk-radio" type="radio" name="radio2" checked> A</label>
|
||||
<label><input class="uk-radio" type="radio" name="radio2"> B</label>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin uk-grid-small uk-child-width-auto uk-grid">
|
||||
<label><input class="uk-checkbox" type="checkbox" checked> A</label>
|
||||
<label><input class="uk-checkbox" type="checkbox"> B</label>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin">
|
||||
<input class="uk-range" type="range" value="2" min="0" max="10" step="0.1" aria-label="Range">
|
||||
</div>
|
||||
|
||||
<div id="submit-button"></div>
|
||||
<div id="parent-div"></div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<table class="uk-table uk-table-small">
|
||||
<thead></thead>
|
||||
<tbody id="event-table-first-row"></tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
+19
-12
@@ -4,28 +4,35 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ledger</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.5/css/uikit.min.css" />
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.5/js/uikit.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.15.23/dist/css/uikit.min.css" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/uikit@3.15.23/dist/js/uikit.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/uikit@3.15.23/dist/js/uikit-icons.min.js"></script>
|
||||
<script src="https://unpkg.com/htmx.org@1.8.5"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav class="uk-navbar">
|
||||
<a href="/" class="uk-navbar-brand">Ledger</a>
|
||||
<ul class="uk-navbar-nav">
|
||||
{% set nav_bar_items = [{'id': 'overview', 'label': 'Overview'},
|
||||
{'id': 'actions', 'label': 'Actions'}]%}
|
||||
{% for itm in nav_bar_items %}
|
||||
<li class="{% if active_navbar_item == itm.id %}uk-active"{% else %} uk-parent {% endif %}"><a href="{{ itm.id }}">{{ itm.label }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
<nav class="uk-navbar-container" uk-navbar>
|
||||
<div class="uk-navbar-left">
|
||||
<a href="/" class="uk-navbar-item uk-logo">Ledger</a>
|
||||
<ul class="uk-navbar-nav">
|
||||
{% set nav_bar_items = [{'id': 'overview', 'label': 'Overview'},
|
||||
{'id': 'actions', 'label': 'Actions'}]%}
|
||||
{% for itm in nav_bar_items %}
|
||||
<li class="{% if active_navbar_item == itm.id %}uk-active"{% endif %}"><a href="{{ itm.id }}">{{ itm.label }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="uk-grid">
|
||||
<div class="uk-width-2-3 uk-container-center">
|
||||
<div class="uk-width-1-6@m"></div>
|
||||
<div class="uk-width-2-3@m">
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div class="uk-width-1-6@m"></div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<button id="submit-button"
|
||||
class="uk-button uk-button-default"
|
||||
hx-post="/v1/events/{{event_type}}"
|
||||
hx-trigger="click"
|
||||
hx-target="#event-table-first-row"
|
||||
hx-swap="outerHTML">
|
||||
Submit
|
||||
</button>
|
||||
@@ -0,0 +1,2 @@
|
||||
<tbody id="event-table-first-row"></tbody>
|
||||
<tr><td>une</td><td>{{ event_type }}</td></tr>
|
||||
Reference in new issue
Block a user