|
|
@ -140,33 +140,99 @@ function upload(evt) { |
|
|
|
if (evt.target.error) return error("error reading file", true); |
|
|
|
if (evt.target.error) return error("error reading file", true); |
|
|
|
if (evt.target.readyState==0) return notice("waiting for data …"); |
|
|
|
if (evt.target.readyState==0) return notice("waiting for data …"); |
|
|
|
if (evt.target.readyState==1) return notice("loading 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); |
|
|
|
reader.readAsText(file); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tobecreated = {}; |
|
|
|
function previewCreate() { |
|
|
|
function previewCreate() { |
|
|
|
var name = $('#name').val(); |
|
|
|
var name = $('#name').val(); |
|
|
|
var nodes = {}; |
|
|
|
var nodes = Object.create(tobecreated); |
|
|
|
nodes[name] = { |
|
|
|
if (name != '') { |
|
|
|
status: docker.containers.Status.Preview, |
|
|
|
nodes[name] = { |
|
|
|
id: null, |
|
|
|
status: docker.containers.Status.Preview, |
|
|
|
name: name, |
|
|
|
id: null, |
|
|
|
image: { |
|
|
|
name: name, |
|
|
|
name: $('#image').val(), |
|
|
|
image: { |
|
|
|
id: null |
|
|
|
name: $('#image').val(), |
|
|
|
}, |
|
|
|
id: null |
|
|
|
ports: $('#createports option').map(function() {return $(this).data();}).get(), |
|
|
|
}, |
|
|
|
env: $('#createvars option').map(function() {return $(this).val();}).get(), |
|
|
|
ports: $('#createports option').map(function() {return $(this).data();}).get(), |
|
|
|
volumes: $('#createvolumes option').map(function() {return $(this).data();}).get(), |
|
|
|
env: $('#createvars option').map(function() {return $(this).val();}).get(), |
|
|
|
volumesfrom: $('#createvolumefroms option').map(function() {return $(this).val();}).get(), |
|
|
|
volumes: $('#createvolumes option').map(function() {return $(this).data();}).get(), |
|
|
|
links: $('#createlinks option').map(function() {return $(this).data();}).get(), |
|
|
|
volumesfrom: $('#createvolumefroms option').map(function() {return $(this).val();}).get(), |
|
|
|
entrypoint: $('#createentrypoints option').map(function() {return $(this).val();}).get(), |
|
|
|
links: $('#createlinks option').map(function() {return $(this).data();}).get(), |
|
|
|
cmd: $('#createcommands option').map(function() {return $(this).val();}).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}")); |
|
|
|
$('#doappend').unbind().click(function() { |
|
|
|
|
|
|
|
tobecreated[name] = Object.create(nodes[name]); |
|
|
|
|
|
|
|
tobecreated[name].status = docker.containers.Status.Prepared; |
|
|
|
|
|
|
|
$('#createpreview').append('<option>'+name+'</option>'); |
|
|
|
|
|
|
|
$('#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() { |
|
|
|
function create() { |
|
|
@ -289,6 +355,11 @@ function stats(data) { |
|
|
|
function images(i) { |
|
|
|
function images(i) { |
|
|
|
console.log("->rcv images"); |
|
|
|
console.log("->rcv images"); |
|
|
|
docker.images.set(i); |
|
|
|
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) { |
|
|
|
function containers(c) { |
|
|
@ -490,7 +561,7 @@ function start() { |
|
|
|
|
|
|
|
|
|
|
|
function initForms() { |
|
|
|
function initForms() { |
|
|
|
$('#create form *').change(previewCreate); |
|
|
|
$('#create form *').change(previewCreate); |
|
|
|
$("#create form fieldset .add").click(function() { |
|
|
|
$("#create form fieldset .add").unbind().click(function() { |
|
|
|
$(this).siblings("select.collect") |
|
|
|
$(this).siblings("select.collect") |
|
|
|
.append('<option '+$(this).siblings("input") |
|
|
|
.append('<option '+$(this).siblings("input") |
|
|
|
.map(function() { |
|
|
|
.map(function() { |
|
|
@ -516,10 +587,13 @@ function initForms() { |
|
|
|
} |
|
|
|
} |
|
|
|
return sep+val; |
|
|
|
return sep+val; |
|
|
|
}).get().join('')+'</option>'); |
|
|
|
}).get().join('')+'</option>'); |
|
|
|
$(this).siblings("input").val(); |
|
|
|
$(this).siblings("input[type=text]").val(''); |
|
|
|
|
|
|
|
previewCreate(); |
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#create form fieldset .remove").unbind().click(function() { |
|
|
|
|
|
|
|
$(this).siblings('select.collect').children('option:selected').remove(); |
|
|
|
previewCreate(); |
|
|
|
previewCreate(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
//$("#preview").html(Viz("digraph {\nrankdir="+rankdir+";\n"+docker.containers.graph()+"\n}"));
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function init() { |
|
|
|
function init() { |
|
|
|