0dc93f9687a2fae8d36f08f20ea89466c6952a08
[project/luci.git] / libs / web / 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
7 local iface
8 local ifaces = net:get_interfaces()
9 local value = self:formvalue(section)
10
11 if not value or value == "" then
12 value = self:cfgvalue(section) or self.default
13 end
14
15 local checked = { }
16
17 if value then
18 for value in utl.imatch(value) do
19 checked[value] = true
20 end
21 else
22 local n = self.network and net:get_network(self.network)
23 if n then
24 local i
25 for _, i in ipairs(n:get_interfaces()) do
26 checked[i:name()] = true
27 end
28 end
29 end
30 -%>
31
32 <ul style="margin:0; list-style-type:none">
33 <% for _, iface in ipairs(ifaces) do
34 local link = iface:adminlink()
35 if (not self.nobridges or not iface:is_bridge()) and iface:name() ~= self.exclude then %>
36 <li>
37 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
38 attr("type", self.widget or "radio") ..
39 attr("id", cbid .. "." .. iface:name()) ..
40 attr("name", cbid) .. attr("value", iface:name()) ..
41 ifattr(checked[iface:name()], "checked", "checked") ..
42 ifattr(iface:type() == "wifi" and not iface:is_up(), "disabled", "disabled")
43 %> /> &#160;
44 <label<%=attr("for", cbid .. "." .. iface:name())%>>
45 <% if link then -%><a href="<%=link%>"><% end -%>
46 <img title="<%=iface:get_type_i18n()%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
47 <% if link then -%></a><% end -%>
48 <%=iface:get_i18n()%><% local n = iface:get_network(); if n then %> (<a href="<%=n:adminlink()%>"><%=n:name()%></a>)<% end %>
49 </label>
50 </li>
51 <% end end %>
52 <% if not self.nocreate then %>
53 <li>
54 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
55 attr("type", self.widget or "radio") ..
56 attr("id", cbid .. "_custom") ..
57 attr("name", cbid)
58 %> /> &#160;
59 <label<%=attr("for", cbid .. "_custom")%>>
60 <img title="<%:Custom Interface%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/ethernet_disabled.png" />
61 <%:Custom Interface%>:
62 </label>
63 <input type="text" style="width:50px" onfocus="document.getElementById('<%=cbid%>_custom').checked=true" onblur="var x=document.getElementById('<%=cbid%>_custom'); x.value=this.value; x.checked=true" />
64 </li>
65 <% end %>
66 </ul>
67
68 <%+cbi/valuefooter%>