network_netlist.htm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <%+cbi/valueheader%>
  2. <%-
  3. local utl = require "luci.util"
  4. local nwm = require "luci.model.network".init()
  5. local net, iface
  6. local networks = nwm:get_networks()
  7. local value = self:formvalue(section)
  8. self.cast = nil
  9. if not value or value == "-" then
  10. value = self:cfgvalue(section) or self.default
  11. end
  12. local checked = { }
  13. for value in utl.imatch(value) do
  14. checked[value] = true
  15. end
  16. -%>
  17. <div class="cbi-dropdown" display-items="10" placeholder="<%:-- please select -- %>"<%=
  18. attr("name", cbid) ..
  19. ifattr(self.widget == "checkbox", "multiple", "multiple") ..
  20. ifattr(self.widget == "checkbox", "optional", "optional")
  21. %>>
  22. <script type="item-template"><!--
  23. <li data-value="{{value}}">
  24. <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)">
  25. {{value}}: <em>(<%:create%>)</em>
  26. </span>
  27. </li>
  28. --></script>
  29. <ul>
  30. <% if self.widget ~= "checkbox" then %>
  31. <li data-value=""<%= ifattr(not value, "selected", "selected") %>>
  32. <em><%:unspecified%></em>
  33. </li>
  34. <% end %>
  35. <% for _, net in ipairs(networks) do
  36. if (net:name() ~= "loopback") and
  37. (net:name() ~= self.exclude) and
  38. (not self.novirtual or not net:is_virtual())
  39. then %>
  40. <li<%= attr("data-value", net:name()) .. ifattr(checked[net:name()], "selected", "selected") %>>
  41. <span class="ifacebadge"><%=net:name()%>:
  42. <%
  43. local empty = true
  44. for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
  45. if not iface:is_bridge() then
  46. empty = false
  47. -%>
  48. <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" />
  49. <%- end end %>
  50. <% if empty then %>
  51. <em class="hide-close"><%:(no interfaces attached)%></em>
  52. <em class="hide-open">-</em>
  53. <% end %>
  54. </span>
  55. </li>
  56. <% end end %>
  57. <% if not self.nocreate then %>
  58. <li data-value="-"<%= ifattr(not value and self.widget ~= "checkbox", "selected", "selected") %>>
  59. <em>
  60. <%- if self.widget == "checkbox" then -%>
  61. <%:create:%>
  62. <%- else -%>
  63. <%:unspecified -or- create:%>
  64. <%- end -%>
  65. </em>
  66. <input style="display:none" type="password" />
  67. <input class="create-item-input" type="text" />
  68. </li>
  69. <% end %>
  70. </ul>
  71. </div>
  72. <%+cbi/valuefooter%>