From f4795b94204470500f3ef81316ec64bba5ee9a2d Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Mon, 4 Dec 2023 02:47:50 +0100 Subject: [PATCH] Merge pull request #5631 from coudu/luci-app-nut-fixes luci-app-nut: nut-monitor fixes (cherry picked from commit 51a7e0b8e8db3709feccfa83176ae77372b2b1e7) --- .../luasrc/model/cbi/nut_monitor.lua | 28 ++++++--- .../luci-app-nut/po/templates/nut.pot | 62 +++++++++++-------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua b/applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua index 2496259bad..b1bb1b850f 100644 --- a/applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua +++ b/applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua @@ -78,9 +78,9 @@ o.optional = true validatenotify = function(self, value) val = StaticList.validate(self, value) if val then - for k, v in pairs(val) do - if (v == 'IGNORE') then - return nil, "Ignore must the only option selected, when selected" + for i, v in ipairs(val) do + if (i > 1) and (v == 'IGNORE') then + return nil, "If selected, Ignore must be the only option." end end end @@ -112,7 +112,7 @@ o:value("SYSLOG", translate("Write to syslog")) o:value("IGNORE", translate("Ignore")) o.validate = validatenotify -o = s:option(StaticList, "nowbattnotify", translate("Notify when low battery")) +o = s:option(StaticList, "lowbattnotify", translate("Notify when low battery")) o.optional = true o.widget = "select" o:value("EXEC", translate("Execute notify command")) @@ -120,7 +120,7 @@ o:value("SYSLOG", translate("Write to syslog")) o:value("IGNORE", translate("Ignore")) o.validate = validatenotify -o = s:option(StaticList, "nowbattnotify", translate("Notify when low battery")) +o = s:option(StaticList, "fsdnotify", translate("Notify when force shutdown")) o.optional = true o.widget = "select" o:value("EXEC", translate("Execute notify command")) @@ -128,7 +128,7 @@ o:value("SYSLOG", translate("Write to syslog")) o:value("IGNORE", translate("Ignore")) o.validate = validatenotify -o = s:option(StaticList, "fsdnotify", translate("Notify when force shutdown")) +o = s:option(StaticList, "comoknotify", translate("Notify when communications restored")) o.optional = true o.widget = "select" o:value("EXEC", translate("Execute notify command")) @@ -136,7 +136,7 @@ o:value("SYSLOG", translate("Write to syslog")) o:value("IGNORE", translate("Ignore")) o.validate = validatenotify -o = s:option(StaticList, "comoknotify", translate("Notify when communications restored")) +o = s:option(StaticList, "combadnotify", translate("Notify when communications lost")) o.optional = true o.widget = "select" o:value("EXEC", translate("Execute notify command")) @@ -144,7 +144,7 @@ o:value("SYSLOG", translate("Write to syslog")) o:value("IGNORE", translate("Ignore")) o.validate = validatenotify -o = s:option(StaticList, "combadnotify", translate("Notify when communications lost")) +o = s:option(StaticList, "shutdownotify", translate("Notify when shutting down")) o.optional = true o.widget = "select" o:value("EXEC", translate("Execute notify command")) @@ -152,7 +152,7 @@ o:value("SYSLOG", translate("Write to syslog")) o:value("IGNORE", translate("Ignore")) o.validate = validatenotify -o = s:option(StaticList, "shutdownotify", translate("Notify when shutting down")) +o = s:option(StaticList, "replbattnotify", translate("Notify when battery needs replacing")) o.optional = true o.widget = "select" o:value("EXEC", translate("Execute notify command")) @@ -160,7 +160,15 @@ o:value("SYSLOG", translate("Write to syslog")) o:value("IGNORE", translate("Ignore")) o.validate = validatenotify -o = s:option(StaticList, "replbattnotify", translate("Notify when battery needs replacing")) +o = s:option(StaticList, "nocommnotify", translate("Notify when no communications")) +o.optional = true +o.widget = "select" +o:value("EXEC", translate("Execute notify command")) +o:value("SYSLOG", translate("Write to syslog")) +o:value("IGNORE", translate("Ignore")) +o.validate = validatenotify + +o = s:option(StaticList, "noparentnotify", translate("Notify when no parent process")) o.optional = true o.widget = "select" o:value("EXEC", translate("Execute notify command")) diff --git a/applications/luci-app-nut/po/templates/nut.pot b/applications/luci-app-nut/po/templates/nut.pot index 4b5416a6f2..b8e7675afd 100644 --- a/applications/luci-app-nut/po/templates/nut.pot +++ b/applications/luci-app-nut/po/templates/nut.pot @@ -14,8 +14,8 @@ msgid "Allowed actions" msgstr "" #: applications/luci-app-nut/luasrc/model/cbi/nut_cgi.lua:20 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:188 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:217 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:196 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:225 msgid "As configured by NUT" msgstr "" @@ -23,7 +23,7 @@ msgstr "" msgid "Bytes to read from interrupt pipe" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:174 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:182 msgid "CA Certificate path" msgstr "" @@ -120,6 +120,7 @@ msgstr "" #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:150 #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:158 #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:166 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:174 msgid "Execute notify command" msgstr "" @@ -151,8 +152,8 @@ msgstr "" msgid "Hostname or IP address" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:191 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:220 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:199 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:228 msgid "Hostname or address of UPS" msgstr "" @@ -174,6 +175,7 @@ msgstr "" #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:152 #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:160 #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:168 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:176 msgid "Ignore" msgstr "" @@ -250,8 +252,8 @@ msgstr "" msgid "NUT Users" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:188 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:217 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:196 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:225 msgid "Name of UPS" msgstr "" @@ -314,32 +316,39 @@ msgstr "" msgid "Notify when back online" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:163 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:155 msgid "Notify when battery needs replacing" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:147 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:139 msgid "Notify when communications lost" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:139 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:131 msgid "Notify when communications restored" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:131 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:123 msgid "Notify when force shutdown" msgstr "" #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:115 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:123 msgid "Notify when low battery" msgstr "" +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:163 +msgid "Notify when no communications" +msgstr "" + +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:171 +msgid "Notify when no parent process" +msgstr "" + #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:107 msgid "Notify when on battery" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:155 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:147 msgid "Notify when shutting down" msgstr "" @@ -359,13 +368,13 @@ msgstr "" msgid "Online message" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:208 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:237 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:216 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:245 #: applications/luci-app-nut/luasrc/model/cbi/nut_server.lua:19 msgid "Password" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:174 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:182 msgid "Path containing ca certificates to match against host certificate" msgstr "" @@ -398,15 +407,15 @@ msgid "Polling Frequency(s)" msgstr "" #: applications/luci-app-nut/luasrc/model/cbi/nut_cgi.lua:27 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:195 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:224 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:203 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:232 #: applications/luci-app-nut/luasrc/model/cbi/nut_server.lua:46 #: applications/luci-app-nut/luasrc/model/cbi/nut_server.lua:202 msgid "Port" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:200 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:229 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:208 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:237 msgid "Power value" msgstr "" @@ -418,7 +427,7 @@ msgstr "" msgid "Replace battery message" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:178 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:186 msgid "Require SSL and make sure server CN matches hostname" msgstr "" @@ -509,7 +518,7 @@ msgstr "" msgid "Time in seconds that upsdrvctl will wait for driver to finish starting" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:183 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:191 msgid "UPS Master" msgstr "" @@ -517,7 +526,7 @@ msgstr "" msgid "UPS Server Global Settings" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:212 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:220 msgid "UPS Slave" msgstr "" @@ -549,8 +558,8 @@ msgid "" "be read-write for that user." msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:205 -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:234 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:213 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:242 #: applications/luci-app-nut/luasrc/model/cbi/nut_server.lua:16 msgid "Username" msgstr "" @@ -559,7 +568,7 @@ msgstr "" msgid "Vendor (regex)" msgstr "" -#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:178 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:186 msgid "Verify all connection with SSL" msgstr "" @@ -577,6 +586,7 @@ msgstr "" #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:151 #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:159 #: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:167 +#: applications/luci-app-nut/luasrc/model/cbi/nut_monitor.lua:175 msgid "Write to syslog" msgstr "" -- 2.30.2