diff options
author | Florian Eckert <fe@dev.tdt.de> | 2018-01-17 16:05:25 +0100 |
---|---|---|
committer | Florian Eckert <fe@dev.tdt.de> | 2018-01-18 15:09:38 +0100 |
commit | aae3d298c2a74d2f17887555bf7398c3de339b62 (patch) | |
tree | 6bee9c136871815269ba0db53e64412335dc792d /applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua | |
parent | de1afe2a90450d68e2e2c368fd888520e4ac3f7d (diff) |
luci-app-mwan3: refactoring warning compilation on the rule config pages
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua')
-rw-r--r-- | applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua index 812d46365..4ff9f1167 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua @@ -1,23 +1,7 @@ --- ------ extra functions ------ -- - -function ruleCheck() -- determine if rule needs a protocol specified - local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".src_port")) - local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".dest_port")) - if sourcePort ~= "" or destPort ~= "" then -- ports configured - local protocol = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".proto")) - if protocol == "" or protocol == "all" then -- no or improper protocol - error_protocol = 1 - end - end -end - -function ruleWarn() -- display warning message at the top of the page - if error_protocol == 1 then - return "<font color=\"ff0000\"><strong>" .. translate("WARNING: This rule is incorrectly configured with no or improper protocol specified! Please configure a specific protocol!") .. "</strong></font>" - else - return "" - end -end +dsp = require "luci.dispatcher" +sys = require "luci.sys" +ut = require "luci.util" +arg[1] = arg[1] or "" function cbiAddPolicy(field) uci.cursor():foreach("mwan3", "policy", @@ -34,20 +18,8 @@ function cbiAddProtocol(field) end end --- ------ rule configuration ------ -- - -dsp = require "luci.dispatcher" -sys = require "luci.sys" -ut = require "luci.util" -arg[1] = arg[1] or "" - -error_protocol = 0 -ruleCheck() - - -m5 = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]), - ruleWarn()) - m5.redirect = dsp.build_url("admin", "network", "mwan", "rule") +m5 = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1])) +m5.redirect = dsp.build_url("admin", "network", "mwan", "rule") mwan_rule = m5:section(NamedSection, arg[1], "rule", "") |