-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathDockerContainers.page
More file actions
executable file
·224 lines (219 loc) · 10.5 KB
/
DockerContainers.page
File metadata and controls
executable file
·224 lines (219 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
Menu="Docker:1"
Title="Docker Containers"
Tag="cubes"
Cond="is_file('/var/run/dockerd.pid')"
Markdown="false"
Nchan="docker_load"
Tabs="false"
---
<?PHP
/* Copyright 2005-2025, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2014-2021, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* 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.
*/
?>
<?
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$width = $themeHelper->isTopNavTheme() ? -58: -44; // $themeHelper set in DefaultPageLayout.php
$top = $themeHelper->isTopNavTheme() ? 40 : 20;
$busy = "<i class='fa fa-spin fa-circle-o-notch'></i> <span class='font-sans'>"._('Please wait')."... "._('starting up containers')."</span>";
$cpus = cpu_list();
?>
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.switchbutton.css')?>">
<div class="ToggleViewMode"><span><input type="checkbox" class="advancedview"></span></div>
<div class="TableContainer">
<table id="docker_containers" class="tablesorter shift">
<thead>
<tr>
<th><a id="resetsort" class="nohand" onclick="resetSorting()" title="_(Reset sorting)_"><i class="fa fa-th-list"></i></a>_(Application)_</th>
<th>_(Version)_</th>
<th>_(Network)_</th>
<th>_(Container IP)_ <span class="advanced">/ _(MAC)_</span></th>
<th>_(Container Port)_</th>
<th>_(LAN IP:Port)_</th>
<th>_(Volume Mappings)_ <small>(_(App to Host)_)</small></th>
<th class="load advanced">_(CPU & Memory load)_</th>
<th class="nine">_(Autostart)_</th>
<th class="five">_(Uptime)_</th>
</tr>
</thead>
<tbody id="docker_list" class="js-fill-available-height"><tr><td colspan='10'></td></tr></tbody>
</table>
</div>
<div class="js-actions">
<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">
<input type="button" onclick="contSizes()" value="_(Container Size)_" style="display:none">
</div>
<div id="iframe-popup" style="display:none;-webkit-overflow-scrolling:touch;"></div>
<script src="<?autov('/webGui/javascript/jquery.switchbutton.js')?>"></script>
<script src="<?autov('/plugins/dynamix.docker.manager/javascript/docker.js')?>"></script>
<script>
var docker = [];
<?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:1.4rem;letter-spacing:2px'><?=$busy?></span>");
<?endif;?>
function resetSorting() {
if ($.cookie('lockbutton')==null) return;
$('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(($dockercfg['DOCKER_READMORE']??'yes') === 'yes'):?>
$('.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>"});
<?endif;?>
$('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();
});
}
function LockButton() {
if ($.cookie('lockbutton')==null) {
$.cookie('lockbutton','lockbutton');
$('#resetsort').removeClass('nohand').addClass('hand');
$('i.mover').show();
$('#docker_list .sortable').css({'cursor':'move'});
<?if ($themeHelper->isTopNavTheme()):?>
$('div.nav-item.LockButton').find('a').prop('title',"_(Lock sortable items)_");
$('div.nav-item.LockButton').find('b').removeClass('icon-u-lock green-text').addClass('icon-u-lock-open red-text');
<?endif;?>
$('div.nav-item.LockButton').find('span').text("_(Lock sortable items)_");
$('#docker_list').sortable({helper:'clone',items:'.sortable',cursor:'grab',axis:'y',containment:'parent',cancel:'span.docker_readmore,input',delay:100,opacity:0.5,zIndex:9999,forcePlaceholderSize:true,
update:function(e,ui){
var row = $('#docker_list').find('tr:first');
var names = ''; var index = '';
row.parent().children().find('td.ct-name').each(function(){names+=$(this).find('.appname').text()+';';index+=$(this).parent().parent().children().index($(this).parent())+';';});
$.post('/plugins/dynamix.docker.manager/include/UserPrefs.php',{names:names,index:index});
}});
} else {
$.removeCookie('lockbutton');
$('#resetsort').removeClass('hand').addClass('nohand');
$('i.mover').hide();
$('#docker_list .sortable').css({'cursor':'default'});
<?if ($themeHelper->isTopNavTheme()):?>
$('div.nav-item.LockButton').find('a').prop('title',"_(Unlock sortable items)_");
$('div.nav-item.LockButton').find('b').removeClass('icon-u-lock-open red-text').addClass('icon-u-lock green-text');
<?endif;?>
$('div.nav-item.LockButton').find('span').text("_(Unlock sortable items)_");
$('#docker_list').sortable('destroy');
}
}
function loadlist(init) {
timers.docker = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
docker = [];
$.get('/plugins/dynamix.docker.manager/include/DockerContainers.php',function(d) {
clearTimeout(timers.docker);
var data = d.split(/\0/);
$(".TS_tooltip").tooltipster("destroy");
$('#docker_list').html(data[0]);
$('.TS_tooltip').tooltipster({
animation: 'fade',
delay: 200,
trigger: 'custom',
triggerOpen: {click:true,touchstart:true,mouseenter:true},
triggerClose:{click:true,scroll:false,mouseleave:true},
interactive: true,
viewportAware: true,
contentAsHTML: true,
functionBefore: function(instance,helper) {
var origin = $(helper.origin);
var TScontent = $(origin).attr("data-tstitle");
instance.content(TScontent);
}
});
$('head').append('<script>'+data[1]+'<\/script>');
$('.iconstatus').each(function(){
if ($(this).hasClass('stopped')) $('div.'+$(this).prop('id')).hide();
});
$('.autostart').switchButton({labels_placement:'right', on_label:"_(On)_", off_label:"_(Off)_"});
$('.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();}
$('input[type=button]').prop('disabled',false).show('slow');
var update = false, rebuild = false;
for (var i=0,ct; ct=docker[i]; i++) {
if (ct.update==1) update = true;
if (ct.update==2) rebuild = true;
}
listview();
$('div.spinner.fixed').hide('slow');
if (data[2]==1) {$('#busy').show(); setTimeout(loadlist,5000);} else if ($('#busy').is(':visible')) {$('#busy').hide(); setTimeout(loadlist,3000);}
<?if (_var($display,'resize')):?>
function resizeTableColumns() { // Handle table header fixed positioning after resize
$('#docker_containers thead,#docker_containers tbody').removeClass('fixed');
$('#docker_containers thead tr th').each(function(){$(this).width($(this).width());});
$('#docker_containers tbody tr td').each(function(){$(this).width($(this).width());});
$('#docker_containers thead,#docker_containers tbody').addClass('fixed');
};
fillAvailableHeight({
targetElementSelector: '.js-fill-available-height',
elementSelectorsForHeight: [
'.js-actions',
'#docker_containers thead',
],
manualSpacingOffset: 30, // without this, the main content will still be scrollable by like 20px
});
resizeTableColumns()
if (init) {
$(window).bind('resize',function(){
resizeTableColumns();
});
}
<?endif;?>
if (!update) $('input#updateAll').prop('disabled',true);
if (rebuild) rebuildAll();
});
}
function contSizes() {
// show spinner over window
$('div.spinner.fixed').css({'z-index':'100000'}).show();
openPlugin('container_size', "_(Container Size)_");
}
var dockerload = new NchanSubscriber('/sub/dockerload',{subscriber:'websocket'});
dockerload.on('message', function(msg){
var data = msg.split('\n');
for (var i=0,row; row=data[i]; i++) {
var id = row.split(';');
var w1 = Math.round(Math.min(id[1].slice(0,-1)/<?=count($cpus)*count(preg_split('/[,-]/',$cpus[0]))?>,100)*100)/100+'%';
$('.cpu-'+id[0]).text(w1.replace('.','<?=_var($display,'number','.,')[0]?>'));
$('.mem-'+id[0]).text(id[2]);
$('#cpu-'+id[0]).css('width',w1);
}
});
$(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',$(this).is(':checked')?'advanced':'basic',{expires:3650});
listview();
});
$.removeCookie('lockbutton');
loadlist(true);
dockerload.start();
});
</script>