libs/web: align interface related widgets to changed network model api
[project/luci.git] / libs / web / 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="padding:0.5em">
21         <label style="background-color:<%=zone:get_color()%>; padding:0.4em">
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                         &#160;
31                         <%- if net:name() == self.network then -%>
32                                 <span style="background-color:#FFFFFF; border:1px solid #000000; padding:2px; font-weight:bold"><%=net:name()%>:
33                         <%- else -%>
34                                 <span style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:2px"><%=net:name()%>:
35                         <%- end -%>
36                         <%
37                                 local nempty = true
38                                 for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
39                                         nempty = false
40                          %>
41                                 <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" />
42                         <% end %>
43                         <% if nempty then %><em><%:(empty)%></em><% end %>
44                         </span>
45                 <% end end %>
46                 <% if zempty then %><em><%:(empty)%></em><% end %>
47         </label>
48         &#160;&#8658;&#160;
49         <% for _, fwd in ipairs(zone:get_forwardings_by("src")) do
50                 fz = fwd:dest_zone()
51                 empty = false %>
52                 <label style="background-color:<%=fz:get_color()%>; padding:0.4em">
53                         <strong><%=fz:name()%></strong>
54                 </label>&#160;
55         <% end %>
56         <% if empty then %>
57                 <label style="border:1px dashed #AAAAAA; color:#AAAAAA; padding:0.3em">
58                         <strong><small><em><%=zone:forward():upper()%></em></small></strong>
59                 </label>
60         <% end %>
61 </div>
62 <% end %>
63
64 <%+cbi/valuefooter%>