add logbook history

This commit is contained in:
philipp 2023-07-30 14:13:49 +02:00
parent c6d19d276c
commit 2e80f7bc38
4 changed files with 38 additions and 8 deletions

View File

@ -9,7 +9,7 @@ use rocket::{
time::{Duration, OffsetDateTime},
Request, Route, State,
};
use rocket_dyn_templates::Template;
use rocket_dyn_templates::{context, Template};
use sqlx::SqlitePool;
use tera::Context;
@ -64,6 +64,20 @@ async fn index(
Template::render("log", context.into_json())
}
#[get("/show", rank = 2)]
async fn show(db: &State<SqlitePool>, user: User) -> Template {
let logs = Logbook::completed(db).await;
Template::render("log.completed", context!(logs, loggedin_user: &user))
}
#[get("/show")]
async fn show_kiosk(db: &State<SqlitePool>, _kios: KioskCookie) -> Template {
let logs = Logbook::completed(db).await;
Template::render("log.completed", context!(logs))
}
#[get("/kiosk/ekrv2019")]
fn new_kiosk(cookies: &CookieJar<'_>) -> Redirect {
let mut cookie = Cookie::new("kiosk", "yes".to_string());
@ -198,7 +212,9 @@ pub fn routes() -> Vec<Route> {
home,
kiosk,
home_kiosk,
new_kiosk
new_kiosk,
show,
show_kiosk
]
}

View File

@ -17,6 +17,10 @@
STATS
<span class="sr-only">Logbuch</span>
</a>
<a href="/log/show" class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer">
LGBUCH HISTORY
<span class="sr-only">Logbuch History</span>
</a>
<a href="/log" class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer">
LOGBUCH
<span class="sr-only">Logbuch</span>

View File

@ -0,0 +1,16 @@
{% import "includes/macros" as macros %}
{% import "includes/forms/log" as log %}
{% extends "base" %}
{% block content %}
<div class="max-w-screen-lg w-full">
<h1 class="h1">Logbuch</h1>
{% for log in logs %}
{{ log::show(log=log, state="completed", only_ones=false) }}
<hr />
{% endfor %}
</div>
{% endblock content%}

View File

@ -22,12 +22,6 @@
{% endif %}
<hr />
{% endfor %}
<h2 style="font-size: 100px">Einträge</h2>
{% for log in completed %}
{{ log::show(log=log, state="completed", only_ones=false) }}
<hr />
{% endfor %}
</div>
{% endblock content%}