From d04c1bd2c5f63e407acd77ce0d202e6013e36132 Mon Sep 17 00:00:00 2001 From: Alice Sedgwick Date: Mon, 18 Nov 2024 15:51:17 -0500 Subject: [PATCH] Youssof explained a dropdown --- ui/general/assets/icons/drone-icon.svg | 2 +- ui/general/health.html | 69 ++------------------------ ui/general/health.js | 42 +++------------- 3 files changed, 13 insertions(+), 100 deletions(-) diff --git a/ui/general/assets/icons/drone-icon.svg b/ui/general/assets/icons/drone-icon.svg index 6ab5781..5f510a9 100644 --- a/ui/general/assets/icons/drone-icon.svg +++ b/ui/general/assets/icons/drone-icon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/ui/general/health.html b/ui/general/health.html index e6656f8..94f52c9 100644 --- a/ui/general/health.html +++ b/ui/general/health.html @@ -7,9 +7,6 @@ - - - @@ -30,76 +27,20 @@ Select a Drone for Inspection
- - - +
- +
- +
- -
- diff --git a/ui/general/health.js b/ui/general/health.js index fd75152..a4c3115 100644 --- a/ui/general/health.js +++ b/ui/general/health.js @@ -1,6 +1,7 @@ // Elements const drone = document.getElementById("drone"); +const droneDropdown = document.getElementById("droneSelection"); const drones = [ ["1", "mu1"], ["2", "mu2"], ["3", "mu3"], @@ -10,26 +11,25 @@ const drones = [ // Load initial settings document.onload = initPage(); -document.getElementById("save").addEventListener("click", saveSettings); +droneDropdown.addEventListener("change", droneChange); -const dropdownElement = document.getElementById('dropdownMenuButton1'); -new bootstrap.Dropdown(dropdownElement); // Function to initialize the page function initPage() { // TODO: Replace /home/spiri/services with some root level path // Search for drones files in the services directory and populate the dropdown with directory names - const currentDrone = getValueByKey(content, "common", "drone"); - addDropDown(drone, drones, currentDrone); + addDropDown(droneDropdown, drones, "1"); } -function handleSelect(account) { +function droneChange() { + console.log(droneDropdown.value); + return ; var drone1Table = "
Drone1
"; var drone2Table = "
Drone2
"; var drone3Table = "
Drone3/td>
"; var drone4Table = "
Drone4
"; var drone5Table = "
Drone5
"; - switch(account) + switch(droneDropdown.value) { case "Drone1": document.getElementById("myTableContainer").innerHTML = drone1Table @@ -49,34 +49,6 @@ function handleSelect(account) { } } -// Save configuration values to the configuration file -function saveSettings() { - - try { - cockpit.file(confLocation) - .read() - .then((content) => { - // WiFi & Temperature Configuration - content = setValueByKey(content, "[common]", "drone_channel", drone_channel.value); - - cockpit.file(confLocation, { superuser: "try" }).replace(content) - .then(() => { - displayDroneTable(); - displaySuccess("table updated successfully."); - }) - .catch((error) => { - displayFail("Failed to update table: " + error.message); - }); - }) - .catch(error => { - displayFail("Failed to update table: " + error.message); - }); - } catch (e) { - console.error("Error during update operation:", e); - failureReadFile(e); - } -} - // Restart drone service function displayDroneTable() {