network_netlist.htm 3.0 KB

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