Merge pull request #3790 from PolynomialDivision/feature/luci-app-dawn
[project/luci.git] / applications / luci-app-simple-adblock / luasrc / view / simple-adblock / buttons.htm
1 <%#
2 Copyright 2019 Stan Grishin <stangri@melmac.net>
3 -%>
4
5 <%-
6 local packageName = "simple-adblock"
7 local enabledFlag = luci.model.uci.cursor():get(packageName, "config", "enabled")
8 if nixio.fs.access("/var/run/" .. packageName .. ".json") then
9 tmpfs = luci.jsonc.parse(luci.util.trim(luci.sys.exec("cat /var/run/" .. packageName .. ".json")))
10 end
11 local tmpfsVersion, tmpfsStatus, tmpfsMessage, tmpfsError, tmpfsStats = "", "Stopped"
12 if tmpfs and tmpfs['data'] then
13 if tmpfs['data']['status'] and tmpfs['data']['status'] ~= "" then
14 tmpfsStatus = tmpfs['data']['status']
15 end
16 if tmpfs['data']['message'] and tmpfs['data']['message'] ~= "" then
17 tmpfsMessage = tmpfs['data']['message']
18 end
19 if tmpfs['data']['error'] and tmpfs['data']['error'] ~= "" then
20 tmpfsError = tmpfs['data']['error']
21 end
22 if tmpfs['data']['stats'] and tmpfs['data']['stats'] ~= "" then
23 tmpfsStats = tmpfs['data']['stats']
24 end
25 if tmpfs['data']['version'] and tmpfs['data']['version'] ~= "" then
26 tmpfsVersion = " (" .. packageName .. " " .. tmpfs['data']['version'] .. ")"
27 end
28 end
29 if tmpfsStatus == "Stopped" then
30 btn_start_style = "cbi-button cbi-button-apply important"
31 btn_action_style = "cbi-button cbi-button-apply important"
32 btn_stop_style = "cbi-button cbi-button-reset -disabled"
33 else
34 btn_start_style = "cbi-button cbi-button-apply -disabled"
35 btn_action_style = "cbi-button cbi-button-apply important"
36 btn_stop_style = "cbi-button cbi-button-reset important"
37 end
38 if enabledFlag ~= "1" then
39 btn_start_style = "cbi-button cbi-button-apply -disabled"
40 btn_action_style = "cbi-button cbi-button-apply -disabled"
41 btn_enable_style = "cbi-button cbi-button-apply important"
42 btn_disable_style = "cbi-button cbi-button-reset -disabled"
43 else
44 btn_enable_style = "cbi-button cbi-button-apply -disabled"
45 btn_disable_style = "cbi-button cbi-button-reset important"
46 end
47 -%>
48
49 <%+simple-adblock/css%>
50 <%+simple-adblock/js%>
51
52 <div class="cbi-value"><label class="cbi-value-title">Service Control</label>
53 <div class="cbi-value-field">
54 <input type="button" class="<%=btn_start_style%>" id="btn_start" name="start" value="<%:Start%>" onclick="button_action(this)" />
55 <span id="btn_start_spinner" class="btn_spinner"></span>
56 <input type="button" class="<%=btn_action_style%>" id="btn_action" name="action" value="<%:Force Re-Download%>" onclick="button_action(this)" />
57 <span id="btn_action_spinner" class="btn_spinner"></span>
58 <input type="button" class="<%=btn_stop_style%>" id="btn_stop" name="stop" value="<%:Stop%>" onclick="button_action(this)" />
59 <span id="btn_stop_spinner" class="btn_spinner"></span>
60 &nbsp;
61 &nbsp;
62 &nbsp;
63 &nbsp;
64 <input type="button" class="<%=btn_enable_style%>" id="btn_enable" name="enable" value="<%:Enable%>" onclick="button_action(this)" />
65 <span id="btn_enable_spinner" class="btn_spinner"></span>
66 <input type="button" class="<%=btn_disable_style%>" id="btn_disable" name="disable" value="<%:Disable%>" onclick="button_action(this)" />
67 <span id="btn_disable_spinner" class="btn_spinner"></span>
68 </div>
69 </div>