luci-0.11: merge r9559 - r9569
[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 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 checked[value] = true
23 end
24 else
25 local n = self.network and net:get_network(self.network)
26 if n then
27 local i
28 for _, i in ipairs(n:get_interfaces() or { n:get_interface() }) do
29 checked[i:name()] = true
30 end
31 end
32 end
33 -%>
34
35 <input type="hidden" name="<%=cbeid%>" value="1" />
36 <ul style="margin:0; list-style-type:none">
37 <% for _, iface in ipairs(ifaces) do
38 local link = iface:adminlink()
39 if (not self.nobridges or not iface:is_bridge()) and
40 (not self.noinactive or iface:is_up()) and
41 iface:name() ~= self.exclude
42 then %>
43 <li>
44 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
45 attr("type", self.widget or "radio") ..
46 attr("id", cbid .. "." .. iface:name()) ..
47 attr("name", cbid) .. attr("value", iface:name()) ..
48 ifattr(checked[iface:name()], "checked", "checked")
49 %> /> &#160;
50 <label<%=attr("for", cbid .. "." .. iface:name())%>>
51 <% if link then -%><a href="<%=link%>"><% end -%>
52 <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" />
53 <% if link then -%></a><% end -%>
54 <%=pcdata(iface:get_i18n())%>
55 <% local ns = iface:get_networks(); if #ns > 0 then %>(
56 <%- local i, n; for i, n in ipairs(ns) do -%>
57 <%-= (i>1) and ', ' -%>
58 <a href="<%=n:adminlink()%>"><%=n:name()%></a>
59 <%- end -%>
60 )<% end %>
61 </label>
62 </li>
63 <% end end %>
64 <% if not self.nocreate then %>
65 <li>
66 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
67 attr("type", self.widget or "radio") ..
68 attr("id", cbid .. "_custom") ..
69 attr("name", cbid) ..
70 attr("value", " ")
71 %> /> &#160;
72 <label<%=attr("for", cbid .. "_custom")%>>
73 <img title="<%:Custom Interface%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/ethernet_disabled.png" />
74 <%:Custom Interface%>:
75 </label>
76 <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" />
77 </li>
78 <% end %>
79 </ul>
80
81 <%+cbi/valuefooter%>