/* 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 */ pub mod log; pub mod user; use crate::{locale::{tr, Language}, scaffold::FlashDisplay, Page}; 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: Option>, invites: &'a [String]) { h1 { "Admin Panel" } @FlashDisplay { flash: flash.clone() } @if !last_import_err.is_empty() { section.message.error { details { summary { p.error { @format!("The last import resulted in {} errors:", last_import_err.len()) } } ol { @for e in *last_import_err { li.error { pre.error { @e } } }} } } } ul { li{a[href=u_admin_log(true)] { "Server Log (Warnings only)" }} li{a[href=u_admin_log(false)] { "Server Log (Full) " }} } h2 { "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="Start incremental import"]; } form[method="POST", action=u_admin_import(false)] { input[type="submit", disabled=busy.is_some(), value="Start full import"]; } form[method="POST", action=u_admin_update_search()] { input[type="submit", value="Regenerate full-text search index"]; } h2 { "Users" } p { a[href=u_admin_users()] "Manage Users" } h2 { "Invitations" } form[method="POST", action=u_admin_invite_create()] { input[type="submit", value="Generate new invite code"]; } 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="Invalidate"]; } } }} // h2 { "Database" } // @match db_stats(&database) { // Ok(s) => { @s } // Err(e) => { pre.error { @format!("{e:?}") } } // } } );