From: Russ Handorf Date: Tue, 28 Feb 2023 17:57:50 +0000 (-0500) Subject: dot graph map X-Git-Url: https://handorf.org/code/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=kismet-logviewer.git dot graph map --- diff --git a/logviewer/dbview/__pycache__/views.cpython-38.pyc b/logviewer/dbview/__pycache__/views.cpython-38.pyc index 7e183cb..714a6c4 100644 Binary files a/logviewer/dbview/__pycache__/views.cpython-38.pyc and b/logviewer/dbview/__pycache__/views.cpython-38.pyc differ diff --git a/logviewer/dbview/views.py b/logviewer/dbview/views.py index d91b507..161ef6a 100644 --- a/logviewer/dbview/views.py +++ b/logviewer/dbview/views.py @@ -309,6 +309,22 @@ def index(request): return HttpResponse(dev_string, content_type='text/json') elif request.path == "/eventbus/events.ws": return HttpResponse("[]", content_type='text/json') + elif request.path == "/phy/DOT/map_data.json": + node_list = "" + link_list = "" + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'IEEE802.11' and cast(device as text) like '%dot11.device.client_map%'")) + for device in dev_list: + (dev,) = device + dev_json = json.loads(dev) + newdev = {} + node_list = node_list + "{ \"id\": \""+dev_json["kismet.device.base.macaddr"]+"\", \"label\": \""+dev_json["kismet.device.base.macaddr"]+"\", \"level\": 1}," + for device in dev_json['dot11.device']['dot11.device.client_map']: + node_list = node_list + "{ \"id\": \""+device+"\", \"label\": \""+device+"\", \"level\": 2}," + link_list = link_list + "{ \"target\": \""+device+"\", \"source\": \""+dev_json["kismet.device.base.macaddr"]+"\" , \"strength\": 0.7 }," + node_list = node_list[:-1] + link_list = link_list[:-1] + thang="{ \"nodes\": [" +node_list+"], \"links\": [" +link_list+"] }" + return HttpResponse(thang, content_type='text/json') elif request.path == "/phy/RUSS/map_data.json": min_long = 361.0 max_long = 0.0 diff --git a/logviewer/dotmap/__init__.py b/logviewer/dotmap/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logviewer/dotmap/__pycache__/__init__.cpython-38.pyc b/logviewer/dotmap/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..605e22a Binary files /dev/null and b/logviewer/dotmap/__pycache__/__init__.cpython-38.pyc differ diff --git a/logviewer/dotmap/__pycache__/urls.cpython-38.pyc b/logviewer/dotmap/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..fbce56c Binary files /dev/null and b/logviewer/dotmap/__pycache__/urls.cpython-38.pyc differ diff --git a/logviewer/dotmap/__pycache__/views.cpython-38.pyc b/logviewer/dotmap/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000..87ecb61 Binary files /dev/null and b/logviewer/dotmap/__pycache__/views.cpython-38.pyc differ diff --git a/logviewer/dotmap/admin.py b/logviewer/dotmap/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/logviewer/dotmap/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/logviewer/dotmap/apps.py b/logviewer/dotmap/apps.py new file mode 100644 index 0000000..673bc46 --- /dev/null +++ b/logviewer/dotmap/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DotmapConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'dotmap' diff --git a/logviewer/dotmap/migrations/__init__.py b/logviewer/dotmap/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logviewer/dotmap/models.py b/logviewer/dotmap/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/logviewer/dotmap/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/logviewer/dotmap/tests.py b/logviewer/dotmap/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/logviewer/dotmap/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/logviewer/dotmap/urls.py b/logviewer/dotmap/urls.py new file mode 100644 index 0000000..4c9189f --- /dev/null +++ b/logviewer/dotmap/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] + diff --git a/logviewer/dotmap/views.py b/logviewer/dotmap/views.py new file mode 100644 index 0000000..33c4107 --- /dev/null +++ b/logviewer/dotmap/views.py @@ -0,0 +1,15 @@ +from django.shortcuts import render +from django.http import HttpResponse, HttpRequest +import os + +def index(request): + #print("===") + #print(request) + #print("====") + if request.method == 'POST': + for key, value in request.POST.items(): + print(key,value) + + load_file = open('static/'+request.path, mode='rb') + if request.path == "/dot_map_panel.html": + return HttpResponse(load_file, content_type='text/html') diff --git a/logviewer/logviewer/__pycache__/urls.cpython-38.pyc b/logviewer/logviewer/__pycache__/urls.cpython-38.pyc index 693196d..6300a7d 100644 Binary files a/logviewer/logviewer/__pycache__/urls.cpython-38.pyc and b/logviewer/logviewer/__pycache__/urls.cpython-38.pyc differ diff --git a/logviewer/logviewer/urls.py b/logviewer/logviewer/urls.py index aee7816..0317a34 100644 --- a/logviewer/logviewer/urls.py +++ b/logviewer/logviewer/urls.py @@ -37,6 +37,7 @@ urlpatterns = [ path('css/images/', include('kiscontent.urls')), path('adsb_map_panel.html', include('adsbmap.urls')), path('russ_map_panel.html', include('russmap.urls')), + path('dot_map_panel.html', include('dotmap.urls')), path('system/status.json', include('dbview.urls')), path('alerts/wrapped/last-time/0/alerts.json', include('dbview.urls')), path('messagebus/last-time/0/messages.json', include('dbview.urls')), @@ -56,6 +57,7 @@ urlpatterns = [ path('devices/views/phy-IEEE802.11/devices.json', include('dbview.urls')), path('phy/ADSB/map_data.json', include('dbview.urls')), path('phy/RUSS/map_data.json', include('dbview.urls')), + path('phy/DOT/map_data.json', include('dbview.urls')), path('devices/by-key//device.json', include('devices.urls')), path('devices/multikey/as-object/devices.json', include('dbview.urls')), path('datasource/by-uuid//source.json', include('devices.urls')), diff --git a/logviewer/static/dot_map_panel.html b/logviewer/static/dot_map_panel.html new file mode 100644 index 0000000..bd8eb9f --- /dev/null +++ b/logviewer/static/dot_map_panel.html @@ -0,0 +1,270 @@ + + + + dot map + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Warning! +

