summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docker-status.html13
-rwxr-xr-xdocker-status.sh4
-rw-r--r--load-status.js29
3 files changed, 44 insertions, 2 deletions
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 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Kuchen</title>
+<script type="text/javascript" src="/load-status.js"></script>
+</head>
+<body onload="getStatus();">
+ <div id="status">
+ </div>
+ <a href="#" onclick="getStatus(); return false">refresh</a>
+ <a href="/protected/redirect_uri?logout=">logout</a>
+</body>
+</html>
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 = "<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);
+}
+