luci/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/disk.js
Jo-Philipp Wich d4a475163e luci-app-statistics: clean and fix plugin configurations
- Remove redundant form flags
 - Fix various default values
 - Add some new collect options and remove options that do not exist anymore

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-22 23:26:49 +01:00

46 lines
1.4 KiB
JavaScript

'use strict';
'require fs';
'require form';
return L.Class.extend({
title: _('Disk Plugin Configuration'),
description: _('The disk plugin collects detailed usage statistics for selected partitions or whole disks.'),
addFormOptions: function(s) {
var o;
o = s.option(form.Flag, 'enable', _('Enable this plugin'));
o = s.option(form.DynamicList, 'Disks', _('Monitor disks and partitions'),
_('When none selected, all disks will be monitored.'));
o.depends('enable', '1');
o.load = function(section_id) {
return fs.trimmed('/proc/partitions').then(L.bind(function(str) {
var lines = (str || '').split(/\n/);
for (var i = 0; i < lines.length; i++) {
var m = lines[i].match(/^ +[0-9]+ +[0-9]+ +[0-9]+ (\S+)$/);
if (m)
this.value(m[1]);
}
return this.super('load', [section_id]);
}, this));
};
o = s.option(form.Flag, 'IgnoreSelected', _('Monitor all except specified'));
o.depends('enable', '1');
},
configSummary: function(section) {
var disks = L.toArray(section.Disks),
invert = section.IgnoreSelected == '1';
if (disks.length == 0)
return _('Monitoring all disks');
else if (invert)
return N_(disks.length, 'Monitoring all but one disk', 'Monitoring all but %d disks').format(disks.length);
else
return N_(disks.length, 'Monitoring one disk', 'Monitoring %d disks').format(disks.length);
}
});