31 lines
1021 B
Rust
31 lines
1021 B
Rust
use rocket::{get, request::FlashMessage, State};
|
|
use rocket_dyn_templates::{tera::Context, Template};
|
|
|
|
use crate::routes::authentication::Authenticated;
|
|
use crate::RocketConfig;
|
|
|
|
// HELPERS AND ROUTES FOR /settings
|
|
|
|
/// View and delete currently configured admin.
|
|
#[get("/settings")]
|
|
pub fn settings_menu(
|
|
_auth: Authenticated,
|
|
flash: Option<FlashMessage>,
|
|
config: &State<RocketConfig>,
|
|
) -> Template {
|
|
let mut context = Context::new();
|
|
context.insert("back", &Some("/".to_string()));
|
|
context.insert("title", &Some("Settings".to_string()));
|
|
|
|
// pass in mode from managed state so we can conditionally render html elements
|
|
context.insert("standalone_mode", &config.standalone_mode);
|
|
|
|
// check to see if there is a flash message to display
|
|
if let Some(flash) = flash {
|
|
context.insert("flash_name", &Some(flash.kind().to_string()));
|
|
context.insert("flash_msg", &Some(flash.message().to_string()));
|
|
};
|
|
|
|
Template::render("settings/menu", &context.into_json())
|
|
}
|