aboutsummaryrefslogtreecommitdiff
path: root/ui/src/admin/import.rs
blob: 04b80b2c7f3c6a0725bc4217d4cc21f0497c9d4e (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
/*
    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>
*/

use crate::{
    FlashM, Page,
    locale::{Language, tr, trs},
    scaffold::FlashDisplay,
};
use jellycommon::routes::u_admin_import_post;

impl Page for AdminImportPage<'_> {
    fn title(&self) -> String {
        "User Management".to_string()
    }
    fn to_render(&self) -> markup::DynRender<'_> {
        markup::new!(@self)
    }
}

markup::define!(
    AdminImportPage<'a>(lang: &'a Language, busy: bool, last_import_err: &'a [String], flash: &'a FlashM) {
        @FlashDisplay { flash }
        @if *busy {
            h1 { @trs(lang, "admin.import.running") }
            noscript { "Live import progress needs javascript." }
            div[id="admin_import"] {}
        } else {
            h1 { @trs(lang, "admin.import.title") }
            @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 } }
                        }}
                    }
                }
            }
            form[method="POST", action=u_admin_import_post(true)] {
                input[type="submit", value=tr(**lang, "admin.dashboard.import.inc").to_string()];
            }
            form[method="POST", action=u_admin_import_post(false)] {
                input[type="submit", value=tr(**lang, "admin.dashboard.import.full").to_string()];
            }
        }
    }
);