diff options
author | Jo-Philipp Wich <jo@mein.io> | 2023-09-26 09:20:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-26 09:20:00 +0200 |
commit | 08fbceecd9b7c98e79cb32b886a37c67c4bc63d7 (patch) | |
tree | f7493d5784594d86693840e0f9b324d308421e29 /applications/luci-app-olsr-viz/root | |
parent | 8a511da2602b8e7a6033978e6204f0a990ae34bd (diff) | |
parent | 00cfca13b5cd01ee86194e3f859b81e1db475b8a (diff) |
Merge pull request #6480 from Ayushmanwebdeveloper/luci-app-olsr-viz-mig
luci-app-olsr-viz: migrate to JavaScript-based implementation
Diffstat (limited to 'applications/luci-app-olsr-viz/root')
3 files changed, 78 insertions, 5 deletions
diff --git a/applications/luci-app-olsr-viz/root/usr/libexec/rpcd/olsrvizinfo b/applications/luci-app-olsr-viz/root/usr/libexec/rpcd/olsrvizinfo new file mode 100644 index 0000000000..27c1f67af3 --- /dev/null +++ b/applications/luci-app-olsr-viz/root/usr/libexec/rpcd/olsrvizinfo @@ -0,0 +1,59 @@ +#!/bin/sh +. /usr/share/libubox/jshn.sh + +case "$1" in +list) + json_init + json_add_object "getolsrvizdata" + json_close_object + json_dump + ;; +call) + case "$2" in + getolsrvizdata) + + jsonreq4=$( + cat <<EOF +<script language='JavaScript1.2' type='text/javascript'> +EOF + + # sed + txtinfo plugin + re_ip='[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}' + re_sep='[[:space:]]\{1,\}' + re_nosep='[^[:space:]]\{1,\}' + wget http://127.0.0.1:2006/all -qO - | sed -n " +/^Table: Links$/,/^$/ { +s# # - #g +s#\($re_ip\)$re_sep\($re_ip\)\($re_sep$re_nosep\)\{3\}$re_sep\($re_nosep\)#touch_edge(touch_node('\1').set_metric(1).update(),touch_node('\2').set_metric(1).update(),'\4');#p +} +/^Table: Topology$/,/^$/ { +s#\($re_ip\)$re_sep\($re_ip\)\($re_sep$re_nosep\)\{2\}$re_sep\($re_nosep\)#touch_edge(touch_node('\1').update(),touch_node('\2').update(),'\4');#p +} +/^Table: HNA$/,/^$/ { +s#\($re_ip\)/\([0-9]\{1,\}\)$re_sep\($re_ip\)#touch_hna(touch_node('\3'),'\1','\2');#p +} +/^Table: Routes$/,/^$/ { +s#\($re_ip\)/32$re_sep$re_nosep$re_sep\($re_nosep\).*#touch_node('\1').set_metric('\2').update();#p +} +" + + hosts=$(uci show olsrd | grep hosts_file | cut -d "=" -f 2) + if [ -n $hosts ]; then + sed -n " +s#\($re_ip\)$re_sep\($re_nosep\)$re_sep.*#touch_node('\1').set_desc('\2');#p +" <$hosts + fi + + cat <<EOF + viz_callback(); +</script> +EOF + ) + + json_init + json_add_string "jsonreq4" "$jsonreq4" + json_dump + ;; + esac + ;; +esac 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 02cfd6b646..ad6393b4ac 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,10 +1,12 @@ { - "admin/status/olsr/olsr-viz": { - "title": "OLSR-Viz", - "order": 90, + + "olsr/olsr-viz": { + "title": "OLSR Visualization", + "order": 100, "action": { - "type": "template", - "path": "olsr-viz/olsr-viz" + "type": "view", + "path": "olsr-viz/olsr-viz-view" } } + } diff --git a/applications/luci-app-olsr-viz/root/usr/share/rpcd/acl.d/luci-app-olsr-viz-unauthenticated.json b/applications/luci-app-olsr-viz/root/usr/share/rpcd/acl.d/luci-app-olsr-viz-unauthenticated.json new file mode 100644 index 0000000000..7238fd9053 --- /dev/null +++ b/applications/luci-app-olsr-viz/root/usr/share/rpcd/acl.d/luci-app-olsr-viz-unauthenticated.json @@ -0,0 +1,12 @@ +{ + "unauthenticated": { + "description": "Grant read access for luci-app-olsr-viz", + "read": { + "ubus": { + "olsrvizinfo": [ + "getolsrvizdata" + ] + } + } + } +} |