To display the Russ map, your browser will connect to the Leaflet and Open Street Map servers to fetch the map tiles. This requires you have a functional Internet connection, and will reveal something about your location (the bounding region where planes have been seen.) +

Don't warn me again +

+

+
+ + + + diff --git a/logviewer/static/dynamic.js b/logviewer/static/dynamic.js index 8c386ea..1edfd01 100644 --- a/logviewer/static/dynamic.js +++ b/logviewer/static/dynamic.js @@ -11,6 +11,7 @@ var kismet_ui_rtl433; var kismet_ui_uav; var kismet_ui_zwave; var kismet_ui_russmap; +var kismet_ui_dotmap; async function load_dynamics() { kismet_ui_adsb = await import(`${local_uri_prefix}js/kismet.ui.adsb.js`); kismet_ui_bluetooth = await import(`${local_uri_prefix}js/kismet.ui.bluetooth.js`); @@ -22,4 +23,5 @@ kismet_ui_rtl433 = await import(`${local_uri_prefix}js/kismet.ui.rtl433.js`); kismet_ui_uav = await import(`${local_uri_prefix}js/kismet.ui.uav.js`); kismet_ui_zwave = await import(`${local_uri_prefix}js/kismet.ui.zwave.js`); kismet_ui_russmap = await import(`${local_uri_prefix}js/kismet.ui.russmap.js`); +kismet_ui_dotmap = await import(`${local_uri_prefix}js/kismet.ui.dotmap.js`); } diff --git a/logviewer/static/js/kismet.ui.dotmap.js b/logviewer/static/js/kismet.ui.dotmap.js new file mode 100644 index 0000000..82ec5f8 --- /dev/null +++ b/logviewer/static/js/kismet.ui.dotmap.js @@ -0,0 +1,30 @@ + +"use strict"; + +var local_uri_prefix = ""; +if (typeof(KISMET_URI_PREFIX) !== 'undefined') + local_uri_prefix = KISMET_URI_PREFIX; + +kismet_ui_tabpane.AddTab({ + id: 'dotmap', + tabTitle: 'Relationship Map', + expandable: false, + createCallback: function(div) { + var url = new URL(parent.document.URL); + url.searchParams.append('parent_url', url.origin) + url.searchParams.append('local_uri_prefix', local_uri_prefix); + url.searchParams.append('KISMET_PROXY_PREFIX', KISMET_PROXY_PREFIX); + url.pathname = `${local_uri_prefix}${KISMET_PROXY_PREFIX}dot_map_panel.html`; + + div.append( + $('