c60fcf9cb5d645cab485b32f33b5c698da71bcaa
[project/luci2/ui.git] / luci2 / htdocs / luci2 / view / network.routes.js
1 L.ui.view.extend({
2 title: L.tr('Routes'),
3 description: L.tr('Routes specify over which interface and gateway a certain host or network can be reached.'),
4
5 execute: function() {
6 var self = this;
7 var ifaces = L.network.getInterfaces();
8
9 var m = new L.cbi.Map('network', {
10 readonly: !self.options.acls.network
11 });
12
13 var s4 = m.section(L.cbi.TableSection, 'route', {
14 caption: L.tr('Static IPv4 Routes'),
15 anonymous: true,
16 addremove: true,
17 sortable: true,
18 add_caption: L.tr('Add new route'),
19 remove_caption: L.tr('Remove route')
20 });
21
22 var ifc = s4.option(L.cbi.ListValue, 'interface', {
23 caption: L.tr('Interface')
24 });
25
26 for (var i = 0; i < ifaces.length; i++)
27 ifc.value(ifaces[i].name());
28
29 s4.option(L.cbi.InputValue, 'target', {
30 caption: L.tr('Target'),
31 datatype: 'ip4addr'
32 });
33
34 s4.option(L.cbi.InputValue, 'netmask', {
35 caption: L.tr('IPv4-Netmask'),
36 datatype: 'ip4addr',
37 placeholder: '255.255.255.255',
38 optional: true
39 });
40
41 s4.option(L.cbi.InputValue, 'gateway', {
42 caption: L.tr('IPv4-Gateway'),
43 datatype: 'ip4addr',
44 optional: true
45 });
46
47 s4.option(L.cbi.InputValue, 'metric', {
48 caption: L.tr('Metric'),
49 datatype: 'range(0,255)',
50 placeholder: 0,
51 optional: true
52 });
53
54 s4.option(L.cbi.InputValue, 'mtu', {
55 caption: L.tr('MTU'),
56 datatype: 'range(64,9000)',
57 placeholder: 1500,
58 optional: true
59 });
60
61
62 var s6 = m.section(L.cbi.TableSection, 'route6', {
63 caption: L.tr('Static IPv6 Routes'),
64 anonymous: true,
65 addremove: true,
66 sortable: true,
67 add_caption: L.tr('Add new route'),
68 remove_caption: L.tr('Remove route')
69 });
70
71 var ifc = s6.option(L.cbi.ListValue, 'interface', {
72 caption: L.tr('Interface')
73 });
74
75 for (var i = 0; i < ifaces.length; i++)
76 ifc.value(ifaces[i].name());
77
78 s6.option(L.cbi.InputValue, 'target', {
79 caption: L.tr('Target'),
80 datatype: 'ip6addr'
81 });
82
83 s6.option(L.cbi.InputValue, 'gateway', {
84 caption: L.tr('IPv6-Gateway'),
85 datatype: 'ip6addr',
86 optional: true
87 });
88
89 s6.option(L.cbi.InputValue, 'metric', {
90 caption: L.tr('Metric'),
91 datatype: 'range(0,255)',
92 placeholder: 0,
93 optional: true
94 });
95
96 s6.option(L.cbi.InputValue, 'mtu', {
97 caption: L.tr('MTU'),
98 datatype: 'range(64,9000)',
99 placeholder: 1500,
100 optional: true
101 });
102
103 m.insertInto('#map');
104 }
105 });