Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / modules / luci-mod-network / htdocs / luci-static / resources / view / network / hosts.js
1 'use strict';
2 'require rpc';
3 'require form';
4
5 return L.view.extend({
6         callHostHints: rpc.declare({
7                 object: 'luci',
8                 method: 'getHostHints',
9                 expect: { '': {} }
10         }),
11
12         load: function() {
13                 return this.callHostHints();
14         },
15
16         render: function(hosts) {
17                 var m, s, o;
18
19                 m = new form.Map('dhcp', _('Hostnames'));
20
21                 s = m.section(form.GridSection, 'domain', _('Host entries'));
22                 s.addremove = true;
23                 s.anonymous = true;
24                 s.sortable  = true;
25
26                 o = s.option(form.Value, 'name', _('Hostname'));
27                 o.datatype = 'hostname';
28                 o.rmempty = true;
29
30                 o = s.option(form.Value, 'ip', _('IP address'));
31                 o.datatype = 'ipaddr';
32                 o.rmempty = true;
33                 L.sortedKeys(hosts, 'ipv4', 'addr').forEach(function(mac) {
34                         o.value(hosts[mac].ipv4, '%s (%s)'.format(
35                                 hosts[mac].ipv4,
36                                 hosts[mac].name || mac
37                         ));
38                 });
39
40                 return m.render();
41         }
42 });