member.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. -- Copyright 2014 Aedan Renner <chipdankly@gmail.com>
  2. -- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
  3. -- Licensed to the public under the GNU General Public License v2.
  4. dsp = require "luci.dispatcher"
  5. m5 = Map("mwan3", translate("MWAN - Members"))
  6. mwan_member = m5:section(TypedSection, "member", nil,
  7. translate("Members are profiles attaching a metric and weight to an MWAN interface<br />" ..
  8. "Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
  9. "Members may not share the same name as configured interfaces, policies or rules"))
  10. mwan_member.addremove = true
  11. mwan_member.dynamic = false
  12. mwan_member.sectionhead = translate("Member")
  13. mwan_member.sortable = true
  14. mwan_member.template = "cbi/tblsection"
  15. mwan_member.extedit = dsp.build_url("admin", "network", "mwan", "member", "%s")
  16. function mwan_member.create(self, section)
  17. TypedSection.create(self, section)
  18. m5.uci:save("mwan3")
  19. luci.http.redirect(dsp.build_url("admin", "network", "mwan", "member", section))
  20. end
  21. interface = mwan_member:option(DummyValue, "interface", translate("Interface"))
  22. interface.rawhtml = true
  23. function interface.cfgvalue(self, s)
  24. return self.map:get(s, "interface") or "&#8212;"
  25. end
  26. metric = mwan_member:option(DummyValue, "metric", translate("Metric"))
  27. metric.rawhtml = true
  28. function metric.cfgvalue(self, s)
  29. return self.map:get(s, "metric") or "1"
  30. end
  31. weight = mwan_member:option(DummyValue, "weight", translate("Weight"))
  32. weight.rawhtml = true
  33. function weight.cfgvalue(self, s)
  34. return self.map:get(s, "weight") or "1"
  35. end
  36. return m5