libs/cbi: add interface picker widget
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 8 Oct 2009 10:26:57 +0000 (10:26 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 8 Oct 2009 10:26:57 +0000 (10:26 +0000)
libs/cbi/luasrc/view/cbi/network_ifacelist.htm [new file with mode: 0644]

diff --git a/libs/cbi/luasrc/view/cbi/network_ifacelist.htm b/libs/cbi/luasrc/view/cbi/network_ifacelist.htm
new file mode 100644 (file)
index 0000000..b3a61fa
--- /dev/null
@@ -0,0 +1,43 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+
+<%-
+       local utl = require "luci.util"
+       local net = require "luci.model.network"
+
+       local iface
+       local ifaces = net:get_interfaces()
+       local value = (self:cfgvalue(section) or self.default or "")
+       local checked = { }
+
+       for value in value:gmatch("%S+") do
+               checked[value] = true
+       end
+-%>
+
+<ul style="margin:0; list-style-type:none">
+       <% for _, iface in utl.spairs(ifaces, function(a,b) return (ifaces[a]:name() < ifaces[b]:name()) end) do
+         if not self.nobridges or not iface:is_bridge() then %>
+       <li>
+               <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;
+               <label<%=attr("for", cbid .. "." .. iface:name())%>>
+                       <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" />
+                       <%=iface:name()%><% local n = iface:get_network(); if n then %> (<%=n:name()%>)<% end %>
+               </label>
+       </li>
+       <% end end %>
+</ul>
+
+<%+cbi/valuefooter%>