19ff059449e0e8eafa2da2f4b1d223f4fa72dddd
[project/luci.git] / libs / web / luasrc / view / cbi / firewall_zonelist.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, net, iface
9         local zones = fwm:get_zones()
10         local value = self:formvalue(section)
11         if not value or value == "-" then
12                 value = self:cfgvalue(section) or self.default
13         end
14
15         local selected = false
16         local checked = { }
17
18         for value in utl.imatch(value) do
19                 checked[value] = true
20         end
21
22         if not next(checked) then
23                 checked[""] = true
24         end
25 -%>
26
27 <ul style="margin:0; list-style-type:none; text-align:left">
28         <% if self.allowlocal then %>
29         <li style="padding:0.5em">
30                 <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_empty") .. attr("name", cbid) .. attr("value", "") .. ifattr(checked[""], "checked", "checked")%> /> &#160;
31                 <label<%=attr("for", cbid .. "_empty")%> style="background-color:<%=fwm.zone.get_color()%>; padding:0.5em">
32                         <strong><%:Device%></strong> (<%:input%>)
33                 </label>
34         </li>
35         <% end %>
36         <% if self.allowany then %>
37         <li style="padding:0.5em">
38                 <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_any") .. attr("name", cbid) .. attr("value", "*") .. ifattr(checked["*"], "checked", "checked")%> /> &#160;
39                 <label<%=attr("for", cbid .. "_any")%> style="background-color:<%=fwm.zone.get_color()%>; padding:0.5em">
40                         <strong><%:Any zone%></strong> (<%:forward%>)
41                 </label>
42         </li>
43         <% end %>
44         <%
45                 for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do
46                         if zone:name() ~= self.exclude then
47                                 selected = selected or (value == zone:name())
48         %>
49         <li style="padding:0.5em">
50                 <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> /> &#160;
51                 <label<%=attr("for", cbid .. "." .. zone:name())%> style="background-color:<%=zone:get_color()%>; padding:0.5em">
52                         <strong><%=zone:name()%>:</strong>
53                         <%
54                                 local zempty = true
55                                 for _, net in ipairs(zone:get_networks()) do
56                                         net = nwm:get_network(net)
57                                         if net then
58                                                 zempty = false
59                         %>
60                                 &#160;
61                                 <%- if net:name() == self.network then -%>
62                                         <span style="background-color:#FFFFFF; border:1px solid #000000; padding:2px; font-weight:bold"><%=net:name()%>:
63                                 <%- else -%>
64                                         <span style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:2px"><%=net:name()%>:
65                                 <%- end -%>
66                                 <%
67                                         local nempty = true
68                                         for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
69                                                 nempty = false
70                                  %>
71                                         <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" />
72                                 <% end %>
73                                 <% if nempty then %><em><%:(empty)%></em><% end %>
74                                 </span>
75                         <% end end %>
76                         <% if zempty then %><em><%:(empty)%></em><% end %>
77                 </label>
78         </li>
79         <% end end %>
80
81         <% if self.widget ~= "checkbox" and not self.nocreate then %>
82         <li style="padding:0.5em">
83                 <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> /> &#160;
84                 <div style="background-color:<%=fwm.zone.get_color()%>; padding:0.5em; display:inline">
85                         <label<%=attr("for", cbid .. "_new")%>><em><%:unspecified -or- create:%>&#160;</em></label>
86                         <input style="width:6em" type="text"<%=attr("name", cbid .. ".newzone") .. ifattr(not selected, "value", luci.http.formvalue(cbid .. ".newzone") or self.default)%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
87                 </div>
88         </li>
89         <% end %>
90 </ul>
91
92 <%+cbi/valuefooter%>