fix typo; throw exception on error

master
Marc Wäckerlin 6 years ago
parent 786cb0be5b
commit d3c6c1c6cc
  1. 23
      client/servicedock.js
  2. 2
      package.json
  3. 2
      routes/index.js

@ -1,11 +1,10 @@
var socket = io.connect() var socket = io.connect()
var docker = new Docker(socket, error, sigstack) var docker = new Docker(socket, error, sigstack)
var parameters = docker.graphics.parameters var parameters = docker.graphics.parameters
console.log(localStorage)
function error(msg, data) { function error(e) {
$('#status').removeClass().addClass('error') $('#status').removeClass().addClass('error')
$('#error').html('<h1>Error</h1><p>'+(new Date()).toLocaleString()+'</p><p>'+msg+'</p><pre>'+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() {
@ -13,31 +12,33 @@ function sigstack() {
$('#clock').text((new Date()).toLocaleString()) $('#clock').text((new Date()).toLocaleString())
$('#status').removeClass().addClass('wait') $('#status').removeClass().addClass('wait')
var dot = docker.graphics.stack(parameters) var dot = docker.graphics.stack(parameters)
var svg = docker.graphics.viz(dot, error) $('a#dot').attr('href', 'data:text/vnd.graphviz;base64,'+btoa(dot))
$('#stacks').html(svg) .attr('target', '_blank')
.attr('download', window.location.hostname+'.dot')
try {
$('#clock').text((new Date()).toLocaleString()) $('#clock').text((new Date()).toLocaleString())
var svg = docker.graphics.viz(dot)
$('#stacks').html(svg)
$('#status').removeClass().addClass('success') $('#status').removeClass().addClass('success')
$('a#svg').attr('href', 'data:image/svg;base64,'+btoa(svg)) $('a#svg').attr('href', 'data:image/svg;base64,'+btoa(svg))
.attr('target', '_blank') .attr('target', '_blank')
.attr('download', window.location.hostname+'.svg') .attr('download', window.location.hostname+'.svg')
$('a#dot').attr('href', 'data:text/vnd.graphviz;base64,'+btoa(dot)) } catch (e) {
.attr('target', '_blank') error(e)
.attr('download', window.location.hostname+'.dot') }
$('#clock').text((new Date()).toLocaleString())
} }
function setParameters() { function setParameters() {
localStorage.rankdir = (++localStorage.rankdir)%setParameters.rankdirs.length localStorage.rankdir = (++localStorage.rankdir)%setParameters.rankdirs.length
parameters.rankdir = setParameters.rankdirs[localStorage.rankdir] parameters.rankdir = setParameters.rankdirs[localStorage.rankdir]
$('#orientation').removeClass().addClass(parameters.rankdir.toLowerCase()) $('#orientation').removeClass().addClass(parameters.rankdir.toLowerCase())
console.log(localStorage.rankdir)
} }
setParameters.rankdirs = ['LR', 'TB', 'RL', 'BT'] setParameters.rankdirs = ['LR', 'TB', 'RL', 'BT']
if (!localStorage.rankdir) if (!localStorage.rankdir)
localStorage.rankdir = -1 localStorage.rankdir = -1
else else
--localStorage.rankdir --localStorage.rankdir
console.log(localStorage.rankdir)
function init() { function init() {
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.8", "docker.js": "^1.4.10",
"dockerode": "^2.5.7", "dockerode": "^2.5.7",
"express": "*", "express": "*",
"jquery": "^3.1.1", "jquery": "^3.1.1",

@ -3,7 +3,7 @@ var router = express.Router();
/* GET home page. */ /* GET home page. */
router.get('/', function(req, res) { router.get('/', function(req, res) {
res.render('index', { title: 'Express' }); res.render('index', { title: 'ServiceDock' });
}); });
module.exports = router; module.exports = router;

Loading…
Cancel
Save