Merge pull request #2193 from rosysong/freespace
[project/luci.git] / modules / luci-base / luasrc / view / cbi / firewall_zoneforwards.htm
1 <%+cbi/valueheader%>
2
3 <%-
4 local utl = require "luci.util"
5 local fwm = require "luci.model.firewall".init()
6 local nwm = require "luci.model.network".init()
7
8 local zone, fwd, fz
9 local value = self:formvalue(section)
10 if not value or value == "-" then
11 value = self:cfgvalue(section) or self.default
12 end
13
14 local def = fwm:get_defaults()
15 local zone = fwm:get_zone(value)
16 local empty = true
17
18 local function render_zone(zone)
19 -%>
20 <label class="zonebadge" style="background-color:<%=zone:get_color()%>">
21 <strong><%=zone:name()%></strong>
22 <div class="cbi-tooltip">
23 <%-
24 local zempty = true
25 for _, net in ipairs(zone:get_networks()) do
26 net = nwm:get_network(net)
27 if net then
28 zempty = false
29 -%>
30 <span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:&#160;
31 <%
32 local nempty = true
33 for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
34 nempty = false
35 %>
36 <img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
37 <% end %>
38 <% if nempty then %><em><%:(empty)%></em><% end %>
39 </span>
40 <%- end end -%>
41 <% if zempty then %><span class="ifacebadge"><em><%:(empty)%></em></span><% end %>
42 </div>
43 </label>
44 <%-
45 end
46 -%>
47
48 <% if zone then %>
49 <div class="zone-forwards">
50 <div class="zone-src">
51 <%=render_zone(zone)%>
52 </div>
53 <span>&#8658;</span>
54 <div class="zone-dest">
55 <%
56 for _, fwd in ipairs(zone:get_forwardings_by("src")) do
57 fz = fwd:dest_zone()
58 if fz then
59 empty = false
60 render_zone(fz)
61 end
62 end
63 if empty then
64 %>
65 <label class="zonebadge zonebadge-empty">
66 <strong><%=def:forward():upper()%></strong>
67 </label>
68 <% end %>
69 </div>
70 </div>
71 <% end %>
72
73 <%+cbi/valuefooter%>