From 20553b472f439d22ae340083b72ba01d99aeb9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Numbus?= Date: Sun, 17 May 2026 15:12:32 +0200 Subject: [PATCH] Make the startDiscovery button work. --- .gitignore | 1 + script/deploy.sh | 4 +- web/logic/interactive.py | 3 - web/pages/preparation.html | 141 +++++++++++++++++-------------------- 4 files changed, 69 insertions(+), 80 deletions(-) diff --git a/.gitignore b/.gitignore index db879a2..c9470f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /config/ web/ux/ test* +example* .DS_Store .env \ No newline at end of file diff --git a/script/deploy.sh b/script/deploy.sh index 9257e85..413126a 100755 --- a/script/deploy.sh +++ b/script/deploy.sh @@ -776,8 +776,8 @@ hierarchy_preparation until [[ -e web/signals/hw_detection_ready ]]; do sleep 5 done -LIVE_TARGET_IP="$(yq -r '.live_target_ip' ${LIVE_DATA_FILE})" -LIVE_TARGET_PASSWORD="$(yq -r '.live_target_password' ${LIVE_DATA_FILE})" +LIVE_TARGET_IP="$(yq -r '.live_target.ip' ${LIVE_DATA_FILE})" +LIVE_TARGET_PASSWORD="$(yq -r '.live_target.password' ${LIVE_DATA_FILE})" until [[ -e web/signals/configuration_ready ]]; do sleep 5 done diff --git a/web/logic/interactive.py b/web/logic/interactive.py index 077844b..0abaf7b 100644 --- a/web/logic/interactive.py +++ b/web/logic/interactive.py @@ -44,9 +44,6 @@ class BridgeHandler(http.server.SimpleHTTPRequestHandler): post_data = self.rfile.read(content_length) if self.path == '/discovery': - # Store secrets in memory-backed filesystem - # We write to CONFIG_DIR so deploy.sh can find it easily - os.makedirs(CONFIG_DIR, exist_ok=True) with open(os.path.join(CONFIG_DIR, "live.yaml"), "wb") as f: f.write(post_data) self.send_response(200) diff --git a/web/pages/preparation.html b/web/pages/preparation.html index e5fe3c6..23ebddb 100644 --- a/web/pages/preparation.html +++ b/web/pages/preparation.html @@ -29,9 +29,8 @@ formData: { 1: { language: 'French', country: 'France', timeZone: 'Europe/Paris' }, 2: { deviceType: '' }, - 3: { deploymentMode: '' }, - 4: { replicationHardware: '', replicationStrategy: '', replicationSecrets: '' }, - 5: { liveIp: '', livePassword: '' }, + 3: { deploymentMode: '', gitUrl: '', gitUsername: '', gitPassword: '' }, + 4: { liveIp: '', livePassword: '' }, }, isStepValid() { const currentStepData = this.formData[this.step]; @@ -39,7 +38,7 @@ return Object.values(currentStepData).every(value => !!value); }, goToPrevStep() { - if (this.step === 5 && this.formData[3].deploymentMode === 'interactive') { + if (this.step === 4 && this.formData[3].deploymentMode === 'interactive') { this.step--; } this.step--; @@ -50,9 +49,46 @@ } this.step++; }, - startDiscovery() { - console.log("Discovery started with:", JSON.parse(JSON.stringify(this.formData))); - // Add your bridge communication logic here + async startDiscovery() { + const data = JSON.parse(JSON.stringify(this.formData)); + console.log("Discovery started with:", data); + + const payload = { + internationalisation: { + language: data[1].language, + country: data[1].country, + time_zone: data[1].timeZone + }, + device: { + type: data[2].deviceType + }, + deployment: { + mode: data[3].deploymentMode, + git_url: data[3].gitUrl || '', + git_username: data[3].gitUsername || '', + git_password: data[3].gitPassword || '' + }, + live_target: { + ip: data[4].liveIp, + password: data[4].livePassword + } + }; + + try { + const response = await fetch('/discovery', { + method: 'POST', + headers: { 'Content-Type': 'text/yaml' }, + body: jsyaml.dump(payload) + }); + + if (response.ok) { + console.log("Discovery signal sent successfully."); + } else { + console.error("Server returned an error:", response.statusText); + } + } catch (error) { + console.error("Network error during discovery:", error); + } } } } @@ -61,8 +97,8 @@ @@ -169,6 +205,9 @@ + + +
@@ -270,6 +309,9 @@
+ + +
@@ -325,81 +367,29 @@
+ + - -
-

Replication Mode

-
-

Select your preferred replication mode. It compares the current deployment to the old one.

-

Hardware

-
- - -
-

Strategy

-
- - -
-

Secrets

-
- - -
-
-
+

Live Setup

Provide the necessary information to connect to the device. It needs to be in a NixOS live environment.

Live Target IP Address - +
Temporary Password - +
+ + +
@@ -407,22 +397,23 @@
+