summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm
blob: b38e4b13dbd229a5267e44904260b3860fe87efe (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
<%+cbi/valueheader%>

<%-
	local utl = require "luci.util"
	local fwm = require "luci.model.firewall".init()
	local nwm = require "luci.model.network".init()

	local zone, fwd, fz
	local value = self:formvalue(section)
	if not value or value == "-" then
		value = self:cfgvalue(section) or self.default
	end

	local def  = fwm:get_defaults()
	local zone = fwm:get_zone(value)
	local empty = true

	local function render_zone(zone)
-%>
		<label class="zonebadge" style="background-color:<%=zone:get_color()%>">
			<strong><%=zone:name()%></strong>
			<div class="cbi-tooltip">
			<%-
				local zempty = true
				for _, net in ipairs(zone:get_networks()) do
					net = nwm:get_network(net)
					if net then
						zempty = false
			-%>
				<span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:&#160;
				<%
					local nempty = true
					for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
						nempty = false
				 %>
					<img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
				<% end %>
				<% if nempty then %><em><%:(empty)%></em><% end %>
				</span>
			<%- end end -%>
			<% if zempty then %><span class="ifacebadge"><em><%:(empty)%></em></span><% end %>
			</div>
		</label>
<%-
	end
-%>

<% if zone then %>
<div class="zone-forwards">
	<div class="zone-src">
		<%=render_zone(zone)%>
	</div>
	<span>&#8658;</span>
	<div class="zone-dest">
	<%
		for _, fwd in ipairs(zone:get_forwardings_by("src")) do
			fz = fwd:dest_zone()
			if fz then
				empty = false
				render_zone(fz)
			end
		end
		if empty then
	%>
		<label class="zonebadge zonebadge-empty">
			<strong><%=zone:forward():upper()%></strong>
		</label>
	<% end %>
	</div>
</div>
<% end %>

<%+cbi/valuefooter%>