luci-app-olsrd2: New Package for OLSR2 configuration and status visualisation'
[feed/routing.git] / luci-app-olsrd2 / htdocs / luci-static / resources / view / olsrd2 / neighbors.js
1 'use strict';
2 'require view';
3 'require ui';
4 'require rpc';
5 'require poll';
6
7 var callgetData = rpc.declare({
8 object: 'status.olsrd2',
9 method: 'getNeighbors'
10 });
11
12 function createTable(data) {
13 let tableData = [];
14 data.neighbors.forEach(row => {
15 let hostname = E('a',{ 'href': 'https://' + row.hostname + '/cgi-bin-olsrd2-neigh.html'},row.hostname);
16 let orginator = E('a',{ 'href': 'https://[' + row.originator + ']/cgi-bin-olsrd2-neigh.html'},row.originator);
17 tableData.push([
18 hostname,
19 orginator,
20 row.lladdr,
21 row.interface,
22 row.metric_in,
23 row.metric_in_raw
24 ])
25 });
26 return tableData;
27 };
28
29 return view.extend({
30 title: _('OLSRD2 mesh neighbors'),
31 handleSaveApply: null,
32 handleSave: null,
33 handleReset: null,
34
35
36 render: function(data) {
37
38 var tr = E('table', { 'class': 'table' });
39 tr.appendChild(E('tr', { 'class': 'tr cbi-section-table-titles' }, [
40 E('th', { 'class': 'th left' }, [ 'Hostname' ]),
41 E('th', { 'class': 'th left' }, [ 'Orginator' ]),
42 E('th', { 'class': 'th left' }, [ 'MAC' ]),
43 E('th', { 'class': 'th left' }, [ 'Interface' ]),
44 E('th', { 'class': 'th left' }, [ 'Metric' ]),
45 E('th', { 'class': 'th left' }, [ 'raw' ])
46 ]));
47 poll.add(() => {
48 Promise.all([
49 callgetData()
50 ]).then((results) => {
51 cbi_update_table(tr, createTable(results[0]));
52 })
53 }, 30);
54 return tr
55
56 }
57
58 });