forked from PeachCloud/peach-workspace
add scuttlebutt settings routes and template
This commit is contained in:
parent
1506e89c5e
commit
61828082fd
|
@ -0,0 +1,41 @@
|
|||
use rocket::{get, request::FlashMessage, serde::Serialize};
|
||||
use rocket_dyn_templates::Template;
|
||||
|
||||
use crate::routes::authentication::Authenticated;
|
||||
|
||||
// HELPERS AND ROUTES FOR /settings/scuttlebutt
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct ScuttlebuttSettingsContext {
|
||||
pub back: Option<String>,
|
||||
pub title: Option<String>,
|
||||
pub flash_name: Option<String>,
|
||||
pub flash_msg: Option<String>,
|
||||
}
|
||||
|
||||
impl ScuttlebuttSettingsContext {
|
||||
pub fn build() -> ScuttlebuttSettingsContext {
|
||||
ScuttlebuttSettingsContext {
|
||||
back: None,
|
||||
title: None,
|
||||
flash_name: None,
|
||||
flash_msg: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Scuttlebutt settings menu.
|
||||
#[get("/")]
|
||||
pub fn ssb_settings_menu(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||
let mut context = ScuttlebuttSettingsContext::build();
|
||||
// set back icon link to network route
|
||||
context.back = Some("/settings".to_string());
|
||||
context.title = Some("Scuttlebutt Settings".to_string());
|
||||
// check to see if there is a flash message to display
|
||||
if let Some(flash) = flash {
|
||||
// add flash message contents to the context object
|
||||
context.flash_name = Some(flash.kind().to_string());
|
||||
context.flash_msg = Some(flash.message().to_string());
|
||||
};
|
||||
Template::render("settings/scuttlebutt", &context)
|
||||
}
|
Loading…
Reference in New Issue