// Elements const droneName = document.getElementById("name"); const address = document.getElementById("address"); const container = document.getElementById("container"); // Load page + drone settings 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 command1 = "hostname" const command2 = "hostname -I" const command3 = "docker container ls" cockpit.spawn(["bash", "-c", command1]) .then((data) => { droneName.innerHTML = data.split(" ")[0]; }) .catch((error) => console.log(error)); cockpit.spawn(["bash", "-c", command2]) .then((data) => { address.innerHTML = data.split(" ")[0]; }) .catch((error) => console.log(error)); cockpit.spawn(["bash", "-c", command3]) .then((data) => { const datalist = data.split("\n"); for (let i = 0; i < datalist.length - 2; i++) { container.innerHTML += datalist[i + 1].split(" ")[0]; container.innerHTML += "
"; } container.innerHTML += datalist[datalist.length - 1].split(" ")[0] }) .catch((error) => console.log(error)); }