Compare commits
40
Commits
v4.0.0-beta.2
...
feature
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5981a21830 | ||
|
|
8100b8146f | ||
|
|
6c047b1022 | ||
|
|
4afa4f721f | ||
|
|
e7df2f6772 | ||
|
|
b85e548049 | ||
|
|
097fe5c685 | ||
|
|
c83479fb1d | ||
|
|
79a234fcc9 | ||
|
|
db76752a82 | ||
|
|
47f263f5c2 | ||
|
|
6eb20004f9 | ||
|
|
836d9f40d7 | ||
|
|
607347ff18 | ||
|
|
0f6051731a | ||
|
|
3c9aebfd2f | ||
|
|
60a5fe1eae | ||
|
|
3fbeb97810 | ||
|
|
f3b822e18d | ||
|
|
555c1fac4c | ||
|
|
cf8641939a | ||
|
|
2893fff111 | ||
|
|
25fdcb6cf4 | ||
|
|
5d330bc830 | ||
|
|
03b8c9c76e | ||
|
|
02a7118a33 | ||
|
|
44e49495fe | ||
|
|
f4b1e34826 | ||
|
|
f8c6e9e193 | ||
|
|
19adcab4a9 | ||
|
|
d2d2106246 | ||
|
|
9072faf7cf | ||
|
|
6f43b959bd | ||
|
|
1048feff52 | ||
|
|
7ff0a9650f | ||
|
|
8d5de5c49f | ||
|
|
96afdf8d83 | ||
|
|
aba0598947 | ||
|
|
142de460b9 | ||
|
|
2600209724 |
No files matched your search
@@ -0,0 +1,15 @@
|
|||||||
|
name: NetBox plugin manifest modified
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ develop ]
|
||||||
|
paths:
|
||||||
|
- netbox-plugin.yaml
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
manifest-modified:
|
||||||
|
uses: netboxlabs/public-workflows/.github/workflows/reusable-plugin-manifest-modified.yml@release
|
||||||
@@ -14,31 +14,15 @@ Options to export to xml (for draw.io/diagrams.net) or png.
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
**_NOTE:_** For docker please see: [Docker install](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins)
|
**_NOTE:_** For Docker please see: [Docker install](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins)
|
||||||
|
|
||||||
**_NOTE:_** Add `RUN mkdir -p /opt/netbox/netbox/static/netbox_topology_views/img` to the Dockerfile-Plugins file to create the image folder
|
**_NOTE:_** Add `RUN mkdir -p /opt/netbox/netbox/static/netbox_topology_views/img` to the Dockerfile-Plugins file to create the image folder.
|
||||||
|
|
||||||
The plugin is available as a Python package and can be installed with pip.
|
The plugin is available as a Python package and can be installed with pip.
|
||||||
|
|
||||||
Run `pip install netbox-topology-views` in your virtual env.
|
|
||||||
|
|
||||||
To ensure NetBox Topology Views plugin is automatically re-installed during future upgrades, create a file named `local_requirements.txt` (if not already existing) in the NetBox root directory (alongside `requirements.txt`) and list the `netbox-topology-views` package:
|
|
||||||
|
|
||||||
```no-highlight
|
|
||||||
# echo netbox-topology-views >> local_requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
Once installed, the plugin needs to be enabled in your `configuration.py`
|
|
||||||
|
|
||||||
```python
|
|
||||||
# In your configuration.py
|
|
||||||
PLUGINS = ["netbox_topology_views"]
|
|
||||||
```
|
|
||||||
|
|
||||||
First run `source /opt/netbox/venv/bin/activate` to enter the Python virtual environment.
|
First run `source /opt/netbox/venv/bin/activate` to enter the Python virtual environment.
|
||||||
|
|
||||||
|
Then run:
|
||||||
Then run
|
|
||||||
```bash
|
```bash
|
||||||
cd /opt/netbox/netbox
|
cd /opt/netbox/netbox
|
||||||
pip3 install netbox-topology-views
|
pip3 install netbox-topology-views
|
||||||
@@ -46,21 +30,44 @@ python3 manage.py migrate netbox_topology_views
|
|||||||
python3 manage.py collectstatic --no-input
|
python3 manage.py collectstatic --no-input
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To ensure NetBox Topology Views plugin is automatically re-installed during future upgrades, create a file named `local_requirements.txt` (if not already existing) in the NetBox root directory (alongside `requirements.txt`) and list the `netbox-topology-views` package:
|
||||||
|
|
||||||
|
```no-highlight
|
||||||
|
echo netbox-topology-views >> /opt/netbox/local_requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Once installed, the plugin needs to be enabled in your `configuration.py`:
|
||||||
|
```no-highlight
|
||||||
|
vim /opt/netbox/netbox/netbox/configuration.py
|
||||||
|
```
|
||||||
|
|
||||||
|
```python
|
||||||
|
PLUGINS = ["netbox_topology_views"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, restart NetBox:
|
||||||
|
```no-highlight
|
||||||
|
systemctl restart netbox
|
||||||
|
```
|
||||||
|
|
||||||
### Versions
|
### Versions
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> If the version of netbox is not listed here the plugin will most likely not work. Remove the plugin if you want to update netbox before this plugin has released an update for that netbox version.
|
||||||
|
|
||||||
| netbox version | netbox-topology-views version |
|
| netbox version | netbox-topology-views version |
|
||||||
| -------------- | ----------------------------- |
|
| -------------- | ----------------------------- |
|
||||||
| >= 3.7.0 | >= v3.9.0 |
|
| = 4.4.X | = v4.4.0 |
|
||||||
| >= 3.6.4 | >= v3.8.1 |
|
| = 4.3.X | = v4.3.0 |
|
||||||
| >= 3.6.0 | >= v3.7.X |
|
| = 4.2.1 | = v4.2.1 |
|
||||||
| >= 3.5.0 | >= v3.4.X |
|
| = 4.2.0 | = v4.2.0 |
|
||||||
| >= 3.4.0 | >= v3.X.X |
|
| = 4.1.X | = v4.1.0 |
|
||||||
| >= 3.3.0 | >= v3.0.0 |
|
| = 4.0.X | = v4.0.0 |
|
||||||
| >= 3.2.0 | >= v1.1.0 |
|
| = 3.7.0 | = v3.9.0 |
|
||||||
| >= 3.1.8 | >= v1.0.0 |
|
| = 3.6.4 | = v3.8.1 |
|
||||||
| >= 2.11.1 | >= v0.5.3 |
|
| = 3.6.0 | = v3.7.0 |
|
||||||
| >= 2.10.0 | >= v0.5.0 |
|
| = 3.5.0 | = v3.6.2 |
|
||||||
| < 2.10.0 | =< v0.4.10 |
|
|
||||||
|
|
||||||
### Update
|
### Update
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
version: '3.4'
|
version: '3.4'
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:12-alpine
|
image: postgres:16-alpine
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: J5brHrAXFLQSif0K #just for local dev
|
POSTGRES_PASSWORD: J5brHrAXFLQSif0K #just for local dev
|
||||||
POSTGRES_DB: netbox
|
POSTGRES_DB: netbox
|
||||||
@@ -9,7 +9,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- netbox-postgres-data:/var/lib/postgresql/data
|
- netbox-postgres-data-16:/var/lib/postgresql/data
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:6-alpine
|
image: redis:6-alpine
|
||||||
@@ -35,7 +35,7 @@ services:
|
|||||||
- "6378:6379"
|
- "6378:6379"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
netbox-postgres-data:
|
netbox-postgres-data-16:
|
||||||
driver: local
|
driver: local
|
||||||
netbox-redis-data:
|
netbox-redis-data:
|
||||||
driver: local
|
driver: local
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
version: 0.1
|
||||||
|
package_name: netbox-topology-views
|
||||||
|
compatibility:
|
||||||
|
- release: 4.4.0
|
||||||
|
netbox_min: 4.4.0
|
||||||
|
netbox_max: 4.4.3
|
||||||
|
- release: 4.3.0
|
||||||
|
netbox_min: 4.3.0
|
||||||
|
netbox_max: 4.3.7
|
||||||
|
- release: 4.2.0
|
||||||
|
netbox_min: 4.2.0
|
||||||
|
netbox_max: 4.2.1
|
||||||
|
- release: 4.1.0
|
||||||
|
netbox_min: 4.1.0
|
||||||
|
netbox_max: 4.1.11
|
||||||
|
- release: 4.0.1
|
||||||
|
netbox_min: 4.0.9
|
||||||
|
netbox_max: 4.0.11
|
||||||
|
- release: 4.0.0
|
||||||
|
netbox_min: 4.0.0
|
||||||
|
netbox_max: 4.0.9
|
||||||
|
- release: 3.9.1
|
||||||
|
netbox_min: 3.7.1
|
||||||
|
netbox_max: 3.7.8
|
||||||
|
- release: 3.9.0
|
||||||
|
netbox_min: 3.7.1
|
||||||
|
netbox_max: 3.7.8
|
||||||
|
- release: 3.8.1
|
||||||
|
netbox_min: 3.6.9
|
||||||
|
netbox_max: 3.6.9
|
||||||
|
- release: 3.6.2
|
||||||
|
netbox_min: 3.5.1
|
||||||
|
netbox_max: 3.5.9
|
||||||
@@ -5,7 +5,7 @@ class TopologyViewsConfig(PluginConfig):
|
|||||||
name = "netbox_topology_views"
|
name = "netbox_topology_views"
|
||||||
verbose_name = "Topology views"
|
verbose_name = "Topology views"
|
||||||
description = "An plugin to render topology maps"
|
description = "An plugin to render topology maps"
|
||||||
version = "4.0.0-beta.2"
|
version = "4.4.0"
|
||||||
author = "Mattijs Vanhaverbeke"
|
author = "Mattijs Vanhaverbeke"
|
||||||
author_email = "[email protected]"
|
author_email = "[email protected]"
|
||||||
base_url = "netbox_topology_views"
|
base_url = "netbox_topology_views"
|
||||||
|
|||||||
@@ -50,4 +50,4 @@ class PowerFeedCoordinateSerializer(NetBoxModelSerializer):
|
|||||||
class IndividualOptionsSerializer(NetBoxModelSerializer):
|
class IndividualOptionsSerializer(NetBoxModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IndividualOptions
|
model = IndividualOptions
|
||||||
fields = ("ignore_cable_type", "save_coords", "show_unconnected", "show_cables", "show_logical_connections", "show_single_cable_logical_conns", "show_neighbors", "show_circuit", "show_power", "show_wireless", "group_sites", "group_locations", "group_racks", "draw_default_layout")
|
fields = ("ignore_cable_type", "save_coords", "show_unconnected", "show_cables", "show_logical_connections", "show_single_cable_logical_conns", "show_neighbors", "show_circuit", "show_power", "show_wireless", "group_sites", "group_locations", "group_racks", "group_virtualchassis", "draw_default_layout", "straight_cables", "grid_size", "node_label_items")
|
||||||
@@ -7,5 +7,10 @@ router = NetBoxRouter()
|
|||||||
router.register("save-coords", views.SaveCoordsViewSet)
|
router.register("save-coords", views.SaveCoordsViewSet)
|
||||||
router.register("images", views.SaveRoleImageViewSet)
|
router.register("images", views.SaveRoleImageViewSet)
|
||||||
router.register("xml-export", views.ExportTopoToXML, "xml-export")
|
router.register("xml-export", views.ExportTopoToXML, "xml-export")
|
||||||
|
router.register("coordinate-groups", views.CoordinateGroupViewSet)
|
||||||
|
router.register("coordinate", views.CoordinateViewSet)
|
||||||
|
router.register("circuitcoordinate", views.CircuitCoordinateViewSet)
|
||||||
|
router.register("powerpanelcoordinate", views.PowerPanelCoordinateViewSet)
|
||||||
|
router.register("powerfeedcoordinate", views.PowerFeedCoordinateViewSet)
|
||||||
|
|
||||||
urlpatterns = router.urls
|
urlpatterns = router.urls
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from netbox.api.viewsets import BaseViewSet, NetBoxModelViewSet
|
||||||
|
|
||||||
from circuits.models import Circuit
|
from circuits.models import Circuit
|
||||||
from dcim.models import Device, DeviceRole, PowerFeed, PowerPanel
|
from dcim.models import Device, DeviceRole, PowerFeed, PowerPanel
|
||||||
from extras.models import SavedFilter
|
from extras.models import SavedFilter
|
||||||
@@ -15,6 +17,11 @@ from rest_framework.viewsets import ReadOnlyModelViewSet, ViewSet
|
|||||||
from netbox_topology_views.api.serializers import (
|
from netbox_topology_views.api.serializers import (
|
||||||
RoleImageSerializer,
|
RoleImageSerializer,
|
||||||
TopologyDummySerializer,
|
TopologyDummySerializer,
|
||||||
|
CoordinateGroupSerializer,
|
||||||
|
CoordinateSerializer,
|
||||||
|
CircuitCoordinateSerializer,
|
||||||
|
PowerPanelCoordinateSerializer,
|
||||||
|
PowerFeedCoordinateSerializer,
|
||||||
)
|
)
|
||||||
import netbox_topology_views.models
|
import netbox_topology_views.models
|
||||||
from netbox_topology_views.models import RoleImage, IndividualOptions, CoordinateGroup, Coordinate, CircuitCoordinate, PowerPanelCoordinate, PowerFeedCoordinate
|
from netbox_topology_views.models import RoleImage, IndividualOptions, CoordinateGroup, Coordinate, CircuitCoordinate, PowerPanelCoordinate, PowerFeedCoordinate
|
||||||
@@ -22,7 +29,7 @@ from netbox_topology_views.views import get_topology_data
|
|||||||
from netbox_topology_views.utils import get_image_from_url, export_data_to_xml, get_query_settings
|
from netbox_topology_views.utils import get_image_from_url, export_data_to_xml, get_query_settings
|
||||||
from netbox_topology_views.filters import DeviceFilterSet
|
from netbox_topology_views.filters import DeviceFilterSet
|
||||||
|
|
||||||
class SaveCoordsViewSet(PermissionRequiredMixin, ReadOnlyModelViewSet):
|
class SaveCoordsViewSet(BaseViewSet, ReadOnlyModelViewSet):
|
||||||
permission_required = 'netbox_topology_views.change_coordinate'
|
permission_required = 'netbox_topology_views.change_coordinate'
|
||||||
|
|
||||||
queryset = Device.objects.none()
|
queryset = Device.objects.none()
|
||||||
@@ -89,16 +96,14 @@ class SaveCoordsViewSet(PermissionRequiredMixin, ReadOnlyModelViewSet):
|
|||||||
|
|
||||||
return Response({"status": "saved coords"})
|
return Response({"status": "saved coords"})
|
||||||
|
|
||||||
class ExportTopoToXML(PermissionRequiredMixin, ViewSet):
|
class ExportTopoToXML(BaseViewSet, ViewSet):
|
||||||
permission_required = ("dcim.view_site", "dcim.view_device")
|
|
||||||
|
|
||||||
queryset = Device.objects.none()
|
queryset = Device.objects.none()
|
||||||
serializer_class = TopologyDummySerializer
|
serializer_class = TopologyDummySerializer
|
||||||
|
|
||||||
def list(self, request):
|
def list(self, request):
|
||||||
|
|
||||||
self.filterset = DeviceFilterSet
|
self.filterset = DeviceFilterSet
|
||||||
self.queryset = Device.objects.all().select_related(
|
self.queryset = Device.objects.restrict(request.user, 'view').select_related(
|
||||||
"device_type", "role"
|
"device_type", "role"
|
||||||
)
|
)
|
||||||
self.queryset = self.filterset(request.GET, self.queryset).qs
|
self.queryset = self.filterset(request.GET, self.queryset).qs
|
||||||
@@ -109,7 +114,7 @@ class ExportTopoToXML(PermissionRequiredMixin, ViewSet):
|
|||||||
|
|
||||||
if request.GET:
|
if request.GET:
|
||||||
|
|
||||||
filter_id, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks,show_neighbors = get_query_settings(request)
|
filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, grid_size, node_label_items = get_query_settings(request)
|
||||||
|
|
||||||
# Read options from saved filters as NetBox does not handle custom plugin filters
|
# Read options from saved filters as NetBox does not handle custom plugin filters
|
||||||
if "filter_id" in request.GET and request.GET["filter_id"] != '':
|
if "filter_id" in request.GET and request.GET["filter_id"] != '':
|
||||||
@@ -117,7 +122,9 @@ class ExportTopoToXML(PermissionRequiredMixin, ViewSet):
|
|||||||
saved_filter = SavedFilter.objects.get(pk=filter_id)
|
saved_filter = SavedFilter.objects.get(pk=filter_id)
|
||||||
saved_filter_params = getattr(saved_filter, 'parameters')
|
saved_filter_params = getattr(saved_filter, 'parameters')
|
||||||
|
|
||||||
|
if ignore_cable_type == () and 'ignore_cable_type' in saved_filter_params: ignore_cable_type = saved_filter_params['ignore_cable_type']
|
||||||
if save_coords == False and 'save_coords' in saved_filter_params: save_coords = saved_filter_params['save_coords']
|
if save_coords == False and 'save_coords' in saved_filter_params: save_coords = saved_filter_params['save_coords']
|
||||||
|
if show_unconnected == False and 'show_unconnected' in saved_filter_params: show_unconnected = saved_filter_params['show_unconnected']
|
||||||
if show_power == False and 'show_power' in saved_filter_params: show_power = saved_filter_params['show_power']
|
if show_power == False and 'show_power' in saved_filter_params: show_power = saved_filter_params['show_power']
|
||||||
if show_circuit == False and 'show_circuit' in saved_filter_params: show_circuit = saved_filter_params['show_circuit']
|
if show_circuit == False and 'show_circuit' in saved_filter_params: show_circuit = saved_filter_params['show_circuit']
|
||||||
if show_logical_connections == False and 'show_logical_connections' in saved_filter_params: show_logical_connections = saved_filter_params['show_logical_connections']
|
if show_logical_connections == False and 'show_logical_connections' in saved_filter_params: show_logical_connections = saved_filter_params['show_logical_connections']
|
||||||
@@ -127,19 +134,27 @@ class ExportTopoToXML(PermissionRequiredMixin, ViewSet):
|
|||||||
if group_sites == False and 'group_sites' in saved_filter_params: group_sites = saved_filter_params['group_sites']
|
if group_sites == False and 'group_sites' in saved_filter_params: group_sites = saved_filter_params['group_sites']
|
||||||
if group_locations == False and 'group_locations' in saved_filter_params: group_locations = saved_filter_params['group_locations']
|
if group_locations == False and 'group_locations' in saved_filter_params: group_locations = saved_filter_params['group_locations']
|
||||||
if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks']
|
if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks']
|
||||||
|
if group_virtualchassis == False and 'group_virtualchassis' in saved_filter_params: group_virtualchassis = saved_filter_params['group_virtualchassis']
|
||||||
if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors']
|
if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors']
|
||||||
|
if straight_cables == False and 'straight_cables' in saved_filter_params: show_neighbors = saved_filter_params['straight_cables']
|
||||||
|
if grid_size == 0 and 'grid_size' in saved_filter_params: grid_size = saved_filter_params['grid_size']
|
||||||
|
if node_label_items == () and 'node_label_items' in saved_filter_params: node_label_items = saved_filter_params['node_label_items']
|
||||||
except SavedFilter.DoesNotExist: # filter_id not found
|
except SavedFilter.DoesNotExist: # filter_id not found
|
||||||
pass
|
pass
|
||||||
except Exception as inst:
|
except Exception as inst:
|
||||||
print(type(inst))
|
print(type(inst))
|
||||||
|
|
||||||
if 'group' not in request.query_params:
|
if 'group' not in request.query_params:
|
||||||
group_id = "default"
|
if 'saved_filter_params' in locals() and "group" in saved_filter_params:
|
||||||
|
group_id = saved_filter_params['group'][0]
|
||||||
|
else:
|
||||||
|
group_id = "default"
|
||||||
else:
|
else:
|
||||||
group_id = request.query_params["group"]
|
group_id = request.query_params["group"]
|
||||||
topo_data = get_topology_data(
|
topo_data = get_topology_data(
|
||||||
queryset=self.queryset,
|
queryset=self.queryset,
|
||||||
individualOptions=individualOptions,
|
individualOptions=individualOptions,
|
||||||
|
ignore_cable_type=ignore_cable_type,
|
||||||
save_coords=save_coords,
|
save_coords=save_coords,
|
||||||
show_unconnected=show_unconnected,
|
show_unconnected=show_unconnected,
|
||||||
show_cables=show_cables,
|
show_cables=show_cables,
|
||||||
@@ -152,9 +167,13 @@ class ExportTopoToXML(PermissionRequiredMixin, ViewSet):
|
|||||||
group_sites=group_sites,
|
group_sites=group_sites,
|
||||||
group_locations=group_locations,
|
group_locations=group_locations,
|
||||||
group_racks=group_racks,
|
group_racks=group_racks,
|
||||||
|
group_virtualchassis=group_virtualchassis,
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
|
straight_cables=straight_cables,
|
||||||
|
grid_size=grid_size,
|
||||||
|
node_label_items=node_label_items,
|
||||||
)
|
)
|
||||||
xml_data = export_data_to_xml(topo_data).decode('utf-8')
|
xml_data = export_data_to_xml(topo_data).decode('utf-8').replace('\n', '
')
|
||||||
|
|
||||||
return HttpResponse(xml_data, content_type="application/xml; charset=utf-8")
|
return HttpResponse(xml_data, content_type="application/xml; charset=utf-8")
|
||||||
else:
|
else:
|
||||||
@@ -162,7 +181,7 @@ class ExportTopoToXML(PermissionRequiredMixin, ViewSet):
|
|||||||
{"status": "Missing or malformed request parameters"}, status=400
|
{"status": "Missing or malformed request parameters"}, status=400
|
||||||
)
|
)
|
||||||
|
|
||||||
class SaveRoleImageViewSet(PermissionRequiredMixin, ReadOnlyModelViewSet):
|
class SaveRoleImageViewSet(BaseViewSet, ReadOnlyModelViewSet):
|
||||||
queryset = DeviceRole.objects.none()
|
queryset = DeviceRole.objects.none()
|
||||||
serializer_class = RoleImageSerializer
|
serializer_class = RoleImageSerializer
|
||||||
permission_required = (
|
permission_required = (
|
||||||
@@ -240,3 +259,23 @@ class SaveRoleImageViewSet(PermissionRequiredMixin, ReadOnlyModelViewSet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return JsonResponse({"status": "Ok"})
|
return JsonResponse({"status": "Ok"})
|
||||||
|
|
||||||
|
class CoordinateGroupViewSet(NetBoxModelViewSet):
|
||||||
|
queryset = CoordinateGroup.objects.all()
|
||||||
|
serializer_class = CoordinateGroupSerializer
|
||||||
|
|
||||||
|
class CoordinateViewSet(NetBoxModelViewSet):
|
||||||
|
queryset = Coordinate.objects.all()
|
||||||
|
serializer_class = CoordinateSerializer
|
||||||
|
|
||||||
|
class CircuitCoordinateViewSet(NetBoxModelViewSet):
|
||||||
|
queryset = CircuitCoordinate.objects.all()
|
||||||
|
serializer_class = CircuitCoordinateSerializer
|
||||||
|
|
||||||
|
class PowerPanelCoordinateViewSet(NetBoxModelViewSet):
|
||||||
|
queryset = PowerPanelCoordinate.objects.all()
|
||||||
|
serializer_class = PowerPanelCoordinateSerializer
|
||||||
|
|
||||||
|
class PowerFeedCoordinateViewSet(NetBoxModelViewSet):
|
||||||
|
queryset = PowerFeedCoordinate.objects.all()
|
||||||
|
serializer_class = PowerFeedCoordinateSerializer
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
from utilities.choices import ChoiceSet
|
||||||
|
|
||||||
|
class NodeLabelItems(ChoiceSet):
|
||||||
|
DEVICE_NAME = 'devicename'
|
||||||
|
DEVICE_TYPE = 'devicetype'
|
||||||
|
ROLE = 'role'
|
||||||
|
DESCRIPTION = 'description'
|
||||||
|
PRIMARY_IPV4 = 'primaryipv4'
|
||||||
|
PRIMARY_IPV6 = 'primaryipv6'
|
||||||
|
OUT_OF_BAND_IP = 'outofbandip'
|
||||||
|
PLATFORM = 'platform'
|
||||||
|
SERIAL = 'serial'
|
||||||
|
TENANT = 'tenant'
|
||||||
|
SITE = 'site'
|
||||||
|
LOCATION = 'location'
|
||||||
|
RACK = 'rack'
|
||||||
|
VIRTUAL_CHASSIS = 'virtualchassis'
|
||||||
|
|
||||||
|
CHOICES = [
|
||||||
|
(DEVICE_NAME, 'Device Name'),
|
||||||
|
(DEVICE_TYPE, 'Device Type'),
|
||||||
|
(ROLE, 'Role'),
|
||||||
|
(DESCRIPTION, 'Description'),
|
||||||
|
(PRIMARY_IPV4, 'Primary IPv4'),
|
||||||
|
(PRIMARY_IPV6, 'Primary IPv6'),
|
||||||
|
(OUT_OF_BAND_IP, 'Out-of-band IP'),
|
||||||
|
(PLATFORM, 'Platform'),
|
||||||
|
(SERIAL, 'Serial'),
|
||||||
|
(TENANT, 'Tenant'),
|
||||||
|
(SITE, 'Site'),
|
||||||
|
(LOCATION, 'Location'),
|
||||||
|
(RACK, 'Rack'),
|
||||||
|
(VIRTUAL_CHASSIS, 'Virtual Chassis'),
|
||||||
|
]
|
||||||
@@ -71,7 +71,7 @@ class DeviceFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilter
|
|||||||
null_value=None,
|
null_value=None,
|
||||||
)
|
)
|
||||||
mac_address = MultiValueMACAddressFilter(
|
mac_address = MultiValueMACAddressFilter(
|
||||||
field_name='interfaces__mac_address',
|
field_name='interfaces__mac_addresses__mac_address',
|
||||||
label="MAC address",
|
label="MAC address",
|
||||||
)
|
)
|
||||||
serial = MultiValueCharFilter(
|
serial = MultiValueCharFilter(
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from utilities.forms.fields import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from netbox_topology_views.models import IndividualOptions, CoordinateGroup, Coordinate, CircuitCoordinate, PowerPanelCoordinate, PowerFeedCoordinate
|
from netbox_topology_views.models import IndividualOptions, CoordinateGroup, Coordinate, CircuitCoordinate, PowerPanelCoordinate, PowerFeedCoordinate
|
||||||
|
from netbox_topology_views.choices import NodeLabelItems
|
||||||
|
|
||||||
class DeviceFilterForm(
|
class DeviceFilterForm(
|
||||||
LocalConfigContextFilterForm,
|
LocalConfigContextFilterForm,
|
||||||
@@ -34,9 +35,9 @@ class DeviceFilterForm(
|
|||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag'),
|
FieldSet('q', 'filter_id', 'tag'),
|
||||||
FieldSet(
|
FieldSet(
|
||||||
'group', 'save_coords', 'show_unconnected', 'show_cables', 'show_logical_connections',
|
'group', 'ignore_cable_type', 'save_coords', 'show_unconnected', 'show_cables', 'show_logical_connections',
|
||||||
'show_single_cable_logical_conns', 'show_neighbors', 'show_circuit', 'show_power', 'show_wireless',
|
'show_single_cable_logical_conns', 'show_neighbors', 'show_circuit', 'show_power', 'show_wireless',
|
||||||
'group_sites', 'group_locations', 'group_racks', name=_("Options")
|
'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis', 'straight_cables', 'grid_size', 'node_label_items', name=_("Options")
|
||||||
),
|
),
|
||||||
FieldSet('id', name=_("Device")),
|
FieldSet('id', name=_("Device")),
|
||||||
FieldSet('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', name=_("Location")),
|
FieldSet('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', name=_("Location")),
|
||||||
@@ -229,6 +230,11 @@ class DeviceFilterForm(
|
|||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
# options
|
# options
|
||||||
|
ignore_cable_type = forms.MultipleChoiceField(
|
||||||
|
label=_('Ignore Termination Types'),
|
||||||
|
required=False,
|
||||||
|
choices=IndividualOptions.CHOICES
|
||||||
|
)
|
||||||
save_coords = forms.NullBooleanField(
|
save_coords = forms.NullBooleanField(
|
||||||
label=_('Save Coordinates'),
|
label=_('Save Coordinates'),
|
||||||
required=False,
|
required=False,
|
||||||
@@ -310,6 +316,31 @@ class DeviceFilterForm(
|
|||||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
group_virtualchassis = forms.NullBooleanField(
|
||||||
|
label =_('Group Virtual Chassis'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
straight_cables = forms.BooleanField(
|
||||||
|
label=_('Straight Cables'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
grid_size = forms.IntegerField(
|
||||||
|
label=_('Grid Size'),
|
||||||
|
required=False,
|
||||||
|
initial=0,
|
||||||
|
min_value=0,
|
||||||
|
max_value=1000,
|
||||||
|
help_text=_('Show grid and snap dragged icons to grid. Set to 0 to disable grid and snapping.')
|
||||||
|
)
|
||||||
|
node_label_items = forms.MultipleChoiceField(
|
||||||
|
label=_('Node Label Items'),
|
||||||
|
required=False,
|
||||||
|
choices=NodeLabelItems
|
||||||
|
)
|
||||||
|
|
||||||
class CoordinateGroupsForm(NetBoxModelForm):
|
class CoordinateGroupsForm(NetBoxModelForm):
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
@@ -485,7 +516,6 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet
|
FieldSet
|
||||||
(
|
(
|
||||||
'user_id',
|
|
||||||
'ignore_cable_type',
|
'ignore_cable_type',
|
||||||
'preselected_device_roles',
|
'preselected_device_roles',
|
||||||
'preselected_tags',
|
'preselected_tags',
|
||||||
@@ -501,7 +531,11 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'group_sites',
|
'group_sites',
|
||||||
'group_locations',
|
'group_locations',
|
||||||
'group_racks',
|
'group_racks',
|
||||||
|
'group_virtualchassis',
|
||||||
'draw_default_layout',
|
'draw_default_layout',
|
||||||
|
'straight_cables',
|
||||||
|
'grid_size',
|
||||||
|
'node_label_items',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -622,6 +656,13 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
help_text=_('Draws a rectangle around Devices that belong to the '
|
help_text=_('Draws a rectangle around Devices that belong to the '
|
||||||
'same rack.')
|
'same rack.')
|
||||||
)
|
)
|
||||||
|
group_virtualchassis = forms.BooleanField(
|
||||||
|
label =_('Group Virtual Chassis'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
help_text=_('Draws a rectangle around Devices that belong to the '
|
||||||
|
'same virtual chassis.')
|
||||||
|
)
|
||||||
draw_default_layout = forms.BooleanField(
|
draw_default_layout = forms.BooleanField(
|
||||||
label = ('Draw Default Layout'),
|
label = ('Draw Default Layout'),
|
||||||
required=False,
|
required=False,
|
||||||
@@ -629,6 +670,29 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
help_text=_('Enable this option if you want to draw the topology on '
|
help_text=_('Enable this option if you want to draw the topology on '
|
||||||
'the initial load (when you go to the topology plugin page).')
|
'the initial load (when you go to the topology plugin page).')
|
||||||
)
|
)
|
||||||
|
straight_cables = forms.BooleanField(
|
||||||
|
label=('Use Straight Cables'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
help_text=_('Enable this option if you want to draw cables as straight lines '
|
||||||
|
'instead of curves.')
|
||||||
|
)
|
||||||
|
grid_size = forms.IntegerField(
|
||||||
|
label=_('Grid Size'),
|
||||||
|
required=True,
|
||||||
|
initial=0,
|
||||||
|
min_value=0,
|
||||||
|
max_value=1000,
|
||||||
|
help_text=_('Default grid value. Set to 0 to disable grid. '
|
||||||
|
'Integers between 0 and 1000 are allowed. Snap to grid will be '
|
||||||
|
'automatically enabled for values > 0.')
|
||||||
|
)
|
||||||
|
node_label_items = forms.MultipleChoiceField(
|
||||||
|
label=_('Node Label Items'),
|
||||||
|
required=False,
|
||||||
|
choices=NodeLabelItems,
|
||||||
|
help_text=_('Choose Label Items that you want to be displayed.')
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IndividualOptions
|
model = IndividualOptions
|
||||||
@@ -636,5 +700,6 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'user_id', 'ignore_cable_type', 'preselected_device_roles', 'preselected_tags',
|
'user_id', 'ignore_cable_type', 'preselected_device_roles', 'preselected_tags',
|
||||||
'save_coords', 'show_unconnected', 'show_cables', 'show_logical_connections',
|
'save_coords', 'show_unconnected', 'show_cables', 'show_logical_connections',
|
||||||
'show_single_cable_logical_conns', 'show_neighbors', 'show_circuit', 'show_power',
|
'show_single_cable_logical_conns', 'show_neighbors', 'show_circuit', 'show_power',
|
||||||
'show_wireless', 'group_sites', 'group_locations', 'group_racks', 'draw_default_layout'
|
'show_wireless', 'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis', 'draw_default_layout',
|
||||||
|
'straight_cables', 'grid_size', 'node_label_items'
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.10 on 2024-04-29 14:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('netbox_topology_views', '0007_individualoptions_group_locations_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='straight_cables',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.6 on 2024-07-29 08:54
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('netbox_topology_views', '0008_straight_cables'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='group_virtualchassis',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.6 on 2024-08-14 09:46
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('netbox_topology_views', '0009_individualoptions_group_virtualchassis'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='grid_size',
|
||||||
|
field=models.PositiveSmallIntegerField(default=0),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.9 on 2024-09-27 18:19
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('netbox_topology_views', '0010_individualoptions_grid_size'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='node_label_items',
|
||||||
|
field=models.CharField(blank=True, max_length=255),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -25,6 +25,7 @@ from netbox_topology_views.utils import (
|
|||||||
image_static_url,
|
image_static_url,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from netbox_topology_views.choices import NodeLabelItems
|
||||||
|
|
||||||
class RoleImage(ChangeLoggingMixin, ExportTemplatesMixin, EventRulesMixin):
|
class RoleImage(ChangeLoggingMixin, ExportTemplatesMixin, EventRulesMixin):
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -331,12 +332,12 @@ class PowerFeedCoordinate(NetBoxModel):
|
|||||||
class IndividualOptions(NetBoxModel):
|
class IndividualOptions(NetBoxModel):
|
||||||
CHOICES = (
|
CHOICES = (
|
||||||
('interface', 'interface'),
|
('interface', 'interface'),
|
||||||
('front port', 'front port'),
|
('frontport', 'frontport'),
|
||||||
('rear port', 'rear port'),
|
('rearport', 'rearport'),
|
||||||
('power outlet', 'power outlet'),
|
('poweroutlet', 'poweroutlet'),
|
||||||
('power port', 'power port'),
|
('powerport', 'powerport'),
|
||||||
('console port', 'console port'),
|
('consoleport', 'consoleport'),
|
||||||
('console server port', 'console server port'),
|
('consoleserverport', 'consoleserverport'),
|
||||||
)
|
)
|
||||||
|
|
||||||
user_id = models.IntegerField(
|
user_id = models.IntegerField(
|
||||||
@@ -395,9 +396,22 @@ class IndividualOptions(NetBoxModel):
|
|||||||
group_racks = models.BooleanField(
|
group_racks = models.BooleanField(
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
group_virtualchassis = models.BooleanField(
|
||||||
|
default=False
|
||||||
|
)
|
||||||
draw_default_layout = models.BooleanField(
|
draw_default_layout = models.BooleanField(
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
straight_cables = models.BooleanField(
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
grid_size = models.PositiveSmallIntegerField(
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
node_label_items = models.CharField(
|
||||||
|
max_length=255,
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
|
|
||||||
_netbox_private = True
|
_netbox_private = True
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
.vis-overlay{bottom:0;left:0;position:absolute;right:0;top:0;z-index:10}.vis-active{box-shadow:0 0 10px #86d5f8}.vis [class*=span]{min-height:0;width:auto}div.vis-color-picker{background-color:#fff;border-radius:15px;box-shadow:0 0 10px #00000080;display:none;height:444px;left:30px;margin-left:30px;margin-top:-140px;padding:10px;position:absolute;top:0;width:310px;z-index:1}div.vis-color-picker div.vis-arrow{left:5px;position:absolute;top:147px}div.vis-color-picker div.vis-arrow:after,div.vis-color-picker div.vis-arrow:before{border:solid transparent;content:" ";height:0;pointer-events:none;position:absolute;right:100%;top:50%;width:0}div.vis-color-picker div.vis-arrow:after{border-color:hsla(0,0%,100%,0) #fff hsla(0,0%,100%,0) hsla(0,0%,100%,0);border-width:30px;margin-top:-30px}div.vis-color-picker div.vis-color{cursor:pointer;height:289px;position:absolute;width:289px}div.vis-color-picker div.vis-brightness{position:absolute;top:313px}div.vis-color-picker div.vis-opacity{position:absolute;top:350px}div.vis-color-picker div.vis-selector{background:#4c4c4c;background:-moz-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4c4c4c),color-stop(12%,#595959),color-stop(25%,#666),color-stop(39%,#474747),color-stop(50%,#2c2c2c),color-stop(51%,#000),color-stop(60%,#111),color-stop(76%,#2b2b2b),color-stop(91%,#1c1c1c),color-stop(100%,#131313));background:-webkit-linear-gradient(top,#4c4c4c,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313);background:-o-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-ms-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:linear-gradient(180deg,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313);border:1px solid #fff;border-radius:15px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#4c4c4c",endColorstr="#131313",GradientType=0);height:15px;left:137px;position:absolute;top:137px;width:15px}div.vis-color-picker div.vis-new-color{left:159px;padding-right:2px;text-align:right}div.vis-color-picker div.vis-initial-color,div.vis-color-picker div.vis-new-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;color:#0006;font-size:10px;height:20px;line-height:20px;position:absolute;top:380px;vertical-align:middle;width:140px}div.vis-color-picker div.vis-initial-color{left:10px;padding-left:2px;text-align:left}div.vis-color-picker div.vis-label{left:10px;position:absolute;width:300px}div.vis-color-picker div.vis-label.vis-brightness{top:300px}div.vis-color-picker div.vis-label.vis-opacity{top:338px}div.vis-color-picker div.vis-button{background-color:#f7f7f7;border:2px solid #d9d9d9;border-radius:10px;cursor:pointer;height:25px;line-height:25px;position:absolute;text-align:center;top:410px;vertical-align:middle;width:68px}div.vis-color-picker div.vis-button.vis-cancel{left:5px}div.vis-color-picker div.vis-button.vis-load{left:82px}div.vis-color-picker div.vis-button.vis-apply{left:159px}div.vis-color-picker div.vis-button.vis-save{left:236px}div.vis-color-picker input.vis-range{height:20px;width:290px}div.vis-configuration{display:block;float:left;font-size:12px;position:relative}div.vis-configuration-wrapper{display:block;width:700px}div.vis-configuration-wrapper:after{clear:both;content:"";display:block}div.vis-configuration.vis-config-option-container{background-color:#fff;border:2px solid #f7f8fa;border-radius:4px;display:block;left:10px;margin-top:20px;padding-left:5px;width:495px}div.vis-configuration.vis-config-button{background-color:#f7f8fa;border:2px solid #ceced0;border-radius:4px;cursor:pointer;display:block;height:25px;left:10px;line-height:25px;margin-bottom:30px;margin-top:20px;padding-left:5px;vertical-align:middle;width:495px}div.vis-configuration.vis-config-button.hover{background-color:#4588e6;border:2px solid #214373;color:#fff}div.vis-configuration.vis-config-item{display:block;float:left;height:25px;line-height:25px;vertical-align:middle;width:495px}div.vis-configuration.vis-config-item.vis-config-s2{background-color:#f7f8fa;border-radius:3px;left:10px;padding-left:5px}div.vis-configuration.vis-config-item.vis-config-s3{background-color:#e4e9f0;border-radius:3px;left:20px;padding-left:5px}div.vis-configuration.vis-config-item.vis-config-s4{background-color:#cfd8e6;border-radius:3px;left:30px;padding-left:5px}div.vis-configuration.vis-config-header{font-size:18px;font-weight:700}div.vis-configuration.vis-config-label{height:25px;line-height:25px;width:120px}div.vis-configuration.vis-config-label.vis-config-s3{width:110px}div.vis-configuration.vis-config-label.vis-config-s4{width:100px}div.vis-configuration.vis-config-colorBlocLine truncated
|
.vis-overlay{inset:0;position:absolute;z-index:10}.vis-active{box-shadow:0 0 10px #86d5f8}.vis [class*=span]{min-height:0;width:auto}div.vis-color-picker{background-color:#fff;border-radius:15px;box-shadow:0 0 10px #00000080;display:none;height:444px;left:30px;margin-left:30px;margin-top:-140px;padding:10px;position:absolute;top:0;width:310px;z-index:1}div.vis-color-picker div.vis-arrow{left:5px;position:absolute;top:147px}div.vis-color-picker div.vis-arrow:after,div.vis-color-picker div.vis-arrow:before{border:solid transparent;content:" ";height:0;pointer-events:none;position:absolute;right:100%;top:50%;width:0}div.vis-color-picker div.vis-arrow:after{border-color:hsla(0,0%,100%,0) #fff hsla(0,0%,100%,0) hsla(0,0%,100%,0);border-width:30px;margin-top:-30px}div.vis-color-picker div.vis-color{cursor:pointer;height:289px;position:absolute;width:289px}div.vis-color-picker div.vis-brightness{position:absolute;top:313px}div.vis-color-picker div.vis-opacity{position:absolute;top:350px}div.vis-color-picker div.vis-selector{background:#4c4c4c;background:-moz-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4c4c4c),color-stop(12%,#595959),color-stop(25%,#666),color-stop(39%,#474747),color-stop(50%,#2c2c2c),color-stop(51%,#000),color-stop(60%,#111),color-stop(76%,#2b2b2b),color-stop(91%,#1c1c1c),color-stop(100%,#131313));background:-webkit-linear-gradient(top,#4c4c4c,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313);background:-o-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-ms-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:linear-gradient(180deg,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313);border:1px solid #fff;border-radius:15px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#4c4c4c",endColorstr="#131313",GradientType=0);height:15px;left:137px;position:absolute;top:137px;width:15px}div.vis-color-picker div.vis-new-color{left:159px;padding-right:2px;text-align:right}div.vis-color-picker div.vis-initial-color,div.vis-color-picker div.vis-new-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;color:#0006;font-size:10px;height:20px;line-height:20px;position:absolute;top:380px;vertical-align:middle;width:140px}div.vis-color-picker div.vis-initial-color{left:10px;padding-left:2px;text-align:left}div.vis-color-picker div.vis-label{left:10px;position:absolute;width:300px}div.vis-color-picker div.vis-label.vis-brightness{top:300px}div.vis-color-picker div.vis-label.vis-opacity{top:338px}div.vis-color-picker div.vis-button{background-color:#f7f7f7;border:2px solid #d9d9d9;border-radius:10px;cursor:pointer;height:25px;line-height:25px;position:absolute;text-align:center;top:410px;vertical-align:middle;width:68px}div.vis-color-picker div.vis-button.vis-cancel{left:5px}div.vis-color-picker div.vis-button.vis-load{left:82px}div.vis-color-picker div.vis-button.vis-apply{left:159px}div.vis-color-picker div.vis-button.vis-save{left:236px}div.vis-color-picker input.vis-range{height:20px;width:290px}div.vis-configuration{display:block;float:left;font-size:12px;position:relative}div.vis-configuration-wrapper{display:block;width:700px}div.vis-configuration-wrapper:after{clear:both;content:"";display:block}div.vis-configuration.vis-config-option-container{background-color:#fff;border:2px solid #f7f8fa;border-radius:4px;display:block;left:10px;margin-top:20px;padding-left:5px;width:495px}div.vis-configuration.vis-config-button{background-color:#f7f8fa;border:2px solid #ceced0;border-radius:4px;cursor:pointer;display:block;height:25px;left:10px;line-height:25px;margin-bottom:30px;margin-top:20px;padding-left:5px;vertical-align:middle;width:495px}div.vis-configuration.vis-config-button.hover{background-color:#4588e6;border:2px solid #214373;color:#fff}div.vis-configuration.vis-config-item{display:block;float:left;height:25px;line-height:25px;vertical-align:middle;width:495px}div.vis-configuration.vis-config-item.vis-config-s2{background-color:#f7f8fa;border-radius:3px;left:10px;padding-left:5px}div.vis-configuration.vis-config-item.vis-config-s3{background-color:#e4e9f0;border-radius:3px;left:20px;padding-left:5px}div.vis-configuration.vis-config-item.vis-config-s4{background-color:#cfd8e6;border-radius:3px;left:30px;padding-left:5px}div.vis-configuration.vis-config-header{font-size:18px;font-weight:700}div.vis-configuration.vis-config-label{height:25px;line-height:25px;width:120px}div.vis-configuration.vis-config-label.vis-config-s3{width:110px}div.vis-configuration.vis-config-label.vis-config-s4{width:100px}div.vis-configuration.vis-config-colorBlock{border:1px solid #44Line truncated
|
||||||
@@ -1,104 +1,114 @@
|
|||||||
(()=>{var bn=Object.create;var Tt=Object.defineProperty,vn=Object.defineProperties,wn=Object.getOwnPropertyDescriptor,_n=Object.getOwnPropertyDescriptors,En=Object.getOwnPropertyNames,ji=Object.getOwnPropertySymbols,xn=Object.getPrototypeOf,Wi=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable;var Zt=(n,e,t)=>e in n?Tt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,le=(n,e)=>{for(var t in e||(e={}))Wi.call(e,t)&&Zt(n,t,e[t]);if(ji)for(var t of ji(e))Cn.call(e,t)&&Zt(n,t,e[t]);return n},Be=(n,e)=>vn(n,_n(e)),Tn=n=>Tt(n,"__esModule",{value:!0});var kn=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var On=(n,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of En(e))!Wi.call(n,i)&&i!=="default"&&Tt(n,i,{get:()=>e[i],enumerable:!(t=wn(e,i))||t.enumerable});return n},Vi=n=>On(Tn(Tt(n!=null?bn(xn(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var X=(n,e,t)=>(Zt(n,typeof e!="symbol"?e+"":e,t),t);var qi=(n,e,t)=>new Promise((i,s)=>{var o=d=>{try{a(t.next(d))}catch(h){s(h)}},r=d=>{try{a(t.throw(d))}catch(h){s(h)}},a=d=>d.done?i(d.value):Promise.resolve(d.value).then(o,r);a((t=t.apply(n,e)).next())});var Jt=kn((za,Qt)=>{typeof Qt!="undefined"&&(Qt.exports=te);function te(n){if(n)return Sn(n)}function Sn(n){for(var e in te.prototype)n[e]=te.prototype[e];return n}te.prototype.on=te.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};te.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};te.prototype.off=te.prototype.removeListener=te.prototype.removeAllListeners=te.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,s=0;s<t.length;s++)if(i=t[s],i===e||i.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+n],this};te.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(t){t=t.slice(0);for(var i=0,s=t.length;i<s;++i)t[i].apply(this,e)}return this};te.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};te.prototype.hasListeners=function(n){return!!this.listeners(n).length}});var Os=Vi(Jt());function ce(){return ce=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},ce.apply(this,arguments)}function ne(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e}function kt(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}var ei;typeof Object.assign!="function"?ei=function(e){if(e==null)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i<arguments.length;i++){var s=arguments[i];if(s!=null)for(var o in s)s.hasOwnProperty(o)&&(t[o]=s[o])}return t}:ei=Object.assign;var Ae=ei,Ui=["","webkit","Moz","MS","ms","o"],In=typeof document=="undefined"?{style:{}}:document.createElement("div"),Pn="function",$e=Math.round,ze=Math.abs,ti=Date.now;function Ot(n,e){for(var t,i,s=e[0].toUpperCase()+e.slice(1),o=0;o<Ui.length;){if(t=Ui[o],i=t?t+s:e,i in n)return i;o++}}var me;typeof window=="undefined"?me={}:me=window;var Yi=Ot(In.style,"touchAction"),Xi=Yi!==void 0;function Mn(){if(!Xi)return!1;var n={},e=me.CSS&&me.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(t){return n[t]=e?me.CSS.supports("touch-action",t):!0}),n}var Gi="compute",Ki="auto",ii="manipulation",Re="none",nt="pan-x",rt="pan-y",St=Mn(),Dn=/mobile|tablet|ip(ad|hone|od)|android/i,$i="ontouchstart"in me,Fn=Ot(me,"PointerEvent")!==void 0,Nn=$i&&Dn.test(navigator.userAgent),at="touch",Bn="pen",si="mouse",An="kinect",zn=25,$=1,Le=2,j=4,J=8,It=1,dt=2,ht=4,lt=8,Ze=16,ue=dt|ht,He=lt|Ze,Zi=ue|He,Qi=["x","y"],Pt=["clientX","clientY"];function ye(n,e,t){var i;if(!!n)if(n.forEach)n.forEach(e,t);else if(n.length!==void 0)for(i=0;i<n.length;)e.call(t,n[i],i,n),i++;else for(i in n)n.hasOwnProperty(i)&&e.call(t,n[i],i,n)}function Mt(n,e){return typeof n===Pn?n.apply(e&&e[0]||void 0,e):n}function je(n,e){return n.indexOf(e)>-1}function Rn(n){if(je(n,Re))return Re;var e=je(n,nt),t=je(n,rt);return e&&t?Re:e||t?e?nt:rt:je(n,ii)?ii:Ki}var Ji=function(){function n(t,i){this.manager=t,this.set(i)}var e=n.prototype;return e.set=function(i){i===Gi&&(i=this.compute()),Xi&&this.manager.element.style&&St[i]&&(this.manager.element.style[Yi]=i),this.actions=i.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.coLine truncated
|
(()=>{var Tn=Object.create;var ci=Object.defineProperty,Cn=Object.defineProperties,kn=Object.getOwnPropertyDescriptor,On=Object.getOwnPropertyDescriptors,Sn=Object.getOwnPropertyNames,Vs=Object.getOwnPropertySymbols,In=Object.getPrototypeOf,qs=Object.prototype.hasOwnProperty,Pn=Object.prototype.propertyIsEnumerable;var li=(r,e,t)=>e in r?ci(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,be=(r,e)=>{for(var t in e||(e={}))qs.call(e,t)&&li(r,t,e[t]);if(Vs)for(var t of Vs(e))Pn.call(e,t)&&li(r,t,e[t]);return r},je=(r,e)=>Cn(r,On(e));var Mn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Dn=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Sn(e))!qs.call(r,o)&&o!==t&&ci(r,o,{get:()=>e[o],enumerable:!(s=kn(e,o))||s.enumerable});return r};var Ys=(r,e,t)=>(t=r!=null?Tn(In(r)):{},Dn(e||!r||!r.__esModule?ci(t,"default",{value:r,enumerable:!0}):t,r));var se=(r,e,t)=>li(r,typeof e!="symbol"?e+"":e,t);var Us=(r,e,t)=>new Promise((s,o)=>{var n=h=>{try{d(t.next(h))}catch(l){o(l)}},a=h=>{try{d(t.throw(h))}catch(l){o(l)}},d=h=>h.done?s(h.value):Promise.resolve(h.value).then(n,a);d((t=t.apply(r,e)).next())});var fi=Mn((ja,ui)=>{typeof ui!="undefined"&&(ui.exports=ce);function ce(r){if(r)return Nn(r)}function Nn(r){for(var e in ce.prototype)r[e]=ce.prototype[e];return r}ce.prototype.on=ce.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};ce.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};ce.prototype.off=ce.prototype.removeListener=ce.prototype.removeAllListeners=ce.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var s,o=0;o<t.length;o++)if(s=t[o],s===e||s.fn===e){t.splice(o,1);break}return t.length===0&&delete this._callbacks["$"+r],this};ce.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,o=t.length;s<o;++s)t[s].apply(this,e)}return this};ce.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};ce.prototype.hasListeners=function(r){return!!this.listeners(r).length}});var Do=Ys(fi());function ve(){return ve=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s])}return r},ve.apply(this,arguments)}function me(r,e){r.prototype=Object.create(e.prototype),r.prototype.constructor=r,r.__proto__=e}function Pt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}var pi;typeof Object.assign!="function"?pi=function(e){if(e==null)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),s=1;s<arguments.length;s++){var o=arguments[s];if(o!=null)for(var n in o)o.hasOwnProperty(n)&&(t[n]=o[n])}return t}:pi=Object.assign;var Ye=pi,Xs=["","webkit","Moz","MS","ms","o"],Fn=typeof document=="undefined"?{style:{}}:document.createElement("div"),Bn="function",Je=Math.round,Ue=Math.abs,bi=Date.now;function zt(r,e){for(var t,s,o=e[0].toUpperCase()+e.slice(1),n=0;n<Xs.length;){if(t=Xs[n],s=t?t+o:e,s in r)return s;n++}}var ke;typeof window=="undefined"?ke={}:ke=window;var oo=zt(Fn.style,"touchAction"),no=oo!==void 0;function An(){if(!no)return!1;var r={},e=ke.CSS&&ke.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(t){return r[t]=e?ke.CSS.supports("touch-action",t):!0}),r}var ro="compute",ao="auto",gi="manipulation",Ve="none",ct="pan-x",ut="pan-y",Mt=An(),zn=/mobile|tablet|ip(ad|hone|od)|android/i,ho="ontouchstart"in ke,Rn=zt(ke,"PointerEvent")!==void 0,Ln=ho&&zn.test(navigator.userAgent),mt="touch",Hn="pen",vi="mouse",jn="kinect",Wn=25,oe=1,Ge=2,Q=4,de=8,Ft=1,yt=2,bt=4,vt=8,tt=16,Ee=yt|bt,qe=vt|tt,lo=Ee|qe,co=["x","y"],Bt=["clientX","clientY"];function Oe(r,e,t){var s;if(r)if(r.forEach)r.forEach(e,t);else if(r.length!==void 0)for(s=0;s<r.length;)e.call(t,r[s],s,r),s++;else for(s in r)r.hasOwnProperty(s)&&e.call(t,r[s],s,r)}function Rt(r,e){return typeof r===Bn?r.apply(e&&e[0]||void 0,e):r}function We(r,e){return r.indexOf(e)>-1}function Vn(r){if(We(r,Ve))return Ve;var e=We(r,ct),t=We(r,ut);return e&&t?Ve:e||t?e?ct:ut:We(r,gi)?gi:ao}var uo=function(){function r(t,s){this.manager=t,this.set(s)}var e=r.prototype;return e.set=function(s){s===ro&&(s=this.compute()),no&&this.manager.element.style&&Mt[s]&&(this.manager.element.style[oo]=s),this.actions=s.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var s=[];return Oe(this.manager.recognizers,function(o){RtLine truncated
|
||||||
`+t+` AT
|
`+t+` AT
|
||||||
`;return function(){var s=new Error("get-stack-trace"),o=s&&s.stack?s.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=window.console&&(window.console.warn||window.console.log);return r&&r.call(window.console,i,o),n.apply(this,arguments)}}var xs=Es(function(n,e,t){for(var i=Object.keys(e),s=0;s<i.length;)(!t||t&&n[i[s]]===void 0)&&(n[i[s]]=e[i[s]]),s++;return n},"extend","Use `assign`."),ur=Es(function(n,e){return xs(n,e,!0)},"merge","Use `assign`.");function fr(n,e,t){var i=e.prototype,s;s=n.prototype=Object.create(i),s.constructor=n,s._super=i,t&&Ae(s,t)}function Cs(n,e){return function(){return n.apply(e,arguments)}}var Ts=function(){var n=function(t,i){return i===void 0&&(i={}),new _s(t,ce({recognizers:bs.concat()},i))};return n.VERSION="2.0.17-rc",n.DIRECTION_ALL=Zi,n.DIRECTION_DOWN=Ze,n.DIRECTION_LEFT=dt,n.DIRECTION_RIGHT=ht,n.DIRECTION_UP=lt,n.DIRECTION_HORIZONTAL=ue,n.DIRECTION_VERTICAL=He,n.DIRECTION_NONE=It,n.DIRECTION_DOWN=Ze,n.INPUT_START=$,n.INPUT_MOVE=Le,n.INPUT_END=j,n.INPUT_CANCEL=J,n.STATE_POSSIBLE=Ft,n.STATE_BEGAN=re,n.STATE_CHANGED=et,n.STATE_ENDED=Se,n.STATE_RECOGNIZED=be,n.STATE_CANCELLED=gt,n.STATE_FAILED=fe,n.Manager=_s,n.Input=Qe,n.TouchAction=Ji,n.TouchInput=ai,n.MouseInput=di,n.PointerEventInput=as,n.TouchMouseInput=ls,n.SingleTouchInput=lr,n.Recognizer=mt,n.AttrRecognizer=tt,n.Tap=hi,n.Pan=li,n.Swipe=fs,n.Pinch=ps,n.Rotate=gs,n.Press=ms,n.on=ut,n.off=ft,n.each=ye,n.merge=ur,n.extend=xs,n.bindFn=Cs,n.assign=Ae,n.inherit=fr,n.bindFn=Cs,n.prefixed=Ot,n.toArray=pt,n.inArray=We,n.uniqueArray=ri,n.splitStr=ct,n.boolOrFn=Mt,n.hasParent=oi,n.addEventListeners=ut,n.removeEventListeners=ft,n.defaults=Ae({},ys,{preset:bs}),n}(),Ra=Ts.defaults,ks=Ts;var ci=Symbol("DELETE");function Ss(n,...e){return Is({},n,...e)}function Is(...n){let e=Bt(...n);return Ms(e),e}function Bt(...n){if(n.length<2)return n[0];if(n.length>2)return Bt(Is(n[0],n[1]),...n.slice(2));let e=n[0],t=n[1];if(e instanceof Date&&t instanceof Date)return e.setTime(t.getTime()),e;for(let i of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,i)&&(t[i]===ci?delete e[i]:e[i]!==null&&t[i]!==null&&typeof e[i]=="object"&&typeof t[i]=="object"&&!Array.isArray(e[i])&&!Array.isArray(t[i])?e[i]=Bt(e[i],t[i]):e[i]=Ps(t[i]));return e}function Ps(n){return Array.isArray(n)?n.map(e=>Ps(e)):typeof n=="object"&&n!==null?n instanceof Date?new Date(n.getTime()):Bt({},n):n}function Ms(n){for(let e of Object.keys(n))n[e]===ci?delete n[e]:typeof n[e]=="object"&&n[e]!==null&&Ms(n[e])}function yt(...n){return pr(n.length?n:[Date.now()])}function pr(n){let[e,t,i]=gr(n),s=1,o=()=>{let r=2091639*e+s*23283064365386963e-26;return e=t,t=i,i=r-(s=r|0)};return o.uint32=()=>o()*4294967296,o.fract53=()=>o()+(o()*2097152|0)*11102230246251565e-32,o.algorithm="Alea",o.seed=n,o.version="0.9",o}function gr(...n){let e=mr(),t=e(" "),i=e(" "),s=e(" ");for(let o=0;o<n.length;o++)t-=e(n[o]),t<0&&(t+=1),i-=e(n[o]),i<0&&(i+=1),s-=e(n[o]),s<0&&(s+=1);return[t,i,s]}function mr(){let n=4022871197;return function(e){let t=e.toString();for(let i=0;i<t.length;i++){n+=t.charCodeAt(i);let s=.02519603282416938*n;n=s>>>0,s-=n,s*=n,n=s>>>0,s-=n,n+=s*4294967296}return(n>>>0)*23283064365386963e-26}}function yr(){let n=()=>{};return{on:n,off:n,destroy:n,emit:n,get(){return{set:n}}}}var ui=typeof window!="undefined"?window.Hammer||ks:function(){return yr()};function pe(n){this._cleanupQueue=[],this.active=!1,this._dom={container:n,overlay:document.createElement("div")},this._dom.overlay.classList.add("vis-overlay"),this._dom.container.appendChild(this._dom.overlay),this._cleanupQueue.push(()=>{this._dom.overlay.parentNode.removeChild(this._dom.overlay)});let e=ui(this._dom.overlay);e.on("tap",this._onTapOverlay.bind(this)),this._cleanupQueue.push(()=>{e.destroy()}),["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(i=>{e.on(i,s=>{s.srcEvent.stopPropagation()})}),document&&document.body&&(this._onClick=i=>{br(i.target,n)||this.deactivate()},document.body.addEventListener("click",this._onClick),this._cleanupQueue.push(()=>{document.body.removeEventListener("click",this._onClick)})),this._escListener=i=>{("key"in i?i.key==="Escape":i.keyCode===27)&&this.deactivate()}}(0,Os.default)(pe.prototype);pe.current=null;pe.prototype.destroy=function(){this.deactivate();for(let n of this._cleanupQueue.splice(0).reverse())n()};pe.prototype.activate=function(){pe.current&&pe.current.deactivate(),pe.current=this,this.active=!0,this._dom.overlay.style.display="none",this._dom.container.classList.add("vis-active"),this.emit("change"),this.emit("activate"),document.body.addEventListener("keydown",this._escListener)};pe.prototype.deactivate=function(){this.active=!1,this._dom.overlay.style.display="block",this._dom.container.classList.remove("vis-active"),document.body.removeEventListener("keydown",this._escListener),this.emit("change"),this.emit("deactivate")};pe.prototy
Line truncated
|
`;return function(){var o=new Error("get-stack-trace"),n=o&&o.stack?o.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",a=window.console&&(window.console.warn||window.console.log);return a&&a.call(window.console,s,n),r.apply(this,arguments)}}var Oo=ko(function(r,e,t){for(var s=Object.keys(e),o=0;o<s.length;)(!t||t&&r[s[o]]===void 0)&&(r[s[o]]=e[s[o]]),o++;return r},"extend","Use `assign`."),yr=ko(function(r,e){return Oo(r,e,!0)},"merge","Use `assign`.");function br(r,e,t){var s=e.prototype,o;o=r.prototype=Object.create(s),o.constructor=r,o._super=s,t&&Ye(o,t)}function so(r,e){return function(){return r.apply(e,arguments)}}var So=function(){var r=function(t,s){return s===void 0&&(s={}),new io(t,ve({recognizers:Js.concat()},s))};return r.VERSION="2.0.17-rc",r.DIRECTION_ALL=lo,r.DIRECTION_DOWN=tt,r.DIRECTION_LEFT=yt,r.DIRECTION_RIGHT=bt,r.DIRECTION_UP=vt,r.DIRECTION_HORIZONTAL=Ee,r.DIRECTION_VERTICAL=qe,r.DIRECTION_NONE=Ft,r.DIRECTION_DOWN=tt,r.INPUT_START=oe,r.INPUT_MOVE=Ge,r.INPUT_END=Q,r.INPUT_CANCEL=de,r.STATE_POSSIBLE=Nt,r.STATE_BEGAN=ge,r.STATE_CHANGED=it,r.STATE_ENDED=Be,r.STATE_RECOGNIZED=Se,r.STATE_CANCELLED=gt,r.STATE_FAILED=_e,r.Manager=io,r.Input=ot,r.TouchAction=uo,r.TouchInput=Ei,r.MouseInput=xi,r.PointerEventInput=bo,r.TouchMouseInput=vo,r.SingleTouchInput=gr,r.Recognizer=wt,r.AttrRecognizer=st,r.Tap=yi,r.Pan=Ti,r.Swipe=_o,r.Pinch=Eo,r.Rotate=xo,r.Press=To,r.on=ht,r.off=lt,r.each=Oe,r.merge=yr,r.extend=Oo,r.bindFn=so,r.assign=Ye,r.inherit=br,r.bindFn=so,r.prefixed=zt,r.toArray=pt,r.inArray=Xe,r.uniqueArray=_i,r.splitStr=ft,r.boolOrFn=Rt,r.hasParent=wi,r.addEventListeners=ht,r.removeEventListeners=lt,r.defaults=Ye({},Co,{preset:Js}),r}(),Wa=So.defaults,Io=So;var Oi=Symbol("DELETE");function No(r,...e){return Fo({},r,...e)}function Fo(...r){let e=Ht(...r);return Ao(e),e}function Ht(...r){if(r.length<2)return r[0];if(r.length>2)return Ht(Fo(r[0],r[1]),...r.slice(2));let e=r[0],t=r[1];if(e instanceof Date&&t instanceof Date)return e.setTime(t.getTime()),e;for(let s of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,s)&&(t[s]===Oi?delete e[s]:e[s]!==null&&t[s]!==null&&typeof e[s]=="object"&&typeof t[s]=="object"&&!Array.isArray(e[s])&&!Array.isArray(t[s])?e[s]=Ht(e[s],t[s]):e[s]=Bo(t[s]));return e}function Bo(r){return Array.isArray(r)?r.map(e=>Bo(e)):typeof r=="object"&&r!==null?r instanceof Date?new Date(r.getTime()):Ht({},r):r}function Ao(r){for(let e of Object.keys(r))r[e]===Oi?delete r[e]:typeof r[e]=="object"&&r[e]!==null&&Ao(r[e])}function xt(...r){return vr(r.length?r:[Date.now()])}function vr(r){let[e,t,s]=wr(r),o=1,n=()=>{let a=2091639*e+o*23283064365386963e-26;return e=t,t=s,s=a-(o=a|0)};return n.uint32=()=>n()*4294967296,n.fract53=()=>n()+(n()*2097152|0)*11102230246251565e-32,n.algorithm="Alea",n.seed=r,n.version="0.9",n}function wr(...r){let e=_r(),t=e(" "),s=e(" "),o=e(" ");for(let n=0;n<r.length;n++)t-=e(r[n]),t<0&&(t+=1),s-=e(r[n]),s<0&&(s+=1),o-=e(r[n]),o<0&&(o+=1);return[t,s,o]}function _r(){let r=4022871197;return function(e){let t=e.toString();for(let s=0;s<t.length;s++){r+=t.charCodeAt(s);let o=.02519603282416938*r;r=o>>>0,o-=r,o*=r,r=o>>>0,o-=r,r+=o*4294967296}return(r>>>0)*23283064365386963e-26}}function Er(){let r=()=>{};return{on:r,off:r,destroy:r,emit:r,get(){return{set:r}}}}var Si=typeof window!="undefined"?window.Hammer||Io:function(){return Er()};function xe(r){this._cleanupQueue=[],this.active=!1,this._dom={container:r,overlay:document.createElement("div")},this._dom.overlay.classList.add("vis-overlay"),this._dom.container.appendChild(this._dom.overlay),this._cleanupQueue.push(()=>{this._dom.overlay.parentNode.removeChild(this._dom.overlay)});let e=Si(this._dom.overlay);e.on("tap",this._onTapOverlay.bind(this)),this._cleanupQueue.push(()=>{e.destroy()}),["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(s=>{e.on(s,o=>{o.srcEvent.stopPropagation()})}),document&&document.body&&(this._onClick=s=>{xr(s.target,r)||this.deactivate()},document.body.addEventListener("click",this._onClick),this._cleanupQueue.push(()=>{document.body.removeEventListener("click",this._onClick)})),this._escListener=s=>{("key"in s?s.key==="Escape":s.keyCode===27)&&this.deactivate()}}(0,Do.default)(xe.prototype);xe.current=null;xe.prototype.destroy=function(){this.deactivate();for(let r of this._cleanupQueue.splice(0).reverse())r()};xe.prototype.activate=function(){xe.current&&xe.current.deactivate(),xe.current=this,this.active=!0,this._dom.overlay.style.display="none",this._dom.container.classList.add("vis-active"),this.emit("change"),this.emit("activate"),document.body.addEventListener("keydown",this._escListener)};xe.prototype.deactivate=function(){this.active=!1,this._dom.overlay.style.display="block",this._dom.container.classList.remove("vis-active"),document.body.removeEventListener("keydown",this._escListener),this.emit("change"),this.emit("deactivate")};xe.proto
Line truncated
|
||||||
|
|
||||||
`:o.distance<=a&&s.distance>o.distance?d=" in "+L.printLocation(s.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+L.printLocation(o.path,o.closestMatch,""):s.distance<=r?d='. Did you mean "'+s.closestMatch+'"?'+L.printLocation(s.path,e):d=". Did you mean one of these: "+L.print(Object.keys(t))+L.printLocation(i,e),console.error('%cUnknown option detected: "'+e+'"'+d,mi),wt=!0}static findInOptions(e,t,i,s=!1){let o=1e9,r="",a=[],d=e.toLowerCase(),h;for(let l in t){let c;if(t[l].__type__!==void 0&&s===!0){let u=L.findInOptions(e,t[l],At(i,l));o>u.distance&&(r=u.closestMatch,a=u.path,o=u.distance,h=u.indexMatch)}else l.toLowerCase().indexOf(d)!==-1&&(h=l),c=L.levenshteinDistance(e,l),o>c&&(r=l,a=xr(i),o=c)}return{closestMatch:r,path:a,distance:o,indexMatch:h}}static printLocation(e,t,i=`Problem value found at:
|
`:n.distance<=d&&o.distance>n.distance?h=" in "+G.printLocation(o.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+G.printLocation(n.path,n.closestMatch,""):o.distance<=a?h='. Did you mean "'+o.closestMatch+'"?'+G.printLocation(o.path,e):h=". Did you mean one of these: "+G.print(Object.keys(t))+G.printLocation(s,e),console.error('%cUnknown option detected: "'+e+'"'+h,ki),_t=!0}static findInOptions(e,t,s,o=!1){let n=1e9,a="",d=[],h=e.toLowerCase(),l;for(let c in t){let u;if(t[c].__type__!==void 0&&o===!0){let f=G.findInOptions(e,t[c],jt(s,c));n>f.distance&&(a=f.closestMatch,d=f.path,n=f.distance,l=f.indexMatch)}else c.toLowerCase().indexOf(h)!==-1&&(l=c),u=G.levenshteinDistance(e,c),n>u&&(a=c,d=Sr(s),n=u)}return{closestMatch:a,path:d,distance:n,indexMatch:l}}static printLocation(e,t,s=`Problem value found at:
|
||||||
`){let s=`
|
`){let o=`
|
||||||
|
|
||||||
`+i+`options = {
|
`+s+`options = {
|
||||||
`;for(let o=0;o<e.length;o++){for(let r=0;r<o+1;r++)s+=" ";s+=e[o]+`: {
|
`;for(let n=0;n<e.length;n++){for(let a=0;a<n+1;a++)o+=" ";o+=e[n]+`: {
|
||||||
`}for(let o=0;o<e.length+1;o++)s+=" ";s+=t+`
|
`}for(let n=0;n<e.length+1;n++)o+=" ";o+=t+`
|
||||||
`;for(let o=0;o<e.length+1;o++){for(let r=0;r<e.length-o;r++)s+=" ";s+=`}
|
`;for(let n=0;n<e.length+1;n++){for(let a=0;a<e.length-n;a++)o+=" ";o+=`}
|
||||||
`}return s+`
|
`}return o+`
|
||||||
|
|
||||||
`}static print(e){return JSON.stringify(e).replace(/(")|(\[)|(\])|(,"__type__")/g,"").replace(/(,)/g,", ")}static levenshteinDistance(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let i=[],s;for(s=0;s<=t.length;s++)i[s]=[s];let o;for(o=0;o<=e.length;o++)i[0][o]=o;for(s=1;s<=t.length;s++)for(o=1;o<=e.length;o++)t.charAt(s-1)==e.charAt(o-1)?i[s][o]=i[s-1][o-1]:i[s][o]=Math.min(i[s-1][o-1]+1,Math.min(i[s][o-1]+1,i[s-1][o]+1));return i[t.length][e.length]}},Hs=pe;var js=Sr,Ue=ui,Ws=Ir,yi=mi,Vs=Pr;var Ht,Mr=new Uint8Array(16);function bi(){if(!Ht&&(Ht=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ht(Mr)}var qs=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Dr(n){return typeof n=="string"&&qs.test(n)}var Us=Dr;var U=[];for(jt=0;jt<256;++jt)U.push((jt+256).toString(16).substr(1));var jt;function Fr(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(U[n[e+0]]+U[n[e+1]]+U[n[e+2]]+U[n[e+3]]+"-"+U[n[e+4]]+U[n[e+5]]+"-"+U[n[e+6]]+U[n[e+7]]+"-"+U[n[e+8]]+U[n[e+9]]+"-"+U[n[e+10]]+U[n[e+11]]+U[n[e+12]]+U[n[e+13]]+U[n[e+14]]+U[n[e+15]]).toLowerCase();if(!Us(t))throw TypeError("Stringified UUID is invalid");return t}var Ys=Fr;function Nr(n,e,t){n=n||{};var i=n.random||(n.rng||bi)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=i[s];return e}return Ys(i)}var xe=Nr;function Xs(n){return typeof n=="string"||typeof n=="number"}var Wt=class{constructor(e){X(this,"delay");X(this,"max");X(this,"_queue",[]);X(this,"_timeout",null);X(this,"_extended",null);this.delay=null,this.max=1/0,this.setOptions(e)}setOptions(e){e&&typeof e.delay!="undefined"&&(this.delay=e.delay),e&&typeof e.max!="undefined"&&(this.max=e.max),this._flushIfNeeded()}static extend(e,t){let i=new Wt(t);if(e.flush!==void 0)throw new Error("Target object already has a property flush");e.flush=()=>{i.flush()};let s=[{name:"flush",original:void 0}];if(t&&t.replace)for(let o=0;o<t.replace.length;o++){let r=t.replace[o];s.push({name:r,original:e[r]}),i.replace(e,r)}return i._extended={object:e,methods:s},i}destroy(){if(this.flush(),this._extended){let e=this._extended.object,t=this._extended.methods;for(let i=0;i<t.length;i++){let s=t[i];s.original?e[s.name]=s.original:delete e[s.name]}this._extended=null}}replace(e,t){let i=this,s=e[t];if(!s)throw new Error("Method "+t+" undefined");e[t]=function(...o){i.queue({args:o,fn:s,context:this})}}queue(e){typeof e=="function"?this._queue.push({fn:e}):this._queue.push(e),this._flushIfNeeded()}_flushIfNeeded(){this._queue.length>this.max&&this.flush(),this._timeout!=null&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&typeof this.delay=="number"&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(e=>{e.fn.apply(e.context||e.fn,e.args||[])})}},_t=class{constructor(){X(this,"_subscribers",{"*":[],add:[],remove:[],update:[]});X(this,"subscribe",_t.prototype.on);X(this,"unsubscribe",_t.prototype.off)}_trigger(e,t,i){if(e==="*")throw new Error("Cannot trigger event *");[...this._subscribers[e],...this._subscribers["*"]].forEach(s=>{s(e,t,i!=null?i:null)})}on(e,t){typeof t=="function"&&this._subscribers[e].push(t)}off(e,t){this._subscribers[e]=this._subscribers[e].filter(i=>i!==t)}},Ie=class{constructor(e){X(this,"_pairs");this._pairs=e}*[Symbol.iterator](){for(let[e,t]of this._pairs)yield[e,t]}*entries(){for(let[e,t]of this._pairs)yield[e,t]}*keys(){for(let[e]of this._pairs)yield e}*values(){for(let[,e]of this._pairs)yield e}toIdArray(){return[...this._pairs].map(e=>e[0])}toItemArray(){return[...this._pairs].map(e=>e[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){let e=Object.create(null);for(let[t,i]of this._pairs)e[t]=i;return e}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new Ie([...this._pairs])}distinct(e){let t=new Set;for(let[i,s]of this._pairs)t.add(e(s,i));return t}filter(e){let t=this._pairs;return new Ie({*[Symbol.iterator](){for(let[i,s]of t)e(s,i)&&(yield[i,s])}})}forEach(e){for(let[t,i]of this._pairs)e(i,t)}map(e){let t=this._pairs;return new Ie({*[Symbol.iterator](){for(let[i,s]of t)yield[i,e(s,i)]}})}max(e){let t=this._pairs[Symbol.iterator](),i=t.next();if(i.done)return null;let s=i.value[1],o=e(i.value[1],i.value[0]);for(;!(i=t.next()).done;){let[r,a]=i.value,d=e(a,r);d>o&&(o=d,s=a)}return s}min(e){let t=this._pairs[Symbol.iterator](),i=t.next();if(i.done)return null;let s=i.value[1],o=e(i.value[1],i.value[0]);for(;!(i=t.next()).done;){let[r,a]=i.value,d=e(a,r);d<o&&(o=d,s=a)}return s}reduce(e,t){for(let[i,s]of
Line truncated
|
`}static print(e){return JSON.stringify(e).replace(/(")|(\[)|(\])|(,"__type__")/g,"").replace(/(,)/g,", ")}static levenshteinDistance(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let s=[],o;for(o=0;o<=t.length;o++)s[o]=[o];let n;for(n=0;n<=e.length;n++)s[0][n]=n;for(o=1;o<=t.length;o++)for(n=1;n<=e.length;n++)t.charAt(o-1)==e.charAt(n-1)?s[o][n]=s[o-1][n-1]:s[o][n]=Math.min(s[o-1][n-1]+1,Math.min(s[o][n-1]+1,s[o-1][n]+1));return s[t.length][e.length]}},Vo=xe;var qo=Nr,Ze=Si,Yo=Fr,Mi=ki,Uo=Br;var qt,Ar=new Uint8Array(16);function Di(){if(!qt&&(qt=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!qt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qt(Ar)}var Xo=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function zr(r){return typeof r=="string"&&Xo.test(r)}var Go=zr;var ee=[];for(Yt=0;Yt<256;++Yt)ee.push((Yt+256).toString(16).substr(1));var Yt;function Rr(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(ee[r[e+0]]+ee[r[e+1]]+ee[r[e+2]]+ee[r[e+3]]+"-"+ee[r[e+4]]+ee[r[e+5]]+"-"+ee[r[e+6]]+ee[r[e+7]]+"-"+ee[r[e+8]]+ee[r[e+9]]+"-"+ee[r[e+10]]+ee[r[e+11]]+ee[r[e+12]]+ee[r[e+13]]+ee[r[e+14]]+ee[r[e+15]]).toLowerCase();if(!Go(t))throw TypeError("Stringified UUID is invalid");return t}var Ko=Rr;function Lr(r,e,t){r=r||{};var s=r.random||(r.rng||Di)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(var o=0;o<16;++o)e[t+o]=s[o];return e}return Ko(s)}var Ne=Lr;function $o(r){return typeof r=="string"||typeof r=="number"}var Ni=class r{constructor(e){se(this,"delay");se(this,"max");se(this,"_queue",[]);se(this,"_timeout",null);se(this,"_extended",null);this.delay=null,this.max=1/0,this.setOptions(e)}setOptions(e){e&&typeof e.delay!="undefined"&&(this.delay=e.delay),e&&typeof e.max!="undefined"&&(this.max=e.max),this._flushIfNeeded()}static extend(e,t){let s=new r(t);if(e.flush!==void 0)throw new Error("Target object already has a property flush");e.flush=()=>{s.flush()};let o=[{name:"flush",original:void 0}];if(t&&t.replace)for(let n=0;n<t.replace.length;n++){let a=t.replace[n];o.push({name:a,original:e[a]}),s.replace(e,a)}return s._extended={object:e,methods:o},s}destroy(){if(this.flush(),this._extended){let e=this._extended.object,t=this._extended.methods;for(let s=0;s<t.length;s++){let o=t[s];o.original?e[o.name]=o.original:delete e[o.name]}this._extended=null}}replace(e,t){let s=this,o=e[t];if(!o)throw new Error("Method "+t+" undefined");e[t]=function(...n){s.queue({args:n,fn:o,context:this})}}queue(e){typeof e=="function"?this._queue.push({fn:e}):this._queue.push(e),this._flushIfNeeded()}_flushIfNeeded(){this._queue.length>this.max&&this.flush(),this._timeout!=null&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&typeof this.delay=="number"&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(e=>{e.fn.apply(e.context||e.fn,e.args||[])})}},Fi=class r{constructor(){se(this,"_subscribers",{"*":[],add:[],remove:[],update:[]});se(this,"subscribe",r.prototype.on);se(this,"unsubscribe",r.prototype.off)}_trigger(e,t,s){if(e==="*")throw new Error("Cannot trigger event *");[...this._subscribers[e],...this._subscribers["*"]].forEach(o=>{o(e,t,s!=null?s:null)})}on(e,t){typeof t=="function"&&this._subscribers[e].push(t)}off(e,t){this._subscribers[e]=this._subscribers[e].filter(s=>s!==t)}},Ut=class r{constructor(e){se(this,"_pairs");this._pairs=e}*[Symbol.iterator](){for(let[e,t]of this._pairs)yield[e,t]}*entries(){for(let[e,t]of this._pairs)yield[e,t]}*keys(){for(let[e]of this._pairs)yield e}*values(){for(let[,e]of this._pairs)yield e}toIdArray(){return[...this._pairs].map(e=>e[0])}toItemArray(){return[...this._pairs].map(e=>e[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){let e=Object.create(null);for(let[t,s]of this._pairs)e[t]=s;return e}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new r([...this._pairs])}distinct(e){let t=new Set;for(let[s,o]of this._pairs)t.add(e(o,s));return t}filter(e){let t=this._pairs;return new r({*[Symbol.iterator](){for(let[s,o]of t)e(o,s)&&(yield[s,o])}})}forEach(e){for(let[t,s]of this._pairs)e(s,t)}map(e){let t=this._pairs;return new r({*[Symbol.iterator](){for(let[s,o]of t)yield[s,e(o,s)]}})}max(e){let t=this._pairs[Symbol.iterator](),s=t.next();if(s.done)return null;let o=s.value[1],n=e(s.value[1],s.value[0]);for(;!(s=t.next()).done;){let[a,d]=s.value,h=e(d,a);h>n&&(n=h,o=d)}return o}min(e){let t=this._pairs[Symbol.iterator](),s=t.next();if(s.done)return null;let o=s.value[1],n=e(s.value[1],s.value[0]);for(;!(s=t.next()).done;){let[a,d]=s.value,h=e(d,a);h<n&&(n=h,o=d)}return o
Line truncated
|
||||||
`||P==="\r";)V();do{var n=!1;if(P==="#"){for(var e=it-1;Pe.charAt(e)===" "||Pe.charAt(e)===" ";)e--;if(Pe.charAt(e)===`
|
`||B==="\r";)J();do{var r=!1;if(B==="#"){for(var e=at-1;Re.charAt(e)===" "||Re.charAt(e)===" ";)e--;if(Re.charAt(e)===`
|
||||||
`||Pe.charAt(e)===""){for(;P!=""&&P!=`
|
`||Re.charAt(e)===""){for(;B!=""&&B!=`
|
||||||
`;)V();n=!0}}if(P==="/"&&st()==="/"){for(;P!=""&&P!=`
|
`;)J();r=!0}}if(B==="/"&&nt()==="/"){for(;B!=""&&B!=`
|
||||||
`;)V();n=!0}if(P==="/"&&st()==="*"){for(;P!="";)if(P==="*"&&st()==="/"){V(),V();break}else V();n=!0}for(;P===" "||P===" "||P===`
|
`;)J();r=!0}if(B==="/"&&nt()==="*"){for(;B!="";)if(B==="*"&&nt()==="/"){J(),J();break}else J();r=!0}for(;B===" "||B===" "||B===`
|
||||||
`||P==="\r";)V()}while(n);if(P===""){ee=Z.DELIMITER;return}var t=P+st();if(eo[t]){ee=Z.DELIMITER,S=t,V(),V();return}if(eo[P]){ee=Z.DELIMITER,S=P,V();return}if(to(P)||P==="-"){for(S+=P,V();to(P);)S+=P,V();S==="false"?S=!1:S==="true"?S=!0:isNaN(Number(S))||(S=Number(S)),ee=Z.IDENTIFIER;return}if(P==='"'){for(V();P!=""&&(P!='"'||P==='"'&&st()==='"');)P==='"'?(S+=P,V()):P==="\\"&&st()==="n"?(S+=`
|
`||B==="\r";)J()}while(r);if(B===""){he=re.DELIMITER;return}var t=B+nt();if(Qo[t]){he=re.DELIMITER,M=t,J(),J();return}if(Qo[B]){he=re.DELIMITER,M=B,J();return}if(Jo(B)||B==="-"){for(M+=B,J();Jo(B);)M+=B,J();M==="false"?M=!1:M==="true"?M=!0:isNaN(Number(M))||(M=Number(M)),he=re.IDENTIFIER;return}if(B==='"'){for(J();B!=""&&(B!='"'||B==='"'&&nt()==='"');)B==='"'?(M+=B,J()):B==="\\"&&nt()==="n"?(M+=`
|
||||||
`,V()):S+=P,V();if(P!='"')throw Q('End of string " expected');V(),ee=Z.IDENTIFIER;return}for(ee=Z.UNKNOWN;P!="";)S+=P,V();throw new SyntaxError('Syntax error in part "'+ao(S,30)+'"')}function Gr(){var n={};if(Ur(),B(),S==="strict"&&(n.strict=!0,B()),(S==="graph"||S==="digraph")&&(n.type=S,B()),ee===Z.IDENTIFIER&&(n.id=S,B()),S!="{")throw Q("Angle bracket { expected");if(B(),oo(n),S!="}")throw Q("Angle bracket } expected");if(B(),S!=="")throw Q("End of file expected");return B(),delete n.node,delete n.edge,delete n.graph,n}function oo(n){for(;S!==""&&S!="}";)Kr(n),S===";"&&B()}function Kr(n){var e=no(n);if(e){ro(n,e);return}var t=$r(n);if(!t){if(ee!=Z.IDENTIFIER)throw Q("Identifier expected");var i=S;if(B(),S==="="){if(B(),ee!=Z.IDENTIFIER)throw Q("Identifier expected");n[i]=S,B()}else Zr(n,i)}}function no(n){var e=null;if(S==="subgraph"&&(e={},e.type="subgraph",B(),ee===Z.IDENTIFIER&&(e.id=S,B())),S==="{"){if(B(),e||(e={}),e.parent=n,e.node=n.node,e.edge=n.edge,e.graph=n.graph,oo(e),S!="}")throw Q("Angle bracket } expected");B(),delete e.node,delete e.edge,delete e.graph,delete e.parent,n.subgraphs||(n.subgraphs=[]),n.subgraphs.push(e)}return e}function $r(n){return S==="node"?(B(),n.node=Et(),"node"):S==="edge"?(B(),n.edge=Et(),"edge"):S==="graph"?(B(),n.graph=Et(),"graph"):null}function Zr(n,e){var t={id:e},i=Et();i&&(t.attr=i),io(n,t),ro(n,e)}function ro(n,e){for(;S==="->"||S==="--";){var t,i=S;B();var s=no(n);if(s)t=s;else{if(ee!=Z.IDENTIFIER)throw Q("Identifier or subgraph expected");t=S,io(n,{id:t}),B()}var o=Et(),r=so(n,e,t,i,o);Xr(n,r),e=t}}function Et(){for(var n,e=null,t={dashed:!0,solid:!1,dotted:[1,5]},i={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},s=new Array,o=new Array;S==="[";){for(B(),e={};S!==""&&S!="]";){if(ee!=Z.IDENTIFIER)throw Q("Attribute name expected");var r=S;if(B(),S!="=")throw Q("Equal sign = expected");if(B(),ee!=Z.IDENTIFIER)throw Q("Attribute value expected");var a=S;r==="style"&&(a=t[a]);var d;r==="arrowhead"&&(d=i[a],r="arrows",a={to:{enabled:!0,type:d}}),r==="arrowtail"&&(d=i[a],r="arrows",a={from:{enabled:!0,type:d}}),s.push({attr:e,name:r,value:a}),o.push(r),B(),S==","&&B()}if(S!="]")throw Q("Bracket ] expected");B()}if(o.includes("dir")){var h={};for(h.arrows={},n=0;n<s.length;n++)if(s[n].name==="arrows")if(s[n].value.to!=null)h.arrows.to=n;else if(s[n].value.from!=null)h.arrows.from=n;else throw Q("Invalid value of arrows");else s[n].name==="dir"&&(h.dir=n);var l=s[h.dir].value;if(!o.includes("arrows"))if(l==="both")s.push({attr:s[h.dir].attr,name:"arrows",value:{to:{enabled:!0}}}),h.arrows.to=s.length-1,s.push({attr:s[h.dir].attr,name:"arrows",value:{from:{enabled:!0}}}),h.arrows.from=s.length-1;else if(l==="forward")s.push({attr:s[h.dir].attr,name:"arrows",value:{to:{enabled:!0}}}),h.arrows.to=s.length-1;else if(l==="back")s.push({attr:s[h.dir].attr,name:"arrows",value:{from:{enabled:!0}}}),h.arrows.from=s.length-1;else if(l==="none")s.push({attr:s[h.dir].attr,name:"arrows",value:""}),h.arrows.to=s.length-1;else throw Q('Invalid dir type "'+l+'"');var c,u;if(l==="both")h.arrows.to&&h.arrows.from?(u=s[h.arrows.to].value.to.type,c=s[h.arrows.from].value.from.type,s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}},s.splice(h.arrows.from,1)):h.arrows.to?(u=s[h.arrows.to].value.to.type,c="arrow",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.from&&(u="arrow",c=s[h.arrows.from].value.from.type,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}});else if(l==="back")h.arrows.to&&h.arrows.from?(u="",c=s[h.arrows.from].value.from.type,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.to?(u="",c="arrow",h.arrows.from=h.arrows.to,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.from&&(u="",c=s[h.arrows.from].value.from.type,s[h.arrows.to]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}),s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{from:{enabled:!0,type:s[h.arrows.from].value.from.type}}};else if(l==="none"){var f;h.arrows.to?f=h.arrows.to:f=h.arrows.from,s[f]={attr:s[f].attr,name:s[f].name,value:""}}else if(l==="forward")h.arrows.to&&h.arrows.from?(u=s[h.arrows.to].value.to.type,c="",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.to?(u=s[h.arrows.to].value.to.type,c="",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.a
Line truncated
|
`,J()):M+=B,J();if(B!='"')throw ae('End of string " expected');J(),he=re.IDENTIFIER;return}for(he=re.UNKNOWN;B!="";)M+=B,J();throw new SyntaxError('Syntax error in part "'+fn(M,30)+'"')}function Jr(){var r={};if($r(),Y(),M==="strict"&&(r.strict=!0,Y()),(M==="graph"||M==="digraph")&&(r.type=M,Y()),he===re.IDENTIFIER&&(r.id=M,Y()),M!="{")throw ae("Angle bracket { expected");if(Y(),ln(r),M!="}")throw ae("Angle bracket } expected");if(Y(),M!=="")throw ae("End of file expected");return Y(),delete r.node,delete r.edge,delete r.graph,r}function ln(r){for(;M!==""&&M!="}";)ea(r),M===";"&&Y()}function ea(r){var e=cn(r);if(e){un(r,e);return}var t=ta(r);if(!t){if(he!=re.IDENTIFIER)throw ae("Identifier expected");var s=M;if(Y(),M==="="){if(Y(),he!=re.IDENTIFIER)throw ae("Identifier expected");r[s]=M,Y()}else ia(r,s)}}function cn(r){var e=null;if(M==="subgraph"&&(e={},e.type="subgraph",Y(),he===re.IDENTIFIER&&(e.id=M,Y())),M==="{"){if(Y(),e||(e={}),e.parent=r,e.node=r.node,e.edge=r.edge,e.graph=r.graph,ln(e),M!="}")throw ae("Angle bracket } expected");Y(),delete e.node,delete e.edge,delete e.graph,delete e.parent,r.subgraphs||(r.subgraphs=[]),r.subgraphs.push(e)}return e}function ta(r){return M==="node"?(Y(),r.node=kt(),"node"):M==="edge"?(Y(),r.edge=kt(),"edge"):M==="graph"?(Y(),r.graph=kt(),"graph"):null}function ia(r,e){var t={id:e},s=kt();s&&(t.attr=s),dn(r,t),un(r,e)}function un(r,e){for(;M==="->"||M==="--";){var t,s=M;Y();var o=cn(r);if(o)t=o;else{if(he!=re.IDENTIFIER)throw ae("Identifier or subgraph expected");t=M,dn(r,{id:t}),Y()}var n=kt(),a=hn(r,e,t,s,n);Qr(r,a),e=t}}function kt(){for(var r,e=null,t={dashed:!0,solid:!1,dotted:[1,5]},s={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},o=new Array,n=new Array;M==="[";){for(Y(),e={};M!==""&&M!="]";){if(he!=re.IDENTIFIER)throw ae("Attribute name expected");var a=M;if(Y(),M!="=")throw ae("Equal sign = expected");if(Y(),he!=re.IDENTIFIER)throw ae("Attribute value expected");var d=M;a==="style"&&(d=t[d]);var h;a==="arrowhead"&&(h=s[d],a="arrows",d={to:{enabled:!0,type:h}}),a==="arrowtail"&&(h=s[d],a="arrows",d={from:{enabled:!0,type:h}}),o.push({attr:e,name:a,value:d}),n.push(a),Y(),M==","&&Y()}if(M!="]")throw ae("Bracket ] expected");Y()}if(n.includes("dir")){var l={};for(l.arrows={},r=0;r<o.length;r++)if(o[r].name==="arrows")if(o[r].value.to!=null)l.arrows.to=r;else if(o[r].value.from!=null)l.arrows.from=r;else throw ae("Invalid value of arrows");else o[r].name==="dir"&&(l.dir=r);var c=o[l.dir].value;if(!n.includes("arrows"))if(c==="both")o.push({attr:o[l.dir].attr,name:"arrows",value:{to:{enabled:!0}}}),l.arrows.to=o.length-1,o.push({attr:o[l.dir].attr,name:"arrows",value:{from:{enabled:!0}}}),l.arrows.from=o.length-1;else if(c==="forward")o.push({attr:o[l.dir].attr,name:"arrows",value:{to:{enabled:!0}}}),l.arrows.to=o.length-1;else if(c==="back")o.push({attr:o[l.dir].attr,name:"arrows",value:{from:{enabled:!0}}}),l.arrows.from=o.length-1;else if(c==="none")o.push({attr:o[l.dir].attr,name:"arrows",value:""}),l.arrows.to=o.length-1;else throw ae('Invalid dir type "'+c+'"');var u,f;if(c==="both")l.arrows.to&&l.arrows.from?(f=o[l.arrows.to].value.to.type,u=o[l.arrows.from].value.from.type,o[l.arrows.to]={attr:o[l.arrows.to].attr,name:o[l.arrows.to].name,value:{to:{enabled:!0,type:f},from:{enabled:!0,type:u}}},o.splice(l.arrows.from,1)):l.arrows.to?(f=o[l.arrows.to].value.to.type,u="arrow",o[l.arrows.to]={attr:o[l.arrows.to].attr,name:o[l.arrows.to].name,value:{to:{enabled:!0,type:f},from:{enabled:!0,type:u}}}):l.arrows.from&&(f="arrow",u=o[l.arrows.from].value.from.type,o[l.arrows.from]={attr:o[l.arrows.from].attr,name:o[l.arrows.from].name,value:{to:{enabled:!0,type:f},from:{enabled:!0,type:u}}});else if(c==="back")l.arrows.to&&l.arrows.from?(f="",u=o[l.arrows.from].value.from.type,o[l.arrows.from]={attr:o[l.arrows.from].attr,name:o[l.arrows.from].name,value:{to:{enabled:!0,type:f},from:{enabled:!0,type:u}}}):l.arrows.to?(f="",u="arrow",l.arrows.from=l.arrows.to,o[l.arrows.from]={attr:o[l.arrows.from].attr,name:o[l.arrows.from].name,value:{to:{enabled:!0,type:f},from:{enabled:!0,type:u}}}):l.arrows.from&&(f="",u=o[l.arrows.from].value.from.type,o[l.arrows.to]={attr:o[l.arrows.from].attr,name:o[l.arrows.from].name,value:{to:{enabled:!0,type:f},from:{enabled:!0,type:u}}}),o[l.arrows.from]={attr:o[l.arrows.from].attr,name:o[l.arrows.from].name,value:{from:{enabled:!0,type:o[l.arrows.from].value.from.type}}};else if(c==="none"){var p;l.arrows.to?p=l.arrows.to:p=l.arrows.from,o[p]={attr:o[p].attr,name:o[p].name,value:""}}else if(c==="forward")l.arrows.to&&l.arrows.from?(f=o[l.arrows.to].value.to.type,u="",o[l.arrows.to]={attr:o[l.arrows.to].attr,name:o[l.arrows.to].name,value:{to:{enabled:!0,type:f},from:{enabled:!0,type:u}}}):l.arrows.to?(f=o[l.arrows.to].value.to.type,u="",o[l.arrows.to]={attr:o[l.arrows.to].attr,name:o[l.arrows.to].name,value:{to:{enabled:!0,type:f},from:{en
Line truncated
|
||||||
`),e=e.replace(/\r/g,`
|
`),e=e.replace(/\r/g,`
|
||||||
`);let i=String(e).split(`
|
`);let s=String(e).split(`
|
||||||
`),s=i.length;if(t.multi)for(let o=0;o<s;o++){let r=this.splitBlocks(i[o],t.multi);if(r!==void 0){if(r.length===0){this.lines.newLine("");continue}if(t.maxWdt>0)for(let a=0;a<r.length;a++){let d=r[a].mod,h=r[a].text;this.splitStringIntoLines(h,d,!0)}else for(let a=0;a<r.length;a++){let d=r[a].mod,h=r[a].text;this.lines.append(h,d)}this.lines.newLine()}}else if(t.maxWdt>0)for(let o=0;o<s;o++)this.splitStringIntoLines(i[o]);else for(let o=0;o<s;o++)this.lines.newLine(i[o]);return this.lines.finalize()}decodeMarkupSystem(e){let t="none";return e==="markdown"||e==="md"?t="markdown":(e===!0||e==="html")&&(t="html"),t}splitHtmlBlocks(e){let t=new ki(e),i=s=>/&/.test(s)?(t.replace(t.text,"<","<")||t.replace(t.text,"&","&")||t.add("&"),!0):!1;for(;t.position<t.text.length;){let s=t.text.charAt(t.position);t.parseWS(s)||/</.test(s)&&(t.parseStartTag("bold","<b>")||t.parseStartTag("ital","<i>")||t.parseStartTag("mono","<code>")||t.parseEndTag("bold","</b>")||t.parseEndTag("ital","</i>")||t.parseEndTag("mono","</code>"))||i(s)||t.add(s),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new ki(e),i=!0,s=o=>/\\/.test(o)?(t.position<this.text.length+1&&(t.position++,o=this.text.charAt(t.position),/ \t/.test(o)?t.spacing=!0:(t.add(o),i=!1)),!0):!1;for(;t.position<t.text.length;){let o=t.text.charAt(t.position);t.parseWS(o)||s(o)||(i||t.spacing)&&(t.parseStartTag("bold","*")||t.parseStartTag("ital","_")||t.parseStartTag("mono","`"))||t.parseEndTag("bold","*","afterBold")||t.parseEndTag("ital","_","afterItal")||t.parseEndTag("mono","`","afterMono")||(t.add(o),i=!1),t.position++}return t.emitBlock(),t.blocks}splitBlocks(e,t){let i=this.decodeMarkupSystem(t);if(i==="none")return[{text:e,mod:"normal"}];if(i==="markdown")return this.splitMarkdownBlocks(e);if(i==="html")return this.splitHtmlBlocks(e)}overMaxWidth(e){let t=this.ctx.measureText(e).width;return this.lines.curWidth()+t>this.parent.fontOptions.maxWdt}getLongestFit(e){let t="",i=0;for(;i<e.length;){let o=t+(t===""?"":" ")+e[i];if(this.overMaxWidth(o))break;t=o,i++}return i}getLongestFitWord(e){let t=0;for(;t<e.length&&!this.overMaxWidth(e.slice(0,t));)t++;return t}splitStringIntoLines(e,t="normal",i=!1){this.parent.getFormattingValues(this.ctx,this.selected,this.hover,t),e=e.replace(/^( +)/g,"$1\r"),e=e.replace(/([^\r][^ ]*)( +)/g,"$1\r$2\r");let s=e.split("\r");for(;s.length>0;){let o=this.getLongestFit(s);if(o===0){let r=s[0],a=this.getLongestFitWord(r);this.lines.newLine(r.slice(0,a),t),s[0]=r.slice(a)}else{let r=o;s[o-1]===" "?o--:s[r]===" "&&r++;let a=s.slice(0,o).join("");o==s.length&&i?this.lines.append(a,t):this.lines.newLine(a,t),s=s.slice(r)}}}},Ut=["bold","ital","boldital","mono"],Ye=class{constructor(e,t,i=!1){this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(t),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=i}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),qt(e.label)?this.labelDirty=!0:e.label=void 0,e.font!==void 0&&e.font!==null){if(typeof e.font=="string")this.baseSize=this.fontOptions.size;else if(typeof e.font=="object"){let t=e.font.size;t!==void 0&&(this.baseSize=t)}}}initFontOptions(e){if(I(Ut,t=>{this.fontOptions[t]={}}),Ye.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}I(e,(t,i)=>{t!=null&&typeof t!="object"&&(this.fontOptions[i]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let i=t.split(" ");return e.size=+i[0].replace("px",""),e.face=i[1],e.color=i[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},i=Ee(e,"widthConstraint");if(typeof i=="number")t.maxWdt=Number(i),t.minWdt=Number(i);else if(typeof i=="object"){let o=Ee(e,["widthConstraint","maximum"]);typeof o=="number"&&(t.maxWdt=Number(o));let r=Ee(e,["widthConstraint","minimum"]);typeof r=="number"&&(t.minWdt=Number(r))}let s=Ee(e,"heightConstraint");if(typeof s=="number")t.minHgt=Number(s);else if(typeof s=="object"){let o=Ee(e,["heightConstraint","minimum"]);typeof o=="number"&&(t.minHgt=Number(o));let r=Ee(e,["heightConstraint","valign"]);typeof r=="string"&&(r==="top"||r==="bottom")&&(t.valign=r)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),D(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=Ci("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let i=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=i)}addFontOptionsToPile(e,t){for(let i=0;i<t.length;++i)this.addFontToPile(e,t[i])}addFontToPile(e,t){if(t===void 0||t.font===void 0||t.font===null)return;let i=t.font;e.push(i)}getBasicOptions(e){let t={};for(let i=0;i<e.length;++i){let s=e[i],o={};Ye.parseFontString(o,s)&&(s=o),I(s,(r,a)=>{r!==void 0&&(Object.prototype.hasOwnProperty.call(t,a)||(Ut.indexOf(a)!==-1?t[a]={}:t[a]=r))})}return t}getFontOption(e,t,i){let s;for(let o=0;
Line truncated
|
`),o=s.length;if(t.multi)for(let n=0;n<o;n++){let a=this.splitBlocks(s[n],t.multi);if(a!==void 0){if(a.length===0){this.lines.newLine("");continue}if(t.maxWdt>0)for(let d=0;d<a.length;d++){let h=a[d].mod,l=a[d].text;this.splitStringIntoLines(l,h,!0)}else for(let d=0;d<a.length;d++){let h=a[d].mod,l=a[d].text;this.lines.append(l,h)}this.lines.newLine()}}else if(t.maxWdt>0)for(let n=0;n<o;n++)this.splitStringIntoLines(s[n]);else for(let n=0;n<o;n++)this.lines.newLine(s[n]);return this.lines.finalize()}decodeMarkupSystem(e){let t="none";return e==="markdown"||e==="md"?t="markdown":(e===!0||e==="html")&&(t="html"),t}splitHtmlBlocks(e){let t=new Zt(e),s=o=>/&/.test(o)?(t.replace(t.text,"<","<")||t.replace(t.text,"&","&")||t.add("&"),!0):!1;for(;t.position<t.text.length;){let o=t.text.charAt(t.position);t.parseWS(o)||/</.test(o)&&(t.parseStartTag("bold","<b>")||t.parseStartTag("ital","<i>")||t.parseStartTag("mono","<code>")||t.parseEndTag("bold","</b>")||t.parseEndTag("ital","</i>")||t.parseEndTag("mono","</code>"))||s(o)||t.add(o),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new Zt(e),s=!0,o=n=>/\\/.test(n)?(t.position<this.text.length+1&&(t.position++,n=this.text.charAt(t.position),/ \t/.test(n)?t.spacing=!0:(t.add(n),s=!1)),!0):!1;for(;t.position<t.text.length;){let n=t.text.charAt(t.position);t.parseWS(n)||o(n)||(s||t.spacing)&&(t.parseStartTag("bold","*")||t.parseStartTag("ital","_")||t.parseStartTag("mono","`"))||t.parseEndTag("bold","*","afterBold")||t.parseEndTag("ital","_","afterItal")||t.parseEndTag("mono","`","afterMono")||(t.add(n),s=!1),t.position++}return t.emitBlock(),t.blocks}splitBlocks(e,t){let s=this.decodeMarkupSystem(t);if(s==="none")return[{text:e,mod:"normal"}];if(s==="markdown")return this.splitMarkdownBlocks(e);if(s==="html")return this.splitHtmlBlocks(e)}overMaxWidth(e){let t=this.ctx.measureText(e).width;return this.lines.curWidth()+t>this.parent.fontOptions.maxWdt}getLongestFit(e){let t="",s=0;for(;s<e.length;){let n=t+(t===""?"":" ")+e[s];if(this.overMaxWidth(n))break;t=n,s++}return s}getLongestFitWord(e){let t=0;for(;t<e.length&&!this.overMaxWidth(e.slice(0,t));)t++;return t}splitStringIntoLines(e,t="normal",s=!1){this.parent.getFormattingValues(this.ctx,this.selected,this.hover,t),e=e.replace(/^( +)/g,"$1\r"),e=e.replace(/([^\r][^ ]*)( +)/g,"$1\r$2\r");let o=e.split("\r");for(;o.length>0;){let n=this.getLongestFit(o);if(n===0){let a=o[0],d=this.getLongestFitWord(a);this.lines.newLine(a.slice(0,d),t),o[0]=a.slice(d)}else{let a=n;o[n-1]===" "?n--:o[a]===" "&&a++;let d=o.slice(0,n).join("");n==o.length&&s?this.lines.append(d,t):this.lines.newLine(d,t),o=o.slice(a)}}}},Gt=["bold","ital","boldital","mono"],Qt=class r{constructor(e,t,s=!1){this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(t),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=s}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),$t(e.label)?this.labelDirty=!0:e.label=void 0,e.font!==void 0&&e.font!==null){if(typeof e.font=="string")this.baseSize=this.fontOptions.size;else if(typeof e.font=="object"){let t=e.font.size;t!==void 0&&(this.baseSize=t)}}}initFontOptions(e){if(F(Gt,t=>{this.fontOptions[t]={}}),r.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}F(e,(t,s)=>{t!=null&&typeof t!="object"&&(this.fontOptions[s]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let s=t.split(" ");return e.size=+s[0].replace("px",""),e.face=s[1],e.color=s[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},s=De(e,"widthConstraint");if(typeof s=="number")t.maxWdt=Number(s),t.minWdt=Number(s);else if(typeof s=="object"){let n=De(e,["widthConstraint","maximum"]);typeof n=="number"&&(t.maxWdt=Number(n));let a=De(e,["widthConstraint","minimum"]);typeof a=="number"&&(t.minWdt=Number(a))}let o=De(e,"heightConstraint");if(typeof o=="number")t.minHgt=Number(o);else if(typeof o=="object"){let n=De(e,["heightConstraint","minimum"]);typeof n=="number"&&(t.minHgt=Number(n));let a=De(e,["heightConstraint","valign"]);typeof a=="string"&&(a==="top"||a==="bottom")&&(t.valign=a)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),V(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=js("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let s=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=s)}addFontOptionsToPile(e,t){for(let s=0;s<t.length;++s)this.addFontToPile(e,t[s])}addFontToPile(e,t){if(t===void 0||t.font===void 0||t.font===null)return;let s=t.font;e.push(s)}getBasicOptions(e){let t={};for(let s=0;s<e.length;++s){let o=e[s],n={};r.parseFontString(n,o)&&(o=n),F(o,(a,d)=>{a!==void 0&&(Object.prototype.hasOwnProperty.call(t,d)||(Gt.indexOf(d)!==-1?t[d]={}:t[d]=a))})}return t}getFontOption(e,t,s){let o;for(let n=0;
Line truncated
|
||||||
/*! Hammer.JS - v2.0.17-rc - 2019-12-16
|
/*! Bundled license information:
|
||||||
* http://naver.github.io/egjs
|
|
||||||
*
|
@egjs/hammerjs/dist/hammer.esm.js:
|
||||||
* Forked By Naver egjs
|
(*! Hammer.JS - v2.0.17-rc - 2019-12-16
|
||||||
* Copyright (c) hammerjs
|
* http://naver.github.io/egjs
|
||||||
* Licensed under the MIT license */
|
*
|
||||||
/**
|
* Forked By Naver egjs
|
||||||
* vis-data
|
* Copyright (c) hammerjs
|
||||||
* http://visjs.org/
|
* Licensed under the MIT license *)
|
||||||
*
|
|
||||||
* Manage unstructured data using DataSet. Add, update, and remove data, and listen for changes in the data.
|
vis-util/esnext/esm/vis-util.js:
|
||||||
*
|
(**
|
||||||
* @version 7.1.9
|
* vis-util
|
||||||
* @date 2023-11-24T17:53:34.179Z
|
* https://github.com/visjs/vis-util
|
||||||
*
|
*
|
||||||
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
* utilitie collection for visjs
|
||||||
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
*
|
||||||
*
|
* @version 5.0.7
|
||||||
* @license
|
* @date 2023-11-20T09:06:51.067Z
|
||||||
* vis.js is dual licensed under both
|
*
|
||||||
*
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
||||||
* 1. The Apache 2.0 License
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
*
|
||||||
*
|
* @license
|
||||||
* and
|
* vis.js is dual licensed under both
|
||||||
*
|
*
|
||||||
* 2. The MIT License
|
* 1. The Apache 2.0 License
|
||||||
* http://opensource.org/licenses/MIT
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* vis.js may be distributed under either license.
|
* and
|
||||||
*/
|
*
|
||||||
/**
|
* 2. The MIT License
|
||||||
* vis-network
|
* http://opensource.org/licenses/MIT
|
||||||
* https://visjs.github.io/vis-network/
|
*
|
||||||
*
|
* vis.js may be distributed under either license.
|
||||||
* A dynamic, browser-based visualization library.
|
*)
|
||||||
*
|
|
||||||
* @version 9.1.9
|
vis-data/esnext/esm/vis-data.js:
|
||||||
* @date 2023-11-03T01:42:27.418Z
|
(**
|
||||||
*
|
* vis-data
|
||||||
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
* http://visjs.org/
|
||||||
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
*
|
||||||
*
|
* Manage unstructured data using DataSet. Add, update, and remove data, and listen for changes in the data.
|
||||||
* @license
|
*
|
||||||
* vis.js is dual licensed under both
|
* @version 7.1.9
|
||||||
*
|
* @date 2023-11-24T17:53:34.179Z
|
||||||
* 1. The Apache 2.0 License
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
||||||
*
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
||||||
* and
|
*
|
||||||
*
|
* @license
|
||||||
* 2. The MIT License
|
* vis.js is dual licensed under both
|
||||||
* http://opensource.org/licenses/MIT
|
*
|
||||||
*
|
* 1. The Apache 2.0 License
|
||||||
* vis.js may be distributed under either license.
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*
|
||||||
/**
|
* and
|
||||||
* vis-util
|
*
|
||||||
* https://github.com/visjs/vis-util
|
* 2. The MIT License
|
||||||
*
|
* http://opensource.org/licenses/MIT
|
||||||
* utilitie collection for visjs
|
*
|
||||||
*
|
* vis.js may be distributed under either license.
|
||||||
* @version 5.0.7
|
*)
|
||||||
* @date 2023-11-20T09:06:51.067Z
|
|
||||||
*
|
vis-network/esnext/esm/vis-network.js:
|
||||||
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
(**
|
||||||
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
* vis-network
|
||||||
*
|
* https://visjs.github.io/vis-network/
|
||||||
* @license
|
*
|
||||||
* vis.js is dual licensed under both
|
* A dynamic, browser-based visualization library.
|
||||||
*
|
*
|
||||||
* 1. The Apache 2.0 License
|
* @version 9.1.10
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* @date 2025-05-10T16:57:42.930Z
|
||||||
*
|
*
|
||||||
* and
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
||||||
*
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
||||||
* 2. The MIT License
|
*
|
||||||
* http://opensource.org/licenses/MIT
|
* @license
|
||||||
*
|
* vis.js is dual licensed under both
|
||||||
* vis.js may be distributed under either license.
|
*
|
||||||
*/
|
* 1. The Apache 2.0 License
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* and
|
||||||
|
*
|
||||||
|
* 2. The MIT License
|
||||||
|
* http://opensource.org/licenses/MIT
|
||||||
|
*
|
||||||
|
* vis.js may be distributed under either license.
|
||||||
|
*)
|
||||||
|
*/
|
||||||
@@ -1 +1 @@
|
|||||||
(()=>{var l=(e,t,o)=>new Promise((n,r)=>{var c=s=>{try{i(o.next(s))}catch(a){r(a)}},m=s=>{try{i(o.throw(s))}catch(a){r(a)}},i=s=>s.done?n(s.value):Promise.resolve(s.value).then(c,m);i((o=o.apply(e,t)).next())});var d=e=>{if(!document.cookie)return;let t=null,o=document.cookie.split(";");for(let n=0;n<o.length;n++){let r=o[n].trim();if(r.substring(0,e.length+1)===e+"="){t=decodeURIComponent(r.substring(e.length+1));break}}return t};var u={success:e=>{let t=document.querySelector("#topology-plugin-success-toast");if(!t)return console.error("Could not find toast component!");let o=t.querySelector("span");o.textContent=e,new window.Toast(t).show()},error:e=>{let t=document.querySelector("#topology-plugin-error-toast");if(!t)return console.error("Could not find toast component!");let o=t.querySelector("span");o.textContent=e,new window.Toast(t).show()}};var g={},p=d("csrftoken");document.querySelector("form#images").addEventListener("submit",e=>l(void 0,null,function*(){e.preventDefault();try{let t=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/images/save/",{method:"POST",body:JSON.stringify(g),headers:{"X-CSRFToken":p,"Content-Type":"application/json"}});if(!t.ok)throw new Error(yield t.text());u.success("Saved settings")}catch(t){console.dir(t),u.error(t.message)}}));document.querySelectorAll("form#images .dropdown-menu img").forEach(e=>{e.addEventListener("click",t=>{var c;if(!(t.currentTarget instanceof HTMLElement))return;let{dataset:{role:o,image:n}}=t.currentTarget;g[o]=n;let r=(c=t.currentTarget.closest(".dropdown"))==null?void 0:c.querySelector(`#dropdownMenuButton${o}`);r&&(r.innerHTML=`<img src="${n}" />`)})});})();
|
(()=>{var w=(o,t)=>()=>(o&&(t=o(o=0)),t);var f=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var l=(o,t,e)=>new Promise((r,s)=>{var c=n=>{try{a(e.next(n))}catch(i){s(i)}},g=n=>{try{a(e.throw(n))}catch(i){s(i)}},a=n=>n.done?r(n.value):Promise.resolve(n.value).then(c,g);a((e=e.apply(o,t)).next())});var u,d=w(()=>{u={success:o=>{let t=document.querySelector("#topology-plugin-success-toast");if(!t)return console.error("Could not find toast component!");let e=t.querySelector("span");e.textContent=o,new window.Toast(t).show()},error:o=>{let t=document.querySelector("#topology-plugin-error-toast");if(!t)return console.error("Could not find toast component!");let e=t.querySelector("span");e.textContent=o,new window.Toast(t).show()}}});var y=f(p=>{d();var m={};document.querySelector("form#images").addEventListener("submit",o=>l(null,null,function*(){o.preventDefault();try{let t=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/images/save/",{method:"POST",body:JSON.stringify(m),headers:{"X-CSRFToken":window.CSRF_TOKEN,"Content-Type":"application/json"}});if(!t.ok)throw new Error(yield t.text());u.success("Saved settings")}catch(t){console.dir(t),u.error(t.message)}}));document.querySelectorAll("form#images .dropdown-menu img").forEach(o=>{o.addEventListener("click",t=>{var c;if(!(t.currentTarget instanceof HTMLElement))return;let{dataset:{role:e,image:r}}=t.currentTarget;m[e]=r;let s=(c=t.currentTarget.closest(".dropdown"))==null?void 0:c.querySelector(`#dropdownMenuButton${e}`);s&&(s.innerHTML=`<img src="${r}" />`)})})});y();})();
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": 3,
|
"version": 3,
|
||||||
"sources": ["../../../static_dev/js/csrftoken.js", "../../../static_dev/js/toast.js", "../../../static_dev/js/images.js"],
|
"sources": ["../../../static_dev/js/toast.js", "../../../static_dev/js/images.js"],
|
||||||
"mappings": "mNAAO,GAAM,GAAY,AAAC,GAAS,CAC/B,GAAI,CAAC,SAAS,OAAQ,OAEtB,GAAI,GAAc,KACZ,EAAU,SAAS,OAAO,MAAM,KAEtC,OAAS,GAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACrC,GAAM,GAAS,EAAQ,GAAG,OAE1B,GAAI,EAAO,UAAU,EAAG,EAAK,OAAS,KAAO,EAAO,IAAK,CACrD,EAAc,mBAAmB,EAAO,UAAU,EAAK,OAAS,IAChE,OAIR,MAAO,ICfJ,GAAM,GAAQ,CACjB,QAAS,AAAC,GAAY,CAClB,GAAM,GAAK,SAAS,cAAc,kCAClC,GAAI,CAAC,EAAI,MAAO,SAAQ,MAAM,mCAC9B,GAAM,GAAU,EAAG,cAAc,QACjC,EAAQ,YAAc,EAEtB,AADc,GAAI,QAAO,MAAM,GACzB,QAEV,MAAO,AAAC,GAAY,CAChB,GAAM,GAAK,SAAS,cAAc,gCAClC,GAAI,CAAC,EAAI,MAAO,SAAQ,MAAM,mCAC9B,GAAM,GAAU,EAAG,cAAc,QACjC,EAAQ,YAAc,EAEtB,AADc,GAAI,QAAO,MAAM,GACzB,SCZd,GAAM,GAAU,GACV,EAAY,EAAU,aAE5B,SAAS,cAAc,eAAe,iBAAiB,SAAU,AAAO,GAAM,0BAC1E,EAAE,iBACF,GAAI,CACA,GAAM,GAAM,KAAM,OAAM,IAAM,SAAW,iDAAkD,CACvF,OAAQ,OACR,KAAM,KAAK,UAAU,GACrB,QAAS,CACL,cAAe,EACf,eAAgB,sBAIxB,GAAI,CAAC,EAAI,GAAI,KAAM,IAAI,OAAM,KAAM,GAAI,QACvC,EAAM,QAAQ,wBACT,EAAP,CACE,QAAQ,IAAI,GACZ,EAAM,MAAM,EAAI,aAIxB,SAAS,iBAAiB,kCAAkC,QAAQ,AAAC,GAAO,CACxE,EAAG,iBAAiB,QAAS,AAAC,GAAM,CA3BxC,MA4BQ,GAAI,CAAE,GAAE,wBAAyB,cAAc,OAC/C,GAAM,CACF,QAAS,CAAE,OAAM,UACjB,EAAE,cAEN,EAAQ,GAAQ,EAEhB,GAAM,GAAS,KAAE,cACZ,QAAQ,eADE,cAET,cAAc,sBAAsB,KAC1C,AAAI,GAAQ,GAAO,UAAY,aAAa",
|
"mappings": "oTAAA,IAAaA,EAAbC,EAAAC,EAAA,KAAaF,EAAQ,CACjB,QAAUG,GAAY,CAClB,IAAMC,EAAK,SAAS,cAAc,gCAAgC,EAClE,GAAI,CAACA,EAAI,OAAO,QAAQ,MAAM,iCAAiC,EAC/D,IAAMC,EAAUD,EAAG,cAAc,MAAM,EACvCC,EAAQ,YAAcF,EACR,IAAI,OAAO,MAAMC,CAAE,EAC3B,KAAK,CACf,EACA,MAAQD,GAAY,CAChB,IAAMC,EAAK,SAAS,cAAc,8BAA8B,EAChE,GAAI,CAACA,EAAI,OAAO,QAAQ,MAAM,iCAAiC,EAC/D,IAAMC,EAAUD,EAAG,cAAc,MAAM,EACvCC,EAAQ,YAAcF,EACR,IAAI,OAAO,MAAMC,CAAE,EAC3B,KAAK,CACf,CACJ,ICjBA,IAAAE,EAAAC,EAAAC,GAAA,CAAAC,IAEA,IAAMC,EAAU,CAAC,EAEjB,SAAS,cAAc,aAAa,EAAE,iBAAiB,SAAiBC,GAAMC,EAAA,sBAC1ED,EAAE,eAAe,EACjB,GAAI,CACA,IAAME,EAAM,MAAM,MAAM,IAAM,SAAW,iDAAkD,CACvF,OAAQ,OACR,KAAM,KAAK,UAAUH,CAAO,EAC5B,QAAS,CACL,cAAe,OAAO,WACtB,eAAgB,kBACpB,CACJ,CAAC,EAED,GAAI,CAACG,EAAI,GAAI,MAAM,IAAI,MAAM,MAAMA,EAAI,KAAK,CAAC,EAC7CC,EAAM,QAAQ,gBAAgB,CAClC,OAASC,EAAK,CACV,QAAQ,IAAIA,CAAG,EACfD,EAAM,MAAMC,EAAI,OAAO,CAC3B,CACJ,EAAC,EAED,SAAS,iBAAiB,gCAAgC,EAAE,QAASC,GAAO,CACxEA,EAAG,iBAAiB,QAAUL,GAAM,CAzBxC,IAAAM,EA0BQ,GAAI,EAAEN,EAAE,yBAAyB,aAAc,OAC/C,GAAM,CACF,QAAS,CAAE,KAAAO,EAAM,MAAAC,CAAM,CAC3B,EAAIR,EAAE,cAEND,EAAQQ,CAAI,EAAIC,EAEhB,IAAMC,GAASH,EAAAN,EAAE,cACZ,QAAQ,WAAW,IADT,YAAAM,EAET,cAAc,sBAAsBC,CAAI,IAC1CE,IAAQA,EAAO,UAAY,aAAaD,CAAK,OACrD,CAAC,CACL,CAAC",
|
||||||
"names": []
|
"names": ["toast", "init_toast", "__esmMin", "message", "el", "content", "require_images", "__commonJSMin", "exports", "init_toast", "mapping", "e", "__async", "res", "toast", "err", "el", "_a", "role", "image", "button"]
|
||||||
}
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
export const getCookie = (name) => {
|
|
||||||
if (!document.cookie) return
|
|
||||||
|
|
||||||
let cookieValue = null
|
|
||||||
const cookies = document.cookie.split(';')
|
|
||||||
|
|
||||||
for (let i = 0; i < cookies.length; i++) {
|
|
||||||
const cookie = cookies[i].trim()
|
|
||||||
// Does this cookie string begin with the name we want?
|
|
||||||
if (cookie.substring(0, name.length + 1) === name + '=') {
|
|
||||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cookieValue
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { DataSet } from 'vis-data/esnext'
|
import { DataSet } from 'vis-data/esnext'
|
||||||
import { Network } from 'vis-network/esnext'
|
import { Network } from 'vis-network/esnext'
|
||||||
import { getCookie } from './csrftoken.js'
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
interaction: {
|
interaction: {
|
||||||
@@ -36,9 +35,6 @@ const options = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load CSRF token
|
|
||||||
const csrftoken = getCookie('csrftoken')
|
|
||||||
|
|
||||||
// Render vis graph
|
// Render vis graph
|
||||||
let graph = null // vis graph instance
|
let graph = null // vis graph instance
|
||||||
|
|
||||||
@@ -73,11 +69,131 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
const group_sites = topologyData.options.group_sites
|
const group_sites = topologyData.options.group_sites
|
||||||
const group_locations = topologyData.options.group_locations
|
const group_locations = topologyData.options.group_locations
|
||||||
const group_racks = topologyData.options.group_racks
|
const group_racks = topologyData.options.group_racks
|
||||||
|
const group_virtualchassis = topologyData.options.group_virtualchassis
|
||||||
|
|
||||||
|
const gridSize = parseInt(topologyData.options.grid_size[0]);
|
||||||
|
var dragMode = false;
|
||||||
|
|
||||||
graph = new Network(container, { nodes, edges }, options)
|
graph = new Network(container, { nodes, edges }, options)
|
||||||
graph.fit()
|
graph.fit()
|
||||||
|
|
||||||
|
function getGridPosition(nodeId, gridSize) {
|
||||||
|
x = graph.getPosition(nodeId).x;
|
||||||
|
y = graph.getPosition(nodeId).y;
|
||||||
|
|
||||||
|
if(x >= 0) {
|
||||||
|
if((x % gridSize) > (gridSize / 2)) {
|
||||||
|
x += gridSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if((-x % gridSize) > (gridSize / 2)) {
|
||||||
|
x -= gridSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x = x - x % gridSize;
|
||||||
|
|
||||||
|
if(y >= 0) {
|
||||||
|
if((y % gridSize) > (gridSize / 2)) {
|
||||||
|
y += gridSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if((-y % gridSize) > (gridSize / 2)) {
|
||||||
|
y -= gridSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
y = y - y % gridSize;
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: x,
|
||||||
|
y: y
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawGrid(canvascontext) {
|
||||||
|
// Canvas can be zoomed. It then contains more or less virtual pixels than the real number of pixels
|
||||||
|
const zoomFactor = graph.getScale() * window.devicePixelRatio;
|
||||||
|
const virtualWidth = canvascontext.canvas.width / zoomFactor;
|
||||||
|
const virtualHeight = canvascontext.canvas.height / zoomFactor;
|
||||||
|
|
||||||
|
// Canvas can be moved. Get the center of the virtual canvas. Take the grid into account
|
||||||
|
const virtualCenter = graph.getViewPosition();
|
||||||
|
const rasterizedCenterX = virtualCenter.x - virtualCenter.x % gridSize;
|
||||||
|
const rasterizedCenterY = virtualCenter.y - virtualCenter.y % gridSize;
|
||||||
|
|
||||||
|
// Calculate virtual space for the grid
|
||||||
|
const hSpace = (virtualWidth / 2) - (virtualWidth / 2) % gridSize + gridSize;
|
||||||
|
const vSpace = (virtualHeight / 2) - (virtualHeight / 2) % gridSize + gridSize;
|
||||||
|
|
||||||
|
// Calculate virtual position for the grid
|
||||||
|
const left = rasterizedCenterX - gridSize - hSpace;
|
||||||
|
const right = rasterizedCenterX + gridSize + hSpace;
|
||||||
|
const top = rasterizedCenterY - gridSize - vSpace;
|
||||||
|
const bottom = rasterizedCenterY + gridSize + vSpace;
|
||||||
|
|
||||||
|
// Draw grid
|
||||||
|
canvascontext.beginPath();
|
||||||
|
|
||||||
|
for (let x = left; x < right; x += gridSize) {
|
||||||
|
canvascontext.moveTo(x, top);
|
||||||
|
canvascontext.lineTo(x, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let y = top; y < bottom; y += gridSize) {
|
||||||
|
canvascontext.moveTo(left, y);
|
||||||
|
canvascontext.lineTo(right, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
canvascontext.strokeStyle = '#777777';
|
||||||
|
canvascontext.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawGridSnapHint(canvascontext) {
|
||||||
|
// Draw grid hinting line and circle
|
||||||
|
if(gridSize > 0 && dragMode == true && graph.getSelectedNodes().length > 0) {
|
||||||
|
for(i = 0; i < graph.getSelectedNodes().length; i++) {
|
||||||
|
id = graph.getSelectedNodes()[i];
|
||||||
|
if(window.nodes.get(id).x != graph.getPosition(id).x || window.nodes.get(id).y != graph.getPosition(id).y) {
|
||||||
|
pos = getGridPosition(graph.getSelectedNodes()[i], gridSize);
|
||||||
|
|
||||||
|
canvascontext.beginPath();
|
||||||
|
canvascontext.arc(graph.getPosition(graph.getSelectedNodes()[i]).x, graph.getPosition(graph.getSelectedNodes()[i]).y, 5, 0, 2 * Math.PI);
|
||||||
|
canvascontext.fillStyle = '#FF3D3D';
|
||||||
|
canvascontext.fill();
|
||||||
|
|
||||||
|
canvascontext.beginPath();
|
||||||
|
canvascontext.moveTo(graph.getPosition(graph.getSelectedNodes()[i]).x, graph.getPosition(graph.getSelectedNodes()[i]).y);
|
||||||
|
canvascontext.lineTo(pos.x, pos.y);
|
||||||
|
canvascontext.strokeStyle = '#FF3D3D';
|
||||||
|
canvascontext.stroke();
|
||||||
|
|
||||||
|
canvascontext.beginPath();
|
||||||
|
canvascontext.arc(pos.x, pos.y, 10, 0, 2 * Math.PI);
|
||||||
|
canvascontext.fillStyle = '#9C0000';
|
||||||
|
canvascontext.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
graph.on('dragStart', (params) => {
|
||||||
|
dragMode = true;
|
||||||
|
})
|
||||||
|
|
||||||
graph.on('dragEnd', (params) => {
|
graph.on('dragEnd', (params) => {
|
||||||
|
dragMode = false;
|
||||||
|
// Place icon on the grid
|
||||||
|
if(gridSize > 0 && graph.getSelectedNodes().length > 0) {
|
||||||
|
for(i = 0; i < graph.getSelectedNodes().length; i++) {
|
||||||
|
id = graph.getSelectedNodes()[i];
|
||||||
|
if(window.nodes.get(id).x != graph.getPosition(id).x || window.nodes.get(id).y != graph.getPosition(id).y) {
|
||||||
|
pos = getGridPosition(graph.getSelectedNodes()[i], gridSize);
|
||||||
|
window.nodes.update({id: graph.getSelectedNodes()[i], x: pos.x, y: pos.y});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coordSaveCheckbox.options[coordSaveCheckbox.selectedIndex].text != "Yes") return
|
if (coordSaveCheckbox.options[coordSaveCheckbox.selectedIndex].text != "Yes") return
|
||||||
|
|
||||||
Promise.allSettled(
|
Promise.allSettled(
|
||||||
@@ -108,7 +224,7 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
{
|
{
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': csrftoken,
|
'X-CSRFToken': window.CSRF_TOKEN,
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
@@ -138,21 +254,30 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
graph.on('beforeDrawing', (canvascontext) => {
|
||||||
|
if (gridSize > 0) {
|
||||||
|
drawGrid(canvascontext);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
graph.on('afterDrawing', (canvascontext) => {
|
graph.on('afterDrawing', (canvascontext) => {
|
||||||
allRectangles = [];
|
allRectangles = [];
|
||||||
if(group_sites != null && group_sites == 'on') { drawGroupRectangles(canvascontext, groupedNodeSites, siteRectParams); }
|
if(group_sites != null && group_sites == 'on') { drawGroupRectangles(canvascontext, groupedNodeSites, siteRectParams); }
|
||||||
if(group_locations != null && group_locations == 'on') { drawGroupRectangles(canvascontext, groupedNodeLocations, locationRectParams); }
|
if(group_locations != null && group_locations == 'on') { drawGroupRectangles(canvascontext, groupedNodeLocations, locationRectParams); }
|
||||||
if(group_racks != null && group_racks == 'on') { drawGroupRectangles(canvascontext, groupedNodeRacks, rackRectParams); }
|
if(group_racks != null && group_racks == 'on') { drawGroupRectangles(canvascontext, groupedNodeRacks, rackRectParams); }
|
||||||
|
if(group_virtualchassis != null && group_virtualchassis == 'on') { drawGroupRectangles(canvascontext, groupedNodeVirtualchassis, virtualchassisRectParams); }
|
||||||
|
|
||||||
|
drawGridSnapHint(canvascontext);
|
||||||
})
|
})
|
||||||
|
|
||||||
graph.on('click', (canvascontext) => {
|
graph.on('click', (canvascontext) => {
|
||||||
allRectangles.forEach(key => {
|
allRectangles.forEach(key => {
|
||||||
// Is the mouse pointer inside of the current rectangle?
|
// Is the mouse pointer inside of the current rectangle?
|
||||||
if(canvascontext.pointer.canvas.x > (key.x1 - key.border / 2 - 1) && canvascontext.pointer.canvas.x < (key.x2 + key.border / 2 + 1)
|
if(canvascontext.pointer.canvas.x > (key.x1 - key.border / 2 - 3) && canvascontext.pointer.canvas.x < (key.x2 + key.border / 2 + 3)
|
||||||
&& canvascontext.pointer.canvas.y > (key.y1 - key.border / 2 - 1) && canvascontext.pointer.canvas.y < (key.y2 + key.border / 2 + 1)) {
|
&& canvascontext.pointer.canvas.y > (key.y1 - key.border / 2 - 3) && canvascontext.pointer.canvas.y < (key.y2 + key.border / 2 + 3)) {
|
||||||
// We just want to react when the border has been clicked, not the whole rectangle
|
// We just want to react when the border has been clicked, not the whole rectangle
|
||||||
if (canvascontext.pointer.canvas.x < (key.x1 + key.border / 2 + 1) || canvascontext.pointer.canvas.x > (key.x2 - key.border / 2 - 1)
|
if (canvascontext.pointer.canvas.x < (key.x1 + key.border / 2 + 3) || canvascontext.pointer.canvas.x > (key.x2 - key.border / 2 - 3)
|
||||||
|| canvascontext.pointer.canvas.y < (key.y1 + key.border / 2 + 1) || canvascontext.pointer.canvas.y > (key.y2 - key.border / 2 - 1)) {
|
|| canvascontext.pointer.canvas.y < (key.y1 + key.border / 2 + 3) || canvascontext.pointer.canvas.y > (key.y2 - key.border / 2 - 3)) {
|
||||||
// Generate an array of affected nodes in order to pass it to the select.Nodes() function
|
// Generate an array of affected nodes in order to pass it to the select.Nodes() function
|
||||||
let arr = [];
|
let arr = [];
|
||||||
if(key.category == "Site") {
|
if(key.category == "Site") {
|
||||||
@@ -182,20 +307,29 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if(key.category == "Virtual Chassis") {
|
||||||
|
groupedNodeVirtualchassis.forEach(subArray => {
|
||||||
|
subArray.forEach(element => {
|
||||||
|
if (element[1] === key.id) {
|
||||||
|
arr.push(element[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
graph.selectNodes(arr);
|
graph.selectNodes(arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add information on which node belongs to which group (site/location/rack).
|
// Add information on which node belongs to which group (site/location/rack/virtualchassis).
|
||||||
// Create an array for each group in order to loop through that arrays later
|
// Create an array for each group in order to loop through that arrays later
|
||||||
function combineNodeInfo(typeId, type) {
|
function combineNodeInfo(typeId, type) {
|
||||||
let nodesArray = [];
|
let nodesArray = [];
|
||||||
// Extract node ids and node type ids from all nodes
|
// Extract node ids and node type ids from all nodes
|
||||||
for (let [key, value] of nodes._data) {
|
for (let [key, value] of nodes._data) {
|
||||||
if (value[typeId] != undefined) {
|
if (value[typeId] != undefined) {
|
||||||
nodesArray.push([value.id, value[typeId], value[type]]);
|
nodesArray.push([value.id, value[typeId], value[type], value.label_num_lines]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Split single array above into arrays grouped by node id
|
// Split single array above into arrays grouped by node id
|
||||||
@@ -238,7 +372,7 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
allRectangles.push({category: rectangle.category, id: rectangle.id, x1: rectangle.x, y1: rectangle.y, x2: rectangle.x + rectangle.width, y2: rectangle.y + rectangle.height, border: rectangle.lineWidth})
|
allRectangles.push({category: rectangle.category, id: rectangle.id, x1: rectangle.x, y1: rectangle.y, x2: rectangle.x + rectangle.width, y2: rectangle.y + rectangle.height, border: rectangle.lineWidth})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw all rectangles of a given group (site/location/rack)
|
/* Draw all rectangles of a given group (site/location//virtualchassis)
|
||||||
rectParams expects an object that consists of the following keys:
|
rectParams expects an object that consists of the following keys:
|
||||||
lineWidth: border width (string)
|
lineWidth: border width (string)
|
||||||
color: border color (string)
|
color: border color (string)
|
||||||
@@ -252,16 +386,24 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
const rectangles = [];
|
const rectangles = [];
|
||||||
const xValues = [];
|
const xValues = [];
|
||||||
const yValues = [];
|
const yValues = [];
|
||||||
|
const yValuesWithLabel = [];
|
||||||
|
const labelLineHeight = 16;
|
||||||
|
|
||||||
|
// Get coordinates for every node in a given group
|
||||||
for(let val of value[1]) {
|
for(let val of value[1]) {
|
||||||
xValues.push(graph.getPosition(val[0]).x);
|
xValues.push(graph.getPosition(val[0]).x);
|
||||||
yValues.push(graph.getPosition(val[0]).y);
|
yValues.push(graph.getPosition(val[0]).y);
|
||||||
|
yValuesWithLabel.push(yValues[yValues.length -1] + val[3] * labelLineHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rectX = Math.min(...xValues) - rectParams.paddingX;
|
const minX = Math.min(...xValues);
|
||||||
const rectY = Math.min(...yValues) - rectParams.paddingY;
|
const maxX = Math.max(...xValues);
|
||||||
const rectSizeX = Math.max(...xValues) - Math.min(...xValues) + 2*rectParams.paddingX;
|
const minY = Math.min(...yValues);
|
||||||
const rectSizeY = Math.max(...yValues) - Math.min(...yValues) + 2*rectParams.paddingY;
|
const maxY = Math.max(...yValuesWithLabel);
|
||||||
|
const rectX = minX - rectParams.paddingX;
|
||||||
|
const rectY = minY - rectParams.paddingY;
|
||||||
|
const rectSizeX = maxX - minX + 2*rectParams.paddingX;
|
||||||
|
const rectSizeY = maxY - minY + 2*rectParams.paddingY;
|
||||||
|
|
||||||
rectangles.push({
|
rectangles.push({
|
||||||
ctx: canvascontext,
|
ctx: canvascontext,
|
||||||
@@ -303,8 +445,8 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
color: "#337ab7",
|
color: "#337ab7",
|
||||||
paddingX: 77,
|
paddingX: 77,
|
||||||
paddingY: 77,
|
paddingY: 77,
|
||||||
textPaddingX: 12,
|
textPaddingX: 22,
|
||||||
textPaddingY: 22,
|
textPaddingY: 29,
|
||||||
font: "14px helvetica",
|
font: "14px helvetica",
|
||||||
category: "Location"
|
category: "Location"
|
||||||
}
|
}
|
||||||
@@ -315,11 +457,23 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
color: "green",
|
color: "green",
|
||||||
paddingX: 70,
|
paddingX: 70,
|
||||||
paddingY: 70,
|
paddingY: 70,
|
||||||
textPaddingX: 8,
|
textPaddingX: 15,
|
||||||
textPaddingY: 30,
|
textPaddingY: 36,
|
||||||
font: "14px helvetica",
|
font: "14px helvetica",
|
||||||
category: "Rack"
|
category: "Rack"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let groupedNodeVirtualchassis = combineNodeInfo('virtual_chassis_id', 'virtual_chassis');
|
||||||
|
let virtualchassisRectParams = {
|
||||||
|
lineWidth: "5",
|
||||||
|
color: "orange",
|
||||||
|
paddingX: 63,
|
||||||
|
paddingY: 63,
|
||||||
|
textPaddingX: 8,
|
||||||
|
textPaddingY: 43,
|
||||||
|
font: "14px helvetica",
|
||||||
|
category: "Virtual Chassis"
|
||||||
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
// Download Graph
|
// Download Graph
|
||||||
@@ -361,12 +515,12 @@ function performXmlDownload() {
|
|||||||
if (curr_url.includes(sites_prefix)) {
|
if (curr_url.includes(sites_prefix)) {
|
||||||
var site_id = curr_url.split(sites_prefix)[1];
|
var site_id = curr_url.split(sites_prefix)[1];
|
||||||
site_id = site_id.split('/')[0]
|
site_id = site_id.split('/')[0]
|
||||||
xml_search_options = 'site_id=' + site_id + '&show_cables=on&show_unconnected=on'
|
xml_search_options = 'site_id=' + site_id + '&show_cables=True&show_unconnected=True'
|
||||||
}
|
}
|
||||||
else if (curr_url.includes(location_prefix)) {
|
else if (curr_url.includes(location_prefix)) {
|
||||||
var location_id = curr_url.split(location_prefix)[1];
|
var location_id = curr_url.split(location_prefix)[1];
|
||||||
location_id = location_id.split('/')[0]
|
location_id = location_id.split('/')[0]
|
||||||
xml_search_options = 'location_id=' + location_id + '&show_cables=on&show_unconnected=on'
|
xml_search_options = 'location_id=' + location_id + '&show_cables=True&show_unconnected=True'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { getCookie } from './csrftoken.js'
|
|
||||||
import { toast } from './toast.js'
|
import { toast } from './toast.js'
|
||||||
|
|
||||||
const mapping = {}
|
const mapping = {}
|
||||||
const csrftoken = getCookie('csrftoken')
|
|
||||||
|
|
||||||
document.querySelector('form#images').addEventListener('submit', async (e) => {
|
document.querySelector('form#images').addEventListener('submit', async (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@@ -11,7 +9,7 @@ document.querySelector('form#images').addEventListener('submit', async (e) => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(mapping),
|
body: JSON.stringify(mapping),
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': csrftoken,
|
'X-CSRFToken': window.CSRF_TOKEN,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+1160
-348
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "netbox_topology_views",
|
"name": "netbox_topology_views",
|
||||||
"version": "4.0.0-beta.2",
|
"version": "4.4.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"bundle": "node bundle.js",
|
"bundle": "node bundle.js",
|
||||||
"bundle:styles": "node bundle.js --styles",
|
"bundle:styles": "node bundle.js --styles",
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@egjs/hammerjs": "^2.0.0",
|
"@egjs/hammerjs": "^2.0.0",
|
||||||
"component-emitter": "^1.3.0",
|
"component-emitter": "^1.3.0",
|
||||||
"esbuild": "^0.12.24",
|
"esbuild": "^0.25.0",
|
||||||
"esbuild-sass-plugin": "^1.5.2",
|
"esbuild-sass-plugin": "^3.3.1",
|
||||||
"keycharm": "^0.4.0",
|
"keycharm": "^0.4.0",
|
||||||
"timsort": "^0.3.0",
|
"timsort": "^0.3.0",
|
||||||
"uuid": "^8.0.0"
|
"uuid": "^8.0.0"
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
from netbox.plugins import PluginTemplateExtension
|
|
||||||
from django.conf import settings
|
|
||||||
from packaging import version
|
|
||||||
|
|
||||||
NETBOX_CURRENT_VERSION = version.parse(settings.VERSION)
|
|
||||||
|
|
||||||
|
|
||||||
class SiteButtons(PluginTemplateExtension):
|
|
||||||
model = 'dcim.site'
|
|
||||||
def buttons(self):
|
|
||||||
return self.render('netbox_topology_views/site_button.html')
|
|
||||||
|
|
||||||
class LocationButtons(PluginTemplateExtension):
|
|
||||||
model = 'dcim.location'
|
|
||||||
def buttons(self):
|
|
||||||
return self.render('netbox_topology_views/location_button.html')
|
|
||||||
|
|
||||||
|
|
||||||
template_extensions = [SiteButtons, LocationButtons]
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
{% load static %}
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="{% static 'netbox_topology_views/css/vendor.css' %}">
|
|
||||||
<link rel="stylesheet" href="{% static 'netbox_topology_views/css/app.css' %}">
|
|
||||||
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title">Topology Views</h5>
|
|
||||||
<div class="controls">
|
|
||||||
<div class="control-group">
|
|
||||||
{% block extra_controls %}{% endblock %}
|
|
||||||
<a id="btnDownloadXml" class="btn btn-info" href="#">
|
|
||||||
<i class="mdi mdi-download"></i>
|
|
||||||
Download XML
|
|
||||||
</a>
|
|
||||||
<a id="btnDownloadImage" class="btn btn-info" href="#">
|
|
||||||
<i class="mdi mdi-download"></i>
|
|
||||||
Download PNG
|
|
||||||
</a>
|
|
||||||
<a class="btn btn-danger" data-bs-dismiss="modal">
|
|
||||||
<i class="mdi mdi-close-thick"></i>
|
|
||||||
Close
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body" >
|
|
||||||
<div style="max-width: 900px; height: 500px;">
|
|
||||||
<div id="visgraph" style="width: 100%; height: 100%;">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style type="text/css">
|
|
||||||
.modal-dialog {
|
|
||||||
max-width: 902px !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var is_htmx = true;
|
|
||||||
var brokenImage = '{{ broken_image }}';
|
|
||||||
var topologyData = {{ topology_data | safe }};
|
|
||||||
</script>
|
|
||||||
<script src="{% static 'netbox_topology_views/js/app.js' %}?ver={{ epoch }} " defer></script>
|
|
||||||
@@ -61,6 +61,13 @@
|
|||||||
|
|
||||||
<div class="tab-pane show active" id="networks" role="tabpanel" aria-labelledby="network-tab">
|
<div class="tab-pane show active" id="networks" role="tabpanel" aria-labelledby="network-tab">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
{% if filter_required %}
|
||||||
|
<div class="bg-warning text-white p-2">Nothing to display! Set filters and hit search button or set "Draw Default Layout" in your individual options.</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if empty_result %}
|
||||||
|
<div class="bg-warning text-white p-2">Empty result set! Please review your filter settings.</div>
|
||||||
|
<div class="bg-info text-white p-2">Hint: Some options may produce an empty result. Use at least "Show Unconnected/Cables/Logical Connections".</div>
|
||||||
|
{% endif %}
|
||||||
<div id="visgraph"></div>
|
<div id="visgraph"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
<a role="button" class="btn btn-primary" title="Topology" href="#" hx-get="/plugins/netbox_topology_views/topology/?site_id={{ object.id }}&show_cables=True&show_unconnected=True" hx-target="#htmx-modal-content" data-bs-toggle="modal" data-bs-target="#htmx-modal">
|
|
||||||
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
|
||||||
Topology
|
|
||||||
</a>
|
|
||||||
@@ -123,6 +123,10 @@ def get_query_settings(request):
|
|||||||
save_coords = True
|
save_coords = True
|
||||||
|
|
||||||
# Individual options
|
# Individual options
|
||||||
|
ignore_cable_type = ()
|
||||||
|
if "ignore_cable_type" in request.GET:
|
||||||
|
ignore_cable_type = request.GET.getlist('ignore_cable_type')
|
||||||
|
|
||||||
show_unconnected = False
|
show_unconnected = False
|
||||||
if "show_unconnected" in request.GET:
|
if "show_unconnected" in request.GET:
|
||||||
if request.GET["show_unconnected"] == "True":
|
if request.GET["show_unconnected"] == "True":
|
||||||
@@ -173,12 +177,34 @@ def get_query_settings(request):
|
|||||||
if request.GET["group_racks"] == "True" :
|
if request.GET["group_racks"] == "True" :
|
||||||
group_racks = True
|
group_racks = True
|
||||||
|
|
||||||
|
group_virtualchassis = False
|
||||||
|
if "group_virtualchassis" in request.GET:
|
||||||
|
if request.GET["group_virtualchassis"] == "True" :
|
||||||
|
group_virtualchassis = True
|
||||||
|
|
||||||
|
group = False
|
||||||
|
if "group" in request.GET:
|
||||||
|
group = request.GET["group"]
|
||||||
|
|
||||||
show_neighbors = False
|
show_neighbors = False
|
||||||
if "show_neighbors" in request.GET:
|
if "show_neighbors" in request.GET:
|
||||||
if request.GET["show_neighbors"] == "True" :
|
if request.GET["show_neighbors"] == "True" :
|
||||||
show_neighbors = True
|
show_neighbors = True
|
||||||
|
|
||||||
return filter_id, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, show_neighbors
|
straight_cables = False
|
||||||
|
if "straight_cables" in request.GET:
|
||||||
|
if request.GET["straight_cables"] == "True":
|
||||||
|
straight_cables = True
|
||||||
|
|
||||||
|
grid_size = 0
|
||||||
|
if "grid_size" in request.GET:
|
||||||
|
grid_size = request.GET.getlist('grid_size')
|
||||||
|
|
||||||
|
node_label_items = ()
|
||||||
|
if "node_label_items" in request.GET:
|
||||||
|
node_label_items = request.GET.getlist('node_label_items')
|
||||||
|
|
||||||
|
return filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, grid_size, node_label_items
|
||||||
|
|
||||||
class LinePattern():
|
class LinePattern():
|
||||||
wireless = [2, 10, 2, 10]
|
wireless = [2, 10, 2, 10]
|
||||||
|
|||||||
+116
-40
@@ -1,7 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from typing import DefaultDict, Dict, Optional, Union
|
from typing import DefaultDict, Dict, Optional, Union
|
||||||
import time
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
from circuits.models import Circuit, CircuitTermination, ProviderNetwork
|
from circuits.models import Circuit, CircuitTermination, ProviderNetwork
|
||||||
@@ -28,7 +27,6 @@ from django.shortcuts import render, get_object_or_404
|
|||||||
from django.views.generic import View
|
from django.views.generic import View
|
||||||
from extras.models import Tag, SavedFilter
|
from extras.models import Tag, SavedFilter
|
||||||
from wireless.models import WirelessLink
|
from wireless.models import WirelessLink
|
||||||
from utilities.htmx import htmx_partial
|
|
||||||
from netbox.views.generic import (
|
from netbox.views.generic import (
|
||||||
ObjectView,
|
ObjectView,
|
||||||
ObjectListView,
|
ObjectListView,
|
||||||
@@ -78,7 +76,7 @@ from netbox_topology_views.utils import (
|
|||||||
IMAGE_FILETYPES
|
IMAGE_FILETYPES
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from netbox_topology_views.choices import NodeLabelItems
|
||||||
|
|
||||||
def get_image_for_entity(entity: Union[Device, Circuit, PowerPanel, PowerFeed]):
|
def get_image_for_entity(entity: Union[Device, Circuit, PowerPanel, PowerFeed]):
|
||||||
is_device = isinstance(entity, Device)
|
is_device = isinstance(entity, Device)
|
||||||
@@ -97,7 +95,10 @@ def get_image_for_entity(entity: Union[Device, Circuit, PowerPanel, PowerFeed]):
|
|||||||
|
|
||||||
|
|
||||||
def create_node(
|
def create_node(
|
||||||
device: Union[Device, Circuit, PowerPanel, PowerFeed], save_coords: bool, group_id="default"
|
device: Union[Device, Circuit, PowerPanel, PowerFeed],
|
||||||
|
save_coords: bool,
|
||||||
|
node_label_items: list,
|
||||||
|
group_id="default"
|
||||||
):
|
):
|
||||||
node = {}
|
node = {}
|
||||||
node_content = ""
|
node_content = ""
|
||||||
@@ -146,7 +147,7 @@ def create_node(
|
|||||||
model_name = 'Coordinate'
|
model_name = 'Coordinate'
|
||||||
dev_name = device.name
|
dev_name = device.name
|
||||||
if dev_name is None:
|
if dev_name is None:
|
||||||
dev_name = device.device_type.get_full_name
|
dev_name = device.device_type.full_name
|
||||||
|
|
||||||
if device.device_type is not None:
|
if device.device_type is not None:
|
||||||
node_content += (
|
node_content += (
|
||||||
@@ -189,6 +190,9 @@ def create_node(
|
|||||||
if device.rack is not None:
|
if device.rack is not None:
|
||||||
node["rack"] = device.rack.name
|
node["rack"] = device.rack.name
|
||||||
node["rack_id"] = device.rack_id
|
node["rack_id"] = device.rack_id
|
||||||
|
if device.virtual_chassis is not None:
|
||||||
|
node["virtual_chassis"] = device.virtual_chassis.name
|
||||||
|
node["virtual_chassis_id"] = device.virtual_chassis_id
|
||||||
|
|
||||||
if device.role.color != "":
|
if device.role.color != "":
|
||||||
node["color.border"] = "#" + device.role.color
|
node["color.border"] = "#" + device.role.color
|
||||||
@@ -226,10 +230,36 @@ def create_node(
|
|||||||
dev_title = "<table><tbody> %s</tbody></table>" % (node_content)
|
dev_title = "<table><tbody> %s</tbody></table>" % (node_content)
|
||||||
node["title"] = dev_title
|
node["title"] = dev_title
|
||||||
node["name"] = dev_name
|
node["name"] = dev_name
|
||||||
node["label"] = dev_name
|
|
||||||
|
# Create a list of possible label items. Omit None types
|
||||||
|
label_mapping = {
|
||||||
|
NodeLabelItems.DEVICE_NAME: dev_name,
|
||||||
|
NodeLabelItems.DEVICE_TYPE: getattr(device, 'device_type', None),
|
||||||
|
NodeLabelItems.ROLE: getattr(device, 'role', None),
|
||||||
|
NodeLabelItems.DESCRIPTION: getattr(device, 'description', None),
|
||||||
|
NodeLabelItems.PRIMARY_IPV4: getattr(device, 'primary_ip4', None),
|
||||||
|
NodeLabelItems.PRIMARY_IPV6: getattr(device, 'primary_ip6', None),
|
||||||
|
NodeLabelItems.OUT_OF_BAND_IP: getattr(device, 'oob_ip', None),
|
||||||
|
NodeLabelItems.PLATFORM: getattr(device, 'platform', None),
|
||||||
|
NodeLabelItems.SERIAL: getattr(device, 'serial', None),
|
||||||
|
NodeLabelItems.TENANT: getattr(device, 'tenant', None),
|
||||||
|
NodeLabelItems.SITE: getattr(device, 'site', None),
|
||||||
|
NodeLabelItems.LOCATION: getattr(device, 'location', None),
|
||||||
|
NodeLabelItems.RACK: getattr(device, 'rack', None),
|
||||||
|
NodeLabelItems.VIRTUAL_CHASSIS: getattr(device, 'virtual_chassis', None),
|
||||||
|
}
|
||||||
|
|
||||||
|
label_items = []
|
||||||
|
for item in node_label_items:
|
||||||
|
if label_mapping[item] and label_mapping[item] is not None:
|
||||||
|
label_items.append(str(label_mapping[item]))
|
||||||
|
node_label = '\n'.join(label_items)
|
||||||
|
|
||||||
|
node["label"] = node_label
|
||||||
node["shape"] = "image"
|
node["shape"] = "image"
|
||||||
node["href"] = device.get_absolute_url()
|
node["href"] = device.get_absolute_url()
|
||||||
node["image"] = get_image_for_entity(device)
|
node["image"] = get_image_for_entity(device)
|
||||||
|
node["label_num_lines"] = len(label_items)
|
||||||
|
|
||||||
return node
|
return node
|
||||||
|
|
||||||
@@ -238,6 +268,7 @@ def create_edge(
|
|||||||
edge_id: int,
|
edge_id: int,
|
||||||
termination_a: Dict,
|
termination_a: Dict,
|
||||||
termination_b: Dict,
|
termination_b: Dict,
|
||||||
|
straight_cables: bool,
|
||||||
circuit: Optional[Dict] = None,
|
circuit: Optional[Dict] = None,
|
||||||
cable: Optional[Cable] = None,
|
cable: Optional[Cable] = None,
|
||||||
wireless: Optional[Dict] = None,
|
wireless: Optional[Dict] = None,
|
||||||
@@ -291,15 +322,23 @@ def create_edge(
|
|||||||
edge["color"] = '#f1c232'
|
edge["color"] = '#f1c232'
|
||||||
edge["href"] = interface.get_absolute_url() + "trace"
|
edge["href"] = interface.get_absolute_url() + "trace"
|
||||||
|
|
||||||
|
if cable is not None and cable.label:
|
||||||
|
cable_label = "<br>Label: " + cable.label
|
||||||
|
else:
|
||||||
|
cable_label = ""
|
||||||
|
|
||||||
edge[
|
edge[
|
||||||
"title"
|
"title"
|
||||||
] = f"{title} between<br>{cable_a_dev_name} [{cable_a_name}]<br>{cable_b_dev_name} [{cable_b_name}]"
|
] = f"{title} between<br>{cable_a_dev_name} [{cable_a_name}]<br>{cable_b_dev_name} [{cable_b_name}] {cable_label}"
|
||||||
|
|
||||||
if cable is not None:
|
if cable is not None:
|
||||||
edge["href"] = cable.get_absolute_url()
|
edge["href"] = cable.get_absolute_url()
|
||||||
if hasattr(cable, 'color') and cable.color != "":
|
if hasattr(cable, 'color') and cable.color != "":
|
||||||
edge["color"] = "#" + cable.color
|
edge["color"] = "#" + cable.color
|
||||||
|
|
||||||
|
# if straight_cables == True: edge["smooth"] = False
|
||||||
|
edge["smooth"] = not straight_cables
|
||||||
|
|
||||||
return edge
|
return edge
|
||||||
|
|
||||||
|
|
||||||
@@ -327,6 +366,7 @@ def get_topology_data(
|
|||||||
queryset: QuerySet,
|
queryset: QuerySet,
|
||||||
individualOptions: IndividualOptions,
|
individualOptions: IndividualOptions,
|
||||||
show_unconnected: bool,
|
show_unconnected: bool,
|
||||||
|
ignore_cable_type: list,
|
||||||
save_coords: bool,
|
save_coords: bool,
|
||||||
show_cables: bool,
|
show_cables: bool,
|
||||||
show_circuit: bool,
|
show_circuit: bool,
|
||||||
@@ -338,7 +378,11 @@ def get_topology_data(
|
|||||||
group_sites: bool,
|
group_sites: bool,
|
||||||
group_locations: bool,
|
group_locations: bool,
|
||||||
group_racks: bool,
|
group_racks: bool,
|
||||||
|
group_virtualchassis: bool,
|
||||||
group_id,
|
group_id,
|
||||||
|
straight_cables: bool,
|
||||||
|
grid_size: list,
|
||||||
|
node_label_items: list,
|
||||||
):
|
):
|
||||||
|
|
||||||
supported_termination_types = []
|
supported_termination_types = []
|
||||||
@@ -360,8 +404,6 @@ def get_topology_data(
|
|||||||
cable_ids = DefaultDict(dict)
|
cable_ids = DefaultDict(dict)
|
||||||
interface_ids = DefaultDict(dict)
|
interface_ids = DefaultDict(dict)
|
||||||
|
|
||||||
ignore_cable_type = individualOptions.ignore_cable_type
|
|
||||||
|
|
||||||
device_ids = [d.pk for d in queryset]
|
device_ids = [d.pk for d in queryset]
|
||||||
site_ids = [d.site_id for d in queryset]
|
site_ids = [d.site_id for d in queryset]
|
||||||
|
|
||||||
@@ -393,8 +435,8 @@ def get_topology_data(
|
|||||||
|
|
||||||
if show_circuit:
|
if show_circuit:
|
||||||
circuit_terminations = CircuitTermination.objects.filter(
|
circuit_terminations = CircuitTermination.objects.filter(
|
||||||
Q(site_id__in=site_ids) | Q(provider_network__isnull=False)
|
Q(_site_id__in=site_ids) | Q(_provider_network__isnull=False)
|
||||||
).prefetch_related("provider_network", "circuit")
|
)
|
||||||
for circuit_termination in circuit_terminations:
|
for circuit_termination in circuit_terminations:
|
||||||
circuit_termination: CircuitTermination
|
circuit_termination: CircuitTermination
|
||||||
if (
|
if (
|
||||||
@@ -408,21 +450,21 @@ def get_topology_data(
|
|||||||
termination_a = {}
|
termination_a = {}
|
||||||
termination_b = {}
|
termination_b = {}
|
||||||
circuit_model = {}
|
circuit_model = {}
|
||||||
if circuit_termination.cable is not None:
|
if circuit_termination.cable is not None and bool(circuit_termination.cable.a_terminations) and bool(circuit_termination.cable.b_terminations):
|
||||||
termination_a = create_circuit_termination(
|
termination_a = create_circuit_termination(
|
||||||
circuit_termination.cable.a_terminations[0]
|
circuit_termination.cable.a_terminations[0]
|
||||||
)
|
)
|
||||||
termination_b = create_circuit_termination(
|
termination_b = create_circuit_termination(
|
||||||
circuit_termination.cable.b_terminations[0]
|
circuit_termination.cable.b_terminations[0]
|
||||||
)
|
)
|
||||||
elif circuit_termination.provider_network is not None:
|
elif circuit_termination.termination is not None:
|
||||||
if (
|
if (
|
||||||
circuit_termination.provider_network_id
|
circuit_termination.termination_id
|
||||||
not in nodes_provider_networks
|
not in nodes_provider_networks
|
||||||
):
|
):
|
||||||
nodes_provider_networks[
|
nodes_provider_networks[
|
||||||
circuit_termination.provider_network.pk
|
circuit_termination.termination.pk
|
||||||
] = circuit_termination.provider_network
|
] = circuit_termination.termination
|
||||||
|
|
||||||
if bool(termination_a) and bool(termination_b):
|
if bool(termination_a) and bool(termination_b):
|
||||||
circuit_model = {
|
circuit_model = {
|
||||||
@@ -436,6 +478,7 @@ def get_topology_data(
|
|||||||
circuit=circuit_model,
|
circuit=circuit_model,
|
||||||
termination_a=termination_a,
|
termination_a=termination_a,
|
||||||
termination_b=termination_b,
|
termination_b=termination_b,
|
||||||
|
straight_cables=straight_cables,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -462,7 +505,7 @@ def get_topology_data(
|
|||||||
] = circuit_termination.circuit
|
] = circuit_termination.circuit
|
||||||
|
|
||||||
for d in nodes_circuits.values():
|
for d in nodes_circuits.values():
|
||||||
nodes.append(create_node(d, save_coords, group_id))
|
nodes.append(create_node(d, save_coords, node_label_items, group_id))
|
||||||
|
|
||||||
if show_power:
|
if show_power:
|
||||||
power_panels_ids = PowerPanel.objects.filter(
|
power_panels_ids = PowerPanel.objects.filter(
|
||||||
@@ -505,6 +548,7 @@ def get_topology_data(
|
|||||||
termination_a=termination_a,
|
termination_a=termination_a,
|
||||||
termination_b=termination_b,
|
termination_b=termination_b,
|
||||||
power=True,
|
power=True,
|
||||||
|
straight_cables=straight_cables,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -512,10 +556,10 @@ def get_topology_data(
|
|||||||
cable_ids[power_feed.cable_id][power_feed.cable_end] = termination_b
|
cable_ids[power_feed.cable_id][power_feed.cable_end] = termination_b
|
||||||
|
|
||||||
for d in nodes_powerfeed.values():
|
for d in nodes_powerfeed.values():
|
||||||
nodes.append(create_node(d, save_coords, group_id))
|
nodes.append(create_node(d, save_coords, node_label_items ,group_id))
|
||||||
|
|
||||||
for d in nodes_powerpanel.values():
|
for d in nodes_powerpanel.values():
|
||||||
nodes.append(create_node(d, save_coords, group_id))
|
nodes.append(create_node(d, save_coords, node_label_items, group_id))
|
||||||
|
|
||||||
if show_logical_connections:
|
if show_logical_connections:
|
||||||
interfaces = Interface.objects.filter(
|
interfaces = Interface.objects.filter(
|
||||||
@@ -543,7 +587,7 @@ def get_topology_data(
|
|||||||
edge_ids += 1
|
edge_ids += 1
|
||||||
termination_a = { "termination_name": interface.name, "termination_device_name": interface.device.name, "device_id": interface.device.id }
|
termination_a = { "termination_name": interface.name, "termination_device_name": interface.device.name, "device_id": interface.device.id }
|
||||||
termination_b = { "termination_name": destination.name, "termination_device_name": destination.device.name, "device_id": destination.device.id }
|
termination_b = { "termination_name": destination.name, "termination_device_name": destination.device.name, "device_id": destination.device.id }
|
||||||
edges.append(create_edge(edge_id=edge_ids, termination_a=termination_a, termination_b=termination_b, interface=interface))
|
edges.append(create_edge(edge_id=edge_ids, termination_a=termination_a, termination_b=termination_b, interface=interface, straight_cables=straight_cables))
|
||||||
nodes_devices[interface.device.id] = interface.device
|
nodes_devices[interface.device.id] = interface.device
|
||||||
nodes_devices[destination.device.id] = destination.device
|
nodes_devices[destination.device.id] = destination.device
|
||||||
|
|
||||||
@@ -553,11 +597,11 @@ def get_topology_data(
|
|||||||
).select_related("termination_type")
|
).select_related("termination_type")
|
||||||
|
|
||||||
for link in links:
|
for link in links:
|
||||||
if link.termination_type.name in ignore_cable_type:
|
if link.termination_type.model in ignore_cable_type:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Normal device cables
|
# Normal device cables
|
||||||
if link.termination_type.name in supported_termination_types:
|
if link.termination_type.model in supported_termination_types:
|
||||||
complete_link = False
|
complete_link = False
|
||||||
if link.cable_end == "A":
|
if link.cable_end == "A":
|
||||||
if link.cable_id not in cable_ids:
|
if link.cable_id not in cable_ids:
|
||||||
@@ -623,6 +667,7 @@ def get_topology_data(
|
|||||||
cable=link.cable,
|
cable=link.cable,
|
||||||
termination_a=termination_a,
|
termination_a=termination_a,
|
||||||
termination_b=termination_b,
|
termination_b=termination_b,
|
||||||
|
straight_cables=straight_cables,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -662,6 +707,7 @@ def get_topology_data(
|
|||||||
termination_a=termination_a,
|
termination_a=termination_a,
|
||||||
termination_b=termination_b,
|
termination_b=termination_b,
|
||||||
wireless=wireless,
|
wireless=wireless,
|
||||||
|
straight_cables=straight_cables,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -671,6 +717,12 @@ def get_topology_data(
|
|||||||
options['group_racks'] = 'on'
|
options['group_racks'] = 'on'
|
||||||
if group_sites:
|
if group_sites:
|
||||||
options['group_sites'] = 'on'
|
options['group_sites'] = 'on'
|
||||||
|
if group_virtualchassis:
|
||||||
|
options['group_virtualchassis'] = 'on'
|
||||||
|
if grid_size:
|
||||||
|
options['grid_size'] = grid_size
|
||||||
|
else:
|
||||||
|
options['grid_size'] = list('0')
|
||||||
|
|
||||||
for qs_device in queryset:
|
for qs_device in queryset:
|
||||||
if qs_device.pk not in nodes_devices and show_unconnected:
|
if qs_device.pk not in nodes_devices and show_unconnected:
|
||||||
@@ -679,7 +731,7 @@ def get_topology_data(
|
|||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
for d in nodes_devices.values():
|
for d in nodes_devices.values():
|
||||||
nodes.append(create_node(d, save_coords, group_id))
|
nodes.append(create_node(d, save_coords, node_label_items, group_id))
|
||||||
|
|
||||||
results["nodes"] = nodes
|
results["nodes"] = nodes
|
||||||
results["edges"] = edges
|
results["edges"] = edges
|
||||||
@@ -697,7 +749,7 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
self.filterset = DeviceFilterSet
|
self.filterset = DeviceFilterSet
|
||||||
self.queryset = Device.objects.all().select_related(
|
self.queryset = Device.objects.restrict(request.user, 'view').select_related(
|
||||||
"device_type", "role"
|
"device_type", "role"
|
||||||
)
|
)
|
||||||
self.queryset = self.filterset(request.GET, self.queryset).qs
|
self.queryset = self.filterset(request.GET, self.queryset).qs
|
||||||
@@ -710,7 +762,10 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
|
|
||||||
if request.GET:
|
if request.GET:
|
||||||
|
|
||||||
filter_id, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, show_neighbors = get_query_settings(request)
|
filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, grid_size, node_label_items = get_query_settings(request)
|
||||||
|
|
||||||
|
filter_required = True
|
||||||
|
empty_result = False
|
||||||
|
|
||||||
# Read options from saved filters as NetBox does not handle custom plugin filters
|
# Read options from saved filters as NetBox does not handle custom plugin filters
|
||||||
if "filter_id" in request.GET and request.GET["filter_id"] != '':
|
if "filter_id" in request.GET and request.GET["filter_id"] != '':
|
||||||
@@ -718,7 +773,9 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
saved_filter = SavedFilter.objects.get(pk=filter_id)
|
saved_filter = SavedFilter.objects.get(pk=filter_id)
|
||||||
saved_filter_params = getattr(saved_filter, 'parameters')
|
saved_filter_params = getattr(saved_filter, 'parameters')
|
||||||
|
|
||||||
|
if ignore_cable_type == () and 'ignore_cable_type' in saved_filter_params: ignore_cable_type = saved_filter_params['ignore_cable_type']
|
||||||
if save_coords == False and 'save_coords' in saved_filter_params: save_coords = saved_filter_params['save_coords']
|
if save_coords == False and 'save_coords' in saved_filter_params: save_coords = saved_filter_params['save_coords']
|
||||||
|
if show_unconnected == False and 'show_unconnected' in saved_filter_params: show_unconnected = saved_filter_params['show_unconnected']
|
||||||
if show_power == False and 'show_power' in saved_filter_params: show_power = saved_filter_params['show_power']
|
if show_power == False and 'show_power' in saved_filter_params: show_power = saved_filter_params['show_power']
|
||||||
if show_circuit == False and 'show_circuit' in saved_filter_params: show_circuit = saved_filter_params['show_circuit']
|
if show_circuit == False and 'show_circuit' in saved_filter_params: show_circuit = saved_filter_params['show_circuit']
|
||||||
if show_logical_connections == False and 'show_logical_connections' in saved_filter_params: show_logical_connections = saved_filter_params['show_logical_connections']
|
if show_logical_connections == False and 'show_logical_connections' in saved_filter_params: show_logical_connections = saved_filter_params['show_logical_connections']
|
||||||
@@ -728,21 +785,31 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
if group_sites == False and 'group_sites' in saved_filter_params: group_sites = saved_filter_params['group_sites']
|
if group_sites == False and 'group_sites' in saved_filter_params: group_sites = saved_filter_params['group_sites']
|
||||||
if group_locations == False and 'group_locations' in saved_filter_params: group_locations = saved_filter_params['group_locations']
|
if group_locations == False and 'group_locations' in saved_filter_params: group_locations = saved_filter_params['group_locations']
|
||||||
if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks']
|
if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks']
|
||||||
|
if group_virtualchassis == False and 'group_virtualchassis' in saved_filter_params: group_virtualchassis = saved_filter_params['group_virtualchassis']
|
||||||
if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors']
|
if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors']
|
||||||
|
if straight_cables == False and 'straight_cables' in saved_filter_params: straight_cables = saved_filter_params['straight_cables']
|
||||||
|
if grid_size == 0 and 'grid_size' in saved_filter_params: grid_size = saved_filter_params['grid_size']
|
||||||
|
if node_label_items == () and 'node_label_items' in saved_filter_params: node_label_items = saved_filter_params['node_label_items']
|
||||||
except SavedFilter.DoesNotExist: # filter_id not found
|
except SavedFilter.DoesNotExist: # filter_id not found
|
||||||
pass
|
pass
|
||||||
except Exception as inst:
|
except Exception as inst:
|
||||||
print(type(inst))
|
print(type(inst))
|
||||||
|
|
||||||
if "group" not in request.GET:
|
if "group" not in request.GET:
|
||||||
group_id = "default"
|
if 'saved_filter_params' in locals() and "group" in saved_filter_params:
|
||||||
|
group_id = saved_filter_params['group'][0]
|
||||||
|
else:
|
||||||
|
group_id = "default"
|
||||||
else:
|
else:
|
||||||
group_id = request.GET["group"]
|
group_id = request.GET["group"]
|
||||||
|
|
||||||
if not "draw_init" in request.GET or "draw_init" in request.GET and request.GET["draw_init"].lower() == "true":
|
if not "draw_init" in request.GET or "draw_init" in request.GET and request.GET["draw_init"].lower() == "true":
|
||||||
|
filter_required = False
|
||||||
|
|
||||||
topo_data = get_topology_data(
|
topo_data = get_topology_data(
|
||||||
queryset=self.queryset,
|
queryset=self.queryset,
|
||||||
individualOptions=individualOptions,
|
individualOptions=individualOptions,
|
||||||
|
ignore_cable_type=ignore_cable_type,
|
||||||
save_coords=save_coords,
|
save_coords=save_coords,
|
||||||
show_unconnected=show_unconnected,
|
show_unconnected=show_unconnected,
|
||||||
show_cables=show_cables,
|
show_cables=show_cables,
|
||||||
@@ -755,17 +822,27 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
group_sites=group_sites,
|
group_sites=group_sites,
|
||||||
group_locations=group_locations,
|
group_locations=group_locations,
|
||||||
group_racks=group_racks,
|
group_racks=group_racks,
|
||||||
|
group_virtualchassis=group_virtualchassis,
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
|
straight_cables=straight_cables,
|
||||||
|
grid_size=grid_size,
|
||||||
|
node_label_items=node_label_items,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not topo_data["nodes"]:
|
||||||
|
empty_result = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# No GET-Request in URL. We most likely came here from the navigation menu.
|
# No GET-Request in URL. We most likely came here from the navigation menu.
|
||||||
preselected_device_roles = IndividualOptions.objects.get(id=individualOptions.id).preselected_device_roles.all().values_list('id', flat=True)
|
preselected_device_roles = IndividualOptions.objects.get(id=individualOptions.id).preselected_device_roles.all().values_list('id', flat=True)
|
||||||
preselected_tags = IndividualOptions.objects.get(id=individualOptions.id).preselected_tags.all().values_list(Lower('name'), flat=True)
|
preselected_tags = IndividualOptions.objects.get(id=individualOptions.id).preselected_tags.all().values_list(Lower('name'), flat=True)
|
||||||
|
ignore_cable_type = IndividualOptions.objects.get(id=individualOptions.id).ignore_cable_type.translate({ord(i): None for i in '[]\''}).split(', ')
|
||||||
|
if ignore_cable_type == ['']: ignore_cable_type = []
|
||||||
|
|
||||||
q = QueryDict(mutable=True)
|
q = QueryDict(mutable=True)
|
||||||
q.setlist("role_id", list(preselected_device_roles))
|
q.setlist("role_id", list(preselected_device_roles))
|
||||||
q.setlist("tag", list(preselected_tags))
|
q.setlist("tag", list(preselected_tags))
|
||||||
|
q.setlist("ignore_cable_type", ignore_cable_type)
|
||||||
|
|
||||||
if individualOptions.save_coords: q['save_coords'] = "True"
|
if individualOptions.save_coords: q['save_coords'] = "True"
|
||||||
if individualOptions.show_unconnected: q['show_unconnected'] = "True"
|
if individualOptions.show_unconnected: q['show_unconnected'] = "True"
|
||||||
@@ -779,6 +856,13 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
if individualOptions.group_sites: q['group_sites'] = "True"
|
if individualOptions.group_sites: q['group_sites'] = "True"
|
||||||
if individualOptions.group_locations: q['group_locations'] = "True"
|
if individualOptions.group_locations: q['group_locations'] = "True"
|
||||||
if individualOptions.group_racks: q['group_racks'] = "True"
|
if individualOptions.group_racks: q['group_racks'] = "True"
|
||||||
|
if individualOptions.group_virtualchassis: q['group_virtualchassis'] = "True"
|
||||||
|
if individualOptions.straight_cables: q['straight_cables'] = "True"
|
||||||
|
if individualOptions.grid_size: q['grid_size'] = individualOptions.grid_size
|
||||||
|
node_label_items = IndividualOptions.objects.get(id=individualOptions.id).node_label_items.translate({ord(i): None for i in '[]\''}).split(', ')
|
||||||
|
if node_label_items == ['']: node_label_items = []
|
||||||
|
q.setlist("node_label_items", node_label_items)
|
||||||
|
|
||||||
if individualOptions.draw_default_layout:
|
if individualOptions.draw_default_layout:
|
||||||
q['draw_init'] = "True"
|
q['draw_init'] = "True"
|
||||||
else:
|
else:
|
||||||
@@ -787,20 +871,6 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
query_string = q.urlencode()
|
query_string = q.urlencode()
|
||||||
return HttpResponseRedirect(f"{request.path}?{query_string}")
|
return HttpResponseRedirect(f"{request.path}?{query_string}")
|
||||||
|
|
||||||
|
|
||||||
if htmx_partial(request):
|
|
||||||
return render(
|
|
||||||
request,
|
|
||||||
"netbox_topology_views/htmx_topology.html",
|
|
||||||
{
|
|
||||||
"filter_form": DeviceFilterForm(request.GET, label_suffix=""),
|
|
||||||
"topology_data": json.dumps(topo_data),
|
|
||||||
"broken_image": find_image_url("role-unknown"),
|
|
||||||
"epoch": int(time.time()),
|
|
||||||
"basepath": settings.BASE_PATH,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"netbox_topology_views/index.html",
|
"netbox_topology_views/index.html",
|
||||||
@@ -810,6 +880,8 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
"broken_image": find_image_url("role-unknown"),
|
"broken_image": find_image_url("role-unknown"),
|
||||||
"model": self.model,
|
"model": self.model,
|
||||||
"basepath": settings.BASE_PATH,
|
"basepath": settings.BASE_PATH,
|
||||||
|
"filter_required": filter_required,
|
||||||
|
"empty_result": empty_result,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1136,7 +1208,11 @@ class TopologyIndividualOptionsView(PermissionRequiredMixin, View):
|
|||||||
'group_sites': queryset.group_sites,
|
'group_sites': queryset.group_sites,
|
||||||
'group_locations': queryset.group_locations,
|
'group_locations': queryset.group_locations,
|
||||||
'group_racks': queryset.group_racks,
|
'group_racks': queryset.group_racks,
|
||||||
|
'group_virtualchassis': queryset.group_virtualchassis,
|
||||||
'draw_default_layout': queryset.draw_default_layout,
|
'draw_default_layout': queryset.draw_default_layout,
|
||||||
|
'straight_cables': queryset.straight_cables,
|
||||||
|
'grid_size': queryset.grid_size,
|
||||||
|
'node_label_items': tuple(queryset.node_label_items.translate({ord(i): None for i in '[]\''}).split(', ')),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ long_description = readme.read_text()
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="netbox-topology-views",
|
name="netbox-topology-views",
|
||||||
version="4.0.0-beta.2",
|
version="4.4.0",
|
||||||
description="An NetBox plugin to create Topology maps",
|
description="An NetBox plugin to create Topology maps",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|||||||
Reference in new issue
Block a user