|
|
|
@ -1,4 +1,3 @@ |
|
|
|
|
|
|
|
|
|
function dPostOrgin(args, callback) { |
|
|
|
|
$.post('/plugins/run', args, function(data) { |
|
|
|
|
callback(data); |
|
|
|
@ -73,13 +72,13 @@ function logsCon(id){ |
|
|
|
|
title: 'Docker日志', |
|
|
|
|
area: '600px', |
|
|
|
|
closeBtn: 2, |
|
|
|
|
content:'<div class="bt-form">' |
|
|
|
|
+'<pre class="crontab-log" style="overflow: auto; \ |
|
|
|
|
content: '<div class="bt-form">' + |
|
|
|
|
'<pre class="crontab-log" style="overflow: auto; \ |
|
|
|
|
border: 0px none; line-height:23px;padding: 15px; \ |
|
|
|
|
margin: 0px; white-space: pre-wrap; height: 405px; \ |
|
|
|
|
background-color: rgb(51,51,51);color:#f1f1f1;\ |
|
|
|
|
border-radius:0px;">'+ (rdata.msg == '' ? 'No logs':rdata.msg) +'</pre>' |
|
|
|
|
+'</div>', |
|
|
|
|
border-radius:0px;">' + (rdata.msg == '' ? 'No logs' : rdata.msg) + '</pre>' + |
|
|
|
|
'</div>', |
|
|
|
|
success: function(index, layers) { |
|
|
|
|
$(".crontab-log").scrollTop(1000000); |
|
|
|
|
} |
|
|
|
@ -198,7 +197,7 @@ function createConTemplate(){ |
|
|
|
|
|
|
|
|
|
dPost('get_docker_create_info', '', {}, function(rdata) { |
|
|
|
|
var rdata = $.parseJSON(rdata.data); |
|
|
|
|
console.log(rdata); |
|
|
|
|
// console.log(rdata);
|
|
|
|
|
var rdata = rdata.data; |
|
|
|
|
var imageOpt = ''; |
|
|
|
|
for (var i = 0; i < rdata.images.length; i++) { |
|
|
|
@ -287,25 +286,21 @@ function createConTemplate(){ |
|
|
|
|
</div>\ |
|
|
|
|
</div>', |
|
|
|
|
success: function() { |
|
|
|
|
$(".bt-cancel").click(function(){ |
|
|
|
|
layer.close(layer_index); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".plus").click(function() { |
|
|
|
|
var name1 = $(".type-port input[name='name1']").val(); |
|
|
|
|
var name2 = $(".type-port input[name='name2']").val(); |
|
|
|
|
if (name1 < 1 || name1 > 65535 || name2 < 1 || name2 > 65535 || isNaN(name1) || isNaN(name2)) { |
|
|
|
|
layer.msg('Port setting value range is invalid, range [1-65535]',{icon:2}); |
|
|
|
|
layer.msg('端口设置值范围无效,范围 [1-65535]', { icon: 2 }); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var portval = $('#portabletr')[0].childNodes; |
|
|
|
|
for (var i = 0; i < portval.length; i++) { |
|
|
|
|
if(portval[i].childNodes[0].innerText == '当前未添加目录映射') continue; |
|
|
|
|
if (portval[i].childNodes[0].innerText == '当前未添加端口映射') continue; |
|
|
|
|
var sport = portval[i].childNodes[2].innerText; |
|
|
|
|
if (name2 == sport) { |
|
|
|
|
layer.msg('The port ['+name2+'] is already in the mapping list!',{icon:2}); |
|
|
|
|
layer.msg('端口 [' + name2 + '] 已在映射列表中!', { icon: 2 }); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -314,15 +309,22 @@ function createConTemplate(){ |
|
|
|
|
address = '*'; |
|
|
|
|
} |
|
|
|
|
var port = address + ':' + name2; |
|
|
|
|
var loadT = layer.msg('Testing <img src="/static/img/ing.gif">',{icon:16,time:0,shade: [0.3, "#000"]}); |
|
|
|
|
$.post('/plugin?action=a&name=docker&s=IsPortExists',{port:port},function(rdata){ |
|
|
|
|
var loadT = layer.msg('正在检测中... <img src="/static/img/ing.gif">', { icon: 16, time: 0, shade: [0.3, "#000"] }); |
|
|
|
|
dPost('docker_port_check', '',{port:port}, function(rdata){ |
|
|
|
|
layer.close(loadT); |
|
|
|
|
if(rdata !== false){ |
|
|
|
|
layer.msg('Port ['+name2+'] is already in the mapping list!',{icon:2}); |
|
|
|
|
var rdata = $.parseJSON(rdata.data); |
|
|
|
|
if (rdata.status){ |
|
|
|
|
layer.msg('端口 [' + name2 + ']已在映射列表中!', { icon: 2 }); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var selecttype = $(".type-port select").val(); |
|
|
|
|
var portable= '<tr><td>'+name1+'</td><td>'+selecttype+'</td><td>'+name2+'</td><td class="text-right" width="60"><a href="javascript:;" class="btlink minus">Del</a></td></tr>'; |
|
|
|
|
var portable = '<tr>\ |
|
|
|
|
<td>' + name1 + '</td>\ |
|
|
|
|
<td>' + selecttype + '</td>\ |
|
|
|
|
<td>' + name2 + '</td>\ |
|
|
|
|
<td class="text-right" width="60"><a href="javascript:;" class="btlink minus">删除</a></td>\ |
|
|
|
|
</tr>'; |
|
|
|
|
$("#portabletr").append(portable); |
|
|
|
|
$(".more1").remove(); |
|
|
|
|
$(".minus").click(function() { |
|
|
|
@ -342,10 +344,10 @@ function createConTemplate(){ |
|
|
|
|
} |
|
|
|
|
var portval = $('#portabletr2')[0].childNodes; |
|
|
|
|
for (var i = 0; i < portval.length; i++) { |
|
|
|
|
if(portval[i].childNodes[0].innerText == '当前未添加目录映射') continue; |
|
|
|
|
if (portval[i].childNodes[0].innerText == '当前未添加端口映射') continue; |
|
|
|
|
var sport = portval[i].childNodes[2].innerText; |
|
|
|
|
if (path2 == sport) { |
|
|
|
|
layer.msg('Directory ['+path2+'] is already in the mapping list!',{icon:2}); |
|
|
|
|
layer.msg('目录 [' + path2 + '] 已在映射列表中!', { icon: 2 }); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -353,7 +355,7 @@ function createConTemplate(){ |
|
|
|
|
var portable = '<tr>\ |
|
|
|
|
<td class="td_width_1" title="' + path1 + '">' + path1 + '</td>\ |
|
|
|
|
<td>' + selecttype + '</td><td title="' + path2 + '" class="td_width_1" style="max-width: 138px;">' + path2 + '</td>\ |
|
|
|
|
<td class="text-right" width="50"><a href="javascript:;" class="btlink minus2">Del</a></td>\ |
|
|
|
|
<td class="text-right" width="50"><a href="javascript:;" class="btlink minus2">删除</a></td>\ |
|
|
|
|
</tr>'; |
|
|
|
|
$("#portabletr2").append(portable); |
|
|
|
|
$(".more2").remove(); |
|
|
|
@ -374,26 +376,36 @@ function createConTemplate(){ |
|
|
|
|
|
|
|
|
|
//遍历端口映射
|
|
|
|
|
for (var i = 0; i < portval.length; i++) { |
|
|
|
|
// console.log(portval[i].childNodes[0].innerText);
|
|
|
|
|
|
|
|
|
|
if (portval[i].childNodes[0].innerText == '当前未添加端口映射') { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
var port = portval[i].childNodes[0].innerText.replace(/\s/g,''); |
|
|
|
|
var dport = port + '/' + portval[i].childNodes[1].innerText.toLowerCase().replace(/\s/g,''); |
|
|
|
|
var sport = [address,parseInt(portval[i].childNodes[2].innerText.replace(/\s/g,''))]; |
|
|
|
|
|
|
|
|
|
// console.log(i,portval[i].children[0].innerText);
|
|
|
|
|
// console.log(i,portval[i].childNodes[0].innerText);
|
|
|
|
|
|
|
|
|
|
var port = portval[i].children[0].innerText.replace(/\s/g, ''); |
|
|
|
|
var dport = port + '/' + portval[i].children[1].innerText.toLowerCase().replace(/\s/g, ''); |
|
|
|
|
var sport = [address, parseInt(portval[i].children[2].innerText.replace(/\s/g, ''))]; |
|
|
|
|
ports[dport] = sport |
|
|
|
|
accept.push(port); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//遍历目录映射
|
|
|
|
|
volumes['/sys/fs/cgroup'] = {'bind':'/sys/fs/cgroup', 'mode': 'rw'}; |
|
|
|
|
volumes['/sys/fs/cgroup'] = { |
|
|
|
|
'bind': '/sys/fs/cgroup', |
|
|
|
|
'mode': 'rw' |
|
|
|
|
}; |
|
|
|
|
for (var i = 0; i < portval2.length; i++) { |
|
|
|
|
if (portval2[i].childNodes[0].innerText.replace(/\s/g, ' ') == '当前未添加目录映射') { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
var dpath = portval2[i].childNodes[2].innerText.replace(/\s/g, ''); |
|
|
|
|
var spath = {'bind':portval2[i].childNodes[0].innerText.replace(/\s/g,''),'mode':portval2[i].childNodes[1].innerText.toLowerCase().replace(/\s/g,'')}; |
|
|
|
|
volumes[dpath] = spath |
|
|
|
|
var spath = { |
|
|
|
|
'bind': portval2[i].childNodes[0].innerText.replace(/\s/g, ''), |
|
|
|
|
'mode': portval2[i].childNodes[1].innerText.toLowerCase().replace(/\s/g, '') |
|
|
|
|
}; |
|
|
|
|
volumes[dpath] = spath; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var data = { |
|
|
|
@ -417,6 +429,8 @@ function createConTemplate(){ |
|
|
|
|
layer.msg('CPU配额设置值范围应为 [1-100]!', { icon: 2 }); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// console.log(data);
|
|
|
|
|
dPost('docker_create_con','', data, function(rdata){ |
|
|
|
|
var rdata = $.parseJSON(rdata.data); |
|
|
|
|
showMsg(rdata.msg,function(){ |
|
|
|
@ -749,7 +763,8 @@ function dockerImagePick(){ |
|
|
|
|
_tbody = '<tr><td colspan="5" align="center">当前无镜像</td></tr>'; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
var versionData = imageList[i].RepoTags,version,reg = new RegExp('((?<=:)[0-9A-z/.-]*)$'); |
|
|
|
|
var versionData = imageList[i].RepoTags, |
|
|
|
|
version, reg = new RegExp('((?<=:)[0-9A-z/.-]*)$'); |
|
|
|
|
version = versionData.match(reg); |
|
|
|
|
_tbody += "<tr><td><input data-name='" + imageList[i].RepoTags + "' type='checkbox' name='images'></td>\ |
|
|
|
|
<td><span class='max_span' title='" + imageList[i].RepoTags + "'>" + imageList[i].RepoTags + "</span></td>\ |
|
|
|
@ -781,7 +796,8 @@ function dockerImagePick(){ |
|
|
|
|
tableFixed('images_table'); |
|
|
|
|
}, |
|
|
|
|
yes: function(layers, index) { |
|
|
|
|
var data = '', tit = '\xa0', |
|
|
|
|
var data = '', |
|
|
|
|
tit = '\xa0', |
|
|
|
|
choose_num = $(".images_pull tbody [name=images]:checked").length; |
|
|
|
|
for (var i = 0; i < choose_num; i++) { |
|
|
|
|
if (choose_num == 0) { |
|
|
|
@ -997,8 +1013,7 @@ function repoLogin(){ |
|
|
|
|
|
|
|
|
|
function delRepo(address) { |
|
|
|
|
safeMessage('退出', '你将退出 [' + address + '],确定?', function() { |
|
|
|
|
dPost('docker_logout', '', |
|
|
|
|
{registry:address}, |
|
|
|
|
dPost('docker_logout', '', { registry: address }, |
|
|
|
|
function(rdata) { |
|
|
|
|
var rdata = $.parseJSON(rdata.data); |
|
|
|
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); |
|
|
|
@ -1037,6 +1052,7 @@ function repoListRender(){ |
|
|
|
|
$('#con_list tbody').html(list); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function repoList() { |
|
|
|
|
|
|
|
|
|
var con = '<div class="safe bgw">\ |
|
|
|
@ -1066,5 +1082,3 @@ function repoList(){ |
|
|
|
|
|
|
|
|
|
repoListRender(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|