Merge pull request #5430 from jeje42/feature/luci-app-openvpn-add-tls_crypt_v2-option
[project/luci.git] / applications / luci-app-simple-adblock / luasrc / view / simple-adblock / buttons.htm
1 <%# Copyright 2020 Stan Grishin <stangri@melmac.ca> -%>
2
3 <%+simple-adblock/css%>
4 <%+simple-adblock/js%>
5
6 <%-
7 local packageName = "simple-adblock"
8 local serviceRunning, serviceEnabled = false, false;
9 local tmpfs, tmpfsStatus;
10 local jsonStatusFile = "/var/run/" .. packageName .. "/" .. packageName .. ".json"
11 if nixio.fs.access(jsonStatusFile) then
12 tmpfs = luci.jsonc.parse(luci.util.trim(luci.sys.exec("cat " .. jsonStatusFile)))
13 if tmpfs and tmpfs['data'] and tmpfs['data']['status'] then
14 tmpfsStatus = tmpfs['data']['status']
15 end
16 end
17 if tmpfsStatus == "statusStarting" or tmpfsStatus == "statusRestarting" or
18 tmpfsStatus == "statusForceReloading" or tmpfsStatus == "statusDownloading" or
19 tmpfsStatus == "statusError" or tmpfsStatus == "statusWarning"
20 or tmpfsStatus == "statusSuccess" then
21 serviceRunning = true
22 end
23
24 if luci.model.uci.cursor():get(packageName, "config", "enabled") == "1" then
25 serviceEnabled = true
26 end
27
28 if serviceEnabled then
29 btn_start_status = true
30 btn_action_status = true
31 btn_stop_status = true
32 btn_enable_status = false
33 btn_disable_status = true
34 else
35 btn_start_status = false
36 btn_action_status = false
37 btn_stop_status = false
38 btn_enable_status = true
39 btn_disable_status = false
40 end
41 if serviceRunning then
42 btn_start_status = false
43 btn_action_status = true
44 btn_stop_status = true
45 else
46 btn_action_status = false
47 btn_stop_status = false
48 end
49 -%>
50
51 <%+cbi/valueheader%>
52 <input type="button" class="btn cbi-button cbi-button-apply" id="btn_start" name="start" value="<%:Start%>"
53 onclick="button_action(this)" />
54 <span id="btn_start_spinner" class="btn_spinner"></span>
55 <input type="button" class="btn cbi-button cbi-button-apply" id="btn_action" name="action" value="<%:Force Re-Download%>"
56 onclick="button_action(this)" />
57 <span id="btn_action_spinner" class="btn_spinner"></span>
58 <input type="button" class="btn cbi-button cbi-button-reset" id="btn_stop" name="stop" value="<%:Stop%>"
59 onclick="button_action(this)" />
60 <span id="btn_stop_spinner" class="btn_spinner"></span>
61 &#160;
62 &#160;
63 &#160;
64 &#160;
65 <input type="button" class="btn cbi-button cbi-button-apply" id="btn_enable" name="enable" value="<%:Enable%>"
66 onclick="button_action(this)" />
67 <span id="btn_enable_spinner" class="btn_spinner"></span>
68 <input type="button" class="btn cbi-button cbi-button-reset" id="btn_disable" name="disable" value="<%:Disable%>"
69 onclick="button_action(this)" />
70 <span id="btn_disable_spinner" class="btn_spinner"></span>
71 <%+cbi/valuefooter%>
72
73 <%-if not btn_start_status then%>
74 <script type="text/javascript">document.getElementById("btn_start").disabled = true;</script>
75 <%-end%>
76 <%-if not btn_action_status then%>
77 <script type="text/javascript">document.getElementById("btn_action").disabled = true;</script>
78 <%-end%>
79 <%-if not btn_stop_status then%>
80 <script type="text/javascript">document.getElementById("btn_stop").disabled = true;</script>
81 <%-end%>
82 <%-if not btn_enable_status then%>
83 <script type="text/javascript">document.getElementById("btn_enable").disabled = true;</script>
84 <%-end%>
85 <%-if not btn_disable_status then%>
86 <script type="text/javascript">document.getElementById("btn_disable").disabled = true;</script>
87 <%-end%>