luci/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/apcups.js
Jo-Philipp Wich dd5d96afdb luci-app-statistics: fix APC UPS host configuration
Ensure that list of hosts is stored as space separated list, like it was
done in the previous Lua implementation.

Fixes: #5010
Fixes: e7d22dce5 ("luci-app-statistics: convert collectd configuration to client side views")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-26 17:40:23 +02:00

36 lines
1,003 B
JavaScript

'use strict';
'require baseclass';
'require form';
return baseclass.extend({
title: _('APCUPS Plugin Configuration'),
description: _('The APCUPS plugin collects statistics about the APC UPS.'),
addFormOptions: function(s) {
var o;
o = s.option(form.Flag, 'enable', _('Enable this plugin'));
o = s.option(form.DynamicList, 'Host', _('Monitor host'));
o.default = 'localhost';
o.datatype = 'host';
o.depends('enable', '1');
o.write = function(section_id, value) {
return form.Value.prototype.write.call(this, section_id, L.toArray(value).join(' '));
};
o = s.option(form.Value, 'Port', _('Port for apcupsd communication'));
o.default = '3551';
o.datatype = 'port';
o.depends('enable', '1');
},
configSummary: function(section) {
var hosts = L.toArray(section.Host);
if (hosts.length)
return N_(hosts.length,
'Monitoring APC UPS at host %s, port %d',
'Monitoring APC UPS at hosts %s, port %d'
).format(hosts.join(', '), section.Port || 3551);
}
});