aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--src/bin/fake-radio.rs4
-rw-r--r--src/db.rs2
-rw-r--r--src/main.rs30
-rw-r--r--src/ui.rs51
-rw-r--r--static/chat.js102
-rw-r--r--static/send.js49
-rw-r--r--static/strftime.js106
-rw-r--r--static/style.css2
-rw-r--r--templates/chat.html27
-rw-r--r--templates/head.html2
11 files changed, 334 insertions, 44 deletions
diff --git a/README.md b/README.md
index 8ce266c..19c6b8a 100644
--- a/README.md
+++ b/README.md
@@ -15,12 +15,11 @@ This project contains a web user interface for controlling a
Configuration read/write through UI is done.
RF4463 integration, message decoding and presentation, UI to send messages.
Tunnel IP packets through Arbitrary whiskers, using TUN.
+Live update of incoming packets using WebSocket, in the 'Chat' window.
### TODO:
* Nicer UI for presenting incoming packets. For now it just shows the Comment whisker.
-* Live update of incoming packets using WebSocket.
-* A 'chat' page that works better to actually chat with another node.
* igate integration
## Additional tools
diff --git a/src/bin/fake-radio.rs b/src/bin/fake-radio.rs
index 6747937..f27b7d6 100644
--- a/src/bin/fake-radio.rs
+++ b/src/bin/fake-radio.rs
@@ -80,6 +80,10 @@ fn receive_loop() {
eprintln!(" Ident {}-{}", ident.callsign, ident.ssid);
}
+ for dest in packet.destination_iter() {
+ eprintln!(" TO {}-{}", dest.callsign(), dest.ssid());
+ }
+
if let Some(gps) = packet.gps() {
eprintln!(" GPS {} {}", gps.latitude(), gps.longitude());
}
diff --git a/src/db.rs b/src/db.rs
index 2e07792..68455b3 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -103,7 +103,7 @@ impl Database {
SELECT id, received_at, content
FROM frames_received
WHERE received_at > ?1
- ORDER BY received_at DESC"#)
+ ORDER BY received_at"#)
.bind(unix_timestamp)
.fetch_all(&self.pool)
.await?;
diff --git a/src/main.rs b/src/main.rs
index 5eb47e8..35d7d65 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -24,7 +24,10 @@ const TUN_MTU : usize = 255;
#[tokio::main]
async fn main() -> std::io::Result<()> {
- simple_logger::SimpleLogger::new().env().init().unwrap();
+ simple_logger::SimpleLogger::new()
+ .with_level(log::LevelFilter::Debug)
+ .env()
+ .init().unwrap();
let conf = config::Config::load().expect("Could not load config");
@@ -125,18 +128,21 @@ async fn main() -> std::io::Result<()> {
if let Some(ident) = packet.identification() {
debug!(" From {}-{}", ident.callsign, ident.ssid);
- let mut commentbuf = [0u8, 255];
- if let Ok(comment) = packet.comment(&mut commentbuf) {
- let m = ui::UIPacket {
- received_at: chrono::Utc::now(),
- from_callsign: ident.callsign.to_string(),
- from_ssid: ident.ssid,
- comment: Some(comment.to_owned())
- };
- match ws_broadcast.send(m) {
- Ok(num) => debug!("Send WS message to {num}"),
- Err(_) => debug!("No WS receivers currently"),
+ let mut commentbuf = [0u8; 255];
+ match packet.comment(&mut commentbuf) {
+ Ok(comment) => {
+ let m = ui::UIPacket {
+ received_at: chrono::Utc::now(),
+ from_callsign: ident.callsign.to_string(),
+ from_ssid: ident.ssid,
+ comment: Some(comment.to_owned())
+ };
+ match ws_broadcast.send(m) {
+ Ok(num) => debug!("Send WS message to {num}"),
+ Err(_) => debug!("No WS receivers currently"),
+ }
}
+ Err(e) => warn!("Decode packet comment error: {e}"),
}
}
diff --git a/src/ui.rs b/src/ui.rs
index 5a5e322..7aa7773 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -41,7 +41,9 @@ pub async fn serve(port: u16, shared_state: SharedState) {
.with_state(shared_state);
let listener = tokio::net::TcpListener::bind(("0.0.0.0", port)).await.unwrap();
- axum::serve(listener, app).await.unwrap()
+ axum::serve(listener,
+ app.into_make_service_with_connect_info::<SocketAddr>())
+ .await.unwrap()
}
#[derive(PartialEq)]
@@ -58,8 +60,8 @@ impl ActivePage {
fn styles(&self) -> Vec<&'static str> {
match self {
ActivePage::Dashboard => vec![],
- ActivePage::Chat => vec!["chat.js"],
- ActivePage::Send => vec!["send.js"],
+ ActivePage::Chat => vec!["chat.js", "main.js", "strftime.js"],
+ ActivePage::Send => vec!["send.js", "main.js", "strftime.js"],
ActivePage::Settings => vec![],
ActivePage::None => vec![],
}
@@ -208,7 +210,7 @@ async fn handle_socket(
mut socket: WebSocket,
mut rx: tokio::sync::broadcast::Receiver<UIPacket>,
who: SocketAddr) {
- if socket.send(Message::Ping(vec![1, 2, 3])).await.is_ok() {
+ if socket.send(Message::Ping(vec![1])).await.is_ok() {
info!("Pinged {who}...");
} else {
info!("Could not ping {who}!");
@@ -218,13 +220,17 @@ async fn handle_socket(
let mut send_task = tokio::spawn(async move {
while let Ok(m) = rx.recv().await {
- if let Ok(m_json) = serde_json::to_string(&m) {
- if sender
+ debug!("Sending {:?} to {who}", m.comment);
+ match serde_json::to_string(&m) {
+ Ok(m_json) => if sender
.send(Message::Text(m_json))
- .await
- .is_err()
+ .await
+ .is_err()
{
return;
+ },
+ Err(e) => {
+ warn!("Could not convert message to json: {e}");
}
}
}
@@ -343,22 +349,41 @@ fn build_packet(config: config::Config, payload: ApiSendPacket) -> anyhow::Resul
}
async fn post_packet(State(state): State<SharedState>, Json(payload): Json<ApiSendPacket>) -> StatusCode {
- let (config, transmit_queue) = {
+ let (config, transmit_queue, mut db, ws_broadcast) = {
let s = state.lock().unwrap();
- (s.conf.clone(), s.transmit_queue.clone())
+ (s.conf.clone(), s.transmit_queue.clone(), s.db.clone(), s.ws_broadcast.clone())
};
info!("send_packet {:?}", payload);
+ let m = UIPacket {
+ received_at: chrono::Utc::now(),
+ from_callsign: config.callsign.to_string(),
+ from_ssid: config.ssid,
+ comment: payload.comment.clone(),
+ };
+
match build_packet(config, payload) {
Ok(p) => {
info!("Built packet of {} bytes", p.len());
- match transmit_queue.send(p).await {
- Ok(()) => StatusCode::OK,
+
+ match ws_broadcast.send(m) {
+ Ok(num) => debug!("Send own WS message to {num}"),
+ Err(_) => debug!("No WS receivers currently"),
+ }
+
+ match transmit_queue.send(p.clone()).await {
+ Ok(()) => {
+ if let Err(e) = db.store_packet(&p[2..]).await {
+ warn!("Failed to write outgoing packet to sqlite: {}", e);
+ }
+
+ StatusCode::OK
+ },
Err(_) => StatusCode::BAD_REQUEST,
}
},
- Err(_) =>StatusCode::INTERNAL_SERVER_ERROR,
+ Err(_) => StatusCode::INTERNAL_SERVER_ERROR,
}
}
diff --git a/static/chat.js b/static/chat.js
new file mode 100644
index 0000000..00c4d4e
--- /dev/null
+++ b/static/chat.js
@@ -0,0 +1,102 @@
+var socket = null;
+var retry_scheduled = false;
+
+function init_socket() {
+
+ retry_scheduled = false;
+
+ if (socket !== null) {
+ socket.onmessage = null;
+ socket.onopen = null;
+ socket.onclose = null;
+ socket.onerror = null;
+
+ delete socket;
+ }
+
+ socket = new WebSocket("ws://" + window.location.host + "/chat/ws");
+
+ socket.onmessage = function(data) {
+ const message = JSON.parse(data.data)
+ add_message(message);
+ }
+
+ socket.onopen = function(_data) {
+ console.log("Websocket open");
+ }
+
+ socket.onclose = function(_code, text) {
+ if (!retry_scheduled) {
+ console.log(`Websocket closed ${text}`);
+ retry_scheduled = true;
+ init_socket();
+ }
+ }
+
+ socket.onerror = function(e) {
+ if (!retry_scheduled) {
+ console.log(`Websocket error because ${e}. Trying again in 3s`);
+ retry_scheduled = true;
+ setTimeout(init_socket, 3000);
+ }
+ }
+}
+
+function keep_alive() {
+ if (socket !== null && socket.readyState == 1) {
+ try {
+ socket.send('{}');
+ } catch (e) {
+ }
+ }
+
+ setTimeout(keep_alive, 10000);
+}
+
+function add_message(message) {
+ let template = document.getElementById('message_template');
+ let clon = template.content.cloneNode(true);
+
+ const msg_timestamp = clon.querySelector("div.msg_timestamp");
+ const ts = strftime("%Y-%m-%d %H:%M:%S", new Date(message.received_at * 1000));
+ msg_timestamp.textContent = `${ts} UTC`;
+
+ const msg_from = clon.querySelector("div.msg_from");
+ msg_from.textContent = `${message.from_callsign}-${message.from_ssid}`;
+
+ const msg_comment = clon.querySelector("div.msg_comment");
+ msg_comment.textContent = message.comment;
+
+ const messagelist = document.getElementById('messagelist');
+ messagelist.appendChild(clon);
+ messagelist.scrollTo(0, messagelist.scrollHeight);
+}
+
+function call_clicked(element_clicked) {
+ let call_ssid = element_clicked.textContent;
+ document.getElementById('dest').value = call_ssid;
+}
+
+async function btn_chat_send_message() {
+ let data = {
+ 'comment': document.getElementById('whisker_comment').value,
+ 'destinations': [],
+ };
+
+ let callsign_ssid = document.getElementById('dest').value;
+ if (callsign_ssid !== "") {
+ let splitted = callsign_ssid.split("-");
+ let ssid = 0;
+ if (splitted.length == 2) {
+ ssid = parseInt(splitted[1], 10);
+ }
+ data.destinations.push({'callsign': splitted[0], 'ssid': ssid});
+ }
+ await post('/api/send_packet', data);
+}
+
+window.addEventListener("load", (_event) => {
+ init_socket();
+ keep_alive();
+});
+
diff --git a/static/send.js b/static/send.js
new file mode 100644
index 0000000..33585ea
--- /dev/null
+++ b/static/send.js
@@ -0,0 +1,49 @@
+async function btn_send_add_destination() {
+ const template = document.getElementById('destination_template');
+
+ let clon = template.content.cloneNode(true);
+ document.getElementById('destinations').appendChild(clon);
+}
+
+async function btn_send_remove_destination(element_clicked) {
+ element_clicked.parentElement.remove()
+}
+
+async function btn_send_send() {
+ let data = {
+ 'comment': null,
+ //'simplex': null,
+ 'destinations': [],
+ };
+
+ if (document.getElementById('with_comment').checked) {
+ data.comment = document.getElementById('whisker_comment').value;
+ }
+
+ /* not yet implemented in ham-cats
+ if (document.getElementById('with_simplex').checked) {
+ const simplex_freq_MHz = parseInt(document.getElementById('simplex_mode').value, 10);
+ const mode_select = document.getElementById('simplex_mode')
+ const i = mode_select.selectedIndex;
+ const simplex_mode = mode_select.options[i].text;
+
+ data.simplex = {'frequency': simplex_freq_MHz * 1e6, 'mode': simplex_mode};
+ }
+ */
+
+ const destinations = document.getElementById('destinations');
+ const destList = destinations.querySelectorAll("p.destination");
+ for (let i = 0; i < destList.length; i++) {
+ const dest_callsign = destList[i].querySelector("input.dest_callsign").value;
+ const dest_ssid_str = destList[i].querySelector("input.dest_ssid").value;
+ const dest_ssid = parseInt(dest_ssid_str, 10);
+ if (dest_ssid < 0 || dest_ssid > 255) {
+ alert("SSID must be between 0 and 255");
+ return;
+ }
+ data.destinations.push({'callsign': dest_callsign, 'ssid': dest_ssid});
+ }
+
+ await post('/api/send_packet', data);
+}
+
diff --git a/static/strftime.js b/static/strftime.js
new file mode 100644
index 0000000..a081e2e
--- /dev/null
+++ b/static/strftime.js
@@ -0,0 +1,106 @@
+/* Port of strftime() by T. H. Doan (https://thdoan.github.io/strftime/)
+ *
+ * Day of year (%j) code based on Joe Orost's answer:
+ * http://stackoverflow.com/questions/8619879/javascript-calculate-the-day-of-the-year-1-366
+ *
+ * Week number (%V) code based on Taco van den Broek's prototype:
+ * http://techblog.procurios.nl/k/news/view/33796/14863/calculate-iso-8601-week-and-year-in-javascript.html
+ */
+function strftime(sFormat, date) {
+ if (typeof sFormat !== 'string') {
+ return '';
+ }
+
+ if (!(date instanceof Date)) {
+ date = new Date();
+ }
+
+ const nDay = date.getDay();
+ const nDate = date.getDate();
+ const nMonth = date.getMonth();
+ const nYear = date.getFullYear();
+ const nHour = date.getHours();
+ const nTime = date.getTime();
+ const aDays = [
+ 'Sunday',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
+ 'Saturday'
+ ];
+ const aMonths = [
+ 'January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ 'August',
+ 'September',
+ 'October',
+ 'November',
+ 'December'
+ ];
+ const aDayCount = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
+ const isLeapYear = () => (nYear % 4 === 0 && nYear % 100 !== 0) || nYear % 400 === 0;
+ const getThursday = () => {
+ const target = new Date(date);
+ target.setDate(nDate - ((nDay + 6) % 7) + 3);
+ return target;
+ };
+ const zeroPad = (nNum, nPad) => ((Math.pow(10, nPad) + nNum) + '').slice(1);
+
+ return sFormat.replace(/%[a-z]+\b/gi, (sMatch) => {
+ return (({
+ '%a': aDays[nDay].slice(0, 3),
+ '%A': aDays[nDay],
+ '%b': aMonths[nMonth].slice(0, 3),
+ '%B': aMonths[nMonth],
+ '%c': date.toUTCString().replace(',', ''),
+ '%C': Math.floor(nYear / 100),
+ '%d': zeroPad(nDate, 2),
+ '%e': nDate,
+ '%F': (new Date(nTime - (date.getTimezoneOffset() * 60000))).toISOString().slice(0, 10),
+ '%G': getThursday().getFullYear(),
+ '%g': (getThursday().getFullYear() + '').slice(2),
+ '%H': zeroPad(nHour, 2),
+ '%I': zeroPad((nHour + 11) % 12 + 1, 2),
+ '%j': zeroPad(aDayCount[nMonth] + nDate + ((nMonth > 1 && isLeapYear()) ? 1 : 0), 3),
+ '%k': nHour,
+ '%l': (nHour + 11) % 12 + 1,
+ '%m': zeroPad(nMonth + 1, 2),
+ '%n': nMonth + 1,
+ '%M': zeroPad(date.getMinutes(), 2),
+ '%p': (nHour < 12) ? 'AM' : 'PM',
+ '%P': (nHour < 12) ? 'am' : 'pm',
+ '%s': Math.round(nTime / 1000),
+ '%S': zeroPad(date.getSeconds(), 2),
+ '%u': nDay || 7,
+ '%V': (() => {
+ const target = getThursday();
+ const n1stThu = target.valueOf();
+ target.setMonth(0, 1);
+ const nJan1 = target.getDay();
+
+ if (nJan1 !== 4) {
+ target.setMonth(0, 1 + ((4 - nJan1) + 7) % 7);
+ }
+
+ return zeroPad(1 + Math.ceil((n1stThu - target) / 604800000), 2);
+ })(),
+ '%w': nDay,
+ '%x': date.toLocaleDateString(),
+ '%X': date.toLocaleTimeString(),
+ '%y': (nYear + '').slice(2),
+ '%Y': nYear,
+ '%z': date.toTimeString().replace(/.+GMT([+-]\d+).+/, '$1'),
+ '%Z': date.toTimeString().replace(/.+\((.+?)\)$/, '$1'),
+ '%Zs': new Intl.DateTimeFormat('default', {
+ timeZoneName: 'short',
+ }).formatToParts(date).find((oPart) => oPart.type === 'timeZoneName')?.value,
+ }[sMatch] || '') + '') || sMatch;
+ });
+}
diff --git a/static/style.css b/static/style.css
index eda120e..1c27020 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}.mt-1{margin-top:.25rem}.flex{display:flex}.h-12{height:3rem}.h-\[96\%\]{height:96%}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-60{width:15rem}.w-8{width:2rem}.w-full{width:100%}.flex-1{flex:1 1 0%}.flex-auto{flex:1 1 auto}.flex-none{flex:none}.grow{flex-grow:1}.grow-0{flex-grow:0}.flex-col{flex-direction:column}.gap-4{gap:1rem}.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}.border-l-2{border-left-width:2px}.border-sky-100{--tw-border-opacity:1;border-color:rgb(224 242 254/var(--tw-border-opacity))}.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-bold{font-weight:700}.font-semibold{font-weight:600}.font-thin{font-weight:100}.text-sky-400{--tw-text-opacity:1;color:rgb(56 189 248/var(--tw-text-opacity))}.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}div.content{padding:.25rem .5rem}div.content,div.section{margin-top:.25rem;margin-bottom:.25rem}div.section{padding-top:.25rem;padding-bottom:.25rem;border-top-width:2px;--tw-border-opacity:1;border-color:rgb(125 211 252/var(--tw-border-opacity))}.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
+/*! 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}.mt-1{margin-top:.25rem}.flex{display:flex}.h-16{height:4rem}.h-\[90vh\]{height:90vh}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-60{width:15rem}.w-8{width:2rem}.w-full{width:100%}.flex-1{flex:1 1 0%}.flex-auto{flex:1 1 auto}.flex-none{flex:none}.grow{flex-grow:1}.grow-0{flex-grow:0}.flex-col{flex-direction:column}.gap-2{gap:.5rem}.gap-4{gap:1rem}.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))}.overflow-scroll{overflow:scroll}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.border-l-2{border-left-width:2px}.border-sky-100{--tw-border-opacity:1;border-color:rgb(224 242 254/var(--tw-border-opacity))}.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}.text-sm{font-size:.875rem;line-height:1.25rem}.font-bold{font-weight:700}.font-semibold{font-weight:600}.font-thin{font-weight:100}.text-sky-400{--tw-text-opacity:1;color:rgb(56 189 248/var(--tw-text-opacity))}.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}div.content{padding:.25rem .5rem}div.content,div.section{margin-top:.25rem;margin-bottom:.25rem}div.section{padding-top:.25rem;padding-bottom:.25rem;border-top-width:2px;--tw-border-opacity:1;border-color:rgb(125 211 252/var(--tw-border-opacity))}.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/templates/chat.html b/templates/chat.html
index 8411b01..f68b1da 100644
--- a/templates/chat.html
+++ b/templates/chat.html
@@ -1,34 +1,33 @@
{% include "head.html" %}
<div class="content h-full">
<h1>Chat</h1>
- <div class="section h-[96%]">
+ <div class="section h-[90vh]">
<div class="m-2 h-full flex flex-col">
- <div class="flex-1 grow">
+ <div id="messagelist" class="flex-1 grow overflow-scroll">
<template id="message_template">
- <div class="p-2 m-2 border-l-1 border-sky-100">
- <div class="font-thin text-sky-400">Timestamp</div>
- <div class="font-bold text-sky-900">FROM</div>
- <div class="text-sky-800">Message</div>
+ <div class="p-2 border-l-2 border-sky-100 flex gap-4">
+ <div class="msg_timestamp flex-none font-thin text-sm text-sky-400">timestamp</div>
+ <div class="msg_from flex-none font-bold text-sky-900" onclick="call_clicked(this)">CALL-SSID</div>
+ <div class="msg_comment flex-1 text-sky-800">COMMENT</div>
</div>
</template>
{% for packet in packets %}
{% match packet.comment %}{% when Some with (comment) %}
<div class="p-2 border-l-2 border-sky-100 flex gap-4">
- <div class="flex-none font-thin text-sky-400">{{ packet.received_at_iso()|e }}</div>
- <div class="flex-none font-bold text-sky-900">{{ packet.from_callsign|e }}-{{ packet.from_ssid|e }}</div>
- <div class="flex-1 text-sky-800">{{ comment|e }}
- </div>
+ <div class="flex-none font-thin text-sm text-sky-400">{{ packet.received_at_iso()|e }}</div>
+ <div class="flex-none font-bold text-sky-900" onclick="call_clicked(this)">{{ packet.from_callsign|e }}-{{ packet.from_ssid|e }}</div>
+ <div class="flex-1 text-sky-800">{{ comment|e }}</div>
</div>
{% when None %}{% endmatch %}
{% endfor %}
</div>
- <div class="flex-none grow-0 h-12">
- <div class="flex">
+ <div class="m-2 flex-none grow-0 h-16">
+ <div class="flex gap-2">
<div class="flex-none">
- <label for="dest">Message for:</label><input class="textinput" type="text" name="dest" value="" placeholder="callsign-ssid">
+ <label for="dest">Message for:</label><input class="textinput" type="text" id="dest" value="" placeholder="callsign-ssid">
</div>
<div class="flex-1">
- <input class="textinput w-full" type="text" name="message" value="" placeholder="Type your message here">
+ <input class="textinput w-full" type="text" id="whisker_comment" value="" placeholder="Type your message here">
</div>
<div class="flex-none">
<button class="btn" type="button" onclick="btn_chat_send_message()">Send</button>
diff --git a/templates/head.html b/templates/head.html
index fd0afe4..aabc380 100644
--- a/templates/head.html
+++ b/templates/head.html
@@ -7,7 +7,7 @@
<link rel="stylesheet" href="/static/style.css" type="text/css">
<link rel="stylesheet" href="/static/font-awesome/css/font-awesome.min.css">
{% for js in page.styles() %}
- <script src="/static/{{ js }}.js" defer></script>
+ <script src="/static/{{ js }}" defer></script>
{% endfor %}
</head>
<body>