luci-app-dockerman: view/dockerman: update coding style
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
25539b2d98
commit
833aebaa64
9 changed files with 609 additions and 631 deletions
|
@ -41,6 +41,7 @@
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
var xhr = new XHR(),
|
var xhr = new XHR(),
|
||||||
uci_apply_rollback = <%=math.max(luci.config and luci.config.apply and luci.config.apply.rollback or 30, 30)%>,
|
uci_apply_rollback = <%=math.max(luci.config and luci.config.apply and luci.config.apply.rollback or 30, 30)%>,
|
||||||
|
@ -49,7 +50,7 @@
|
||||||
uci_apply_display = <%=math.max(luci.config and luci.config.apply and luci.config.apply.display or 1.5, 1)%>,
|
uci_apply_display = <%=math.max(luci.config and luci.config.apply and luci.config.apply.display or 1.5, 1)%>,
|
||||||
was_xhr_poll_running = false;
|
was_xhr_poll_running = false;
|
||||||
|
|
||||||
function docker_status_message(type, content) {
|
function docker_status_message(type, content) {
|
||||||
document.getElementById('docker_apply_overlay') || document.body.insertAdjacentHTML("beforeend",'<div id="docker_apply_overlay"><div class="alert-message"></div></div>')
|
document.getElementById('docker_apply_overlay') || document.body.insertAdjacentHTML("beforeend",'<div id="docker_apply_overlay"><div class="alert-message"></div></div>')
|
||||||
var overlay = document.getElementById('docker_apply_overlay')
|
var overlay = document.getElementById('docker_apply_overlay')
|
||||||
message = overlay.querySelector('.alert-message');
|
message = overlay.querySelector('.alert-message');
|
||||||
|
@ -73,19 +74,20 @@ function docker_status_message(type, content) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
document.body.classList.remove('apply-overlay-active');
|
document.body.classList.remove('apply-overlay-active');
|
||||||
|
|
||||||
if (was_xhr_poll_running)
|
if (was_xhr_poll_running)
|
||||||
XHR.run();
|
XHR.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var loading_msg="Loading.."
|
|
||||||
function uci_confirm_docker() {
|
var loading_msg="Loading.."
|
||||||
|
function uci_confirm_docker() {
|
||||||
var tt;
|
var tt;
|
||||||
docker_status_message('notice');
|
docker_status_message('notice');
|
||||||
var call = function(r, resjson, duration) {
|
var call = function(r, resjson, duration) {
|
||||||
if (r && r.status === 200 ) {
|
if (r && r.status === 200 ) {
|
||||||
var indicator = document.querySelector('.uci_change_indicator');
|
var indicator = document.querySelector('.uci_change_indicator');
|
||||||
if (indicator) indicator.style.display = 'none';
|
if (indicator)
|
||||||
|
indicator.style.display = 'none';
|
||||||
docker_status_message('notice', '<%:Docker actions done.%>');
|
docker_status_message('notice', '<%:Docker actions done.%>');
|
||||||
document.body.classList.remove('apply-overlay-active');
|
document.body.classList.remove('apply-overlay-active');
|
||||||
window.clearTimeout(tt);
|
window.clearTimeout(tt);
|
||||||
|
@ -96,19 +98,21 @@ function uci_confirm_docker() {
|
||||||
var delay =1000
|
var delay =1000
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
xhr.get('<%=url("admin/docker/confirm")%>', null, call, uci_apply_timeout * 1000);
|
xhr.get('<%=url("admin/docker/confirm")%>', null, call, uci_apply_timeout * 1000);
|
||||||
}, delay);
|
},delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
var tick = function() {
|
var tick = function() {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
|
||||||
docker_status_message('notice',
|
docker_status_message(
|
||||||
'<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" /> <span style="white-space:pre-line; word-break:break-all; font-family: \'Courier New\', Courier, monospace;">' +
|
'notice',
|
||||||
loading_msg + '</span>');
|
'<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" /> <span style="white-space:pre-line; word-break:break-all; font-family: \'Courier New\', Courier, monospace;">' + loading_msg + '</span>'
|
||||||
|
);
|
||||||
|
|
||||||
tt = window.setTimeout(tick, 200);
|
tt = window.setTimeout(tick, 200);
|
||||||
ts = now;
|
ts = now;
|
||||||
};
|
};
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
/* wait a few seconds for the settings to become effective */
|
/* wait a few seconds for the settings to become effective */
|
||||||
window.setTimeout(call, Math.max(uci_apply_holdoff * 1000 , 1));
|
window.setTimeout(call, Math.max(uci_apply_holdoff * 1000 , 1));
|
||||||
|
@ -117,24 +121,27 @@ function uci_confirm_docker() {
|
||||||
// uci_confirm_docker()
|
// uci_confirm_docker()
|
||||||
// })
|
// })
|
||||||
|
|
||||||
function fnSubmitForm(el){
|
function fnSubmitForm(el){
|
||||||
if (el.id != "cbid.table.1._new") {
|
if (el.id != "cbid.table.1._new") {
|
||||||
uci_confirm_docker()
|
uci_confirm_docker()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<% if self.err then -%>
|
<% if self.err then -%>
|
||||||
docker_status_message('warning', '<span style="white-space:pre-line; word-break:break-all; font-family: \'Courier New\', Courier, monospace;">'+`<%=self.err%>`+'</span>');
|
docker_status_message('warning', '<span style="white-space:pre-line; word-break:break-all; font-family: \'Courier New\', Courier, monospace;">'+`<%=self.err%>`+'</span>');
|
||||||
document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
|
document.getElementById('docker_apply_overlay').addEventListener(
|
||||||
|
"click",
|
||||||
|
(e)=>{
|
||||||
docker_status_message()
|
docker_status_message()
|
||||||
})
|
}
|
||||||
<%- end %>
|
)
|
||||||
|
<%- end %>
|
||||||
|
|
||||||
window.onload= function (){
|
window.onload= function (){
|
||||||
var buttons = document.querySelectorAll('input[type="submit"]');
|
var buttons = document.querySelectorAll('input[type="submit"]');
|
||||||
[].slice.call(buttons).forEach(function (el) {
|
[].slice.call(buttons).forEach(function (el) {
|
||||||
el.onclick = fnSubmitForm.bind(this, el);
|
el.onclick = fnSubmitForm.bind(this, el);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//]]></script>
|
//]]></script>
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
document.getElementById("a-cbi-tab-container_" + item).href= path[0]+"/admin/docker/container/"+container_id+'/'+item
|
document.getElementById("a-cbi-tab-container_" + item).href= path[0]+"/admin/docker/container/"+container_id+'/'+item
|
||||||
if (action === item) {
|
if (action === item) {
|
||||||
document.getElementById("cbi-tab-container_" + item).className="cbi-tab"
|
document.getElementById("cbi-tab-container_" + item).className="cbi-tab"
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
document.getElementById("cbi-tab-container_" + item).className="cbi-tab-disabled"
|
document.getElementById("cbi-tab-container_" + item).className="cbi-tab-disabled"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
<div id="upload-container" class="cbi-value cbi-value-last">
|
<div id="upload-container" class="cbi-value cbi-value-last">
|
||||||
<label class="cbi-value-title" for="archive"><%:Upload%></label>
|
<label class="cbi-value-title" for="archive"><%:Upload%></label>
|
||||||
<div class="cbi-value-field">
|
<div class="cbi-value-field">
|
||||||
|
@ -15,6 +14,7 @@
|
||||||
<input type="button"" class="btn cbi-button cbi-button-action important" id="download" name="download" value="<%:Download%>" />
|
<input type="button"" class="btn cbi-button cbi-button-action important" id="download" name="download" value="<%:Download%>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
let btnUpload = document.getElementById('upload')
|
let btnUpload = document.getElementById('upload')
|
||||||
btnUpload.onclick = function (e) {
|
btnUpload.onclick = function (e) {
|
||||||
|
@ -22,9 +22,12 @@
|
||||||
let uploadPath = document.getElementById('path').value
|
let uploadPath = document.getElementById('path').value
|
||||||
if (!uploadArchive.value || !uploadPath) {
|
if (!uploadArchive.value || !uploadPath) {
|
||||||
docker_status_message('warning', "<%:Please input the PATH and select the file !%>")
|
docker_status_message('warning', "<%:Please input the PATH and select the file !%>")
|
||||||
document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
|
document.getElementById('docker_apply_overlay').addEventListener(
|
||||||
|
"click",
|
||||||
|
(e)=>{
|
||||||
docker_status_message()
|
docker_status_message()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let fileName = uploadArchive.files[0].name
|
let fileName = uploadArchive.files[0].name
|
||||||
|
@ -42,20 +45,27 @@
|
||||||
else {
|
else {
|
||||||
docker_status_message('warning', "<%:Upload Error%>:" + xhr.statusText)
|
docker_status_message('warning', "<%:Upload Error%>:" + xhr.statusText)
|
||||||
}
|
}
|
||||||
document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
|
document.getElementById('docker_apply_overlay').addEventListener(
|
||||||
|
"click",
|
||||||
|
(e)=>{
|
||||||
docker_status_message()
|
docker_status_message()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
xhr.send(formData)
|
xhr.send(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
let btnDownload = document.getElementById('download')
|
let btnDownload = document.getElementById('download')
|
||||||
btnDownload.onclick = function (e) {
|
btnDownload.onclick = function (e) {
|
||||||
let downloadPath = document.getElementById('path').value
|
let downloadPath = document.getElementById('path').value
|
||||||
if (!downloadPath) {
|
if (!downloadPath) {
|
||||||
docker_status_message('warning', "<%:Please input the PATH !%>")
|
docker_status_message('warning', "<%:Please input the PATH !%>")
|
||||||
document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
|
document.getElementById('docker_apply_overlay').addEventListener(
|
||||||
|
"click",
|
||||||
|
(e)=>{
|
||||||
docker_status_message()
|
docker_status_message()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
window.open('<%=luci.dispatcher.build_url("admin/docker/container_get_archive")%>?id=<%=self.container%>&path=' + encodeURIComponent(downloadPath))
|
window.open('<%=luci.dispatcher.build_url("admin/docker/container_get_archive")%>?id=<%=self.container%>&path=' + encodeURIComponent(downloadPath))
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
let last_bw_tx
|
let last_bw_tx
|
||||||
let last_bw_rx
|
let last_bw_rx
|
||||||
let interval = 3
|
let interval = 3
|
||||||
|
|
||||||
function progressbar(v, m, pc, np, f) {
|
function progressbar(v, m, pc, np, f) {
|
||||||
m = m || 100
|
m = m || 100
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
if (valISrc.value == "") {
|
if (valISrc.value == "") {
|
||||||
document.getElementById("file_import").click()
|
document.getElementById("file_import").click()
|
||||||
return
|
return
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
let formData = new FormData()
|
let formData = new FormData()
|
||||||
formData.append('src', valISrc.value)
|
formData.append('src', valISrc.value)
|
||||||
formData.append('tag', valITag.value)
|
formData.append('tag', valITag.value)
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
xhr.send(formData)
|
xhr.send(formData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileimport = document.getElementById('file_import')
|
let fileimport = document.getElementById('file_import')
|
||||||
fileimport.onchange = function (e) {
|
fileimport.onchange = function (e) {
|
||||||
let fileimport = document.getElementById('file_import')
|
let fileimport = document.getElementById('file_import')
|
||||||
|
@ -52,37 +54,51 @@
|
||||||
let new_tag = prompt("<%:New tag%>\n<%:Image%>" + "ID: " + image_id + "\n<%:Please input new tag%>:", "")
|
let new_tag = prompt("<%:New tag%>\n<%:Image%>" + "ID: " + image_id + "\n<%:Please input new tag%>:", "")
|
||||||
if (new_tag) {
|
if (new_tag) {
|
||||||
(new XHR()).post("<%=luci.dispatcher.build_url('admin/docker/images_tag')%>",
|
(new XHR()).post("<%=luci.dispatcher.build_url('admin/docker/images_tag')%>",
|
||||||
{ id: image_id, tag: new_tag },
|
{
|
||||||
|
id: image_id,
|
||||||
|
tag: new_tag
|
||||||
|
},
|
||||||
function (r) {
|
function (r) {
|
||||||
if (r.status == 201) {
|
if (r.status == 201) {
|
||||||
location.reload()
|
location.reload()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
docker_status_message('warning', 'Image: untagging ' + tag + '...fail code:' + r.status + r.statusText);
|
docker_status_message('warning', 'Image: untagging ' + tag + '...fail code:' + r.status + r.statusText);
|
||||||
document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
|
document.getElementById('docker_apply_overlay').addEventListener(
|
||||||
|
"click",
|
||||||
|
(e)=>{
|
||||||
docker_status_message()
|
docker_status_message()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let un_tag = function (tag) {
|
let un_tag = function (tag) {
|
||||||
if (tag.match("<none>")) return
|
if (tag.match("<none>"))
|
||||||
|
return
|
||||||
if (confirm("<%:Remove tag%>: " + tag + " ?")) {
|
if (confirm("<%:Remove tag%>: " + tag + " ?")) {
|
||||||
(new XHR()).post("<%=luci.dispatcher.build_url('admin/docker/images_untag')%>",
|
(new XHR()).post("<%=luci.dispatcher.build_url('admin/docker/images_untag')%>",
|
||||||
{ tag: tag },
|
{
|
||||||
|
tag: tag
|
||||||
|
},
|
||||||
function (r) {
|
function (r) {
|
||||||
if (r.status == 200) {
|
if (r.status == 200) {
|
||||||
location.reload()
|
location.reload()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
docker_status_message('warning', 'Image: untagging ' + tag + '...fail code:' + r.status + r.statusText);
|
docker_status_message('warning', 'Image: untagging ' + tag + '...fail code:' + r.status + r.statusText);
|
||||||
document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
|
document.getElementById('docker_apply_overlay').addEventListener(
|
||||||
|
"click",
|
||||||
|
(e)=>{
|
||||||
docker_status_message()
|
docker_status_message()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
document.getElementById("file_load").click()
|
document.getElementById("file_load").click()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileLoad = document.getElementById('file_load')
|
let fileLoad = document.getElementById('file_load')
|
||||||
fileLoad.onchange = function(e){
|
fileLoad.onchange = function(e){
|
||||||
let fileLoad = document.getElementById('file_load')
|
let fileLoad = document.getElementById('file_load')
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function close_reslov_dialog() {
|
function close_reslov_dialog() {
|
||||||
document.body.classList.remove('dialog-reslov-active')
|
document.body.classList.remove('dialog-reslov-active')
|
||||||
|
@ -57,16 +58,21 @@
|
||||||
|
|
||||||
function reslov_container() {
|
function reslov_container() {
|
||||||
let s = document.getElementById('cmd-line-status')
|
let s = document.getElementById('cmd-line-status')
|
||||||
if (!s) return
|
|
||||||
|
if (!s)
|
||||||
|
return
|
||||||
|
|
||||||
let cmd_line = document.getElementById("dialog_reslov_text").value;
|
let cmd_line = document.getElementById("dialog_reslov_text").value;
|
||||||
if (cmd_line == null || cmd_line == "") {
|
if (cmd_line == null || cmd_line == "") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_line = cmd_line.replace(/(^\s*)/g,"")
|
cmd_line = cmd_line.replace(/(^\s*)/g,"")
|
||||||
if (!cmd_line.match(/^docker\s+(run|create)/)) {
|
if (!cmd_line.match(/^docker\s+(run|create)/)) {
|
||||||
s.innerHTML = "<font color='red'><%:Command line Error%></font>"
|
s.innerHTML = "<font color='red'><%:Command line Error%></font>"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let reg_space = /\s+/g
|
let reg_space = /\s+/g
|
||||||
let reg_muti_line= /\\\s*\n/g
|
let reg_muti_line= /\\\s*\n/g
|
||||||
// reg_rem =/(?<!\\)`#.+(?<!\\)`/g // the command has `# `
|
// reg_rem =/(?<!\\)`#.+(?<!\\)`/g // the command has `# `
|
||||||
|
@ -90,6 +96,7 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<%+cbi/valueheader%>
|
<%+cbi/valueheader%>
|
||||||
|
|
||||||
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Command line%>" onclick="show_reslov_dialog()" />
|
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Command line%>" onclick="show_reslov_dialog()" />
|
||||||
|
|
||||||
<%+cbi/valuefooter%>
|
<%+cbi/valuefooter%>
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue