diff --git a/peach-web/src/context/network.rs b/peach-web/src/context/network.rs index 3ce1ee5..9e3b1b4 100644 --- a/peach-web/src/context/network.rs +++ b/peach-web/src/context/network.rs @@ -3,11 +3,7 @@ use std::collections::HashMap; -use rocket::{ - form::FromForm, - serde::{Deserialize, Serialize}, - UriDisplayQuery, -}; +use rocket::{form::FromForm, serde::Serialize, UriDisplayQuery}; use peach_network::{ network, @@ -36,12 +32,12 @@ pub fn ap_state() -> String { } } -#[derive(Debug, Deserialize, FromForm, UriDisplayQuery)] +#[derive(Debug, FromForm, UriDisplayQuery)] pub struct Ssid { pub ssid: String, } -#[derive(Debug, Deserialize, FromForm)] +#[derive(Debug, FromForm)] pub struct WiFi { pub ssid: String, pub pass: String, diff --git a/peach-web/src/context/scuttlebutt.rs b/peach-web/src/context/scuttlebutt.rs index 9d319a6..6a1fe5e 100644 --- a/peach-web/src/context/scuttlebutt.rs +++ b/peach-web/src/context/scuttlebutt.rs @@ -62,11 +62,11 @@ impl StatusContext { // retrieve go-sbot systemd process status let sbot_status = SbotStatus::read()?; + // retrieve latest go-sbot configuration parameters + let sbot_config = SbotConfig::read().ok(); + // we only want to try and interact with the sbot if it's active if sbot_status.state == Some("active".to_string()) { - // retrieve latest go-sbot configuration parameters - let sbot_config = SbotConfig::read().ok(); - let mut sbot_client = init_sbot_with_config(&sbot_config).await?; // retrieve the local id @@ -80,14 +80,13 @@ impl StatusContext { // assign the sequence number of the latest msg context.latest_seq = Some(msgs[0].sequence); - - context.sbot_config = sbot_config; } else { // the sbot is not currently active; return a helpful message context.flash_name = Some("warning".to_string()); context.flash_msg = Some("The Sbot is currently inactive. As a result, status data cannot be retrieved. Visit the Scuttlebutt settings menu to start the Sbot and then try again".to_string()); } + context.sbot_config = sbot_config; context.sbot_status = Some(sbot_status); Ok(context) diff --git a/peach-web/src/routes/scuttlebutt.rs b/peach-web/src/routes/scuttlebutt.rs index 01aa108..1d12076 100644 --- a/peach-web/src/routes/scuttlebutt.rs +++ b/peach-web/src/routes/scuttlebutt.rs @@ -156,7 +156,7 @@ pub async fn create_invite(invite: Form, _auth: Authenticated) -> Flash< Ok(false) => { return Flash::warning( Redirect::to(url), - "The Sbot is currently inactive. As a result, new posts cannot be published. Visit the Scuttlebutt settings menu to start the Sbot and then try again", + "The Sbot is currently inactive. As a result, new invite codes cannot be generated. Visit the Scuttlebutt settings menu to start the Sbot and then try again", ) } // failed to retrieve go-sbot systemd process status @@ -335,12 +335,20 @@ pub fn peers(flash: Option, _auth: Authenticated) -> Template { context.insert("title", &Some("Scuttlebutt Peers")); context.insert("back", &Some("/")); - // 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.insert("flash_name", &Some(flash.kind().to_string())); - context.insert("flash_msg", &Some(flash.message().to_string())); - }; + // display a helpful message if the sbot is inactive + if let Ok(false) = is_sbot_active() { + context.insert("sbot_state", &Some("inactive".to_string())); + context.insert("flash_name", &Some("warning".to_string())); + context.insert("flash_msg", &Some("The Sbot is currently inactive. As a result, social lists and interactions are unavailable. Visit the Scuttlebutt settings menu to start the Sbot and then try again".to_string())); + } else { + context.insert("sbot_state", &Some("active".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.insert("flash_name", &Some(flash.kind().to_string())); + context.insert("flash_msg", &Some(flash.message().to_string())); + }; + } Template::render("scuttlebutt/peers", &context.into_json()) } diff --git a/peach-web/src/routes/settings/dns.rs b/peach-web/src/routes/settings/dns.rs index 4d50672..376a115 100644 --- a/peach-web/src/routes/settings/dns.rs +++ b/peach-web/src/routes/settings/dns.rs @@ -3,7 +3,6 @@ use rocket::{ form::{Form, FromForm}, get, post, request::FlashMessage, - serde::Deserialize, }; use rocket_dyn_templates::Template; @@ -19,7 +18,7 @@ use crate::{ utils, }; -#[derive(Debug, Deserialize, FromForm)] +#[derive(Debug, FromForm)] pub struct DnsForm { pub external_domain: String, pub enable_dyndns: bool, diff --git a/peach-web/src/routes/settings/network.rs b/peach-web/src/routes/settings/network.rs index 14f0530..0e67c15 100644 --- a/peach-web/src/routes/settings/network.rs +++ b/peach-web/src/routes/settings/network.rs @@ -4,7 +4,6 @@ use rocket::{ get, post, request::FlashMessage, response::{Flash, Redirect}, - serde::Deserialize, uri, UriDisplayQuery, }; use rocket_dyn_templates::{tera::Context, Template}; @@ -21,12 +20,12 @@ use crate::{ // STRUCTS USED BY NETWORK ROUTES -#[derive(Debug, Deserialize, FromForm, UriDisplayQuery)] +#[derive(Debug, FromForm, UriDisplayQuery)] pub struct Ssid { pub ssid: String, } -#[derive(Debug, Deserialize, FromForm)] +#[derive(Debug, FromForm)] pub struct WiFi { pub ssid: String, pub pass: String, diff --git a/peach-web/src/routes/settings/scuttlebutt.rs b/peach-web/src/routes/settings/scuttlebutt.rs index 8e364d4..54b66f7 100644 --- a/peach-web/src/routes/settings/scuttlebutt.rs +++ b/peach-web/src/routes/settings/scuttlebutt.rs @@ -10,14 +10,13 @@ use rocket::{ get, post, request::FlashMessage, response::{Flash, Redirect}, - serde::Deserialize, }; use rocket_dyn_templates::{tera::Context, Template}; use crate::routes::authentication::Authenticated; use crate::utils; -#[derive(Debug, Deserialize, FromForm)] +#[derive(Debug, FromForm)] pub struct SbotConfigForm { /// Directory path for the log and indexes. repo: String, diff --git a/peach-web/static/css/peachcloud.css b/peach-web/static/css/peachcloud.css index 676d43a..984ab2a 100644 --- a/peach-web/static/css/peachcloud.css +++ b/peach-web/static/css/peachcloud.css @@ -720,7 +720,7 @@ form { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; - margin-top: 0.5rem; + /* margin-top: 0.5rem; */ margin-bottom: 1rem; padding-left: 5px; line-height: 1.5rem; @@ -738,6 +738,7 @@ form { .message-input { height: 7rem; + margin-top: 0.5rem; overflow: auto; resize: vertical; width: 100%; @@ -770,7 +771,6 @@ form { } .label-medium { - color: var(--text-color); font-size: var(--font-size-3); display: block; } @@ -799,6 +799,10 @@ form { /* color: var(--font-near-black); */ } +.link:hover { + text-decoration: underline; +} + /* * LISTS */ diff --git a/peach-web/templates/scuttlebutt/peers.html.tera b/peach-web/templates/scuttlebutt/peers.html.tera index 23d667f..5409bf7 100644 --- a/peach-web/templates/scuttlebutt/peers.html.tera +++ b/peach-web/templates/scuttlebutt/peers.html.tera @@ -2,6 +2,8 @@ {%- block card %}
+ {# only render the peer menu elements if the sbot is active #} + {%- if sbot_state == "active" %}
@@ -12,5 +14,8 @@ Invites
+ {%- endif %} + + {% include "snippets/flash_message" %}
{%- endblock card -%} diff --git a/peach-web/templates/scuttlebutt/peers_list.html.tera b/peach-web/templates/scuttlebutt/peers_list.html.tera index c2dcfb4..9f7ee27 100644 --- a/peach-web/templates/scuttlebutt/peers_list.html.tera +++ b/peach-web/templates/scuttlebutt/peers_list.html.tera @@ -1,24 +1,30 @@ {%- extends "nav" -%} {%- block card %}
- {%- if peers %} + {%- if peers %} {%- else %}

No follows found

- {%- endif %} + {%- endif %}
{%- endblock card -%} diff --git a/peach-web/templates/scuttlebutt/search.html.tera b/peach-web/templates/scuttlebutt/search.html.tera index d5e508d..f4582dc 100644 --- a/peach-web/templates/scuttlebutt/search.html.tera +++ b/peach-web/templates/scuttlebutt/search.html.tera @@ -9,8 +9,8 @@ + + {% include "snippets/flash_message" %} - - {% include "snippets/flash_message" %} {%- endblock card -%} diff --git a/peach-web/templates/settings/scuttlebutt/menu.html.tera b/peach-web/templates/settings/scuttlebutt/menu.html.tera index a2f5513..93fb2d3 100644 --- a/peach-web/templates/settings/scuttlebutt/menu.html.tera +++ b/peach-web/templates/settings/scuttlebutt/menu.html.tera @@ -11,8 +11,6 @@ {% else %} Start Sbot {% endif %} - Check Filesystem - Remove Blocked Feeds {% include "snippets/flash_message" %} diff --git a/peach-web/templates/status/scuttlebutt.html.tera b/peach-web/templates/status/scuttlebutt.html.tera index 998efad..7e1e4d5 100644 --- a/peach-web/templates/status/scuttlebutt.html.tera +++ b/peach-web/templates/status/scuttlebutt.html.tera @@ -5,12 +5,12 @@ {%- if sbot_status.memory -%} {% set mem = sbot_status.memory / 1024 / 1024 | round | int -%} {%- else -%} - {% set mem = "X" -%} + {% set mem = "0" -%} {%- endif -%} {%- if sbot_status.blobstore -%} {% set blobs = sbot_status.blobstore / 1024 / 1024 | round | int -%} {%- else -%} - {% set blobs = "X" -%} + {% set blobs = "0" -%} {%- endif -%}
@@ -54,8 +54,12 @@
+ {% if sbot_status.state == "active" %} + {% else %} + + {% endif %}
@@ -65,22 +69,22 @@
- +
- - + +
- +