Files
webgui/plugins/dynamix.docker.manager/DockerContainers.page
bergware d0c14e3a28 Show "Update all Containers" button next to "Check for Updates" button
+added animation when complete list gets refreshed
2018-03-24 10:15:38 +01:00

131 lines
6.2 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.
*/
?>
<link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.ui.css">
<link type="text/css" rel="stylesheet" href="/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}
.log{cursor:zoom-in}
.exec{cursor:pointer}
.fa-custom{font-size:1.3em}
.iconstatus{position:absolute;z-index:2;bottom:-4px;right:-4px;font-size:1.2em;text-shadow:0 0 2px #FFF}
.iconstatus.started{font-size:1.3em}
.iconstatus.stopped{font-size:1.2em}
.started{color:#009900}
.stopped{color:#EF3D47}
.switch-button-label.off{color:inherit}
th.five{width:5%}
th.eight{width:8%}
</style>
<div id="dialog-confirm" style="display:none;" title="Dialog Title"></div>
<div id="iframe-popup" style="display:none;-webkit-overflow-scrolling:touch;"></div>
<span class="status" style="margin-top:-44px"><span><input type="checkbox" class="advancedview"></span></span>
<div class="spinner fixed"></div>
<table class="tablesorter shift" id="docker_containers">
<thead><tr><th></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="eight">Autostart</th><th class="five">Log</th><th class="five" style="text-align:right;padding-right:24px"><a href="#" style="cursor:hand" onclick="resetSorting()" title="Reset sorting"><i class="fa fa-sort"></i></a></th></tr></thead>
<tbody id="docker_list"><tr><td colspan='8'><div class="spinner"></div></td></tr></tbody>
</table>
<input type="button" onclick="addContainer()" value="Add Container" style="display:none">
<input type="button" onclick="startAll()" value="Start all Containers" style="display:none">
<input type="button" onclick="stopAll()" value="Stop all Containers" 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 Containers" 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 ($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() {
if ($.cookie('docker_listview_mode')=='advanced') {
$('.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>"});
}
}
function loadlist(update) {
$.get('/plugins/dynamix.docker.manager/include/DockerContainers.php',function(d) {
var data = d.split(/\0/);
$('div.spinner').hide('slow');
$('#docker_list').html(data[0]);
$('head').append('<script>'+data[1]+'<\/script>');
<?if ($display['resize']):?>
resize();
$(window).bind('resize',function(){resize(true);});
<?endif;?>
$('.autostart').switchButton({labels_placement:"right"});
$('.autostart').change(function() {
$.post( "/plugins/dynamix.docker.manager/include/UpdateConfig.php",{action:'autostart',container:$(this).attr('container'),response:'json'},function(data){$(this).prop('checked',data.autostart);},'json');
});
if ($.cookie('docker_listview_mode')=='advanced') {$('.advanced').show(); $('.basic').hide();}
listview();
context.init({preventDoubleContext:false});
$('input[type=button]').prop('disabled',false).show('slow');
if (!update) $('input#updateAll').hide();
$('i.up,i.down').click(function() {
var row = $(this).parents('tr:first');
var color1 = row.css('background-color');
if ($(this).is('.up')) {
var color2 = row.prev().css('background-color');
row.prev().css('background-color',color1);
row.css('background-color',color2);
row.insertBefore(row.prev());
} else {
var color2 = row.next().css('background-color');
row.next().css('background-color',color1);
row.css('background-color',color2);
row.insertAfter(row.next());
}
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});
});
});
}
$(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();
});
$.post('/plugins/dynamix.docker.manager/include/DockerUpdate.php',{},function(u){loadlist(u);});
});
</script>