luci-app-mwan3: refactoring notify page

clean up notify page

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2018-01-10 15:18:17 +01:00
parent 6ac76568e7
commit 2a165111e8

View file

@ -1,13 +1,12 @@
-- ------ hotplug script configuration ------ -- -- ------ hotplug script configuration ------ --
fs = require "nixio.fs" local fs = require "nixio.fs"
ut = require "luci.util" local ut = require "luci.util"
script = "/etc/mwan3.user" script = "/etc/mwan3.user"
m5 = SimpleForm("luci", nil) m5 = SimpleForm("luci", nil)
f = m5:section(SimpleSection, nil, f = m5:section(SimpleSection, translate("MWAN Notification"),
translate("This section allows you to modify the content of \"/etc/mwan3.user\".<br />" .. translate("This section allows you to modify the content of \"/etc/mwan3.user\".<br />" ..
"The file is also preserved during sysupgrade.<br />" .. "The file is also preserved during sysupgrade.<br />" ..
"<br />" .. "<br />" ..
@ -27,13 +26,13 @@ f = m5:section(SimpleSection, nil,
"<br />")) "<br />"))
t = f:option(TextValue, "lines") t = f:option(TextValue, "lines")
t.rmempty = true t.rmempty = true
t.rows = 20 t.rows = 20
function t.cfgvalue() function t.cfgvalue()
return fs.readfile(script) return fs.readfile(script)
end end
function t.write(self, section, data) -- format and write new data to script function t.write(self, section, data)
return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n") return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n")
end end
return m5 return m5