libs/cbi: add interface picker widget
[project/luci.git] / libs / cbi / 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"
19
20 local iface
21 local ifaces = net:get_interfaces()
22 local value = (self:cfgvalue(section) or self.default or "")
23 local checked = { }
24
25 for value in value:gmatch("%S+") do
26 checked[value] = true
27 end
28 -%>
29
30 <ul style="margin:0; list-style-type:none">
31 <% for _, iface in utl.spairs(ifaces, function(a,b) return (ifaces[a]:name() < ifaces[b]:name()) end) do
32 if not self.nobridges or not iface:is_bridge() then %>
33 <li>
34 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. iface:name()) .. attr("name", cbid) .. attr("value", iface:name()) .. ifattr(checked[iface:name()], "checked", "checked")%> /> &nbsp;
35 <label<%=attr("for", cbid .. "." .. iface:name())%>>
36 <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" />
37 <%=iface:name()%><% local n = iface:get_network(); if n then %> (<%=n:name()%>)<% end %>
38 </label>
39 </li>
40 <% end end %>
41 </ul>
42
43 <%+cbi/valuefooter%>