network_ifacelist.htm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. checked[value] = true
  18. end
  19. else
  20. local n = self.network and net:get_network(self.network)
  21. if n then
  22. local i
  23. for _, i in ipairs(n:get_interfaces() or { n:get_interface() }) do
  24. checked[i:name()] = true
  25. end
  26. end
  27. end
  28. -%>
  29. <input type="hidden" name="<%=cbeid%>" value="1" />
  30. <ul style="margin:0; list-style-type:none">
  31. <% for _, iface in ipairs(ifaces) do
  32. local link = iface:adminlink()
  33. if (not self.nobridges or not iface:is_bridge()) and
  34. (not self.noinactive or iface:is_up()) and
  35. iface:name() ~= self.exclude
  36. then %>
  37. <li>
  38. <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
  39. attr("type", self.widget or "radio") ..
  40. attr("id", cbid .. "." .. iface:name()) ..
  41. attr("name", cbid) .. attr("value", iface:name()) ..
  42. ifattr(checked[iface:name()], "checked", "checked")
  43. %> /> &#160;
  44. <label<%=attr("for", cbid .. "." .. iface:name())%>>
  45. <% if link then -%><a href="<%=link%>"><% end -%>
  46. <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" />
  47. <% if link then -%></a><% end -%>
  48. <%=pcdata(iface:get_i18n())%>
  49. <% local ns = iface:get_networks(); if #ns > 0 then %>(
  50. <%- local i, n; for i, n in ipairs(ns) do -%>
  51. <%-= (i>1) and ', ' -%>
  52. <a href="<%=n:adminlink()%>"><%=n:name()%></a>
  53. <%- end -%>
  54. )<% end %>
  55. </label>
  56. </li>
  57. <% end end %>
  58. <% if not self.nocreate then %>
  59. <li>
  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 .. "_custom") ..
  63. attr("name", cbid) ..
  64. attr("value", " ")
  65. %> /> &#160;
  66. <label<%=attr("for", cbid .. "_custom")%>>
  67. <img title="<%:Custom Interface%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/ethernet_disabled.png" />
  68. <%:Custom Interface%>:
  69. </label>
  70. <input type="text" style="width:50px" onfocus="document.getElementById('<%=cbid%>_custom').checked=true" onblur="var x=document.getElementById('<%=cbid%>_custom'); x.value=this.value; x.checked=true" />
  71. </li>
  72. <% end %>
  73. </ul>
  74. <%+cbi/valuefooter%>