mirror of
https://github.com/unraid/webgui.git
synced 2026-03-14 15:01:42 -05:00
Docker Manager: updates from gfjardim and revamped vm settings
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
function addDockerContainerContext(container, image, template, started, update, autostart, webui){
|
||||
var eventURL = "/plugins/dynamix.docker.manager/include/Events.php";
|
||||
|
||||
function addDockerContainerContext(container, image, template, started, update, autostart, webui, id){
|
||||
var opts = [{header: container, image: "/plugins/dynamix.docker.manager/images/dynamix.docker.manager.png"}];
|
||||
if (started && (webui != "#")) {
|
||||
opts.push({text: 'WebUI', icon:'fa-globe', href: webui, target: '_blank' });
|
||||
@@ -9,20 +11,20 @@ function addDockerContainerContext(container, image, template, started, update,
|
||||
opts.push({divider: true});
|
||||
}
|
||||
if (started){
|
||||
opts.push({text: 'Stop', icon:'fa-stop', action: function(e){ e.preventDefault(); containerControl(container, 'stop'); }});
|
||||
opts.push({text: 'Restart', icon:'fa-refresh', action: function(e){ e.preventDefault(); containerControl(container, 'restart'); }});
|
||||
opts.push({text: 'Stop', icon:'fa-stop', action: function(e){ e.preventDefault(); containerControl(id, 'stop', true); }});
|
||||
opts.push({text: 'Restart', icon:'fa-refresh', action: function(e){ e.preventDefault(); containerControl(id, 'restart', true); }});
|
||||
} else {
|
||||
opts.push({text: 'Start', icon:'fa-play', action: function(e){ e.preventDefault(); containerControl(container, 'start'); }});
|
||||
opts.push({text: 'Start', icon:'fa-play', action: function(e){ e.preventDefault(); containerControl(id, 'start', true); }});
|
||||
}
|
||||
opts.push({divider: true});
|
||||
if (location.pathname.indexOf("/Dashboard") === 0) {
|
||||
opts.push({text: 'Logs', icon:'fa-navicon', action: function(e){ e.preventDefault(); containerLogs(container); }});
|
||||
opts.push({text: 'Logs', icon:'fa-navicon', action: function(e){ e.preventDefault(); containerLogs(container, id); }});
|
||||
}
|
||||
if (template) {
|
||||
opts.push({text: 'Edit', icon:'fa-wrench', action: function(e){ e.preventDefault(); editContainer(container, template); }});
|
||||
}
|
||||
opts.push({divider: true});
|
||||
opts.push({text: 'Remove', icon:'fa-trash', action: function(e){ e.preventDefault(); rmContainer(container, image); }});
|
||||
opts.push({text: 'Remove', icon:'fa-trash', action: function(e){ e.preventDefault(); rmContainer(container, image, id); }});
|
||||
context.attach('#context-'+container, opts);
|
||||
}
|
||||
|
||||
@@ -86,23 +88,9 @@ function editContainer(container, template) {
|
||||
location = path + '/UpdateContainer?xmlTemplate=edit:' + template;
|
||||
}
|
||||
|
||||
function rmContainer(containers, images){
|
||||
var ctCmd = "/plugins/dynamix.docker.manager/scripts/docker rm -f";
|
||||
var imgCmd = "/plugins/dynamix.docker.manager/scripts/docker rmi";
|
||||
var ctTitle = "";
|
||||
if (typeof containers === "object") {
|
||||
for (var i = 0; i < containers.length; i++) {
|
||||
ctCmd += " " + containers[i];
|
||||
imgCmd += " " + images[i];
|
||||
ctTitle += containers[i] + "<br>";
|
||||
}
|
||||
} else {
|
||||
ctCmd += " " + containers;
|
||||
imgCmd += " " + images;
|
||||
ctTitle += containers + "<br>";
|
||||
}
|
||||
var title = 'Removing container';
|
||||
$( "#dialog-confirm" ).html(ctTitle);
|
||||
function rmContainer(container, image, id){
|
||||
var title = 'Removing container: '+ container;
|
||||
$( "#dialog-confirm" ).html('');
|
||||
$( "#dialog-confirm" ).append( "<br><span style='color: #E80000;'>Are you sure?</span>" );
|
||||
$( "#dialog-confirm" ).dialog({
|
||||
title: title,
|
||||
@@ -114,13 +102,12 @@ function rmContainer(containers, images){
|
||||
buttons: {
|
||||
"Just the container": function() {
|
||||
$( this ).dialog( "close" );
|
||||
var cmd = '/plugins/dynamix.docker.manager/include/Exec.php?cmd=' + encodeURIComponent(ctCmd);
|
||||
popupWithIframe(title, cmd, true);
|
||||
containerControl(id, 'remove_container', true);
|
||||
},
|
||||
"Container and image": function() {
|
||||
$( this ).dialog( "close" );
|
||||
var cmd = '/plugins/dynamix.docker.manager/include/Exec.php?cmd=' + encodeURIComponent(ctCmd + ";" + imgCmd);
|
||||
popupWithIframe(title, cmd, true);
|
||||
containerControl(id, 'remove_container', false);
|
||||
imageControl(image, "remove_image", true);
|
||||
},
|
||||
Cancel: function() {
|
||||
$( this ).dialog( "close" );
|
||||
@@ -134,20 +121,12 @@ function rmContainer(containers, images){
|
||||
$(".ui-button-text").css('padding','0px 5px');
|
||||
}
|
||||
|
||||
function updateContainer(containers){
|
||||
var ctCmd ="";
|
||||
function updateContainer(container){
|
||||
var ctCmd = "&ct[]=" + encodeURIComponent(container);
|
||||
var ctTitle = "";
|
||||
if (typeof containers === "object") {
|
||||
for (var i = 0; i < containers.length; i++) {
|
||||
ctCmd += "&ct[]=" + encodeURIComponent(containers[i]);
|
||||
ctTitle += containers[i] + "<br>";
|
||||
}
|
||||
} else {
|
||||
ctCmd += "&ct[]=" + encodeURIComponent(containers);
|
||||
ctTitle += containers + "<br>";
|
||||
}
|
||||
var title = 'Updating container';
|
||||
$( "#dialog-confirm" ).html(ctTitle);
|
||||
|
||||
var title = 'Updating container: '+container;
|
||||
$( "#dialog-confirm" ).html('');
|
||||
$( "#dialog-confirm" ).append( "<br><span style='color: #E80000;'>Are you sure?</span>" );
|
||||
$( "#dialog-confirm" ).dialog({
|
||||
title: title,
|
||||
@@ -175,20 +154,10 @@ function updateContainer(containers){
|
||||
$( ".ui-dialog .ui-dialog-title" ).css( 'width', "100%");
|
||||
}
|
||||
|
||||
function rmImage(images, imageName){
|
||||
var imgCmd = "/plugins/dynamix.docker.manager/scripts/docker rmi";
|
||||
var imgTitle = "";
|
||||
if (typeof images === "object") {
|
||||
for (var i = 0; i < images.length; i++) {
|
||||
imgCmd += " " + images[i];
|
||||
imgTitle += imageName[i] + "<br>";
|
||||
}
|
||||
} else {
|
||||
imgCmd += " " + images;
|
||||
imgTitle += imageName + "<br>";
|
||||
}
|
||||
var title = "Removing image";
|
||||
$( "#dialog-confirm" ).html(imgTitle);
|
||||
function rmImage(image, imageName){
|
||||
var imageName = $('<textarea />').html(imageName).text();
|
||||
var title = "Removing image: "+imageName;
|
||||
$( "#dialog-confirm" ).html('');
|
||||
$( "#dialog-confirm" ).append( "<br><span style='color: #E80000;'>Are you sure?</span>" );
|
||||
$( "#dialog-confirm" ).dialog({
|
||||
title: title,
|
||||
@@ -201,8 +170,7 @@ function rmImage(images, imageName){
|
||||
buttons: {
|
||||
"Just do it!": function() {
|
||||
$( this ).dialog( "close" );
|
||||
var cmd = '/plugins/dynamix.docker.manager/include/Exec.php?cmd=' + encodeURIComponent(imgCmd);
|
||||
popupWithIframe(title, cmd, true);
|
||||
imageControl(image, "remove_image", true);
|
||||
},
|
||||
Cancel: function() {
|
||||
$( this ).dialog( "close" );
|
||||
@@ -217,11 +185,24 @@ function rmImage(images, imageName){
|
||||
$( ".ui-dialog .ui-dialog-title" ).css( 'width', "100%");
|
||||
}
|
||||
|
||||
function containerControl(container, action){
|
||||
$("#cmdStartStop").val("/plugins/dynamix.docker.manager/scripts/docker");
|
||||
$("#cmdArg1").val(action);
|
||||
$("#cmdArg2").val(container);
|
||||
$("#formStartStop").submit();
|
||||
function imageControl(image, action, reload){
|
||||
if (typeof reload == undefined) reload = true
|
||||
$.post(eventURL,{action:action, image:image},function(data){
|
||||
if(data.success === true) {
|
||||
if (reload) location.reload();
|
||||
} else {
|
||||
alert("Error:\n\n"+data.success);
|
||||
}},"json");
|
||||
}
|
||||
|
||||
function containerControl(container, action, reload){
|
||||
if (typeof reload == undefined) reload = true
|
||||
$.post(eventURL,{action:action, container:container},function(data){
|
||||
if(data.success === true) {
|
||||
if (reload) location.reload();
|
||||
} else {
|
||||
alert("Error:\n\n"+data.success);
|
||||
}},"json");
|
||||
}
|
||||
|
||||
function reloadUpdate(){
|
||||
@@ -237,6 +218,13 @@ function autoStart(container, event){
|
||||
$("#formStartStop").submit();
|
||||
}
|
||||
|
||||
function containerLogs(container){
|
||||
openWindow('/plugins/dynamix.docker.manager/scripts/docker&arg1=logs&arg2=--tail=350&arg3=-f&arg4=' + container, 'Log for: ' + container, 600, 900);
|
||||
function containerLogs(container, id){
|
||||
var height = 600;
|
||||
var width = 900;
|
||||
var run = eventURL+'?action=log&container='+id+'&title=Log for: '+container;
|
||||
var top = (screen.height-height)/2;
|
||||
var left = (screen.width-width)/2;
|
||||
var options = 'resizeable=yes,scrollbars=yes,height='+height+',width='+width+',top='+top+',left='+left;
|
||||
window.open(run, 'log', options);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user