2
0

buttons.htm 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <%# Copyright 2020 Stan Grishin <stangri@melmac.net> -%>
  2. <%+https-dns-proxy/css%>
  3. <%+https-dns-proxy/js%>
  4. <%-
  5. local packageName = "https-dns-proxy"
  6. local serviceRunning, serviceEnabled = false, false;
  7. serviceEnabled = luci.sys.init.enabled(packageName)
  8. local ubusStatus = luci.util.ubus("service", "list", { name = packageName })
  9. if ubusStatus and ubusStatus[packageName] then
  10. serviceRunning = true
  11. end
  12. if serviceEnabled then
  13. btn_start_status = true
  14. btn_action_status = true
  15. btn_stop_status = true
  16. btn_enable_status = false
  17. btn_disable_status = true
  18. else
  19. btn_start_status = false
  20. btn_action_status = false
  21. btn_stop_status = false
  22. btn_enable_status = true
  23. btn_disable_status = false
  24. end
  25. if serviceRunning then
  26. btn_start_status = false
  27. btn_action_status = true
  28. btn_stop_status = true
  29. else
  30. btn_action_status = false
  31. btn_stop_status = false
  32. end
  33. -%>
  34. <%+cbi/valueheader%>
  35. <div class="cbi-value-field">
  36. <input type="button" class="btn cbi-button cbi-button-apply" id="btn_start" name="start" value="<%:Start%>"
  37. onclick="button_action(this)" />
  38. <span id="btn_start_spinner" class="btn_spinner"></span>
  39. <input type="button" class="btn cbi-button cbi-button-apply" id="btn_action" name="action" value="<%:Reload%>"
  40. onclick="button_action(this)" />
  41. <span id="btn_action_spinner" class="btn_spinner"></span>
  42. <input type="button" class="btn cbi-button cbi-button-reset" id="btn_stop" name="stop" value="<%:Stop%>"
  43. onclick="button_action(this)" />
  44. <span id="btn_stop_spinner" class="btn_spinner"></span>
  45. &nbsp;
  46. &nbsp;
  47. &nbsp;
  48. &nbsp;
  49. <input type="button" class="btn cbi-button cbi-button-apply" id="btn_enable" name="enable" value="<%:Enable%>"
  50. onclick="button_action(this)" />
  51. <span id="btn_enable_spinner" class="btn_spinner"></span>
  52. <input type="button" class="btn cbi-button cbi-button-reset" id="btn_disable" name="disable" value="<%:Disable%>"
  53. onclick="button_action(this)" />
  54. <span id="btn_disable_spinner" class="btn_spinner"></span>
  55. </div>
  56. <%+cbi/valuefooter%>
  57. <%-if not btn_start_status then%>
  58. <script type="text/javascript">document.getElementById("btn_start").disabled = true;</script>
  59. <%-end%>
  60. <%-if not btn_action_status then%>
  61. <script type="text/javascript">document.getElementById("btn_action").disabled = true;</script>
  62. <%-end%>
  63. <%-if not btn_stop_status then%>
  64. <script type="text/javascript">document.getElementById("btn_stop").disabled = true;</script>
  65. <%-end%>
  66. <%-if not btn_enable_status then%>
  67. <script type="text/javascript">document.getElementById("btn_enable").disabled = true;</script>
  68. <%-end%>
  69. <%-if not btn_disable_status then%>
  70. <script type="text/javascript">document.getElementById("btn_disable").disabled = true;</script>
  71. <%-end%>