I think the table works

This commit is contained in:
Alice Sedgwick 2024-11-24 17:23:45 -05:00
parent 957d0319df
commit d11117844f
1 changed files with 13 additions and 5 deletions

View File

@ -2,6 +2,9 @@
// Elements
const drone = document.getElementById("drone");
const droneDropdown = document.getElementById("droneSelection");
const droneName = document.getElementById("name");
const address = document.getElementById("address");
const container = document.getElementById("container");
const drones = [
["1", "mu1"], ["2", "mu2"], ["3", "mu3"],
@ -19,22 +22,27 @@ function initPage() {
// Search for drones files in the services directory and populate the dropdown with directory names
addDropDown(droneDropdown, drones, "1");
const command1 = "hostname -I"
const command2 = "hostname"
const command1 = "hostname"
const command2 = "hostname -I"
const command3 = "docker container ls"
cockpit.spawn(["bash", "-c", command1])
.then((data) => {
console.log(data.split(" ")[0]);
droneName.innerHTML = data.split(" ")[0];
})
.catch((error) => console.log(error));
cockpit.spawn(["bash", "-c", command2])
.then((data) => {
console.log(data.split(" ")[0]);
address.innerHTML = data.split(" ")[0];
})
.catch((error) => console.log(error));
cockpit.spawn(["bash", "-c", command3])
.then((data) => {
console.log(data.split(" ")[0]);
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]
})
.catch((error) => console.log(error));
}