luci2: convert route config to GridSection
[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.GridSection, '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 width: 2
33 });
34
35 s4.option(L.cbi.InputValue, 'netmask', {
36 caption: L.tr('IPv4-Netmask'),
37 datatype: 'ip4addr',
38 placeholder: '255.255.255.255',
39 optional: true,
40 width: 2
41 });
42
43 s4.option(L.cbi.InputValue, 'gateway', {
44 caption: L.tr('IPv4-Gateway'),
45 datatype: 'ip4addr',
46 optional: true,
47 width: 2
48 });
49
50 s4.option(L.cbi.InputValue, 'metric', {
51 caption: L.tr('Metric'),
52 datatype: 'range(0,255)',
53 placeholder: 0,
54 optional: true
55 });
56
57 s4.option(L.cbi.InputValue, 'mtu', {
58 caption: L.tr('MTU'),
59 datatype: 'range(64,9000)',
60 placeholder: 1500,
61 optional: true
62 });
63
64
65 var s6 = m.section(L.cbi.GridSection, 'route6', {
66 caption: L.tr('Static IPv6 Routes'),
67 anonymous: true,
68 addremove: true,
69 sortable: true,
70 add_caption: L.tr('Add new route'),
71 remove_caption: L.tr('Remove route')
72 });
73
74 var ifc = s6.option(L.cbi.ListValue, 'interface', {
75 caption: L.tr('Interface')
76 });
77
78 for (var i = 0; i < ifaces.length; i++)
79 ifc.value(ifaces[i].name());
80
81 s6.option(L.cbi.InputValue, 'target', {
82 caption: L.tr('Target'),
83 datatype: 'ip6addr',
84 width: 3
85 });
86
87 s6.option(L.cbi.InputValue, 'gateway', {
88 caption: L.tr('IPv6-Gateway'),
89 datatype: 'ip6addr',
90 optional: true,
91 width: 3
92 });
93
94 s6.option(L.cbi.InputValue, 'metric', {
95 caption: L.tr('Metric'),
96 datatype: 'range(0,255)',
97 placeholder: 0,
98 optional: true
99 });
100
101 s6.option(L.cbi.InputValue, 'mtu', {
102 caption: L.tr('MTU'),
103 datatype: 'range(64,9000)',
104 placeholder: 1500,
105 optional: true
106 });
107
108 m.insertInto('#map');
109 }
110 });