treewide: remove rendundant proto handler options
[project/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.default = '';
24 o.value('', _('Send the hostname of this device'));
25 o.value('*', _('Do not send a hostname'));
26 o.datatype = 'or(hostname, "*")';
27 o.load = function(section_id) {
28 return callFileRead('/proc/sys/kernel/hostname').then(L.bind(function(hostname) {
29 this.placeholder = hostname;
30 return form.Value.prototype.load.apply(this, [section_id]);
31 }, this));
32 };
33
34 o = s.taboption('advanced', form.Flag, 'broadcast', _('Use broadcast flag'), _('Required for certain ISPs, e.g. Charter with DOCSIS 3'));
35 o.default = o.disabled;
36
37 o = s.taboption('advanced', form.Value, 'clientid', _('Client ID to send when requesting DHCP'));
38 o.datatype = 'hexstring';
39
40 s.taboption('advanced', form.Value, 'vendorid', _('Vendor Class to send when requesting DHCP'));
41
42 o = s.taboption('advanced', form.Value, 'macaddr', _('Override MAC address'));
43 o.datatype = 'macaddr';
44 o.placeholder = dev ? (dev.getMAC() || '') : '';
45
46 o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
47 o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
48 o.datatype = 'max(9200)';
49 }
50 });