2024-10-28 12:02:39 -03:00
|
|
|
// Elements
|
2024-11-24 18:23:45 -04:00
|
|
|
const droneName = document.getElementById("name");
|
|
|
|
const address = document.getElementById("address");
|
|
|
|
const container = document.getElementById("container");
|
2024-11-10 03:13:25 -04:00
|
|
|
|
2024-11-27 04:53:47 -04:00
|
|
|
// Load page + drone settings
|
2024-10-28 12:02:39 -03:00
|
|
|
document.onload = initPage();
|
|
|
|
|
|
|
|
// Function to initialize the page
|
|
|
|
function initPage() {
|
2024-11-27 04:53:47 -04:00
|
|
|
// 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
|
2024-11-24 18:23:45 -04:00
|
|
|
const command1 = "hostname"
|
|
|
|
const command2 = "hostname -I"
|
2024-11-24 17:47:47 -04:00
|
|
|
const command3 = "docker container ls"
|
|
|
|
cockpit.spawn(["bash", "-c", command1])
|
|
|
|
.then((data) => {
|
2024-11-24 18:23:45 -04:00
|
|
|
droneName.innerHTML = data.split(" ")[0];
|
2024-11-24 17:47:47 -04:00
|
|
|
})
|
|
|
|
.catch((error) => console.log(error));
|
|
|
|
cockpit.spawn(["bash", "-c", command2])
|
|
|
|
.then((data) => {
|
2024-11-24 18:23:45 -04:00
|
|
|
address.innerHTML = data.split(" ")[0];
|
2024-11-24 17:47:47 -04:00
|
|
|
})
|
|
|
|
.catch((error) => console.log(error));
|
|
|
|
cockpit.spawn(["bash", "-c", command3])
|
|
|
|
.then((data) => {
|
2024-11-24 18:23:45 -04:00
|
|
|
const datalist = data.split("\n");
|
|
|
|
for (let i = 0; i < datalist.length - 2; i++) {
|
|
|
|
container.innerHTML += datalist[i + 1].split(" ")[0];
|
|
|
|
container.innerHTML += "<br>";
|
|
|
|
}
|
|
|
|
container.innerHTML += datalist[datalist.length - 1].split(" ")[0]
|
2024-11-24 17:47:47 -04:00
|
|
|
})
|
|
|
|
.catch((error) => console.log(error));
|
2024-11-16 19:38:52 -04:00
|
|
|
}
|