882fc4c3455b94d03ec5b98e5f985b7e90449171
[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 o.default = '0';
14
15 o = s.option(form.Flag, 'CollectIndividualUsers', _('Generate a separate graph for each logged user'));
16 o.default = '0';
17 o.rmempty = true;
18 o.depends('enable', '1');
19
20 o = s.option(form.Flag, 'CollectUserCount', _('Aggregate number of connected users'));
21 o.default = '0';
22 o.rmempty = true;
23 o.depends('enable', '1');
24
25 o = s.option(form.Flag, 'CollectCompression', _('Gather compression statistics'));
26 o.default = '0';
27 o.rmempty = true;
28 o.depends('enable', '1');
29
30 o = s.option(form.Flag, 'ImprovedNamingSchema', _('Use improved naming schema'));
31 o.default = '0';
32 o.rmempty = true;
33 o.depends('enable', '1');
34
35 o = s.option(form.DynamicList, 'StatusFile', _('OpenVPN status files'));
36 o.rmempty = true;
37 o.depends('enable', '1');
38 o.load = function(section_id) {
39 return L.resolveDefault(fs.list('/var/run'), []).then(L.bind(function(entries) {
40 for (var i = 0; i < entries.length; i++)
41 if (entries[i].type == 'file' && entries[i].name.match(/^openvpn\..+\.status$/))
42 o.value('/var/run/' + entries[i].name);
43 }, this));
44 };
45 },
46
47 configSummary: function(section) {
48 var stats = L.toArray(section.StatusFile);
49
50 if (stats.length)
51 return N_(stats.length, 'Monitoring one OpenVPN instance', 'Monitoring %d OpenVPN instancees').format(stats.length);
52 }
53 });