4 local utl = require "luci.util"
5 local fwm = require "luci.model.firewall".init()
6 local nwm = require "luci.model.network".init()
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
15 local selected = false
18 for value in utl.imatch(value) do
22 if not next(checked) then
27 <div class="cbi-dropdown" dropdown-items="5" placeholder="<%:-- please select -- %>"<%=
29 ifattr(self.widget == "checkbox", "multiple", "multiple") ..
30 ifattr(self.rmempty or self.optional, "optional", "optional")
32 <script type="item-template"><!--
33 <li data-value="{{value}}">
34 <span class="zonebadge" style="background:repeating-linear-gradient(45deg,rgba(204,204,204,0.5),rgba(204,204,204,0.5) 5px,rgba(255,255,255,0.5) 5px,rgba(255,255,255,0.5) 10px)">
35 <strong>{{value}}:</strong><em>(<%:create%>)</em>
40 <% if self.allowlocal then %>
41 <li data-value=""<%=ifattr(checked[""], "selected", "selected")%>>
42 <span style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
43 <strong><%:Device%></strong>
44 <% if self.allowany and self.allowlocal then -%>
45 (<%= self.alias ~= "dest"
46 and translate("output") or translate("input") %>)
50 <% elseif self.widget ~= "checkbox" and (self.rmempty or self.optional) then %>
51 <li data-value=""<%=ifattr(checked[""], "selected", "selected")%>>
52 <span class="zonebadge">
53 <em><%:unspecified%></em>
57 <% if self.allowany then %>
58 <li data-value="*"<%=ifattr(checked["*"], "selected", "selected")%>>
59 <span style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
60 <strong><%:Any zone%></strong>
61 <% if self.allowany and self.allowlocal then %>(<%:forward%>)<% end %>
66 for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do
67 if zone:name() ~= self.exclude then
68 selected = selected or (value == zone:name())
70 <li<%=attr("data-value", zone:name()) .. ifattr(checked[zone:name()], "selected", "selected")%>>
71 <span style="background-color:<%=zone:get_color()%>" class="zonebadge">
72 <strong><%=zone:name()%>:</strong>
75 for _, net in ipairs(zone:get_networks()) do
76 net = nwm:get_network(net)
80 <span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:
83 for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
86 <img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
88 <% if nempty then %><em><%:(empty)%></em><% end -%>
91 <%- if zempty then %><em><%:(empty)%></em><% end -%>
96 <% if self.widget ~= "checkbox" and not self.nocreate then %>
98 <span class="zonebadge">
100 <input type="password" style="display:none" />
101 <input class="create-item-input" type="text" data-type="and(uciname,maxlength(11))" data-optional="true" />