luci2: adapt views to changed luci2 framework
[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 return L.network.listNetworkNames().then(function(list) {
8 var m = new L.cbi.Map('network', {
9 readonly: !self.options.acls.network
10 });
11
12 var s4 = m.section(L.cbi.TableSection, 'route', {
13 caption: L.tr('Static IPv4 Routes'),
14 anonymous: true,
15 addremove: true,
16 sortable: true,
17 add_caption: L.tr('Add new route'),
18 remove_caption: L.tr('Remove route')
19 });
20
21 var ifc = s4.option(L.cbi.ListValue, 'interface', {
22 caption: L.tr('Interface')
23 });
24
25 for (var i = 0; i < list.length; i++)
26 ifc.value(list[i]);
27
28 s4.option(L.cbi.InputValue, 'target', {
29 caption: L.tr('Target'),
30 datatype: 'ip4addr'
31 });
32
33 s4.option(L.cbi.InputValue, 'netmask', {
34 caption: L.tr('IPv4-Netmask'),
35 datatype: 'ip4addr',
36 placeholder: '255.255.255.255',
37 optional: true
38 });
39
40 s4.option(L.cbi.InputValue, 'gateway', {
41 caption: L.tr('IPv4-Gateway'),
42 datatype: 'ip4addr',
43 optional: true
44 });
45
46 s4.option(L.cbi.InputValue, 'metric', {
47 caption: L.tr('Metric'),
48 datatype: 'range(0,255)',
49 placeholder: 0,
50 optional: true
51 });
52
53 s4.option(L.cbi.InputValue, 'mtu', {
54 caption: L.tr('MTU'),
55 datatype: 'range(64,9000)',
56 placeholder: 1500,
57 optional: true
58 });
59
60
61 var s6 = m.section(L.cbi.TableSection, 'route6', {
62 caption: L.tr('Static IPv6 Routes'),
63 anonymous: true,
64 addremove: true,
65 sortable: true,
66 add_caption: L.tr('Add new route'),
67 remove_caption: L.tr('Remove route')
68 });
69
70 var ifc = s6.option(L.cbi.ListValue, 'interface', {
71 caption: L.tr('Interface')
72 });
73
74 for (var i = 0; i < list.length; i++)
75 ifc.value(list[i]);
76
77 s6.option(L.cbi.InputValue, 'target', {
78 caption: L.tr('Target'),
79 datatype: 'ip6addr'
80 });
81
82 s6.option(L.cbi.InputValue, 'gateway', {
83 caption: L.tr('IPv6-Gateway'),
84 datatype: 'ip6addr',
85 optional: true
86 });
87
88 s6.option(L.cbi.InputValue, 'metric', {
89 caption: L.tr('Metric'),
90 datatype: 'range(0,255)',
91 placeholder: 0,
92 optional: true
93 });
94
95 s6.option(L.cbi.InputValue, 'mtu', {
96 caption: L.tr('MTU'),
97 datatype: 'range(64,9000)',
98 placeholder: 1500,
99 optional: true
100 });
101
102 m.insertInto('#map');
103 });
104 }
105 });