luci-app-statistics: clean and fix plugin configurations
[project/luci.git] / applications / luci-app-statistics / htdocs / luci-static / resources / view / statistics / plugins / iwinfo.js
1 'use strict';
2 'require form';
3 'require tools.widgets as widgets';
4
5 return L.Class.extend({
6 title: _('Wireless iwinfo Plugin Configuration'),
7 description: _('The iwinfo plugin collects statistics about wireless signal strength, noise and quality.'),
8
9 addFormOptions: function(s) {
10 var o;
11
12 o = s.option(form.Flag, 'enable', _('Enable this plugin'));
13
14 o = s.option(widgets.DeviceSelect, 'Interfaces', _('Monitor interfaces'), _('Leave unselected to automatically determine interfaces to monitor.'));
15 o.multiple = true;
16 o.noaliases = true;
17 o.noinactive = true;
18 o.depends('enable', '1');
19 o.filter = function(section_id, name) {
20 var dev = this.devices.filter(function(dev) { return dev.getName() == name })[0];
21 return (dev && dev.getType() == 'wifi');
22 };
23
24 o = s.option(form.Flag, 'IgnoreSelected', _('Monitor all except specified'));
25 o.depends('enable', '1');
26 },
27
28 configSummary: function(section) {
29 var ifaces = L.toArray(section.Interfaces),
30 invert = section.IgnoreSelected == '1';
31
32 if (ifaces.length == 0)
33 return _('Monitoring all interfaces');
34 else if (invert)
35 return N_(ifaces.length, 'Monitoring all but one interface', 'Monitoring all but %d interfaces').format(ifaces.length);
36 else
37 return N_(ifaces.length, 'Monitoring one interface', 'Monitoring %d interfaces').format(ifaces.length);
38 }
39 });