1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
pub mod log;
pub mod user;
use crate::{
FlashM, Page,
locale::{Language, tr, trs},
scaffold::FlashDisplay,
};
use jellycommon::routes::{
u_admin_import, u_admin_invite_create, u_admin_invite_remove, u_admin_log,
u_admin_update_search, u_admin_users,
};
impl Page for AdminDashboardPage<'_> {
fn title(&self) -> String {
"Admin Dashboard".to_string()
}
fn to_render(&self) -> markup::DynRender {
markup::new!(@self)
}
}
markup::define!(
AdminDashboardPage<'a>(lang: &'a Language, busy: Option<&'static str>, last_import_err: &'a [String], flash: &'a FlashM, invites: &'a [String]) {
h1 { @trs(lang, "admin.dashboard.title") }
@FlashDisplay { flash }
@if !last_import_err.is_empty() {
section.message.error {
details {
summary { p.error { @tr(**lang, "admin.import_errors").replace("{n}", &last_import_err.len().to_string()) } }
ol { @for e in *last_import_err {
li.error { pre.error { @e } }
}}
}
}
}
ul {
li{a[href=u_admin_log(true)] { @trs(lang, "admin.log.warnonly") }}
li{a[href=u_admin_log(false)] { @trs(lang, "admin.log.full") }}
}
h2 { @trs(lang, "admin.dashboard.library") }
@if let Some(text) = busy {
section.message { p.warn { @text } }
}
form[method="POST", action=u_admin_import(true)] {
input[type="submit", disabled=busy.is_some(), value=tr(**lang, "admin.dashboard.import.inc").to_string()];
}
form[method="POST", action=u_admin_import(false)] {
input[type="submit", disabled=busy.is_some(), value=tr(**lang, "admin.dashboard.import.full").to_string()];
}
form[method="POST", action=u_admin_update_search()] {
input[type="submit", value=tr(**lang, "admin.dashboard.update_search").to_string()];
}
h2 { @trs(lang, "admin.dashboard.users") }
p { a[href=u_admin_users()] { @trs(lang, "admin.dashboard.manage_users") } }
h2 { @trs(lang, "admin.dashboard.invites") }
form[method="POST", action=u_admin_invite_create()] {
input[type="submit", value=tr(**lang, "admin.dashboard.create_invite").to_string()];
}
ul { @for t in *invites {
li {
form[method="POST", action=u_admin_invite_remove()] {
span { @t }
input[type="text", name="invite", value=&t, hidden];
input[type="submit", value=tr(**lang, "admin.dashboard.create_invite").to_string()];
}
}
}}
// h2 { "Database" }
// @match db_stats(&database) {
// Ok(s) => { @s }
// Err(e) => { pre.error { @format!("{e:?}") } }
// }
}
);
|