aboutsummaryrefslogtreecommitdiff
path: root/server/src/ui/admin/mod.rs
blob: 555b6bcb8b0e788f0b8aeb024c4ebec641708729 (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
/*
    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;

use super::error::MyResult;
use crate::{request_info::RequestInfo, ui_responder::UiResponse};
use jellycommon::{jellyobject::ObjectBuffer, *};
use rocket::get;

#[get("/admin/dashboard")]
pub async fn r_admin_dashboard(ri: RequestInfo<'_>) -> MyResult<UiResponse> {
    ri.require_admin()?;

    let mut db_debug = String::new();
    ri.state.database.transaction(&mut |txn| {
        db_debug = txn.debug_info()?;
        Ok(())
    })?;

    Ok(ri.respond_ui(ObjectBuffer::new(&mut [
        (VIEW_ADMIN_DASHBOARD.0, &()),
        (
            VIEW_ADMIN_INFO.0,
            &ObjectBuffer::new(&mut [
                (ADMIN_INFO_TITLE.0, &"Database Debug"),
                (ADMIN_INFO_TEXT.0, &db_debug.as_str()),
            ]),
        ),
    ])))
}