1 <style type=
"text/css">
2 #docker_apply_overlay {
8 background: rgba(
0,
0,
0,
0.7);
13 #docker_apply_overlay .alert-message {
24 #docker_apply_overlay .alert-message
> h4,
25 #docker_apply_overlay .alert-message
> p,
26 #docker_apply_overlay .alert-message
> div {
30 #docker_apply_overlay .alert-message
> img {
35 body.apply-overlay-active {
40 body.apply-overlay-active #docker_apply_overlay {
44 <script type=
"text/javascript">//<![CDATA[
46 uci_apply_rollback = <%=math.max(luci.config and luci.config.apply and luci.config.apply.rollback or
30,
30)%
>,
47 uci_apply_holdoff = <%=math.max(luci.config and luci.config.apply and luci.config.apply.holdoff or
4,
1)%
>,
48 uci_apply_timeout = <%=math.max(luci.config and luci.config.apply and luci.config.apply.timeout or
5,
1)%
>,
49 uci_apply_display = <%=math.max(luci.config and luci.config.apply and luci.config.apply.display or
1.5,
1)%
>,
50 was_xhr_poll_running = false;
52 function docker_status_message(type, content) {
53 document.getElementById('docker_apply_overlay') || document.body.insertAdjacentHTML(
"beforeend",'
<div id=
"docker_apply_overlay"><div class=
"alert-message"></div></div>')
54 var overlay = document.getElementById('docker_apply_overlay')
55 message = overlay.querySelector('.alert-message');
57 if (message && type) {
58 if (!message.classList.contains(type)) {
59 message.classList.remove('notice');
60 message.classList.remove('warning');
61 message.classList.add(type);
65 message.innerHTML = content;
67 document.body.classList.add('apply-overlay-active');
68 document.body.scrollTop = document.documentElement.scrollTop =
0;
69 if (!was_xhr_poll_running) {
70 was_xhr_poll_running = XHR.running();
75 document.body.classList.remove('apply-overlay-active');
77 if (was_xhr_poll_running)
81 var
loading_msg=
"Loading.."
82 function uci_confirm_docker() {
84 docker_status_message('notice');
85 var call = function(r, resjson, duration) {
86 if (r && r.status ===
200 ) {
87 var indicator = document.querySelector('.uci_change_indicator');
88 if (indicator) indicator.style.display = 'none';
89 docker_status_message('notice', '<%:Docker actions done.%
>');
90 document.body.classList.remove('apply-overlay-active');
91 window.clearTimeout(tt);
94 loading_msg = resjson?resjson.info:loading_msg
95 // var delay = isNaN(duration) ?
0 : Math.max(
1000 - duration,
0);
97 window.setTimeout(function() {
98 xhr.get('<%=url(
"admin/docker/confirm")%
>', null, call, uci_apply_timeout *
1000);
102 var tick = function() {
103 var now = Date.now();
105 docker_status_message('notice',
106 '
<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;">' +
107 loading_msg + '
</span>');
109 tt = window.setTimeout(tick,
200);
113 /* wait a few seconds for the settings to become effective */
114 window.setTimeout(call, Math.max(uci_apply_holdoff *
1000 ,
1));
116 // document.getElementsByTagName(
"form")[
0].addEventListener(
"submit", (e)=
>{
117 // uci_confirm_docker()
120 function fnSubmitForm(el){
121 if (el.id !=
"cbid.table.1._new") {
126 <% if self.err then -%
>
127 docker_status_message('warning', '
<span style=
"white-space:pre-line; word-break:break-all; font-family: \'Courier New\', Courier, monospace;">'+`<%=self.err%
>`+'
</span>');
128 document.getElementById('docker_apply_overlay').addEventListener(
"click", (e)=
>{
129 docker_status_message()
133 window.onload= function (){
134 var buttons = document.querySelectorAll('input[
type=
"submit"]');
135 [].slice.call(buttons).forEach(function (el) {
136 el.onclick = fnSubmitForm.bind(this, el);