luci-app-simple-adblock: bugfix: template layout on theme-openwrt-2020
[project/luci.git] / applications / luci-app-simple-adblock / luasrc / view / simple-adblock / buttons.htm
1 <%# Copyright 2020 Stan Grishin <stangri@melmac.net> -%>
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 if nixio.fs.access("/var/run/" .. packageName .. ".json") then
11 tmpfs = luci.jsonc.parse(luci.util.trim(luci.sys.exec("cat /var/run/" .. packageName .. ".json")))
12 if tmpfs and tmpfs['data'] and tmpfs['data']['status'] then
13 tmpfsStatus = tmpfs['data']['status']
14 end
15 end
16 if tmpfsStatus == "statusStarting" or tmpfsStatus == "statusRestarting" or
17 tmpfsStatus == "statusForceReloading" or tmpfsStatus == "statusDownloading" or
18 tmpfsStatus == "statusError" or tmpfsStatus == "statusWarning"
19 or tmpfsStatus == "statusSuccess" then
20 serviceRunning = true
21 end
22
23 if luci.model.uci.cursor():get(packageName, "config", "enabled") == "1" then
24 serviceEnabled = true
25 end
26
27 if serviceEnabled then
28 btn_start_status = true
29 btn_action_status = true
30 btn_stop_status = true
31 btn_enable_status = false
32 btn_disable_status = true
33 else
34 btn_start_status = false
35 btn_action_status = false
36 btn_stop_status = false
37 btn_enable_status = true
38 btn_disable_status = false
39 end
40 if serviceRunning then
41 btn_start_status = false
42 btn_action_status = true
43 btn_stop_status = true
44 else
45 btn_action_status = false
46 btn_stop_status = false
47 end
48 -%>
49
50 <%+cbi/valueheader%>
51 <div class="cbi-value-field">
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 &nbsp;
62 &nbsp;
63 &nbsp;
64 &nbsp;
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 </div>
72 <%+cbi/valuefooter%>
73
74 <%-if not btn_start_status then%>
75 <script type="text/javascript">document.getElementById("btn_start").disabled = true;</script>
76 <%-end%>
77 <%-if not btn_action_status then%>
78 <script type="text/javascript">document.getElementById("btn_action").disabled = true;</script>
79 <%-end%>
80 <%-if not btn_stop_status then%>
81 <script type="text/javascript">document.getElementById("btn_stop").disabled = true;</script>
82 <%-end%>
83 <%-if not btn_enable_status then%>
84 <script type="text/javascript">document.getElementById("btn_enable").disabled = true;</script>
85 <%-end%>
86 <%-if not btn_disable_status then%>
87 <script type="text/javascript">document.getElementById("btn_disable").disabled = true;</script>
88 <%-end%>