treewide: move templates and libraries not used by the core to luci-compat
[project/luci.git] / modules / luci-compat / luasrc / view / cbi / network_ifacelist.htm
1 <%+cbi/valueheader%>
2
3 <%-
4 local utl = require "luci.util"
5 local net = require "luci.model.network".init()
6 local cbeid = luci.cbi.FEXIST_PREFIX .. self.config .. "." .. section .. "." .. self.option
7
8 local iface
9 local ifaces = net:get_interfaces()
10 local value
11
12 if self.map:formvalue(cbeid) == "1" then
13 value = self:formvalue(section) or self.default or ""
14 else
15 value = self:cfgvalue(section) or self.default
16 end
17
18 local checked = { }
19
20 if value then
21 for value in utl.imatch(value) do
22 for value in utl.imatch(value) do
23 checked[value] = true
24 end
25 end
26 else
27 local n = self.network and net:get_network(self.network)
28 if n then
29 local a = n:is_alias()
30 if a then
31 checked['@' .. a] = true
32 else
33 local i
34 for _, i in ipairs(n:get_interfaces() or { n:get_interface() }) do
35 checked[i:name()] = true
36 end
37 end
38 end
39 end
40 -%>
41
42 <input type="hidden" name="<%=cbeid%>" value="1" />
43
44 <div class="cbi-dropdown" display-items="10" placeholder="<%:-- please select -- %>"<%=
45 attr("name", cbid) ..
46 ifattr(self.widget == "checkbox", "multiple", "multiple") ..
47 ifattr(self.widget == "checkbox", "optional", "optional")
48 %>>
49 <script type="item-template"><!--
50 <li data-value="{{value}}">
51 <img title="<%:Custom Interface%>: &quot;{{value}}&quot;" src="<%=resource%>/icons/ethernet_disabled.png" />
52 <span class="hide-open">{{value}}</span>
53 <span class="hide-close"><%:Custom Interface%>: "{{value}}"</span>
54 </li>
55 --></script>
56 <ul>
57 <% for _, iface in ipairs(ifaces) do
58 if (not self.noaliases or iface:type() ~= "alias") and
59 (not self.nobridges or not iface:is_bridge()) and
60 (not self.noinactive or iface:is_up()) and
61 iface:name() ~= self.exclude
62 then %>
63 <li<%=
64 attr("data-value", iface:name()) ..
65 ifattr(checked[iface:name()], "selected", "selected")
66 %>>
67 <img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
68 <span class="hide-open"><%=pcdata(iface:name())%></span>
69 <span class="hide-close">
70 <%=pcdata(iface:get_i18n())%>
71 <% local ns = iface:get_networks(); if #ns > 0 then %>(
72 <%- local i, n; for i, n in ipairs(ns) do -%>
73 <%-= (i>1) and ', ' -%>
74 <a href="<%=n:adminlink()%>"><%=n:name()%></a>
75 <%- end -%>
76 )<% end %>
77 </span>
78 </li>
79 <% end end %>
80 <% if not self.nocreate then %>
81 <li data-value="">
82 <img title="<%:Custom Interface%>" src="<%=resource%>/icons/ethernet_disabled.png" />
83 <span><%:Custom Interface%>:</span>
84 <input type="password" style="display:none" />
85 <input class="create-item-input" type="text" />
86 </li>
87 <% end %>
88 </ul>
89 </div>
90
91 <%+cbi/valuefooter%>