From e2d0f6104d34e2e9a3d4cc97d92d3eff19e741f8 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Mon, 16 Jul 2018 03:30:43 +0200 Subject: [PATCH] luci-app-ddns: various fix Rework overview page, sync with new style and simplify the code by removing unnecessary check. Signed-off-by: Ansuel Smith --- applications/luci-app-ddns/Makefile | 2 +- .../luci-app-ddns/luasrc/controller/ddns.lua | 72 ++++--- .../luasrc/view/ddns/system_status.htm | 185 +++++------------- 3 files changed, 91 insertions(+), 168 deletions(-) diff --git a/applications/luci-app-ddns/Makefile b/applications/luci-app-ddns/Makefile index 195e08131..331851d26 100644 --- a/applications/luci-app-ddns/Makefile +++ b/applications/luci-app-ddns/Makefile @@ -16,7 +16,7 @@ PKG_VERSION:=2.4.9 # Release == build # increase on changes of translation files -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_LICENSE:=Apache-2.0 PKG_MAINTAINER:=Ansuel Smith diff --git a/applications/luci-app-ddns/luasrc/controller/ddns.lua b/applications/luci-app-ddns/luasrc/controller/ddns.lua index e152bb0d9..24735289e 100755 --- a/applications/luci-app-ddns/luasrc/controller/ddns.lua +++ b/applications/luci-app-ddns/luasrc/controller/ddns.lua @@ -25,6 +25,8 @@ local app_name = "luci-app-ddns" local app_title = "Dynamic DNS" local app_version = "2.4.9-1" +local translate = I18N.translate + function index() local nxfs = require "nixio.fs" -- global definitions not available local sys = require "luci.sys" -- in function index() @@ -59,40 +61,47 @@ end -- Application specific information functions function app_description() - return I18N.translate("Dynamic DNS allows that your router can be reached with " .. - "a fixed hostname while having a dynamically changing IP address.") - .. [[
]] - .. I18N.translate("OpenWrt Wiki") .. ": " - .. [[]] - .. I18N.translate("DDNS Client Documentation") .. [[]] - .. " --- " - .. [[]] - .. I18N.translate("DDNS Client Configuration") .. [[]] + local tmp = {} + tmp[#tmp+1] = translate("Dynamic DNS allows that your router can be reached with \ + a fixed hostname while having a dynamically changing IP address.") + tmp[#tmp+1] = [[
]] + tmp[#tmp+1] = translate("OpenWrt Wiki") .. ": " + tmp[#tmp+1] = [[]] + tmp[#tmp+1] = translate("DDNS Client Documentation") + tmp[#tmp+1] = [[]] + tmp[#tmp+1] = " --- " + tmp[#tmp+1] = [[]] + tmp[#tmp+1] = translate("DDNS Client Configuration") + tmp[#tmp+1] = [[]] + + return table.concat(tmp) end function app_title_back() - return [[]] - .. I18N.translate(app_title) - .. [[]] + local tmp = {} + tmp[#tmp+1] = [[]] + tmp[#tmp+1] = translate(app_title) + tmp[#tmp+1] = [[]] + return table.concat(tmp) end -- Standardized application/service functions function app_title_main() - tmp = {} + local tmp = {} tmp[#tmp+1] = [[]] - tmp[#tmp+1] = I18N.translate(app_title) + tmp[#tmp+1] = translate(app_title) tmp[#tmp+1] = [[]] return table.concat(tmp) @@ -102,7 +111,7 @@ function service_version() local srv_ver_cmd = luci_helper .. " -V | awk {'print $2'} " local ver - + if IPKG then ver = IPKG.info(srv_name)[srv_name].Version else @@ -137,6 +146,7 @@ local function _get_status() local enabled = tonumber(s["enabled"]) or 0 local datelast = "_empty_" -- formatted date of last update local datenext = "_empty_" -- formatted date of next update + local datenextstat = nil -- get force seconds local force_seconds = DDNS.calc_seconds( @@ -170,18 +180,22 @@ local function _get_status() force_seconds = (force_seconds > uptime) and uptime or force_seconds if pid > 0 and ( lasttime + force_seconds - uptime ) <= 0 then datenext = "_verify_" + datenextstat = translate("Verify") -- run once elseif force_seconds == 0 then datenext = "_runonce_" + datenextstat = translate("Run once") -- no process running and NOT enabled elseif pid == 0 and enabled == 0 then datenext = "_disabled_" + datenextstat = translate("Disabled") -- no process running and enabled elseif pid == 0 and enabled ~= 0 then datenext = "_stopped_" + datenextstat = translate("Stopped") end -- get/set monitored interface and IP version @@ -192,10 +206,12 @@ local function _get_status() -- try to get registered IP local lookup_host = s["lookup_host"] or "_nolookup_" + local chk_sec = DDNS.calc_seconds( tonumber(s["check_interval"]) or 10, s["check_unit"] or "minutes" ) local reg_ip = DDNS.get_regip(section, chk_sec) + if reg_ip == "NOFILE" then local dnsserver = s["dns_server"] or "" local force_ipversion = tonumber(s["force_ipversion"] or 0) @@ -212,9 +228,6 @@ local function _get_status() command = command .. [[ -- get_registered_ip]] reg_ip = SYS.exec(command) end - if reg_ip == "" then - reg_ip = "_nodata_" - end -- fill transfer array data[#data+1] = { @@ -225,7 +238,8 @@ local function _get_status() reg_ip = reg_ip, pid = pid, datelast = datelast, - datenext = datenext + datenext = datenext, + datenextstat = datenextstat } end) diff --git a/applications/luci-app-ddns/luasrc/view/ddns/system_status.htm b/applications/luci-app-ddns/luasrc/view/ddns/system_status.htm index 7fcb882a1..31ed42b0a 100644 --- a/applications/luci-app-ddns/luasrc/view/ddns/system_status.htm +++ b/applications/luci-app-ddns/luasrc/view/ddns/system_status.htm @@ -1,151 +1,60 @@
<%:Dynamic DNS%> - -
-
-
<%:Configuration%>
-
<%:Next Update%>
-
<%:Lookup Hostname%>
-
<%:Registered IP%>
-
<%:Network%>
-
-
-

<%:Collecting data...%>
+
+
+
+
<%:Configuration%>
+
<%:Next Update%>
+
<%:Lookup Hostname%>
+
<%:Registered IP%>
+
<%:Network%>
+
+
+

<%:Collecting data...%>
+
- + \ No newline at end of file -- 2.25.1