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