diff options
author | Erich Eckner <erich.eckner.ext@bestsecret.com> | 2024-08-19 19:32:36 +0200 |
---|---|---|
committer | Erich Eckner <erich.eckner.ext@bestsecret.com> | 2024-08-19 19:32:36 +0200 |
commit | 7b5ea21241543b0f75d525888da87f763883b1c7 (patch) | |
tree | c4f1b8be8b43d91be302f6cc54e6c32585b5b54b /load-status.js | |
parent | d4cfa5367ac30cee46b43304c70a9d1e4c03c06d (diff) | |
download | docker-status-7b5ea21241543b0f75d525888da87f763883b1c7.tar.xz |
geht erst mal
Diffstat (limited to 'load-status.js')
-rw-r--r-- | load-status.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/load-status.js b/load-status.js new file mode 100644 index 0000000..b10d5e9 --- /dev/null +++ b/load-status.js @@ -0,0 +1,29 @@ +function httpGetAsync(theUrl, callback) +{ + var xmlHttp = new XMLHttpRequest(); + xmlHttp.onreadystatechange = function() { + if (xmlHttp.readyState == 4 && xmlHttp.status == 200) + callback(xmlHttp.responseText); + } + xmlHttp.open("GET", theUrl, true); // true for asynchronous + xmlHttp.send(null); +} + +function displayStatus(statusString) { + let statusElement = document.getElementById('status'); + let status = JSON.parse(statusString); + let tableContent = "<table>"; + columns = ['ID', 'Image', 'Command', 'Mounts', 'Running For', 'State', 'Status']; + tableContent += "<tr><th>" + columns.join("</th><th>") + "</th></tr>\n"; + tableContent += status.map((line) => + "<tr>" + columns + .map((column) => "<td>" + line[column] + "</td>") + .join("") + "</tr>" + ).join(""); + statusElement.innerHTML = tableContent + "</table>"; +} + +function getStatus() { + httpGetAsync('/status', displayStatus); +} + |