From 00cfca13b5cd01ee86194e3f859b81e1db475b8a Mon Sep 17 00:00:00 2001 From: Ayushman Tripathi Date: Thu, 13 Jul 2023 11:49:43 +0530 Subject: luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js luci-app-olsr-viz: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js luci-app-olsr-viz: migrate to js fix tag Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js luci-app-olsr-viz: migrate to js fix var name Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js luci-app-olsr-viz: migrate to js use load for script & fix bugs Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js luci-app-olsr-viz: migrate to js fix script Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js luci-app-olsr-viz: migrate to js fix bugs Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js luci-app-olsr-viz: migrate to js fix view Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js fix script Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js fix view luci-app-olsr-viz: migrate to js luci-app-olsr-viz: migrate to js fix script Signed-off-by: Ayushman Tripathi luci-app-olsr-viz: migrate to js --- .../root/usr/libexec/rpcd/olsrvizinfo | 59 ++++++++++++++++++++++ .../usr/share/luci/menu.d/luci-app-olsr-viz.json | 12 +++-- .../acl.d/luci-app-olsr-viz-unauthenticated.json | 12 +++++ 3 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 applications/luci-app-olsr-viz/root/usr/libexec/rpcd/olsrvizinfo create mode 100644 applications/luci-app-olsr-viz/root/usr/share/rpcd/acl.d/luci-app-olsr-viz-unauthenticated.json (limited to 'applications/luci-app-olsr-viz/root') 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 + + # 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 + ) + + 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" + ] + } + } + } +} -- cgit v1.2.3