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