trunk: s/ / /g
[project/luci.git] / libs / web / luasrc / view / cbi / network_ifacelist.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 $Id$
12
13 -%>
14 <%+cbi/valueheader%>
15
16 <%-
17 local utl = require "luci.util"
18 local net = require "luci.model.network".init()
19
20 local iface
21 local ifaces = net:get_interfaces()
22 local value = self:formvalue(section)
23
24 if not value or value == "" then
25 value = self:cfgvalue(section) or self.default
26 end
27
28 local checked = { }
29
30 if value then
31 for value in utl.imatch(value) do
32 checked[value] = true
33 end
34 else
35 local n = self.network and net:get_network(self.network)
36 if n then
37 local i
38 for _, i in ipairs(n:get_interfaces()) do
39 checked[i:name()] = true
40 end
41 end
42 end
43 -%>
44
45 <ul style="margin:0; list-style-type:none">
46 <% for _, iface in ipairs(ifaces) do
47 local link = iface:adminlink()
48 if (not self.nobridges or not iface:is_bridge()) and iface:name() ~= self.exclude then %>
49 <li>
50 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
51 attr("type", self.widget or "radio") ..
52 attr("id", cbid .. "." .. iface:name()) ..
53 attr("name", cbid) .. attr("value", iface:name()) ..
54 ifattr(checked[iface:name()], "checked", "checked") ..
55 ifattr(iface:type() == "wifi" and not iface:is_up(), "disabled", "disabled")
56 %> /> &#160;
57 <label<%=attr("for", cbid .. "." .. iface:name())%>>
58 <% if link then -%><a href="<%=link%>"><% end -%>
59 <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" />
60 <% if link then -%></a><% end -%>
61 <%=iface:get_i18n()%><% local n = iface:get_network(); if n then %> (<a href="<%=n:adminlink()%>"><%=n:name()%></a>)<% end %>
62 </label>
63 </li>
64 <% end end %>
65 <% if not self.nocreate then %>
66 <li>
67 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
68 attr("type", self.widget or "radio") ..
69 attr("id", cbid .. "_custom") ..
70 attr("name", cbid)
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%>