Add luci
[librecmc/librecmc.git] / package / luci / modules / luci-base / 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 <div class="cbi-dropdown" display-items="5" placeholder="<%:-- please select -- %>"<%=
24         attr("name", cbid) ..
25         ifattr(self.widget == "checkbox", "multiple", "multiple") ..
26         ifattr(self.widget == "checkbox", "optional", "optional")
27 %>>
28         <script type="item-template"><!--
29                 <li value="{{value}}">
30                         <span class="ifacebadge" style="background:repeating-linear-gradient(45deg,rgba(204,204,204,0.5),rgba(204,204,204,0.5) 5px,rgba(255,255,255,0.5) 5px,rgba(255,255,255,0.5) 10px)">
31                                 {{value}}: <em>(<%:create%>)</em>
32                         </span>
33                 </li>
34         --></script>
35         <ul>
36                 <% if self.widget ~= "checkbox" then %>
37                 <li value=""<%= ifattr(not value, "selected", "selected") %>>
38                         <em><%:unspecified%></em>
39                 </li>
40                 <% end %>
41
42                 <% for _, net in ipairs(networks) do
43                        if (net:name() ~= "loopback") and
44                               (net:name() ~= self.exclude) and
45                               (not self.novirtual or not net:is_virtual())
46                            then %>
47                 <li<%= attr("value", net:name()) .. ifattr(checked[net:name()], "selected", "selected") %>>
48                         <span class="ifacebadge"><%=net:name()%>:
49                                 <%
50                                         local empty = true
51                                         for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
52                                                 if not iface:is_bridge() then
53                                                         empty = false
54                                 -%>
55                                         <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" />
56                                 <%- end end %>
57                                 <% if empty then %>
58                                         <em class="hide-close"><%:(no interfaces attached)%></em>
59                                         <em class="hide-open">-</em>
60                                 <% end %>
61                         </span>
62                 </li>
63                 <% end end %>
64
65                 <% if not self.nocreate then %>
66                 <li value="-"<%= ifattr(not value and self.widget ~= "checkbox", "selected", "selected") %>>
67                         <em>
68                                 <%- if self.widget == "checkbox" then -%>
69                                         <%:create:%>
70                                 <%- else -%>
71                                         <%:unspecified -or- create:%>
72                                 <%- end -%>
73                         </em>
74                         <input style="display:none" type="password" />
75                         <input class="create-item-input" type="text" />
76                 </li>
77                 <% end %>
78         </ul>
79 </div>
80
81 <%+cbi/valuefooter%>