libs/web: convert cbi widgets to new network model
[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 net = require "luci.model.network"
18
19 local iface
20 local ifaces = net:get_interfaces()
21 local value = (self:formvalue(section) or self.default or "")
22 local checked = { }
23
24 if value and #value > 0 then
25 if type(value) == "table" then value = table.concat(value, " ") end
26 for value in value:gmatch("%S+") do
27 checked[value] = true
28 end
29 else
30 local n = self.network and net:get_network(self.network)
31 if n then
32 local i
33 for _, i in ipairs(n:get_interfaces()) do
34 checked[i:name()] = true
35 end
36 end
37 end
38 -%>
39
40 <ul style="margin:0; list-style-type:none">
41 <% for _, iface in ipairs(ifaces) do
42 local link = iface:adminlink()
43 if not self.nobridges or not iface:is_bridge() then %>
44 <li>
45 <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;
46 <label<%=attr("for", cbid .. "." .. iface:name())%>>
47 <% if link then -%><a href="<%=link%>"><% end -%>
48 <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" />
49 <% if link then -%></a><% end -%>
50 <%=iface:get_i18n()%><% local n = iface:get_network(); if n then %> (<a href="<%=n:adminlink()%>"><%=n:name()%></a>)<% end %>
51 </label>
52 </li>
53 <% end end %>
54 </ul>
55
56 <%+cbi/valuefooter%>