summaryrefslogtreecommitdiff
path: root/luci2/htdocs/luci2/view/network.routes.js
blob: b323c6ea1fe89b571c8304c45ce56d7d3593efbd (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
L.ui.view.extend({
	title: L.tr('Routes'),
	description: L.tr('Routes specify over which interface and gateway a certain host or network can be reached.'),

	execute: function() {
		var self = this;
		var ifaces = L.network.getInterfaces();

		var m = new L.cbi.Map('network', {
			readonly:    !self.options.acls.network
		});

		var s4 = m.section(L.cbi.GridSection, 'route', {
			caption:     L.tr('Static IPv4 Routes'),
			anonymous:   true,
			addremove:   true,
			sortable:    true,
			add_caption: L.tr('Add new route'),
			remove_caption: L.tr('Remove route')
		});

		var ifc = s4.option(L.cbi.ListValue, 'interface', {
			caption:     L.tr('Interface')
		});

		for (var i = 0; i < ifaces.length; i++)
			ifc.value(ifaces[i].name());

		s4.option(L.cbi.InputValue, 'target', {
			caption:     L.tr('Target'),
			datatype:    'ip4addr',
			width:       2
		});

		s4.option(L.cbi.InputValue, 'netmask', {
			caption:     L.tr('IPv4-Netmask'),
			datatype:    'ip4addr',
			placeholder: '255.255.255.255',
			optional:    true,
			width:       2
		});

		s4.option(L.cbi.InputValue, 'gateway', {
			caption:     L.tr('IPv4-Gateway'),
			datatype:    'ip4addr',
			optional:    true,
			width:       2
		});

		s4.option(L.cbi.InputValue, 'metric', {
			caption:     L.tr('Metric'),
			datatype:    'range(0,255)',
			placeholder: 0,
			optional:    true
		});

		s4.option(L.cbi.InputValue, 'mtu', {
			caption:     L.tr('MTU'),
			datatype:    'range(64,9000)',
			placeholder: 1500,
			optional:    true
		});


		var s6 = m.section(L.cbi.GridSection, 'route6', {
			caption:     L.tr('Static IPv6 Routes'),
			anonymous:   true,
			addremove:   true,
			sortable:    true,
			add_caption: L.tr('Add new route'),
			remove_caption: L.tr('Remove route')
		});

		var ifc = s6.option(L.cbi.ListValue, 'interface', {
			caption:     L.tr('Interface')
		});

		for (var i = 0; i < ifaces.length; i++)
			ifc.value(ifaces[i].name());

		s6.option(L.cbi.InputValue, 'target', {
			caption:     L.tr('Target'),
			datatype:    'ip6addr',
			width:       3
		});

		s6.option(L.cbi.InputValue, 'gateway', {
			caption:     L.tr('IPv6-Gateway'),
			datatype:    'ip6addr',
			optional:    true,
			width:       3
		});

		s6.option(L.cbi.InputValue, 'metric', {
			caption:     L.tr('Metric'),
			datatype:    'range(0,255)',
			placeholder: 0,
			optional:    true
		});

		s6.option(L.cbi.InputValue, 'mtu', {
			caption:     L.tr('MTU'),
			datatype:    'range(64,9000)',
			placeholder: 1500,
			optional:    true
		});

		m.insertInto('#map');
	}
});