aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/config.rs9
-rw-r--r--src/main.rs134
-rw-r--r--static/style.css2
-rw-r--r--style.css20
-rw-r--r--templates/head.html2
-rw-r--r--templates/settings.html54
6 files changed, 196 insertions, 25 deletions
diff --git a/src/config.rs b/src/config.rs
index 33ba361..d54e01a 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -34,11 +34,12 @@ impl Default for TunnelConfig {
}
}
-type DurationSeconds = std::num::NonZeroU32;
+pub(crate) type DurationSeconds = u32;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BeaconConfig {
- pub period_seconds: Option<DurationSeconds>,
+ // A period of zero means beaconing is disabled
+ pub period_seconds: DurationSeconds,
#[serde(default)]
pub max_hops: u8,
pub latitude: Option<f64>,
@@ -47,13 +48,13 @@ pub struct BeaconConfig {
pub comment: Option<String>,
pub antenna_height: Option<u8>,
pub antenna_gain: Option<f32>,
- pub tx_power: Option<f32>,
+ pub tx_power: Option<f32>, // dBm
}
impl Default for BeaconConfig {
fn default() -> Self {
BeaconConfig {
- period_seconds: None,
+ period_seconds: 0,
max_hops: 3,
latitude: None,
longitude: None,
diff --git a/src/main.rs b/src/main.rs
index 50baf2f..6725c44 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-use std::sync::{Arc, Mutex};
+use std::{sync::{Arc, Mutex}, str::FromStr};
use serde::Deserialize;
use askama::Template;
use axum::{
@@ -7,6 +7,7 @@ use axum::{
Router,
response::Html,
Form,
+ http::StatusCode,
};
use sqlx::{Connection, SqliteConnection};
use tower_http::services::ServeDir;
@@ -18,7 +19,7 @@ struct AppState {
db : Mutex<SqliteConnection>
}
-type SharedState = Arc<AppState>;
+type SharedState = Arc<Mutex<AppState>>;
#[tokio::main]
async fn main() -> std::io::Result<()> {
@@ -33,10 +34,10 @@ async fn main() -> std::io::Result<()> {
let conf = config::Config::load().expect("Could not load config");
- let shared_state = Arc::new(AppState {
+ let shared_state = Arc::new(Mutex::new(AppState {
conf,
db: Mutex::new(conn)
- });
+ }));
let app = Router::new()
.route("/", get(dashboard))
@@ -85,13 +86,13 @@ enum ActivePage {
struct DashboardTemplate<'a> {
title: &'a str,
page: ActivePage,
- callsign: String,
+ conf: config::Config,
}
async fn dashboard(State(state): State<SharedState>) -> DashboardTemplate<'static> {
DashboardTemplate {
title: "Dashboard",
- callsign: state.conf.callsign.clone(),
+ conf: state.lock().unwrap().conf.clone(),
page: ActivePage::Dashboard,
}
}
@@ -101,13 +102,13 @@ async fn dashboard(State(state): State<SharedState>) -> DashboardTemplate<'stati
struct IncomingTemplate<'a> {
title: &'a str,
page: ActivePage,
- callsign: String,
+ conf: config::Config,
}
async fn incoming(State(state): State<SharedState>) -> IncomingTemplate<'static> {
IncomingTemplate {
title: "Incoming",
- callsign: state.conf.callsign.clone(),
+ conf: state.lock().unwrap().conf.clone(),
page: ActivePage::Incoming,
}
}
@@ -117,13 +118,13 @@ async fn incoming(State(state): State<SharedState>) -> IncomingTemplate<'static>
struct SendTemplate<'a> {
title: &'a str,
page: ActivePage,
- callsign: String,
+ conf: config::Config,
}
async fn send(State(state): State<SharedState>) -> SendTemplate<'static> {
SendTemplate {
title: "Send",
- callsign: state.conf.callsign.clone(),
+ conf: state.lock().unwrap().conf.clone(),
page: ActivePage::Send,
}
}
@@ -133,19 +134,122 @@ async fn send(State(state): State<SharedState>) -> SendTemplate<'static> {
struct SettingsTemplate<'a> {
title: &'a str,
page: ActivePage,
- callsign: String,
conf: config::Config,
}
async fn show_settings(State(state): State<SharedState>) -> SettingsTemplate<'static> {
SettingsTemplate {
title: "Settings",
- callsign: state.conf.callsign.clone(),
page: ActivePage::Settings,
- conf: state.conf.clone(),
+ conf: state.lock().unwrap().conf.clone(),
+ }
+}
+
+#[derive(Deserialize, Debug)]
+struct FormConfig {
+ callsign: String,
+ ssid: String,
+ icon: String,
+
+ // felinet
+ // felinet_enabled is either "on" or absent.
+ // According to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/checkbox
+ // "If the value attribute was omitted, the default value for the checkbox is `on` [...]"
+ felinet_enabled: Option<String>,
+ address: String,
+
+ // beacon
+ period_seconds: config::DurationSeconds,
+ max_hops: u8,
+ latitude: String,
+ longitude: String,
+ altitude: String,
+ comment: String,
+ antenna_height: String,
+ antenna_gain: String,
+ tx_power: String,
+
+ // tunnel
+ tunnel_enabled: Option<String>,
+ local_ip: String,
+ netmask: String,
+}
+
+fn empty_string_to_none<T: FromStr + Sync>(value: &str) -> Result<Option<T>, T::Err> {
+ if value == "" {
+ Ok(None)
+ }
+ else {
+ Ok(Some(value.parse()?))
}
}
-async fn post_settings(Form(input): Form<config::Config>) {
- dbg!(&input);
+impl TryFrom<FormConfig> for config::Config {
+ type Error = anyhow::Error;
+
+ fn try_from(value: FormConfig) -> Result<Self, Self::Error> {
+ Ok(config::Config {
+ callsign: value.callsign,
+ ssid: value.ssid.parse()?,
+ icon: value.icon.parse()?,
+ felinet: config::FelinetConfig {
+ enabled: value.felinet_enabled.is_some(),
+ address: value.address,
+ },
+ beacon: config::BeaconConfig {
+ period_seconds: value.period_seconds,
+ max_hops: value.max_hops,
+ latitude: empty_string_to_none(&value.latitude)?,
+ longitude: empty_string_to_none(&value.longitude)?,
+ altitude: empty_string_to_none(&value.altitude)?,
+ comment: empty_string_to_none(&value.comment)?,
+ antenna_height: empty_string_to_none(&value.antenna_height)?,
+ antenna_gain: empty_string_to_none(&value.antenna_gain)?,
+ tx_power: empty_string_to_none(&value.tx_power)?,
+ },
+ tunnel: config::TunnelConfig {
+ enabled: value.tunnel_enabled.is_some(),
+ local_ip: value.local_ip,
+ netmask: value.netmask,
+ },
+ })
+ }
+}
+
+async fn post_settings(State(state): State<SharedState>, Form(input): Form<FormConfig>) -> (StatusCode, Html<String>) {
+ match config::Config::try_from(input) {
+ Ok(c) => {
+ match c.store() {
+ Ok(()) => {
+ state.lock().unwrap().conf.clone_from(&c);
+
+ (StatusCode::OK, Html(
+ r#"<!doctype html>
+ <html><head></head><body>
+ <p>Configuration updated</p>
+ <p>To <a href="/">dashboard</a></p>
+ </body></html>"#.to_owned()))
+ }
+ Err(e) => {
+ (StatusCode::INTERNAL_SERVER_ERROR, Html(
+ format!(r#"<!doctype html>
+ <html><head></head>
+ <body><p>Internal Server Error: Could not write config</p>
+ <p>{}</p>
+ </body>
+ </html>"#, e)))
+ },
+ }
+
+ },
+ Err(e) => {
+ (StatusCode::BAD_REQUEST, Html(
+ format!(r#"<!doctype html>
+ <html><head></head>
+ <body><p>Error interpreting POST data</p>
+ <p>{}</p>
+ </body>
+ </html>"#, e)))
+ },
+ }
}
diff --git a/static/style.css b/static/style.css
index 8fbb42d..133246e 100644
--- a/static/style.css
+++ b/static/style.css
@@ -1 +1 @@
-/*! tailwindcss v3.3.5 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }html{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));font-family:sans-serif}.m-2{margin:.5rem}.flex{display:flex}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-60{width:15rem}.w-8{width:2rem}.flex-auto{flex:1 1 auto}.flex-none{flex:none}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px*var(--tw-divide-y-reverse))}.divide-sky-300>:not([hidden])~:not([hidden]){--tw-divide-opacity:1;border-color:rgb(125 211 252/var(--tw-divide-opacity))}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.bg-sky-100{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.bg-sky-200{--tw-bg-opacity:1;background-color:rgb(186 230 253/var(--tw-bg-opacity))}.bg-sky-300{--tw-bg-opacity:1;background-color:rgb(125 211 252/var(--tw-bg-opacity))}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.pb-4{padding-bottom:1rem}.pt-2{padding-top:.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-semibold{font-weight:600}.text-sky-800{--tw-text-opacity:1;color:rgb(7 89 133/var(--tw-text-opacity))}.text-sky-900{--tw-text-opacity:1;color:rgb(12 74 110/var(--tw-text-opacity))}h1{font-size:1.125rem;line-height:1.75rem}h1,h2{font-weight:700}.btn{margin-top:.25rem;margin-bottom:.25rem;border-radius:.25rem;padding:.25rem .5rem;font-weight:700;--tw-bg-opacity:1;background-color:rgb(14 165 233/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.btn:hover{--tw-bg-opacity:1;background-color:rgb(2 132 199/var(--tw-bg-opacity))}.textinput{border-radius:.375rem;border-width:2px;--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity));padding:.25rem;font-size:.875rem;line-height:1.25rem;font-weight:400;--tw-text-opacity:1;color:rgb(63 63 70/var(--tw-text-opacity));outline-style:solid;outline-width:0}.textinput:focus{border-width:2px;--tw-border-opacity:1;border-color:rgb(113 113 122/var(--tw-border-opacity));outline-width:0}.textinput:disabled{border-width:0;--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity))}.hover\:bg-sky-300:hover{--tw-bg-opacity:1;background-color:rgb(125 211 252/var(--tw-bg-opacity))} \ No newline at end of file
+/*! tailwindcss v3.3.5 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }html{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));font-family:sans-serif}.m-2{margin:.5rem}.flex{display:flex}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-60{width:15rem}.w-8{width:2rem}.flex-auto{flex:1 1 auto}.flex-none{flex:none}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px*var(--tw-divide-y-reverse))}.divide-sky-300>:not([hidden])~:not([hidden]){--tw-divide-opacity:1;border-color:rgb(125 211 252/var(--tw-divide-opacity))}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.bg-sky-100{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.bg-sky-200{--tw-bg-opacity:1;background-color:rgb(186 230 253/var(--tw-bg-opacity))}.bg-sky-300{--tw-bg-opacity:1;background-color:rgb(125 211 252/var(--tw-bg-opacity))}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.pb-4{padding-bottom:1rem}.pt-2{padding-top:.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-semibold{font-weight:600}.text-sky-800{--tw-text-opacity:1;color:rgb(7 89 133/var(--tw-text-opacity))}.text-sky-900{--tw-text-opacity:1;color:rgb(12 74 110/var(--tw-text-opacity))}h1{font-size:1.125rem;line-height:1.75rem}h1,h2{font-weight:700}fieldset{margin:.5rem;border-radius:.375rem;padding:.5rem;font-weight:400;--tw-text-opacity:1;color:rgb(3 105 161/var(--tw-text-opacity));outline-style:solid;outline-color:#3b82f61a}fieldset:hover{outline-color:#3b82f64d}legend{padding:.25rem;font-variant:small-caps}label{padding:.5rem}input,label{margin:.25rem}.btn{margin-top:.25rem;margin-bottom:.25rem;border-radius:.25rem;padding:.25rem .5rem;font-weight:700;--tw-bg-opacity:1;background-color:rgb(14 165 233/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.btn:hover{--tw-bg-opacity:1;background-color:rgb(2 132 199/var(--tw-bg-opacity))}.textinput{border-radius:.375rem;border-width:2px;--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity));padding:.25rem;font-size:.875rem;line-height:1.25rem;font-weight:400;--tw-text-opacity:1;color:rgb(3 105 161/var(--tw-text-opacity));outline-style:solid;outline-width:0}.textinput:focus{border-width:2px;--tw-border-opacity:1;border-color:rgb(113 113 122/var(--tw-border-opacity));outline-width:0}.textinput:disabled{border-width:0;--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity))}.hover\:bg-sky-300:hover{--tw-bg-opacity:1;background-color:rgb(125 211 252/var(--tw-bg-opacity))} \ No newline at end of file
diff --git a/style.css b/style.css
index 4c952e0..776dddb 100644
--- a/style.css
+++ b/style.css
@@ -16,12 +16,30 @@ h2 {
@apply font-bold;
}
+fieldset {
+ @apply rounded-md m-2 p-2 font-normal text-sky-700;
+ @apply outline outline-blue-500/10 hover:outline-blue-500/30
+}
+
+legend {
+ @apply p-1;
+ font-variant: small-caps;
+}
+
+label {
+ @apply p-2 m-1;
+}
+
+input {
+ @apply m-1;
+}
+
.btn {
@apply font-bold py-1 px-2 my-1 rounded;
@apply bg-sky-500 hover:bg-sky-600 text-white;
}
.textinput {
- @apply rounded-md border border-2 border-zinc-200 px-1 py-1 text-sm font-normal text-zinc-700 outline outline-0 focus:border-2 focus:border-zinc-500 focus:outline-0 disabled:border-0 disabled:bg-zinc-50;
+ @apply rounded-md border border-2 border-zinc-200 px-1 py-1 text-sm font-normal text-sky-700 outline outline-0 focus:border-2 focus:border-zinc-500 focus:outline-0 disabled:border-0 disabled:bg-zinc-50;
}
diff --git a/templates/head.html b/templates/head.html
index f1c4a8a..063cb8e 100644
--- a/templates/head.html
+++ b/templates/head.html
@@ -14,7 +14,7 @@
<div class="h-full min-h-screen p-3 space-y-2 w-60 bg-sky-100 text-sky-800">
<div class="p-3 rounded-lg space-y-2 bg-sky-300 text-sky-900">
<p class="text-lg">CATS Radio Node</p>
- <p class="text-lg font-semibold">{{ callsign }}</p>
+ <p class="text-lg font-semibold">{{ conf.callsign }}</p>
</div>
<div class="divide-y divide-sky-300">
diff --git a/templates/settings.html b/templates/settings.html
index f86c43b..545a199 100644
--- a/templates/settings.html
+++ b/templates/settings.html
@@ -3,9 +3,57 @@
<h1>Node Settings</h1>
<form action="/settings" method="post">
- <div><label for="callsign">Callsign: <input class="textinput" type="text" name="callsign" value="{{ conf.callsign }}"></label></div>
- <div><label for="ssid">SSID: <input class="textinput" type="number" name="ssid" value="{{ conf.ssid }}"></label></div>
- <div><label for="icon">Icon: <input class="textinput" type="number" name="icon" value="{{ conf.icon }}"></label></div>
+ <fieldset>
+ <legend>General</legend>
+ <div><label for="callsign">Callsign:</label><input class="textinput" type="text" name="callsign" value="{{ conf.callsign }}"></div>
+ <div><label for="ssid">SSID:</label><input class="textinput" type="number" name="ssid" value="{{ conf.ssid }}"></div>
+ <div><label for="icon">Icon:</label><input class="textinput" type="number" name="icon" value="{{ conf.icon }}"></div>
+ </fieldset>
+ <fieldset>
+ <legend>FELINET</legend>
+ <div><label for="felinet_enabled">Enabled:</label><input type="checkbox" name="felinet_enabled" {% if conf.felinet.enabled %} checked {% endif %}></div>
+ <div><label for="address">Address:</label><input class="textinput" type="text" name="address" value="{{ conf.felinet.address }}"></div>
+ </fieldset>
+ <fieldset>
+ <legend>IGate Beacon</legend>
+ <div><label for="period_seconds">Period [s]:</label><input class="textinput" type="number" name="period_seconds" value="{{ conf.beacon.period_seconds }}"></div>
+ <div><label for="max_hops">Max hops:</label><input class="textinput" type="number" name="max_hops" value="{{ conf.beacon.max_hops }}"></div>
+ <div><label for="latitude">Latitude:</label>
+ <input class="textinput" type="text" name="latitude"
+ value="{% match conf.beacon.latitude %}{% when Some with (val) %}{{ val }}{% when None %}{% endmatch %}">
+ </div>
+ <div><label for="longitude">Longitude:</label>
+ <input class="textinput" type="text" name="longitude"
+ value="{% match conf.beacon.longitude %}{% when Some with (val) %}{{ val }}{% when None %}{% endmatch %}">
+ </div>
+ <div><label for="altitude">Altitude:</label>
+ <input class="textinput" type="text" name="altitude"
+ value="{% match conf.beacon.altitude %}{% when Some with (val) %}{{ val }}{% when None %}{% endmatch %}">
+ </div>
+ <div><label for="comment">Comment:</label>
+ <input class="textinput" type="text" name="comment"
+ value="{% match conf.beacon.comment %}{% when Some with (val) %}{{ val }}{% when None %}{% endmatch %}">
+ </div>
+ <div><label for="antenna_height">Ant height:</label>
+ <input class="textinput" type="text" name="antenna_height"
+ value="{% match conf.beacon.antenna_height %}{% when Some with (val) %}{{ val }}{% when None %}{% endmatch %}">
+ </div>
+ <div><label for="antenna_gain">Ant gain:</label>
+ <input class="textinput" type="text" name="antenna_gain"
+ value="{% match conf.beacon.antenna_gain %}{% when Some with (val) %}{{ val }}{% when None %}{% endmatch %}">
+ </div>
+ <div><label for="tx_power">TX power [dBm]:</label>
+ <input class="textinput" type="text" name="tx_power"
+ value="{% match conf.beacon.tx_power %}{% when Some with (val) %}{{ val }}{% when None %}{% endmatch %}">
+ </div>
+ </fieldset>
+ <fieldset>
+ <legend>IP Tunnel</legend>
+ <div><label for="tunnel_enabled">Enabled:</label><input type="checkbox" name="tunnel_enabled" {% if conf.tunnel.enabled %} checked {% endif %}></div>
+ <div><label for="local_ip">Local IP:</label><input class="textinput" type="text" name="local_ip" value="{{ conf.tunnel.local_ip }}"></div>
+ <div><label for="netmask">Netmask:</label><input class="textinput" type="text" name="netmask" value="{{ conf.tunnel.netmask }}"></div>
+ </fieldset>
+
<div><input class="btn" type="submit" value="Update"></div>
</form>
</div>