0
0
mirror of https://github.com/openwrt/routing.git synced 2025-02-23 13:56:13 +00:00
Patrick Grimm d27be8dad9 luci-app-olsrd2: New Package for OLSR2 configuration and status visualisation'
Compile tested: mips_24kc, arm_cortex-a9_vfpv3-d16, i386_pentium4, x86_64, i386_pentium-mmx, mipsel_24kc

Signed-off-by: Patrick Grimm <patrick@lunatiki.de>
2023-01-23 14:25:30 +01:00

59 lines
1.5 KiB
JavaScript

'use strict';
'require view';
'require ui';
'require rpc';
'require poll';
var callgetData = rpc.declare({
object: 'status.olsrd2',
method: 'getNeighbors'
});
function createTable(data) {
let tableData = [];
data.neighbors.forEach(row => {
let hostname = E('a',{ 'href': 'https://' + row.hostname + '/cgi-bin-olsrd2-neigh.html'},row.hostname);
let orginator = E('a',{ 'href': 'https://[' + row.originator + ']/cgi-bin-olsrd2-neigh.html'},row.originator);
tableData.push([
hostname,
orginator,
row.lladdr,
row.interface,
row.metric_in,
row.metric_in_raw
])
});
return tableData;
};
return view.extend({
title: _('OLSRD2 mesh neighbors'),
handleSaveApply: null,
handleSave: null,
handleReset: null,
render: function(data) {
var tr = E('table', { 'class': 'table' });
tr.appendChild(E('tr', { 'class': 'tr cbi-section-table-titles' }, [
E('th', { 'class': 'th left' }, [ 'Hostname' ]),
E('th', { 'class': 'th left' }, [ 'Orginator' ]),
E('th', { 'class': 'th left' }, [ 'MAC' ]),
E('th', { 'class': 'th left' }, [ 'Interface' ]),
E('th', { 'class': 'th left' }, [ 'Metric' ]),
E('th', { 'class': 'th left' }, [ 'raw' ])
]));
poll.add(() => {
Promise.all([
callgetData()
]).then((results) => {
cbi_update_table(tr, createTable(results[0]));
})
}, 30);
return tr
}
});