8598dfe00623e42fe6df64013a0a61e5ac535b17
[project/luci.git] / libs / web / luasrc / view / cbi / apply_xhr.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 $Id$
12
13 -%>
14
15 <% export("cbi_apply_xhr", function(id, configs, redirect) -%>
16 <fieldset class="cbi-section" id="cbi-apply-<%=id%>">
17 <legend><%:Applying changes%></legend>
18 <script type="text/javascript">//<![CDATA[
19 var apply_xhr = new XHR();
20
21 apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "restart", table.concat(configs, ","))%>', null,
22 function() {
23 var checkfinish = function() {
24 apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null,
25 function(x) {
26 if( x.responseText == 'finish' )
27 {
28 var e = document.getElementById('cbi-apply-<%=id%>-status');
29 if( e )
30 {
31 e.innerHTML = '<%:Configuration applied.%>';
32 window.setTimeout(function() {
33 e.parentNode.style.display = 'none';
34 <% if redirect then %>location.href='<%=redirect%>';<% end %>
35 }, 1000);
36 }
37 }
38 else
39 {
40 var e = document.getElementById('cbi-apply-<%=id%>-status');
41 if( e && x.responseText ) e.innerHTML = x.responseText;
42
43 window.setTimeout(checkfinish, 1000);
44 }
45 }
46 );
47 }
48
49 window.setTimeout(checkfinish, 1000);
50 }
51 );
52 //]]></script>
53
54 <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
55 <span id="cbi-apply-<%=id%>-status"><%:Waiting for router...%></span>
56 </fieldset>
57 <%- end) %>