summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-banip/luasrc/view/banip/ipsetview.htm
blob: 22c1312a8fdaca6735d761b037e7d5aa7e8afb63 (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
<%#
Copyright 2018 Dirk Brenken (dev@brenken.org)
This is free software, licensed under the Apache License, Version 2.0
-%>

<%-
	local util   = require("luci.util")
	local ipsets = util.split(util.trim(util.exec("ipset -n -L 2>/dev/null | sort")), "\n", nil, true) or {}
-%>

<%+header%>
<%+banip/banip_css%>

<script type="text/javascript">
//<![CDATA[
	function ipset_view()
	{
		var div_ipsets = document.getElementById("div_ipsets");
		var ipset      = div_ipsets.querySelector("#s_ipsets").value;
		var filter     = document.getElementById("checkbox_filter").checked;
		var view       = document.getElementById("view_id");

		if (!ipset)
		{
			return;
		}
		view.value = "<%:Loading ...%>";

	new XHR().get('<%=luci.dispatcher.build_url("admin", "services", "banip")%>/ipsetview/' + ipset + "/" + filter, null,
		function(x)
		{
		if (!x)
			{
				view.value = "<%:No response!%>";
				return;
			}
			view.value = x.responseText;
		});
	}
//]]>
</script>

<div class="cbi-map">
	<div class="cbi-section">
		<div class="cbi-section-descr"><%:Check the current available IPSets.%></div>
		<div class="cbi-section-node">
			<div class="table cbi-section-table">
				<div class="tr cbi-section-table-row">
					<div class="td left">
						<input class="cbi-input-checkbox" data-update="click change" type="checkbox" id="checkbox_filter" name="checkbox_filter" value="1" checked="checked" />
						<label for="checkbox_filter"><%_Show only set member with packet counter &gt; 0%></label>
					</div>
				</div>
				<div class="tr cbi-section-table-row" id="div_ipsets">
					<div class="td left">
						<select id="s_ipsets" class="cbi-input-select cbi-button" style="width:15em">
							<%- for _, z in ipairs(ipsets) do -%><option value="<%=z%>"><%=z%></option><%- end -%>
						</select>
						<input type="button" id="bt_load" value="<%:Load%>" onclick="ipset_view()" class="cbi-button cbi-button-add" />
					</div>
				</div>
			</div>
		</div>
		<textarea id="view_id" readonly="readonly" wrap="off" value=""></textarea>
	</div>
</div>
<%+footer%>