luci-base: cbi: further refactoring
[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
19 <% if zone then %>
20 <div style="white-space:nowrap">
21         <label class="zonebadge" style="background-color:<%=zone:get_color()%>">
22                 <strong><%=zone:name()%>:</strong>
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()%>:
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())%> style="width:16px; height:16px; vertical-align:middle" 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 %><em><%:(empty)%></em><% end -%>
42         </label>
43         &#160;&#8658;&#160;
44         <% for _, fwd in ipairs(zone:get_forwardings_by("src")) do
45                 fz = fwd:dest_zone()
46                 empty = false %>
47                 <label class="zonebadge" style="background-color:<%=fz:get_color()%>">
48                         <strong><%=fz:name()%></strong>
49                 </label>&#160;
50         <% end %>
51         <% if empty then %>
52                 <label class="zonebadge zonebadge-empty">
53                         <strong><%=zone:forward():upper()%></strong>
54                 </label>
55         <% end %>
56 </div>
57 <% end %>
58
59 <%+cbi/valuefooter%>