added about and images

single-host
Marc Wäckerlin 9 years ago
parent d1c90271be
commit 94cff08bc9
  1. 15
      ax_init_standard_project.m4
  2. 2
      configure.ac
  3. 9
      html/about.php.in
  4. 39
      html/images.php
  5. 8
      html/index.html.in
  6. 6
      html/makefile.am
  7. 8
      html/overview.php
  8. 2
      html/servicedock.css
  9. 48
      html/servicedock.js

@ -90,16 +90,19 @@ AC_DEFUN([AX_ADD_MAKEFILE_TARGET_DEP], [
fi 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: # - parameters:
# $1 = variable name # $1 = variable name
AC_DEFUN([AX_SUBST], [ 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]) AC_SUBST([$1])
tmp_var=$(echo "${$1}" | awk 1 ORS='\\n' | sed 's,\\n$,,') AC_SUBST([$1]_ENCODED)
tmp_var=${tmp_var//\"/\\\"}
tmp_var=${tmp_var//\'/\'\"\'\"\'}
tmp_var=${tmp_var//#/\\#}
AM_CPPFLAGS+=" '-D$1=\"${tmp_var}\"'"
AC_SUBST(AM_CPPFLAGS) AC_SUBST(AM_CPPFLAGS)
]) ])

@ -33,7 +33,7 @@ AX_BUILD_HTML
#AX_REQUIRE_QT([QT], [QtCore QtGui QtNetwork], [QtWidgets]) #AX_REQUIRE_QT([QT], [QtCore QtGui QtNetwork], [QtWidgets])
#AX_QT_NO_KEYWORDS #AX_QT_NO_KEYWORDS
AC_CONFIG_FILES([html/index.html]) AC_CONFIG_FILES([html/index.html html/about.php])
# create output # create output
AC_OUTPUT AC_OUTPUT

@ -0,0 +1,9 @@
<?php
exec("docker --version", $docker);
$res = Array("project" => "@PACKAGE_NAME@",
"version" => "@VERSION@",
"docker" => $docker,
"description" => "@DESCRIPTION_ENCODED@",
"readme" => "@README_ENCODED@");
echo json_encode($res);
?>

@ -0,0 +1,39 @@
<?php
exec("docker images -aq", $res, $ret);
if ($ret!=0) {
echo 'digraph {';
echo ' A [label="Error\nCannot get Docker Images"];';
echo ' B [label="Does the Webserver have Docker rights?"];';
echo ' A->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;
}
?>

@ -25,6 +25,8 @@
<ul id="menu" style="display: none" onmouseleave="$('#menu').hide();"> <ul id="menu" style="display: none" onmouseleave="$('#menu').hide();">
<li onclick="$('#menu').hide();overview()">Overview</li> <li onclick="$('#menu').hide();overview()">Overview</li>
<li onclick="$('#menu').hide();manage()">Manage</li> <li onclick="$('#menu').hide();manage()">Manage</li>
<li onclick="$('#menu').hide();imgs()">Images</li>
<li onclick="$('#menu').hide();about()">About</li>
</ul> </ul>
<div id="main"> <div id="main">
@ -35,10 +37,6 @@
<div id="status"> <div id="status">
<noscript>This is a secure and encryptet chat application, that runs <noscript>JavaScript is required for the interface.</noscript>
in your browser and does not send any credentials to the
server. Your password and your secret key is fully under your
control. That's why you must enable javascript and local storage for
this application.</noscript>
</div> </div>

@ -8,12 +8,12 @@
## 1 2 3 4 5 6 7 8 ## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890 ## 45678901234567890123456789012345678901234567890123456789012345678901234567890
EXTRA_DIST = index.html.in EXTRA_DIST = index.html.in about.php.in
wwwdir = ${pkgdatadir}/html wwwdir = ${pkgdatadir}/html
www_DATA = index.html www_DATA = index.html about.php
dist_www_DATA = servicedock.css servicedock.js jquery.js viz.js \ dist_www_DATA = servicedock.css servicedock.js jquery.js viz.js \
menu.svg overview.php details.php manage.php \ 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 MAINTAINERCLEANFILES = makefile.in

@ -48,7 +48,7 @@ if ($ret==0) {
echo " {rank=same;\n"; echo " {rank=same;\n";
foreach ($containers as $c) { 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"; echo ' "'.$in.':'.$out.'" [label="'.$in.'";shape=box];',"\n";
} }
} }
@ -56,7 +56,7 @@ if ($ret==0) {
echo " {rank=same;\n"; echo " {rank=same;\n";
foreach ($containers as $c) { 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)) if (!preg_match(',^/var/lib/docker/,', $out))
echo ' "'.$out.'" [shape=box];',"\n"; echo ' "'.$out.'" [shape=box];',"\n";
} }
@ -64,7 +64,7 @@ if ($ret==0) {
echo " };\n"; echo " };\n";
foreach ($containers as $c) { 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)) if (!preg_match(',^/var/lib/docker/,', $out))
echo ' "'.$in.':'.$out.'" -> "'.$out.'";',"\n"; echo ' "'.$in.':'.$out.'" -> "'.$out.'";',"\n";
} }
@ -78,7 +78,7 @@ if ($ret==0) {
$link = preg_replace(',.*:/?'.$name.'/,', '', $l); $link = preg_replace(',.*:/?'.$name.'/,', '', $l);
echo '"'.$name.'" -> "'.$to.'" [label="'.$link.'"];'."\n"; 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"; echo '"'.$name.'" -> "'.$in.':'.$out.'";',"\n";
} }
} }

