diff --git a/applications/luci-app-nut/Makefile b/applications/luci-app-nut/Makefile index 1b2bcc548c0f..524b95bbc2d7 100644 --- a/applications/luci-app-nut/Makefile +++ b/applications/luci-app-nut/Makefile @@ -12,6 +12,8 @@ PKG_LICENSE:=Apache-2.0 PKG_MAINTAINER:=Daniel F. Dickinson \ Paul Donald +EXTRA_DEPENDS:=nut (>= 2.8.4-3) + include ../../luci.mk # call BuildPackage - OpenWrt buildroot signature diff --git a/applications/luci-app-nut/htdocs/luci-static/resources/view/nut/nut_monitor.js b/applications/luci-app-nut/htdocs/luci-static/resources/view/nut/nut_monitor.js index 91e43c8c2096..f7b136df6c79 100644 --- a/applications/luci-app-nut/htdocs/luci-static/resources/view/nut/nut_monitor.js +++ b/applications/luci-app-nut/htdocs/luci-static/resources/view/nut/nut_monitor.js @@ -8,17 +8,48 @@ const upsmon_tool = '/usr/sbin/upsmon'; function ESIFlags(o) { o.value('EXEC', _('Execute notify command')); o.value('SYSLOG', _('Write to syslog')); + o.value('SYSLOG+EXEC', _('Write to syslog and execute notify command')) o.value('IGNORE', _('Ignore')); + o.default = 'SYSLOG'; o.optional = true; - o.validate = function(section, v) { - if (!v) return true; - if(v.includes(' ') && v.includes('IGNORE')) - return _('%s is mutually exclusive to other choices'.format(_('Ignore'))); - return true; - } return o; } + +function MonitorUserOptions(s) { + let o + + s.optional = true; + s.addremove = true; + s.anonymous = true; + + o = s.option(form.Value, 'upsname', _('Name of UPS'), _('As configured by NUT')); + o.optional = false; + + o = s.option(form.Value, 'hostname', _('Hostname or address of UPS')); + o.optional = false; + o.datatype = 'or(host,ipaddr)'; + + o = s.option(form.Value, 'port', _('Port')); + o.optional = true; + o.placeholder = 3493; + o.datatype = 'port'; + + o = s.option(form.Value, 'powervalue', _('Power value')); + o.optional = false; + o.datatype = 'uinteger'; + o.default = 1; + + o = s.option(form.Value, 'username', _('Username')); + o.optional = false; + + o = s.option(form.Value, 'password', _('Password')); + o.optional = false; + o.password = true; + + return s; +} + return view.extend({ load: function() { return Promise.all([ @@ -75,69 +106,6 @@ return view.extend({ o.optional = true; o.placeholder = 15; - o = s.option(form.Value, 'onlinemsg', _('Online message')); - o.optional = true; - - o = s.option(form.Value, 'onbattmsg', _('On battery message')); - o.optional = true; - - o = s.option(form.Value, 'lowbattmsg', _('Low battery message')); - o.optional = true; - - o = s.option(form.Value, 'fsdmsg', _('Forced shutdown message')); - o.optional = true; - - o = s.option(form.Value, 'comokmsg', _('Communications restored message')); - o.optional = true; - - o = s.option(form.Value, 'combadmsg', _('Communications lost message')); - o.optional = true; - - o = s.option(form.Value, 'shutdownmsg', _('Shutdown message')); - o.optional = true; - - o = s.option(form.Value, 'replbattmsg', _('Replace battery message')); - o.optional = true; - - o = s.option(form.Value, 'nocommsg', _('No communications message')); - o.optional = true; - - o = s.option(form.Value, 'noparentmsg', _('No parent message')); - o.optional = true; - - o = s.option(form.MultiValue, 'defaultnotify', _('Notification defaults')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'onlinenotify', _('Notify when back online')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'onbattnotify', _('Notify when on battery')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'lowbattnotify', _('Notify when low battery')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'fsdnotify', _('Notify when force shutdown')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'comoknotify', _('Notify when communications restored')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'combadnotify', _('Notify when communications lost')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'shutdownotify', _('Notify when shutting down')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'replbattnotify', _('Notify when battery needs replacing')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'nocommnotify', _('Notify when no communications')); - ESIFlags(o); - - o = s.option(form.MultiValue, 'noparentnotify', _('Notify when no parent process')); - ESIFlags(o); - if (have_ssl_support) { o = s.option(form.Value, 'certpath', _('CA Certificate path'), _('Path containing ca certificates to match against host certificate')); o.optional = true; @@ -148,64 +116,31 @@ return view.extend({ o.default = false; } - s = m.section(form.TypedSection, 'master', _('UPS Primary')); + s = m.section(form.TypedSection, 'notifications', _('Notifications settings')); s.optional = true; s.addremove = true; - s.anonymous = true; - - o = s.option(form.Value, 'upsname', _('Name of UPS'), _('As configured by NUT')); - o.optional = false; - - o = s.option(form.Value, 'hostname', _('Hostname or address of UPS')); - o.optional = false; - o.datatype = 'or(host,ipaddr)'; + s.anonymous = false; - o = s.option(form.Value, 'port', _('Port')); - o.optional = true; - o.placeholder = 3493; - o.datatype = 'port'; + o = s.option(form.Value, 'message', _('Custom notification message for message type')); + o.optional = true - o = s.option(form.Value, 'powervalue', _('Power value')); - o.optional = false; - o.datatype = 'uinteger'; - o.default = 1; + o = s.option(form.ListValue, 'flag', _('Notification flags')); + ESIFlags(o) - o = s.option(form.Value, 'username', _('Username')); - o.optional = false; + s = m.section(form.TypedSection, 'monitor', _('UPS Monitor User Settings)')); + MonitorUserOptions(s); - o = s.option(form.Value, 'password', _('Password')); + o = s.option(form.ListValue, 'type', _('User type (Primary/Auxiliary)')); o.optional = false; - o.password = true; + o.value('primary', 'Primary'); + o.value('secondary', 'Auxiliary'); + o.default = 'secondary' - s = m.section(form.TypedSection, 'slave', _('UPS Auxiliary')); - s.optional = true; - s.addremove = true; - s.anonymous = true; - - o = s.option(form.Value, 'upsname', _('Name of UPS'), _('As configured by NUT')); - o.optional = false; - - o = s.option(form.Value, 'hostname', _('Hostname or address of UPS')); - o.optional = false; - o.datatype = 'or(host,ipaddr)'; - - o = s.option(form.Value, 'port', _('Port')); - o.optional = true; - o.placeholder = 3493; - o.datatype = 'port'; - - o = s.option(form.Value, 'powervalue', _('Power value')); - o.optional = false; - o.datatype = 'uinteger'; - o.default = 1; - - o = s.option(form.Value, 'username', _('Username')); - o.optional = false; - - o = s.option(form.Value, 'password', _('Password')); - o.optional = false; - o.password = true; + s = m.section(form.TypedSection, 'master', _('UPS Primary (Deprecated)')); + MonitorUserOptions(s); + s = m.section(form.TypedSection, 'slave', _('UPS Auxiliary (Deprecated)')); + MonitorUserOptions(s); return m.render(); } diff --git a/applications/luci-app-nut/htdocs/luci-static/resources/view/nut/nut_server.js b/applications/luci-app-nut/htdocs/luci-static/resources/view/nut/nut_server.js index e4229b5c19cd..dcd275426b76 100644 --- a/applications/luci-app-nut/htdocs/luci-static/resources/view/nut/nut_server.js +++ b/applications/luci-app-nut/htdocs/luci-static/resources/view/nut/nut_server.js @@ -56,8 +56,10 @@ return view.extend({ o.optional = true; o = s.option(form.ListValue, 'upsmon', _('Role')); - o.value('slave', _('Auxiliary')); - o.value('master', _('Primary')); + o.value('secondary', _('Auxiliary')); + o.value('primary', _('Primary')); + o.value('slave', _('Auxiliary (Deprecated)')); + o.value('master', _('Primary (Deprecated)')); o.optional = false; // Listen settings