summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-banip/luasrc/view/banip/runtime.htm
blob: 410528130c49c3d14a9e40ff06e5823c695166c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<%#
Copyright 2018-2019 Dirk Brenken (dev@brenken.org)
This is free software, licensed under the Apache License, Version 2.0
-%>

<%+banip/banip_css%>
<script type="text/javascript">
//<![CDATA[
	function status_update(json)
	{
			var btn1         = document.getElementById("btn1");
			var btn1_running = document.getElementById("btn1_running");
			var view         = document.getElementById("value_1");
			var input        = json.data.status;

			btn1.value = "<%:Reload%>";
			btn1.name  = "do_reload";
			view.innerHTML = input || "-";
			if (input != "running")
			{
				btn1.disabled = false;
				running(btn1_running, 0);
			}
			view = document.getElementById("value_2");
			input = json.data.version;
			view.innerHTML = input || "-";
			view = document.getElementById("value_3");
			input = json.data.fetch_info;
			view.innerHTML = input || "-";
			view = document.getElementById("value_4");
			input = json.data.ipset_info;
			view.innerHTML = input || "-";
			view = document.getElementById("value_5");
			input = json.data.last_run;
			view.innerHTML = input || "-";
	}

function btn_action(action)
	{
		var btn1 = document.getElementById("btn1");
		var btn1_running = document.getElementById("btn1_running");

		btn1.disabled = true;
		running(btn1_running, 1);

		new XHR.get('<%=luci.dispatcher.build_url("admin", "services", "banip")%>/action/' + action.name, null,
		function(x)
		{
			if (!x)
			{
				return;
			}
		});
	}

	function running(element, state)
	{
		if (state === 1)
		{
			var running_html = '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" width="16" height="16" style="vertical-align:middle" />';
			element.innerHTML = running_html;
		}
		else
		{
			element.innerHTML = '';
		}
	}

	XHR.get('<%=luci.dispatcher.build_url("admin", "services", "banip", "status")%>', null,
	function(x, json_info)
	{
		if (!x || !json_info)
		{
			return;
		}
		status_update(json_info)
	});

	XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "services", "banip", "status")%>', null,
	function(x, json_info)
	{
		if (!x || !json_info)
		{
			return;
		}
		status_update(json_info)
	});
//]]>
</script>

<h3><%:Runtime Information%></h3>
<div class="cbi-value" id="status_1">
	<label class="cbi-value-title" for="status_1"><%:banIP Status%></label>
	<div class="cbi-value-field">
		<span class="runtime" id="value_1">-</span>
	</div>
</div>
<div class="cbi-value" id="status_2">
	<label class="cbi-value-title" for="status_2"><%:banIP Version%></label>
	<div class="cbi-value-field">
		<span class="runtime" id="value_2">-</span>
	</div>
</div>
<div class="cbi-value" id="status_3">
	<label class="cbi-value-title" for="status_3"><%:Download Utility (SSL Library)%></label>
	<div class="cbi-value-field">
		<span class="runtime" id="value_3">-</span>
	</div>
</div>
<div class="cbi-value" id="status_4">
	<label class="cbi-value-title" for="status_4"><%:IPSet Information%></label>
	<div class="cbi-value-field">
		<span class="runtime" id="value_4">-</span>
	</div>
</div>
<div class="cbi-value" id="status_5">
	<label class="cbi-value-title" for="status_5"><%:Last Run%></label>
	<div class="cbi-value-field">
		<span class="runtime" id="value_5">-</span>
	</div>
</div>
<hr />
<div class="cbi-value" id="button_1">
	<label class="cbi-value-title" for="button_1"><%:Reload IPSets%></label>
	<div class="cbi-value-field">
		<input class="cbi-button cbi-button-apply" id="btn1" type="button" name="do_reload" value="<%:Reload%>" onclick="btn_action(this)" />
		<span id="btn1_running" class="btn_running"></span>
	</div>
</div>