From be4af57d75cc1e233b4714b18198fb7bde49464d Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 16 Feb 2026 17:50:57 +0100 Subject: refactor ui responder; add admin import pages --- ui/src/components/admin.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++ ui/src/components/mod.rs | 8 +++++++ 2 files changed, 60 insertions(+) create mode 100644 ui/src/components/admin.rs (limited to 'ui/src/components') diff --git a/ui/src/components/admin.rs b/ui/src/components/admin.rs new file mode 100644 index 0000000..831c746 --- /dev/null +++ b/ui/src/components/admin.rs @@ -0,0 +1,52 @@ +/* + 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) 2026 metamuffin +*/ + +use crate::RenderInfo; +use jellycommon::{ + ADMIN_IMPORT_BUSY, ADMIN_IMPORT_ERROR, + jellyobject::Object, + routes::{u_admin_import, u_admin_import_post, u_admin_log}, +}; +use jellyui_locale::tr; + +markup::define!( + AdminDashboard<'a>(ri: &'a RenderInfo<'a>) { + h1 { @tr(ri.lang, "admin.dashboard.title") } + ul { + li{a[href=u_admin_log(true)] { @tr(ri.lang, "admin.log.warnonly") }} + li{a[href=u_admin_log(false)] { @tr(ri.lang, "admin.log.full") }} + } + + a[href=u_admin_import()] { h2 { @tr(ri.lang, "admin.import.title") }} + } + + AdminImport<'a>(ri: &'a RenderInfo<'a>, data: Object<'a>) { + @if data.has(ADMIN_IMPORT_BUSY.0) { + h1 { @tr(ri.lang, "admin.import.running") } + noscript { "Live import progress needs javascript." } + div[id="admin_import"] {} + } else { + h1 { @tr(ri.lang, "admin.import.title") } + @if data.has(ADMIN_IMPORT_ERROR.0) { + section.message.error { + details { + summary { p.error { @tr(ri.lang, "admin.import_errors").replace("{n}", "1") } } + ol { @for e in data.iter(ADMIN_IMPORT_ERROR) { + li.error { pre.error { @e } } + }} + } + } + } + form[method="POST", action=u_admin_import_post(true)] { + input[type="submit", value=tr(ri.lang, "admin.dashboard.import.inc").to_string()]; + } + form[method="POST", action=u_admin_import_post(false)] { + input[type="submit", value=tr(ri.lang, "admin.dashboard.import.full").to_string()]; + } + } + } + +); diff --git a/ui/src/components/mod.rs b/ui/src/components/mod.rs index 792894e..cb9ec1b 100644 --- a/ui/src/components/mod.rs +++ b/ui/src/components/mod.rs @@ -4,6 +4,7 @@ Copyright (C) 2026 metamuffin */ +pub mod admin; pub mod login; pub mod message; pub mod node_page; @@ -13,6 +14,7 @@ pub mod stats; use crate::{ RenderInfo, components::{ + admin::{AdminDashboard, AdminImport}, login::{AccountLogin, AccountLogout, AccountSetPassword}, message::Message, node_page::NodePage, @@ -38,5 +40,11 @@ define! { @if let Some(session) = view.get(VIEW_ACCOUNT_SET_PASSWORD) { @AccountSetPassword { ri, session } } + @if let Some(()) = view.get(VIEW_ADMIN_DASHBOARD) { + @AdminDashboard { ri } + } + @if let Some(data) = view.get(VIEW_ADMIN_IMPORT) { + @AdminImport { ri, data } + } } } -- cgit v1.3