diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-02-16 17:50:57 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-02-16 17:50:57 +0100 |
| commit | be4af57d75cc1e233b4714b18198fb7bde49464d (patch) | |
| tree | 6e529e748fc1d5c212dcf8033c8158630ca4f4d6 /ui/src | |
| parent | bb1822e3e68fe6f699102bfc1659731bdbac1a40 (diff) | |
| download | jellything-be4af57d75cc1e233b4714b18198fb7bde49464d.tar jellything-be4af57d75cc1e233b4714b18198fb7bde49464d.tar.bz2 jellything-be4af57d75cc1e233b4714b18198fb7bde49464d.tar.zst | |
refactor ui responder; add admin import pages
Diffstat (limited to 'ui/src')
| -rw-r--r-- | ui/src/components/admin.rs (renamed from ui/src/old/admin/import.rs) | 38 | ||||
| -rw-r--r-- | ui/src/components/mod.rs | 8 | ||||
| -rw-r--r-- | ui/src/lib.rs | 2 | ||||
| -rw-r--r-- | ui/src/old/admin/mod.rs | 64 |
4 files changed, 32 insertions, 80 deletions
diff --git a/ui/src/old/admin/import.rs b/ui/src/components/admin.rs index 805d787..831c746 100644 --- a/ui/src/old/admin/import.rs +++ b/ui/src/components/admin.rs @@ -4,32 +4,37 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use crate::{FlashM, Page, locale::tr, scaffold::{FlashDisplay, RenderInfo}}; -use jellycommon::routes::u_admin_import_post; +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; -impl Page for AdminImportPage<'_> { - fn title(&self) -> String { - "Import".to_string() - } - fn to_render(&self) -> markup::DynRender<'_> { - markup::new!(@self) +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") }} } -} -markup::define!( - AdminImportPage<'a>(ri: &'a RenderInfo<'a>, busy: bool, last_import_err: &'a [String], flash: &'a FlashM) { - @FlashDisplay { flash } - @if *busy { + 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 !last_import_err.is_empty() { + @if data.has(ADMIN_IMPORT_ERROR.0) { section.message.error { details { - summary { p.error { @tr(ri.lang, "admin.import_errors").replace("{n}", &last_import_err.len().to_string()) } } - ol { @for e in *last_import_err { + 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 } } }} } @@ -43,4 +48,5 @@ markup::define!( } } } + ); 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 <metamuffin.org> */ +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 } + } } } diff --git a/ui/src/lib.rs b/ui/src/lib.rs index 9509129..5b23ee2 100644 --- a/ui/src/lib.rs +++ b/ui/src/lib.rs @@ -10,6 +10,8 @@ mod scaffold; pub use jellyui_client_scripts::*; pub use jellyui_client_style::*; +pub use jellyui_locale::tr; + use crate::{components::View, scaffold::Scaffold}; use jellycommon::{jellyobject::Object, *}; use serde::{Deserialize, Serialize}; diff --git a/ui/src/old/admin/mod.rs b/ui/src/old/admin/mod.rs deleted file mode 100644 index f42ba76..0000000 --- a/ui/src/old/admin/mod.rs +++ /dev/null @@ -1,64 +0,0 @@ -/* - 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 <metamuffin.org> -*/ - -pub mod import; -pub mod log; -pub mod user; - -use crate::{FlashM, Page, locale::tr, scaffold::{FlashDisplay, RenderInfo}}; -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>(ri: &'a RenderInfo<'a>, busy: Option<&'static str>, flash: &'a FlashM, invites: &'a [String]) { - h1 { @tr(ri.lang, "admin.dashboard.title") } - @FlashDisplay { flash } - 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") }} - @if let Some(text) = busy { - section.message { p.warn { @text } } - } - form[method="POST", action=u_admin_update_search()] { - input[type="submit", value=tr(ri.lang, "admin.dashboard.update_search").to_string()]; - } - h2 { @tr(ri.lang, "admin.dashboard.users") } - p { a[href=u_admin_users()] { @tr(ri.lang, "admin.dashboard.manage_users") } } - h2 { @tr(ri.lang, "admin.dashboard.invites") } - form[method="POST", action=u_admin_invite_create()] { - input[type="submit", value=tr(ri.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(ri.lang, "admin.dashboard.create_invite").to_string()]; - } - } - }} - - // h2 { "Database" } - // @match db_stats(&database) { - // Ok(s) => { @s } - // Err(e) => { pre.error { @format!("{e:?}") } } - // } - } -); |