From 11cd64e08e3b69371ed61459f5118c7a48a7f846 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Sat, 28 Jul 2018 19:02:35 +0200 Subject: luci-app-travelmate: sync with travelmate 1.2.1 * Runtime Information, Logview and Station Overview are now dynamically updated via XHR poll * New runtime information for "Faulty Stations" (Travelmate backend will no longer rename faulty uplinks) * Add a new "Restart" button to reset "Faulty Stations" information and trigger a Travelmate restart * In Stations overview the currently used uplink is emphasized in blue, faulty uplinks in red * Numerous cleanups (e.g. space=>tab indentation) and other small fixes Signed-off-by: Dirk Brenken --- .../model/cbi/travelmate/cfg_firewall_tab.lua | 18 ++++--- .../model/cbi/travelmate/cfg_network_tab.lua | 18 ++++--- .../model/cbi/travelmate/cfg_wireless_tab.lua | 18 ++++--- .../model/cbi/travelmate/configuration_tab.lua | 18 ++++--- .../luasrc/model/cbi/travelmate/overview_tab.lua | 58 ++-------------------- 5 files changed, 47 insertions(+), 83 deletions(-) (limited to 'applications/luci-app-travelmate/luasrc/model/cbi') diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua index e5a048fa88..fea190e9b9 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua @@ -1,11 +1,11 @@ --- Copyright 2017 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local util = require("luci.util") -local trminput = "/etc/config/firewall" +local fs = require("nixio.fs") +local util = require("luci.util") +local input = "/etc/config/firewall" -if not nixio.fs.access(trminput) then +if not fs.access(input) then m = SimpleForm("error", nil, translate("Input file not found, please check your configuration.")) return m end @@ -23,11 +23,15 @@ f.rows = 20 f.rmempty = true function f.cfgvalue() - return nixio.fs.readfile(trminput) or "" + return fs.readfile(input) or "" end function f.write(self, section, data) - return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") +end + +function f.remove(self, section, value) + return fs.writefile(input, "") end function s.handle(self, state, data) diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua index 0096d6a8c2..6f0ade772d 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua @@ -1,11 +1,11 @@ --- Copyright 2017 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local util = require("luci.util") -local trminput = "/etc/config/network" +local fs = require("nixio.fs") +local util = require("luci.util") +local input = "/etc/config/network" -if not nixio.fs.access(trminput) then +if not fs.access(input) then m = SimpleForm("error", nil, translate("Input file not found, please check your configuration.")) return m end @@ -23,11 +23,15 @@ f.rows = 20 f.rmempty = true function f.cfgvalue() - return nixio.fs.readfile(trminput) or "" + return fs.readfile(input) or "" end function f.write(self, section, data) - return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") +end + +function f.remove(self, section, value) + return fs.writefile(input, "") end function s.handle(self, state, data) diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua index 7ef9920a08..ab59dfb376 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua @@ -1,11 +1,11 @@ --- Copyright 2017 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local util = require("luci.util") -local trminput = "/etc/config/wireless" +local fs = require("nixio.fs") +local util = require("luci.util") +local input = "/etc/config/wireless" -if not nixio.fs.access(trminput) then +if not fs.access(input) then m = SimpleForm("error", nil, translate("Input file not found, please check your configuration.")) return m end @@ -23,11 +23,15 @@ f.rows = 20 f.rmempty = true function f.cfgvalue() - return nixio.fs.readfile(trminput) or "" + return fs.readfile(input) or "" end function f.write(self, section, data) - return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") +end + +function f.remove(self, section, value) + return fs.writefile(input, "") end function s.handle(self, state, data) diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua index 8a20ab9cce..7bb32c1ec5 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua @@ -1,11 +1,11 @@ --- Copyright 2017 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local util = require("luci.util") -local trminput = "/etc/config/travelmate" +local fs = require("nixio.fs") +local util = require("luci.util") +local input = "/etc/config/travelmate" -if not nixio.fs.access(trminput) then +if not fs.access(input) then m = SimpleForm("error", nil, translate("Input file not found, please check your configuration.")) m.reset = false m.submit = false @@ -25,11 +25,15 @@ f.rows = 20 f.rmempty = true function f.cfgvalue() - return nixio.fs.readfile(trminput) or "" + return fs.readfile(input) or "" end function f.write(self, section, data) - return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") +end + +function f.remove(self, section, value) + return fs.writefile(input, "") end function s.handle(self, state, data) diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua index a1dcbc638c..ab39dab6bd 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua @@ -3,15 +3,12 @@ local fs = require("nixio.fs") local uci = require("luci.model.uci").cursor() -local json = require("luci.jsonc") local util = require("luci.util") local nw = require("luci.model.network").init() local fw = require("luci.model.firewall").init() local dump = util.ubus("network.interface", "dump", {}) local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" -local trminput = uci:get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json" local uplink = uci:get("network", trmiface) or "" -local parse = json.parse(fs.readfile(trminput) or "") m = Map("travelmate", translate("Travelmate"), translate("Configuration of the travelmate package to to enable travel router functionality. ") @@ -20,11 +17,9 @@ m = Map("travelmate", translate("Travelmate"), .. "see online documentation", "https://github.com/openwrt/packages/blob/master/net/travelmate/files/README.md")) m:chain("network") m:chain("firewall") -m.apply_on_parse = true function m.on_apply(self) luci.sys.call("env -i /etc/init.d/travelmate restart >/dev/null 2>&1") - luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate")) end -- Interface Wizard @@ -33,7 +28,7 @@ if uplink == "" then ds = m:section(NamedSection, "global", "travelmate", translate("Interface Wizard")) o = ds:option(Value, "trm_iface", translate("Create Uplink interface"), translate("Create a new wireless wan uplink interface, configure it to use dhcp and ") - .. translate("add it to the wan zone of the firewall.
") + .. translate("add it to the wan zone of the firewall. ") .. translate("This step has only to be done once.")) o.datatype = "and(uciname,rangelength(3,15))" o.default = trmiface @@ -96,55 +91,8 @@ end -- Runtime information -ds = m:section(NamedSection, "global", "travelmate", translate("Runtime Information")) - -dv1 = ds:option(DummyValue, "status", translate("Travelmate Status (Quality)")) -dv1.template = "travelmate/runtime" -if parse ~= nil then - dv1.value = parse.data.travelmate_status or translate("n/a") -else - dv1.value = translate("n/a") -end - -dv2 = ds:option(DummyValue, "travelmate_version", translate("Travelmate Version")) -dv2.template = "travelmate/runtime" -if parse ~= nil then - dv2.value = parse.data.travelmate_version or translate("n/a") -else - dv2.value = translate("n/a") -end - -dv3 = ds:option(DummyValue, "station_id", translate("Station ID (SSID/BSSID)")) -dv3.template = "travelmate/runtime" -if parse ~= nil then - dv3.value = parse.data.station_id or translate("n/a") -else - dv3.value = translate("n/a") -end - -dv4 = ds:option(DummyValue, "station_interface", translate("Station Interface")) -dv4.template = "travelmate/runtime" -if parse ~= nil then - dv4.value = parse.data.station_interface or translate("n/a") -else - dv4.value = translate("n/a") -end - -dv5 = ds:option(DummyValue, "station_radio", translate("Station Radio")) -dv5.template = "travelmate/runtime" -if parse ~= nil then - dv5.value = parse.data.station_radio or translate("n/a") -else - dv5.value = translate("n/a") -end - -dv6 = ds:option(DummyValue, "last_rundate", translate("Last rundate")) -dv6.template = "travelmate/runtime" -if parse ~= nil then - dv6.value = parse.data.last_rundate or translate("n/a") -else - dv6.value = translate("n/a") -end +ds = s:option(DummyValue, "_dummy") +ds.template = "travelmate/runtime" -- Extra options -- cgit v1.2.3