diff --git a/ax_init_standard_project.m4 b/ax_init_standard_project.m4
index ccddf89..0e41482 100644
--- a/ax_init_standard_project.m4
+++ b/ax_init_standard_project.m4
@@ -90,16 +90,19 @@ AC_DEFUN([AX_ADD_MAKEFILE_TARGET_DEP], [
fi
])
-# Same as AC_SUBST, but adds -Dname="value" option to CPPFLAGS
+# Same as AC_SUBST, but adds -Dname="value" option to CPPFLAGS and a
+# notz only a @name@ replacement, but also a @name_ENCODED@ one to be
+# used in code.
# - parameters:
# $1 = variable name
AC_DEFUN([AX_SUBST], [
+ [$1]_ENCODED=$(echo "${$1}" | awk 1 ORS='\\n' | sed 's,\\n$,,')
+ [$1]_ENCODED=${[$1]_ENCODED//\"/\\\"}
+ [$1]_ENCODED=${[$1]_ENCODED//\'/\'\"\'\"\'}
+ [$1]_ENCODED=${[$1]_ENCODED//#/\\#}
+ AM_CPPFLAGS+=" '-D$1=\"${[$1]_ENCODED}\"'"
AC_SUBST([$1])
- tmp_var=$(echo "${$1}" | awk 1 ORS='\\n' | sed 's,\\n$,,')
- tmp_var=${tmp_var//\"/\\\"}
- tmp_var=${tmp_var//\'/\'\"\'\"\'}
- tmp_var=${tmp_var//#/\\#}
- AM_CPPFLAGS+=" '-D$1=\"${tmp_var}\"'"
+ AC_SUBST([$1]_ENCODED)
AC_SUBST(AM_CPPFLAGS)
])
diff --git a/configure.ac b/configure.ac
index 63e3c4a..d496d8a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@ AX_BUILD_HTML
#AX_REQUIRE_QT([QT], [QtCore QtGui QtNetwork], [QtWidgets])
#AX_QT_NO_KEYWORDS
-AC_CONFIG_FILES([html/index.html])
+AC_CONFIG_FILES([html/index.html html/about.php])
# create output
AC_OUTPUT
diff --git a/html/about.php.in b/html/about.php.in
new file mode 100644
index 0000000..69dcae4
--- /dev/null
+++ b/html/about.php.in
@@ -0,0 +1,9 @@
+ "@PACKAGE_NAME@",
+ "version" => "@VERSION@",
+ "docker" => $docker,
+ "description" => "@DESCRIPTION_ENCODED@",
+ "readme" => "@README_ENCODED@");
+echo json_encode($res);
+?>
\ No newline at end of file
diff --git a/html/images.php b/html/images.php
new file mode 100644
index 0000000..10035ac
--- /dev/null
+++ b/html/images.php
@@ -0,0 +1,39 @@
+B [label="Probable\nCause"];';
+ echo '}';
+ return;
+}
+exec("docker inspect ".join(" ", $res), $res2, $ret);
+if ($ret==0) {
+ $images=json_decode(join($res2), true);
+ echo "digraph {\n";
+ echo " rankdir=TB;\n";
+
+ foreach ($images as $i) {
+ $name = "";
+ if (isset($i['RepoTags']) && count($i['RepoTags'])>0) {
+ $name = join("\\n", $i['RepoTags']);
+ if (isset($i['Author']) && $i['Author']!="") $name .= '\\n['.$i['Author'].']';
+ }
+ echo ' "'.$i['Id'].'" [label="'.$name.'"];'."\n";
+ }
+
+ foreach ($images as $i) {
+ if (isset($i['Parent']) && $i['Parent']!="")
+ echo ' "'.$i['Parent'].'" -> "'.$i['Id'].'";'."\n";
+ }
+
+ echo "}";
+} else {
+ echo 'digraph {';
+ echo ' A [label="Error\nCannot Inspect Docker Container"];';
+ echo '}';
+ return;
+}
+
+?>
\ No newline at end of file
diff --git a/html/index.html.in b/html/index.html.in
index a6b3780..21337a2 100644
--- a/html/index.html.in
+++ b/html/index.html.in
@@ -25,6 +25,8 @@
@@ -35,10 +37,6 @@
-
+
diff --git a/html/makefile.am b/html/makefile.am
index 42bd2d2..240eaff 100644
--- a/html/makefile.am
+++ b/html/makefile.am
@@ -8,12 +8,12 @@
## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
-EXTRA_DIST = index.html.in
+EXTRA_DIST = index.html.in about.php.in
wwwdir = ${pkgdatadir}/html
-www_DATA = index.html
+www_DATA = index.html about.php
dist_www_DATA = servicedock.css servicedock.js jquery.js viz.js \
menu.svg overview.php details.php manage.php \
- action.php jquery-ui.js jquery-ui.css
+ action.php jquery-ui.js jquery-ui.css images
MAINTAINERCLEANFILES = makefile.in
diff --git a/html/overview.php b/html/overview.php
index f7aabd3..c434fa2 100644
--- a/html/overview.php
+++ b/html/overview.php
@@ -48,7 +48,7 @@ if ($ret==0) {
echo " {rank=same;\n";
foreach ($containers as $c) {
- foreach ($c['Volumes'] as $in => $out) {
+ if (isset($c['Volumes'])) foreach ($c['Volumes'] as $in => $out) {
echo ' "'.$in.':'.$out.'" [label="'.$in.'";shape=box];',"\n";
}
}
@@ -56,7 +56,7 @@ if ($ret==0) {
echo " {rank=same;\n";
foreach ($containers as $c) {
- foreach ($c['Volumes'] as $in => $out) {
+ if (isset($c['Volumes'])) foreach ($c['Volumes'] as $in => $out) {
if (!preg_match(',^/var/lib/docker/,', $out))
echo ' "'.$out.'" [shape=box];',"\n";
}
@@ -64,7 +64,7 @@ if ($ret==0) {
echo " };\n";
foreach ($containers as $c) {
- foreach ($c['Volumes'] as $in => $out) {
+ if (isset($c['Volumes'])) foreach ($c['Volumes'] as $in => $out) {
if (!preg_match(',^/var/lib/docker/,', $out))
echo ' "'.$in.':'.$out.'" -> "'.$out.'";',"\n";
}
@@ -78,7 +78,7 @@ if ($ret==0) {
$link = preg_replace(',.*:/?'.$name.'/,', '', $l);
echo '"'.$name.'" -> "'.$to.'" [label="'.$link.'"];'."\n";
}
- foreach ($c['Volumes'] as $in => $out) {
+ if (isset($c['Volumes'])) foreach ($c['Volumes'] as $in => $out) {
echo '"'.$name.'" -> "'.$in.':'.$out.'";',"\n";
}
}
diff --git a/html/servicedock.css b/html/servicedock.css
index 8c6ba19..da00fdc 100644
--- a/html/servicedock.css
+++ b/html/servicedock.css
@@ -9,7 +9,7 @@
}
}
-p {
+pre, p {
padding: .5em 0 1em 0;
}
diff --git a/html/servicedock.js b/html/servicedock.js
index e31830e..b03c01e 100644
--- a/html/servicedock.js
+++ b/html/servicedock.js
@@ -92,6 +92,24 @@ function togglemenu() {
$("#menu").toggle();
}
+function about(c) {
+ $.ajax({url: "about.php", success: function(res) {
+ try {
+ var a = JSON.parse(res);
+ status("
"+a.description+"
"+
+ "
"+a.project+"-"+a.version+"
"+
+ "
"+a.docker+"
"+
+ "
README
"+
+ "
"+a.readme+"
");
+ } catch(e) {
+ status("
"+res+"
");
+ error("Exception Caught: "+e);
+ }
+ }}).fail(function() {
+ error("offline");
+ });
+}
+
function details(c) {
$.ajax({url: "details.php?container="+c, success: function(res) {
try {
@@ -101,7 +119,7 @@ function details(c) {
error("Exception Caught: "+e);
}
}}).fail(function() {
- error("offline")
+ error("offline");
});
}
@@ -110,7 +128,7 @@ function action(container, action) {
success(res);
manage();
}}).fail(function() {
- error("offline")
+ error("offline");
});
}
@@ -119,22 +137,40 @@ function manage() {
$.ajax({url: "manage.php", success: function(res) {
status(res);
}}).fail(function() {
- error("offline")
+ error("offline");
});
}
/** Show an Overview of all Docker Services */
function overview() {
$.ajax({url: "overview.php", success: function(res) {
+ try {
+ status(Viz(res));
+ } catch(e) {
+ (res = res.split("\n")).forEach(function(v, i, a) {
+ a[i] = ("000"+(i+1)).slice(-3)+": "+v;
+ });
+ status("
Exception Caught:
"+e+"
"+res.join("\n")+"
");
+ }
+ }}).fail(function() {
+ error("offline");
+ });
+}
+
+/** Show an Overview of all Docker Images */
+function imgs() {
+ $.ajax({url: "images.php", success: function(res) {
try {
status(Viz(res));
//status(res);
} catch(e) {
- status("
"+res+"
");
- error("Exception Caught: "+e);
+ (res = res.split("\n")).forEach(function(v, i, a) {
+ a[i] = ("000"+(i+1)).slice(-3)+": "+v;
+ });
+ status("
Exception Caught:
"+e+"
"+res.join("\n")+"
");
}
}}).fail(function() {
- error("offline")
+ error("offline");
});
}