Added more comments
This commit is contained in:
parent
51715550c4
commit
1f6a41de44
|
@ -1,4 +1,4 @@
|
||||||
// Elements
|
// Initialize Drone Table Elements
|
||||||
const droneName = document.getElementById("droneName");
|
const droneName = document.getElementById("droneName");
|
||||||
const ipAddress = document.getElementById("ipAddress");
|
const ipAddress = document.getElementById("ipAddress");
|
||||||
const dockerContainer = document.getElementById("dockerContainer");
|
const dockerContainer = document.getElementById("dockerContainer");
|
||||||
|
@ -7,39 +7,51 @@ const networkSSID = document.getElementById("networkSSID");
|
||||||
const cameraDevices = document.getElementById("cameraDevices");
|
const cameraDevices = document.getElementById("cameraDevices");
|
||||||
const connectedDevices = document.getElementById("connectedDevices");
|
const connectedDevices = document.getElementById("connectedDevices");
|
||||||
|
|
||||||
// Load page + drone settings
|
// Load page
|
||||||
document.onload = initPage();
|
document.onload = initPage();
|
||||||
|
|
||||||
// Function to initialize the page
|
// Function to initialize the page
|
||||||
function initPage() {
|
function initPage() {
|
||||||
// Populate table with drone name, drone IP address, and drone docker containers that are running
|
// Populate health table with:
|
||||||
// Name corresponds to host computer's name, IP address is host computer's address
|
// Drone Name
|
||||||
// and docker containers are all those displayed by docker container ls
|
// Drone IP address
|
||||||
const droneNameCommand = "hostname"
|
// Drone Docker Containers that are running
|
||||||
const ipAddressCommand = "hostname -I"
|
// Connection Upstream Status
|
||||||
const dockerContainerCommand = "docker container ls"
|
// Network SSID
|
||||||
const connectionUpstreamCommand = "ping google.com -c 1"
|
// Camera Devices List
|
||||||
const networkSSIDCommand = "iwgetid -r"
|
// Connected Devices List
|
||||||
const cameraDevicesCommand = "ls /dev/video*"
|
|
||||||
|
|
||||||
// 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"
|
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])
|
cockpit.spawn(["bash", "-c", droneNameCommand])
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
droneName.innerHTML = data.split(" ")[0];
|
droneName.innerHTML = data.split(" ")[0];
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error));
|
.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])
|
cockpit.spawn(["bash", "-c", ipAddressCommand])
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
ipAddress.innerHTML = data.split(" ")[0];
|
ipAddress.innerHTML = data.split(" ")[0];
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error));
|
.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])
|
cockpit.spawn(["bash", "-c", dockerContainerCommand])
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
const datalist = data.split("\n");
|
const datalist = data.split("\n");
|
||||||
|
@ -58,7 +70,7 @@ function initPage() {
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error));
|
.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])
|
cockpit.spawn(["bash", "-c", connectionUpstreamCommand])
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
const datalist = data.split(" ");
|
const datalist = data.split(" ");
|
||||||
|
@ -71,7 +83,7 @@ function initPage() {
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error));
|
.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])
|
cockpit.spawn(["bash", "-c", networkSSIDCommand])
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.length == 0) {
|
if (data.length == 0) {
|
||||||
|
@ -82,7 +94,7 @@ function initPage() {
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error));
|
.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])
|
cockpit.spawn(["bash", "-c", cameraDevicesCommand])
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
// If no devices detected
|
// If no devices detected
|
||||||
|
@ -95,7 +107,7 @@ function initPage() {
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error));
|
.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])
|
cockpit.spawn(["bash", "-c", connectedDevicesCommand])
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
const datalist = data.split("\n");
|
const datalist = data.split("\n");
|
||||||
|
|
Loading…
Reference in New Issue