diff --git a/ChangeLog b/ChangeLog
index 4e82dc0..1ebc736 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+2016-01-29 15:55 marc
+
+ * nodejs/docker/docker.js,
+ nodejs/public/javascripts/servicedock.js, nodejs/views/index.ejs:
+ create continued
+
+2016-01-28 15:42 marc
+
+ * nodejs/docker/docker.js,
+ nodejs/public/javascripts/servicedock.js,
+ nodejs/public/stylesheets/servicedock.css,
+ nodejs/views/index.ejs: more of create
+
+2016-01-28 08:01 marc
+
+ * nodejs/makefile.am: first part of create new nodes - added
+ missing folder
+
+2016-01-28 08:01 marc
+
+ * nodejs/docker, nodejs/docker/docker.js, nodejs/docker/index.js:
+ first part of create new nodes - added missing folder
+
+2016-01-27 16:06 marc
+
+ * doc/screenshot-main-43.png, doc/screenshot.png,
+ doc/servicedock.ogv, nodejs/public/javascripts/servicedock.js,
+ nodejs/public/stylesheets/servicedock.css, nodejs/servicedock.js,
+ nodejs/sockets/index.js, nodejs/views/index.ejs: first part of
+ create neew nodes
+
+2016-01-25 15:52 marc
+
+ * ChangeLog, ax_init_standard_project.m4, build-in-docker.sh,
+ nodejs/etc, nodejs/etc/servicedock.json, nodejs/makefile.am,
+ nodejs/package.json.in, nodejs/public/javascripts/servicedock.js,
+ nodejs/servicedock.js: more bashing
+
2016-01-25 08:00 marc
* ChangeLog: small fixes
diff --git a/nodejs/docker/docker.js b/nodejs/docker/docker.js
index bfee14c..8848210 100644
--- a/nodejs/docker/docker.js
+++ b/nodejs/docker/docker.js
@@ -40,10 +40,13 @@ var Docker = function() {
nodes[c.Id].author = c.Author;
nodes[c.Id].os = c.Os+"/"+c.Architecture;
nodes[c.Id].parent = c.Parent;
- nodes[c.Id].env = c.Config.Env;
+ nodes[c.Id].env = c.Config.Env || [];
nodes[c.Id].cmd = c.Config.Cmd;
nodes[c.Id].entrypoint = c.Config.Entrypoint;
- nodes[c.Id].ports = c.Config.ExposedPorts;
+ nodes[c.Id].ports = [];
+ if (c.Config.ExposedPorts)
+ for (p in c.Config.ExposedPorts)
+ nodes[c.Id].ports.push(p);
nodes[c.Id].volumes = c.Config.Volumes;
if (c.Parent) {
if (!nodes[c.Parent]) nodes[c.Parent] = {};
@@ -52,6 +55,15 @@ var Docker = function() {
}
});
}
+ this.tags = function() {
+ var res = [];
+ for (n in nodes) if (nodes[n].tags) res = res.concat(nodes[n].tags);
+ return res;
+ }
+ this.get = function(tag) {
+ for (n in nodes) if (nodes[n].tags && nodes[n].tags.indexOf(tag)>-1) return nodes[n];
+ return null;
+ }
this.cleanup = function(id, instance) {
if (!nodes[id]) return
nodes[id].env.forEach(function(e) {
@@ -79,7 +91,8 @@ var Docker = function() {
Restarting: {color: "lightblue", action1: "start", action2: "remove", bash: false},
Paused: {color: "grey", action1: "unpause", action2: null, bash: false},
Running: {color: "lightgreen", action1: "pause", action2: "stop", bash: true},
- Preview: {color: "lightgrey"}
+ Preview: {color: "orangered"},
+ Prepared: {color: "lightgrey"}
});
var containers = [];
var nodes = [];
@@ -143,7 +156,7 @@ var Docker = function() {
function graphVolumesInside(n) {
var res = "";
if (n.volumes) n.volumes.forEach(function(v) {
- res += '"'+v.id+'" [label="'+v.inside+'",shape=box];\n';
+ res += '"'+v.id+v.inside+'" [label="'+v.inside+'",shape=box];\n';
});
return res;
}
@@ -159,8 +172,8 @@ var Docker = function() {
var res = "";
if (n.volumes) n.volumes.forEach(function(v) {
if (v.host)
- res += '"'+v.id+'" -> "'+v.outside+'" [label="mounted from"]\n';
- res += '"'+n.name+'" -> "'+v.id+'" [label="volume/'+v.rw+'"]\n';
+ res += '"'+v.id+v.inside+'" -> "'+v.outside+'" [label="mounted from"]\n';
+ res += '"'+n.name+'" -> "'+v.id+v.inside+'" [label="volume/'+v.rw+'"]\n';
});
if (n.volumesfrom) n.volumesfrom.forEach(function(o) {
res += '"'+n.name+'" -> "'+nodes[o].name+'" [label="volumes from"]\n';
@@ -208,7 +221,8 @@ var Docker = function() {
return this.graph(this.subnet(name, nodes), nodes);
}
this.configuration = function(name) {
- var ns = this.subnet(name);
+ var ns = name;
+ if (typeof name == 'string') ns = this.subnet(name);
var creates = [];
for (n in ns) {
var instance = {
@@ -280,6 +294,10 @@ var Docker = function() {
}
return res;
}
+ this.names = function(more) {
+ if (more) return Object.keys(nodes).concat(Object.keys(more))
+ else return Object.keys(nodes);
+ }
function setup() {
delete nodes; nodes = [];
containers.forEach(function(c, i) {
diff --git a/nodejs/public/javascripts/servicedock.js b/nodejs/public/javascripts/servicedock.js
index 21e725c..85d8299 100644
--- a/nodejs/public/javascripts/servicedock.js
+++ b/nodejs/public/javascripts/servicedock.js
@@ -140,33 +140,99 @@ function upload(evt) {
if (evt.target.error) return error("error reading file", true);
if (evt.target.readyState==0) return notice("waiting for data …");
if (evt.target.readyState==1) return notice("loading data …");
- emit("create", evt.target.result);
+ tobecreated = JSON.parse(evt.target.result);
+ showCreate();
}
reader.readAsText(file);
}
}
+var tobecreated = {};
function previewCreate() {
var name = $('#name').val();
- var nodes = {};
- nodes[name] = {
- status: docker.containers.Status.Preview,
- id: null,
- name: name,
- image: {
- name: $('#image').val(),
- id: null
- },
- ports: $('#createports option').map(function() {return $(this).data();}).get(),
- env: $('#createvars option').map(function() {return $(this).val();}).get(),
- volumes: $('#createvolumes option').map(function() {return $(this).data();}).get(),
- volumesfrom: $('#createvolumefroms option').map(function() {return $(this).val();}).get(),
- links: $('#createlinks option').map(function() {return $(this).data();}).get(),
- entrypoint: $('#createentrypoints option').map(function() {return $(this).val();}).get(),
- cmd: $('#createcommands option').map(function() {return $(this).val();}).get(),
- };
- console.log("PREVIEW", nodes[name]);
- $('#preview').html(Viz("digraph {\n"+" rankdir="+rankdir+";\n"+docker.containers.subgraph(name, nodes)+"\n}"));
+ var nodes = Object.create(tobecreated);
+ if (name != '') {
+ nodes[name] = {
+ status: docker.containers.Status.Preview,
+ id: null,
+ name: name,
+ image: {
+ name: $('#image').val(),
+ id: null
+ },
+ ports: $('#createports option').map(function() {return $(this).data();}).get(),
+ env: $('#createvars option').map(function() {return $(this).val();}).get(),
+ volumes: $('#createvolumes option').map(function() {return $(this).data();}).get(),
+ volumesfrom: $('#createvolumefroms option').map(function() {return $(this).val();}).get(),
+ links: $('#createlinks option').map(function() {return $(this).data();}).get(),
+ entrypoint: $('#createentrypoints option').map(function() {return $(this).val();}).get(),
+ cmd: $('#createcommands option').map(function() {return $(this).val();}).get(),
+ };
+ $('#doappend').unbind().click(function() {
+ tobecreated[name] = Object.create(nodes[name]);
+ tobecreated[name].status = docker.containers.Status.Prepared;
+ $('#createpreview').append('');
+ $('#create form input[type=text]').val('');
+ $('#create form select.collect option').remove();
+ previewCreate();
+ });
+ $('#doremove').unbind().click(function() {
+ $(this).siblings('#createpreview').children('option:selected').each(function(a,b,c) {
+ delete tobecreated[b.innerHTML];
+ }).remove();
+ previewCreate();
+ });
+ $('#dosend').unbind().click(function() {
+ if (Object.keys(tobecreated).length>0) {
+ emit("create", docker.containers.configuration(tobecreated));
+ tobecreated = {};
+ showImage();
+ }
+ });
+ }
+ if ($('#image').val()!='') {
+ var img = docker.images.get($('#image').val());
+ if (img) {
+ $('#portintdata').empty().append(img.ports.map(function(i) {
+ var option = document.createElement('option');
+ option.value = i.replace(/\/.*/g, '');
+ return option;
+ }));
+ $('#varnamedata').empty().append(img.env.map(function(i) {
+ var option = document.createElement('option');
+ option.value = i.replace(/=.*/g, '');
+ return option;
+ }));
+ $('#varvaluedata').empty().append(img.env.map(function(i) {
+ var option = document.createElement('option');
+ option.value = i.replace(/^[^=]*=/g, '');
+ return option;
+ }));
+ $('#volumeextdata').empty();
+ $('#volumeintdata').empty();
+ for (i in img.volumes) {
+ var option = document.createElement('option');
+ option.value = i;
+ $('#volumeextdata').append(option);
+ $('#volumeintdata').append(option);
+ }
+ $('#volumesfromdata').empty().append(docker.containers.names(tobecreated).map(function(i) {
+ var option = document.createElement('option');
+ option.value = i;
+ return option;
+ }));
+ $('#linkcontainerdata').empty().append(docker.containers.names(tobecreated).map(function(i) {
+ var option = document.createElement('option');
+ option.value = i;
+ return option;
+ }));
+ }
+ }
+ if (name=='' && nodes) for (name in nodes) break;
+ if (name && name!='') $('#preview').html(Viz("digraph {\n"+" rankdir="+rankdir+";\n"
+ +docker.containers.subgraph(name, nodes)
+ +"\n}"));
+ else $('#preview').html('');
}
function create() {
@@ -289,6 +355,11 @@ function stats(data) {
function images(i) {
console.log("->rcv images");
docker.images.set(i);
+ $('#imagedata').empty().append(docker.images.tags().map(function(i) {
+ var option = document.createElement('option');
+ option.value = i;
+ return option;
+ }));
}
function containers(c) {
@@ -490,7 +561,7 @@ function start() {
function initForms() {
$('#create form *').change(previewCreate);
- $("#create form fieldset .add").click(function() {
+ $("#create form fieldset .add").unbind().click(function() {
$(this).siblings("select.collect")
.append('