network_ifacelist.htm 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <%+cbi/valueheader%>
  2. <%-
  3. local utl = require "luci.util"
  4. local net = require "luci.model.network".init()
  5. local cbeid = luci.cbi.FEXIST_PREFIX .. self.config .. "." .. section .. "." .. self.option
  6. local iface
  7. local ifaces = net:get_interfaces()
  8. local value
  9. if self.map:formvalue(cbeid) == "1" then
  10. value = self:formvalue(section) or self.default or ""
  11. else
  12. value = self:cfgvalue(section) or self.default
  13. end
  14. local checked = { }
  15. if value then
  16. for value in utl.imatch(value) do
  17. for value in utl.imatch(value) do
  18. checked[value] = true
  19. end
  20. end
  21. else
  22. local n = self.network and net:get_network(self.network)
  23. if n then
  24. local a = n:is_alias()
  25. if a then
  26. checked['@' .. a] = true
  27. else
  28. local i
  29. for _, i in ipairs(n:get_interfaces() or { n:get_interface() }) do
  30. checked[i:name()] = true
  31. end
  32. end
  33. end
  34. end
  35. -%>
  36. <input type="hidden" name="<%=cbeid%>" value="1" />
  37. <div class="cbi-dropdown" display-items="10" placeholder="<%:-- please select -- %>"<%=
  38. attr("name", cbid) ..
  39. ifattr(self.widget == "checkbox", "multiple", "multiple") ..
  40. ifattr(self.widget == "checkbox", "optional", "optional")
  41. %>>
  42. <script type="item-template"><!--
  43. <li data-value="{{value}}">
  44. <img title="<%:Custom Interface%>: &quot;{{value}}&quot;" src="<%=resource%>/icons/ethernet_disabled.png" />
  45. <span class="hide-open">{{value}}</span>
  46. <span class="hide-close"><%:Custom Interface%>: "{{value}}"</span>
  47. </li>
  48. --></script>
  49. <ul>
  50. <% for _, iface in ipairs(ifaces) do
  51. if (not self.noaliases or iface:type() ~= "alias") and
  52. (not self.nobridges or not iface:is_bridge()) and
  53. (not self.noinactive or iface:is_up()) and
  54. iface:name() ~= self.exclude
  55. then %>
  56. <li<%=
  57. attr("data-value", iface:name()) ..
  58. ifattr(checked[iface:name()], "selected", "selected")
  59. %>>
  60. <img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
  61. <span class="hide-open"><%=pcdata(iface:name())%></span>
  62. <span class="hide-close">
  63. <%=pcdata(iface:get_i18n())%>
  64. <% local ns = iface:get_networks(); if #ns > 0 then %>(
  65. <%- local i, n; for i, n in ipairs(ns) do -%>
  66. <%-= (i>1) and ', ' -%>
  67. <a href="<%=n:adminlink()%>"><%=n:name()%></a>
  68. <%- end -%>
  69. )<% end %>
  70. </span>
  71. </li>
  72. <% end end %>
  73. <% if not self.nocreate then %>
  74. <li data-value="">
  75. <img title="<%:Custom Interface%>" src="<%=resource%>/icons/ethernet_disabled.png" />
  76. <span><%:Custom Interface%>:</span>
  77. <input type="password" style="display:none" />
  78. <input class="create-item-input" type="text" />
  79. </li>
  80. <% end %>
  81. </ul>
  82. </div>
  83. <%+cbi/valuefooter%>