add route for sbot config
This commit is contained in:
parent
5d75aebf0d
commit
3bb00c4eb7
|
@ -1,41 +1,36 @@
|
||||||
use rocket::{get, request::FlashMessage, serde::Serialize};
|
use rocket::{get, request::FlashMessage};
|
||||||
use rocket_dyn_templates::Template;
|
use rocket_dyn_templates::{tera::Context, Template};
|
||||||
|
|
||||||
use crate::routes::authentication::Authenticated;
|
use crate::routes::authentication::Authenticated;
|
||||||
|
|
||||||
// HELPERS AND ROUTES FOR /settings/scuttlebutt
|
// 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.
|
/// Scuttlebutt settings menu.
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub fn ssb_settings_menu(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
pub fn ssb_settings_menu(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = ScuttlebuttSettingsContext::build();
|
let mut context = Context::new();
|
||||||
// set back icon link to network route
|
context.insert("back", &Some("/settings".to_string()));
|
||||||
context.back = Some("/settings".to_string());
|
context.insert("title", &Some("Scuttlebutt 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 {
|
if let Some(flash) = flash {
|
||||||
// add flash message contents to the context object
|
context.insert("flash_name", &Some(flash.kind().to_string()));
|
||||||
context.flash_name = Some(flash.kind().to_string());
|
context.insert("flash_msg", &Some(flash.message().to_string()));
|
||||||
context.flash_msg = Some(flash.message().to_string());
|
|
||||||
};
|
};
|
||||||
Template::render("settings/scuttlebutt", &context)
|
|
||||||
|
Template::render("settings/scuttlebutt/menu", &context.into_json())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sbot configuration page (includes form for updating configuration parameters).
|
||||||
|
#[get("/configure")]
|
||||||
|
pub fn configure_sbot(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
|
let mut context = Context::new();
|
||||||
|
context.insert("back", &Some("/settings/scuttlebutt".to_string()));
|
||||||
|
context.insert("title", &Some("Sbot Configuration".to_string()));
|
||||||
|
|
||||||
|
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/scuttlebutt/configure_sbot", &context.into_json())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue