now also rendering local standalone containers

master
Marc Wäckerlin 6 years ago
parent d3c6c1c6cc
commit 1d7ee79830
  1. 48
      client/servicedock.js
  2. 2
      package.json
  3. 15
      style/style.styl
  4. 4
      views/index.pug
  5. 4
      views/layout.pug

@ -1,22 +1,30 @@
var socket = io.connect() var socket = io.connect()
var docker = new Docker(socket, error, sigstack) var docker = new Docker(socket, error, sigstack, sigcontainer)
var parameters = docker.graphics.parameters var parameters = docker.graphics.parameters
var showstack = true
var showcontainer = true
function showdate() {
$('#clock').text((new Date()).toLocaleString())
}
function error(e) { function error(e) {
showdate()
$('#status').removeClass().addClass('error') $('#status').removeClass().addClass('error')
$('#error').html('<h1>Error</h1><p>'+(new Date()).toLocaleString()+'</p><p>'+e.msg+'</p><pre>'+e.data+'</pre>').show() $('#error').html('<h1>Error</h1><p>'+(new Date()).toLocaleString()+'</p><p>'+e.msg+'</p><pre>'+e.data+'</pre>').show()
} }
function sigstack() { function sigstack() {
$('#error').hide() if (!showstack) return;
$('#clock').text((new Date()).toLocaleString()) showdate()
$('#status').removeClass().addClass('wait') $('#status').removeClass().addClass('wait')
var dot = docker.graphics.stack(parameters) var dot = docker.graphics.stack(parameters)
$('a#dot').attr('href', 'data:text/vnd.graphviz;base64,'+btoa(dot)) $('a#dot').attr('href', 'data:text/vnd.graphviz;base64,'+btoa(dot))
.attr('target', '_blank') .attr('target', '_blank')
.attr('download', window.location.hostname+'.dot') .attr('download', window.location.hostname+'.dot')
$('#error').hide()
showdate()
try { try {
$('#clock').text((new Date()).toLocaleString())
var svg = docker.graphics.viz(dot) var svg = docker.graphics.viz(dot)
$('#stacks').html(svg) $('#stacks').html(svg)
$('#status').removeClass().addClass('success') $('#status').removeClass().addClass('success')
@ -26,7 +34,35 @@ function sigstack() {
} catch (e) { } catch (e) {
error(e) error(e)
} }
$('#clock').text((new Date()).toLocaleString()) showdate()
}
function sigcontainer() {
if (!showcontainer) return;
console.log(docker.containers.get())
showdate()
$('#status').removeClass().addClass('wait')
var dot = docker.graphics.standalone(parameters)
/*
$('a#dot').attr('href', 'data:text/vnd.graphviz;base64,'+btoa(dot))
.attr('target', '_blank')
.attr('download', window.location.hostname+'.dot')
*/
$('#error').hide()
showdate()
try {
var svg = docker.graphics.viz(dot)
$('#standalone').html(svg)
$('#status').removeClass().addClass('success')
/*
$('a#svg').attr('href', 'data:image/svg;base64,'+btoa(svg))
.attr('target', '_blank')
.attr('download', window.location.hostname+'.svg')
*/
} catch (e) {
error(e)
}
showdate()
} }
function setParameters() { function setParameters() {
@ -41,6 +77,8 @@ else
--localStorage.rankdir --localStorage.rankdir
function init() { function init() {
showdate()
$('#status').removeClass().addClass('wait')
setParameters() setParameters()
$('#orientation').on('click', () => { $('#orientation').on('click', () => {
setParameters() setParameters()

@ -10,7 +10,7 @@
"child_process": "^1.0.2", "child_process": "^1.0.2",
"cookie-parser": "*", "cookie-parser": "*",
"debug": "*", "debug": "*",
"docker.js": "^1.4.10", "docker.js": "^1.4.12",
"dockerode": "^2.5.7", "dockerode": "^2.5.7",
"express": "*", "express": "*",
"jquery": "^3.1.1", "jquery": "^3.1.1",

@ -91,7 +91,7 @@ header
.top .top
header header
position: absolute position: fixed
top: 0 top: 0
left: 0 left: 0
width: 100% width: 100%
@ -108,7 +108,7 @@ header
.bottom .bottom
header header
position: absolute position: fixed
bottom: 0 bottom: 0
left: 0 left: 0
width: 100% width: 100%
@ -126,15 +126,15 @@ header
.left .left
header header
transform: translate(-50%) translate(1em) rotate(270deg) translate(-50%) translate(1em) position: fixed
position: absolute
top: 0 top: 0
left: 0 left: 0
width: 100vh width: 100vh
height: 2em height: 2em
transform: translate(-50%) translate(1em) rotate(270deg) translate(-50%) translate(1em)
#orientation #orientation
transform: rotate(90deg) transform: rotate(90deg)
#menu #menu
position: absolute position: absolute
left: -3em left: -3em
transform: rotate(90deg) translate(50%) translate(-2em) transform: rotate(90deg) translate(50%) translate(-2em)
@ -147,7 +147,7 @@ header
.right .right
header header
position: absolute position: fixed
top: 0 top: 0
right: 0 right: 0
width: 100vh width: 100vh
@ -167,6 +167,9 @@ header
bottom: 0 bottom: 0
overflow: auto overflow: auto
.imagecontainer
padding: 1em
#image #image
height: 100% height: 100%

@ -1,7 +1,9 @@
extends layout extends layout
block content block content
div#stacks div.imagecontainer#stacks
div#loading loading... div#loading loading...
noscript noscript
p.error this site requires javascript p.error this site requires javascript
div.imagecontainer#standalone
div#loading loading...

@ -20,8 +20,8 @@ html
a#dot download source a#dot download source
div#info div#info
div#orientation div#orientation
div#clock div#clock= (new Date()).toLocaleString()
div#status div#status.error
main main
block content block content
footer footer

Loading…
Cancel
Save