From 0c3f396b2fbbe691713b6fe598ff41f8235ca20d Mon Sep 17 00:00:00 2001 From: Ayushman Tripathi Date: Tue, 25 Jul 2023 17:13:26 +0530 Subject: luci-app-babeld: migrate to js Signed-off-by: Ayushman Tripathi [fixup commit message, resolve merge conflict] Signed-off-by: Jo-Philipp Wich --- .../root/www/luci-static/resources/babeld.js | 189 --------------------- 1 file changed, 189 deletions(-) delete mode 100644 applications/luci-app-babeld/root/www/luci-static/resources/babeld.js (limited to 'applications/luci-app-babeld/root/www/luci-static') diff --git a/applications/luci-app-babeld/root/www/luci-static/resources/babeld.js b/applications/luci-app-babeld/root/www/luci-static/resources/babeld.js deleted file mode 100644 index b2468dfbea..0000000000 --- a/applications/luci-app-babeld/root/www/luci-static/resources/babeld.js +++ /dev/null @@ -1,189 +0,0 @@ -function ubus_call(command, argument, params) { - var request_data = {}; - request_data.jsonrpc = "2.0"; - request_data.method = "call"; - request_data.params = [data.ubus_rpc_session, command, argument, params] - var request_json = JSON.stringify(request_data); - var request = new XMLHttpRequest(); - request.open("POST", ubus_url, false); - request.setRequestHeader("Content-type", "application/json"); - request.send(request_json); - if (request.status === 200) { - var response = JSON.parse(request.responseText) - if (!("error" in response) && "result" in response) { - if (response.result.length === 2) { - return response.result[1]; - } - } else { - console.err("Failed query ubus!"); - } - } -} - -function renderTableXRoutes(data, target_id) { - for (var protocol in data) { - var target = document.getElementById(target_id); - - var title = document.createElement('h3'); - title.appendChild(document.createTextNode('X-Routes ' + protocol)); - target.appendChild(title); - - var table = document.createElement('table'); - table.setAttribute('class', 'table'); - table.setAttribute('id', 'babel_overview_xroutes_' + protocol); - - var headerRow = document.createElement('tr'); - headerRow.setAttribute('class', 'tr table-titles'); - var headerContent = '' + protocol + ' Prefix\ - Metric\ - Source-Prefix'; - - headerRow.innerHTML = headerContent; - table.appendChild(headerRow); - - - for (var prefix in data[protocol]) { - var prefixRow = document.createElement('tr'); - prefixRow.setAttribute('class', 'tr'); - var prefixContent = '' + prefix + '\ - ' + data[protocol][prefix]["metric"] + '\ - ' + data[protocol][prefix]["src-prefix"] + ''; - - prefixRow.innerHTML = prefixContent; - table.appendChild(prefixRow); - } - target.appendChild(table); - } -} - -function renderTableRoutes(data, target_id) { - for (var protocol in data) { - var target = document.getElementById(target_id); - - var title = document.createElement('h3'); - title.appendChild(document.createTextNode('Routes ' + protocol)); - target.appendChild(title); - - var table = document.createElement('table'); - table.setAttribute('class', 'table'); - table.setAttribute('id', 'babel_overview_routes_' + protocol); - - var headerRow = document.createElement('tr'); - headerRow.setAttribute('class', 'tr table-titles'); - var headerContent = '' + protocol + ' Prefix\ - Source-Prefix\ - Route-Metric\ - Route Smoothed Metric\ - Refmetric\ - ID\ - Seq. No.\ - Channes\ - Age\ - Via\ - Nexthop\ - Installed\ - Feasible'; - - headerRow.innerHTML = headerContent; - table.appendChild(headerRow); - - for (var prefix in data[protocol]) { - var prefixRow = document.createElement('tr'); - prefixRow.setAttribute('class', 'tr'); - var prefixContent = '' + prefix + '\ - ' + data[protocol][prefix]["src-prefix"] + '\ - ' + data[protocol][prefix]["route_metric"] + '\ - ' + data[protocol][prefix]["route_smoothed_metric"] + '\ - ' + data[protocol][prefix]["refmetric"] + '\ - ' + data[protocol][prefix]["id"] + '\ - ' + data[protocol][prefix]["seqno"] + '\ - ' + data[protocol][prefix]["channels"] + '\ - ' + data[protocol][prefix]["age"] + '\ - ' + data[protocol][prefix]["via"] + '\ - ' + data[protocol][prefix]["nexthop"] + '\ - ' + data[protocol][prefix]["installed"] + '\ - ' + data[protocol][prefix]["feasible"] + ''; - - prefixRow.innerHTML = prefixContent; - table.appendChild(prefixRow); - } - target.appendChild(table); - } -} - -function renderTableNeighbours(data, target_id) { - for (var protocol in data) { - var target = document.getElementById(target_id); - - var title = document.createElement('h3'); - title.appendChild(document.createTextNode('Neighbours ' + protocol)); - target.appendChild(title); - - var table = document.createElement('table'); - table.setAttribute('class', 'table'); - table.setAttribute('id', 'babel_overview_neighbours_' + protocol); - - var headerRow = document.createElement('tr'); - headerRow.setAttribute('class', 'tr table-titles'); - var headerContent = '' + protocol + ' Neighbour\ - Device\ - Hello-Reach\ - RX cost\ - TX cost\ - RTT\ - Channel\ - Interface up'; - - headerRow.innerHTML = headerContent; - table.appendChild(headerRow); - - for (var neighbour in data[protocol]) { - var neighbourRow = document.createElement('tr'); - neighbourRow.setAttribute('class', 'tr'); - var neighbourContent = '' + neighbour + '\ - ' + data[protocol][neighbour]["dev"] + '\ - ' + data[protocol][neighbour]["hello-reach"] + '\ - ' + data[protocol][neighbour]["rxcost"] + '\ - ' + data[protocol][neighbour]["txcost"] + '\ - ' + data[protocol][neighbour]["rtt"] + '\ - ' + data[protocol][neighbour]["channel"] + '\ - ' + data[protocol][neighbour]["if_up"] + ''; - - neighbourRow.innerHTML = neighbourContent; - table.appendChild(neighbourRow); - } - target.appendChild(table); - } -} - -function renderTableInfo(data, target_id) { - var target = document.getElementById(target_id); - - var title = document.createElement('h3'); - title.appendChild(document.createTextNode('Info')); - target.appendChild(title); - - var table = document.createElement('table'); - table.setAttribute('class', 'table'); - table.setAttribute('id', 'babel_overview_info'); - - - var headerRow = document.createElement('tr'); - headerRow.setAttribute('class', 'tr table-titles'); - var headerContent = 'Babeld Version\ - My-ID\ - Host'; - - headerRow.innerHTML = headerContent; - table.appendChild(headerRow); - - var neighbourRow = document.createElement('tr'); - neighbourRow.setAttribute('class', 'tr'); - var neighbourContent = '' + data["babeld-version"] + '\ - ' + data["my-id"] + '\ - ' + data["host"] + ''; - - neighbourRow.innerHTML = neighbourContent; - table.appendChild(neighbourRow); - target.appendChild(table); -} -- cgit v1.2.3