Skip to content

Commit 1e013b3

Browse files
committed
[chores] Misc improvements to geo & indoor map features
- Refined gifs in docs - Improved documentation structure - Fixed indoor-coordinates API path and reduced sleep in tests. - Increased test coverage for map page admin - Removed calls to sleep() in browser tests Co-authored-by: Federico Capoano <f.capoano@openwisp.io>
1 parent 2a29ac7 commit 1e013b3

File tree

19 files changed

+364
-236
lines changed

19 files changed

+364
-236
lines changed

docs/user/geo-indoor-maps.rst

Lines changed: 68 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,92 @@
1-
Geographic and Indoor Maps
2-
==========================
1+
Geographic & Indoor Maps
2+
========================
33

44
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/intro.gif
5+
:target: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/intro.gif
56
:alt: Intro
67

78
OpenWISP provides a unified web interface to monitor network status across
89
all scales: start with a global geographic overview, drill down into
910
specific buildings via indoor maps, and switch between floors to track
1011
devices in real time.
1112

12-
- **Indoor Map View with Floor Navigation:** The dashboard map includes an
13-
indoor view with floor switching and fullscreen mode.
13+
.. contents:: **Table of contents**:
14+
:depth: 1
15+
:local:
1416

15-
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/indoor-map-view.gif
16-
:alt: Indoor map view
17+
Indoor Map View with Floor Navigation
18+
-------------------------------------
1719

18-
- **Location View on Dedicated Map Page from Device Details Page:** The
19-
device detail page provides navigation to a full-page geographic map for
20-
the associated location.
20+
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/indoor-map-view.gif
21+
:target: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/indoor-map-view.gif
22+
:alt: Indoor map view
2123

22-
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/view-on-general-map-button.gif
23-
:alt: Location View from Device Details Page
24+
The dashboard map includes an indoor view with floor switching and
25+
full-screen mode.
2426

25-
- **Indoor Device View on Dedicated Map Page from Device Details Page:**
26-
The device detail page provides navigation to a full-page indoor map
27-
showing the device position.
27+
Shareable Geographic Map URLs
28+
-----------------------------
2829

29-
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/view-on-indoor-map-button.gif
30-
:alt: Indoor Device View from Device Details Page
30+
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/bookmark-url-map.gif
31+
:target: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/bookmark-url-map.gif
32+
:alt: Shareable Geographic Map URLs
3133

32-
- **Shareable Geographic Map URLs:** Interactions with location or device
33-
nodes on the geographic map update the URL.
34+
Interactions with location or device nodes on the geographic map update
35+
the URL, which can be bookmarked or shared.
3436

35-
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/bookmark-url-map.gif
36-
:alt: Shareable Geographic Map URLs
37+
Shareable Indoor Map URLs
38+
-------------------------
3739

38-
- **Shareable Indoor Map URLs:** Interactions with indoor device nodes
39-
update the URL.
40+
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/bookmark-url-indoor-map.gif
41+
:target: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/bookmark-url-indoor-map.gif
42+
:alt: Shareable Indoor Map URLs
4043

41-
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/bookmark-url-indoor-map.gif
42-
:alt: Shareable Indoor Map URLs
44+
Interactions with indoor device nodes update the URL, which can be
45+
bookmarked or shared.
4346

44-
- **Real-Time Device Position Updates:** Device positions on the map are
45-
updated when new location data is received.
47+
Jump from Device Detail to General Map
48+
--------------------------------------
4649

47-
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/moving-devices.gif
48-
:alt: Real-Time Device Position Updates
50+
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/view-on-general-map-button.gif
51+
:target: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/view-on-general-map-button.gif
52+
:alt: Location View from Device Details Page
4953

50-
- **WebSocket-Based Real-Time Location Updates:** Real-time map updates
51-
are delivered using WebSocket connections, allowing the frontend to
52-
receive live location data without polling. The common location
53-
broadcast channel is available at ``/ws/loci/location/`` and is used to
54-
push device location updates to geographic map views as soon as new data
55-
is received.
54+
Easily jump from the device detail page to the full geographic map, where
55+
the current device is already in focus and nearby devices are visible.
5656

57-
The location broadcast channel requires authentication. Access is
58-
controlled based on organization membership:
57+
Jump from Device Detail to Full Indoor View
58+
-------------------------------------------
5959

60-
- **Superusers:** Can receive location updates for all organizations.
61-
- **Regular Users:** Can only receive location updates for organizations
62-
they manage.
60+
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/view-on-indoor-map-button.gif
61+
:target: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/view-on-indoor-map-button.gif
62+
:alt: Indoor Device View from Device Details Page
6363

