aboutsummaryrefslogtreecommitdiff
path: root/ui/src/components/admin.rs
blob: 831c746e8ffda1b6baa182473ed93de2d2180b95 (plain)
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
/*
    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>
*/

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()];
            }
        }
    }

);