luci-app-statistics: clean and fix plugin configurations
[project/luci.git] / applications / luci-app-statistics / htdocs / luci-static / resources / view / statistics / plugins / openvpn.js
1 'use strict';
2 'require fs';
3 'require form';
4
5 return L.Class.extend({
6 title: _('OpenVPN Plugin Configuration'),
7 description: _('The OpenVPN plugin gathers information about the current vpn connection status.'),
8
9 addFormOptions: function(s) {
10 var o;
11
12 o = s.option(form.Flag, 'enable', _('Enable this plugin'));
13
14 o = s.option(form.Flag, 'CollectIndividualUsers', _('Generate a separate graph for each logged user'));
15 o.depends('enable', '1');
16
17 o = s.option(form.Flag, 'CollectUserCount', _('Aggregate number of connected users'));
18 o.depends('enable', '1');
19
20 o = s.option(form.Flag, 'CollectCompression', _('Gather compression statistics'));
21 o.depends('enable', '1');
22
23 o = s.option(form.Flag, 'ImprovedNamingSchema', _('Use improved naming schema'));
24 o.depends('enable', '1');
25
26 o = s.option(form.DynamicList, 'StatusFile', _('OpenVPN status files'));
27 o.depends('enable', '1');
28 o.load = function(section_id) {
29 return L.resolveDefault(fs.list('/var/run'), []).then(L.bind(function(entries) {
30 for (var i = 0; i < entries.length; i++)
31 if (entries[i].type == 'file' && entries[i].name.match(/^openvpn\..+\.status$/))
32 o.value('/var/run/' + entries[i].name);
33 }, this));
34 };
35 },
36
37 configSummary: function(section) {
38 var stats = L.toArray(section.StatusFile);
39
40 if (stats.length)
41 return N_(stats.length, 'Monitoring one OpenVPN instance', 'Monitoring %d OpenVPN instancees').format(stats.length);
42 }
43 });