64-
This ensures that location data is properly scoped and users can only
65-
receive real-time updates for locations within their managed
66-
organizations.
64+
Easily jump from the device detail page to the full indoor map, where the
65+
current device is already in focus and nearby devices are visible.
66+
67+
Real-Time Device Position Updates
68+
---------------------------------
69+
70+
.. image:: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/moving-devices.gif
71+
:target: https://raw.githubusercontent.com/openwisp/openwisp-monitoring/docs/docs/1.3/moving-devices.gif
72+
:alt: Real-Time Device Position Updates
73+
74+
Device positions on the map are updated when new location data is
75+
received.
76+
77+
Real-time map updates are delivered using WebSocket connections, allowing
78+
the frontend to receive live location data without polling. The common
79+
location broadcast channel is available at ``/ws/loci/location/`` and is
80+
used to push device location updates to geographic map views as soon as
81+
new data is received.
82+
83+
The location broadcast channel requires authentication. Access is
84+
controlled based on organization membership:
85+
86+
- **Superusers:** Can receive location updates for all organizations.
87+
- **Regular Users:** Can only receive location updates for organizations
88+
they manage.
89+
90+
This ensures that location data is properly scoped and users can only
91+
receive real-time updates for locations within their managed
92+
organizations.

docs/user/rest-api.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,22 +255,22 @@ Here's a few examples:
255255
List Device Indoor Coordinates in a Location
256256
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257257

258-
Returns a list of indoor coordinates of network devices deployed in the
259-
specified location, along with device details and available floors.
260-
261258
.. code-block:: text
262259
263260
GET /api/v1/monitoring/location/{pk}/indoor-coordinates/
264261
262+
Returns a list of indoor coordinates of network devices deployed in the
263+
specified location, along with device details and available floors.
264+
265265
**Available filters**
266266

267-
- ``floor`` (floor number of the floorplan)
267+
- ``floor`` (floor number of the floor plan)
268268

269269
Here's a few examples:
270270

271271
.. code-block:: text
272272
273-
GET /api/v1/monitoring/location/5/indoor-coordinates/?floor=2
273+
GET /api/v1/monitoring/location/{pk}/indoor-coordinates/?floor=2
274274
275275
List WiFi Session
276276
~~~~~~~~~~~~~~~~~

openwisp_monitoring/device/admin.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import uuid
32
from urllib.parse import urljoin
43

@@ -9,7 +8,7 @@
98
from django.contrib.contenttypes.models import ContentType
109
from django.forms import ModelForm
1110
from django.templatetags.static import static
12-
from django.urls import resolve, reverse, reverse_lazy
11+
from django.urls import resolve, reverse
1312
from django.utils import timezone
1413
from django.utils.formats import localize
1514
from django.utils.html import format_html
@@ -598,6 +597,7 @@ class Media:
598597
"leaflet/leaflet.css",
599598
"monitoring/css/leaflet.fullscreen.css",
600599
"monitoring/css/netjsongraph.css",
600+
"monitoring/css/monitoring.css",
601601
]
602602
}
603603

@@ -606,32 +606,10 @@ def has_module_permission(self, request):
606606
return False
607607

608608
def changelist_view(self, request, extra_context=None):
609-
loc_geojson_url = reverse_lazy(
610-
"monitoring:api_location_geojson", urlconf=MONITORING_API_URLCONF
611-
)
612-
device_list_url = reverse_lazy(
613-
"monitoring:api_location_device_list",
614-
urlconf=MONITORING_API_URLCONF,
615-
args=["000"],
616-
)
617-
indoor_coordinates_list_url = reverse_lazy(
618-
"monitoring:api_indoor_coordinates_list",
619-
urlconf=MONITORING_API_URLCONF,
620-
args=["000"],
621-
)
622-
if MONITORING_API_BASEURL:
623-
loc_geojson_url = urljoin(MONITORING_API_BASEURL, str(loc_geojson_url))
624-
device_list_url = urljoin(MONITORING_API_BASEURL, str(device_list_url))
625-
indoor_coordinates_list_url = urljoin(
626-
MONITORING_API_BASEURL, str(indoor_coordinates_list_url)
627-
)
628609
extra_context = extra_context or {}
629610
extra_context.update(
630611
{
631-
"monitoring_device_list_url": device_list_url,
632-
"monitoring_location_geojson_url": loc_geojson_url,
633-
"monitoring_indoor_coordinates_list": indoor_coordinates_list_url,
634-
"monitoring_labels": json.dumps(app_settings.HEALTH_STATUS_LABELS),
612+
"monitoring_labels": app_settings.HEALTH_STATUS_LABELS,
635613
# By default shows 'Select Map to change' heading making it empty to hide it
636614
"title": "",
637615
}

openwisp_monitoring/device/api/serializers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
Device = load_model("config", "Device")
1313
DeviceMonitoring = load_model("device_monitoring", "DeviceMonitoring")
1414
DeviceData = load_model("device_monitoring", "DeviceData")
15-
Device = load_model("config", "Device")
16-
DeviceLocation = load_model("geo", "DeviceLocation")
1715
WifiSession = load_model("device_monitoring", "WifiSession")
1816
WifiClient = load_model("device_monitoring", "WifiClient")
1917

openwisp_monitoring/device/api/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
views.wifi_session_detail,
4141
name="api_wifi_session_detail",
4242
),
43-
path(
44-
"api/v1/monitoring/location/<str:pk>/indoor-coordinates/",
43+
re_path(
44+
r"^api/v1/monitoring/location/(?P<pk>[^/]+)/indoor-coordinates/$",
4545
views.monitoring_indoor_coordinates_list,
4646
name="api_indoor_coordinates_list",
4747
),

openwisp_monitoring/device/apps.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
from urllib.parse import urljoin
32

43
from django.apps import AppConfig
@@ -368,30 +367,10 @@ def register_dashboard_items(self):
368367
)
369368

