diff --git a/peach-web-lite/Cargo.toml b/peach-web-lite/Cargo.toml
index 9172ded..3c697a5 100644
--- a/peach-web-lite/Cargo.toml
+++ b/peach-web-lite/Cargo.toml
@@ -12,3 +12,4 @@ peach-lib = { path = "../peach-lib" }
peach-network = { path = "../peach-network" }
peach-stats = { path = "../peach-stats" }
rouille = "3.5.0"
+golgi = { path = "/home/glyph/Projects/playground/rust/golgi" }
diff --git a/peach-web-lite/ap_card b/peach-web-lite/ap_card
new file mode 100644
index 0000000..707bed0
--- /dev/null
+++ b/peach-web-lite/ap_card
@@ -0,0 +1,68 @@
+{%- if ap_state == "up" %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
Access Point
+
+
peach
+
+
{{ ap_ip }}
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+

+
+ {%- if ap_traffic -%}
+
+
+ {%- else -%}
+
+
+ {%- endif -%}
+
+
+
+
+

+
+ {%- if ap_traffic -%}
+
+
+ {%- else -%}
+
+
+ {%- endif -%}
+
+
+
+
+
+
diff --git a/peach-web-lite/compilation_comparions b/peach-web-lite/compilation_comparions
new file mode 100644
index 0000000..7ac3e9d
--- /dev/null
+++ b/peach-web-lite/compilation_comparions
@@ -0,0 +1,12 @@
+
+[ peach-web-lite ]
+
+230 total dependencies
+
+Finished release [optimized] target(s) in 35.12s
+
+[ peach-web ]
+
+522 total dependencies
+
+Finished release [optimized] target(s) in 1m 33s
diff --git a/peach-web-lite/src/context/mod.rs b/peach-web-lite/src/context/mod.rs
index 908a926..a7c14cd 100644
--- a/peach-web-lite/src/context/mod.rs
+++ b/peach-web-lite/src/context/mod.rs
@@ -1,3 +1,4 @@
pub mod admin;
pub mod network;
pub mod status;
+pub mod test;
diff --git a/peach-web-lite/src/context/network.rs b/peach-web-lite/src/context/network.rs
index 708b2b4..551dae3 100644
--- a/peach-web-lite/src/context/network.rs
+++ b/peach-web-lite/src/context/network.rs
@@ -144,10 +144,10 @@ pub fn save_dns_configuration(
#[derive(Debug)]
pub struct IfaceTraffic {
- rx: u64,
- rx_unit: String,
- tx: u64,
- tx_unit: String,
+ pub rx: u64,
+ pub rx_unit: String,
+ pub tx: u64,
+ pub tx_unit: String,
}
#[derive(Debug)]
diff --git a/peach-web-lite/src/context/test.rs b/peach-web-lite/src/context/test.rs
new file mode 100644
index 0000000..38907eb
--- /dev/null
+++ b/peach-web-lite/src/context/test.rs
@@ -0,0 +1,12 @@
+use golgi;
+
+use golgi::sbot::Sbot;
+
+pub async fn test_async() -> Result<(), Box> {
+ let mut sbot_client = Sbot::init(Some("127.0.0.1:8009".to_string()), None).await?;
+
+ let id = sbot_client.whoami().await?;
+ println!("whoami: {}", id);
+
+ Ok(())
+}
diff --git a/peach-web-lite/src/main.rs b/peach-web-lite/src/main.rs
index 2d4e57c..82c1fcd 100644
--- a/peach-web-lite/src/main.rs
+++ b/peach-web-lite/src/main.rs
@@ -1,7 +1,7 @@
use std::env;
use lazy_static::lazy_static;
-use log::{info, warn};
+use log::info;
mod auth;
mod context;
diff --git a/peach-web-lite/src/router.rs b/peach-web-lite/src/router.rs
index 310ce7c..b3b3b65 100644
--- a/peach-web-lite/src/router.rs
+++ b/peach-web-lite/src/router.rs
@@ -76,6 +76,9 @@ pub fn minimal_router(request: &Request) -> Response {
/// Define router for fully-featured mode (PeachCloud).
pub fn complete_router(request: &Request) -> Response {
router!(request,
+ (GET) (/async) => {
+ routes::home::async_test()
+ },
(GET) (/) => {
routes::home::menu()
},
diff --git a/peach-web-lite/src/routes/home.rs b/peach-web-lite/src/routes/home.rs
index 6de59e4..a702595 100644
--- a/peach-web-lite/src/routes/home.rs
+++ b/peach-web-lite/src/routes/home.rs
@@ -8,3 +8,7 @@ pub fn menu() -> Response {
Response::html(templates::home::menu())
}
+
+pub fn async_test() -> Response {
+ Response::html(templates::home::async_test())
+}
diff --git a/peach-web-lite/src/templates/home.rs b/peach-web-lite/src/templates/home.rs
index 1a7de94..74c92dd 100644
--- a/peach-web-lite/src/templates/home.rs
+++ b/peach-web-lite/src/templates/home.rs
@@ -1,7 +1,21 @@
use maud::{html, PreEscaped};
+use crate::context;
use crate::templates;
+pub async fn async_test() -> PreEscaped {
+ let back = "".to_string();
+ let title = "".to_string();
+
+ let whoami = context::test::test_async().await.unwrap();
+
+ let content = html! {
+ p { (whoami) }
+ };
+
+ templates::base::base(back, title, content)
+}
+
pub fn menu() -> PreEscaped {
let back = "".to_string();
let title = "".to_string();
diff --git a/peach-web-lite/src/templates/status.rs b/peach-web-lite/src/templates/status.rs
index cf534ba..dc1ea74 100644
--- a/peach-web-lite/src/templates/status.rs
+++ b/peach-web-lite/src/templates/status.rs
@@ -3,6 +3,293 @@ use maud::{html, PreEscaped};
use crate::context::{network::NetworkStatusContext, status::StatusContext};
use crate::{templates, STANDALONE_MODE};
+fn ap_network_card(status: NetworkStatusContext) -> PreEscaped {
+ html! {
+ (PreEscaped(""))
+ div class="card center" {
+ (PreEscaped(""))
+ div class="capsule capsule-container success-border" {
+ (PreEscaped(""))
+ div class="two-grid" title="PeachCloud network mode and status" {
+ (PreEscaped(""))
+ a class="link two-grid-top-right" href="/settings/network" title="Configure network settings" {
+ img id="configureNetworking" class="icon-small" src="/static/icons/cog.svg" alt="Configure";
+ }
+ (PreEscaped(""))
+ (PreEscaped(""))
+ div class="grid-column-1" {
+ img id="netModeIcon" class="center icon icon-active" src="/static/icons/router.svg" alt="WiFi router";
+ label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="Access Point Online" { "ONLINE" }
+ }
+ (PreEscaped(""))
+ (PreEscaped(""))
+ div class="grid-column-2" {
+ label class="label-small font-gray" for="netMode" title="Network Mode" { "MODE" }
+ p id="netMode" class="card-text" title="Network Mode" { "Access Point" }
+ label class="label-small font-gray" for="netSsid" title="Access Point SSID" { "SSID" }
+ p id="netSsid" class="card-text" title="SSID" { (status.ap_ssid) }
+ label class="label-small font-gray" for="netIp" title="Access Point IP Address" { "IP" }
+ p id="netIp" class="card-text" title="IP" { (status.ap_ip) }
+ }
+ }
+ (PreEscaped(""))
+ hr;
+ (PreEscaped(""))
+ div class="three-grid card-container" {
+ // devices stack
+ div class="stack" {
+ img id="devices" class="icon icon-medium" title="Connected devices" src="/static/icons/devices.svg" alt="Digital devices";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ label class="label-medium" for="devices" style="padding-right: 3px;" title="Number of connected devices";
+ }
+ label class="label-small font-gray" { "DEVICES" }
+ }
+ // download stack
+ div class="stack" {
+ img id="dataDownload" class="icon icon-medium" title="Download" src="/static/icons/down-arrow.svg" alt="Download";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ @if let Some(traffic) = &status.ap_traffic {
+ label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total in "{ (traffic.rx_unit) }"" { (traffic.rx) }
+ label class="label-small font-near-black" { (traffic.rx_unit) }
+ } @else {
+ label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total";
+ label class="label-small font-near-black" { "0" }
+ }
+ }
+ label class="label-small font-gray" { "DOWNLOAD" }
+ }
+ // upload stack
+ div class="stack" {
+ img id="dataUpload" class="icon icon-medium" title="Upload" src="/static/icons/up-arrow.svg" alt="Upload";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ @if let Some(traffic) = status.ap_traffic {
+ label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total in "{ (traffic.tx_unit) }"" { (traffic.tx) }
+ label class="label-small font-near-black" { (traffic.tx_unit) }
+ } @else {
+ label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total";
+ label class="label-small font-near-black" { "0" }
+ }
+ }
+ label class="label-small font-gray" { "UPLOAD" }
+ }
+ }
+ }
+ }
+ }
+}
+
+fn wlan_network_card(status: NetworkStatusContext) -> PreEscaped {
+ let capsule = if status.wlan_state == *"up" {
+ "capsule capsule-container success-border"
+ } else {
+ "capsule capsule-container warning-border"
+ };
+ html! {
+ (PreEscaped(""))
+ div class="card center" {
+ (PreEscaped(""))
+ div class=(capsule) {
+ @if status.wlan_state == *"up" {
+ (PreEscaped(""))
+ div id="netInfoBox" class="two-grid" title="PeachCloud network mode and status" {
+ a class="link two-grid-top-right" href="/settings/network" title="Configure network settings" {
+ img id="configureNetworking" class="icon-small" src="/static/icons/cog.svg" alt="Configure";
+ }
+ (PreEscaped(""))
+ (PreEscaped(""))
+ (PreEscaped(""))
+ div class="grid-column-1" {
+ img id="netModeIcon" class="center icon icon-active" src="/static/icons/wifi.svg" alt="WiFi online";
+ label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="WiFi Client Status" { "ONLINE" }
+ }
+ div class="grid-column-2" {
+ (PreEscaped(""))
+ (PreEscaped(""))
+ label class="label-small font-gray" for="netMode" title="Network Mode" { "MODE" }
+ p id="netMode" class="card-text" title="Network Mode" { "WiFi Client" }
+ label class="label-small font-gray" for="netSsid" title="WiFi SSID" { "SSID" }
+ p id="netSsid" class="card-text" title="SSID" { (status.wlan_ssid) }
+ label class="label-small font-gray" for="netIp" title="WiFi Client IP Address" { "IP" }
+ p id="netIp" class="card-text" title="IP" { (status.wlan_ip) }
+ }
+ }
+ } @else {
+ div id="netInfoBox" class="two-grid" title="PeachCloud network mode and status" {
+ a class="link two-grid-top-right" href="/settings/network" title="Configure network settings" {
+ img id="configureNetworking" class="icon-small" src="/static/icons/cog.svg" alt="Configure";
+ }
+ div class="grid-column-1" {
+ img id="netModeIcon" class="center icon icon-inactive" src="/static/icons/wifi.svg" alt="WiFi offline";
+ label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="WiFi Client Status" { "OFFLINE" }
+ }
+ div class="grid-column-2" {
+ (PreEscaped(""))
+ (PreEscaped(""))
+ label class="label-small font-gray" for="netMode" title="Network Mode" { "MODE" }
+ p id="netMode" class="card-text" title="Network Mode" { "WiFi Client" }
+ label class="label-small font-gray" for="netSsid" title="WiFi SSID" { "SSID" }
+ p id="netSsid" class="card-text" title="SSID" { (status.wlan_ssid) }
+ label class="label-small font-gray" for="netIp" title="WiFi Client IP Address" { "IP" }
+ p id="netIp" class="card-text" title="IP" { (status.wlan_ip) }
+ }
+ }
+ }
+ (PreEscaped(""))
+ hr;
+ (PreEscaped(""))
+ (PreEscaped(""))
+ div class="three-grid card-container" {
+ div class="stack" {
+ img id="netSignal" class="icon icon-medium" alt="Signal" title="WiFi Signal (%)" src="/static/icons/low-signal.svg";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ label class="label-medium" for="netSignal" style="padding-right: 3px;" title="Signal strength of WiFi connection (%)" {
+ @if let Some(wlan_rssi) = status.wlan_rssi { (wlan_rssi) } @else { "0" }
+ }
+ }
+ label class="label-small font-gray" { "SIGNAL" }
+ }
+ div class="stack" {
+ img id="dataDownload" class="icon icon-medium" alt="Download" title="WiFi download total" src="/static/icons/down-arrow.svg";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ @if let Some(traffic) = &status.wlan_traffic {
+ (PreEscaped(""))
+ label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total in "{ (traffic.rx_unit) }"" { (traffic.rx) }
+ label class="label-small font-near-black" { (traffic.rx_unit) }
+ } @else {
+ (PreEscaped(""))
+ label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total" { "0" }
+ label class="label-small font-near-black" { "MB" }
+ }
+ }
+ label class="label-small font-gray" { "DOWNLOAD" }
+ }
+ div class="stack" {
+ img id="dataUpload" class="icon icon-medium" alt="Upload" title="WiFi upload total" src="/static/icons/up-arrow.svg";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ @if let Some(traffic) = status.wlan_traffic {
+ (PreEscaped(""))
+ label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total in "{ (traffic.tx_unit) }"" { (traffic.tx) }
+ label class="label-small font-near-black" { (traffic.tx_unit) }
+ } @else {
+ (PreEscaped(""))
+ label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total" { "0" }
+ label class="label-small font-near-black" { "MB" }
+ }
+ }
+ label class="label-small font-gray" { "UPLOAD" }
+ }
+ }
+ }
+ }
+ }
+}
+
+/*
+ * WORKS ... kinda
+fn wlan_network_card(status: NetworkStatusContext) -> PreEscaped {
+ html! {
+ (PreEscaped(""))
+ div class="card center" {
+ (PreEscaped(""))
+ @if status.wlan_state == *"up" {
+ div class="capsule capsule-container success-border" {
+ (PreEscaped(""))
+ div id="netInfoBox" class="two-grid" title="PeachCloud network mode and status" {
+ a class="link two-grid-top-right" href="/settings/network" title="Configure network settings" {
+ img id="configureNetworking" class="icon-small" src="/static/icons/cog.svg" alt="Configure";
+ }
+ (PreEscaped(""))
+ (PreEscaped(""))
+ (PreEscaped(""))
+ div class="grid-column-1" {
+ img id="netModeIcon" class="center icon icon-active" src="/static/icons/wifi.svg" alt="WiFi online";
+ label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="WiFi Client Status" { "ONLINE" }
+ }
+ div class="grid-column-2" {
+ (PreEscaped(""))
+ (PreEscaped(""))
+ label class="label-small font-gray" for="netMode" title="Network Mode" { "MODE" }
+ p id="netMode" class="card-text" title="Network Mode" { "WiFi Client" }
+ label class="label-small font-gray" for="netSsid" title="WiFi SSID" { "SSID" }
+ p id="netSsid" class="card-text" title="SSID" { (status.wlan_ssid) }
+ label class="label-small font-gray" for="netIp" title="WiFi Client IP Address" { "IP" }
+ p id="netIp" class="card-text" title="IP" { (status.wlan_ip) }
+ }
+ }
+ }
+ } @else {
+ div class="capsule capsule-container warning-border" {
+ div id="netInfoBox" class="two-grid" title="PeachCloud network mode and status" {
+ a class="link two-grid-top-right" href="/settings/network" title="Configure network settings" {
+ img id="configureNetworking" class="icon-small" src="/static/icons/cog.svg" alt="Configure";
+ }
+ div class="grid-column-1" {
+ img id="netModeIcon" class="center icon icon-inactive" src="/static/icons/wifi.svg" alt="WiFi offline";
+ label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="WiFi Client Status" { "OFFLINE" }
+ }
+ div class="grid-column-2" {
+ (PreEscaped(""))
+ (PreEscaped(""))
+ label class="label-small font-gray" for="netMode" title="Network Mode" { "MODE" }
+ p id="netMode" class="card-text" title="Network Mode" { "WiFi Client" }
+ label class="label-small font-gray" for="netSsid" title="WiFi SSID" { "SSID" }
+ p id="netSsid" class="card-text" title="SSID" { (status.wlan_ssid) }
+ label class="label-small font-gray" for="netIp" title="WiFi Client IP Address" { "IP" }
+ p id="netIp" class="card-text" title="IP" { (status.wlan_ip) }
+ }
+ }
+ }
+ }
+ (PreEscaped(""))
+ hr;
+ (PreEscaped(""))
+ (PreEscaped(""))
+ div class="three-grid card-container" {
+ div class="stack" {
+ img id="netSignal" class="icon icon-medium" alt="Signal" title="WiFi Signal (%)" src="/static/icons/low-signal.svg";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ label class="label-medium" for="netSignal" style="padding-right: 3px;" title="Signal strength of WiFi connection (%)" {
+ @if let Some(wlan_rssi) = status.wlan_rssi { (wlan_rssi) } @else { "0" }
+ }
+ }
+ label class="label-small font-gray" { "SIGNAL" }
+ }
+ div class="stack" {
+ img id="dataDownload" class="icon icon-medium" alt="Download" title="WiFi download total" src="/static/icons/down-arrow.svg";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ @if let Some(traffic) = &status.wlan_traffic {
+ (PreEscaped(""))
+ label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total in "{ (traffic.rx_unit) }"" { (traffic.rx) }
+ label class="label-small font-near-black" { (traffic.rx_unit) }
+ } @else {
+ (PreEscaped(""))
+ label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total" { "0" }
+ label class="label-small font-near-black" { "MB" }
+ }
+ }
+ label class="label-small font-gray" { "DOWNLOAD" }
+ }
+ div class="stack" {
+ img id="dataUpload" class="icon icon-medium" alt="Upload" title="WiFi upload total" src="/static/icons/up-arrow.svg";
+ div class="flex-grid" style="padding-top: 0.5rem;" {
+ @if let Some(traffic) = status.wlan_traffic {
+ (PreEscaped(""))
+ label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total in "{ (traffic.tx_unit) }"" { (traffic.tx) }
+ label class="label-small font-near-black" { (traffic.tx_unit) }
+ } @else {
+ (PreEscaped(""))
+ label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total" { "0" }
+ label class="label-small font-near-black" { "MB" }
+ }
+ }
+ label class="label-small font-gray" { "UPLOAD" }
+ }
+ }
+ }
+ }
+}
+*/
+
pub fn network() -> PreEscaped {
let back = "/status".to_string();
let title = "Network Status".to_string();
@@ -13,170 +300,34 @@ pub fn network() -> PreEscaped {
let content = html! {
(PreEscaped(""))
// if ap is up, show ap card, else show wlan card
+ @if status.ap_state == *"up" {
+ (ap_network_card(status))
+ } @else {
+ (wlan_network_card(status))
+ }
};
templates::base::base(back, title, content)
}
-/*
- {%- if ap_state == "up" %}
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
Access Point
-
-
peach
-
-
{{ ap_ip }}
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-

-
- {%- if ap_traffic -%}
-
-
- {%- else -%}
-
-
- {%- endif -%}
-
-
-
-
-

-
- {%- if ap_traffic -%}
-
-
- {%- else -%}
-
-
- {%- endif -%}
-
-
-
-
-
-
- {%- else %}
-
-
-
- {%- if wlan_state == "up" %}
-
-
-
-
-
-
-
-
-
-
-

-
- {%- else %}
-
-
-
-
-
-
-

-
- {%- endif %}
-
-
-
-
-
-
WiFi Client
-
-
{{ wlan_ssid }}
-
-
{{ wlan_ip }}
-
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-

-
- {%- if wlan_traffic %}
-
-
-
- {%- else %}
-
-
-
- {%- endif %}
-
-
-
-
-

-
- {%- if wlan_traffic %}
-
-
-
- {%- else %}
-
-
-
- {%- endif %}
-
-
-
-
-
-
- {%- endif -%}
- };
-
- templates::base::base(back, title, content)
+fn scuttlebutt_status() -> PreEscaped
{
+ html! {
+ (PreEscaped(""))
+ div class="card center" {
+ div class="card-container" {
+ p { "Network key: " }
+ p { "Replication hops: " }
+ p { "Sbot version: " }
+ p { "Process status: " }
+ p { "Process uptime: " }
+ p { "Blobstore size: " }
+ p { "Latest sequence number: " }
+ p { "Last time you visited this page, latest sequence was x ... now it's y" }
+ p { "Number of follows / followers / friends / blocks" }
+ }
+ }
+ }
}
-*/
pub fn status() -> PreEscaped {
let back = "/".to_string();
@@ -191,14 +342,7 @@ pub fn status() -> PreEscaped {
// render the scuttlebutt status template
let content = if *STANDALONE_MODE {
- html! {
- (PreEscaped(""))
- div class="card center" {
- div class="card-container" {
- p { "such scuttlebutt stats" }
- }
- }
- }
+ scuttlebutt_status()
// or render the complete system status template
} else {
html! {
diff --git a/peach-web-lite/wlan_card b/peach-web-lite/wlan_card
new file mode 100644
index 0000000..b0cc11f
--- /dev/null
+++ b/peach-web-lite/wlan_card
@@ -0,0 +1,85 @@
+{%- else %}
+
+
+
+ {%- if wlan_state == "up" %}
+
+
+
+
+
+
+
+
+
+
+

+
+ {%- else %}
+
+
+
+
+
+
+

+
+ {%- endif %}
+
+
+
+
+
+
WiFi Client
+
+
{{ wlan_ssid }}
+
+
{{ wlan_ip }}
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+

+
+ {%- if wlan_traffic %}
+
+
+
+ {%- else %}
+
+
+
+ {%- endif %}
+
+
+
+
+

+
+ {%- if wlan_traffic %}
+
+
+
+ {%- else %}
+
+
+
+ {%- endif %}
+
+
+
+
+
+
+ {%- endif -%}