Force JS eval of window.location

We need to get the fqdn of machine running the app, otherwise the
frontend cannot access the api on the VOC VM
This commit is contained in:
q
2024-05-26 22:50:34 +01:00
parent 81ddd7152d
commit 6c8e5adb79
3 changed files with 8 additions and 1 deletions
+1
View File
@@ -1410,6 +1410,7 @@ dependencies = [
"env_logger",
"ewebsock",
"hrtime",
"js-sys",
"log",
"serde",
"serde_json",
+1
View File
@@ -10,6 +10,7 @@ eframe = { version = "0.27.0", default-features = false, features = [
"default_fonts", # Embed the default egui fonts.
"glow", # Use the glow rendering backend. Alternative: "wgpu".
] }
js-sys = "0.3.69"
log = "0.4"
serde = { version = "1", features = ["derive"] }
hrtime = "0.2.0"
+6 -1
View File
@@ -7,6 +7,7 @@ use std::{
use egui::{Button, Color32, RichText, Rounding, Sense, Stroke, Vec2};
use ewebsock::{Options, WsReceiver, WsSender};
use wasm_timer::Instant;
use js_sys::eval;
use crate::websocket::{
AddHyperdeckRequest, ClientRequest, HyperdeckConnectionState, HyperdeckRecordBay,
@@ -27,8 +28,12 @@ pub struct HyperdeckMonitorApp {
impl Default for HyperdeckMonitorApp {
fn default() -> Self {
// returns voc.emf.camp:9681/
let window_location = eval("window.location.host").unwrap().as_string().unwrap();
// returns ws://voc.emf.camp:9681
let api_websocket_location = format!("ws://{}ws", window_location);
let (ws_sender, ws_receiver) =
ewebsock::connect("ws://127.0.0.1:9681/ws", Options::default()).unwrap();
ewebsock::connect(api_websocket_location, Options::default()).unwrap();
Self {
blink: false,
last_blink_change: Instant::now(),