@ -9,7 +9,7 @@
} }
} }
p { pre, p {
padding: .5em 0 1em 0; padding: .5em 0 1em 0;
} }

@ -92,6 +92,24 @@ function togglemenu() {
$("#menu").toggle(); $("#menu").toggle();
} }
function about(c) {
$.ajax({url: "about.php", success: function(res) {
try {
var a = JSON.parse(res);
status("<h2>"+a.description+"</h2>"+
"<p>"+a.project+"-"+a.version+"</p>"+
"<p>"+a.docker+"</p>"+
"<h3>README</h3>"+
"<pre>"+a.readme+"</pre>");
} catch(e) {
status("<pre>"+res+"</pre>");
error("Exception Caught: "+e);
}
}}).fail(function() {
error("offline");
});
}
function details(c) { function details(c) {
$.ajax({url: "details.php?container="+c, success: function(res) { $.ajax({url: "details.php?container="+c, success: function(res) {
try { try {
@ -101,7 +119,7 @@ function details(c) {
error("Exception Caught: "+e); error("Exception Caught: "+e);
} }
}}).fail(function() { }}).fail(function() {
error("offline") error("offline");
}); });
} }
@ -110,7 +128,7 @@ function action(container, action) {
success(res); success(res);
manage(); manage();
}}).fail(function() { }}).fail(function() {
error("offline") error("offline");
}); });
} }
@ -119,22 +137,40 @@ function manage() {
$.ajax({url: "manage.php", success: function(res) { $.ajax({url: "manage.php", success: function(res) {
status(res); status(res);
}}).fail(function() { }}).fail(function() {
error("offline") error("offline");
}); });
} }
/** Show an Overview of all Docker Services */ /** Show an Overview of all Docker Services */
function overview() { function overview() {
$.ajax({url: "overview.php", success: function(res) { $.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("<h2>Exception Caught:</h2><p>"+e+"<p><pre>"+res.join("\n")+"</pre>");
}
}}).fail(function() {
error("offline");
});
}
/** Show an Overview of all Docker Images */
function imgs() {
$.ajax({url: "images.php", success: function(res) {
try { try {
status(Viz(res)); status(Viz(res));
//status(res); //status(res);
} catch(e) { } catch(e) {
status("<pre>"+res+"</pre>"); (res = res.split("\n")).forEach(function(v, i, a) {
error("Exception Caught: "+e); a[i] = ("000"+(i+1)).slice(-3)+": "+v;
});
status("<h2>Exception Caught:</h2><p>"+e+"<p><pre>"+res.join("\n")+"</pre>");
} }
}}).fail(function() { }}).fail(function() {
error("offline") error("offline");
}); });
} }

Loading…
Cancel
Save