diff --git a/index.html b/index.html new file mode 100644 index 0000000..86991f9 --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ +Google
Search Images Maps Play YouTube News Gmail Drive More »
Web History | Settings | Sign in



 

Advanced search

Google offered in: Français

© 2024 - Privacy - Terms

\ No newline at end of file diff --git a/index.html.1 b/index.html.1 new file mode 100644 index 0000000..5efaa2c --- /dev/null +++ b/index.html.1 @@ -0,0 +1,14 @@ +Google
Search Images Maps Play YouTube News Gmail Drive More »
Web History | Settings | Sign in



 

Advanced search

Google offered in: Français

© 2024 - Privacy - Terms

\ No newline at end of file diff --git a/ui/general/assets/icons/drone-icon.svg b/ui/general/assets/icons/drone-icon.svg new file mode 100644 index 0000000..5f510a9 --- /dev/null +++ b/ui/general/assets/icons/drone-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/general/health.html b/ui/general/health.html index 86b6d5a..0b1403c 100644 --- a/ui/general/health.html +++ b/ui/general/health.html @@ -14,7 +14,61 @@

Health Status

-

At a glance view of the status of the drone.

+
+ At a glance view of the status of the drone. +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Drone +
IP Address
Docker Container
Connection Upstream
Network SSID
Camera Devices
Connected Devices
Zerotier IPN/A
Hotspot ConnectionsN/A
GCSN/A
FCU FirmwareN/A
+
diff --git a/ui/general/health.js b/ui/general/health.js index 8f3dacd..2bcea8f 100644 --- a/ui/general/health.js +++ b/ui/general/health.js @@ -1,9 +1,130 @@ +// Initialize Drone Table Elements +const droneName = document.getElementById("droneName"); +const ipAddress = document.getElementById("ipAddress"); +const dockerContainer = document.getElementById("dockerContainer"); +const connectionUpstream = document.getElementById("connectionUpstream"); +const networkSSID = document.getElementById("networkSSID"); +const cameraDevices = document.getElementById("cameraDevices"); +const connectedDevices = document.getElementById("connectedDevices"); -// Elements - -// Load initial settings +// Load page document.onload = initPage(); // Function to initialize the page function initPage() { -} + // Populate health table with: + // Drone Name + // Drone IP address + // Drone Docker Containers that are running + // Connection Upstream Status + // Network SSID + // Camera Devices List + // Connected Devices List + + // Below are the list of Commands used to acquire the information to populate the health table + // Name corresponds to host computer's name + const droneNameCommand = "hostname" + // Host Computer's IP + const ipAddressCommand = "hostname -I" + // List of all Docker Container IDs + const dockerContainerCommand = "docker container ls" + // Ping Google to check upstream connection + const connectionUpstreamCommand = "ping google.com -c 1" + // SSID of the network the Drone is connected to + const networkSSIDCommand = "iwgetid -r" + // Camera devices are those listed by /dev/video* + const cameraDevicesCommand = "ls /dev/video*" + // Connected Devices are those listed under /dev/bus/usb + const connectedDevicesCommand = "lsusb" + + // Extract the Drone Name from console output and insert it into the table + cockpit.spawn(["bash", "-c", droneNameCommand]) + .then((data) => { + droneName.innerHTML = data.split(" ")[0]; + }) + .catch((error) => console.log(error)); + + // Extract the IP Address from console output and insert it into the table + cockpit.spawn(["bash", "-c", ipAddressCommand]) + .then((data) => { + ipAddress.innerHTML = data.split(" ")[0]; + }) + .catch((error) => console.log(error)); + + // Extract the Docker Container IDs from console output and insert it into the table + cockpit.spawn(["bash", "-c", dockerContainerCommand]) + .then((data) => { + const datalist = data.split("\n"); + // If no Docker Containers up + if (datalist[1].split(" ")[0] == ""){ + dockerContainer.className = "p-3 mb-2 bg-danger text-white"; + dockerContainer.innerHTML += "Error: No Docker Containers to Display"; + } else { + // List each container on a new line + for (let i = 0; i < datalist.length - 2; i++) { + dockerContainer.innerHTML += datalist[i + 1].split(" ")[0]; + dockerContainer.innerHTML += "
"; + } + dockerContainer.innerHTML += datalist[datalist.length - 1].split(" ")[0]; + } + }) + .catch((error) => console.log(error)); + + // Extract the Connection Upstream Status from console output and insert it into the table + cockpit.spawn(["bash", "-c", connectionUpstreamCommand]) + .then((data) => { + const datalist = data.split(" "); + // If error no upstream returned + if (datalist[0] == "ping:") {connectionUpstream.innerHTML = "Connection LIMITED - No upstream";} + // If ping succeeded + else if (datalist[0] == "PING") {connectionUpstream.innerHTML = "Connection OK";} + // If some other output returned + else {connectionUpstream.innerHTML = "Connection DOWN";} + }) + .catch((error) => console.log(error)); + + // Extract the Network SSID from console output and insert it into the table + cockpit.spawn(["bash", "-c", networkSSIDCommand]) + .then((data) => { + if (data.length == 0) { + networkSSID.innerHTML = "None"; + } else { + networkSSID.innerHTML = data + } + }) + .catch((error) => console.log(error)); + + // Extract the Camera Devices from console output and insert it into the table + cockpit.spawn(["bash", "-c", cameraDevicesCommand]) + .then((data) => { + // If no devices detected + if (data.length == 0) {cameraDevices.innerHTML = "No Camera Devices Detected";} + // Otherwise print the list of Camera Devices + else { + const datalist = data.replaceAll("\n", "
"); + cameraDevices.innerHTML += datalist; + } + }) + .catch((error) => console.log(error)); + + // Extract the Connected Devices List from console output and insert it into the table + cockpit.spawn(["bash", "-c", connectedDevicesCommand]) + .then((data) => { + const datalist = data.split("\n"); + // If no devices listed + if (data.length == 0) {connectedDevices.innerHTML = "No devices detected";} + // Otherwise, list each device by name and path + for (let i = 0; i < datalist.length - 1; i++) { + const name = datalist[i].split(" "); + for (let j = 6; j < name.length; j++) { + connectedDevices.innerHTML += name[j] + " "; + } + connectedDevices.innerHTML += "
"; + connectedDevices.innerHTML += "/dev/bus/usb/" + name[1] + "/" + name[3].replace(":", ""); + if (i != datalist.length - 2) { + connectedDevices.innerHTML += "

"; + } + } + }) + .catch((error) => console.log(error)); +} \ No newline at end of file