libs/cbi: add interface picker widget
This commit is contained in:
parent
a037d94383
commit
a5b315694d
1 changed files with 43 additions and 0 deletions
43
libs/cbi/luasrc/view/cbi/network_ifacelist.htm
Normal file
43
libs/cbi/luasrc/view/cbi/network_ifacelist.htm
Normal file
|
@ -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")%> />
|
||||
<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%>
|
Loading…
Reference in a new issue