From 440f4c8fb56761a2aefdee2c59d5e016596d7da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Numbus?= Date: Sun, 17 May 2026 19:52:02 +0200 Subject: [PATCH] Update the logic to wait for the hardware detection data. --- script/deploy.sh | 12 ++++++++++-- web/logic/interactive.py | 7 +------ web/pages/preparation.html | 28 +++++++++++++++++++++++++--- web/signals/.gitignore | 0 4 files changed, 36 insertions(+), 11 deletions(-) delete mode 100644 web/signals/.gitignore diff --git a/script/deploy.sh b/script/deploy.sh index 413126a..ca9bbca 100755 --- a/script/deploy.sh +++ b/script/deploy.sh @@ -772,16 +772,24 @@ echo """ """ launch_gui -hierarchy_preparation -until [[ -e web/signals/hw_detection_ready ]]; do + +until [[ -e "${LIVE_DATA_FILE}" ]]; 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})" +DEVICE_TYPE="$(yq -r '.device.type' ${LIVE_DATA_FILE})" + +hardware_detection + until [[ -e web/signals/configuration_ready ]]; do sleep 5 done until [[ -e web/signals/deployment_ready ]]; do sleep 5 done + +hierarchy_preparation + # --- MAIN LOGIC ---< \ No newline at end of file diff --git a/web/logic/interactive.py b/web/logic/interactive.py index 0abaf7b..89e2c89 100644 --- a/web/logic/interactive.py +++ b/web/logic/interactive.py @@ -33,7 +33,7 @@ class BridgeHandler(http.server.SimpleHTTPRequestHandler): return # Restrict static file access to specific directories only - if not any(self.path.startswith(prefix) for prefix in ['/pages', '/media']): + if not any(self.path.startswith(prefix) for prefix in ['/pages', '/media', '/config']): self.send_error(403, "Access Denied: Resource is restricted.") return @@ -48,16 +48,11 @@ class BridgeHandler(http.server.SimpleHTTPRequestHandler): f.write(post_data) self.send_response(200) self.end_headers() - # Signal Bash that discovery data is ready and we can proceed to hardware detection - os.makedirs(SIGNALS_DIR, exist_ok=True) - with open(os.path.join(SIGNALS_DIR, "hw_detection_ready"), "w") as f: f.write("1") - with open(os.path.join(SIGNALS_DIR, "configuration_ready"), "w") as f: f.write("1") elif self.path == '/deploy': with open(os.path.join(CONFIG_DIR, "numbus.yaml"), "wb") as f: f.write(post_data) self.send_response(200) self.end_headers() - with open(os.path.join(SIGNALS_DIR, "deployment_ready"), "w") as f: f.write("1") http.server.HTTPServer(('localhost', 8088), BridgeHandler).serve_forever() \ No newline at end of file diff --git a/web/pages/preparation.html b/web/pages/preparation.html index c72a36c..a109f21 100644 --- a/web/pages/preparation.html +++ b/web/pages/preparation.html @@ -26,6 +26,7 @@ function numbusPreparation() { return { step: 1, + discoveryLoading: false, formData: { 1: { language: 'French', country: 'France', timeZone: 'Europe/Paris' }, 2: { deviceType: '' }, @@ -45,6 +46,9 @@ this.step++; }, async startDiscovery() { + if (this.discoveryLoading) return; + this.discoveryLoading = true; + const data = JSON.parse(JSON.stringify(this.formData)); console.log("Discovery started with:", data); @@ -78,12 +82,29 @@ if (response.ok) { console.log("Discovery signal sent successfully."); + this.pollHardwareResults(); } else { console.error("Server returned an error:", response.statusText); + this.discoveryLoading = false; } } catch (error) { console.error("Network error during discovery:", error); + this.discoveryLoading = false; } + }, + pollHardwareResults() { + // Poll every 2 seconds for the hardware detection results file + const interval = setInterval(async () => { + try { + const response = await fetch('/config/hardware.yaml', { cache: 'no-store' }); + if (response.ok) { + clearInterval(interval); + window.location.href = 'configuration.html'; + } + } catch (err) { + // Errors are expected until the file is actually created + } + }, 2000); } } } @@ -400,9 +421,10 @@ @click="startDiscovery()" x-show="step === 4" x-cloak - :disabled="!isStepValid()" - class="px-10 py-3 text-white font-bold rounded-xl scale-100 transition duration-200 ease-in bg-gradient-to-r from-fuchsia-500 via-fuchsia-600 to-fuchsia-700 hover:scale-105 hover:bg-gradient-to-br shadow-lg shadow-fuchsia-500/30 dark:shadow-lg dark:shadow-fuchsia-800/80 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100">Start Discovery - + diff --git a/web/signals/.gitignore b/web/signals/.gitignore deleted file mode 100644 index e69de29..0000000