apply_xhr.htm 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <% export("cbi_apply_xhr", function(id, configs, redirect) -%>
  2. <fieldset class="cbi-section" id="cbi-apply-<%=id%>">
  3. <legend><%:Applying changes%></legend>
  4. <script type="text/javascript">//<![CDATA[
  5. var apply_xhr = new XHR();
  6. apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "restart", table.concat(configs, ","))%>', null,
  7. function() {
  8. var checkfinish = function() {
  9. apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null,
  10. function(x) {
  11. if( x.responseText == 'finish' )
  12. {
  13. var e = document.getElementById('cbi-apply-<%=id%>-status');
  14. if( e )
  15. {
  16. e.innerHTML = '<%:Configuration applied.%>';
  17. window.setTimeout(function() {
  18. e.parentNode.style.display = 'none';
  19. <% if redirect then %>location.href='<%=redirect%>';<% end %>
  20. }, 1000);
  21. }
  22. }
  23. else
  24. {
  25. var e = document.getElementById('cbi-apply-<%=id%>-status');
  26. if( e && x.responseText ) e.innerHTML = x.responseText;
  27. window.setTimeout(checkfinish, 1000);
  28. }
  29. }
  30. );
  31. }
  32. window.setTimeout(checkfinish, 1000);
  33. }
  34. );
  35. //]]></script>
  36. <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
  37. <span id="cbi-apply-<%=id%>-status"><%:Waiting for changes to be applied...%></span>
  38. </fieldset>
  39. <%- end) %>