allow showing stat in kiosk mode
This commit is contained in:
parent
fb503dda6e
commit
a96bd81691
@ -84,7 +84,7 @@ async fn show(db: &State<SqlitePool>, user: User) -> Template {
|
||||
}
|
||||
|
||||
#[get("/show")]
|
||||
async fn show_kiosk(db: &State<SqlitePool>, _kios: KioskCookie) -> Template {
|
||||
async fn show_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie) -> Template {
|
||||
let logs = Logbook::completed(db).await;
|
||||
|
||||
Template::render("log.completed", context!(logs))
|
||||
|
@ -7,17 +7,30 @@ use crate::model::{
|
||||
user::User,
|
||||
};
|
||||
|
||||
#[get("/")]
|
||||
use super::log::KioskCookie;
|
||||
|
||||
#[get("/", rank = 2)]
|
||||
async fn index(db: &State<SqlitePool>, user: User) -> Template {
|
||||
let stat = Stat::get_rowed_km(db).await;
|
||||
let personal = stat::get_personal(db, &user).await;
|
||||
let kiosk = false;
|
||||
|
||||
println!("{personal:?}");
|
||||
Template::render("stat", context!(loggedin_user: &user, stat, personal))
|
||||
Template::render(
|
||||
"stat",
|
||||
context!(loggedin_user: &user, stat, personal, kiosk),
|
||||
)
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
async fn index_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie) -> Template {
|
||||
let stat = Stat::get_rowed_km(db).await;
|
||||
let kiosk = true;
|
||||
|
||||
Template::render("stat", context!(stat, kiosk))
|
||||
}
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![index]
|
||||
routes![index, index_kiosk]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -38,12 +38,14 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
{% if personal %}
|
||||
const data = [
|
||||
{%- for p in personal %}
|
||||
{ date: '{{p.date}}', km: {{p.km}} },
|
||||
{%- endfor %}
|
||||
]
|
||||
sessionStorage.setItem('userStats', JSON.stringify(data));
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<script src="/public/logbook.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user