Merge pull request 'Add sbot configuration route and template' (#71) from sbot_settings into main
Reviewed-on: #71
This commit is contained in:
commit
72fbbe83f0
|
@ -48,7 +48,10 @@ pub fn build_minimal_rocket() -> Rocket<Build> {
|
|||
],
|
||||
)
|
||||
// SCUTTLEBUTT SETTINGS HTML ROUTES
|
||||
.mount("/settings/scuttlebutt", routes![ssb_settings_menu])
|
||||
.mount(
|
||||
"/settings/scuttlebutt",
|
||||
routes![ssb_settings_menu, configure_sbot],
|
||||
)
|
||||
// SCUTTLEBUTT SOCIAL HTML ROUTES
|
||||
.mount(
|
||||
"/scuttlebutt",
|
||||
|
@ -125,7 +128,10 @@ pub fn build_complete_rocket() -> Rocket<Build> {
|
|||
],
|
||||
)
|
||||
// SCUTTLEBUTT SETTINGS HTML ROUTES
|
||||
.mount("/settings/scuttlebutt", routes![ssb_settings_menu])
|
||||
.mount(
|
||||
"/settings/scuttlebutt",
|
||||
routes![ssb_settings_menu, configure_sbot],
|
||||
)
|
||||
// SCUTTLEBUTT SOCIAL HTML ROUTES
|
||||
.mount(
|
||||
"/scuttlebutt",
|
||||
|
|
|
@ -1,41 +1,36 @@
|
|||
use rocket::{get, request::FlashMessage, serde::Serialize};
|
||||
use rocket_dyn_templates::Template;
|
||||
use rocket::{get, request::FlashMessage};
|
||||
use rocket_dyn_templates::{tera::Context, 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
|
||||
let mut context = Context::new();
|
||||
context.insert("back", &Some("/settings".to_string()));
|
||||
context.insert("title", &Some("Scuttlebutt Settings".to_string()));
|
||||
|
||||
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());
|
||||
context.insert("flash_name", &Some(flash.kind().to_string()));
|
||||
context.insert("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())
|
||||
}
|
||||
|
|
|
@ -684,6 +684,7 @@ html {
|
|||
font-family: var(--sans-serif);
|
||||
font-size: var(--font-size-7);
|
||||
display: block;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.label-medium {
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
{%- extends "nav" -%}
|
||||
{%- block card %}
|
||||
<!-- SBOT CONFIGURATION FORM -->
|
||||
<div class="card center">
|
||||
<form>
|
||||
<div class="center" style="display: flex; flex-direction: column; width: 80%;" title="Number of hops to replicate">
|
||||
<label for="hops" class="label-small">HOPS</label>
|
||||
<div id="hops" style="display: flex; justify-content: space-evenly;">
|
||||
<input type="radio" id="hops_0" name="hops" value="0">
|
||||
<label for="hops_0">0</label>
|
||||
<input type="radio" id="hops_1" name="hops" value="1">
|
||||
<label for="hops_1">1</label>
|
||||
<input type="radio" id="hops_2" name="hops" value="2">
|
||||
<label for="hops_2">2</label>
|
||||
<input type="radio" id="hops_3" name="hops" value="3">
|
||||
<label for="hops_3">3</label>
|
||||
<input type="radio" id="hops_4" name="hops" value="4">
|
||||
<label for="hops_4">4</label><br>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="center" style="display: flex; justify-content: space-between; width: 80%;">
|
||||
<div style="display: flex; flex-direction: column; width: 60%;" title="IP address on which the sbot runs">
|
||||
<label for="ip" class="label-small">IP ADDRESS</label>
|
||||
<input type="text" id="ip" name="ip">
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; width: 20%;" title="Port on which the sbot runs">
|
||||
<label for="port" class="label-small">PORT</label>
|
||||
<input type="text" id="port" name="port">
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="center" style="display: flex; flex-direction: column; width: 80%;" title="Network key (aka 'caps key') to define the Scuttleverse in which the sbot operates in">
|
||||
<label for="network_key" class="label-small">NETWORK KEY</label>
|
||||
<input type="text" id="network_key" name="network_key">
|
||||
</div>
|
||||
<br>
|
||||
<div class="center" style="display: flex; flex-direction: column; width: 80%;" title="Directory in which the sbot database is saved">
|
||||
<label for="database_dir" class="label-small">DATABASE DIRECTORY</label>
|
||||
<input type="text" id="database_dir" name="database_dir">
|
||||
</div>
|
||||
<br>
|
||||
<div class="center" style="width: 80%;" title="Broadcast the IP and port of this sbot instance so that local peers can discovery it and attempt to connect">
|
||||
<input type="checkbox" id="lan_broadcast" name="lan_broadcast">
|
||||
<label for="lan_broadcast">Enable LAN Broadcasting</label><br>
|
||||
<br>
|
||||
<input type="checkbox" id="lan_discovery" name="lan_discovery" title="Listen for the presence of local peers and attempt to connect if found">
|
||||
<label for="lan_discovery">Enable LAN Discovery</label><br>
|
||||
</div>
|
||||
<br>
|
||||
<input class="button button-primary center" type="button" value="Save">
|
||||
<input class="button button-warning center" type="button" value="Restore Defaults">
|
||||
</form>
|
||||
</div>
|
||||
{%- endblock card -%}
|
|
@ -4,15 +4,13 @@
|
|||
<div class="card center">
|
||||
<!-- BUTTONS -->
|
||||
<div id="settingsButtons">
|
||||
<a id="networkKey" class="button button-primary center" href="/settings/scuttlebutt/network_key" title="Set Network Key">Set Network Key</a>
|
||||
<a id="replicationHops" class="button button-primary center" href="/settings/scuttlebutt/hops" title="Set Replication Hops">Set Replication Hops</a>
|
||||
<a id="removeFeeds" class="button button-primary center" href="/settings/scuttlebutt/remove_feeds" title="Remove Blocked Feeds">Remove Blocked Feeds</a>
|
||||
<a id="setDirectory" class="button button-primary center" href="/settings/scuttlebutt/set_directory" title="Set Database Directory">Set Database Directory</a>
|
||||
<a id="checkFilesystem" class="button button-primary center" href="/settings/scuttlebutt/check_fs" title="Check Filesystem">Check Filesystem</a>
|
||||
<a id="repairFilesystem" class="button button-primary center" href="/settings/scuttlebutt/repair" title="Repair Filesystem">Repair Filesystem</a>
|
||||
<a id="configureSbot" class="button button-primary center" href="/settings/scuttlebutt/configure" title="Configure Sbot">Configure Sbot</a>
|
||||
<a id="disable" class="button button-primary center" href="/settings/scuttlebutt/disable" title="Disable Sbot">Disable Sbot</a>
|
||||
<a id="enable" class="button button-primary center" href="/settings/scuttlebutt/enable" title="Enable Sbot">Enable Sbot</a>
|
||||
<a id="restart" class="button button-primary center" href="/settings/scuttlebutt/restart" title="Restart Sbot">Restart Sbot</a>
|
||||
<a id="checkFilesystem" class="button button-primary center" href="/settings/scuttlebutt/check_fs" title="Check Filesystem">Check Filesystem</a>
|
||||
<a id="repairFilesystem" class="button button-primary center" href="/settings/scuttlebutt/repair" title="Repair Filesystem">Repair Filesystem</a>
|
||||
<a id="removeFeeds" class="button button-primary center" href="/settings/scuttlebutt/remove_feeds" title="Remove Blocked Feeds">Remove Blocked Feeds</a>
|
||||
</div>
|
||||
</div>
|
||||
{%- endblock card -%}
|
Loading…
Reference in New Issue