luci-app-travelmate: sync with travelmate 0.7.2
* simplify uplink interface setup (just one Click! ;-), now part of the overview tab (removed separate setup page!) * cosmetics Signed-off-by: Dirk Brenken <dev@brenken.org> Conflict resolved by Hannu Nyman
This commit is contained in:
parent
57121f3743
commit
d0938f33e0
4 changed files with 50 additions and 68 deletions
|
@ -12,15 +12,14 @@ function index()
|
||||||
if not nixio.fs.access("/etc/config/travelmate") then
|
if not nixio.fs.access("/etc/config/travelmate") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
entry({"admin", "services", "travelmate"}, firstchild(), _("Travelmate"), 30).dependent = false
|
entry({"admin", "services", "travelmate"}, firstchild(), _("Travelmate"), 40).dependent = false
|
||||||
entry({"admin", "services", "travelmate", "tab_from_cbi"}, cbi("travelmate/overview_tab"), _("Overview"), 10).leaf = true
|
entry({"admin", "services", "travelmate", "tab_from_cbi"}, cbi("travelmate/overview_tab", {hideresetbtn=true, hidesavebtn=true}), _("Overview"), 10).leaf = true
|
||||||
entry({"admin", "services", "travelmate", "logfile"}, call("logread"), _("View Logfile"), 20).leaf = true
|
entry({"admin", "services", "travelmate", "logfile"}, call("logread"), _("View Logfile"), 20).leaf = true
|
||||||
entry({"admin", "services", "travelmate", "advanced"}, firstchild(), _("Advanced"), 100)
|
entry({"admin", "services", "travelmate", "advanced"}, firstchild(), _("Advanced"), 100)
|
||||||
entry({"admin", "services", "travelmate", "advanced", "setup"}, cbi("travelmate/setup_tab"), _("Setup WWAN Interface"), 110).leaf = true
|
entry({"admin", "services", "travelmate", "advanced", "configuration"}, cbi("travelmate/configuration_tab"), _("Edit Travelmate Configuration"), 110).leaf = true
|
||||||
entry({"admin", "services", "travelmate", "advanced", "configuration"}, cbi("travelmate/configuration_tab"), _("Edit Travelmate Configuration"), 120).leaf = true
|
entry({"admin", "services", "travelmate", "advanced", "cfg_wireless"}, cbi("travelmate/cfg_wireless_tab"), _("Edit Wireless Configuration"), 120).leaf = true
|
||||||
entry({"admin", "services", "travelmate", "advanced", "cfg_wireless"}, cbi("travelmate/cfg_wireless_tab"), _("Edit Wireless Configuration"), 130).leaf = true
|
entry({"admin", "services", "travelmate", "advanced", "cfg_network"}, cbi("travelmate/cfg_network_tab"), _("Edit Network Configuration"), 130).leaf = true
|
||||||
entry({"admin", "services", "travelmate", "advanced", "cfg_network"}, cbi("travelmate/cfg_network_tab"), _("Edit Network Configuration"), 140).leaf = true
|
entry({"admin", "services", "travelmate", "advanced", "cfg_firewall"}, cbi("travelmate/cfg_firewall_tab"), _("Edit Firewall Configuration"), 140).leaf = true
|
||||||
entry({"admin", "services", "travelmate", "advanced", "cfg_firewall"}, cbi("travelmate/cfg_firewall_tab"), _("Edit Firewall Configuration"), 150).leaf = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function logread()
|
function logread()
|
||||||
|
|
|
@ -7,6 +7,8 @@ local trminput = "/etc/config/travelmate"
|
||||||
|
|
||||||
if not nixio.fs.access(trminput) then
|
if not nixio.fs.access(trminput) then
|
||||||
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
|
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
|
||||||
|
m.reset = false
|
||||||
|
m.submit = false
|
||||||
return m
|
return m
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,18 @@
|
||||||
|
|
||||||
local fs = require("nixio.fs")
|
local fs = require("nixio.fs")
|
||||||
local uci = require("uci")
|
local uci = require("uci")
|
||||||
local sys = require("luci.sys")
|
|
||||||
local json = require("luci.jsonc")
|
local json = require("luci.jsonc")
|
||||||
|
local nw = require("luci.model.network").init()
|
||||||
|
local fw = require("luci.model.firewall").init()
|
||||||
|
local uplink = uci.get("network", "trm_wwan") or ""
|
||||||
local trminput = uci.get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json"
|
local trminput = uci.get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json"
|
||||||
local parse = json.parse(fs.readfile(trminput) or "")
|
local parse = json.parse(fs.readfile(trminput) or "")
|
||||||
|
|
||||||
m = Map("travelmate", translate("Travelmate"),
|
m = Map("travelmate", translate("Travelmate"),
|
||||||
translate("Configuration of the travelmate package to to enable travel router functionality. ")
|
translate("Configuration of the travelmate package to to enable travel router functionality. ")
|
||||||
.. translate("For further information ")
|
.. translatef("For further information "
|
||||||
.. [[<a href="https://github.com/openwrt/packages/blob/master/net/travelmate/files/README.md" target="_blank">]]
|
.. "<a href=\"%s\" target=\"_blank\">"
|
||||||
.. translate("see online documentation")
|
.. "see online documentation</a>", "https://github.com/openwrt/packages/blob/master/net/travelmate/files/README.md"))
|
||||||
.. [[</a>]]
|
|
||||||
.. translate("."))
|
|
||||||
|
|
||||||
-- Main travelmate options
|
-- Main travelmate options
|
||||||
|
|
||||||
|
@ -44,6 +44,42 @@ o5 = s:option(Flag, "trm_debug", translate("Enable verbose debug logging"))
|
||||||
o5.default = o5.disabled
|
o5.default = o5.disabled
|
||||||
o5.rmempty = false
|
o5.rmempty = false
|
||||||
|
|
||||||
|
-- Interface setup
|
||||||
|
|
||||||
|
if uplink == "" then
|
||||||
|
dv = s:option(DummyValue, "_dummy", translate("Interface Setup"))
|
||||||
|
dv.template = "cbi/nullsection"
|
||||||
|
btn = s:option(Button, "", translate("Create Uplink Interface"),
|
||||||
|
translate("Automatically create a new wireless wan uplink interface 'trm_wwan', configure it to use dhcp and ")
|
||||||
|
.. translate("add it to the wan zone of the firewall. This step has only to be done once."))
|
||||||
|
btn.inputtitle = translate("Add Interface")
|
||||||
|
btn.inputstyle = "apply"
|
||||||
|
btn.disabled = false
|
||||||
|
function btn.write()
|
||||||
|
local name = "trm_wwan"
|
||||||
|
local net = nw:add_network(name, { proto = "dhcp" })
|
||||||
|
if net then
|
||||||
|
nw:save("network")
|
||||||
|
nw:commit("network")
|
||||||
|
local zone = fw:get_zone_by_network("wan")
|
||||||
|
if zone then
|
||||||
|
zone:add_network(name)
|
||||||
|
fw:save("firewall")
|
||||||
|
fw:commit("firewall")
|
||||||
|
end
|
||||||
|
luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>&1")
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
dv = s:option(DummyValue, "_dummy", translate("Interface Setup"),
|
||||||
|
translate("<br /> Network Interface 'trm_wwan' created successfully. ")
|
||||||
|
.. translatef("Scan & Add new wireless stations via standard "
|
||||||
|
.. "<a href=\"%s\">"
|
||||||
|
.. "Wireless Setup</a>", luci.dispatcher.build_url("admin/network/wireless")))
|
||||||
|
dv.template = "cbi/nullsection"
|
||||||
|
end
|
||||||
|
|
||||||
-- Runtime information
|
-- Runtime information
|
||||||
|
|
||||||
ds = s:option(DummyValue, "_dummy", translate("Runtime information"))
|
ds = s:option(DummyValue, "_dummy", translate("Runtime information"))
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
-- Copyright 2017 Dirk Brenken (dev@brenken.org)
|
|
||||||
-- This is free software, licensed under the Apache License, Version 2.0
|
|
||||||
|
|
||||||
local nw = require("luci.model.network").init()
|
|
||||||
local fw = require("luci.model.firewall").init()
|
|
||||||
local util = require("luci.util")
|
|
||||||
local uci = require("luci.model.uci").cursor()
|
|
||||||
|
|
||||||
m = SimpleForm("network", translate("Interface Setup"),
|
|
||||||
translate("Automatically create a new wireless wan interface, configure it to use dhcp and " ..
|
|
||||||
"add it to the wan zone of the firewall. This step has only to be done once."))
|
|
||||||
m.reset = false
|
|
||||||
|
|
||||||
iface = m:field(Value, "netname", translate("Name of the new wireless wan interface"),
|
|
||||||
translate("The allowed characters are: <code>A-Z</code>, <code>a-z</code>, " ..
|
|
||||||
"<code>0-9</code> and <code>_</code> (3-15 characters)."))
|
|
||||||
iface.default = "wwan"
|
|
||||||
iface.datatype = "and(uciname,minlength(3),maxlength(15))"
|
|
||||||
|
|
||||||
function iface.validate(self, value, section)
|
|
||||||
local value = iface:formvalue(section)
|
|
||||||
local name = uci.get("network", value)
|
|
||||||
if name then
|
|
||||||
iface:add_error(section, translate("The given network interface name already exist"))
|
|
||||||
else
|
|
||||||
iface.datatype = false
|
|
||||||
iface.default = iface.disabled
|
|
||||||
f = m:field(DummyValue, "textfield", " ", translatef("Direct Link: "
|
|
||||||
.. "<a href=\"%s\">"
|
|
||||||
.. "Wireless Setup</a>", luci.dispatcher.build_url("admin/network/wireless")))
|
|
||||||
f.default = translatef("Network Interface '%s' created successfully." ..
|
|
||||||
" Feel free to scan & add new stations via standard wireless setup.", value)
|
|
||||||
f.disabled = true
|
|
||||||
end
|
|
||||||
return value
|
|
||||||
end
|
|
||||||
|
|
||||||
function iface.write(self, section, value)
|
|
||||||
local name = iface:formvalue(section)
|
|
||||||
if name then
|
|
||||||
local net = nw:add_network(name, { proto = "dhcp" })
|
|
||||||
if net then
|
|
||||||
nw:save("network")
|
|
||||||
nw:commit("network")
|
|
||||||
local zone = fw:get_zone_by_network("wan")
|
|
||||||
if zone then
|
|
||||||
zone:add_network(name)
|
|
||||||
fw:save("firewall")
|
|
||||||
fw:commit("firewall")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return m
|
|
Loading…
Reference in a new issue