From d369c80beccedf883b4cd47b4e3c1debc9f37e9a Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Wed, 17 Jan 2018 17:10:06 +0100 Subject: [PATCH] luci-app-mwan3: refactoring member config pages Signed-off-by: Florian Eckert --- .../luasrc/model/cbi/mwan/member.lua | 4 ---- .../luasrc/model/cbi/mwan/memberconfig.lua | 22 +++++-------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua index 67030cc8d..0865fccaf 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua @@ -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 diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua index 8b606cdeb..1208905c3 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua @@ -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")) -- 2.25.1