diff --git a/ui/general/health.js b/ui/general/health.js index 95cfc8f..2bcea8f 100644 --- a/ui/general/health.js +++ b/ui/general/health.js @@ -1,4 +1,4 @@ -// Elements +// Initialize Drone Table Elements const droneName = document.getElementById("droneName"); const ipAddress = document.getElementById("ipAddress"); const dockerContainer = document.getElementById("dockerContainer"); @@ -7,39 +7,51 @@ const networkSSID = document.getElementById("networkSSID"); const cameraDevices = document.getElementById("cameraDevices"); const connectedDevices = document.getElementById("connectedDevices"); -// Load page + drone settings +// Load page document.onload = initPage(); // Function to initialize the page function initPage() { - // Populate table with drone name, drone IP address, and drone docker containers that are running - // Name corresponds to host computer's name, IP address is host computer's address - // and docker containers are all those displayed by docker container ls - const droneNameCommand = "hostname" - const ipAddressCommand = "hostname -I" - const dockerContainerCommand = "docker container ls" - const connectionUpstreamCommand = "ping google.com -c 1" - const networkSSIDCommand = "iwgetid -r" - const cameraDevicesCommand = "ls /dev/video*" + // 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 - // Command for listing all Connected Devices + // 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 + // 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 + // 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 + // 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"); @@ -58,7 +70,7 @@ function initPage() { }) .catch((error) => console.log(error)); - // Extract the Connection Upstream Status from console output + // 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(" "); @@ -71,7 +83,7 @@ function initPage() { }) .catch((error) => console.log(error)); - // Extract the Network SSID from console output + // Extract the Network SSID from console output and insert it into the table cockpit.spawn(["bash", "-c", networkSSIDCommand]) .then((data) => { if (data.length == 0) { @@ -82,7 +94,7 @@ function initPage() { }) .catch((error) => console.log(error)); - // Extract the Camera Devices from console output + // Extract the Camera Devices from console output and insert it into the table cockpit.spawn(["bash", "-c", cameraDevicesCommand]) .then((data) => { // If no devices detected @@ -95,7 +107,7 @@ function initPage() { }) .catch((error) => console.log(error)); - // Extract the Connected Devices List from console output + // 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");