var eventURL = '/plugins/dynamix.docker.manager/include/Events.php'; function addDockerContainerContext(container, image, template, started, paused, update, autostart, webui, tswebui, shell, id, Support, Project, Registry, donateLink, ReadMe) { var opts = []; context.settings({right:false,above:false}); if (started && !paused) { if (webui !== '' && webui != '#') opts.push({text:_('WebUI'), icon:'fa-globe', action:function(e){e.preventDefault();window.open(webui,'_blank');}}); if (tswebui !== '' && tswebui != '#') opts.push({text:_('Tailscale WebUI'), icon:'fa-globe', action:function(e){e.preventDefault();window.open(tswebui,'_blank');}}); opts.push({text:_('Console'), icon:'fa-terminal', action:function(e){e.preventDefault(); openTerminal('docker',container,shell);}}); opts.push({divider:true}); } if (update==1) { opts.push({text:_('Update'), icon:'fa-cloud-download', action:function(e){e.preventDefault(); updateContainer(container);}}); opts.push({divider:true}); } if (started) { if (paused) { opts.push({text:_('Resume'), icon:'fa-play', action:function(e){e.preventDefault(); eventControl({action:'resume', container:id}, 'loadlist');}}); } else { opts.push({text:_('Stop'), icon:'fa-stop', action:function(e){e.preventDefault(); eventControl({action:'stop', container:id}, 'loadlist');}}); opts.push({text:_('Pause'), icon:'fa-pause', action:function(e){e.preventDefault(); eventControl({action:'pause', container:id}, 'loadlist');}}); } opts.push({text:_('Restart'), icon:'fa-refresh', action:function(e){e.preventDefault(); eventControl({action:'restart', container:id}, 'loadlist');}}); } else { opts.push({text:_('Start'), icon:'fa-play', action:function(e){e.preventDefault(); eventControl({action:'start', container:id}, 'loadlist');}}); } opts.push({divider:true}); opts.push({text:_('Logs'), icon:'fa-navicon', action:function(e){e.preventDefault(); openTerminal('docker',container,'.log');}}); if (template) { opts.push({text:_('Edit'), icon:'fa-wrench', action:function(e){e.preventDefault(); editContainer(container, template);}}); } opts.push({text:_('Remove'), icon:'fa-trash', action:function(e){e.preventDefault(); rmContainer(container, image, id);}}); if (ReadMe||Project||Support||Registry) { opts.push({divider:true}); } if (ReadMe) { opts.push({text:_('Read Me First'), icon:'fa-book', href:ReadMe, target:'_blank'}); } if (Project) { opts.push({text:_('Project Page'), icon:'fa-life-ring', href:Project, target:'_blank'}); } if (Support) { opts.push({text:_('Support'), icon:'fa-question', href:Support, target:'_blank'}); } if (Registry) { opts.push({text:_('More Info'),icon:'fa-info-circle', href:Registry, target:'_blank'}); } if (donateLink) { opts.push({divider:true}); opts.push({text:_('Donate'),icon:'fa-external-link', href:donateLink,target:'_blank'}); } context.destroy('#'+id); context.attach('#'+id, opts); } function addDockerImageContext(image, imageTag) { var opts = []; opts.push({text:_('Remove'), icon:'fa-trash', action:function(e){e.preventDefault(); rmImage(image, imageTag);}}); context.attach('#'+image, opts); } function popupWithIframe(title, cmd, reload, func) { pauseEvents(); $('#iframe-popup').html(''); $('#iframe-popup').dialog({ autoOpen:true, title:title, height: 'auto', width: 'auto', draggable: false, resizable:true, modal:true, open:function(ev, ui){ $('#myIframe').attr('src', cmd); }, close:function(event, ui){ if (reload && !$('#myIframe').contents().find('#canvas').length) { if (func) setTimeout(func+'()',0); else location = window.location.href; } else { resumeEvents(); } } }); $('.ui-dialog-titlebar-close').css({'display':'none'}); $('.ui-dialog-title').css({'text-align':'center','width':'100%','font-size':'1.8rem'}); $('.ui-dialog-content').css({'padding-top':'15px','vertical-align':'bottom'}); $('.ui-button-text').css({'padding':'0px 5px'}); } function execUpContainer(container) { var title = _('Updating the container TEST')+': '+container; var cmd = '/plugins/dynamix.docker.manager/include/CreateDocker.php?updateContainer=true&ct[]='+encodeURIComponent(container); popupWithIframe(title, cmd, true, 'loadlist'); } function addContainer() { var path = location.pathname; var x = path.indexOf('?'); if (x!=-1) path = path.substring(0,x); location = path+'/AddContainer'; } function editContainer(container, template) { var path = location.pathname; var x = path.indexOf('?'); if (x!=-1) path = path.substring(0, x); location = path+'/UpdateContainer?xmlTemplate=edit:'+template; } function updateContainer(container) { swal({ title:_('Are you sure?'),text:_('Update container')+': '+container, type:'warning',html:true,showCancelButton:true,closeOnConfirm:false,confirmButtonText:_('Yes, update it!'),cancelButtonText:_('Cancel') },function(){ openDocker('update_container '+encodeURIComponent(container),_('Updating the container'),'','loadlist'); }); } function rmContainer(container, image, id) { var body = _('Remove container')+': '+container+'

'; $('input[type=button]').prop('disabled',true); swal({ title:_('Are you sure?'),text:body,type:'warning',html:true,showCancelButton:true,confirmButtonText:_('Yes, delete it!'),cancelButtonText:_('Cancel'),showLoaderOnConfirm:true },function(c){ if (!c) {setTimeout(loadlist); return;} $('div.spinner.fixed').show('slow'); if ($('#removeimagechk').prop('checked')) { eventControl({action:'remove_all', container:id, name:container, image:image},'loadlist'); } else { eventControl({action:'remove_container', container:id, name:container},'loadlist'); } }); } function rmImage(image, imageName) { var body = _('Remove image')+': '+$('