luci-proto-batman-adv: add luci-proto-batman-adv
[project/luci.git] / protocols / luci-proto-batman-adv / htdocs / luci-static / resources / protocol / batadv_hardif.js
1 'use strict';
2 'require uci';
3 'require form';
4 'require network';
5
6 network.registerPatternVirtual(/^bat.+$/);
7
8 return network.registerProtocol('batadv_hardif', {
9 getI18n: function() {
10 return _('Batman Interface');
11 },
12
13 getIfname: function() {
14 return this._ubus('l3_device') || this.sid;
15 },
16
17 getOpkgPackage: function() {
18 return 'kmod-batman-adv';
19 },
20
21 isFloating: function() {
22 return false;
23 },
24
25 isVirtual: function() {
26 return false;
27 },
28
29 getDevices: function() {
30 return null;
31 },
32
33 containsDevice: function(ifname) {
34 return (network.getIfnameOf(ifname) == this.getIfname());
35 },
36
37 renderFormOptions: function(s) {
38 var dev = this.getL3Device() || this.getDevice(),
39 o;
40
41 o = s.taboption('general', form.ListValue, 'master', _('Batman Device'),
42 _('This is the batman-adv device where you want to link the physical Device from above to. If this list is empty, then you need to create one first. If you want to route mesh traffic over a wired network device, then please select it from the above Device selector. If you want to assign the batman-adv interface to a Wi-fi mesh then do not select a Device in the Device selector but rather go to the Wireless settings and select this Interface as a network from there.'));
43 var uciInterfaces = uci.sections('network', 'interface');
44
45 for (var i = 0; i < uciInterfaces.length; i++)
46 {
47 if (uciInterfaces[i].proto == 'batadv')
48 {
49 var x=uciInterfaces[i]['.name'];
50 o.value(x);
51 }
52 }
53
54 o = s.taboption('general', form.Value, 'mtu', _('Override MTU'));
55 o.placeholder = dev ? (dev.getMTU() || '1536') : '1536';
56 o.datatype = 'max(9200)';
57 }
58 });