Add luci
[librecmc/librecmc.git] / package / luci / modules / luci-base / 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 i
30                         for _, i in ipairs(n:get_interfaces() or { n:get_interface() }) do
31                                 checked[i:name()] = true
32                         end
33                 end
34         end
35 -%>
36
37 <input type="hidden" name="<%=cbeid%>" value="1" />
38
39 <div class="cbi-dropdown" display-items="5" placeholder="<%:-- please select -- %>"<%=
40         attr("name", cbid) ..
41         ifattr(self.widget == "checkbox", "multiple", "multiple") ..
42         ifattr(self.widget == "checkbox", "optional", "optional")
43 %>>
44         <script type="item-template"><!--
45                 <li value="{{value}}">
46                         <img title="<%:Custom Interface%>: &quot;{{value}}&quot;" src="<%=resource%>/icons/ethernet_disabled.png" />
47                         <span class="hide-open">{{value}}</span>
48                         <span class="hide-close"><%:Custom Interface%>: "{{value}}"</span>
49                 </li>
50         --></script>
51         <ul>
52                 <% for _, iface in ipairs(ifaces) do
53                         if (not self.nobridges  or not iface:is_bridge()) and
54                            (not self.noinactive or iface:is_up()) and
55                            iface:name() ~= self.exclude
56                         then %>
57                 <li<%=
58                         attr("value", iface:name()) ..
59                         ifattr(checked[iface:name()], "selected", "selected")
60                 %>>
61                         <img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
62                         <span class="hide-open"><%=pcdata(iface:name())%></span>
63                         <span class="hide-close">
64                                 <%=pcdata(iface:get_i18n())%>
65                                 <% local ns = iface:get_networks(); if #ns > 0 then %>(
66                                         <%- local i, n; for i, n in ipairs(ns) do -%>
67                                                 <%-= (i>1) and ', ' -%>
68                                                 <a href="<%=n:adminlink()%>"><%=n:name()%></a>
69                                         <%- end -%>
70                                 )<% end %>
71                         </span>
72                 </li>
73                 <% end end %>
74                 <% if not self.nocreate then %>
75                 <li value="">
76                         <img title="<%:Custom Interface%>" src="<%=resource%>/icons/ethernet_disabled.png" />
77                         <span><%:Custom Interface%>:</span>
78                         <input type="password" style="display:none" />
79                         <input class="create-item-input" type="text" />
80                 </li>
81                 <% end %>
82         </ul>
83 </div>
84
85 <%+cbi/valuefooter%>