diff options
| author | Paul Donald | 2026-02-15 03:50:28 +0000 |
|---|---|---|
| committer | Paul Donald | 2026-02-16 00:42:57 +0000 |
| commit | c567bfc2a8914e944d8e9e0f914099edb2243674 (patch) | |
| tree | 8da6c4dc7e490505b2db8c9a083a05abc4206204 | |
| parent | 25f9cb44a1c0d28b6f0b7b4ab70799d6127366a9 (diff) | |
| download | luci-c567bfc2a8914e944d8e9e0f914099edb2243674.tar.gz | |
luci-app-olsr: js linting fixes / ES6 treatment
Fix errors.
This app has contained errors for a while (indicating no
usage) so is a good candidate to be dropped.
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
33 files changed, 941 insertions, 1399 deletions
diff --git a/applications/luci-app-olsr-services/htdocs/luci-static/resources/view/freifunk-services/services.js b/applications/luci-app-olsr-services/htdocs/luci-static/resources/view/olsr-services/services.js index 74800dfc77..6aec860895 100644 --- a/applications/luci-app-olsr-services/htdocs/luci-static/resources/view/freifunk-services/services.js +++ b/applications/luci-app-olsr-services/htdocs/luci-static/resources/view/olsr-services/services.js @@ -16,9 +16,9 @@ const getOlsrd6Services = rpc.declare({ }); function createTableData(servicesArray) { - var tableData = []; + const tableData = []; servicesArray.forEach(function (service) { - var sourceUrl = service.isIpv6 ? '[' + service.source + ']' : service.source; + const sourceUrl = service.isIpv6 ? '[' + service.source + ']' : service.source; tableData.push( [ E('a', { 'href': service.url }, service.description), @@ -31,17 +31,17 @@ function createTableData(servicesArray) { } function extractServiceInformation(results) { - var servicesArray = []; + const servicesArray = []; results.forEach(function(result) { if (result.configured && result.services != "") { - var isIpv6 = result.source == "olsrd6"; - var services = result.services.split('\n'); + const isIpv6 = result.source == "olsrd6"; + const services = result.services.split('\n'); services.forEach(function (service) { - var source = service.split('#')[1]; - var serviceRawDescription = service.replace(/\t/g, '').split('#')[0].split('|'); - var url = serviceRawDescription[0]; - var protocol = serviceRawDescription[1]; - var description = serviceRawDescription[2]; + const source = service.split('#')[1]; + const serviceRawDescription = service.replace(/\t/g, '').split('#')[0].split('|'); + const url = serviceRawDescription[0]; + const protocol = serviceRawDescription[1]; + const description = serviceRawDescription[2]; servicesArray.push({ "source": source, "url": url, "protocol": protocol, "description": description, "isIpv6": isIpv6 }); }); } @@ -53,7 +53,7 @@ return view.extend({ handleSaveApply: null, handleSave: null, handleReset: null, - render: function (data) { + render() { poll.add(function () { Promise.all([getOlsrd4Services(), getOlsrd6Services()]).then(function (results) { var servicesArray = extractServiceInformation(results); diff --git a/applications/luci-app-olsr-services/root/usr/libexec/rpcd/olsr-services b/applications/luci-app-olsr-services/root/usr/libexec/rpcd/olsr-services index 20cf496e76..915329b327 100755 --- a/applications/luci-app-olsr-services/root/usr/libexec/rpcd/olsr-services +++ b/applications/luci-app-olsr-services/root/usr/libexec/rpcd/olsr-services @@ -6,45 +6,45 @@ SERVICESFILE="-1" find_service_config() { - local cfg="$1" + local cfg="$1" - config_get library "$cfg" library - if [ "$library" != "olsrd_nameservice" ]; then - return 1 - fi - config_get services_file "$cfg" services_file - SERVICESFILE=$services_file + config_get library "$cfg" library + if [ "$library" != "olsrd_nameservice" ]; then + return 1 + fi + config_get services_file "$cfg" services_file + SERVICESFILE=$services_file } load_services() { - local olsrd="$1" - config_load $olsrd - config_foreach find_service_config LoadPlugin - local services_configured=0 - if [ "$SERVICESFILE" != "-1" ]; then - services_configured=1 - fi - local services=$(cat $SERVICESFILE|grep -ve "^###"|grep -ve "^$") - json_init - json_add_boolean configured $services_configured - json_add_string source "$olsrd" - json_add_string services "$services" - json_dump + local olsrd="$1" + config_load $olsrd + config_foreach find_service_config LoadPlugin + local services_configured=0 + if [ "$SERVICESFILE" != "-1" ]; then + services_configured=1 + fi + local services=$(cat $SERVICESFILE|grep -ve "^###"|grep -ve "^$") + json_init + json_add_boolean configured $services_configured + json_add_string source "$olsrd" + json_add_string services "$services" + json_dump } case "$1" in - list) - # List method must return the list of methods and parameters that the daemon will accept. Only methods listed here will available to call. - echo '{ "services4": { }, "services6": { } }' - ;; - call) - case "$2" in - services4) - load_services "olsrd" - ;; - services6) - load_services "olsrd6" - ;; - esac - ;; + list) + # List method must return the list of methods and parameters that the daemon will accept. Only methods listed here will available to call. + echo '{ "services4": { }, "services6": { } }' + ;; + call) + case "$2" in + services4) + load_services "olsrd" + ;; + services6) + load_services "olsrd6" + ;; + esac + ;; esac diff --git a/applications/luci-app-olsr-services/root/usr/share/luci/menu.d/luci-app-olsr-services.json b/applications/luci-app-olsr-services/root/usr/share/luci/menu.d/luci-app-olsr-services.json index ebff30ebe8..eea4bc10eb 100644 --- a/applications/luci-app-olsr-services/root/usr/share/luci/menu.d/luci-app-olsr-services.json +++ b/applications/luci-app-olsr-services/root/usr/share/luci/menu.d/luci-app-olsr-services.json @@ -1,13 +1,16 @@ { - "freifunk/services": { - "title": "Services", + "admin/services/olsr": { + "title": "OLSR Services", "order": 30, - "depends": { + "depends_comment":{ "uci" : {"olsrd": {"@LoadPlugin": {"library": "olsrd_nameservice" }}} + }, + "depends": { + "uci" : ["olsrd"] }, "action": { "type": "view", - "path": "freifunk-services/services" + "path": "olsr-services/services" } } } diff --git a/applications/luci-app-olsr-services/root/usr/share/rpcd/acl.d/luci-app-olsr-services-unauthenticated.json b/applications/luci-app-olsr-services/root/usr/share/rpcd/acl.d/luci-app-olsr-services-unauthenticated.json new file mode 100644 index 0000000000..e337f61918 --- /dev/null +++ b/applications/luci-app-olsr-services/root/usr/share/rpcd/acl.d/luci-app-olsr-services-unauthenticated.json @@ -0,0 +1,13 @@ +{ + "unauthenticated": { + "description": "Grant access to OLSRd config and services file", + "read": { + "ubus": { + "olsr-services": [ + "services4", + "services6" + ] + } + } + } +}
\ No newline at end of file diff --git a/applications/luci-app-olsr-services/root/usr/share/rpcd/acl.d/luci-app-olsr-services.json b/applications/luci-app-olsr-services/root/usr/share/rpcd/acl.d/luci-app-olsr-services.json index e337f61918..b06d6669e5 100644 --- a/applications/luci-app-olsr-services/root/usr/share/rpcd/acl.d/luci-app-olsr-services.json +++ b/applications/luci-app-olsr-services/root/usr/share/rpcd/acl.d/luci-app-olsr-services.json @@ -1,5 +1,5 @@ { - "unauthenticated": { + "luci-app-olsr-services": { "description": "Grant access to OLSRd config and services file", "read": { "ubus": { diff --git a/applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js b/applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js index 1a35596e69..1797964702 100644 --- a/applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js +++ b/applications/luci-app-olsr-viz/htdocs/luci-static/resources/olsr-viz.js @@ -34,39 +34,39 @@ Changes: 2010-12-11: Changed some paths to make it work with Kamikaze and Luci -- soma */ -var maxmetric = 3; -var iconvariant = "-mini"; -var nodes = new Array(); -var ncount = 0; -var newnodes = new Array(); -var edges = new Array(); -var iel = 220; // ideal edge length -var optsize = 10; // boundingbox around nodes - -var vwidth = 0; -var vheight = 0; - -var xoff = 0; -var yoff = 0; -var scale = 1.0; - -var idle_timeout = 15; -var erase_timeout = 60; -var dcl_timeout = 250; -var dcllow_timeout = 500; -var auto_declump = true; -var showdesc = true; -var auto_save = 1; -var now_secs = 5; +let maxmetric = 3; +let iconvariant = "-mini"; +let nodes = new Array(); +let ncount = 0; +let newnodes = new Array(); +let edges = new Array(); +let iel = 220; // ideal edge length +let optsize = 10; // boundingbox around nodes + +let vwidth = 0; +let vheight = 0; + +let xoff = 0; +let yoff = 0; +let scale = 1.0; + +let idle_timeout = 15; +let erase_timeout = 60; +let dcl_timeout = 250; +let dcllow_timeout = 500; +let auto_declump = true; +let showdesc = true; +let auto_save = 1; +let now_secs = 5; // dom elements -var IFrameObj; -var mainDiv; -var nodeDiv; -var edgeDiv; -var zoomInput; -var maxmetricInput; -var debugSpan; +let IFrameObj; +let mainDiv; +let nodeDiv; +let edgeDiv; +let zoomInput; +let maxmetricInput; +let debugSpan; /******** EDGE CLASS ********/ @@ -263,23 +263,23 @@ function touch_node(ip) { } function place_new_nodes() { - var nc = 0; - for (var i = 0; i < newnodes.length; i++) { - var n = newnodes[i]; + let nc = 0; + for (let i = 0; i < newnodes.length; i++) { + let n = newnodes[i]; if (n.placed) { continue; } - var sp; - if (sp = getCookie("node_" + n.ip)) { - var xy = sp.split("x"); + let sp; + if (sp == getCookie("node_" + n.ip)) { + let xy = sp.split("x"); debug_writeln(("sp: " + sp + " xy[0]: " + xy[0] + " xy[1]: " + xy[1])); n.x = parseFloat(xy[0]); n.y = parseFloat(xy[1]); } else if (n.weight > 1) { // see if we find already placed nodes - var ox = 0, oy = 0; - var dx = 0, dy = 0; - var c = 0; - for (var e in n.edges) { + let ox = 0, oy = 0; + let dx = 0, dy = 0; + let c = 0; + for (let e in n.edges) { if (nodes[e] && nodes[e].placed) { if (!ox && !oy) { ox = nodes[e].x; @@ -528,12 +528,12 @@ function fa(x) { return Math.pow((x * x) / iel, 2); } -var dclTimer = 0; -var declump_running = false; -function declump(t) { - var dx; - var dy; - var d; +let dclTimer = 0; +let declump_running = false; +function declump() { + let dx; + let dy; + let d; // clear declump timer if (dclTimer) { @@ -545,8 +545,7 @@ function declump(t) { declump_running = true; // nodes - var nc = 0; - for (var ip1 in nodes) { + for (let ip1 in nodes) { nodes[ip1].fr_x = 0; nodes[ip1].fr_y = 0; nodes[ip1].fa_x = 0; @@ -555,11 +554,11 @@ function declump(t) { nodes[ip1].y_next = nodes[ip1].y; nodes[ip1].randdisplace = 0; } - for (var ip1 in nodes) { + for (let ip1 in nodes) { if (nodes[ip1].metric > maxmetric || nodes[ip1].pinned) { continue; } - for (var ip2 in nodes) { + for (let ip2 in nodes) { if (nodes[ip2].metric > maxmetric || ip1 == ip2) { continue; } @@ -575,15 +574,13 @@ function declump(t) { dx = nodes[ip1].fr_x; dy = nodes[ip1].fr_y; d = Math.sqrt(dx * dx + dy * dy); - var md = Math.min(d, iel / nodes[ip1].weight); + let md = Math.min(d, iel / nodes[ip1].weight); nodes[ip1].x_next += (dx / d) * md; nodes[ip1].y_next += (dy / d) * md; - nc++; } // edges - var ec = 0; - for (var e in edges) { + for (let e in edges) { if (!edges[e].n1 || !edges[e].n2 || edges[e].n1.metric > maxmetric || edges[e].n2.metric > maxmetric) { continue; @@ -597,16 +594,15 @@ function declump(t) { edges[e].n1.fa_y -= (dy / d) * fa(d); edges[e].n2.fa_x += (dx / d) * fa(d); edges[e].n2.fa_y += (dy / d) * fa(d); - ec++; } // displacement - var xmin = -20; - var ymin = -20; - var xmax = 20; - var ymax = 20; - var dsum = 0; - for (var ip in nodes) { + let xmin = -20; + let ymin = -20; + let xmax = 20; + let ymax = 20; + let dsum = 0; + for (let ip in nodes) { if (nodes[ip].metric > maxmetric || nodes[ip].pinned) { continue; } @@ -657,15 +653,15 @@ function declump(t) { } //Das Objekt, das gerade bewegt wird. -var dragip = null; +let dragip = null; // Position, an der das Objekt angeklickt wurde. -var dragx = 0; -var dragy = 0; +let dragx = 0; +let dragy = 0; // Mausposition -var posx = 0; -var posy = 0; +let posx = 0; +let posy = 0; function draginit() { // Initialisierung der ãberwachung der Events @@ -681,7 +677,7 @@ function dragstart(element) { dragx = posx - element.offsetLeft; dragy = posy - element.offsetTop; - var n = nodes[dragip]; + let n = nodes[dragip]; if (n) { n.pinned = true; } @@ -691,7 +687,7 @@ function dragstart(element) { function dragstop() { //Wird aufgerufen, wenn ein Objekt nicht mehr bewegt werden soll. - var n = nodes[dragip]; + let n = nodes[dragip]; if (n) { n.pinned = false; } @@ -706,12 +702,12 @@ function drag(ereignis) { posx = document.all ? window.event.clientX : ereignis.pageX; posy = document.all ? window.event.clientY : ereignis.pageY; if (dragip != null) { - var n = nodes[dragip]; + let n = nodes[dragip]; if (n) { n.x = (posx - dragx) / scale - xoff; n.y = (posy - dragy) / scale - yoff; } - var e = document.getElementById('node_' + dragip); + let e = document.getElementById('node_' + dragip); e.style.left = parseInt((n.x + xoff) * scale) + "px"; e.style.top = parseInt((n.y + yoff) * scale) + "px"; } @@ -752,7 +748,7 @@ function setCookie(name, value, expires, path, domain, secure) { */ function getCookie(name) { - var results = document.cookie.match(name + '=(.*?)(;|$)'); + let results = document.cookie.match(name + '=(.*?)(;|$)'); if (results) { return unescape(results[1]); } @@ -777,8 +773,8 @@ function deleteCookie(name, path, domain) { } function deleteAllCookies() { - var cookies = document.cookie.split("; "); - for (var i = 0; i < cookies.length; i++) { + const cookies = document.cookie.split("; "); + for (let i = 0; i < cookies.length; i++) { deleteCookie(cookies[i].split("=")[0]); } } diff --git a/applications/luci-app-olsr-viz/htdocs/luci-static/resources/view/olsr-viz/olsr-viz-view.js b/applications/luci-app-olsr-viz/htdocs/luci-static/resources/view/olsr-viz/olsr-viz-view.js index 7624e0e7b2..c26f6f2771 100644 --- a/applications/luci-app-olsr-viz/htdocs/luci-static/resources/view/olsr-viz/olsr-viz-view.js +++ b/applications/luci-app-olsr-viz/htdocs/luci-static/resources/view/olsr-viz/olsr-viz-view.js @@ -4,6 +4,7 @@ 'require poll'; 'require ui'; 'require rpc'; +'require olsr-viz as olsrviz'; return view.extend({ @@ -12,11 +13,10 @@ return view.extend({ method: 'getolsrvizdata' }), - fetch_jsoninfo: function () { - var jsonreq4 = ''; - var json; - var data; - var self = this; + fetch_jsoninfo() { + let json; + let data; + let self = this; return new Promise(function (resolve, reject) { L.resolveDefault(self.callGetOlsrVizData(), {}) .then(function (res) { @@ -31,13 +31,13 @@ return view.extend({ }); }, - action_olsr_viz: function () { - var self = this; + action_olsr_viz() { + let self = this; return new Promise(function (resolve, reject) { self .fetch_jsoninfo() .then(function ([data]) { - var result = { viz_data: data }; + const result = { viz_data: data }; resolve(result); }) .catch(function (err) { @@ -46,36 +46,34 @@ return view.extend({ }); }, - load: function () { - var self = this; + load() { document.querySelector('head').appendChild(E('style', { 'type': 'text/css' }, [ '.label {color:black;background-color:white}', '.olsr_viz_main {width: 100%; height: 93%; border: 1px solid #ccc; margin-left:auto; margin-right:auto; text-align:center; overflow: scroll}' ])); return new Promise(function (resolve, reject) { - var script = E('script', { 'type': 'text/javascript' }); + const script = E('script', { 'type': 'text/javascript' }); script.onload = resolve; script.onerror = reject; script.src = L.resource('olsr-viz.js'); document.querySelector('head').appendChild(script); }); }, - render: function () { - var viz_res; - var self = this; + render() { + let viz_res; return this.action_olsr_viz() .then(function (result) { viz_res = result.viz_data; - var nodeDiv = E('div', { 'id': 'nodes', 'style': 'width: 1px; height: 1px; position: relative; z-index:4' }); - var edgeDiv = E('div', { 'id': 'edges', 'style': 'width: 1px; height: 1px; position: relative; z-index:2' }); + const nodeDiv = E('div', { 'id': 'nodes', 'style': 'width: 1px; height: 1px; position: relative; z-index:4' }); + const edgeDiv = E('div', { 'id': 'edges', 'style': 'width: 1px; height: 1px; position: relative; z-index:2' }); - var mainDiv = E('div', { + const mainDiv = E('div', { 'id': 'main', 'class': 'olsr_viz_main' }, [nodeDiv, edgeDiv]); - var zoomInput = E('input', { + const zoomInput = E('input', { 'id': 'zoom', 'name': 'zoom', 'type': 'text', @@ -84,52 +82,52 @@ return view.extend({ 'style': 'min-width: unset !important;', 'onchange': 'set_scale()' }); - var metricInput = E('input', { + const metricInput = E('input', { 'id': 'maxmetric', 'name': 'maxmetric', 'type': 'text', 'value': '3', 'size': '4', 'style': 'min-width: unset !important;', - 'change': (ev)=>set_maxmetric(ev.target.value) + 'change': (ev)=>olsrviz.set_maxmetric(ev.target.value) }); - var autoOptimizationCheckbox = E('input', { + const autoOptimizationCheckbox = E('input', { 'id': 'auto_declump', 'name': 'auto_declump', 'type': 'checkbox', - 'change': (ev) => set_autodeclump(ev.target.checked), + 'change': (ev) => olsrviz.set_autodeclump(ev.target.checked), 'checked': 'checked' }); - var hostnamesCheckbox = E('input', { + const hostnamesCheckbox = E('input', { 'id': 'show_hostnames', 'name': 'show_hostnames', 'type': 'checkbox', - 'change': (ev) => set_showdesc(ev.target.checked), + 'change': (ev) => olsrviz.set_showdesc(ev.target.checked), 'checked': 'checked' }); - var form = E('form', { 'action': '' }, [ + const form = E('form', { 'action': '' }, [ E('p', {}, [ E('b', { 'title': 'Bestimmt die Vergrößerungsstufe.' }, 'Zoom '), - E('a', { 'href': '#', 'click': () =>set_scale(scale+0.1) }, '+ '), - E('a', { 'href': '#', 'click': () =>set_scale(scale-0.1) }, '\u2212 '), + E('a', { 'href': '#', 'click': () =>olsrviz.set_scale(scale+0.1) }, '+ '), + E('a', { 'href': '#', 'click': () =>olsrviz.set_scale(scale-0.1) }, '\u2212 '), zoomInput, E('b', { 'title': 'Beschränkt die Anzeige auf eine maximale Hop-Entfernung.' }, ' Metrik'), - E('a', { 'href': '#', 'click': () => set_maxmetric(maxmetric+1) }, '+ '), - E('a', { 'href': '#', 'click': () => set_maxmetric(Math.max(maxmetric, 1) - 1) }, '\u2212'), + E('a', { 'href': '#', 'click': () => olsrviz.set_maxmetric(maxmetric+1) }, '+ '), + E('a', { 'href': '#', 'click': () => olsrviz.set_maxmetric(Math.max(maxmetric, 1) - 1) }, '\u2212'), metricInput, E('b', { 'title': 'Schaltet die automatischen Layout-Optimierung ein.' }, ' Optimierung'), autoOptimizationCheckbox, E('b', { 'title': 'Zeige Hostnamen an.' }, ' | Hostnamen'), hostnamesCheckbox, - E('a', { 'href': '#', 'click': viz_save, 'title': 'Speichert die aktuellen Einstellungen in einem Cookie.', 'style': 'font-weight:700;' }, ' | Speichern'), - E('a', { 'href': '#', 'click': viz_reset, 'title': 'Startet das Viz-Skriptprogramm neu.', 'style': 'font-weight:700;' }, ' | Zurücksetzen') + E('a', { 'href': '#', 'click': olsrviz.viz_save, 'title': 'Speichert die aktuellen Einstellungen in einem Cookie.', 'style': 'font-weight:700;' }, ' | Speichern'), + E('a', { 'href': '#', 'click': olsrviz.viz_reset, 'title': 'Startet das Viz-Skriptprogramm neu.', 'style': 'font-weight:700;' }, ' | Zurücksetzen') ]) ]); - var debugSpan = E('span', { 'id': 'debug', 'style': 'visibility:hidden;' }); - var vizDiv = E('div', { 'id': 'RSIFrame', 'name': 'RSIFrame', 'style': 'border:0px; width:0px; height:0px; visibility:hidden;' }); - viz_setup(vizDiv, mainDiv, nodeDiv, edgeDiv, debugSpan, zoomInput, metricInput); viz_update(); + const debugSpan = E('span', { 'id': 'debug', 'style': 'visibility:hidden;' }); + const vizDiv = E('div', { 'id': 'RSIFrame', 'name': 'RSIFrame', 'style': 'border:0px; width:0px; height:0px; visibility:hidden;' }); + olsrviz.viz_setup(vizDiv, mainDiv, nodeDiv, edgeDiv, debugSpan, zoomInput, metricInput); olsrviz.viz_update(); function setInnerHTML(elm, html) { elm.innerHTML = html; @@ -151,9 +149,9 @@ return view.extend({ setInnerHTML(vizDiv, viz_res); - var renderDiv = E('div', { 'style': 'width:100%; height:640px; border:none', 'scrolling': 'no' }, [mainDiv]); - var result = E([], {}, [form, debugSpan, renderDiv, vizDiv]); - return result; + const renderDiv = E('div', { 'style': 'width:100%; height:640px; border:none', 'scrolling': 'no' }, [mainDiv]); + const fresult = E([], {}, [form, debugSpan, renderDiv, vizDiv]); + return fresult; }) .catch(function (error) { console.error(error); diff --git a/applications/luci-app-olsr-viz/root/usr/share/luci/menu.d/luci-app-olsr-viz.json b/applications/luci-app-olsr-viz/root/usr/share/luci/menu.d/luci-app-olsr-viz.json index ad6393b4ac..2c3848b42f 100644 --- a/applications/luci-app-olsr-viz/root/usr/share/luci/menu.d/luci-app-olsr-viz.json +++ b/applications/luci-app-olsr-viz/root/usr/share/luci/menu.d/luci-app-olsr-viz.json @@ -1,6 +1,5 @@ { - - "olsr/olsr-viz": { + "admin/olsr/olsr-viz": { "title": "OLSR Visualization", "order": 100, "action": { @@ -8,5 +7,4 @@ "path": "olsr-viz/olsr-viz-view" } } - } diff --git a/applications/luci-app-olsr-viz/root/usr/share/rpcd/acl.d/luci-app-olsr-viz.json b/applications/luci-app-olsr-viz/root/usr/share/rpcd/acl.d/luci-app-olsr-viz.json new file mode 100644 index 0000000000..8ed098c0d0 --- /dev/null +++ b/applications/luci-app-olsr-viz/root/usr/share/rpcd/acl.d/luci-app-olsr-viz.json @@ -0,0 +1,12 @@ +{ + "luci-app-olsr-viz": { + "description": "Grant read access for luci-app-olsr-viz", + "read": { + "ubus": { + "olsrvizinfo": [ + "getolsrvizdata" + ] + } + } + } +} diff --git a/applications/luci-app-olsr/Makefile b/applications/luci-app-olsr/Makefile index 7291df0f91..5b598bd742 100644 --- a/applications/luci-app-olsr/Makefile +++ b/applications/luci-app-olsr/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=OLSR configuration and status module -LUCI_DEPENDS:=+luci-base +olsrd +LUCI_DEPENDS:=+luci-base +olsrd +olsrd-mod-jsoninfo +olsrd-mod-sgwdynspeed PKG_LICENSE:=Apache-2.0 PKG_MAINTAINER:=Manuel Munz <munz@comuno.net> diff --git a/applications/luci-app-olsr/htdocs/cgi-bin-nodes.html b/applications/luci-app-olsr/htdocs/cgi-bin-nodes.html deleted file mode 120000 index 80d235f15b..0000000000 --- a/applications/luci-app-olsr/htdocs/cgi-bin-nodes.html +++ /dev/null @@ -1 +0,0 @@ -cgi-bin-status.html
\ No newline at end of file diff --git a/applications/luci-app-olsr/htdocs/cgi-bin-status.html b/applications/luci-app-olsr/htdocs/cgi-bin-status.html deleted file mode 100644 index c6061b4334..0000000000 --- a/applications/luci-app-olsr/htdocs/cgi-bin-status.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<html> -<head> -<meta http-equiv="refresh" content="0; URL=/cgi-bin/luci/freifunk/olsr/neighbors" /> -</head> -<body style="background-color: black"> -<a style="color: white; text-decoration: none" href="/cgi-bin/luci/freifunk/olsr/neighbors">LuCI - Lua Configuration Interface</a> -</body> -</html> diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/common/common_js.js b/applications/luci-app-olsr/htdocs/luci-static/resources/common/common_js.js deleted file mode 100644 index 126bcece59..0000000000 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/common/common_js.js +++ /dev/null @@ -1,34 +0,0 @@ -function css(selector, property, value) { - for (var i = 0; i < document.styleSheets.length; i++) { - try { - document.styleSheets[i].insertRule(selector + ' {' + property + ':' + value + '}', document.styleSheets[i].cssRules.length); - } catch (err) { - try { - document.styleSheets[i].addRule(selector, property + ':' + value); - } catch (err) {} - } //IE - } -} - -window.onload = function () { - var buttons = '<input type="button" name="show-proto-4" id="show-proto-4" class="cbi-button cbi-button-apply" style="margin-right: 5px" value="<%:Hide IPv4%>">'; - buttons += '<input type="button" name="show-proto-6" id="show-proto-6" class="cbi-button cbi-button-apply" value="<%:Hide IPv6%>">'; - - document.getElementById('togglebuttons').innerHTML = buttons; - - var visible = true; - document.getElementById('show-proto-4').onclick = function () { - visible = !visible; - document.getElementById('show-proto-4').value = visible ? '<%:Hide IPv4%>' : '<%:Show IPv4%>'; - document.getElementById('show-proto-4').className = visible ? 'cbi-button cbi-button-apply' : 'cbi-button cbi-button-reset'; - css('.proto-4', 'display', visible ? 'table-row' : 'none'); - }; - - var visible6 = true; - document.getElementById('show-proto-6').onclick = function () { - visible6 = !visible6; - document.getElementById('show-proto-6').value = visible6 ? '<%:Hide IPv6%>' : '<%:Show IPv6%>'; - document.getElementById('show-proto-6').className = visible6 ? 'cbi-button cbi-button-apply' : 'cbi-button cbi-button-reset'; - css('.proto-6', 'display', visible6 ? 'table-row' : 'none'); - }; -}; diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/olsr/common_js.js b/applications/luci-app-olsr/htdocs/luci-static/resources/olsr/common_js.js new file mode 100644 index 0000000000..81a78435a6 --- /dev/null +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/olsr/common_js.js @@ -0,0 +1,157 @@ +'use strict'; +'require rpc'; +'require uci'; +'require view'; + +function etx_color(etx) { + let color = '#bb3333'; + if (etx === 0) { + color = '#bb3333'; + } else if (etx < 2) { + color = '#00cc00'; + } else if (etx < 4) { + color = '#ffcb05'; + } else if (etx < 10) { + color = '#ff6600'; + } + return color; +} + +function snr_colors(snr) { + let color = '#bb3333'; + if (snr === 0) { + color = '#bb3333'; + } else if (snr > 30) { + color = '#00cc00'; + } else if (snr > 20) { + color = '#ffcb05'; + } else if (snr > 5) { + color = '#ff6600'; + } + return color; +} + +function css(selector, property, value) { + for (let i = 0; i < document.styleSheets.length; i++) { + try { + document.styleSheets[i].insertRule(selector + ' {' + property + ':' + value + '}', document.styleSheets[i].cssRules.length); + } catch (err) { + try { + document.styleSheets[i].addRule(selector, property + ':' + value); + } catch (err) {} + } //IE + } +} + +window.onload = function () { + let buttons = '<input type="button" name="show-proto-4" id="show-proto-4" class="cbi-button cbi-button-apply" style="margin-right: 5px" value="<%:Hide IPv4%>">'; + buttons += '<input type="button" name="show-proto-6" id="show-proto-6" class="cbi-button cbi-button-apply" value="<%:Hide IPv6%>">'; + + document.getElementById('togglebuttons').innerHTML = buttons; + + let visible = true; + document.getElementById('show-proto-4').onclick = function () { + visible = !visible; + document.getElementById('show-proto-4').value = visible ? '<%:Hide IPv4%>' : '<%:Show IPv4%>'; + document.getElementById('show-proto-4').className = visible ? 'cbi-button cbi-button-apply' : 'cbi-button cbi-button-reset'; + css('.proto-4', 'display', visible ? 'table-row' : 'none'); + }; + + let visible6 = true; + document.getElementById('show-proto-6').onclick = function () { + visible6 = !visible6; + document.getElementById('show-proto-6').value = visible6 ? '<%:Hide IPv6%>' : '<%:Show IPv6%>'; + document.getElementById('show-proto-6').className = visible6 ? 'cbi-button cbi-button-apply' : 'cbi-button cbi-button-reset'; + css('.proto-6', 'display', visible6 ? 'table-row' : 'none'); + }; +}; + + +const olsrview = view.extend({ + + callGetJsonStatus: rpc.declare({ + object: 'olsrinfo', + method: 'getjsondata', + params: ['otable', 'v4_port', 'v6_port'], + }), + + callGetHosts: rpc.declare({ + object: 'olsrinfo', + method: 'hosts', + }), + + fetch_jsoninfo(otable) { + let jsonreq4 = ''; + let jsonreq6 = ''; + const v4_port = parseInt(uci.get('olsrd', 'olsrd_jsoninfo', 'port') || '') || 9090; + const v6_port = parseInt(uci.get('olsrd6', 'olsrd_jsoninfo', 'port') || '') || 9090; + let json; + let self = this; + return new Promise(function (resolve, reject) { + L.resolveDefault(self.callGetJsonStatus(otable, v4_port, v6_port), {}) + .then(function (res) { + json = res; + + if (json.jsonreq4 === '' && json.jsonreq6 === '') { + window.location.href = 'error_olsr'; + reject([null, 0, 0, true]); + return; + } + + + jsonreq4 = JSON.parse(json.jsonreq4); + jsonreq6 = json.jsonreq6 !== '' ? JSON.parse(json.jsonreq6) : []; + let jsondata4 = {}; + let jsondata6 = {}; + let data4 = []; + let data6 = []; + let has_v4 = false; + let has_v6 = false; + + if (jsonreq4 !== '') { + has_v4 = true; + jsondata4 = jsonreq4 || {}; + if (otable === 'status') { + data4 = jsondata4; + } else { + data4 = jsondata4[otable] || []; + } + + for (var i = 0; i < data4.length; i++) { + data4[i]['proto'] = '4'; + } + } + + if (jsonreq6 !== '') { + has_v6 = true; + jsondata6 = jsonreq6 || {}; + if (otable === 'status') { + data6 = jsondata6; + } else { + data6 = jsondata6[otable] || []; + } + + for (var j = 0; j < data6.length; j++) { + data6[j]['proto'] = '6'; + } + } + + for (let d6 of data6) { + data4.push(d6); + } + + resolve([data4, has_v4, has_v6, false]); + }) + .catch(function (err) { + console.error(err); + reject([null, 0, 0, true]); + }); + }); + }, + +}); + +return L.Class.extend({ + olsrview: olsrview, + +});
\ No newline at end of file diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrd.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrd.js index fdabf1b6ff..5955449d36 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrd.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrd.js @@ -11,11 +11,11 @@ return view.extend({ object: 'olsrinfo', method: 'hasipip', }), - load: function () { + load() { return Promise.all([uci.load('olsrd').then(() => { - var hasDefaults = false; + let hasDefaults = false; - uci.sections('olsrd', 'InterfaceDefaults', function (s) { + uci.sections('olsrd', 'InterfaceDefaults', () => { hasDefaults = true; return false; }); @@ -25,10 +25,10 @@ return view.extend({ } })]); }, - render: function () { - let m, s, o; + render() { + let m, s; - var has_ipip; + let has_ipip; m = new form.Map( 'olsrd', @@ -47,7 +47,7 @@ return view.extend({ s.tab('lquality', _('Link Quality Settings')); this.callHasIpIp() .then(function (res) { - var output = res.result; + const output = res.result; has_ipip = output.trim().length > 0; }) .catch(function (err) { @@ -55,7 +55,7 @@ return view.extend({ }) .finally(function () { s.tab('smartgw', _('SmartGW'), !has_ipip && _('Warning: kmod-ipip is not installed. Without kmod-ipip SmartGateway will not work, please install it.')); - var sgw = s.taboption('smartgw', form.Flag, 'SmartGateway', _('Enable'), _('Enable SmartGateway. If it is disabled, then ' + 'all other SmartGateway parameters are ignored. Default is "no".')); + let sgw = s.taboption('smartgw', form.Flag, 'SmartGateway', _('Enable'), _('Enable SmartGateway. If it is disabled, then ' + 'all other SmartGateway parameters are ignored. Default is "no".')); sgw.default = 'no'; sgw.enabled = 'yes'; sgw.disabled = 'no'; @@ -64,7 +64,7 @@ return view.extend({ return uci.get('olsrd', section_id, 'SmartGateway') || 'no'; }; - var sgwnat = s.taboption('smartgw', form.Flag, 'SmartGatewayAllowNAT', _('Allow gateways with NAT'), _('Allow the selection of an outgoing IPv4 gateway with NAT')); + let sgwnat = s.taboption('smartgw', form.Flag, 'SmartGatewayAllowNAT', _('Allow gateways with NAT'), _('Allow the selection of an outgoing IPv4 gateway with NAT')); sgwnat.depends('SmartGateway', 'yes'); sgwnat.default = 'yes'; sgwnat.enabled = 'yes'; @@ -72,7 +72,7 @@ return view.extend({ sgwnat.optional = true; sgwnat.rmempty = true; - var sgwuplink = s.taboption( + let sgwuplink = s.taboption( 'smartgw', form.ListValue, 'SmartGatewayUplink', @@ -88,7 +88,7 @@ return view.extend({ sgwuplink.optional = true; sgwuplink.rmempty = true; - var sgwulnat = s.taboption('smartgw', form.Flag, 'SmartGatewayUplinkNAT', _('Uplink uses NAT'), _('If this Node uses NAT for connections to the internet. ' + 'Default is "yes".')); + let sgwulnat = s.taboption('smartgw', form.Flag, 'SmartGatewayUplinkNAT', _('Uplink uses NAT'), _('If this Node uses NAT for connections to the internet. ' + 'Default is "yes".')); sgwulnat.depends('SmartGatewayUplink', 'ipv4'); sgwulnat.depends('SmartGatewayUplink', 'both'); sgwulnat.default = 'yes'; @@ -97,14 +97,14 @@ return view.extend({ sgwnat.optional = true; sgwnat.rmempty = true; - var sgwspeed = s.taboption('smartgw', form.Value, 'SmartGatewaySpeed', _('Speed of the uplink'), _('Specifies the speed of ' + 'the uplink in kilobits/s. First parameter is upstream, second parameter is downstream. Default is "128 1024".')); + let sgwspeed = s.taboption('smartgw', form.Value, 'SmartGatewaySpeed', _('Speed of the uplink'), _('Specifies the speed of ' + 'the uplink in kilobits/s. First parameter is upstream, second parameter is downstream. Default is "128 1024".')); sgwspeed.depends('SmartGatewayUplink', 'ipv4'); sgwspeed.depends('SmartGatewayUplink', 'ipv6'); sgwspeed.depends('SmartGatewayUplink', 'both'); sgwspeed.optional = true; sgwspeed.rmempty = true; - var sgwprefix = s.taboption( + let sgwprefix = s.taboption( 'smartgw', form.Value, 'SmartGatewayPrefix', @@ -125,26 +125,26 @@ return view.extend({ s.tab('advanced', _('Advanced Settings')); - var ipv = s.taboption('general', form.ListValue, 'IpVersion', _('Internet protocol'), _('IP-version to use. If 6and4 is selected then one olsrd instance is started for each protocol.')); + let ipv = s.taboption('general', form.ListValue, 'IpVersion', _('Internet protocol'), _('IP-version to use. If 6and4 is selected then one olsrd instance is started for each protocol.')); ipv.value('4', 'IPv4'); ipv.value('6and4', '6and4'); - var poll = s.taboption('advanced', form.Value, 'Pollrate', _('Pollrate'), _('Polling rate for OLSR sockets in seconds. Default is 0.05.')); + let poll = s.taboption('advanced', form.Value, 'Pollrate', _('Pollrate'), _('Polling rate for OLSR sockets in seconds. Default is 0.05.')); poll.optional = true; poll.datatype = 'ufloat'; poll.placeholder = '0.05'; - var nicc = s.taboption('advanced', form.Value, 'NicChgsPollInt', _('Nic changes poll interval'), _('Interval to poll network interfaces for configuration changes (in seconds). Default is "2.5".')); + let nicc = s.taboption('advanced', form.Value, 'NicChgsPollInt', _('Nic changes poll interval'), _('Interval to poll network interfaces for configuration changes (in seconds). Default is "2.5".')); nicc.optional = true; nicc.datatype = 'ufloat'; nicc.placeholder = '2.5'; - var tos = s.taboption('advanced', form.Value, 'TosValue', _('TOS value'), _('Type of service value for the IP header of control traffic. Default is "16".')); + let tos = s.taboption('advanced', form.Value, 'TosValue', _('TOS value'), _('Type of service value for the IP header of control traffic. Default is "16".')); tos.optional = true; tos.datatype = 'uinteger'; tos.placeholder = '16'; - var fib = s.taboption( + let fib = s.taboption( 'general', form.ListValue, 'FIBMetric', @@ -162,7 +162,7 @@ return view.extend({ fib.value('correct'); fib.value('approx'); - var lql = s.taboption( + let lql = s.taboption( 'lquality', form.ListValue, 'LinkQualityLevel', @@ -172,7 +172,7 @@ return view.extend({ lql.value('2'); lql.value('0'); - var lqage = s.taboption( + let lqage = s.taboption( 'lquality', form.Value, 'LinkQualityAging', @@ -182,7 +182,7 @@ return view.extend({ lqage.optional = true; lqage.depends('LinkQualityLevel', '2'); - var lqa = s.taboption( + let lqa = s.taboption( 'lquality', form.ListValue, 'LinkQualityAlgorithm', @@ -204,11 +204,11 @@ return view.extend({ lqa.depends('LinkQualityLevel', '2'); lqa.optional = true; - var lqfish = s.taboption('lquality', form.Flag, 'LinkQualityFishEye', _('LQ fisheye'), _('Fisheye mechanism for TCs (checked means on). Default is "on"')); + let lqfish = s.taboption('lquality', form.Flag, 'LinkQualityFishEye', _('LQ fisheye'), _('Fisheye mechanism for TCs (checked means on). Default is "on"')); lqfish.default = '1'; lqfish.optional = true; - var hyst = s.taboption( + let hyst = s.taboption( 'lquality', form.Flag, 'UseHysteresis', @@ -222,12 +222,12 @@ return view.extend({ hyst.optional = true; hyst.rmempty = true; - var port = s.taboption('general', form.Value, 'OlsrPort', _('Port'), _('The port OLSR uses. This should usually stay at the IANA assigned port 698. It can have a value between 1 and 65535.')); + let port = s.taboption('general', form.Value, 'OlsrPort', _('Port'), _('The port OLSR uses. This should usually stay at the IANA assigned port 698. It can have a value between 1 and 65535.')); port.optional = true; port.default = '698'; port.rmempty = true; - var mainip = s.taboption( + let mainip = s.taboption( 'general', form.Value, 'MainIp', @@ -239,14 +239,14 @@ return view.extend({ mainip.datatype = 'ipaddr'; mainip.placeholder = '0.0.0.0'; - var willingness = s.taboption('advanced', form.ListValue, 'Willingness', _('Willingness'), _('The fixed willingness to use. If not set willingness will be calculated dynamically based on battery/power status. Default is "3".')); + let willingness = s.taboption('advanced', form.ListValue, 'Willingness', _('Willingness'), _('The fixed willingness to use. If not set willingness will be calculated dynamically based on battery/power status. Default is "3".')); for (let i = 0; i < 8; i++) { willingness.value(i); } willingness.optional = true; willingness.default = '3'; - var natthr = s.taboption( + let natthr = s.taboption( 'advanced', form.Value, 'NatThreshold', @@ -275,7 +275,7 @@ return view.extend({ } }; - var i = m.section(form.TypedSection, 'InterfaceDefaults', _('Interfaces Defaults')); + let i = m.section(form.TypedSection, 'InterfaceDefaults', _('Interfaces Defaults')); i.anonymous = true; i.addremove = false; @@ -283,13 +283,13 @@ return view.extend({ i.tab('addrs', _('IP Addresses')); i.tab('timing', _('Timing and Validity')); - var mode = i.taboption('general', form.ListValue, 'Mode', _('Mode'), _('Interface mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ' + 'Valid modes are "mesh" and "ether". Default is "mesh".')); - mode.value('mesh'); - mode.value('ether'); - mode.optional = true; - mode.rmempty = true; + let ifmode = i.taboption('general', form.ListValue, 'Mode', _('Mode'), _('Interface mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ' + 'Valid modes are "mesh" and "ether". Default is "mesh".')); + ifmode.value('mesh'); + ifmode.value('ether'); + ifmode.optional = true; + ifmode.rmempty = true; - var weight = i.taboption( + let weight = i.taboption( 'general', form.Value, 'Weight', @@ -306,7 +306,7 @@ return view.extend({ weight.datatype = 'uinteger'; weight.placeholder = '0'; - var lqmult = i.taboption( + let lqmult = i.taboption( 'general', form.DynamicList, 'LinkQualityMult', @@ -324,12 +324,12 @@ return view.extend({ lqmult.placeholder = 'default 1.0'; lqmult.validate = function (section_id) { - for (var i = 0; i < lqmult.formvalue(section_id).length; i++) { - var v = lqmult.formvalue(section_id)[i]; + for (let i = 0; i < lqmult.formvalue(section_id).length; i++) { + const v = lqmult.formvalue(section_id)[i]; if (v !== '') { - var val = v.split(' '); - var host = val[0]; - var mult = val[1]; + const val = v.split(' '); + const host = val[0]; + const mult = val[1]; if (!host || !mult) { return [null, "LQMult requires two values (IP address or 'default' and multiplicator) separated by space."]; } @@ -346,7 +346,7 @@ return view.extend({ } return true; }; - var ip4b = i.taboption( + let ip4b = i.taboption( 'addrs', form.Value, 'Ip4Broadcast', @@ -357,17 +357,17 @@ return view.extend({ ip4b.datatype = 'ip4addr'; ip4b.placeholder = '0.0.0.0'; - var ip6m = i.taboption('addrs', form.Value, 'IPv6Multicast', _('IPv6 multicast'), _('IPv6 multicast address. Default is "FF02::6D", the manet-router linklocal multicast.')); + let ip6m = i.taboption('addrs', form.Value, 'IPv6Multicast', _('IPv6 multicast'), _('IPv6 multicast address. Default is "FF02::6D", the manet-router linklocal multicast.')); ip6m.optional = true; ip6m.datatype = 'ip6addr'; ip6m.placeholder = 'FF02::6D'; - var ip4s = i.taboption('addrs', form.Value, 'IPv4Src', _('IPv4 source'), _('IPv4 src address for outgoing OLSR packages. Default is "0.0.0.0", which triggers usage of the interface IP.')); + let ip4s = i.taboption('addrs', form.Value, 'IPv4Src', _('IPv4 source'), _('IPv4 src address for outgoing OLSR packages. Default is "0.0.0.0", which triggers usage of the interface IP.')); ip4s.optional = true; ip4s.datatype = 'ip4addr'; ip4s.placeholder = '0.0.0.0'; - var ip6s = i.taboption( + let ip6s = i.taboption( 'addrs', form.Value, 'IPv6Src', @@ -378,7 +378,7 @@ return view.extend({ ip6s.datatype = 'ip6addr'; ip6s.placeholder = '0::/0'; - var hi = i.taboption('timing', form.Value, 'HelloInterval', _('Hello interval')); + let hi = i.taboption('timing', form.Value, 'HelloInterval', _('Hello interval')); hi.optional = true; hi.datatype = 'ufloat'; hi.placeholder = '5.0'; @@ -389,7 +389,7 @@ return view.extend({ } }; - var hv = i.taboption('timing', form.Value, 'HelloValidityTime', _('Hello validity time')); + let hv = i.taboption('timing', form.Value, 'HelloValidityTime', _('Hello validity time')); hv.optional = true; hv.datatype = 'ufloat'; hv.placeholder = '40.0'; @@ -400,7 +400,7 @@ return view.extend({ } }; - var ti = i.taboption('timing', form.Value, 'TcInterval', _('TC interval')); + let ti = i.taboption('timing', form.Value, 'TcInterval', _('TC interval')); ti.optional = true; ti.datatype = 'ufloat'; ti.placeholder = '2.0'; @@ -411,7 +411,7 @@ return view.extend({ } }; - var tv = i.taboption('timing', form.Value, 'TcValidityTime', _('TC validity time')); + let tv = i.taboption('timing', form.Value, 'TcValidityTime', _('TC validity time')); tv.optional = true; tv.datatype = 'ufloat'; tv.placeholder = '256.0'; @@ -422,7 +422,7 @@ return view.extend({ } }; - var mi = i.taboption('timing', form.Value, 'MidInterval', _('MID interval')); + let mi = i.taboption('timing', form.Value, 'MidInterval', _('MID interval')); mi.optional = true; mi.datatype = 'ufloat'; mi.placeholder = '18.0'; @@ -433,7 +433,7 @@ return view.extend({ } }; - var mv = i.taboption('timing', form.Value, 'MidValidityTime', _('MID validity time')); + let mv = i.taboption('timing', form.Value, 'MidValidityTime', _('MID validity time')); mv.optional = true; mv.datatype = 'ufloat'; mv.placeholder = '324.0'; @@ -444,7 +444,7 @@ return view.extend({ } }; - var ai = i.taboption('timing', form.Value, 'HnaInterval', _('HNA interval')); + let ai = i.taboption('timing', form.Value, 'HnaInterval', _('HNA interval')); ai.optional = true; ai.datatype = 'ufloat'; ai.placeholder = '18.0'; @@ -455,7 +455,7 @@ return view.extend({ } }; - var av = i.taboption('timing', form.Value, 'HnaValidityTime', _('HNA validity time')); + let av = i.taboption('timing', form.Value, 'HnaValidityTime', _('HNA validity time')); av.optional = true; av.datatype = 'ufloat'; av.placeholder = '108.0'; @@ -466,14 +466,14 @@ return view.extend({ } }; - var ifs = m.section(form.TableSection, 'Interface', _('Interfaces')); + let ifs = m.section(form.TableSection, 'Interface', _('Interfaces')); ifs.addremove = true; ifs.anonymous = true; ifs.extedit = function (eve) { - var editButton = eve.target; - var sid; - var row = editButton.closest('.cbi-section-table-row'); + const editButton = eve.target; + let sid; + const row = editButton.closest('.cbi-section-table-row'); if (row) { sid = row.getAttribute('data-sid'); @@ -482,18 +482,14 @@ return view.extend({ window.location.href = `olsrd/iface/${sid}`; }; - ifs.template = 'cbi/tblsection'; - ifs.handleAdd = function (ev) { - var sid = uci.add('olsrd', 'Interface'); uci .save() .then(function () { return uci.changes(); }) .then(function (res) { - console.log(res); - var sid = null; + let sid = null; if (res.olsrd && Array.isArray(res.olsrd)) { res.olsrd.forEach(function (item) { if (item.length >= 3 && item[0] === 'add' && item[2] === 'Interface') { @@ -501,14 +497,11 @@ return view.extend({ } }); } - if (sid) { - console.log(sid); - } window.location.href = `olsrd/iface/${sid}`; }); }; - var ign = ifs.option(form.Flag, 'ignore', _('Enable')); + let ign = ifs.option(form.Flag, 'ignore', _('Enable')); ign.enabled = '0'; ign.disabled = '1'; ign.rmempty = false; @@ -516,39 +509,38 @@ return view.extend({ return uci.get('olsrd', section_id, 'ignore') || '0'; }; - var network = ifs.option(form.DummyValue, 'interface', _('Network')); - network.template = 'cbi/network_netinfo'; + ifs.option(form.DummyValue, 'interface', _('Network')); - var mode = ifs.option(form.DummyValue, 'Mode', _('Mode')); + let mode = ifs.option(form.DummyValue, 'Mode', _('Mode')); mode.cfgvalue = function (section_id) { return uci.get('olsrd', section_id, 'Mode') || uci.get_first('olsrd', 'InterfaceDefaults', 'Mode'); }; - var hello = ifs.option(form.DummyValue, '_hello', _('Hello')); + let hello = ifs.option(form.DummyValue, '_hello', _('Hello')); hello.cfgvalue = function (section_id) { - var i = uci.get('olsrd', section_id, 'HelloInterval') || uci.get_first('olsrd', 'InterfaceDefaults', 'HelloInterval'); - var v = uci.get('olsrd', section_id, 'HelloValidityTime') || uci.get_first('olsrd', 'InterfaceDefaults', 'HelloValidityTime'); + const i = uci.get('olsrd', section_id, 'HelloInterval') || uci.get_first('olsrd', 'InterfaceDefaults', 'HelloInterval'); + const v = uci.get('olsrd', section_id, 'HelloValidityTime') || uci.get_first('olsrd', 'InterfaceDefaults', 'HelloValidityTime'); return `${i}s / ${v}s`; }; - var tc = ifs.option(form.DummyValue, '_tc', _('TC')); + let tc = ifs.option(form.DummyValue, '_tc', _('TC')); tc.cfgvalue = function (section_id) { - var i = uci.get('olsrd', section_id, 'TcInterval') || uci.get_first('olsrd', 'InterfaceDefaults', 'TcInterval'); - var v = uci.get('olsrd', section_id, 'TcValidityTime') || uci.get_first('olsrd', 'InterfaceDefaults', 'TcValidityTime'); + const i = uci.get('olsrd', section_id, 'TcInterval') || uci.get_first('olsrd', 'InterfaceDefaults', 'TcInterval'); + const v = uci.get('olsrd', section_id, 'TcValidityTime') || uci.get_first('olsrd', 'InterfaceDefaults', 'TcValidityTime'); return `${i}s / ${v}s`; }; - var mid = ifs.option(form.DummyValue, '_mid', _('MID')); + let mid = ifs.option(form.DummyValue, '_mid', _('MID')); mid.cfgvalue = function (section_id) { - var i = uci.get('olsrd', section_id, 'MidInterval') || uci.get_first('olsrd', 'InterfaceDefaults', 'MidInterval'); - var v = uci.get('olsrd', section_id, 'MidValidityTime') || uci.get_first('olsrd', 'InterfaceDefaults', 'MidValidityTime'); + const i = uci.get('olsrd', section_id, 'MidInterval') || uci.get_first('olsrd', 'InterfaceDefaults', 'MidInterval'); + const v = uci.get('olsrd', section_id, 'MidValidityTime') || uci.get_first('olsrd', 'InterfaceDefaults', 'MidValidityTime'); return `${i}s / ${v}s`; }; - var hna = ifs.option(form.DummyValue, '_hna', _('HNA')); + let hna = ifs.option(form.DummyValue, '_hna', _('HNA')); hna.cfgvalue = function (section_id) { - var i = uci.get('olsrd', section_id, 'HnaInterval') || uci.get_first('olsrd', 'InterfaceDefaults', 'HnaInterval'); - var v = uci.get('olsrd', section_id, 'HnaValidityTime') || uci.get_first('olsrd', 'InterfaceDefaults', 'HnaValidityTime'); + const i = uci.get('olsrd', section_id, 'HnaInterval') || uci.get_first('olsrd', 'InterfaceDefaults', 'HnaInterval'); + const v = uci.get('olsrd', section_id, 'HnaValidityTime') || uci.get_first('olsrd', 'InterfaceDefaults', 'HnaValidityTime'); return `${i}s / ${v}s`; }; diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrd6.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrd6.js index 4c673320ce..164183de49 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrd6.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrd6.js @@ -11,11 +11,11 @@ return view.extend({ object: 'olsrinfo', method: 'hasipip', }), - load: function () { + load() { return Promise.all([uci.load('olsrd6').then(() => { - var hasDefaults = false; + let hasDefaults = false; - uci.sections('olsrd6', 'InterfaceDefaults', function (s) { + uci.sections('olsrd6', 'InterfaceDefaults', () => { hasDefaults = true; return false; }); @@ -25,10 +25,10 @@ return view.extend({ } })]); }, - render: function () { - let m, s, o; + render() { + let m, s; - var has_ipip; + let has_ipip; m = new form.Map( 'olsrd6', @@ -47,7 +47,7 @@ return view.extend({ s.tab('lquality', _('Link Quality Settings')); this.callHasIpIp() .then(function (res) { - var output = res.result; + const output = res.result; has_ipip = output.trim().length > 0; }) .catch(function (err) { @@ -55,7 +55,7 @@ return view.extend({ }) .finally(function () { s.tab('smartgw', _('SmartGW'), !has_ipip && _('Warning: kmod-ipip is not installed. Without kmod-ipip SmartGateway will not work, please install it.')); - var sgw = s.taboption('smartgw', form.Flag, 'SmartGateway', _('Enable'), _('Enable SmartGateway. If it is disabled, then ' + 'all other SmartGateway parameters are ignored. Default is "no".')); + let sgw = s.taboption('smartgw', form.Flag, 'SmartGateway', _('Enable'), _('Enable SmartGateway. If it is disabled, then ' + 'all other SmartGateway parameters are ignored. Default is "no".')); sgw.default = 'no'; sgw.enabled = 'yes'; sgw.disabled = 'no'; @@ -64,7 +64,7 @@ return view.extend({ return uci.get('olsrd6', section_id, 'SmartGateway') || 'no'; }; - var sgwnat = s.taboption('smartgw', form.Flag, 'SmartGatewayAllowNAT', _('Allow gateways with NAT'), _('Allow the selection of an outgoing IPv4 gateway with NAT')); + let sgwnat = s.taboption('smartgw', form.Flag, 'SmartGatewayAllowNAT', _('Allow gateways with NAT'), _('Allow the selection of an outgoing IPv4 gateway with NAT')); sgwnat.depends('SmartGateway', 'yes'); sgwnat.default = 'yes'; sgwnat.enabled = 'yes'; @@ -72,7 +72,7 @@ return view.extend({ sgwnat.optional = true; sgwnat.rmempty = true; - var sgwuplink = s.taboption( + let sgwuplink = s.taboption( 'smartgw', form.ListValue, 'SmartGatewayUplink', @@ -88,7 +88,7 @@ return view.extend({ sgwuplink.optional = true; sgwuplink.rmempty = true; - var sgwulnat = s.taboption('smartgw', form.Flag, 'SmartGatewayUplinkNAT', _('Uplink uses NAT'), _('If this Node uses NAT for connections to the internet. ' + 'Default is "yes".')); + let sgwulnat = s.taboption('smartgw', form.Flag, 'SmartGatewayUplinkNAT', _('Uplink uses NAT'), _('If this Node uses NAT for connections to the internet. ' + 'Default is "yes".')); sgwulnat.depends('SmartGatewayUplink', 'ipv4'); sgwulnat.depends('SmartGatewayUplink', 'both'); sgwulnat.default = 'yes'; @@ -97,14 +97,14 @@ return view.extend({ sgwnat.optional = true; sgwnat.rmempty = true; - var sgwspeed = s.taboption('smartgw', form.Value, 'SmartGatewaySpeed', _('Speed of the uplink'), _('Specifies the speed of ' + 'the uplink in kilobits/s. First parameter is upstream, second parameter is downstream. Default is "128 1024".')); + let sgwspeed = s.taboption('smartgw', form.Value, 'SmartGatewaySpeed', _('Speed of the uplink'), _('Specifies the speed of ' + 'the uplink in kilobits/s. First parameter is upstream, second parameter is downstream. Default is "128 1024".')); sgwspeed.depends('SmartGatewayUplink', 'ipv4'); sgwspeed.depends('SmartGatewayUplink', 'ipv6'); sgwspeed.depends('SmartGatewayUplink', 'both'); sgwspeed.optional = true; sgwspeed.rmempty = true; - var sgwprefix = s.taboption( + let sgwprefix = s.taboption( 'smartgw', form.Value, 'SmartGatewayPrefix', @@ -123,22 +123,22 @@ return view.extend({ }); s.tab('advanced', _('Advanced Settings')); - var poll = s.taboption('advanced', form.Value, 'Pollrate', _('Pollrate'), _('Polling rate for OLSR sockets in seconds. Default is 0.05.')); + let poll = s.taboption('advanced', form.Value, 'Pollrate', _('Pollrate'), _('Polling rate for OLSR sockets in seconds. Default is 0.05.')); poll.optional = true; poll.datatype = 'ufloat'; poll.placeholder = '0.05'; - var nicc = s.taboption('advanced', form.Value, 'NicChgsPollInt', _('Nic changes poll interval'), _('Interval to poll network interfaces for configuration changes (in seconds). Default is "2.5".')); + let nicc = s.taboption('advanced', form.Value, 'NicChgsPollInt', _('Nic changes poll interval'), _('Interval to poll network interfaces for configuration changes (in seconds). Default is "2.5".')); nicc.optional = true; nicc.datatype = 'ufloat'; nicc.placeholder = '2.5'; - var tos = s.taboption('advanced', form.Value, 'TosValue', _('TOS value'), _('Type of service value for the IP header of control traffic. Default is "16".')); + let tos = s.taboption('advanced', form.Value, 'TosValue', _('TOS value'), _('Type of service value for the IP header of control traffic. Default is "16".')); tos.optional = true; tos.datatype = 'uinteger'; tos.placeholder = '16'; - var fib = s.taboption( + let fib = s.taboption( 'general', form.ListValue, 'FIBMetric', @@ -156,7 +156,7 @@ return view.extend({ fib.value('correct'); fib.value('approx'); - var lql = s.taboption( + let lql = s.taboption( 'lquality', form.ListValue, 'LinkQualityLevel', @@ -166,7 +166,7 @@ return view.extend({ lql.value('2'); lql.value('0'); - var lqage = s.taboption( + let lqage = s.taboption( 'lquality', form.Value, 'LinkQualityAging', @@ -176,7 +176,7 @@ return view.extend({ lqage.optional = true; lqage.depends('LinkQualityLevel', '2'); - var lqa = s.taboption( + let lqa = s.taboption( 'lquality', form.ListValue, 'LinkQualityAlgorithm', @@ -198,11 +198,11 @@ return view.extend({ lqa.depends('LinkQualityLevel', '2'); lqa.optional = true; - var lqfish = s.taboption('lquality', form.Flag, 'LinkQualityFishEye', _('LQ fisheye'), _('Fisheye mechanism for TCs (checked means on). Default is "on"')); + let lqfish = s.taboption('lquality', form.Flag, 'LinkQualityFishEye', _('LQ fisheye'), _('Fisheye mechanism for TCs (checked means on). Default is "on"')); lqfish.default = '1'; lqfish.optional = true; - var hyst = s.taboption( + let hyst = s.taboption( 'lquality', form.Flag, 'UseHysteresis', @@ -216,12 +216,12 @@ return view.extend({ hyst.optional = true; hyst.rmempty = true; - var port = s.taboption('general', form.Value, 'OlsrPort', _('Port'), _('The port OLSR uses. This should usually stay at the IANA assigned port 698. It can have a value between 1 and 65535.')); + let port = s.taboption('general', form.Value, 'OlsrPort', _('Port'), _('The port OLSR uses. This should usually stay at the IANA assigned port 698. It can have a value between 1 and 65535.')); port.optional = true; port.default = '698'; port.rmempty = true; - var mainip = s.taboption( + let mainip = s.taboption( 'general', form.Value, 'MainIp', @@ -233,14 +233,14 @@ return view.extend({ mainip.datatype = 'ipaddr'; mainip.placeholder = '::'; - var willingness = s.taboption('advanced', form.ListValue, 'Willingness', _('Willingness'), _('The fixed willingness to use. If not set willingness will be calculated dynamically based on battery/power status. Default is "3".')); + let willingness = s.taboption('advanced', form.ListValue, 'Willingness', _('Willingness'), _('The fixed willingness to use. If not set willingness will be calculated dynamically based on battery/power status. Default is "3".')); for (let i = 0; i < 8; i++) { willingness.value(i); } willingness.optional = true; willingness.default = '3'; - var natthr = s.taboption( + let natthr = s.taboption( 'advanced', form.Value, 'NatThreshold', @@ -269,7 +269,7 @@ return view.extend({ } }; - var i = m.section(form.TypedSection, 'InterfaceDefaults', _('Interfaces Defaults')); + let i = m.section(form.TypedSection, 'InterfaceDefaults', _('Interfaces Defaults')); i.anonymous = true; i.addremove = false; @@ -277,13 +277,13 @@ return view.extend({ i.tab('addrs', _('IP Addresses')); i.tab('timing', _('Timing and Validity')); - var mode = i.taboption('general', form.ListValue, 'Mode', _('Mode'), _('Interface mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ' + 'Valid modes are "mesh" and "ether". Default is "mesh".')); - mode.value('mesh'); - mode.value('ether'); - mode.optional = true; - mode.rmempty = true; + let ifmode = i.taboption('general', form.ListValue, 'Mode', _('Mode'), _('Interface mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ' + 'Valid modes are "mesh" and "ether". Default is "mesh".')); + ifmode.value('mesh'); + ifmode.value('ether'); + ifmode.optional = true; + ifmode.rmempty = true; - var weight = i.taboption( + let weight = i.taboption( 'general', form.Value, 'Weight', @@ -300,7 +300,7 @@ return view.extend({ weight.datatype = 'uinteger'; weight.placeholder = '0'; - var lqmult = i.taboption( + let lqmult = i.taboption( 'general', form.DynamicList, 'LinkQualityMult', @@ -318,12 +318,12 @@ return view.extend({ lqmult.placeholder = 'default 1.0'; lqmult.validate = function (section_id) { - for (var i = 0; i < lqmult.formvalue(section_id).length; i++) { - var v = lqmult.formvalue(section_id)[i]; + for (let i = 0; i < lqmult.formvalue(section_id).length; i++) { + const v = lqmult.formvalue(section_id)[i]; if (v !== '') { - var val = v.split(' '); - var host = val[0]; - var mult = val[1]; + const val = v.split(' '); + const host = val[0]; + const mult = val[1]; if (!host || !mult) { return [null, "LQMult requires two values (IP address or 'default' and multiplicator) separated by space."]; } @@ -341,12 +341,12 @@ return view.extend({ return true; }; - var ip6m = i.taboption('addrs', form.Value, 'IPv6Multicast', _('IPv6 multicast'), _('IPv6 multicast address. Default is "FF02::6D", the manet-router linklocal multicast.')); + let ip6m = i.taboption('addrs', form.Value, 'IPv6Multicast', _('IPv6 multicast'), _('IPv6 multicast address. Default is "FF02::6D", the manet-router linklocal multicast.')); ip6m.optional = true; ip6m.datatype = 'ip6addr'; ip6m.placeholder = 'FF02::6D'; - var ip6s = i.taboption( + let ip6s = i.taboption( 'addrs', form.Value, 'IPv6Src', @@ -357,7 +357,7 @@ return view.extend({ ip6s.datatype = 'ip6addr'; ip6s.placeholder = '0::/0'; - var hi = i.taboption('timing', form.Value, 'HelloInterval', _('Hello interval')); + let hi = i.taboption('timing', form.Value, 'HelloInterval', _('Hello interval')); hi.optional = true; hi.datatype = 'ufloat'; hi.placeholder = '5.0'; @@ -368,7 +368,7 @@ return view.extend({ } }; - var hv = i.taboption('timing', form.Value, 'HelloValidityTime', _('Hello validity time')); + let hv = i.taboption('timing', form.Value, 'HelloValidityTime', _('Hello validity time')); hv.optional = true; hv.datatype = 'ufloat'; hv.placeholder = '40.0'; @@ -379,7 +379,7 @@ return view.extend({ } }; - var ti = i.taboption('timing', form.Value, 'TcInterval', _('TC interval')); + let ti = i.taboption('timing', form.Value, 'TcInterval', _('TC interval')); ti.optional = true; ti.datatype = 'ufloat'; ti.placeholder = '2.0'; @@ -390,7 +390,7 @@ return view.extend({ } }; - var tv = i.taboption('timing', form.Value, 'TcValidityTime', _('TC validity time')); + let tv = i.taboption('timing', form.Value, 'TcValidityTime', _('TC validity time')); tv.optional = true; tv.datatype = 'ufloat'; tv.placeholder = '256.0'; @@ -401,7 +401,7 @@ return view.extend({ } }; - var mi = i.taboption('timing', form.Value, 'MidInterval', _('MID interval')); + let mi = i.taboption('timing', form.Value, 'MidInterval', _('MID interval')); mi.optional = true; mi.datatype = 'ufloat'; mi.placeholder = '18.0'; @@ -412,7 +412,7 @@ return view.extend({ } }; - var mv = i.taboption('timing', form.Value, 'MidValidityTime', _('MID validity time')); + let mv = i.taboption('timing', form.Value, 'MidValidityTime', _('MID validity time')); mv.optional = true; mv.datatype = 'ufloat'; mv.placeholder = '324.0'; @@ -423,7 +423,7 @@ return view.extend({ } }; - var ai = i.taboption('timing', form.Value, 'HnaInterval', _('HNA interval')); + let ai = i.taboption('timing', form.Value, 'HnaInterval', _('HNA interval')); ai.optional = true; ai.datatype = 'ufloat'; ai.placeholder = '18.0'; @@ -434,7 +434,7 @@ return view.extend({ } }; - var av = i.taboption('timing', form.Value, 'HnaValidityTime', _('HNA validity time')); + let av = i.taboption('timing', form.Value, 'HnaValidityTime', _('HNA validity time')); av.optional = true; av.datatype = 'ufloat'; av.placeholder = '108.0'; @@ -445,13 +445,13 @@ return view.extend({ } }; - var ifs = m.section(form.TableSection, 'Interface', _('Interfaces')); + let ifs = m.section(form.TableSection, 'Interface', _('Interfaces')); ifs.addremove = true; ifs.anonymous = true; ifs.extedit = function (eve) { - var editButton = eve.target; - var sid; - var row = editButton.closest('.cbi-section-table-row'); + const editButton = eve.target; + let sid; + const row = editButton.closest('.cbi-section-table-row'); if (row) { sid = row.getAttribute('data-sid'); @@ -462,7 +462,6 @@ return view.extend({ ifs.template = 'cbi/tblsection'; ifs.handleAdd = function (ev) { - var sid = uci.add('olsrd6', 'Interface'); uci .save() .then(function () { @@ -470,7 +469,7 @@ return view.extend({ }) .then(function (res) { console.log(res); - var sid = null; + let sid = null; if (res.olsrd6 && Array.isArray(res.olsrd6)) { res.olsrd6.forEach(function (item) { if (item.length >= 3 && item[0] === 'add' && item[2] === 'Interface') { @@ -484,7 +483,7 @@ return view.extend({ window.location.href = `olsrd6/iface/${sid}`; }); }; - var ign = ifs.option(form.Flag, 'ignore', _('Enable')); + let ign = ifs.option(form.Flag, 'ignore', _('Enable')); ign.enabled = '0'; ign.disabled = '1'; ign.rmempty = false; @@ -492,39 +491,39 @@ return view.extend({ return uci.get('olsrd6', section_id, 'ignore') || '0'; }; - var network = ifs.option(form.DummyValue, 'interface', _('Network')); + let network = ifs.option(form.DummyValue, 'interface', _('Network')); network.template = 'cbi/network_netinfo'; - var mode = ifs.option(form.DummyValue, 'Mode', _('Mode')); + let mode = ifs.option(form.DummyValue, 'Mode', _('Mode')); mode.cfgvalue = function (section_id) { return uci.get('olsrd6', section_id, 'Mode') || uci.get_first('olsrd6', 'InterfaceDefaults', 'Mode'); }; - var hello = ifs.option(form.DummyValue, '_hello', _('Hello')); + let hello = ifs.option(form.DummyValue, '_hello', _('Hello')); hello.cfgvalue = function (section_id) { - var i = uci.get('olsrd6', section_id, 'HelloInterval') || uci.get_first('olsrd6', 'InterfaceDefaults', 'HelloInterval'); - var v = uci.get('olsrd6', section_id, 'HelloValidityTime') || uci.get_first('olsrd6', 'InterfaceDefaults', 'HelloValidityTime'); + const i = uci.get('olsrd6', section_id, 'HelloInterval') || uci.get_first('olsrd6', 'InterfaceDefaults', 'HelloInterval'); + const v = uci.get('olsrd6', section_id, 'HelloValidityTime') || uci.get_first('olsrd6', 'InterfaceDefaults', 'HelloValidityTime'); return `${i}s / ${v}s`; }; - var tc = ifs.option(form.DummyValue, '_tc', _('TC')); + let tc = ifs.option(form.DummyValue, '_tc', _('TC')); tc.cfgvalue = function (section_id) { - var i = uci.get('olsrd6', section_id, 'TcInterval') || uci.get_first('olsrd6', 'InterfaceDefaults', 'TcInterval'); - var v = uci.get('olsrd6', section_id, 'TcValidityTime') || uci.get_first('olsrd6', 'InterfaceDefaults', 'TcValidityTime'); + const i = uci.get('olsrd6', section_id, 'TcInterval') || uci.get_first('olsrd6', 'InterfaceDefaults', 'TcInterval'); + const v = uci.get('olsrd6', section_id, 'TcValidityTime') || uci.get_first('olsrd6', 'InterfaceDefaults', 'TcValidityTime'); return `${i}s / ${v}s`; }; - var mid = ifs.option(form.DummyValue, '_mid', _('MID')); + let mid = ifs.option(form.DummyValue, '_mid', _('MID')); mid.cfgvalue = function (section_id) { - var i = uci.get('olsrd6', section_id, 'MidInterval') || uci.get_first('olsrd6', 'InterfaceDefaults', 'MidInterval'); - var v = uci.get('olsrd6', section_id, 'MidValidityTime') || uci.get_first('olsrd6', 'InterfaceDefaults', 'MidValidityTime'); + const i = uci.get('olsrd6', section_id, 'MidInterval') || uci.get_first('olsrd6', 'InterfaceDefaults', 'MidInterval'); + const v = uci.get('olsrd6', section_id, 'MidValidityTime') || uci.get_first('olsrd6', 'InterfaceDefaults', 'MidValidityTime'); return `${i}s / ${v}s`; }; - var hna = ifs.option(form.DummyValue, '_hna', _('HNA')); + let hna = ifs.option(form.DummyValue, '_hna', _('HNA')); hna.cfgvalue = function (section_id) { - var i = uci.get('olsrd6', section_id, 'HnaInterval') || uci.get_first('olsrd6', 'InterfaceDefaults', 'HnaInterval'); - var v = uci.get('olsrd6', section_id, 'HnaValidityTime') || uci.get_first('olsrd6', 'InterfaceDefaults', 'HnaValidityTime'); + const i = uci.get('olsrd6', section_id, 'HnaInterval') || uci.get_first('olsrd6', 'InterfaceDefaults', 'HnaInterval'); + const v = uci.get('olsrd6', section_id, 'HnaValidityTime') || uci.get_first('olsrd6', 'InterfaceDefaults', 'HnaValidityTime'); return `${i}s / ${v}s`; }; diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrddisplay.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrddisplay.js index 5caa7f5933..19d1122260 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrddisplay.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrddisplay.js @@ -5,18 +5,18 @@ 'require uci'; return view.extend({ - load: function () { + load() { return Promise.all([uci.load('luci_olsr')]); }, - render: function () { - let m, s, o; + render() { + let m, s; m = new form.Map('luci_olsr', _('OLSR - Display Options')); s = m.section(form.TypedSection, 'olsr'); s.anonymous = true; - var res = s.option( + let res = s.option( form.Flag, 'resolve', _('Resolve'), diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdhna.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdhna.js index ff66afa1e8..d0f1f613bc 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdhna.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdhna.js @@ -5,41 +5,41 @@ 'require ui'; return view.extend({ - load: function () { + load() { return Promise.all([uci.load('olsrd')]); }, - render: function () { - var ipv = uci.get_first('olsrd', 'olsrd', 'IpVersion') || '4'; + render() { + let ipv = uci.get_first('olsrd', 'olsrd', 'IpVersion') || '4'; - var mh = new form.Map('olsrd', _('OLSR - HNA-Announcements'), _('Hosts in an OLSR routed network can announce connectivity ' + 'to external networks using HNA messages.')); + let mh = new form.Map('olsrd', _('OLSR - HNA-Announcements'), _('Hosts in an OLSR routed network can announce connectivity ' + 'to external networks using HNA messages.')); if (ipv === '6and4' || ipv === '4') { - var hna4 = mh.section(form.TypedSection, 'Hna4', _('Hna4'), _('Both values must use the dotted decimal notation.')); + let hna4 = mh.section(form.TypedSection, 'Hna4', _('Hna4'), _('Both values must use the dotted decimal notation.')); hna4.addremove = true; hna4.anonymous = true; hna4.template = 'cbi/tblsection'; - var net4 = hna4.option(form.Value, 'netaddr', _('Network address')); + let net4 = hna4.option(form.Value, 'netaddr', _('Network address')); net4.datatype = 'ip4addr'; net4.placeholder = '10.11.12.13'; net4.default = '10.11.12.13'; - var msk4 = hna4.option(form.Value, 'netmask', _('Netmask')); + let msk4 = hna4.option(form.Value, 'netmask', _('Netmask')); msk4.datatype = 'ip4addr'; msk4.placeholder = '255.255.255.255'; msk4.default = '255.255.255.255'; } if (ipv === '6and4' || ipv === '6') { - var hna6 = mh.section(form.TypedSection, 'Hna6', _('Hna6'), _('IPv6 network must be given in full notation, ' + 'prefix must be in CIDR notation.')); + let hna6 = mh.section(form.TypedSection, 'Hna6', _('Hna6'), _('IPv6 network must be given in full notation, ' + 'prefix must be in CIDR notation.')); hna6.addremove = true; hna6.anonymous = true; hna6.template = 'cbi/tblsection'; - var net6 = hna6.option(form.Value, 'netaddr', _('Network address')); + let net6 = hna6.option(form.Value, 'netaddr', _('Network address')); net6.datatype = 'ip6addr'; net6.placeholder = 'fec0:2200:106:0:0:0:0:0'; net6.default = 'fec0:2200:106:0:0:0:0:0'; - var msk6 = hna6.option(form.Value, 'prefix', _('Prefix')); + let msk6 = hna6.option(form.Value, 'prefix', _('Prefix')); msk6.datatype = 'range(0,128)'; msk6.placeholder = '128'; msk6.default = '128'; diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdhna6.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdhna6.js index 207469e5fa..e57f7b336a 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdhna6.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdhna6.js @@ -5,22 +5,22 @@ 'require ui'; return view.extend({ - load: function () { + load() { return Promise.all([uci.load('olsrd6')]); }, - render: function () { - var mh = new form.Map('olsrd6', _('OLSR - HNA6-Announcements'), _('Hosts in an OLSR routed network can announce connectivity ' + 'to external networks using HNA6 messages.')); + render() { + let mh = new form.Map('olsrd6', _('OLSR - HNA6-Announcements'), _('Hosts in an OLSR routed network can announce connectivity ' + 'to external networks using HNA6 messages.')); - var hna6 = mh.section(form.TypedSection, 'Hna6', _('Hna6'), _('IPv6 network must be given in full notation, ' + 'prefix must be in CIDR notation.')); + let hna6 = mh.section(form.TypedSection, 'Hna6', _('Hna6'), _('IPv6 network must be given in full notation, ' + 'prefix must be in CIDR notation.')); hna6.addremove = true; hna6.anonymous = true; hna6.template = 'cbi/tblsection'; - var net6 = hna6.option(form.Value, 'netaddr', _('Network address')); + let net6 = hna6.option(form.Value, 'netaddr', _('Network address')); net6.datatype = 'ip6addr'; net6.placeholder = 'fec0:2200:106:0:0:0:0:0'; net6.default = 'fec0:2200:106:0:0:0:0:0'; - var msk6 = hna6.option(form.Value, 'prefix', _('Prefix')); + let msk6 = hna6.option(form.Value, 'prefix', _('Prefix')); msk6.datatype = 'range(0,128)'; msk6.placeholder = '128'; msk6.default = '128'; diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdiface.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdiface.js index ee0c483906..3258703f58 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdiface.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdiface.js @@ -6,12 +6,12 @@ 'require tools.widgets as widgets'; return view.extend({ - load: function () { + load() { return Promise.all([uci.load('olsrd')]); }, - render: function () { + render() { - var m = new form.Map( + let m = new form.Map( 'olsrd', _('OLSR Daemon - Interface'), _('The OLSR daemon is an implementation of the Optimized Link State Routing protocol. ' + @@ -20,15 +20,15 @@ return view.extend({ 'Visit %s for help and documentation.'.format('<a href="http://www.olsr.org">olsrd.org</a>')) ); - var pathname = window.location.pathname; - var segments = pathname.split('/'); - var sidIndex = segments.lastIndexOf('iface') + 1; - var sid = null; + const pathname = window.location.pathname; + const segments = pathname.split('/'); + const sidIndex = segments.lastIndexOf('iface') + 1; + let sid = null; if (sidIndex !== -1 && sidIndex < segments.length) { sid = segments[sidIndex]; } - var i = m.section(form.NamedSection, sid, 'Interface', _('Interface')); + let i = m.section(form.NamedSection, sid, 'Interface', _('Interface')); i.anonymous = true; i.addremove = false; @@ -36,7 +36,7 @@ return view.extend({ i.tab('addrs', _('IP Addresses')); i.tab('timing', _('Timing and Validity')); - var ign = i.taboption('general', form.Flag, 'ignore', _('Enable'), _('Enable this interface.')); + let ign = i.taboption('general', form.Flag, 'ignore', _('Enable'), _('Enable this interface.')); ign.enabled = '0'; ign.disabled = '1'; ign.rmempty = false; @@ -45,16 +45,16 @@ return view.extend({ return uci.get('olsrd', section_id, 'ignore') || '0'; }; - var network = i.taboption('general', widgets.NetworkSelect, 'interface', _('Network'), _('The interface OLSRd should serve.')); - network.optional = false; + let network = i.taboption('general', widgets.NetworkSelect, 'interface', _('Network'), _('The interface OLSRd should serve.')); + network.optional = false; - var mode = i.taboption('general', form.ListValue, 'Mode', _('Mode'), _('Interface mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ' + 'Valid modes are "mesh" and "ether". Default is "mesh".')); + let mode = i.taboption('general', form.ListValue, 'Mode', _('Mode'), _('Interface mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ' + 'Valid modes are "mesh" and "ether". Default is "mesh".')); mode.value('mesh'); mode.value('ether'); mode.optional = true; mode.rmempty = true; - var weight = i.taboption( + let weight = i.taboption( 'general', form.Value, 'Weight', @@ -71,7 +71,7 @@ return view.extend({ weight.datatype = 'uinteger'; weight.placeholder = '0'; - var lqmult = i.taboption( + let lqmult = i.taboption( 'general', form.DynamicList, 'LinkQualityMult', @@ -89,12 +89,12 @@ return view.extend({ lqmult.placeholder = 'default 1.0'; lqmult.validate = function (section_id) { - for (var i = 0; i < lqmult.formvalue(section_id).length; i++) { - var v = lqmult.formvalue(section_id)[i]; + for (let i = 0; i < lqmult.formvalue(section_id).length; i++) { + const v = lqmult.formvalue(section_id)[i]; if (v !== '') { - var val = v.split(' '); - var host = val[0]; - var mult = val[1]; + const val = v.split(' '); + const host = val[0]; + const mult = val[1]; if (!host || !mult) { return [null, "LQMult requires two values (IP address or 'default' and multiplicator) separated by space."]; } @@ -112,7 +112,7 @@ return view.extend({ return true; }; - var ip4b = i.taboption( + const ip4b = i.taboption( 'addrs', form.Value, 'Ip4Broadcast', @@ -123,17 +123,17 @@ return view.extend({ ip4b.datatype = 'ip4addr'; ip4b.placeholder = '0.0.0.0'; - var ip6m = i.taboption('addrs', form.Value, 'IPv6Multicast', _('IPv6 multicast'), _('IPv6 multicast address. Default is "FF02::6D", the manet-router linklocal multicast.')); + const ip6m = i.taboption('addrs', form.Value, 'IPv6Multicast', _('IPv6 multicast'), _('IPv6 multicast address. Default is "FF02::6D", the manet-router linklocal multicast.')); ip6m.optional = true; ip6m.datatype = 'ip6addr'; ip6m.placeholder = 'FF02::6D'; - var ip4s = i.taboption('addrs', form.Value, 'IPv4Src', _('IPv4 source'), _('IPv4 src address for outgoing OLSR packages. Default is "0.0.0.0", which triggers usage of the interface IP.')); + const ip4s = i.taboption('addrs', form.Value, 'IPv4Src', _('IPv4 source'), _('IPv4 src address for outgoing OLSR packages. Default is "0.0.0.0", which triggers usage of the interface IP.')); ip4s.optional = true; ip4s.datatype = 'ip4addr'; ip4s.placeholder = '0.0.0.0'; - var ip6s = i.taboption( + const ip6s = i.taboption( 'addrs', form.Value, 'IPv6Src', @@ -144,7 +144,7 @@ return view.extend({ ip6s.datatype = 'ip6addr'; ip6s.placeholder = '0::/0'; - var hi = i.taboption('timing', form.Value, 'HelloInterval', _('Hello interval')); + const hi = i.taboption('timing', form.Value, 'HelloInterval', _('Hello interval')); hi.optional = true; hi.datatype = 'ufloat'; hi.placeholder = '5.0'; @@ -155,7 +155,7 @@ return view.extend({ } }; - var hv = i.taboption('timing', form.Value, 'HelloValidityTime', _('Hello validity time')); + const hv = i.taboption('timing', form.Value, 'HelloValidityTime', _('Hello validity time')); hv.optional = true; hv.datatype = 'ufloat'; hv.placeholder = '40.0'; @@ -166,7 +166,7 @@ return view.extend({ } }; - var ti = i.taboption('timing', form.Value, 'TcInterval', _('TC interval')); + let ti = i.taboption('timing', form.Value, 'TcInterval', _('TC interval')); ti.optional = true; ti.datatype = 'ufloat'; ti.placeholder = '2.0'; @@ -177,7 +177,7 @@ return view.extend({ } }; - var tv = i.taboption('timing', form.Value, 'TcValidityTime', _('TC validity time')); + let tv = i.taboption('timing', form.Value, 'TcValidityTime', _('TC validity time')); tv.optional = true; tv.datatype = 'ufloat'; tv.placeholder = '256.0'; @@ -188,7 +188,7 @@ return view.extend({ } }; - var mi = i.taboption('timing', form.Value, 'MidInterval', _('MID interval')); + let mi = i.taboption('timing', form.Value, 'MidInterval', _('MID interval')); mi.optional = true; mi.datatype = 'ufloat'; mi.placeholder = '18.0'; @@ -199,7 +199,7 @@ return view.extend({ } }; - var mv = i.taboption('timing', form.Value, 'MidValidityTime', _('MID validity time')); + let mv = i.taboption('timing', form.Value, 'MidValidityTime', _('MID validity time')); mv.optional = true; mv.datatype = 'ufloat'; mv.placeholder = '324.0'; @@ -210,7 +210,7 @@ return view.extend({ } }; - var ai = i.taboption('timing', form.Value, 'HnaInterval', _('HNA interval')); + let ai = i.taboption('timing', form.Value, 'HnaInterval', _('HNA interval')); ai.optional = true; ai.datatype = 'ufloat'; ai.placeholder = '18.0'; @@ -221,7 +221,7 @@ return view.extend({ } }; - var av = i.taboption('timing', form.Value, 'HnaValidityTime', _('HNA validity time')); + let av = i.taboption('timing', form.Value, 'HnaValidityTime', _('HNA validity time')); av.optional = true; av.datatype = 'ufloat'; av.placeholder = '108.0'; diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdiface6.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdiface6.js index 344ca504e9..f970068ba6 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdiface6.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdiface6.js @@ -6,12 +6,12 @@ 'require tools.widgets as widgets'; return view.extend({ - load: function () { + load() { return Promise.all([uci.load('olsrd6')]); }, - render: function () { + render() { - var m = new form.Map( + let m = new form.Map( 'olsrd6', _('OLSR Daemon - Interface'), _('The OLSR daemon is an implementation of the Optimized Link State Routing protocol. ' + @@ -20,15 +20,15 @@ return view.extend({ 'Visit %s for help and documentation.'.format('<a href="http://www.olsr.org">olsrd.org</a>')) ); - var pathname = window.location.pathname; - var segments = pathname.split('/'); - var sidIndex = segments.lastIndexOf('iface') + 1; - var sid = null; + const pathname = window.location.pathname; + const segments = pathname.split('/'); + const sidIndex = segments.lastIndexOf('iface') + 1; + let sid = null; if (sidIndex !== -1 && sidIndex < segments.length) { sid = segments[sidIndex]; } - var i = m.section(form.NamedSection, sid, 'Interface', _('Interface')); + let i = m.section(form.NamedSection, sid, 'Interface', _('Interface')); i.anonymous = true; i.addremove = false; @@ -36,7 +36,7 @@ return view.extend({ i.tab('addrs', _('IP Addresses')); i.tab('timing', _('Timing and Validity')); - var ign = i.taboption('general', form.Flag, 'ignore', _('Enable'), _('Enable this interface.')); + let ign = i.taboption('general', form.Flag, 'ignore', _('Enable'), _('Enable this interface.')); ign.enabled = '0'; ign.disabled = '1'; ign.rmempty = false; @@ -45,16 +45,16 @@ return view.extend({ return uci.get('olsrd', section_id, 'ignore') || '0'; }; - var network = i.taboption('general', widgets.NetworkSelect, 'interface', _('Network'), _('The interface OLSRd should serve.')); + let network = i.taboption('general', widgets.NetworkSelect, 'interface', _('Network'), _('The interface OLSRd should serve.')); network.optional = false; - var mode = i.taboption('general', form.ListValue, 'Mode', _('Mode'), _('Interface mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ' + 'Valid modes are "mesh" and "ether". Default is "mesh".')); + let mode = i.taboption('general', form.ListValue, 'Mode', _('Mode'), _('Interface mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ' + 'Valid modes are "mesh" and "ether". Default is "mesh".')); mode.value('mesh'); mode.value('ether'); mode.optional = true; mode.rmempty = true; - var weight = i.taboption( + let weight = i.taboption( 'general', form.Value, 'Weight', @@ -71,7 +71,7 @@ return view.extend({ weight.datatype = 'uinteger'; weight.placeholder = '0'; - var lqmult = i.taboption( + let lqmult = i.taboption( 'general', form.DynamicList, 'LinkQualityMult', @@ -89,12 +89,12 @@ return view.extend({ lqmult.placeholder = 'default 1.0'; lqmult.validate = function (section_id) { - for (var i = 0; i < lqmult.formvalue(section_id).length; i++) { - var v = lqmult.formvalue(section_id)[i]; + for (let i = 0; i < lqmult.formvalue(section_id).length; i++) { + const v = lqmult.formvalue(section_id)[i]; if (v !== '') { - var val = v.split(' '); - var host = val[0]; - var mult = val[1]; + const val = v.split(' '); + const host = val[0]; + const mult = val[1]; if (!host || !mult) { return [null, "LQMult requires two values (IP address or 'default' and multiplicator) separated by space."]; } @@ -112,12 +112,12 @@ return view.extend({ return true; }; - var ip6m = i.taboption('addrs', form.Value, 'IPv6Multicast', _('IPv6 multicast'), _('IPv6 multicast address. Default is "FF02::6D", the manet-router linklocal multicast.')); + let ip6m = i.taboption('addrs', form.Value, 'IPv6Multicast', _('IPv6 multicast'), _('IPv6 multicast address. Default is "FF02::6D", the manet-router linklocal multicast.')); ip6m.optional = true; ip6m.datatype = 'ip6addr'; ip6m.placeholder = 'FF02::6D'; - var ip6s = i.taboption( + let ip6s = i.taboption( 'addrs', form.Value, 'IPv6Src', @@ -128,7 +128,7 @@ return view.extend({ ip6s.datatype = 'ip6addr'; ip6s.placeholder = '0::/0'; - var hi = i.taboption('timing', form.Value, 'HelloInterval', _('Hello interval')); + let hi = i.taboption('timing', form.Value, 'HelloInterval', _('Hello interval')); hi.optional = true; hi.datatype = 'ufloat'; hi.placeholder = '5.0'; @@ -139,7 +139,7 @@ return view.extend({ } }; - var hv = i.taboption('timing', form.Value, 'HelloValidityTime', _('Hello validity time')); + let hv = i.taboption('timing', form.Value, 'HelloValidityTime', _('Hello validity time')); hv.optional = true; hv.datatype = 'ufloat'; hv.placeholder = '40.0'; @@ -150,7 +150,7 @@ return view.extend({ } }; - var ti = i.taboption('timing', form.Value, 'TcInterval', _('TC interval')); + let ti = i.taboption('timing', form.Value, 'TcInterval', _('TC interval')); ti.optional = true; ti.datatype = 'ufloat'; ti.placeholder = '2.0'; @@ -161,7 +161,7 @@ return view.extend({ } }; - var tv = i.taboption('timing', form.Value, 'TcValidityTime', _('TC validity time')); + let tv = i.taboption('timing', form.Value, 'TcValidityTime', _('TC validity time')); tv.optional = true; tv.datatype = 'ufloat'; tv.placeholder = '256.0'; @@ -172,7 +172,7 @@ return view.extend({ } }; - var mi = i.taboption('timing', form.Value, 'MidInterval', _('MID interval')); + let mi = i.taboption('timing', form.Value, 'MidInterval', _('MID interval')); mi.optional = true; mi.datatype = 'ufloat'; mi.placeholder = '18.0'; @@ -183,7 +183,7 @@ return view.extend({ } }; - var mv = i.taboption('timing', form.Value, 'MidValidityTime', _('MID validity time')); + let mv = i.taboption('timing', form.Value, 'MidValidityTime', _('MID validity time')); mv.optional = true; mv.datatype = 'ufloat'; mv.placeholder = '324.0'; @@ -194,7 +194,7 @@ return view.extend({ } }; - var ai = i.taboption('timing', form.Value, 'HnaInterval', _('HNA interval')); + let ai = i.taboption('timing', form.Value, 'HnaInterval', _('HNA interval')); ai.optional = true; ai.datatype = 'ufloat'; ai.placeholder = '18.0'; @@ -205,7 +205,7 @@ return view.extend({ } }; - var av = i.taboption('timing', form.Value, 'HnaValidityTime', _('HNA validity time')); + let av = i.taboption('timing', form.Value, 'HnaValidityTime', _('HNA validity time')); av.optional = true; av.datatype = 'ufloat'; av.placeholder = '108.0'; diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdplugins.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdplugins.js index 7e3287f964..3f22e19deb 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdplugins.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdplugins.js @@ -8,7 +8,7 @@ 'require validation'; return view.extend({ - load: function () { + load() { return Promise.all([ uci.load('olsrd').then(() => { return fs.list('/usr/lib').then((files) => { @@ -21,10 +21,10 @@ return view.extend({ files.forEach((v) => { if (v.name.substr(0, 6) === 'olsrd_') { - var pluginname = v.name.match(/^(olsrd.*)\.so\..*/)[1]; + const pluginname = v.name.match(/^(olsrd.*)\.so\..*/)[1]; if (!libsArr.includes(pluginname)) { - var sid = uci.add('olsrd', 'LoadPlugin'); + const sid = uci.add('olsrd', 'LoadPlugin'); uci.set('olsrd', sid, 'ignore', '1'); uci.set('olsrd', sid, 'library', pluginname); } @@ -34,20 +34,20 @@ return view.extend({ }), ]); }, - render: function () { - var pathname = window.location.pathname; - var segments = pathname.split('/'); - var sidIndex = segments.lastIndexOf('plugins') + 1; - var sid = null; + render() { + const pathname = window.location.pathname; + const segments = pathname.split('/'); + const sidIndex = segments.lastIndexOf('plugins') + 1; + let sid = null; if (sidIndex !== -1 && sidIndex < segments.length) { sid = segments[sidIndex]; } if (sid) { - var mp = new form.Map('olsrd', _('OLSR - Plugins')); - var p = mp.section(form.NamedSection, sid, 'LoadPlugin', _('Plugin configuration')); + let mp = new form.Map('olsrd', _('OLSR - Plugins')); + let p = mp.section(form.NamedSection, sid, 'LoadPlugin', _('Plugin configuration')); p.anonymous = true; - var plname = uci.get('olsrd', sid, 'library'); - var ign = p.option(form.Flag, 'ignore', _('Enable')); + let plname = uci.get('olsrd', sid, 'library'); + let ign = p.option(form.Flag, 'ignore', _('Enable')); ign.enabled = '0'; ign.disabled = '1'; ign.rmempty = false; @@ -55,12 +55,12 @@ return view.extend({ return uci.get('olsrd', section_id, 'ignore') || '0'; }; - var lib = p.option(form.DummyValue, 'library', _('Library')); + let lib = p.option(form.DummyValue, 'library', _('Library')); lib.default = plname; function Range(x, y) { - var t = []; - for (var i = x; i <= y; i++) { + const t = []; + for (let i = x; i <= y; i++) { t.push(i); } return t; @@ -71,10 +71,11 @@ return view.extend({ return isIPv6 ? network.prefixToMask(prefix, true) : network.prefixToMask(prefix, false); } + let newVal; if (val) { - var newVal = val.map(cidr => { - var [ip, prefix] = cidr.split('/'); - var networkip, mask; + newVal = val.map(cidr => { + const [ip, prefix] = cidr.split('/'); + let networkip, mask; if (validation.parseIPv6(ip)) { networkip = ip; @@ -94,25 +95,25 @@ return view.extend({ function IpMask2Cidr(val) { if (val) { for (let i = 0; i < val.length; i++) { - var [ip, mask] = val[i].match(/([^ ]+)%s+([^ ]+)/) || []; - var cidr; + const [ip, mask] = val[i].match(/([^ ]+)%s+([^ ]+)/) || []; + let cidr; if (ip && mask) { if (validation.parseIPv6(ip)) { cidr = ip + '/' + mask; } else if (validation.parseIPv4(ip)) { - var ipParts = ip.split('.'); - var maskParts = mask.split('.'); - var cidrParts = []; + const ipParts = ip.split('.'); + const maskParts = mask.split('.'); + const cidrParts = []; for (let j = 0; j < 4; j++) { - var ipPart = parseInt(ipParts[j]); - var maskPart = parseInt(maskParts[j]); - var cidrPart = ipPart & maskPart; + const ipPart = parseInt(ipParts[j]); + const maskPart = parseInt(maskParts[j]); + const cidrPart = ipPart & maskPart; cidrParts.push(cidrPart); } - var cidrPrefix = network.maskToPrefix(maskParts.join('.')); + const cidrPrefix = network.maskToPrefix(maskParts.join('.')); cidr = cidrParts.join('.') + '/' + cidrPrefix; } } @@ -259,15 +260,15 @@ return view.extend({ return mp.render(); } else { - var mpi = new form.Map('olsrd', _('OLSR - Plugins')); + const mpi = new form.Map('olsrd', _('OLSR - Plugins')); - var t = mpi.section(form.TableSection, 'LoadPlugin', _('Plugins')); + const t = mpi.section(form.TableSection, 'LoadPlugin', _('Plugins')); t.anonymous = true; t.extedit = function (eve) { - var editButton = eve.target; - var sid; - var row = editButton.closest('.cbi-section-table-row'); + const editButton = eve.target; + let sid; + const row = editButton.closest('.cbi-section-table-row'); if (row) { sid = row.getAttribute('data-sid'); @@ -276,12 +277,11 @@ return view.extend({ window.location.href = `plugins/${sid}`; }; - var ign = t.option(form.Flag, 'ignore', _('Enabled')); + let ign = t.option(form.Flag, 'ignore', _('Enabled')); ign.enabled = '0'; ign.disabled = '1'; ign.rmempty = false; - - function ign_cfgvalue(section_id) { + ign.cfgvalue = function (section_id) { return uci.get(section_id, 'ignore') || '0'; } diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdplugins6.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdplugins6.js index 2fd665c5d9..7ed71af6f7 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdplugins6.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/frontend/olsrdplugins6.js @@ -19,10 +19,10 @@ return view.extend({ files.forEach((v) => { if (v.name.substr(0, 6) === 'olsrd_') { - var pluginname = v.name.match(/^(olsrd_.*)\.so\..*/)[1]; + const pluginname = v.name.match(/^(olsrd_.*)\.so\..*/)[1]; if (!libsArr.includes(pluginname)) { - var sid = uci.add('olsrd6', 'LoadPlugin'); + const sid = uci.add('olsrd6', 'LoadPlugin'); uci.set('olsrd6', sid, 'ignore', '1'); uci.set('olsrd6', sid, 'library', pluginname); } @@ -33,19 +33,19 @@ return view.extend({ ]); }, render: function () { - var pathname = window.location.pathname; - var segments = pathname.split('/'); - var sidIndex = segments.lastIndexOf('plugins') + 1; - var sid = null; + const pathname = window.location.pathname; + const segments = pathname.split('/'); + const sidIndex = segments.lastIndexOf('plugins') + 1; + let sid = null; if (sidIndex !== -1 && sidIndex < segments.length) { sid = segments[sidIndex]; } if (sid) { - var mp = new form.Map('olsrd6', _('OLSR - Plugins')); - var p = mp.section(form.NamedSection, sid, 'LoadPlugin', _('Plugin configuration')); + let mp = new form.Map('olsrd6', _('OLSR - Plugins')); + let p = mp.section(form.NamedSection, sid, 'LoadPlugin', _('Plugin configuration')); p.anonymous = true; - var plname = uci.get('olsrd6', sid, 'library'); - var ign = p.option(form.Flag, 'ignore', _('Enable')); + let plname = uci.get('olsrd6', sid, 'library'); + let ign = p.option(form.Flag, 'ignore', _('Enable')); ign.enabled = '0'; ign.disabled = '1'; ign.rmempty = false; @@ -53,12 +53,12 @@ return view.extend({ return uci.get('olsrd6', section_id, 'ignore') || '0'; }; - var lib = p.option(form.DummyValue, 'library', _('Library')); + let lib = p.option(form.DummyValue, 'library', _('Library')); lib.default = plname; function Range(x, y) { - var t = []; - for (var i = x; i <= y; i++) { + const t = []; + for (let i = x; i <= y; i++) { t.push(i); } return t; @@ -69,10 +69,11 @@ return view.extend({ return isIPv6 ? network.prefixToMask(prefix, true) : network.prefixToMask(prefix, false); } + let newVal if (val) { - var newVal = val.map(cidr => { - var [ip, prefix] = cidr.split('/'); - var networkip, mask; + newVal = val.map(cidr => { + const [ip, prefix] = cidr.split('/'); + let networkip, mask; if (validation.parseIPv6(ip)) { networkip = ip; @@ -92,25 +93,25 @@ return view.extend({ function IpMask2Cidr(val) { if (val) { for (let i = 0; i < val.length; i++) { - var [ip, mask] = val[i].match(/([^ ]+)%s+([^ ]+)/) || []; - var cidr; + const [ip, mask] = val[i].match(/([^ ]+)%s+([^ ]+)/) || []; + let cidr; if (ip && mask) { if (validation.parseIPv6(ip)) { cidr = ip + '/' + mask; } else if (validation.parseIPv4(ip)) { - var ipParts = ip.split('.'); - var maskParts = mask.split('.'); - var cidrParts = []; + const ipParts = ip.split('.'); + const maskParts = mask.split('.'); + const cidrParts = []; for (let j = 0; j < 4; j++) { - var ipPart = parseInt(ipParts[j]); - var maskPart = parseInt(maskParts[j]); - var cidrPart = ipPart & maskPart; + const ipPart = parseInt(ipParts[j]); + const maskPart = parseInt(maskParts[j]); + const cidrPart = ipPart & maskPart; cidrParts.push(cidrPart); } - var cidrPrefix = network.maskToPrefix(maskParts.join('.')); + const cidrPrefix = network.maskToPrefix(maskParts.join('.')); cidr = cidrParts.join('.') + '/' + cidrPrefix; } } @@ -245,7 +246,7 @@ return view.extend({ } if (typeof cbi2uci === 'function') { field.write = function (section_id, formvalue) { - var saveval=cbi2uci(formvalue); + const saveval=cbi2uci(formvalue); uci.set('olsrd6', section_id, name, saveval); }; } @@ -257,15 +258,15 @@ return view.extend({ return mp.render(); } else { - var mpi = new form.Map('olsrd6', _('OLSR - Plugins')); + let mpi = new form.Map('olsrd6', _('OLSR - Plugins')); - var t = mpi.section(form.TableSection, 'LoadPlugin', _('Plugins')); + let t = mpi.section(form.TableSection, 'LoadPlugin', _('Plugins')); t.anonymous = true; t.extedit = function (eve) { - var editButton = eve.target; - var sid; - var row = editButton.closest('.cbi-section-table-row'); + const editButton = eve.target; + let sid; + const row = editButton.closest('.cbi-section-table-row'); if (row) { sid = row.getAttribute('data-sid'); @@ -274,12 +275,11 @@ return view.extend({ window.location.href = `plugins/${sid}`; }; - var ign = t.option(form.Flag, 'ignore', _('Enabled')); + let ign = t.option(form.Flag, 'ignore', _('Enabled')); ign.enabled = '0'; ign.disabled = '1'; ign.rmempty = false; - - function ign_cfgvalue(section_id) { + ign.cfgvalue = function(section_id) { return uci.get(section_id, 'ignore') || '0'; } diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/error_olsr.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/error_olsr.js index 2db2270781..7b80c849c9 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/error_olsr.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/error_olsr.js @@ -3,7 +3,7 @@ 'require rpc'; 'require ui'; return view.extend({ - render: function () { + render() { return E('div', {}, [ E('h2', { 'name': 'content' }, _('OLSR Daemon')), E('p', { 'class': 'error' }, _('Unable to connect to the OLSR daemon!')), diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/hna.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/hna.js index 8b84e7a4a4..db7e1a85d9 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/hna.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/hna.js @@ -5,89 +5,12 @@ 'require network'; 'require rpc'; 'require ui'; +'require olsr.common_js as olsr'; -return view.extend({ - callGetJsonStatus: rpc.declare({ - object: 'olsrinfo', - method: 'getjsondata', - params: ['otable', 'v4_port', 'v6_port'], - }), +return olsr.olsrview.extend({ - callGetHosts: rpc.declare({ - object: 'olsrinfo', - method: 'hosts', - }), - - fetch_jsoninfo: function (otable) { - var jsonreq4 = ''; - var jsonreq6 = ''; - var v4_port = parseInt(uci.get('olsrd', 'olsrd_jsoninfo', 'port') || '') || 9090; - var v6_port = parseInt(uci.get('olsrd6', 'olsrd_jsoninfo', 'port') || '') || 9090; - var json; - var self = this; - return new Promise(function (resolve, reject) { - L.resolveDefault(self.callGetJsonStatus(otable, v4_port, v6_port), {}) - .then(function (res) { - json = res; - - jsonreq4 = JSON.parse(json.jsonreq4); - jsonreq6 = json.jsonreq6 !== '' ? JSON.parse(json.jsonreq6) : []; - - var jsondata4 = {}; - var jsondata6 = {}; - var data4 = []; - var data6 = []; - var has_v4 = false; - var has_v6 = false; - - if (jsonreq4 === '' && jsonreq6 === '') { - window.location.href = 'error_olsr'; - reject([null, 0, 0, true]); - return; - } - - if (jsonreq4 !== '') { - has_v4 = true; - jsondata4 = jsonreq4 || {}; - if (otable === 'status') { - data4 = jsondata4; - } else { - data4 = jsondata4[otable] || []; - } - - for (var i = 0; i < data4.length; i++) { - data4[i]['proto'] = '4'; - } - } - - if (jsonreq6 !== '') { - has_v6 = true; - jsondata6 = jsonreq6 || {}; - if (otable === 'status') { - data6 = jsondata6; - } else { - data6 = jsondata6[otable] || []; - } - - for (var j = 0; j < data6.length; j++) { - data6[j]['proto'] = '6'; - } - } - - for (var k = 0; k < data6.length; k++) { - data4.push(data6[k]); - } - - resolve([data4, has_v4, has_v6, false]); - }) - .catch(function (err) { - console.error(err); - reject([null, 0, 0, true]); - }); - }); - }, - action_hna: function () { - var self = this; + action_hna() { + let self = this; return new Promise(function (resolve, reject) { self .fetch_jsoninfo('hna') @@ -96,7 +19,7 @@ return view.extend({ reject(error); } - var resolveVal = uci.get('luci_olsr', 'general', 'resolve'); + const resolveVal = uci.get('luci_olsr', 'general', 'resolve'); function compare(a, b) { if (a.proto === b.proto) { @@ -105,14 +28,14 @@ return view.extend({ return a.proto < b.proto; } } - var modifiedData; + let modifiedData; self .callGetHosts() .then(function (res) { function matchHostnames(ip) { - var lines = res.hosts.split('\n'); - for (var i = 0; i < lines.length; i++) { - var ipandhostname = lines[i].trim().split(/\s+/); + const lines = res.hosts.split('\n'); + for (let line of lines) { + const ipandhostname = line.trim().split(/\s+/); if (ipandhostname[0] === ip) { return ipandhostname[1]; } @@ -121,7 +44,7 @@ return view.extend({ } modifiedData = data.map(function (v) { if (resolveVal === '1') { - var hostname = matchHostnames(v.gateway); + const hostname = matchHostnames(v.gateway); if (hostname) { v.hostname = hostname; } @@ -134,7 +57,7 @@ return view.extend({ modifiedData.sort(compare); - var result = { hna: modifiedData, has_v4: has_v4, has_v6: has_v6 }; + const result = { hna: modifiedData, has_v4: has_v4, has_v6: has_v6 }; resolve(result); }) .catch(function (err) { @@ -148,24 +71,23 @@ return view.extend({ }); }, - load: function () { - var self = this; + load() { + let self = this; poll.add(function () { self.render(); }, 5); return Promise.all([uci.load('olsrd'), uci.load('luci_olsr')]); }, - render: function () { - var hna_res; - var has_v4; - var has_v6; - var self = this; + render() { + let hna_res; + let has_v4; + let has_v6; return this.action_hna() .then(function (result) { hna_res = result.hna; has_v4 = result.has_v4; has_v6 = result.has_v6; - var table = E('div', { 'class': 'table cbi-section-table', 'id': 'olsrd_hna' }, [ + const table = E('div', { 'class': 'table cbi-section-table', 'id': 'olsrd_hna' }, [ E('div', { 'class': 'tr cbi-section-table-titles' }, [ E('div', { 'class': 'th cbi-section-table-cell' }, _('Announced network')), E('div', { 'class': 'th cbi-section-table-cell' }, _('OLSR gateway')), @@ -173,11 +95,10 @@ return view.extend({ ]), ]); - var i = 1; + let i = 1; - var rv = []; - for (var k = 0; k < hna_res.length; k++) { - var entry = hna_res[k]; + const rv = []; + for (let entry of hna_res) { rv.push({ proto: entry.proto, destination: entry.destination, @@ -188,20 +109,20 @@ return view.extend({ }); } - var info = rv; + const info = rv; - var hnadiv = document.getElementById('olsrd_hna'); + const hnadiv = document.getElementById('olsrd_hna'); if (hnadiv) { - var s = + let s = '<div class="tr cbi-section-table-titles">' + '<div class="th cbi-section-table-cell">Announced network</div>' + '<div class="th cbi-section-table-cell">OLSR gateway</div>' + '<div class="th cbi-section-table-cell">Validity Time</div>' + '</div>'; - for (var idx = 0; idx < info.length; idx++) { - var hna = info[idx]; - var linkgw = ''; + for (let idx = 0; idx < info.length; idx++) { + const hna = info[idx]; + let linkgw = ''; s += '<div class="tr cbi-section-table-row cbi-rowstyle-' + (1 + (idx % 2)) + ' proto-' + hna.proto + '">'; if (hna.proto === '6') { @@ -210,8 +131,8 @@ return view.extend({ linkgw = '<a href="http://' + hna.gateway + '/cgi-bin-status.html">' + hna.gateway + '</a>'; } - var validity = hna.validityTime !== undefined ? hna.validityTime + 's' : '-'; - var hostname = hna.hostname !== null ? ' / <a href="http://%q/cgi-bin-status.html">%h</a>'.format(hna.hostname, hna.hostname) : ''; + const validity = hna.validityTime !== undefined ? hna.validityTime + 's' : '-'; + const hostname = hna.hostname !== null ? ' / <a href="http://%q/cgi-bin-status.html">%h</a>'.format(hna.hostname, hna.hostname) : ''; s += '<div class="td cbi-section-table-cell left">' + @@ -229,12 +150,10 @@ return view.extend({ hnadiv.innerHTML = s; } - var i = 1; - - for (var k = 0; k < hna_res.length; k++) { - var route = hna_res[k]; + i = 1; - var tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + route.proto }, [ + for (let route of hna_res) { + const tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + route.proto }, [ E('div', { 'class': 'td cbi-section-table-cell left' }, route.destination + '/' + route.genmask), E('div', { 'class': 'td cbi-section-table-cell left' }, [ route.proto === '6' ? E('a', { 'href': 'http://[' + route.gateway + ']/cgi-bin-status.html' }, route.gateway) : E('a', { 'href': 'http://' + route.gateway + '/cgi-bin-status.html' }, route.gateway), @@ -247,19 +166,19 @@ return view.extend({ i = (i % 2) + 1; } - var fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of currently active OLSR host net announcements')), table]); + const fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of currently active OLSR host net announcements')), table]); - var h2 = E('h2', { 'name': 'content' }, _('Active host net announcements')); - var divToggleButtons = E('div', { 'id': 'togglebuttons' }); - var statusOlsrCommonJs = null; + const h2 = E('h2', { 'name': 'content' }, _('Active host net announcements')); + const divToggleButtons = E('div', { 'id': 'togglebuttons' }); + let statusOlsrCommonJs = null; if (has_v4 && has_v6) { statusOlsrCommonJs = E('script', { 'type': 'text/javascript', 'src': L.resource('common/common_js.js') }); } - var result = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrCommonJs]); + const fresult = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrCommonJs]); - return result; + return fresult; }) .catch(function (error) { console.error(error); diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/interfaces.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/interfaces.js index fe0ac6a238..69a0ef311b 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/interfaces.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/interfaces.js @@ -1,136 +1,59 @@ 'use strict'; -'require uci'; -'require view'; +'require network'; 'require rpc'; +'require uci'; 'require ui'; -'require network'; +'require view'; +'require olsr.common_js as olsr'; -return view.extend({ - callGetJsonStatus: rpc.declare({ - object: 'olsrinfo', - method: 'getjsondata', - params: ['otable', 'v4_port', 'v6_port'], - }), - - fetch_jsoninfo: function (otable) { - var jsonreq4 = ''; - var jsonreq6 = ''; - var v4_port = parseInt(uci.get('olsrd', 'olsrd_jsoninfo', 'port') || '') || 9090; - var v6_port = parseInt(uci.get('olsrd6', 'olsrd_jsoninfo', 'port') || '') || 9090; - var json; - var self = this; - return new Promise(function (resolve, reject) { - L.resolveDefault(self.callGetJsonStatus(otable, v4_port, v6_port), {}) - .then(function (res) { - json = res; - - jsonreq4 = JSON.parse(json.jsonreq4); - jsonreq6 = json.jsonreq6 !== '' ? JSON.parse(json.jsonreq6) : []; - - var jsondata4 = {}; - var jsondata6 = {}; - var data4 = []; - var data6 = []; - var has_v4 = false; - var has_v6 = false; - - if (jsonreq4 === '' && jsonreq6 === '') { - window.location.href = 'error_olsr'; - reject([null, 0, 0, true]); - return; - } - - if (jsonreq4 !== '') { - has_v4 = true; - jsondata4 = jsonreq4 || {}; - if (otable === 'status') { - data4 = jsondata4; - } else { - data4 = jsondata4[otable] || []; - } - - for (var i = 0; i < data4.length; i++) { - data4[i]['proto'] = '4'; - } - } - - if (jsonreq6 !== '') { - has_v6 = true; - jsondata6 = jsonreq6 || {}; - if (otable === 'status') { - data6 = jsondata6; - } else { - data6 = jsondata6[otable] || []; - } - - for (var j = 0; j < data6.length; j++) { - data6[j]['proto'] = '6'; - } - } - - for (var k = 0; k < data6.length; k++) { - data4.push(data6[k]); - } - - resolve([data4, has_v4, has_v6, false]); - }) - .catch(function (err) { - console.error(err); - reject([null, 0, 0, true]); - }); - }); - }, +return olsr.olsrview.extend({ + + async action_interfaces() { + const [data, has_v4, has_v6, error] = await this.fetch_jsoninfo('interfaces'); + + if (error) { + throw error; + } - action_interfaces: async function () { - try { - const [data, has_v4, has_v6, error] = await this.fetch_jsoninfo('interfaces'); - - if (error) { - throw error; - } - - function compare(a, b) { - return a.proto < b.proto; - } - - const modifiedData = await Promise.all( - data.map(async function (v) { - const interfac = await network.getStatusByAddress(v.olsrInterface.ipAddress); - if (interfac) { - v.interface = interfac; - } - return v; - }) - ); - - modifiedData.sort(compare); - - const result = { - iface: modifiedData, - has_v4: has_v4, - has_v6: has_v6, - }; - - return result; - } catch (err) { - throw err; + function compare(a, b) { + return a.proto < b.proto; } + + const modifiedData = await Promise.all( + data.map(async function (v) { + const interfac = await network.getStatusByAddress(v.olsrInterface.ipAddress); + if (interfac) { + v.interface = interfac; + } + return v; + }) + ); + + modifiedData.sort(compare); + + const result = { + iface: modifiedData, + has_v4: has_v4, + has_v6: has_v6, + }; + + return result; }, - load: function () { + load() { return Promise.all([uci.load('olsrd'), uci.load('luci_olsr')]); }, - render: function () { - var iface_res; - var has_v4; - var has_v6; - var self = this; + + render() { + let iface_res; + let has_v4; + let has_v6; return this.action_interfaces() .then(function (result) { iface_res = result.iface; has_v4 = result.has_v4; has_v6 = result.has_v6; - var table = E('div', { 'class': 'table cbi-section-table' }, [ + const table = E('div', { 'class': 'table cbi-section-table' }, [ E('div', { 'class': 'tr' }, [ E('div', { 'class': 'th cbi-section-table-cell' }, _('Interface')), E('div', { 'class': 'th cbi-section-table-cell' }, _('Device')), @@ -142,12 +65,10 @@ return view.extend({ E('div', { 'class': 'th cbi-section-table-cell' }, _('Broadcast address')), ]), ]); - var i = 1; - - for (var k = 0; k < iface_res.length; k++) { - var iface = iface_res[k]; + let i = 1; - var tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + iface.proto }, [ + for (let iface of iface_res) { + const tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + iface.proto }, [ E('div', { 'class': 'td cbi-section-table-cell left' }, iface?.interface?.interface ?? '?'), E('div', { 'class': 'td cbi-section-table-cell left' }, iface.name), E('div', { 'class': 'td cbi-section-table-cell left' }, iface.olsrInterface.up ? _('up') : _('down')), @@ -162,19 +83,19 @@ return view.extend({ i = (i % 2) + 1; } - var fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of interfaces where OLSR is running')), table]); + const fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of interfaces where OLSR is running')), table]); - var h2 = E('h2', { 'name': 'content' }, _('Interfaces')); - var divToggleButtons = E('div', { 'id': 'togglebuttons' }); - var statusOlsrCommonJs = null; + const h2 = E('h2', { 'name': 'content' }, _('Interfaces')); + const divToggleButtons = E('div', { 'id': 'togglebuttons' }); + let statusOlsrCommonJs = null; if (has_v4 && has_v6) { statusOlsrCommonJs = E('script', { 'type': 'text/javascript', 'src': L.resource('common/common_js.js') }); } - var result = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrCommonJs]); + const fresult = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrCommonJs]); - return result; + return fresult; }) .catch(function (error) { console.error(error); diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/mid.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/mid.js index 828974a844..16f0fc8d06 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/mid.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/mid.js @@ -1,85 +1,14 @@ 'use strict'; -'require uci'; -'require view'; 'require rpc'; +'require uci'; 'require ui'; +'require view'; +'require olsr.common_js as olsr'; -return view.extend({ - callGetJsonStatus: rpc.declare({ - object: 'olsrinfo', - method: 'getjsondata', - params: ['otable', 'v4_port', 'v6_port'], - }), - - fetch_jsoninfo: function (otable) { - var jsonreq4 = ''; - var jsonreq6 = ''; - var v4_port = parseInt(uci.get('olsrd', 'olsrd_jsoninfo', 'port') || '') || 9090; - var v6_port = parseInt(uci.get('olsrd6', 'olsrd_jsoninfo', 'port') || '') || 9090; - var json; - var self = this; - return new Promise(function (resolve, reject) { - L.resolveDefault(self.callGetJsonStatus(otable, v4_port, v6_port), {}) - .then(function (res) { - json = res; - - jsonreq4 = JSON.parse(json.jsonreq4); - jsonreq6 = json.jsonreq6 !== '' ? JSON.parse(json.jsonreq6) : []; - var jsondata4 = {}; - var jsondata6 = {}; - var data4 = []; - var data6 = []; - var has_v4 = false; - var has_v6 = false; - - if (jsonreq4 === '' && jsonreq6 === '') { - window.location.href = 'error_olsr'; - reject([null, 0, 0, true]); - return; - } - - if (jsonreq4 !== '') { - has_v4 = true; - jsondata4 = jsonreq4 || {}; - if (otable === 'status') { - data4 = jsondata4; - } else { - data4 = jsondata4[otable] || []; - } - - for (var i = 0; i < data4.length; i++) { - data4[i]['proto'] = '4'; - } - } - - if (jsonreq6 !== '') { - has_v6 = true; - jsondata6 = jsonreq6 || {}; - if (otable === 'status') { - data6 = jsondata6; - } else { - data6 = jsondata6[otable] || []; - } - - for (var j = 0; j < data6.length; j++) { - data6[j]['proto'] = '6'; - } - } - - for (var k = 0; k < data6.length; k++) { - data4.push(data6[k]); - } +return olsr.olsrview.extend({ - resolve([data4, has_v4, has_v6, false]); - }) - .catch(function (err) { - console.error(err); - reject([null, 0, 0, true]); - }); - }); - }, - action_mid: function () { - var self = this; + action_mid() { + let self = this; return new Promise(function (resolve, reject) { self .fetch_jsoninfo('mid') @@ -98,7 +27,7 @@ return view.extend({ data.sort(compare); - var result = { mids: data, has_v4: has_v4, has_v6: has_v6 }; + const result = { mids: data, has_v4: has_v4, has_v6: has_v6 }; resolve(result); }) .catch(function (err) { @@ -107,10 +36,10 @@ return view.extend({ }); }, - render: function () { - var mids_res; - var has_v4; - var has_v6; + render() { + let mids_res; + let has_v4; + let has_v6; return this.action_mid() .then(function (result) { @@ -118,27 +47,25 @@ return view.extend({ has_v4 = result.has_v4; has_v6 = result.has_v6; - var table = E('div', { 'class': 'table cbi-section-table' }, [ + const table = E('div', { 'class': 'table cbi-section-table' }, [ E('div', { 'class': 'tr cbi-section-table-titles' }, [E('div', { 'class': 'th cbi-section-table-cell' }, _('OLSR node')), E('div', { class: 'th cbi-section-table-cell' }, _('Secondary OLSR interfaces'))]), ]); - var i = 1; + let i = 1; - for (var k = 0; k < mids_res.length; k++) { - var mid = mids_res[k]; - var aliases = ''; - for (var j = 0; j < mid.aliases.length; j++) { - var v = mid.aliases[j]; - var sep = aliases === '' ? '' : ', '; + for (let mid of mids_res) { + let aliases = ''; + for (let v of mid.aliases) { + const sep = aliases === '' ? '' : ', '; aliases = v.ipAddress + sep + aliases; } - var host = mid.main.ipAddress; + let host = mid.main.ipAddress; if (mid.proto === '6') { host = '[' + mid.main.ipAddress + ']'; } - var tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + mid.proto }, [ + const tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + mid.proto }, [ E('div', { 'class': 'td cbi-section-table-cell left' }, [E('a', { 'href': 'http://' + host + '/cgi-bin-status.html' }, mid.main.ipAddress)]), E('div', { 'class': 'td cbi-section-table-cell left' }, aliases), ]); @@ -147,24 +74,25 @@ return view.extend({ i = (i % 2) + 1; } - var fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of known multiple interface announcements')), table]); + const fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of known multiple interface announcements')), table]); - var h2 = E('h2', { 'name': 'content' }, _('Active MID announcements')); - var divToggleButtons = E('div', { 'id': 'togglebuttons' }); - var statusOlsrCommonJs = null; + const h2 = E('h2', { 'name': 'content' }, _('Active MID announcements')); + const divToggleButtons = E('div', { 'id': 'togglebuttons' }); + let statusOlsrCommonJs = null; if (has_v4 && has_v6) { statusOlsrCommonJs = E('script', { 'type': 'text/javascript', 'src': L.resource('common/common_js.js') }); } - var result = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrCommonJs]); + const fresult = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrCommonJs]); - return result; + return fresult; }) .catch(function (error) { console.error(error); }); }, + handleSaveApply: null, handleSave: null, handleReset: null, diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/neighbors.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/neighbors.js index 8feabb32cd..3d315cf91e 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/neighbors.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/neighbors.js @@ -1,120 +1,14 @@ 'use strict'; -'require uci'; -'require view'; +'require network'; 'require poll'; -'require rpc'; +'require uci'; 'require ui'; -'require network'; - -function etx_color(etx) { - let color = '#bb3333'; - if (etx === 0) { - color = '#bb3333'; - } else if (etx < 2) { - color = '#00cc00'; - } else if (etx < 4) { - color = '#ffcb05'; - } else if (etx < 10) { - color = '#ff6600'; - } - return color; -} - -function snr_colors(snr) { - let color = '#bb3333'; - if (snr === 0) { - color = '#bb3333'; - } else if (snr > 30) { - color = '#00cc00'; - } else if (snr > 20) { - color = '#ffcb05'; - } else if (snr > 5) { - color = '#ff6600'; - } - return color; -} - -return view.extend({ - callGetJsonStatus: rpc.declare({ - object: 'olsrinfo', - method: 'getjsondata', - params: ['otable', 'v4_port', 'v6_port'], - }), - - callGetHosts: rpc.declare({ - object: 'olsrinfo', - method: 'hosts', - }), - - fetch_jsoninfo: function (otable) { - var jsonreq4 = ''; - var jsonreq6 = ''; - var v4_port = parseInt(uci.get('olsrd', 'olsrd_jsoninfo', 'port') || '') || 9090; - var v6_port = parseInt(uci.get('olsrd6', 'olsrd_jsoninfo', 'port') || '') || 9090; - var json; - var self = this; - return new Promise(function (resolve, reject) { - L.resolveDefault(self.callGetJsonStatus(otable, v4_port, v6_port), {}) - .then(function (res) { - json = res; - - jsonreq4 = JSON.parse(json.jsonreq4); - jsonreq6 = json.jsonreq6 !== '' ? JSON.parse(json.jsonreq6) : []; - var jsondata4 = {}; - var jsondata6 = {}; - var data4 = []; - var data6 = []; - var has_v4 = false; - var has_v6 = false; - - if (jsonreq4 === '' && jsonreq6 === '') { - window.location.href = 'error_olsr'; - reject([null, 0, 0, true]); - return; - } - - if (jsonreq4 !== '') { - has_v4 = true; - jsondata4 = jsonreq4 || {}; - if (otable === 'status') { - data4 = jsondata4; - } else { - data4 = jsondata4[otable] || []; - } - - for (var i = 0; i < data4.length; i++) { - data4[i]['proto'] = '4'; - } - } - - if (jsonreq6 !== '') { - has_v6 = true; - jsondata6 = jsonreq6 || {}; - if (otable === 'status') { - data6 = jsondata6; - } else { - data6 = jsondata6[otable] || []; - } - - for (var j = 0; j < data6.length; j++) { - data6[j]['proto'] = '6'; - } - } - - for (var k = 0; k < data6.length; k++) { - data4.push(data6[k]); - } +'require view'; +'require olsr.common_js as olsr'; - resolve([data4, has_v4, has_v6, false]); - }) - .catch(function (err) { - console.error(err); - reject([null, 0, 0, true]); - }); - }); - }, +return olsr.olsrview.extend({ - action_neigh: async function () { + async action_neigh() { try { const [data, has_v4, has_v6, error] = await this.fetch_jsoninfo('links'); @@ -130,24 +24,24 @@ return view.extend({ } } - var assoclist = []; - var resolveVal = uci.get('luci_olsr', 'general', 'resolve'); - var devices; - var defaultgw; + const assoclist = []; + const resolveVal = uci.get('luci_olsr', 'general', 'resolve'); + let devices; + let defaultgw; devices = await network.getWifiDevices(); - var rts = await network.getWANNetworks(); + const rts = await network.getWANNetworks(); rts.forEach(function (rt) { defaultgw = rt.getGatewayAddr() || '0.0.0.0'; }); - var networkPromises = devices.map(async function (dev) { - var networks = await dev.getWifiNetworks(); + const networkPromises = devices.map(async function (dev) { + const networks = await dev.getWifiNetworks(); - var promiseArr = networks.map(async function (net) { - var radio = await net.getDevice(); - var [ifname, devnetwork, device, list] = await Promise.all([net.getIfname(), net.getNetworkNames(), radio ? radio.getName() : null, net.getAssocList()]); + const promiseArr = networks.map(async function (net) { + const radio = await net.getDevice(); + const [ifname, devnetwork, device, list] = await Promise.all([net.getIfname(), net.getNetworkNames(), radio ? radio.getName() : null, net.getAssocList()]); assoclist.push({ ifname: ifname, @@ -161,8 +55,8 @@ return view.extend({ }); await Promise.all(networkPromises); - var res = ''; - var self = this; + let res = ''; + let self = this; await (async function () { try { res = await self.callGetHosts(); @@ -173,40 +67,36 @@ return view.extend({ })(); function matchHostnames(ip) { - var lines = res.hosts.split('\n'); - for (var i = 0; i < lines.length; i++) { - var ipandhostname = lines[i].trim().split(/\s+/); + const lines = res.hosts.split('\n'); + for (let line of lines) { + const ipandhostname = line.trim().split(/\s+/); if (ipandhostname[0] === ip) { return ipandhostname[1]; } } return null; } - var modifiedData = await Promise.all( + const modifiedData = await Promise.all( data.map(async function (v) { - var snr = 0; - var signal = 0; - var noise = 0; - var mac = ''; - var ip; - var neihgt = []; + let snr = 0; + let signal = 0; + let noise = 0; if (resolveVal === '1') { - var hostname = matchHostnames(v.remoteIP); + const hostname = matchHostnames(v.remoteIP); if (hostname) { v.hostname = hostname; } } - var hosthints = await network.getHostHints(); - var networkStatus = await network.getStatusByAddress(v.localIP); - var lmac = await hosthints.getMACAddrByIPAddr(v.localIP); - var rmac = await hosthints.getMACAddrByIPAddr(v.remoteIP); + const hosthints = await network.getHostHints(); + const networkStatus = await network.getStatusByAddress(v.localIP); + const lmac = await hosthints.getMACAddrByIPAddr(v.localIP); + const rmac = await hosthints.getMACAddrByIPAddr(v.remoteIP); - for (let i = 0; i < assoclist.length; i++) { - var val = assoclist[i]; + for (let val of assoclist) { if (networkStatus != undefined && val.network === networkStatus.interface && val.list) { - for (var assocmac in val.list) { - var assot = val.list[assocmac]; + for (let assocmac in val.list) { + const assot = val.list[assocmac]; if (rmac == assot.mac) { signal = parseInt(assot.signal); noise = parseInt(assot.noise); @@ -238,7 +128,7 @@ return view.extend({ modifiedData.sort(compare); - var result = { links: modifiedData, has_v4: has_v4, has_v6: has_v6 }; + const result = { links: modifiedData, has_v4: has_v4, has_v6: has_v6 }; return result; } catch (err) { console.error(err); @@ -246,18 +136,18 @@ return view.extend({ } }, - load: function () { - var self = this; + load() { + let self = this; poll.add(function () { self.render(); }, 5); return Promise.all([uci.load('olsrd'), uci.load('luci_olsr')]); }, - render: function () { - var neigh_res; - var has_v4; - var has_v6; - var self = this; + + render() { + let neigh_res; + let has_v4; + let has_v6; return this.action_neigh() .then(function (result) { @@ -265,7 +155,7 @@ return view.extend({ has_v4 = result.has_v4; has_v6 = result.has_v6; - var table = E('div', { 'class': 'table cbi-section-table', 'id': 'olsr_neigh_table' }, [ + const table = E('div', { 'class': 'table cbi-section-table', 'id': 'olsr_neigh_table' }, [ E('div', { 'class': 'tr cbi-section-table-cell' }, [ E('div', { 'class': 'th cbi-section-table-cell' }, _('Neighbour IP')), E('div', { 'class': 'th cbi-section-table-cell' }, _('Hostname')), @@ -278,16 +168,15 @@ return view.extend({ ]), ]); - var rv = []; - for (var k = 0; k < neigh_res.length; k++) { - var link = neigh_res[k]; + const rv = []; + for (let link of neigh_res) { link.linkCost = (link.linkCost).toFixed(3) || 0; if (link.linkCost === 4194304) { link.linkCost = 0; } - var color = etx_color(link.linkCost); - var snr_color = snr_colors(link.snr); - var defaultgw_color = ''; + const color = etx_color(link.linkCost); + const snr_color = snr_colors(link.snr); + let defaultgw_color = ''; if (link.defaultgw === 1) { defaultgw_color = '#ffff99'; } @@ -310,9 +199,9 @@ return view.extend({ }); } - var nt = document.getElementById('olsr_neigh_table'); + const nt = document.getElementById('olsr_neigh_table'); if (nt) { - var s = + let s = '<div class="tr cbi-section-table-cell">' + '<div class="th cbi-section-table-cell">Neighbour IP</div>' + '<div class="th cbi-section-table-cell">Hostname</div>' + @@ -324,8 +213,8 @@ return view.extend({ '<div class="th cbi-section-table-cell">SNR</div>' + '</div>'; - for (var idx = 0; idx < rv.length; idx++) { - var neigh = rv[idx]; + for (let idx = 0; idx < rv.length; idx++) { + const neigh = rv[idx]; if (neigh.proto == '6') { s += @@ -402,28 +291,27 @@ return view.extend({ nt.innerHTML = s; } - var i = 1; + let i = 1; - for (var k = 0; k < neigh_res.length; k++) { - var link = neigh_res[k]; + for (let link of neigh_res) { link.linkCost = Number(link.linkCost).toFixed(3) || 0; if (link.linkCost === 4194304) { link.linkCost = 0; } - color = etx_color(link.linkCost); - snr_color = snr_colors(link.snr); + const color = etx_color(link.linkCost); + const snr_color = snr_colors(link.snr); if (link.snr === 0) { link.snr = '?'; } - var defaultgw_color = ''; + let defaultgw_color = ''; if (link.defaultgw === 1) { defaultgw_color = '#ffff99'; } - var tr = E( + const tr = E( 'div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + link.proto, @@ -526,11 +414,11 @@ return view.extend({ i = (i % 2) + 1; } - var fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of currently established OLSR connections')), table]); + const fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of currently established OLSR connections')), table]); - var h2 = E('h2', { 'name': 'content' }, _('OLSR connections')); - var divToggleButtons = E('div', { 'id': 'togglebuttons' }); - var statusOlsrLegend = E('div', {}, [ + const h2 = E('h2', { 'name': 'content' }, _('OLSR connections')); + const divToggleButtons = E('div', { 'id': 'togglebuttons' }); + const statusOlsrLegend = E('div', {}, [ E('h3', {}, [_('Legend') + ':']), E('ul', {}, [ E('li', {}, [E('strong', {}, [_('LQ: ')]), _('Success rate of packages received from the neighbour')]), @@ -556,7 +444,7 @@ return view.extend({ ]), ]); - var statusOlsrCommonJs = null; + let statusOlsrCommonJs = null; if (has_v4 && has_v6) { statusOlsrCommonJs = E('script', { @@ -565,14 +453,15 @@ return view.extend({ }); } - var result = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrLegend, statusOlsrCommonJs]); + const fresult = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrLegend, statusOlsrCommonJs]); - return result; + return fresult; }) .catch(function (error) { console.error(error); }); }, + handleSaveApply: null, handleSave: null, handleReset: null, diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/routes.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/routes.js index a202da1412..36457d3b82 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/routes.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/routes.js @@ -1,106 +1,16 @@ 'use strict'; -'require uci'; -'require view'; -'require poll'; 'require network'; +'require poll'; 'require rpc'; +'require uci'; 'require ui'; +'require view'; +'require olsr.common_js as olsr'; -function etx_color(etx) { - let color = '#bb3333'; - if (etx === 0) { - color = '#bb3333'; - } else if (etx < 2) { - color = '#00cc00'; - } else if (etx < 4) { - color = '#ffcb05'; - } else if (etx < 10) { - color = '#ff6600'; - } - return color; -} - -return view.extend({ - callGetJsonStatus: rpc.declare({ - object: 'olsrinfo', - method: 'getjsondata', - params: ['otable', 'v4_port', 'v6_port'], - }), - - callGetHosts: rpc.declare({ - object: 'olsrinfo', - method: 'hosts', - }), - - fetch_jsoninfo: function (otable) { - var jsonreq4 = ''; - var jsonreq6 = ''; - var v4_port = parseInt(uci.get('olsrd', 'olsrd_jsoninfo', 'port') || '') || 9090; - var v6_port = parseInt(uci.get('olsrd6', 'olsrd_jsoninfo', 'port') || '') || 9090; - var json; - var self = this; - return new Promise(function (resolve, reject) { - L.resolveDefault(self.callGetJsonStatus(otable, v4_port, v6_port), {}) - .then(function (res) { - json = res; - - jsonreq4 = JSON.parse(json.jsonreq4); - jsonreq6 = json.jsonreq6 !== '' ? JSON.parse(json.jsonreq6) : []; - var jsondata4 = {}; - var jsondata6 = {}; - var data4 = []; - var data6 = []; - var has_v4 = false; - var has_v6 = false; - - if (jsonreq4 === '' && jsonreq6 === '') { - window.location.href = 'error_olsr'; - reject([null, 0, 0, true]); - return; - } - - if (jsonreq4 !== '') { - has_v4 = true; - jsondata4 = jsonreq4 || {}; - if (otable === 'status') { - data4 = jsondata4; - } else { - data4 = jsondata4[otable] || []; - } - - for (var i = 0; i < data4.length; i++) { - data4[i]['proto'] = '4'; - } - } - - if (jsonreq6 !== '') { - has_v6 = true; - jsondata6 = jsonreq6 || {}; - if (otable === 'status') { - data6 = jsondata6; - } else { - data6 = jsondata6[otable] || []; - } - - for (var j = 0; j < data6.length; j++) { - data6[j]['proto'] = '6'; - } - } +return olsr.olsrview.extend({ - for (var k = 0; k < data6.length; k++) { - data4.push(data6[k]); - } - - resolve([data4, has_v4, has_v6, false]); - }) - .catch(function (err) { - console.error(err); - reject([null, 0, 0, true]); - }); - }); - }, - action_routes: function () { - var self = this; + action_routes() { + let self = this; return new Promise(function (resolve, reject) { self .fetch_jsoninfo('routes') @@ -109,7 +19,7 @@ return view.extend({ reject(error); } - var resolveVal = uci.get('luci_olsr', 'general', 'resolve'); + const resolveVal = uci.get('luci_olsr', 'general', 'resolve'); function compare(a, b) { if (a.proto === b.proto) { @@ -118,14 +28,14 @@ return view.extend({ return a.proto < b.proto; } } - var modifiedData; + let modifiedData; self .callGetHosts() .then(function (res) { function matchHostnames(ip) { - var lines = res.hosts.split('\n'); - for (var i = 0; i < lines.length; i++) { - var ipandhostname = lines[i].trim().split(/\s+/); + let lines = res.hosts.split('\n'); + for (let line of lines) { + const ipandhostname = line.trim().split(/\s+/); if (ipandhostname[0] === ip) { return ipandhostname[1]; } @@ -134,7 +44,7 @@ return view.extend({ } modifiedData = data.map(function (v) { if (resolveVal === '1') { - var hostname = matchHostnames(v.gateway); + const hostname = matchHostnames(v.gateway); if (hostname) { v.hostname = hostname; } @@ -144,7 +54,7 @@ return view.extend({ modifiedData.sort(compare); - var result = { routes: modifiedData, has_v4: has_v4, has_v6: has_v6 }; + const result = { routes: modifiedData, has_v4: has_v4, has_v6: has_v6 }; resolve(result); }) .catch(function (err) { @@ -157,24 +67,25 @@ return view.extend({ }); }); }, - load: function () { - var self = this; + + load() { + let self = this; poll.add(function () { self.render(); }, 5); return Promise.all([uci.load('olsrd'), uci.load('luci_olsr')]); }, - render: function () { - var routes_res; - var has_v4; - var has_v6; - var self = this; + + render() { + let routes_res; + let has_v4; + let has_v6; return this.action_routes() .then(function (result) { routes_res = result.routes; has_v4 = result.has_v4; has_v6 = result.has_v6; - var table = E('div', { 'class': 'table cbi-section-table', 'id': 'olsrd_routes' }, [ + const table = E('div', { 'class': 'table cbi-section-table', 'id': 'olsrd_routes' }, [ E('div', { 'class': 'tr cbi-section-table-cell' }, [ E('div', { 'class': 'th cbi-section-table-cell' }, _('Announced network')), E('div', { 'class': 'th cbi-section-table-cell' }, _('OLSR gateway')), @@ -183,10 +94,9 @@ return view.extend({ E('div', { 'class': 'th cbi-section-table-cell' }, 'ETX'), ]), ]); - var rv = []; - for (var k = 0; k < routes_res.length; k++) { - var route = routes_res[k]; - var ETX = (parseFloat(route.etx) || 0).toFixed(3); + const rv = []; + for (let route of routes_res) { + const ETX = (parseFloat(route.etx) || 0).toFixed(3); rv.push({ hostname: route.hostname, dest: route.destination, @@ -199,9 +109,9 @@ return view.extend({ }); } - var rt = document.getElementById('olsrd_routes'); + const rt = document.getElementById('olsrd_routes'); if (rt) { - var s = + let s = '<div class="tr cbi-section-table-cell">' + '<div class="th cbi-section-table-cell">Announced network</div>' + '<div class="th cbi-section-table-cell">OLSR gateway</div>' + @@ -210,8 +120,8 @@ return view.extend({ '<div class="th cbi-section-table-cell">ETX</div>' + '</div>'; - for (var idx = 0; idx < rv.length; idx++) { - var route = rv[idx]; + for (let idx = 0; idx < rv.length; idx++) { + const route = rv[idx]; s += '<div class="tr cbi-section-table-row cbi-rowstyle-' + @@ -258,14 +168,13 @@ return view.extend({ rt.innerHTML = s; } - var i = 1; + let i = 1; - for (var k = 0; k < routes_res.length; k++) { - var route = routes_res[k]; - var ETX = parseInt(route.etx) || 0; - var color = etx_color(ETX); + for (let route of routes_res) { + const ETX = parseInt(route.etx) || 0; + const color = etx_color(ETX); - var tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + route.proto }, [ + const tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + route.proto }, [ E('div', { 'class': 'td cbi-section-table-cell left' }, route.destination + '/' + route.genmask), E('div', { 'class': 'td cbi-section-table-cell left' }, [ route.proto === '6' ? E('a', { 'href': 'http://[' + route.gateway + ']/cgi-bin-status.html' }, route.gateway) : E('a', { 'href': 'http://' + route.gateway + '/cgi-bin-status.html' }, route.gateway), @@ -280,11 +189,11 @@ return view.extend({ i = (i % 2) + 1; } - var fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of currently known routes to other OLSR nodes')), table]); + const fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of currently known routes to other OLSR nodes')), table]); - var h2 = E('h2', { 'name': 'content' }, _('Known OLSR routes')); - var divToggleButtons = E('div', { 'id': 'togglebuttons' }); - var statusOlsrLegend = E('div', {}, [ + const h2 = E('h2', { 'name': 'content' }, _('Known OLSR routes')); + const divToggleButtons = E('div', { 'id': 'togglebuttons' }); + const statusOlsrLegend = E('div', {}, [ E('h3', {}, [_('Legend') + ':']), E('ul', {}, [ E('li', {}, [E('strong', {}, [_('LQ: ')]), _('Success rate of packages received from the neighbour')]), @@ -310,15 +219,15 @@ return view.extend({ ]), ]); - var statusOlsrCommonJs = null; + let statusOlsrCommonJs = null; if (has_v4 && has_v6) { statusOlsrCommonJs = E('script', { 'type': 'text/javascript', 'src': L.resource('common/common_js.js') }); } - var result = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrLegend, statusOlsrCommonJs]); + const fresult = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrLegend, statusOlsrCommonJs]); - return result; + return fresult; }) .catch(function (error) { console.error(error); diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/smartgw.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/smartgw.js index 3b6ca662f9..88397bbcb6 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/smartgw.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/smartgw.js @@ -1,86 +1,15 @@ 'use strict'; -'require uci'; -'require view'; 'require poll'; 'require rpc'; +'require uci'; 'require ui'; +'require view'; +'require olsr.common_js as olsr'; -return view.extend({ - callGetJsonStatus: rpc.declare({ - object: 'olsrinfo', - method: 'getjsondata', - params: ['otable', 'v4_port', 'v6_port'], - }), - - fetch_jsoninfo: function (otable) { - var jsonreq4 = ''; - var jsonreq6 = ''; - var v4_port = parseInt(uci.get('olsrd', 'olsrd_jsoninfo', 'port') || '') || 9090; - var v6_port = parseInt(uci.get('olsrd6', 'olsrd_jsoninfo', 'port') || '') || 9090; - var json; - var self = this; - return new Promise(function (resolve, reject) { - L.resolveDefault(self.callGetJsonStatus(otable, v4_port, v6_port), {}) - .then(function (res) { - json = res; - - jsonreq4 = JSON.parse(json.jsonreq4); - jsonreq6 = json.jsonreq6 !== '' ? JSON.parse(json.jsonreq6) : []; - var jsondata4 = {}; - var jsondata6 = {}; - var data4 = []; - var data6 = []; - var has_v4 = false; - var has_v6 = false; - - if (jsonreq4 === '' && jsonreq6 === '') { - window.location.href = 'error_olsr'; - reject([null, 0, 0, true]); - return; - } - - if (jsonreq4 !== '') { - has_v4 = true; - jsondata4 = jsonreq4 || {}; - if (otable === 'status') { - data4 = jsondata4; - } else { - data4 = jsondata4[otable] || []; - } - - for (var i = 0; i < data4.length; i++) { - data4[i]['proto'] = '4'; - } - } - - if (jsonreq6 !== '') { - has_v6 = true; - jsondata6 = jsonreq6 || {}; - if (otable === 'status') { - data6 = jsondata6; - } else { - data6 = jsondata6[otable] || []; - } - - for (var j = 0; j < data6.length; j++) { - data6[j]['proto'] = '6'; - } - } - - for (var k = 0; k < data6.length; k++) { - data4.push(data6[k]); - } +return olsr.olsrview.extend({ - resolve([data4, has_v4, has_v6, false]); - }) - .catch(function (err) { - console.error(err); - reject([null, 0, 0, true]); - }); - }); - }, - action_smartgw: function () { - var self = this; + action_smartgw() { + let self = this; return new Promise(function (resolve, reject) { self .fetch_jsoninfo('gateways') @@ -100,7 +29,7 @@ return view.extend({ data.ipv4.sort(compare); data.ipv6.sort(compare); - var result = { gws: data, has_v4: has_v4, has_v6: has_v6 }; + const result = { gws: data, has_v4: has_v4, has_v6: has_v6 }; resolve(result); }) .catch(function (err) { @@ -108,24 +37,25 @@ return view.extend({ }); }); }, - load: function () { - var self = this; + + load() { + let self = this; poll.add(function () { self.render(); }, 5); return Promise.all([uci.load('olsrd'), uci.load('luci_olsr')]); }, - render: function () { - var gws_res; - var has_v4; - var has_v6; - var self = this; + + render() { + let gws_res; + let has_v4; + let has_v6; return this.action_smartgw() .then(function (result) { gws_res = result.gws; has_v4 = result.has_v4; has_v6 = result.has_v6; - var fieldset = E('fieldset', { 'class': 'cbi-section' }, [ + const fieldset = E('fieldset', { 'class': 'cbi-section' }, [ E('legend', {}, _('Overview of smart gateways in this network')), E('div', { 'class': 'table cbi-section-table', 'id': 'olsrd_smartgw' }, [ E('div', { 'class': 'tr cbi-section-table-titles' }, [ @@ -141,16 +71,15 @@ return view.extend({ ]), ]), ]); - var has_smartgw; + let has_smartgw; uci.sections('olsrd', 'olsrd', function (s) { if (s.SmartGateway && s.SmartGateway === 'yes') { has_smartgw = true; } }); - var rv = []; - for (var k = 0; k < gws_res.ipv4.length; k++) { - var gw = gws_res.ipv4[k]; + const rv = []; + for (let gw of gws_res.ipv4) { gw.cost = parseFloat(gw.cost) / 1024 || 0; if (gw.cost >= 100) { gw.cost = 0; @@ -159,20 +88,20 @@ return view.extend({ rv.push({ proto: gw.IPv4 ? '4' : '6', originator: gw.originator, - selected: gw.selected ? luci.i18n.translate('yes') : luci.i18n.translate('no'), - cost: gw.cost > 0 ? gw.cost.toFixed(3) : luci.i18n.translate('infinite'), + selected: gw.selected ? _('yes') : _('no'), + cost: gw.cost > 0 ? gw.cost.toFixed(3) : _('infinite'), hops: gw.hops, uplink: gw.uplink, downlink: gw.downlink, - v4: gw.IPv4 ? luci.i18n.translate('yes') : luci.i18n.translate('no'), - v6: gw.IPv6 ? luci.i18n.translate('yes') : luci.i18n.translate('no'), + v4: gw.IPv4 ? _('yes') : _('no'), + v6: gw.IPv6 ? _('yes') : _('no'), prefix: gw.prefix, }); } - var smartgwdiv = document.getElementById('olsrd_smartgw'); + const smartgwdiv = document.getElementById('olsrd_smartgw'); if (smartgwdiv) { - var s = + let s = '<div class="tr cbi-section-table-titles">' + '<div class="th cbi-section-table-cell">Gateway</div>' + '<div class="th cbi-section-table-cell">Selected</div>' + @@ -185,9 +114,9 @@ return view.extend({ '<div class="th cbi-section-table-cell">Prefix</div>' + '</div>'; - for (var idx = 0; idx < rv.length; idx++) { - var smartgw = rv[idx]; - var linkgw; + for (let idx = 0; idx < rv.length; idx++) { + const smartgw = rv[idx]; + let linkgw; s += '<div class="tr cbi-section-table-row cbi-rowstyle-' + (1 + (idx % 2)) + ' proto-' + smartgw.proto + '">'; if (smartgw.proto == '6') { @@ -230,27 +159,26 @@ return view.extend({ smartgwdiv.innerHTML = s; } - var i = 1; + let i = 1; if (has_smartgw) { - for (var k = 0; k < gws_res.ipv4.length; k++) { - var gw = gws_res.ipv4[k]; + for (let gw of gws_res.ipv4) { gw.cost = parseInt(gw.cost) / 1024 || 0; if (gw.cost >= 100) { gw.cost = 0; } - var tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + gw.proto }, [ + const tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + gw.proto }, [ gw.proto === '6' ? E('div', { 'class': 'td cbi-section-table-cell left' }, [E('a', { 'href': 'http://[' + gw.originator + ']/cgi-bin-status.html' }, gw.originator)]) : E('div', { 'class': 'td cbi-section-table-cell left' }, [E('a', { 'href': 'http://' + gw.originator + '/cgi-bin-status.html' }, gw.originator)]), - E('div', { 'class': 'td cbi-section-table-cell left' }, [gw.selected ? luci.i18n.translate('yes') : luci.i18n.translate('no')]), - E('div', { 'class': 'td cbi-section-table-cell left' }, [gw.cost > 0 ? string.format('%.3f', gw.cost) : luci.i18n.translate('infinite')]), + E('div', { 'class': 'td cbi-section-table-cell left' }, [gw.selected ? _('yes') : _('no')]), + E('div', { 'class': 'td cbi-section-table-cell left' }, [gw.cost > 0 ? String.format('%.3f', gw.cost) : _('infinite')]), E('div', { 'class': 'td cbi-section-table-cell left' }, gw.hops), E('div', { 'class': 'td cbi-section-table-cell left' }, gw.uplink), E('div', { 'class': 'td cbi-section-table-cell left' }, gw.downlink), - E('div', { 'class': 'td cbi-section-table-cell left' }, gw.IPv4 ? luci.i18n.translate('yes') : luci.i18n.translate('no')), - E('div', { 'class': 'td cbi-section-table-cell left' }, gw.IPv6 ? luci.i18n.translate('yes') : luci.i18n.translate('no')), + E('div', { 'class': 'td cbi-section-table-cell left' }, gw.IPv4 ? _('yes') : _('no')), + E('div', { 'class': 'td cbi-section-table-cell left' }, gw.IPv6 ? _('yes') : _('no')), E('div', { 'class': 'td cbi-section-table-cell left' }, gw.prefix), ]); @@ -258,17 +186,17 @@ return view.extend({ i = (i % 2) + 1; } - var h2 = E('h2', { 'name': 'content' }, _('SmartGW announcements')); - var divToggleButtons = E('div', { 'id': 'togglebuttons' }); - var statusOlsrCommonJs = null; + const h2 = E('h2', { 'name': 'content' }, _('SmartGW announcements')); + const divToggleButtons = E('div', { 'id': 'togglebuttons' }); + let statusOlsrCommonJs = null; if (has_v4 && has_v6) { statusOlsrCommonJs = E('script', { 'type': 'text/javascript', 'src': L.resource('common/common_js.js') }); } - var result = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrCommonJs]); + const fresult = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrCommonJs]); - return result; + return fresult; } else { return E('h2', {}, _('SmartGateway is not configured on this system')); } diff --git a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/topology.js b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/topology.js index 6a179e848b..c8d927356e 100644 --- a/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/topology.js +++ b/applications/luci-app-olsr/htdocs/luci-static/resources/view/olsr/status-olsr/topology.js @@ -1,100 +1,15 @@ 'use strict'; -'require uci'; -'require view'; 'require poll'; 'require rpc'; +'require uci'; 'require ui'; +'require view'; +'require olsr.common_js as olsr'; -function etx_color(etx) { - let color = '#bb3333'; - if (etx === 0) { - color = '#bb3333'; - } else if (etx < 2) { - color = '#00cc00'; - } else if (etx < 4) { - color = '#ffcb05'; - } else if (etx < 10) { - color = '#ff6600'; - } - return color; -} - -return view.extend({ - callGetJsonStatus: rpc.declare({ - object: 'olsrinfo', - method: 'getjsondata', - params: ['otable', 'v4_port', 'v6_port'], - }), - - fetch_jsoninfo: function (otable) { - var jsonreq4 = ''; - var jsonreq6 = ''; - var v4_port = parseInt(uci.get('olsrd', 'olsrd_jsoninfo', 'port') || '') || 9090; - var v6_port = parseInt(uci.get('olsrd6', 'olsrd_jsoninfo', 'port') || '') || 9090; - var json; - var self = this; - return new Promise(function (resolve, reject) { - L.resolveDefault(self.callGetJsonStatus(otable, v4_port, v6_port), {}) - .then(function (res) { - json = res; - - jsonreq4 = JSON.parse(json.jsonreq4); - jsonreq6 = json.jsonreq6 !== '' ? JSON.parse(json.jsonreq6) : []; - var jsondata4 = {}; - var jsondata6 = {}; - var data4 = []; - var data6 = []; - var has_v4 = false; - var has_v6 = false; - - if (jsonreq4 === '' && jsonreq6 === '') { - window.location.href = 'error_olsr'; - reject([null, 0, 0, true]); - return; - } - - if (jsonreq4 !== '') { - has_v4 = true; - jsondata4 = jsonreq4 || {}; - if (otable === 'status') { - data4 = jsondata4; - } else { - data4 = jsondata4[otable] || []; - } - - for (var i = 0; i < data4.length; i++) { - data4[i]['proto'] = '4'; - } - } - - if (jsonreq6 !== '') { - has_v6 = true; - jsondata6 = jsonreq6 || {}; - if (otable === 'status') { - data6 = jsondata6; - } else { - data6 = jsondata6[otable] || []; - } - - for (var j = 0; j < data6.length; j++) { - data6[j]['proto'] = '6'; - } - } - - for (var k = 0; k < data6.length; k++) { - data4.push(data6[k]); - } +return olsr.olsrview.extend({ - resolve([data4, has_v4, has_v6, false]); - }) - .catch(function (err) { - console.error(err); - reject([null, 0, 0, true]); - }); - }); - }, - action_topology: function () { - var self = this; + action_topology() { + let self = this; return new Promise(function (resolve, reject) { self .fetch_jsoninfo('topology') @@ -113,28 +28,30 @@ return view.extend({ data.sort(compare); - var result = { routes: data, has_v4: has_v4, has_v6: has_v6 }; - resolve(result); + const fresult = { routes: data, has_v4: has_v4, has_v6: has_v6 }; + resolve(fresult); }) .catch(function (err) { reject(err); }); }); }, - load: function () { + + load() { return Promise.all([uci.load('olsrd'), uci.load('luci_olsr')]); }, - render: function () { - var routes_res; - var has_v4; - var has_v6; + + render() { + let routes_res; + let has_v4; + let has_v6; return this.action_topology() .then(function (result) { routes_res = result.routes; has_v4 = result.has_v4; has_v6 = result.has_v6; - var table = E('div', { 'class': 'table cbi-section-table' }, [ + const table = E('div', { 'class': 'table cbi-section-table' }, [ E('div', { 'class': 'tr cbi-section-table-titles' }, [ E('div', { 'class': 'th cbi-section-table-cell' }, _('OLSR node')), E('div', { 'class': 'th cbi-section-table-cell' }, _('Last hop')), @@ -143,16 +60,15 @@ return view.extend({ E('div', { 'class': 'th cbi-section-table-cell' }, _('ETX')), ]), ]); - var i = 1; + let i = 1; - for (var k = 0; k < routes_res.length; k++) { - var route = routes_res[k]; - var cost = (parseInt(route.tcEdgeCost) || 0).toFixed(3); - var color = etx_color(parseInt(cost)); - var lq = (parseInt(route.linkQuality) || 0).toFixed(3); - var nlq = (parseInt(route.neighborLinkQuality) || 0).toFixed(3); + for (let route of routes_res) { + const cost = (parseInt(route.tcEdgeCost) || 0).toFixed(3); + const color = etx_color(parseInt(cost)); + const lq = (parseInt(route.linkQuality) || 0).toFixed(3); + const nlq = (parseInt(route.neighborLinkQuality) || 0).toFixed(3); - var tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + route.proto }, [ + const tr = E('div', { 'class': 'tr cbi-section-table-row cbi-rowstyle-' + i + ' proto-' + route.proto }, [ route.proto === '6' ? E('div', { 'class': 'td cbi-section-table-cell left' }, [E('a', { 'href': 'http://[' + route.destinationIP + ']/cgi-bin-status.html' }, route.destinationIP)]) : E('div', { 'class': 'td cbi-section-table-cell left' }, [E('a', { 'href': 'http://' + route.destinationIP + '/cgi-bin-status.html' }, route.destinationIP)]), @@ -168,11 +84,11 @@ return view.extend({ i = (i % 2) + 1; } - var fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of currently known OLSR nodes')), table]); + const fieldset = E('fieldset', { 'class': 'cbi-section' }, [E('legend', {}, _('Overview of currently known OLSR nodes')), table]); - var h2 = E('h2', { 'name': 'content' }, _('Active OLSR nodes')); - var divToggleButtons = E('div', { 'id': 'togglebuttons' }); - var statusOlsrLegend = E('div', {}, [ + const h2 = E('h2', { 'name': 'content' }, _('Active OLSR nodes')); + const divToggleButtons = E('div', { 'id': 'togglebuttons' }); + const statusOlsrLegend = E('div', {}, [ E('h3', {}, [_('Legend') + ':']), E('ul', {}, [ E('li', {}, [E('strong', {}, [_('LQ: ')]), _('Success rate of packages received from the neighbour')]), @@ -198,15 +114,15 @@ return view.extend({ ]), ]); - var statusOlsrCommonJs = null; + let statusOlsrCommonJs = null; if (has_v4 && has_v6) { statusOlsrCommonJs = E('script', { 'type': 'text/javascript', 'src': L.resource('common/common_js.js') }); } - var result = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrLegend, statusOlsrCommonJs]); + const fresult = E([], {}, [h2, divToggleButtons, fieldset, statusOlsrLegend, statusOlsrCommonJs]); - return result; + return fresult; }) .catch(function (error) { console.error(error); diff --git a/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-frontend.json b/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-frontend.json index 34fd703cf0..e06c3a6832 100644 --- a/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-frontend.json +++ b/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-frontend.json @@ -1,12 +1,13 @@ { - "olsr": { + "admin/olsr": { "title": "OLSR", "order": 9, "action": { "type": "firstchild" } }, - "olsr/neighbours": { + + "admin/olsr/neighbours": { "title": "Neighbours", "order": 15, "action": { @@ -14,7 +15,8 @@ "path": "olsr/status-olsr/neighbors" } }, - "olsr/routes": { + + "admin/olsr/routes": { "title": "Routes", "order": 20, "action": { @@ -22,7 +24,8 @@ "path": "olsr/status-olsr/routes" } }, - "olsr/topology": { + + "admin/olsr/topology": { "title": "Topology", "order": 25, "action": { @@ -30,7 +33,8 @@ "path": "olsr/status-olsr/topology" } }, - "olsr/hna": { + + "admin/olsr/hna": { "title": "HNA", "order": 30, "action": { @@ -38,7 +42,8 @@ "path": "olsr/status-olsr/hna" } }, - "olsr/mid": { + + "admin/olsr/mid": { "title": "MID", "order": 35, "action": { @@ -46,7 +51,8 @@ "path": "olsr/status-olsr/mid" } }, - "olsr/interface": { + + "admin/olsr/interface": { "title": "Interface", "order": 35, "action": { @@ -54,7 +60,8 @@ "path": "olsr/status-olsr/interfaces" } }, - "olsr/smartgw": { + + "admin/olsr/smartgw": { "title": "SmartGW", "order": 40, "action": { @@ -62,7 +69,8 @@ "path": "olsr/status-olsr/smartgw" } }, - "olsr/error_olsr": { + + "admin/olsr/error_olsr": { "order": 45, "action": { "type": "view", diff --git a/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/stations.js b/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/stations.js index afc182b4c8..3bfbe467ff 100644 --- a/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/stations.js +++ b/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/stations.js @@ -254,7 +254,7 @@ return view.extend({ m = new form.Map('wireless'); m.chain('travelmate'); s = m.section(form.GridSection, 'wifi-iface', null, _('Overview of all configured uplinks for travelmate. \ - You can edit, remove or prioritize existing uplinks by drag \& drop and scan for new ones.<br /> \ + You can edit, remove or prioritize existing uplinks by drag & drop and scan for new ones.<br /> \ The currently used uplink connection is emphasized in <span style="color:rgb(51, 119, 204);font-weight:bold">blue</span>, \ an encrypted VPN uplink connection is emphasized in <span style="color:rgb(68, 170, 68);font-weight:bold">green</span>.')); s.anonymous = true; |