Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / modules / luci-base / htdocs / luci-static / resources / protocol / dhcp.js
1 'use strict';
2 'require rpc';
3 'require form';
4 'require network';
5
6 var callFileRead = rpc.declare({
7         object: 'file',
8         method: 'read',
9         params: [ 'path' ],
10         expect: { data: '' },
11         filter: function(value) { return value.trim() }
12 });
13
14 return network.registerProtocol('dhcp', {
15         getI18n: function() {
16                 return _('DHCP client');
17         },
18
19         renderFormOptions: function(s) {
20                 var dev = this.getL2Device() || this.getDevice(), o;
21
22                 o = s.taboption('general', form.Value, 'hostname', _('Hostname to send when requesting DHCP'));
23                 o.datatype    = 'hostname';
24                 o.load = function(section_id) {
25                         return callFileRead('/proc/sys/kernel/hostname').then(L.bind(function(hostname) {
26                                 this.placeholder = hostname;
27                                 return form.Value.prototype.load.apply(this, [section_id]);
28                         }, this));
29                 };
30
31                 o = s.taboption('advanced', form.Flag, 'broadcast', _('Use broadcast flag'), _('Required for certain ISPs, e.g. Charter with DOCSIS 3'));
32                 o.default = o.disabled;
33
34                 o = s.taboption('advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
35                 o.default = o.enabled;
36
37                 o = s.taboption('advanced', form.Flag, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
38                 o.default = o.enabled;
39
40                 o = s.taboption('advanced', form.DynamicList, 'dns', _('Use custom DNS servers'));
41                 o.depends('peerdns', '0');
42                 o.datatype = 'ipaddr';
43                 o.cast     = 'string';
44
45                 o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric'));
46                 o.placeholder = '0';
47                 o.datatype    = 'uinteger';
48
49                 o = s.taboption('advanced', form.Value, 'clientid', _('Client ID to send when requesting DHCP'));
50                 o.datatype  = 'hexstring';
51
52                 s.taboption('advanced', form.Value, 'vendorid', _('Vendor Class to send when requesting DHCP'));
53
54                 o = s.taboption('advanced', form.Value, 'macaddr', _('Override MAC address'));
55                 o.datatype = 'macaddr';
56                 o.placeholder = dev ? (dev.getMAC() || '') : '';
57
58                 o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
59                 o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
60                 o.datatype    = 'max(9200)';
61         }
62 });