redisign using callback to render and show images

This commit is contained in:
Marc Wäckerlin
2018-11-26 23:19:34 +01:00
parent 5b14b54d1e
commit cdb0a28bb9
5 changed files with 33 additions and 16 deletions

View File

@@ -1,10 +1,23 @@
var socket = null;
var docker = null;
function error(msg) {
// handle display errors
function error(msg, data) {
$('#error').html('<h1>Error</h1><p>'+(new Date()).toLocaleString()+'</p><p>'+msg+'</p><pre>'+data+'</pre>').show()
}
function sigstack() {
$('#error').hide()
var dot = docker.graphics.stack()
var svg = docker.graphics.viz(dot, error)
$('#stacks').html(svg)
$('a#svgStacks').attr('href', 'data:image/svg;base64,'+btoa(svg))
.attr('target', '_blank')
.attr('download', window.location.hostname+'.svg')
.show()
}
function init() {
socket = io.connect()
docker = new Docker(socket, error, '#containers', '#nodes', '#stacks')
docker = new Docker(socket, error, sigstack)
}
$(init)