summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-apinger/htdocs/luci-static/resources/view/apinger/targets.js
blob: ae4d501b54755b3e19e97ec4e43c58949a1a3b75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict';
'require view';
'require form';
'require uci';

return view.extend({
	load: function() {
		return Promise.all([
			uci.load('apinger'),
		])
	},

	render: function(data) {
		var m, s, o;
		var a_ifaces, a_down, a_delay, a_loss;

		a_ifaces = uci.sections('apinger', 'interface');
		a_down = uci.sections('apinger', 'alarm_down');
		a_delay = uci.sections('apinger', 'alarm_delay');
		a_loss = uci.sections('apinger', 'alarm_loss');

		m = new form.Map('apinger', _('Apinger - Targets'),
			_('Interface: Interface to use to track target') + '<br />' +
			_('Address: Target address to be tracked') + '<br />' +
			_('Ping Interval: How often the probe should be sent') + '<br />' +
			_('Average Delay: How many replies should be used to compute average delay') + '<br />' +
			_('Average Loss: How many probes should be used to compute average loss') + '<br />' +
			_('Average Delay and Loss: The delay (in samples) after which loss is computed, without this delays larger than interval would be treated as loss') +
			'<br />');

		s = m.section(form.GridSection, 'target');
		s.anonymous = false;
		s.addremove = true;
		s.addbtntitle = _('Add Target');

		o = s.option(form.ListValue, 'interface', _('Interface'));
		for (var i = 0; i < a_ifaces.length; i++) {
			o.value(a_ifaces[i]['.name']);
		}

		o = s.option(form.Value, 'address', _('Address'));
		o.datatype = 'ip4addr';

		o = s.option(form.Value, 'probe_interval', _('Ping Interval'));
		o.datatype = 'integer';

		o= s.option(form.Value, 'avg_delay_samples', _('Average Delay'));
		o.datatype = 'integer';

		o = s.option(form.Value, 'avg_loss_samples', _('Average Loss'));
		o.datatype = 'integer';

		o = s.option(form.Value, 'avg_loss_delay_samples', _('Average Loss/Delay'));
		o.datatype = 'integer';

		o = s.option(form.Flag, 'rrd', _('Generate RRD Graphs'));
		o.datatype = 'boolean';
		o.default = false;

		o = s.option(form.ListValue, 'alarm_down', _('Down Alarm'));
		for (var i = 0; i < a_down.length; i++) {
			o.value(a_down[i]['.name']);
		}
		o.optional = true;

		o = s.option(form.ListValue, 'alarm_delay', _('Delay Alarm'));
		for (var i = 0; i < a_delay.length; i++) {
			o.value(a_delay[i]['.name']);
		}
		o.optional = true;

		o = s.option(form.ListValue, 'alarm_loss', _('Loss Alarm'));
		for (var i = 0; i < a_loss.length; i++) {
			o.value(a_loss[i]['.name']);
		}
		o.optional = true;

		return m.render();
	},
});