build: introduce luci-base
[project/luci.git] / modules / base / luasrc / luasrc / view / cbi / network_netlist.htm
1 <%+cbi/valueheader%>
2
3 <%-
4 local utl = require "luci.util"
5 local nwm = require "luci.model.network".init()
6
7 local net, iface
8 local networks = nwm:get_networks()
9 local value = self:formvalue(section)
10
11 self.cast = nil
12
13 if not value or value == "-" then
14 value = self:cfgvalue(section) or self.default
15 end
16
17 local checked = { }
18 for value in utl.imatch(value) do
19 checked[value] = true
20 end
21 -%>
22
23 <ul style="margin:0; list-style-type:none; text-align:left">
24 <% for _, net in ipairs(networks) do
25 if (net:name() ~= "loopback") and
26 (net:name() ~= self.exclude) and
27 (not self.novirtual or not net:is_virtual())
28 then %>
29 <li style="padding:0.25em 0">
30 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
31 attr("type", self.widget or "radio") ..
32 attr("id", cbid .. "." .. net:name()) ..
33 attr("name", cbid) .. attr("value", net:name()) ..
34 ifattr(checked[net:name()], "checked", "checked")
35 %> /> &#160;
36 <label<%=attr("for", cbid .. "." .. net:name())%>>
37 <span class="ifacebadge"><%=net:name()%>:
38 <%
39 local empty = true
40 for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
41 if not iface:is_bridge() then
42 empty = false
43 %>
44 <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
45 <% end end %>
46 <% if empty then %><em><%:(no interfaces attached)%></em><% end %>
47 </span>
48 </label>
49 </li>
50 <% end end %>
51
52 <% if not self.nocreate then %>
53 <li style="padding:0.25em 0">
54 <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 .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not value and self.widget ~= "checkbox", "checked", "checked")%> /> &#160;
55 <div style="padding:0.5em; display:inline">
56 <label<%=attr("for", cbid .. "_new")%>><em>
57 <%- if self.widget == "checkbox" then -%>
58 <%:create:%>
59 <%- else -%>
60 <%:unspecified -or- create:%>
61 <%- end -%>&#160;</em></label>
62 <input style="width:6em" type="text"<%=attr("name", cbid .. ".newnet")%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
63 </div>
64 </li>
65 <% elseif self.widget ~= "checkbox" and self.unspecified then %>
66 <li style="padding:0.25em 0">
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 .. "_uns") ..
70 attr("name", cbid) ..
71 attr("value", "") ..
72 ifattr(not value or #value == 0, "checked", "checked")
73 %> /> &#160;
74 <div style="padding:0.5em; display:inline">
75 <label<%=attr("for", cbid .. "_uns")%>><em><%:unspecified%></em></label>
76 </div>
77 </li>
78 <% end %>
79 </ul>
80
81 <%+cbi/valuefooter%>