From 7b5ea21241543b0f75d525888da87f763883b1c7 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 19 Aug 2024 19:32:36 +0200 Subject: geht erst mal --- docker-status.html | 13 +++++++++++++ docker-status.sh | 4 ++-- load-status.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 docker-status.html create mode 100644 load-status.js diff --git a/docker-status.html b/docker-status.html new file mode 100644 index 0000000..1ce9c2b --- /dev/null +++ b/docker-status.html @@ -0,0 +1,13 @@ + + + +Kuchen + + + +
+
+ refresh + logout + + diff --git a/docker-status.sh b/docker-status.sh index c990645..461ed44 100755 --- a/docker-status.sh +++ b/docker-status.sh @@ -2,9 +2,9 @@ echo "Content-Type: application/json" echo "" +printf '[\n' docker ps --format json --no-trunc \ | sed ' $! s/$/,/ - 1 i [ - $ a ] ' +printf ']\n' 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 = ""; + columns = ['ID', 'Image', 'Command', 'Mounts', 'Running For', 'State', 'Status']; + tableContent += "\n"; + tableContent += status.map((line) => + "" + columns + .map((column) => "") + .join("") + "" + ).join(""); + statusElement.innerHTML = tableContent + "
" + columns.join("") + "
" + line[column] + "
"; +} + +function getStatus() { + httpGetAsync('/status', displayStatus); +} + -- cgit v1.2.3-70-g09d2