luci-app-mwan3: refactoring member config pages
authorFlorian Eckert <fe@dev.tdt.de>
Wed, 17 Jan 2018 16:10:06 +0000 (17:10 +0100)
committerFlorian Eckert <fe@dev.tdt.de>
Thu, 18 Jan 2018 14:09:50 +0000 (15:09 +0100)
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua
applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua

index 67030cc8db4bedcc1b9e3c8f8ce6d9ad8a267165..0865fccaf7b233b139c2f3a347b1647fb74796ae 100644 (file)
@@ -1,5 +1,3 @@
--- ------ member configuration ------ --
-
 ds = require "luci.dispatcher"
 
 
@@ -21,7 +19,6 @@ mwan_member = m5:section(TypedSection, "member", nil,
                luci.http.redirect(ds.build_url("admin", "network", "mwan", "member", section))
        end
 
-
 interface = mwan_member:option(DummyValue, "interface", translate("Interface"))
        interface.rawhtml = true
        function interface.cfgvalue(self, s)
@@ -40,5 +37,4 @@ weight = mwan_member:option(DummyValue, "weight", translate("Weight"))
                return self.map:get(s, "weight") or "1"
        end
 
-
 return m5
index 8b606cdebdcf2a0972f8299bb295217402835c0b..1208905c3994a95b80d9ef50e4c38ebc00f8f960 100644 (file)
@@ -1,30 +1,20 @@
--- ------ extra functions ------ --
-
-function cbi_add_interface(field)
-       uci.cursor():foreach("mwan3", "interface",
-               function (section)
-                       field:value(section[".name"])
-               end
-       )
-end
-
--- ------ member configuration ------ --
-
 dsp = require "luci.dispatcher"
 arg[1] = arg[1] or ""
 
 
 m5 = Map("mwan3", translatef("MWAN Member Configuration - %s", arg[1]))
-       m5.redirect = dsp.build_url("admin", "network", "mwan", "member")
-
+m5.redirect = dsp.build_url("admin", "network", "mwan", "member")
 
 mwan_member = m5:section(NamedSection, arg[1], "member", "")
        mwan_member.addremove = false
        mwan_member.dynamic = false
 
-
 interface = mwan_member:option(Value, "interface", translate("Interface"))
-       cbi_add_interface(interface)
+m5.uci:foreach("mwan3", "interface",
+       function(s)
+               interface:value(s['.name'], s['.name'])
+       end
+)
 
 metric = mwan_member:option(Value, "metric", translate("Metric"),
        translate("Acceptable values: 1-256. Defaults to 1 if not set"))