mirror of
https://github.com/unraid/webgui.git
synced 2026-01-14 05:30:07 -06:00
165 lines
8.1 KiB
Plaintext
165 lines
8.1 KiB
Plaintext
Menu="Docker:1"
|
|
Title="Docker Containers"
|
|
Tag="cubes"
|
|
Cond="(pgrep('dockerd')!==false)"
|
|
Markdown="false"
|
|
---
|
|
<?PHP
|
|
/* Copyright 2005-2018, Lime Technology
|
|
* Copyright 2014-2018, Guilherme Jardim, Eric Schultz, Jon Panozzo.
|
|
* Copyright 2012-2018, Bergware International.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License version 2,
|
|
* as published by the Free Software Foundation.
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*/
|
|
?>
|
|
<?
|
|
$width = strstr('white,black',$display['theme']) ? -58: -44;
|
|
$top = strstr('white,black',$display['theme']) ? 40 : 20;
|
|
$busy = "<i class='fa fa-spin fa-circle-o-notch'></i> Please wait... starting up containers";
|
|
?>
|
|
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.ui.css')?>">
|
|
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.switchbutton.css')?>">
|
|
<style>
|
|
.basic{display:block}
|
|
.advanced{display:none;white-space:nowrap}
|
|
body{-webkit-overflow-scrolling:touch}
|
|
img.started{opacity:1.0}
|
|
img.stopped{opacity:0.3}
|
|
img.paused{opacity:0.6}
|
|
.log{cursor:zoom-in}
|
|
.exec{cursor:pointer}
|
|
.iconstatus{position:absolute;z-index:2;bottom:-4px;right:-4px;font-size:1.3em;text-shadow:0 0 2px #FFF}
|
|
.started{color:#009900}
|
|
.stopped{color:#EF3D47}
|
|
.paused{color:#F0DD33}
|
|
.switch-button-label.off{color:inherit}
|
|
th.five{width:5%}
|
|
th.eight{width:8%}
|
|
th.load{width:100px}
|
|
tbody > tr.sortable:hover{cursor:move}
|
|
input.wait{width:24px;margin:0 4px;padding:0 5px;border:none;box-shadow:none;background-color:transparent}
|
|
</style>
|
|
<div id="iframe-popup" style="display:none;-webkit-overflow-scrolling:touch;"></div>
|
|
<span class="status" style="margin-top:<?=$width?>px"><span><input type="checkbox" class="advancedview"></span></span>
|
|
<table id="docker_containers" class="tablesorter shift">
|
|
<thead><tr><th><a href="#" style="cursor:hand;margin-left:12px" onclick="resetSorting()" title="Reset sorting"><i class="fa fa-th-list"></i></a></th><th>Application</th><th>Version</th><th>Network</th><th>Port Mappings <small>(App to Host)</small></th><th>Volume Mappings <small>(App to Host)</small></th><th class="load advanced">CPU load</th><th class="load advanced">Memory load</th><th class="eight">Autostart</th><th class="five">Log</th></tr></thead>
|
|
<tbody id="docker_list"><tr><td class="advanced"></td><td colspan='8'><div class="spinner"></div></td><td class="advanced"></td></tr></tbody>
|
|
</table>
|
|
<input type="button" onclick="addContainer()" value="Add Container" style="display:none">
|
|
<input type="button" onclick="startAll()" value="Start All" style="display:none">
|
|
<input type="button" onclick="stopAll()" value="Stop All" style="display:none">
|
|
<input type="button" onclick="pauseAll()" value="Pause All" style="display:none">
|
|
<input type="button" onclick="resumeAll()" value="Resume All" style="display:none">
|
|
<input type="button" onclick="checkAll()" value="Check for Updates" id="checkAll" style="display:none">
|
|
<input type="button" onclick="updateAll()" value="Update All" id="updateAll" style="display:none">
|
|
|
|
<script src="<?autov('/webGui/javascript/jquery.switchbutton.js')?>"></script>
|
|
<script src="<?autov('/plugins/dynamix.docker.manager/javascript/docker.js')?>"></script>
|
|
<script>
|
|
<?if (!$tabbed):?>
|
|
$('#title').append("<span id='busy' class='red-text strong' style='display:none;margin-left:40px'><?=$busy?></span>");
|
|
<?else:?>
|
|
$('.tabs').append("<span id='busy' class='red-text strong' style='display:none;position:relative;top:<?=$top?>px;left:40px;font-size:16px;letter-spacing:2px'><?=$busy?></span>");
|
|
<?endif;?>
|
|
<?if ($display['resize']):?>
|
|
function resize(bind) {
|
|
var width = [];
|
|
var h = $('#docker_list').height();
|
|
var s = Math.max(window.innerHeight-300,370);
|
|
if (h>s || bind) {
|
|
$('#docker_list').height(s);
|
|
$('#docker_containers tbody tr:first-child td').each(function(){width.push($(this).width());});
|
|
$('#docker_containers thead tr th').each(function(i){$(this).width(width[i]);});
|
|
if (!bind) $('#docker_containers thead,#docker_containers tbody').addClass('fixed');
|
|
}
|
|
}
|
|
<?endif;?>
|
|
function resetSorting() {
|
|
$('input[type=button]').prop('disabled',true);
|
|
$.post('/plugins/dynamix.docker.manager/include/UserPrefs.php',{reset:true},function(){loadlist();});
|
|
}
|
|
function listview() {
|
|
var more = $.cookie('docker_listview_mode')=='advanced';
|
|
if (more) {
|
|
$('.docker_readmore').readmore('destroy');
|
|
} else {
|
|
$('.docker_readmore').readmore({maxHeight:32,moreLink:"<a href='#' style='text-align:center'><i class='fa fa-chevron-down'></i></a>",lessLink:"<a href='#' style='text-align:center'><i class='fa fa-chevron-up'></i></a>"});
|
|
}
|
|
$('input.autostart').each(function(){
|
|
var wait = $('#'+$(this).prop('id').replace('auto','wait'));
|
|
var auto = $(this).prop('checked');
|
|
if (auto && more) wait.show(); else wait.hide();
|
|
});
|
|
}
|
|
var sortableHelper = function(e,i){
|
|
i.children().each(function(){
|
|
$(this).width($(this).width());
|
|
});
|
|
return i;
|
|
};
|
|
function loadlist() {
|
|
$.get('/plugins/dynamix.docker.manager/include/DockerContainers.php',function(d) {
|
|
var data = d.split(/\0/);
|
|
$('div.spinner').hide('slow').remove();
|
|
$('#docker_list').html(data[0]).sortable({helper:sortableHelper,items:'tr.sortable',opacity:0.4,update:function(e,i){
|
|
var row = $('#docker_list').find('tr:first');
|
|
var names = ''; var index = '';
|
|
row.parent().children().find('td.ct-name').each(function(){names+=$(this).text().replace(/Container ID.*$/,'')+';';index+=$(this).parent().parent().children().index($(this).parent())+';';});
|
|
$.post('/plugins/dynamix.docker.manager/include/UserPrefs.php',{names:names,index:index});
|
|
}});
|
|
$('head').append('<script>'+data[1]+'<\/script>');
|
|
<?if ($display['resize']):?>
|
|
resize();
|
|
$(window).bind('resize',function(){resize(true);});
|
|
<?endif;?>
|
|
$('.iconstatus').each(function(){
|
|
if ($(this).hasClass('stopped')) $('div.'+$(this).prop('id')).hide();
|
|
});
|
|
$('.autostart').switchButton({labels_placement:'right'});
|
|
$('.autostart').change(function(){
|
|
var more = $.cookie('docker_listview_mode')=='advanced';
|
|
var wait = $('#'+$(this).prop('id').replace('auto','wait'));
|
|
var auto = $(this).prop('checked');
|
|
if (auto && more) wait.show(); else wait.hide();
|
|
$.post('/plugins/dynamix.docker.manager/include/UpdateConfig.php',{action:'autostart',container:$(this).attr('container'),auto:auto,wait:wait.find('input.wait').val()});
|
|
});
|
|
$('input.wait').change(function(){
|
|
$.post('/plugins/dynamix.docker.manager/include/UpdateConfig.php',{action:'wait',container:$(this).attr('container'),wait:$(this).val()});
|
|
});
|
|
if ($.cookie('docker_listview_mode')=='advanced') {$('.advanced').show(); $('.basic').hide();}
|
|
context.init({preventDoubleContext:false});
|
|
$('input[type=button]').prop('disabled',false).show('slow');
|
|
var update = false;
|
|
for (var i=0,ct; ct=docker[i]; i++) if (ct.update=='false') {update = true; break;};
|
|
if (!update) $('input#updateAll').hide();
|
|
listview();
|
|
if (data[2]==1) {$('#busy').show(); setTimeout(loadlist,5000);} else if ($('#busy').is(':visible')) {$('#busy').hide(); setTimeout(loadlist,3000);}
|
|
});
|
|
}
|
|
var watchDocker = new NchanSubscriber('/sub/dockerload', /^((?!chrome|android).)*safari/i.test(navigator.userAgent) ? {subscriber:'longpoll'} : {});
|
|
watchDocker.on('message', function(data){
|
|
data = data.split('\n');
|
|
for (var i=0,row; row=data[i]; i++) {
|
|
var id = row.split(' ');
|
|
$('#cpu-'+id[0]).css('width',id[1]).text(id[1].replace('.','<?=$display['number'][0]?>'));
|
|
$('#mem-'+id[0]).css('width',id[2]).text(id[2].replace('.','<?=$display['number'][0]?>'));
|
|
}
|
|
});
|
|
$(function() {
|
|
$('.advancedview').switchButton({labels_placement:'left', on_label:'Advanced View', off_label:'Basic View', checked:$.cookie('docker_listview_mode')=='advanced'});
|
|
$('.advancedview').change(function(){
|
|
$('.advanced').toggle('slow');
|
|
$('.basic').toggle('slow');
|
|
$.cookie('docker_listview_mode',$('.advancedview').is(':checked')?'advanced':'basic',{expires:3650});
|
|
listview();
|
|
});
|
|
loadlist();
|
|
watchDocker.start();
|
|
});
|
|
</script>
|