8568ced4475dab6fc670edcaa8072211fb3ec367
[project/luci.git] / libs / web / 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         if not value or value == "-" then
12                 value = self:cfgvalue(section) or self.default
13         end
14
15         local checked = { }
16         for value in utl.imatch(value) do
17                 checked[value] = true
18         end
19 -%>
20
21 <ul style="margin:0; list-style-type:none; text-align:left">
22         <% for _, net in ipairs(networks) do
23                if (net:name() ~= "loopback") and
24                       (net:name() ~= self.exclude) and
25                       (not self.novirtual or not net:is_virtual())
26                    then %>
27         <li style="padding:0.25em 0">
28                 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
29                         attr("type", self.widget or "radio") ..
30                         attr("id", cbid .. "." .. net:name()) ..
31                         attr("name", cbid) .. attr("value", net:name()) ..
32                         ifattr(checked[net:name()], "checked", "checked")
33                 %> /> &#160;
34                 <label<%=attr("for", cbid .. "." .. net:name())%>>
35                         <span class="ifacebadge"><%=net:name()%>:
36                                 <%
37                                         local empty = true
38                                         for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
39                                                 if not iface:is_bridge() then
40                                                         empty = false
41                                  %>
42                                         <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" />
43                                 <% end end %>
44                                 <% if empty then %><em><%:(no interfaces attached)%></em><% end %>
45                         </span>
46                 </label>
47         </li>
48         <% end end %>
49
50         <% if not self.nocreate then %>
51         <li style="padding:0.25em 0">
52                 <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, "checked", "checked")%> /> &#160;
53                 <div style="padding:0.5em; display:inline">
54                         <label<%=attr("for", cbid .. "_new")%>><em><%:unspecified -or- create:%>&#160;</em></label>
55                         <input style="width:6em" type="text"<%=attr("name", cbid .. ".newnet")%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
56                 </div>
57         </li>
58         <% elseif self.widget ~= "checkbox" and self.unspecified then %>
59         <li style="padding:0.25em 0">
60                 <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
61                         attr("type", self.widget or "radio") ..
62                         attr("id", cbid .. "_uns") ..
63                         attr("name", cbid) ..
64                         attr("value", "") ..
65                         ifattr(not value or #value == 0, "checked", "checked")
66                 %> /> &#160;
67                 <div style="padding:0.5em; display:inline">
68                         <label<%=attr("for", cbid .. "_uns")%>><em><%:unspecified%></em></label>
69                 </div>
70         </li>
71         <% end %>
72 </ul>
73
74 <%+cbi/valuefooter%>