async experiment (broken) plus lots of template updates
This commit is contained in:
@ -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" }
|
||||
|
68
peach-web-lite/ap_card
Normal file
68
peach-web-lite/ap_card
Normal file
@ -0,0 +1,68 @@
|
||||
{%- if ap_state == "up" %}
|
||||
<!-- NETWORK CARD -->
|
||||
<div class="card center">
|
||||
<!-- NETWORK INFO BOX -->
|
||||
<div class="capsule capsule-container success-border">
|
||||
<!-- NETWORK STATUS GRID -->
|
||||
<div class="two-grid" title="PeachCloud network mode and status">
|
||||
<!-- top-right config icon -->
|
||||
<a class="link two-grid-top-right" href="/settings/network" title="Configure network settings">
|
||||
<img id="configureNetworking" class="icon-small" src="/icons/cog.svg" alt="Configure">
|
||||
</a>
|
||||
<!-- left column -->
|
||||
<!-- network mode icon with label -->
|
||||
<div class="grid-column-1">
|
||||
<img id="netModeIcon" class="center icon icon-active" src="/icons/router.svg" alt="WiFi router">
|
||||
<label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="Access Point Online">ONLINE</label>
|
||||
</div>
|
||||
<!-- right column -->
|
||||
<!-- network mode, ssid & ip with labels -->
|
||||
<div class="grid-column-2">
|
||||
<label class="label-small font-gray" for="netMode" title="Network Mode">MODE</label>
|
||||
<p id="netMode" class="card-text" title="Network Mode">Access Point</p>
|
||||
<label class="label-small font-gray" for="netSsid" title="Access Point SSID">SSID</label>
|
||||
<p id="netSsid" class="card-text" title="SSID">peach</p>
|
||||
<label class="label-small font-gray" for="netIp" title="Access Point IP Address">IP</label>
|
||||
<p id="netIp" class="card-text" title="IP">{{ ap_ip }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- horizontal dividing line -->
|
||||
<hr>
|
||||
<!-- DEVICES AND TRAFFIC GRID -->
|
||||
<div class="three-grid card-container">
|
||||
<div class="stack">
|
||||
<img id="devices" class="icon icon-medium" title="Connected devices" src="/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>
|
||||
</div>
|
||||
<label class="label-small font-gray">DEVICES</label>
|
||||
</div>
|
||||
<div class="stack">
|
||||
<img id="dataDownload" class="icon icon-medium" title="Download" src="/icons/down-arrow.svg" alt="Download">
|
||||
<div class="flex-grid" style="padding-top: 0.5rem;">
|
||||
{%- if ap_traffic -%}
|
||||
<label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total in {{ ap_traffic.rx_unit }}">{{ ap_traffic.received }}</label>
|
||||
<label class="label-small font-near-black">{{ ap_traffic.rx_unit }}</label>
|
||||
{%- else -%}
|
||||
<label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total"></label>
|
||||
<label class="label-small font-near-black"></label>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
<label class="label-small font-gray">DOWNLOAD</label>
|
||||
</div>
|
||||
<div class="stack">
|
||||
<img id="dataUpload" class="icon icon-medium" title="Upload" src="/icons/up-arrow.svg" alt="Upload">
|
||||
<div class="flex-grid" style="padding-top: 0.5rem;">
|
||||
{%- if ap_traffic -%}
|
||||
<label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total in {{ ap_traffic.tx_unit }}">{{ ap_traffic.transmitted }}</label>
|
||||
<label class="label-small font-near-black">{{ ap_traffic.tx_unit }}</label>
|
||||
{%- else -%}
|
||||
<label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total"></label>
|
||||
<label class="label-small font-near-black"></label>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
<label class="label-small font-gray">UPLOAD</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
12
peach-web-lite/compilation_comparions
Normal file
12
peach-web-lite/compilation_comparions
Normal file
@ -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
|
@ -1,3 +1,4 @@
|
||||
pub mod admin;
|
||||
pub mod network;
|
||||
pub mod status;
|
||||
pub mod test;
|
||||
|
@ -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)]
|
||||
|
12
peach-web-lite/src/context/test.rs
Normal file
12
peach-web-lite/src/context/test.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use golgi;
|
||||
|
||||
use golgi::sbot::Sbot;
|
||||
|
||||
pub async fn test_async() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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(())
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
use std::env;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use log::{info, warn};
|
||||
use log::info;
|
||||
|
||||
mod auth;
|
||||
mod context;
|
||||
|
@ -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()
|
||||
},
|
||||
|
@ -8,3 +8,7 @@ pub fn menu() -> Response {
|
||||
|
||||
Response::html(templates::home::menu())
|
||||
}
|
||||
|
||||
pub fn async_test() -> Response {
|
||||
Response::html(templates::home::async_test())
|
||||
}
|
||||
|
@ -1,7 +1,21 @@
|
||||
use maud::{html, PreEscaped};
|
||||
|
||||
use crate::context;
|
||||
use crate::templates;
|
||||
|
||||
pub async fn async_test() -> PreEscaped<String> {
|
||||
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<String> {
|
||||
let back = "".to_string();
|
||||
let title = "".to_string();
|
||||
|
@ -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<String> {
|
||||
html! {
|
||||
(PreEscaped("<!-- NETWORK CARD -->"))
|
||||
div class="card center" {
|
||||
(PreEscaped("<!-- NETWORK INFO BOX -->"))
|
||||
div class="capsule capsule-container success-border" {
|
||||
(PreEscaped("<!-- NETWORK STATUS GRID -->"))
|
||||
div class="two-grid" title="PeachCloud network mode and status" {
|
||||
(PreEscaped("<!-- top-right config icon -->"))
|
||||
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("<!-- left column -->"))
|
||||
(PreEscaped("<!-- network mode icon with label -->"))
|
||||
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("<!-- right column -->"))
|
||||
(PreEscaped("<!-- network mode, ssid & ip with labels -->"))
|
||||
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("<!-- horizontal dividing line -->"))
|
||||
hr;
|
||||
(PreEscaped("<!-- DEVICES AND TRAFFIC GRID -->"))
|
||||
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<String> {
|
||||
let capsule = if status.wlan_state == *"up" {
|
||||
"capsule capsule-container success-border"
|
||||
} else {
|
||||
"capsule capsule-container warning-border"
|
||||
};
|
||||
html! {
|
||||
(PreEscaped("<!-- NETWORK CARD -->"))
|
||||
div class="card center" {
|
||||
(PreEscaped("<!-- NETWORK INFO BOX -->"))
|
||||
div class=(capsule) {
|
||||
@if status.wlan_state == *"up" {
|
||||
(PreEscaped("<!-- NETWORK STATUS GRID -->"))
|
||||
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("<!-- NETWORK STATUS -->"))
|
||||
(PreEscaped("<!-- left column -->"))
|
||||
(PreEscaped("<!-- network mode icon with label -->"))
|
||||
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("<!-- right column -->"))
|
||||
(PreEscaped("<!-- network mode, ssid & ip with labels -->"))
|
||||
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("<!-- right column -->"))
|
||||
(PreEscaped("<!-- network mode, ssid & ip with labels -->"))
|
||||
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("<!-- horizontal dividing line -->"))
|
||||
hr;
|
||||
(PreEscaped("<!-- SIGNAL AND TRAFFIC GRID -->"))
|
||||
(PreEscaped("<!-- row of icons representing network statistics -->"))
|
||||
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("<!-- display wlan traffic data -->"))
|
||||
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("<!-- no wlan traffic data to display -->"))
|
||||
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("<!-- display wlan traffic data -->"))
|
||||
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("<!-- no wlan traffic data to display -->"))
|
||||
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<String> {
|
||||
html! {
|
||||
(PreEscaped("<!-- NETWORK CARD -->"))
|
||||
div class="card center" {
|
||||
(PreEscaped("<!-- NETWORK INFO BOX -->"))
|
||||
@if status.wlan_state == *"up" {
|
||||
div class="capsule capsule-container success-border" {
|
||||
(PreEscaped("<!-- NETWORK STATUS GRID -->"))
|
||||
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("<!-- NETWORK STATUS -->"))
|
||||
(PreEscaped("<!-- left column -->"))
|
||||
(PreEscaped("<!-- network mode icon with label -->"))
|
||||
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("<!-- right column -->"))
|
||||
(PreEscaped("<!-- network mode, ssid & ip with labels -->"))
|
||||
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("<!-- right column -->"))
|
||||
(PreEscaped("<!-- network mode, ssid & ip with labels -->"))
|
||||
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("<!-- horizontal dividing line -->"))
|
||||
hr;
|
||||
(PreEscaped("<!-- SIGNAL AND TRAFFIC GRID -->"))
|
||||
(PreEscaped("<!-- row of icons representing network statistics -->"))
|
||||
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("<!-- display wlan traffic data -->"))
|
||||
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("<!-- no wlan traffic data to display -->"))
|
||||
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("<!-- display wlan traffic data -->"))
|
||||
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("<!-- no wlan traffic data to display -->"))
|
||||
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<String> {
|
||||
let back = "/status".to_string();
|
||||
let title = "Network Status".to_string();
|
||||
@ -13,170 +300,34 @@ pub fn network() -> PreEscaped<String> {
|
||||
let content = html! {
|
||||
(PreEscaped("<!-- NETWORK STATUS -->"))
|
||||
// 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" %}
|
||||
<!-- NETWORK CARD -->
|
||||
<div class="card center">
|
||||
<!-- NETWORK INFO BOX -->
|
||||
<div class="capsule capsule-container success-border">
|
||||
<!-- NETWORK STATUS GRID -->
|
||||
<div class="two-grid" title="PeachCloud network mode and status">
|
||||
<!-- top-right config icon -->
|
||||
<a class="link two-grid-top-right" href="/settings/network" title="Configure network settings">
|
||||
<img id="configureNetworking" class="icon-small" src="/icons/cog.svg" alt="Configure">
|
||||
</a>
|
||||
<!-- left column -->
|
||||
<!-- network mode icon with label -->
|
||||
<div class="grid-column-1">
|
||||
<img id="netModeIcon" class="center icon icon-active" src="/icons/router.svg" alt="WiFi router">
|
||||
<label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="Access Point Online">ONLINE</label>
|
||||
</div>
|
||||
<!-- right column -->
|
||||
<!-- network mode, ssid & ip with labels -->
|
||||
<div class="grid-column-2">
|
||||
<label class="label-small font-gray" for="netMode" title="Network Mode">MODE</label>
|
||||
<p id="netMode" class="card-text" title="Network Mode">Access Point</p>
|
||||
<label class="label-small font-gray" for="netSsid" title="Access Point SSID">SSID</label>
|
||||
<p id="netSsid" class="card-text" title="SSID">peach</p>
|
||||
<label class="label-small font-gray" for="netIp" title="Access Point IP Address">IP</label>
|
||||
<p id="netIp" class="card-text" title="IP">{{ ap_ip }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- horizontal dividing line -->
|
||||
<hr>
|
||||
<!-- DEVICES AND TRAFFIC GRID -->
|
||||
<div class="three-grid card-container">
|
||||
<div class="stack">
|
||||
<img id="devices" class="icon icon-medium" title="Connected devices" src="/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>
|
||||
</div>
|
||||
<label class="label-small font-gray">DEVICES</label>
|
||||
</div>
|
||||
<div class="stack">
|
||||
<img id="dataDownload" class="icon icon-medium" title="Download" src="/icons/down-arrow.svg" alt="Download">
|
||||
<div class="flex-grid" style="padding-top: 0.5rem;">
|
||||
{%- if ap_traffic -%}
|
||||
<label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total in {{ ap_traffic.rx_unit }}">{{ ap_traffic.received }}</label>
|
||||
<label class="label-small font-near-black">{{ ap_traffic.rx_unit }}</label>
|
||||
{%- else -%}
|
||||
<label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total"></label>
|
||||
<label class="label-small font-near-black"></label>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
<label class="label-small font-gray">DOWNLOAD</label>
|
||||
</div>
|
||||
<div class="stack">
|
||||
<img id="dataUpload" class="icon icon-medium" title="Upload" src="/icons/up-arrow.svg" alt="Upload">
|
||||
<div class="flex-grid" style="padding-top: 0.5rem;">
|
||||
{%- if ap_traffic -%}
|
||||
<label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total in {{ ap_traffic.tx_unit }}">{{ ap_traffic.transmitted }}</label>
|
||||
<label class="label-small font-near-black">{{ ap_traffic.tx_unit }}</label>
|
||||
{%- else -%}
|
||||
<label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total"></label>
|
||||
<label class="label-small font-near-black"></label>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
<label class="label-small font-gray">UPLOAD</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{%- else %}
|
||||
<!-- NETWORK CARD -->
|
||||
<div class="card center">
|
||||
<!-- NETWORK INFO BOX -->
|
||||
{%- if wlan_state == "up" %}
|
||||
<div class="capsule capsule-container success-border">
|
||||
<!-- NETWORK STATUS GRID -->
|
||||
<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="/icons/cog.svg" alt="Configure">
|
||||
</a>
|
||||
<!-- NETWORK STATUS -->
|
||||
<!-- left column -->
|
||||
<!-- network mode icon with label -->
|
||||
<div class="grid-column-1">
|
||||
<img id="netModeIcon" class="center icon icon-active" src="/icons/wifi.svg" alt="WiFi online">
|
||||
<label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="WiFi Client Status">ONLINE</label>
|
||||
{%- 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="/icons/cog.svg" alt="Configure">
|
||||
</a>
|
||||
<div class="grid-column-1">
|
||||
<img id="netModeIcon" class="center icon icon-inactive" src="/icons/wifi.svg" alt="WiFi offline">
|
||||
<label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="WiFi Client Status">OFFLINE</label>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<div class="grid-column-2">
|
||||
<!-- right column -->
|
||||
<!-- network mode, ssid & ip with labels -->
|
||||
<label class="label-small font-gray" for="netMode" title="Network Mode">MODE</label>
|
||||
<p id="netMode" class="card-text" title="Network Mode">WiFi Client</p>
|
||||
<label class="label-small font-gray" for="netSsid" title="WiFi SSID">SSID</label>
|
||||
<p id="netSsid" class="card-text" title="SSID">{{ wlan_ssid }}</p>
|
||||
<label class="label-small font-gray" for="netIp" title="WiFi Client IP Address">IP</label>
|
||||
<p id="netIp" class="card-text" title="IP">{{ wlan_ip }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- horizontal dividing line -->
|
||||
<hr>
|
||||
<!-- SIGNAL AND TRAFFIC GRID -->
|
||||
<!-- row of icons representing network statistics -->
|
||||
<div class="three-grid card-container">
|
||||
<div class="stack">
|
||||
<img id="netSignal" class="icon icon-medium" alt="Signal" title="WiFi Signal (%)" src="/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 wlan_rssi %}{{ wlan_rssi }}{% else %}0{% endif %}%</label>
|
||||
</div>
|
||||
<label class="label-small font-gray">SIGNAL</label>
|
||||
</div>
|
||||
<div class="stack">
|
||||
<img id="dataDownload" class="icon icon-medium" alt="Download" title="WiFi download total" src="/icons/down-arrow.svg">
|
||||
<div class="flex-grid" style="padding-top: 0.5rem;">
|
||||
{%- if wlan_traffic %}
|
||||
<!-- display wlan traffic data -->
|
||||
<label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total in {{ wlan_traffic.rx_unit }}">{{ wlan_traffic.received }}</label>
|
||||
<label class="label-small font-near-black">{{ wlan_traffic.rx_unit }}</label>
|
||||
{%- else %}
|
||||
<!-- no wlan traffic data to display -->
|
||||
<label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total">0</label>
|
||||
<label class="label-small font-near-black">MB</label>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<label class="label-small font-gray">DOWNLOAD</label>
|
||||
</div>
|
||||
<div class="stack">
|
||||
<img id="dataUpload" class="icon icon-medium" alt="Upload" title="WiFi upload total" src="/icons/up-arrow.svg">
|
||||
<div class="flex-grid" style="padding-top: 0.5rem;">
|
||||
{%- if wlan_traffic %}
|
||||
<!-- display wlan traffic data -->
|
||||
<label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total in {{ wlan_traffic.tx_unit }}">{{ wlan_traffic.transmitted }}</label>
|
||||
<label class="label-small font-near-black">{{ wlan_traffic.tx_unit }}</label>
|
||||
{%- else %}
|
||||
<!-- no wlan traffic data to display -->
|
||||
<label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total">0</label>
|
||||
<label class="label-small font-near-black">MB</label>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<label class="label-small font-gray">UPLOAD</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
};
|
||||
|
||||
templates::base::base(back, title, content)
|
||||
fn scuttlebutt_status() -> PreEscaped<String> {
|
||||
html! {
|
||||
(PreEscaped("<!-- SCUTTLEBUTT STATUS -->"))
|
||||
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<String> {
|
||||
let back = "/".to_string();
|
||||
@ -191,14 +342,7 @@ pub fn status() -> PreEscaped<String> {
|
||||
|
||||
// render the scuttlebutt status template
|
||||
let content = if *STANDALONE_MODE {
|
||||
html! {
|
||||
(PreEscaped("<!-- SCUTTLEBUTT STATUS -->"))
|
||||
div class="card center" {
|
||||
div class="card-container" {
|
||||
p { "such scuttlebutt stats" }
|
||||
}
|
||||
}
|
||||
}
|
||||
scuttlebutt_status()
|
||||
// or render the complete system status template
|
||||
} else {
|
||||
html! {
|
||||
|
85
peach-web-lite/wlan_card
Normal file
85
peach-web-lite/wlan_card
Normal file
@ -0,0 +1,85 @@
|
||||
{%- else %}
|
||||
<!-- NETWORK CARD -->
|
||||
<div class="card center">
|
||||
<!-- NETWORK INFO BOX -->
|
||||
{%- if wlan_state == "up" %}
|
||||
<div class="capsule capsule-container success-border">
|
||||
<!-- NETWORK STATUS GRID -->
|
||||
<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="/icons/cog.svg" alt="Configure">
|
||||
</a>
|
||||
<!-- NETWORK STATUS -->
|
||||
<!-- left column -->
|
||||
<!-- network mode icon with label -->
|
||||
<div class="grid-column-1">
|
||||
<img id="netModeIcon" class="center icon icon-active" src="/icons/wifi.svg" alt="WiFi online">
|
||||
<label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="WiFi Client Status">ONLINE</label>
|
||||
{%- 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="/icons/cog.svg" alt="Configure">
|
||||
</a>
|
||||
<div class="grid-column-1">
|
||||
<img id="netModeIcon" class="center icon icon-inactive" src="/icons/wifi.svg" alt="WiFi offline">
|
||||
<label id="netModeLabel" for="netModeIcon" class="center label-small font-gray" title="WiFi Client Status">OFFLINE</label>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<div class="grid-column-2">
|
||||
<!-- right column -->
|
||||
<!-- network mode, ssid & ip with labels -->
|
||||
<label class="label-small font-gray" for="netMode" title="Network Mode">MODE</label>
|
||||
<p id="netMode" class="card-text" title="Network Mode">WiFi Client</p>
|
||||
<label class="label-small font-gray" for="netSsid" title="WiFi SSID">SSID</label>
|
||||
<p id="netSsid" class="card-text" title="SSID">{{ wlan_ssid }}</p>
|
||||
<label class="label-small font-gray" for="netIp" title="WiFi Client IP Address">IP</label>
|
||||
<p id="netIp" class="card-text" title="IP">{{ wlan_ip }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- horizontal dividing line -->
|
||||
<hr>
|
||||
<!-- SIGNAL AND TRAFFIC GRID -->
|
||||
<!-- row of icons representing network statistics -->
|
||||
<div class="three-grid card-container">
|
||||
<div class="stack">
|
||||
<img id="netSignal" class="icon icon-medium" alt="Signal" title="WiFi Signal (%)" src="/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 wlan_rssi %}{{ wlan_rssi }}{% else %}0{% endif %}%</label>
|
||||
</div>
|
||||
<label class="label-small font-gray">SIGNAL</label>
|
||||
</div>
|
||||
<div class="stack">
|
||||
<img id="dataDownload" class="icon icon-medium" alt="Download" title="WiFi download total" src="/icons/down-arrow.svg">
|
||||
<div class="flex-grid" style="padding-top: 0.5rem;">
|
||||
{%- if wlan_traffic %}
|
||||
<!-- display wlan traffic data -->
|
||||
<label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total in {{ wlan_traffic.rx_unit }}">{{ wlan_traffic.received }}</label>
|
||||
<label class="label-small font-near-black">{{ wlan_traffic.rx_unit }}</label>
|
||||
{%- else %}
|
||||
<!-- no wlan traffic data to display -->
|
||||
<label class="label-medium" for="dataDownload" style="padding-right: 3px;" title="Data download total">0</label>
|
||||
<label class="label-small font-near-black">MB</label>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<label class="label-small font-gray">DOWNLOAD</label>
|
||||
</div>
|
||||
<div class="stack">
|
||||
<img id="dataUpload" class="icon icon-medium" alt="Upload" title="WiFi upload total" src="/icons/up-arrow.svg">
|
||||
<div class="flex-grid" style="padding-top: 0.5rem;">
|
||||
{%- if wlan_traffic %}
|
||||
<!-- display wlan traffic data -->
|
||||
<label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total in {{ wlan_traffic.tx_unit }}">{{ wlan_traffic.transmitted }}</label>
|
||||
<label class="label-small font-near-black">{{ wlan_traffic.tx_unit }}</label>
|
||||
{%- else %}
|
||||
<!-- no wlan traffic data to display -->
|
||||
<label class="label-medium" for="dataUpload" style="padding-right: 3px;" title="Data upload total">0</label>
|
||||
<label class="label-small font-near-black">MB</label>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<label class="label-small font-gray">UPLOAD</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{%- endif -%}
|
Reference in New Issue
Block a user