370369
if app_settings.DASHBOARD_MAP:
371-
loc_geojson_url = reverse_lazy(
372-
"monitoring:api_location_geojson", urlconf=MONITORING_API_URLCONF
373-
)
374-
device_list_url = reverse_lazy(
375-
"monitoring:api_location_device_list",
376-
urlconf=MONITORING_API_URLCONF,
377-
args=["000"],
378-
)
379-
indoor_coordinates_list_url = reverse_lazy(
380-
"monitoring:api_indoor_coordinates_list",
381-
urlconf=MONITORING_API_URLCONF,
382-
args=["000"],
383-
)
384-
if MONITORING_API_BASEURL:
385-
device_list_url = urljoin(MONITORING_API_BASEURL, str(device_list_url))
386-
loc_geojson_url = urljoin(MONITORING_API_BASEURL, str(loc_geojson_url))
387-
indoor_coordinates_list_url = urljoin(
388-
MONITORING_API_BASEURL, str(indoor_coordinates_list_url)
389-
)
390-
391370
register_dashboard_template(
392371
position=0,
393372
config={
394-
"template": "admin/dashboard/device_map.html",
373+
"template": "admin/map/base_map.html",
395374
"css": (
396375
"monitoring/css/device-map.css",
397376
"leaflet/leaflet.css",
@@ -406,10 +385,7 @@ def register_dashboard_items(self):
406385
),
407386
},
408387
extra_config={
409-
"monitoring_device_list_url": device_list_url,
410-
"monitoring_location_geojson_url": loc_geojson_url,
411-
"monitoring_indoor_coordinates_list": indoor_coordinates_list_url,
412-
"monitoring_labels": json.dumps(app_settings.HEALTH_STATUS_LABELS),
388+
"monitoring_labels": app_settings.HEALTH_STATUS_LABELS,
413389
},
414390
)
415391

openwisp_monitoring/device/static/monitoring/css/device-map.css

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
right: 20px !important;
7676
font-size: 18px !important;
7777
}
78-
.leaflet-popup-close-button:hover,
7978
.leaflet-popup-close-button:active,
8079
.leaflet-popup-close-button:hover {
8180
color: black !important;
@@ -234,7 +233,6 @@
234233
}
235234
#floorplan-container {
236235
position: relative;
237-
background: white;
238236
z-index: 99999;
239237
padding: 16px;
240238
border-radius: 12px;
@@ -316,7 +314,6 @@
316314
width: 45px;
317315
height: 45px;
318316
background-color: white;
319-
border: 1px solid black;
320317
border: none;
321318
font-weight: bold;
322319
cursor: pointer;
@@ -411,10 +408,3 @@
411408
min-width: auto;
412409
}
413410
}
414-
415-
/* Map Page */
416-
.dedicated-map-page {
417-
width: 100%;
418-
height: 87.7vh !important;
419-
margin: 15px auto 0 auto !important;
420-
}
-5.4 KB
Binary file not shown.

openwisp_monitoring/device/static/monitoring/css/monitoring.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,10 @@ fieldset.module .view-on-map-btn {
139139
color: white;
140140
text-decoration: none !important;
141141
}
142+
143+
/* Map Page */
144+
.dedicated-map-page {
145+
width: 100%;
146+
height: calc(100vh - 126px) !important;
147+
margin: 15px auto 0 auto !important;
148+
}

0 commit comments

Comments
 (0)