fix typo; throw exception on error

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

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

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

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

Loading…
Cancel
Save