Merge pull request 'Deduplicate routes and add Scuttlebutt status route & template' (#73) from add_sbot_status into main
Reviewed-on: #73
This commit is contained in:
commit
66555f19bf
|
@ -55,9 +55,9 @@ static AP_IFACE: &str = "ap0";
|
||||||
pub fn init_rocket() -> Rocket<Build> {
|
pub fn init_rocket() -> Rocket<Build> {
|
||||||
info!("Initializing Rocket");
|
info!("Initializing Rocket");
|
||||||
if *STANDALONE_MODE {
|
if *STANDALONE_MODE {
|
||||||
router::build_minimal_rocket()
|
router::mount_peachpub_routes()
|
||||||
} else {
|
} else {
|
||||||
router::build_complete_rocket()
|
router::mount_peachcloud_routes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,15 @@ use crate::routes::{
|
||||||
index::*,
|
index::*,
|
||||||
scuttlebutt::*,
|
scuttlebutt::*,
|
||||||
settings::{admin::*, dns::*, menu::*, network::*, scuttlebutt::*},
|
settings::{admin::*, dns::*, menu::*, network::*, scuttlebutt::*},
|
||||||
status::{device::*, network::*},
|
status::{device::*, network::*, scuttlebutt::*},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Create minimal rocket instance and mount routes. This excludes settings
|
/// Create a Rocket instance and mount PeachPub routes, fileserver and
|
||||||
/// and status routes related to networking and the device (memory,
|
/// catchers. This gives us everything we need to run PeachPub and excludes
|
||||||
|
/// settings and status routes related to networking and the device (memory,
|
||||||
/// hard disk, CPU etc.).
|
/// hard disk, CPU etc.).
|
||||||
pub fn build_minimal_rocket() -> Rocket<Build> {
|
pub fn mount_peachpub_routes() -> Rocket<Build> {
|
||||||
rocket::build()
|
rocket::build()
|
||||||
// GENERAL HTML ROUTES
|
|
||||||
.mount(
|
.mount(
|
||||||
"/",
|
"/",
|
||||||
routes![
|
routes![
|
||||||
|
@ -30,7 +30,6 @@ pub fn build_minimal_rocket() -> Rocket<Build> {
|
||||||
settings_menu,
|
settings_menu,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
// ADMIN SETTINGS HTML ROUTES
|
|
||||||
.mount(
|
.mount(
|
||||||
"/settings/admin",
|
"/settings/admin",
|
||||||
routes![
|
routes![
|
||||||
|
@ -47,12 +46,10 @@ pub fn build_minimal_rocket() -> Rocket<Build> {
|
||||||
send_password_reset_post,
|
send_password_reset_post,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
// SCUTTLEBUTT SETTINGS HTML ROUTES
|
|
||||||
.mount(
|
.mount(
|
||||||
"/settings/scuttlebutt",
|
"/settings/scuttlebutt",
|
||||||
routes![ssb_settings_menu, configure_sbot],
|
routes![ssb_settings_menu, configure_sbot],
|
||||||
)
|
)
|
||||||
// SCUTTLEBUTT SOCIAL HTML ROUTES
|
|
||||||
.mount(
|
.mount(
|
||||||
"/scuttlebutt",
|
"/scuttlebutt",
|
||||||
routes![
|
routes![
|
||||||
|
@ -60,50 +57,17 @@ pub fn build_minimal_rocket() -> Rocket<Build> {
|
||||||
block, publish,
|
block, publish,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
// STATUS HTML ROUTES
|
.mount("/status", routes![scuttlebutt_status])
|
||||||
// TODO: replace this with a route for `scuttlebutt_status`
|
|
||||||
.mount("/status", routes![device_status, network_status])
|
|
||||||
.mount("/", FileServer::from("static"))
|
.mount("/", FileServer::from("static"))
|
||||||
.register("/", catchers![not_found, internal_error, forbidden])
|
.register("/", catchers![not_found, internal_error, forbidden])
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create complete rocket instance and mount all routes.
|
/// Create a Rocket instance with PeachPub routes, fileserver and catchers by
|
||||||
pub fn build_complete_rocket() -> Rocket<Build> {
|
/// calling `mount_peachpub_routes()` and then mount all additional routes
|
||||||
rocket::build()
|
/// required to run a complete PeachCloud build.
|
||||||
// GENERAL HTML ROUTES
|
pub fn mount_peachcloud_routes() -> Rocket<Build> {
|
||||||
.mount(
|
mount_peachpub_routes()
|
||||||
"/",
|
|
||||||
routes![
|
|
||||||
help,
|
|
||||||
home,
|
|
||||||
login,
|
|
||||||
login_post,
|
|
||||||
logout,
|
|
||||||
reboot_cmd,
|
|
||||||
shutdown_cmd,
|
|
||||||
power_menu,
|
|
||||||
settings_menu,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
// ADMIN SETTINGS HTML ROUTES
|
|
||||||
.mount(
|
|
||||||
"/settings/admin",
|
|
||||||
routes![
|
|
||||||
admin_menu,
|
|
||||||
configure_admin,
|
|
||||||
add_admin,
|
|
||||||
add_admin_post,
|
|
||||||
delete_admin_post,
|
|
||||||
change_password,
|
|
||||||
change_password_post,
|
|
||||||
reset_password,
|
|
||||||
reset_password_post,
|
|
||||||
forgot_password_page,
|
|
||||||
send_password_reset_post,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
// NETWORK SETTINGS HTML ROUTES
|
|
||||||
.mount(
|
.mount(
|
||||||
"/settings/network",
|
"/settings/network",
|
||||||
routes![
|
routes![
|
||||||
|
@ -127,22 +91,5 @@ pub fn build_complete_rocket() -> Rocket<Build> {
|
||||||
wifi_usage_reset,
|
wifi_usage_reset,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
// SCUTTLEBUTT SETTINGS HTML ROUTES
|
|
||||||
.mount(
|
|
||||||
"/settings/scuttlebutt",
|
|
||||||
routes![ssb_settings_menu, configure_sbot],
|
|
||||||
)
|
|
||||||
// SCUTTLEBUTT SOCIAL HTML ROUTES
|
|
||||||
.mount(
|
|
||||||
"/scuttlebutt",
|
|
||||||
routes![
|
|
||||||
peers, friends, follows, followers, blocks, profile, private, follow, unfollow,
|
|
||||||
block, publish,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
// STATUS HTML ROUTES
|
|
||||||
.mount("/status", routes![device_status, network_status])
|
.mount("/status", routes![device_status, network_status])
|
||||||
.mount("/", FileServer::from("static"))
|
|
||||||
.register("/", catchers![not_found, internal_error, forbidden])
|
|
||||||
.attach(Template::fairing())
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ use rocket::{get, request::FlashMessage};
|
||||||
use rocket_dyn_templates::{tera::Context, Template};
|
use rocket_dyn_templates::{tera::Context, Template};
|
||||||
|
|
||||||
use crate::routes::authentication::Authenticated;
|
use crate::routes::authentication::Authenticated;
|
||||||
|
use crate::STANDALONE_MODE;
|
||||||
|
|
||||||
// HELPERS AND ROUTES FOR / (HOME PAGE)
|
// HELPERS AND ROUTES FOR / (HOME PAGE)
|
||||||
|
|
||||||
|
@ -11,6 +12,8 @@ pub fn home(_auth: Authenticated) -> Template {
|
||||||
context.insert("flash_name", &None::<()>);
|
context.insert("flash_name", &None::<()>);
|
||||||
context.insert("flash_msg", &None::<()>);
|
context.insert("flash_msg", &None::<()>);
|
||||||
context.insert("title", &None::<()>);
|
context.insert("title", &None::<()>);
|
||||||
|
// pass in mode so we can define appropriate urls in template
|
||||||
|
context.insert("standalone_mode", &*STANDALONE_MODE);
|
||||||
|
|
||||||
Template::render("home", &context.into_json())
|
Template::render("home", &context.into_json())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
pub mod device;
|
pub mod device;
|
||||||
pub mod network;
|
pub mod network;
|
||||||
|
pub mod scuttlebutt;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
use rocket::{get, request::FlashMessage};
|
||||||
|
use rocket_dyn_templates::{tera::Context, Template};
|
||||||
|
|
||||||
|
use crate::routes::authentication::Authenticated;
|
||||||
|
|
||||||
|
// HELPERS AND ROUTES FOR /status/scuttlebutt
|
||||||
|
|
||||||
|
#[get("/scuttlebutt")]
|
||||||
|
pub fn scuttlebutt_status(_auth: Authenticated) -> Template {
|
||||||
|
let mut context = Context::new();
|
||||||
|
context.insert("flash_name", &None::<()>);
|
||||||
|
context.insert("flash_msg", &None::<()>);
|
||||||
|
context.insert("title", &Some("Scuttlebutt Status"));
|
||||||
|
|
||||||
|
Template::render("status/scuttlebutt", &context.into_json())
|
||||||
|
}
|
|
@ -29,7 +29,11 @@
|
||||||
</a>
|
</a>
|
||||||
<!-- bottom-left -->
|
<!-- bottom-left -->
|
||||||
<!-- SYSTEM STATUS LINK AND ICON -->
|
<!-- SYSTEM STATUS LINK AND ICON -->
|
||||||
|
{%- if standalone_mode == true -%}
|
||||||
|
<a class="bottom-left" href="/status/scuttlebutt" title="Status">
|
||||||
|
{% else -%}
|
||||||
<a class="bottom-left" href="/status" title="Status">
|
<a class="bottom-left" href="/status" title="Status">
|
||||||
|
{%- endif -%}
|
||||||
<div class="circle circle-small">
|
<div class="circle circle-small">
|
||||||
<img class="icon-medium" src="/icons/heart-pulse.svg">
|
<img class="icon-medium" src="/icons/heart-pulse.svg">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
{# Display microservice status for network, oled & stats #}
|
{# Display microservice status for network, oled & stats #}
|
||||||
<!-- PEACH-NETWORK STATUS STACK -->
|
<!-- PEACH-NETWORK STATUS STACK -->
|
||||||
<a class="link" href="/status/network">
|
<a class="link" href="/status/network">
|
||||||
<div class="stack capsule{% if network_ping == "ONLINE" %} success-border{% else %} warning-border{% endif %}">
|
<div class="stack capsule{% if network_ping == "ONLINE" %} success-border{% else %} warning-border{% endif %}">
|
||||||
<img id="networkIcon" class="icon{% if network_ping == "OFFLINE" %} icon-inactive{% endif %} icon-medium" alt="Network" title="Network microservice status" src="/icons/wifi.svg">
|
<img id="networkIcon" class="icon{% if network_ping == "OFFLINE" %} icon-inactive{% endif %} icon-medium" alt="Network" title="Network microservice status" src="/icons/wifi.svg">
|
||||||
<div class="stack" style="padding-top: 0.5rem;">
|
<div class="stack" style="padding-top: 0.5rem;">
|
||||||
<label class="label-small font-near-black">Networking</label>
|
<label class="label-small font-near-black">Networking</label>
|
||||||
<label class="label-small font-near-black">{{ network_ping }}</label>
|
<label class="label-small font-near-black">{{ network_ping }}</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</a>
|
</a>
|
||||||
<!-- PEACH-OLED STATUS STACK -->
|
<!-- PEACH-OLED STATUS STACK -->
|
||||||
<div class="stack capsule{% if oled_ping == "ONLINE" %} success-border{% else %} warning-border{% endif %}">
|
<div class="stack capsule{% if oled_ping == "ONLINE" %} success-border{% else %} warning-border{% endif %}">
|
||||||
|
@ -67,14 +67,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- SBOT STATUS STACK -->
|
<!-- SBOT STATUS STACK -->
|
||||||
<div class="stack capsule{% if sbot_is_online %} success-border{% else %} warning-border{% endif %}">
|
<a class="link" href="/status/scuttlebutt">
|
||||||
<img id="networkIcon" class="icon{% if sbot_is_online != true %} icon-inactive{% endif %} icon-medium" alt="Sbot" title="Sbot status" src="/icons/hermies.svg">
|
<div class="stack capsule{% if sbot_is_online %} success-border{% else %} warning-border{% endif %}">
|
||||||
<div class="stack" style="padding-top: 0.5rem;">
|
<img id="networkIcon" class="icon{% if sbot_is_online != true %} icon-inactive{% endif %} icon-medium" alt="Sbot" title="Sbot status" src="/icons/hermies.svg">
|
||||||
<label class="label-small font-near-black">Sbot</label>
|
<div class="stack" style="padding-top: 0.5rem;">
|
||||||
<label class="label-small font-near-black">{% if sbot_is_online %} ONLINE {% else %} OFFLINE {% endif %} </label>
|
<label class="label-small font-near-black">Sbot</label>
|
||||||
|
<label class="label-small font-near-black">{% if sbot_is_online %} ONLINE {% else %} OFFLINE {% endif %} </label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
<div class="card-container">
|
<div class="card-container">
|
||||||
{# Display CPU usage meter #}
|
{# Display CPU usage meter #}
|
||||||
{%- if cpu_stat_percent -%}
|
{%- if cpu_stat_percent -%}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{%- extends "nav" -%}
|
||||||
|
{%- block card %}
|
||||||
|
<!-- SCUTTLEBUTT STATUS -->
|
||||||
|
<div class="card center">
|
||||||
|
<div class="card-container">
|
||||||
|
<p>Network key: </p>
|
||||||
|
<p>Replication hops: </p>
|
||||||
|
<p>Sbot version: </p>
|
||||||
|
<p>Process status: </p>
|
||||||
|
<p>Process uptime: </p>
|
||||||
|
<p>Blobstore size: </p>
|
||||||
|
<p>Latest sequence number: </p>
|
||||||
|
<p>Last time you visited this page, latest sequence was x ... now it's y</p>
|
||||||
|
<p>Number of follows / followers / friends / blocks</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{%- endblock card -%}
|
Loading…
Reference in New Issue