Compare commits
41
Commits
v3.9.0
...
dreng-patch-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c8f5d728c | ||
|
|
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 | ||
|
|
ed8a717bc5 | ||
|
|
0b7046b10d | ||
|
|
e784e717ca | ||
|
|
2895294903 | ||
|
|
8368ffa2fd | ||
|
|
23428c8ad2 | ||
|
|
c00b8c2cfe | ||
|
|
32003e59f9 | ||
|
|
bd32642b5c | ||
|
|
f463804087 | ||
|
|
b92b012309 |
@@ -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,40 @@ 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 >> local_requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Once installed, the plugin needs to be enabled in your `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.3.X | = v4.2.1 |
|
||||||
| >= 3.6.4 | >= v3.8.1 |
|
| = 4.2.1 | = v4.2.1 |
|
||||||
| >= 3.6.0 | >= v3.7.X |
|
| = 4.2.0 | = v4.2.0 |
|
||||||
| >= 3.5.0 | >= v3.4.X |
|
| = 4.1.X | = v4.1.0 |
|
||||||
| >= 3.4.0 | >= v3.X.X |
|
| = 4.0.X | = v4.0.0 |
|
||||||
| >= 3.3.0 | >= v3.0.0 |
|
| = 3.7.0 | = v3.9.0 |
|
||||||
| >= 3.2.0 | >= v1.1.0 |
|
| = 3.6.4 | = v3.8.1 |
|
||||||
| >= 3.1.8 | >= v1.0.0 |
|
| = 3.6.0 | = v3.7.0 |
|
||||||
| >= 2.11.1 | >= v0.5.3 |
|
| = 3.5.0 | = v3.6.2 |
|
||||||
| >= 2.10.0 | >= v0.5.0 |
|
|
||||||
| < 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,27 @@
|
|||||||
|
version: 0.1
|
||||||
|
package_name: netbox-topology-views
|
||||||
|
compatibility:
|
||||||
|
- 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
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
from extras.plugins import PluginConfig
|
from netbox.plugins import PluginConfig
|
||||||
|
|
||||||
|
|
||||||
class TopologyViewsConfig(PluginConfig):
|
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 = "3.9.0"
|
version = "4.2.1"
|
||||||
author = "Mattijs Vanhaverbeke"
|
author = "Mattijs Vanhaverbeke"
|
||||||
author_email = "author@example.com"
|
author_email = "author@example.com"
|
||||||
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", "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")
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ 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)
|
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,8 +1,11 @@
|
|||||||
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 django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
@@ -14,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
|
||||||
@@ -21,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()
|
||||||
@@ -88,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
|
||||||
@@ -108,14 +114,47 @@ class ExportTopoToXML(PermissionRequiredMixin, ViewSet):
|
|||||||
|
|
||||||
if request.GET:
|
if request.GET:
|
||||||
|
|
||||||
save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, 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
|
||||||
|
if "filter_id" in request.GET and request.GET["filter_id"] != '':
|
||||||
|
try:
|
||||||
|
saved_filter = SavedFilter.objects.get(pk=filter_id)
|
||||||
|
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 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_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_single_cable_logical_conns == False and 'show_single_cable_logical_conns' in saved_filter_params: show_single_cable_logical_conns = saved_filter_params['show_single_cable_logical_conns']
|
||||||
|
if show_cables == False and 'show_cables' in saved_filter_params: show_cables = saved_filter_params['show_cables']
|
||||||
|
if show_wireless == False and 'show_wireless' in saved_filter_params: show_wireless = saved_filter_params['show_wireless']
|
||||||
|
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_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 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
|
||||||
|
pass
|
||||||
|
except Exception as 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,
|
||||||
@@ -125,9 +164,16 @@ class ExportTopoToXML(PermissionRequiredMixin, ViewSet):
|
|||||||
show_circuit=show_circuit,
|
show_circuit=show_circuit,
|
||||||
show_power=show_power,
|
show_power=show_power,
|
||||||
show_wireless=show_wireless,
|
show_wireless=show_wireless,
|
||||||
|
group_sites=group_sites,
|
||||||
|
group_locations=group_locations,
|
||||||
|
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:
|
||||||
@@ -135,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 = (
|
||||||
@@ -213,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,14 @@
|
|||||||
|
from utilities.choices import ChoiceSet
|
||||||
|
|
||||||
|
class NodeLabelItems(ChoiceSet):
|
||||||
|
DEVICE_NAME = 'devicename'
|
||||||
|
PRIMARY_IPV4 = 'primaryipv4'
|
||||||
|
PRIMARY_IPV6 = 'primaryipv6'
|
||||||
|
OUT_OF_BAND_IP = 'outofbandip'
|
||||||
|
|
||||||
|
CHOICES = [
|
||||||
|
(DEVICE_NAME, 'Device Name'),
|
||||||
|
(PRIMARY_IPV4, 'Primary IPv4'),
|
||||||
|
(PRIMARY_IPV6, 'Primary IPv6'),
|
||||||
|
(OUT_OF_BAND_IP, 'Out-of-band IP'),
|
||||||
|
]
|
||||||
@@ -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(
|
||||||
|
|||||||
+222
-80
@@ -15,6 +15,7 @@ from extras.forms import LocalConfigContextFilterForm
|
|||||||
from tenancy.forms import ContactModelFilterForm, TenancyFilterForm
|
from tenancy.forms import ContactModelFilterForm, TenancyFilterForm
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from netbox.forms import NetBoxModelFilterSetForm, NetBoxModelForm, NetBoxModelImportForm
|
from netbox.forms import NetBoxModelFilterSetForm, NetBoxModelForm, NetBoxModelImportForm
|
||||||
|
from utilities.forms.rendering import FieldSet
|
||||||
from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES, add_blank_choice
|
from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES, add_blank_choice
|
||||||
from utilities.forms.fields import (
|
from utilities.forms.fields import (
|
||||||
TagFilterField,
|
TagFilterField,
|
||||||
@@ -22,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,
|
||||||
@@ -29,26 +31,26 @@ class DeviceFilterForm(
|
|||||||
ContactModelFilterForm,
|
ContactModelFilterForm,
|
||||||
NetBoxModelFilterSetForm
|
NetBoxModelFilterSetForm
|
||||||
):
|
):
|
||||||
default_renderer = forms.renderers.DjangoTemplates()
|
|
||||||
model = Device
|
model = Device
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, ('q', 'filter_id', 'tag')),
|
FieldSet('q', 'filter_id', 'tag'),
|
||||||
(_('Options'), (
|
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', 'group_virtualchassis', 'straight_cables', 'grid_size', 'node_label_items', name=_("Options")
|
||||||
(_('Device'), ('id',)),
|
),
|
||||||
(_('Location'), ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id')),
|
FieldSet('id', name=_("Device")),
|
||||||
(_('Operation'), ('status', 'role_id', 'airflow', 'serial', 'asset_tag', 'mac_address')),
|
FieldSet('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', name=_("Location")),
|
||||||
(_('Hardware'), ('manufacturer_id', 'device_type_id', 'platform_id')),
|
FieldSet('status', 'role_id', 'airflow', 'serial', 'asset_tag', 'mac_address', name=_("Operation")),
|
||||||
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
|
FieldSet('manufacturer_id', 'device_type_id', 'platform_id', name=_("Hardware")),
|
||||||
(_('Contacts'), ('contact', 'contact_role', 'contact_group')),
|
FieldSet('tenant_group_id', 'tenant_id', name=_("Tenant")),
|
||||||
(_('Components'), (
|
FieldSet('contact', 'contact_role', 'contact_group', name=_("Contacts")),
|
||||||
'console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces', 'pass_through_ports',
|
FieldSet(
|
||||||
)),
|
'console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces', 'pass_through_ports', name=_("Components")
|
||||||
(_('Miscellaneous'), (
|
),
|
||||||
'has_primary_ip', 'has_oob_ip', 'virtual_chassis_member', 'config_template_id', 'local_context_data',
|
FieldSet(
|
||||||
)),
|
'has_primary_ip', 'has_oob_ip', 'virtual_chassis_member', 'config_template_id', 'local_context_data', name=_("Miscellaneous")
|
||||||
|
),
|
||||||
)
|
)
|
||||||
group = forms.ModelChoiceField(
|
group = forms.ModelChoiceField(
|
||||||
queryset=CoordinateGroup.objects.all(),
|
queryset=CoordinateGroup.objects.all(),
|
||||||
@@ -71,8 +73,8 @@ class DeviceFilterForm(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
region_id = DynamicModelMultipleChoiceField(
|
region_id = DynamicModelMultipleChoiceField(
|
||||||
queryset=Region.objects.all(),
|
queryset=Region.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
label=_('Region')
|
label=_('Region')
|
||||||
)
|
)
|
||||||
site_group_id = DynamicModelMultipleChoiceField(
|
site_group_id = DynamicModelMultipleChoiceField(
|
||||||
@@ -111,13 +113,13 @@ class DeviceFilterForm(
|
|||||||
label=_('Rack'),
|
label=_('Rack'),
|
||||||
)
|
)
|
||||||
status = forms.MultipleChoiceField(
|
status = forms.MultipleChoiceField(
|
||||||
choices=DeviceStatusChoices,
|
choices=DeviceStatusChoices,
|
||||||
required=False,
|
required=False,
|
||||||
label=_('Device Status')
|
label=_('Device Status')
|
||||||
)
|
)
|
||||||
role_id = DynamicModelMultipleChoiceField(
|
role_id = DynamicModelMultipleChoiceField(
|
||||||
queryset=DeviceRole.objects.all(),
|
queryset=DeviceRole.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
label=_('Role')
|
label=_('Role')
|
||||||
)
|
)
|
||||||
airflow = forms.MultipleChoiceField(
|
airflow = forms.MultipleChoiceField(
|
||||||
@@ -136,7 +138,7 @@ class DeviceFilterForm(
|
|||||||
mac_address = forms.CharField(
|
mac_address = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label=_('MAC address')
|
label=_('MAC address')
|
||||||
)
|
)
|
||||||
manufacturer_id = DynamicModelMultipleChoiceField(
|
manufacturer_id = DynamicModelMultipleChoiceField(
|
||||||
queryset=Manufacturer.objects.all(),
|
queryset=Manufacturer.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
@@ -212,7 +214,7 @@ class DeviceFilterForm(
|
|||||||
)
|
)
|
||||||
has_oob_ip = forms.NullBooleanField(
|
has_oob_ip = forms.NullBooleanField(
|
||||||
required=False,
|
required=False,
|
||||||
label='Has an OOB IP',
|
label=_('Has an OOB IP'),
|
||||||
widget=forms.Select(
|
widget=forms.Select(
|
||||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
)
|
)
|
||||||
@@ -228,40 +230,121 @@ class DeviceFilterForm(
|
|||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
# options
|
# options
|
||||||
save_coords = forms.BooleanField(
|
ignore_cable_type = forms.MultipleChoiceField(
|
||||||
|
label=_('Ignore Termination Types'),
|
||||||
|
required=False,
|
||||||
|
choices=IndividualOptions.CHOICES
|
||||||
|
)
|
||||||
|
save_coords = forms.NullBooleanField(
|
||||||
label=_('Save Coordinates'),
|
label=_('Save Coordinates'),
|
||||||
required=False,
|
required=False,
|
||||||
disabled=(not settings.PLUGINS_CONFIG['netbox_topology_views']['allow_coordinates_saving'] or settings.PLUGINS_CONFIG['netbox_topology_views']['always_save_coordinates']),
|
disabled=(not settings.PLUGINS_CONFIG['netbox_topology_views']['allow_coordinates_saving'] or settings.PLUGINS_CONFIG['netbox_topology_views']['always_save_coordinates']),
|
||||||
initial=(settings.PLUGINS_CONFIG['netbox_topology_views']['always_save_coordinates'])
|
initial=(settings.PLUGINS_CONFIG['netbox_topology_views']['always_save_coordinates']),
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
)
|
)
|
||||||
show_unconnected = forms.BooleanField(
|
show_unconnected = forms.NullBooleanField(
|
||||||
label=_('Show Unconnected'), required=False, initial=False
|
label=_('Show Unconnected'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
)
|
)
|
||||||
show_cables = forms.BooleanField(
|
|
||||||
label =_('Show Cables'), required=False, initial=False
|
show_cables = forms.NullBooleanField(
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
label=_('Show Cables'),
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
)
|
)
|
||||||
show_logical_connections = forms.BooleanField(
|
|
||||||
label =_('Show Logical Connections'), required=False, initial=False
|
show_logical_connections = forms.NullBooleanField(
|
||||||
|
label =_('Show Logical Connections'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
)
|
)
|
||||||
show_single_cable_logical_conns = forms.BooleanField(
|
show_single_cable_logical_conns = forms.NullBooleanField(
|
||||||
label =_('Show redundant Cable and Logical Connection'), required=False, initial=False
|
label =_('Show redundant Cable and Logical Connection'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
)
|
)
|
||||||
show_neighbors = forms.BooleanField(
|
show_neighbors = forms.NullBooleanField(
|
||||||
label =_('Show Neighbors'), required=False, initial=False
|
label =_('Show Neighbors'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
)
|
)
|
||||||
show_circuit = forms.BooleanField(
|
show_circuit = forms.NullBooleanField(
|
||||||
label=_('Show Circuit Terminations'), required=False, initial=False
|
label=_('Show Circuit Terminations'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
)
|
)
|
||||||
show_power = forms.BooleanField(
|
show_power = forms.NullBooleanField(
|
||||||
label=_('Show Power Feeds'), required=False, initial=False
|
label=_('Show Power Feeds'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
)
|
)
|
||||||
show_wireless = forms.BooleanField(
|
show_wireless = forms.NullBooleanField(
|
||||||
label =_('Show Wireless Links'), required=False, initial=False
|
label =_('Show Wireless Links'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
group_sites = forms.NullBooleanField(
|
||||||
|
label =_('Group Sites'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
group_locations = forms.NullBooleanField(
|
||||||
|
label =_('Group Locations'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
group_racks = forms.NullBooleanField(
|
||||||
|
label =_('Group Racks'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
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 = (
|
||||||
('Group Details', ('name', 'description')),
|
FieldSet('name', 'description', name=_("Group Details")),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -275,7 +358,7 @@ class CoordinateGroupsImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
class CircuitCoordinatesForm(NetBoxModelForm):
|
class CircuitCoordinatesForm(NetBoxModelForm):
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
('CircuitCoordinate', ('group', 'device', 'x', 'y')),
|
FieldSet('group', 'device', 'x', 'y', name=_("Circuit Coordinate")),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -284,7 +367,7 @@ class CircuitCoordinatesForm(NetBoxModelForm):
|
|||||||
|
|
||||||
class PowerPanelCoordinatesForm(NetBoxModelForm):
|
class PowerPanelCoordinatesForm(NetBoxModelForm):
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
('PowerPanel', ('group', 'device', 'x', 'y')),
|
FieldSet('group', 'device', 'x', 'y', name=_("Power Panel")),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -293,7 +376,7 @@ class PowerPanelCoordinatesForm(NetBoxModelForm):
|
|||||||
|
|
||||||
class PowerFeedCoordinatesForm(NetBoxModelForm):
|
class PowerFeedCoordinatesForm(NetBoxModelForm):
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
('PowerFeedCoordinate', ('group', 'device', 'x', 'y')),
|
FieldSet('group', 'device', 'x', 'y', name=_("PowerFeed Coordinate")),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -302,7 +385,7 @@ class PowerFeedCoordinatesForm(NetBoxModelForm):
|
|||||||
|
|
||||||
class CoordinatesForm(NetBoxModelForm):
|
class CoordinatesForm(NetBoxModelForm):
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
('Coordinate', ('group', 'device', 'x', 'y')),
|
FieldSet('group', 'device', 'x', 'y', name=_("Coordinate")),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -332,8 +415,8 @@ class CoordinatesImportForm(NetBoxModelImportForm):
|
|||||||
class CircuitCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
class CircuitCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
||||||
model = CircuitCoordinate
|
model = CircuitCoordinate
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, ('q', 'filter_id')),
|
FieldSet('q', 'filter_id'),
|
||||||
('CircuitCoordinates', ('group', 'device', 'x', 'y'))
|
FieldSet('group', 'device', 'x', 'y', name=_("Circuit Coordinates")),
|
||||||
)
|
)
|
||||||
|
|
||||||
group = forms.ModelMultipleChoiceField(
|
group = forms.ModelMultipleChoiceField(
|
||||||
@@ -357,8 +440,8 @@ class CircuitCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
|||||||
class PowerPanelCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
class PowerPanelCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
||||||
model = PowerPanelCoordinate
|
model = PowerPanelCoordinate
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, ('q', 'filter_id')),
|
FieldSet('q', 'filter_id'),
|
||||||
('PowerPanelCoordinates', ('group', 'device', 'x', 'y'))
|
FieldSet('group', 'device', 'x', 'y', name=_('PowerPanel Coordinates')),
|
||||||
)
|
)
|
||||||
|
|
||||||
group = forms.ModelMultipleChoiceField(
|
group = forms.ModelMultipleChoiceField(
|
||||||
@@ -382,8 +465,8 @@ class PowerPanelCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
|||||||
class PowerFeedCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
class PowerFeedCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
||||||
model = Coordinate
|
model = Coordinate
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, ('q', 'filter_id')),
|
FieldSet('q', 'filter_id'),
|
||||||
('PowerFeedCoordinates', ('group', 'device', 'x', 'y'))
|
FieldSet('group', 'device', 'x', 'y', name=_("PowerFeed Coordinates")),
|
||||||
)
|
)
|
||||||
|
|
||||||
group = forms.ModelMultipleChoiceField(
|
group = forms.ModelMultipleChoiceField(
|
||||||
@@ -407,8 +490,8 @@ class PowerFeedCoordinatesFilterForm(NetBoxModelFilterSetForm):
|
|||||||
class CoordinatesFilterForm(NetBoxModelFilterSetForm):
|
class CoordinatesFilterForm(NetBoxModelFilterSetForm):
|
||||||
model = Coordinate
|
model = Coordinate
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, ('q', 'filter_id')),
|
FieldSet('q', 'filter_id'),
|
||||||
('Coordinates', ('group', 'device', 'x', 'y'))
|
FieldSet('group', 'device', 'x', 'y', name=_("Coordinates")),
|
||||||
)
|
)
|
||||||
|
|
||||||
group = forms.ModelMultipleChoiceField(
|
group = forms.ModelMultipleChoiceField(
|
||||||
@@ -431,10 +514,8 @@ class CoordinatesFilterForm(NetBoxModelFilterSetForm):
|
|||||||
|
|
||||||
class IndividualOptionsForm(NetBoxModelForm):
|
class IndividualOptionsForm(NetBoxModelForm):
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(
|
FieldSet
|
||||||
None,
|
|
||||||
(
|
(
|
||||||
'user_id',
|
|
||||||
'ignore_cable_type',
|
'ignore_cable_type',
|
||||||
'preselected_device_roles',
|
'preselected_device_roles',
|
||||||
'preselected_tags',
|
'preselected_tags',
|
||||||
@@ -447,16 +528,22 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'show_circuit',
|
'show_circuit',
|
||||||
'show_power',
|
'show_power',
|
||||||
'show_wireless',
|
'show_wireless',
|
||||||
|
'group_sites',
|
||||||
|
'group_locations',
|
||||||
|
'group_racks',
|
||||||
|
'group_virtualchassis',
|
||||||
'draw_default_layout',
|
'draw_default_layout',
|
||||||
|
'straight_cables',
|
||||||
|
'grid_size',
|
||||||
|
'node_label_items',
|
||||||
),
|
),
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
user_id = forms.CharField(widget=forms.HiddenInput())
|
user_id = forms.CharField(widget=forms.HiddenInput())
|
||||||
|
|
||||||
ignore_cable_type = forms.MultipleChoiceField(
|
ignore_cable_type = forms.MultipleChoiceField(
|
||||||
label=_('Ignore Termination Types'),
|
label=_('Ignore Termination Types'),
|
||||||
required=False,
|
required=False,
|
||||||
choices=IndividualOptions.CHOICES,
|
choices=IndividualOptions.CHOICES,
|
||||||
help_text=_('Choose Termination Types that you want to be ignored. '
|
help_text=_('Choose Termination Types that you want to be ignored. '
|
||||||
'If any ignored Termination Type is part of a connection, the '
|
'If any ignored Termination Type is part of a connection, the '
|
||||||
@@ -477,8 +564,8 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'preselected in the filter tab.')
|
'preselected in the filter tab.')
|
||||||
)
|
)
|
||||||
save_coords = forms.BooleanField(
|
save_coords = forms.BooleanField(
|
||||||
label=_('Save Coordinates'),
|
label=_('Save Coordinates'),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
help_text=_('Coordinates of nodes will be saved if dragged to a different '
|
help_text=_('Coordinates of nodes will be saved if dragged to a different '
|
||||||
'position. This option depends on parameters set in the config file. '
|
'position. This option depends on parameters set in the config file. '
|
||||||
@@ -486,24 +573,24 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
' \'always_save_coordinates\' has been set.')
|
' \'always_save_coordinates\' has been set.')
|
||||||
)
|
)
|
||||||
show_unconnected = forms.BooleanField(
|
show_unconnected = forms.BooleanField(
|
||||||
label=_('Show Unconnected'),
|
label=_('Show Unconnected'),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
help_text=_('Draws devices that have no connections or for which no '
|
help_text=_('Draws devices that have no connections or for which no '
|
||||||
'connection is displayed. This option depends on other parameters '
|
'connection is displayed. This option depends on other parameters '
|
||||||
'like \'Show Cables\' and \'Show Logical Connections\'.')
|
'like \'Show Cables\' and \'Show Logical Connections\'.')
|
||||||
)
|
)
|
||||||
show_cables = forms.BooleanField(
|
show_cables = forms.BooleanField(
|
||||||
label =_('Show Cables'),
|
label =_('Show Cables'),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
help_text=_('Displays connections between interfaces that are connected '
|
help_text=_('Displays connections between interfaces that are connected '
|
||||||
'with one or more cables. These connections are displayed as solid '
|
'with one or more cables. These connections are displayed as solid '
|
||||||
'lines in the color of the cable.')
|
'lines in the color of the cable.')
|
||||||
)
|
)
|
||||||
show_logical_connections = forms.BooleanField(
|
show_logical_connections = forms.BooleanField(
|
||||||
label =_('Show Logical Connections'),
|
label =_('Show Logical Connections'),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
help_text=_('Displays connections between devices that are not '
|
help_text=_('Displays connections between devices that are not '
|
||||||
'directly connected (e.g. via patch panels). These connections '
|
'directly connected (e.g. via patch panels). These connections '
|
||||||
@@ -519,35 +606,63 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'has an effect if \'Show Logical Connections\' is activated.')
|
'has an effect if \'Show Logical Connections\' is activated.')
|
||||||
)
|
)
|
||||||
show_neighbors = forms.BooleanField(
|
show_neighbors = forms.BooleanField(
|
||||||
label =_('Show Neighbors'),
|
label =_('Show Neighbors'),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
help_text=_('Adds neighbors to the filter result set automatically. '
|
help_text=_('Adds neighbors to the filter result set automatically. '
|
||||||
'Link peers will be added if \'Show Cables\' is ticked, far-end '
|
'Link peers will be added if \'Show Cables\' is ticked, far-end '
|
||||||
'terminations will be added if \'Show Logical Connections\' is ticked.')
|
'terminations will be added if \'Show Logical Connections\' is ticked.')
|
||||||
)
|
)
|
||||||
show_circuit = forms.BooleanField(
|
show_circuit = forms.BooleanField(
|
||||||
label=_('Show Circuit Terminations'),
|
label=_('Show Circuit Terminations'),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
help_text=_('Displays connections between circuit terminations. '
|
help_text=_('Displays connections between circuit terminations. '
|
||||||
'These connections are displayed as blue dashed lines.')
|
'These connections are displayed as blue dashed lines.')
|
||||||
)
|
)
|
||||||
show_power = forms.BooleanField(
|
show_power = forms.BooleanField(
|
||||||
label=_('Show Power Feeds'),
|
label=_('Show Power Feeds'),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
help_text=_('Displays connections between power outlets and power '
|
help_text=_('Displays connections between power outlets and power '
|
||||||
'ports. These connections are displayed as solid lines in the '
|
'ports. These connections are displayed as solid lines in the '
|
||||||
'color of the cable. This option depends on \'Show Cables\'.')
|
'color of the cable. This option depends on \'Show Cables\'.')
|
||||||
)
|
)
|
||||||
show_wireless = forms.BooleanField(
|
show_wireless = forms.BooleanField(
|
||||||
label =_('Show Wireless Links'),
|
label =_('Show Wireless Links'),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
help_text=_('Displays wireless connections. These connections are '
|
help_text=_('Displays wireless connections. These connections are '
|
||||||
'displayed as blue dotted lines.')
|
'displayed as blue dotted lines.')
|
||||||
)
|
)
|
||||||
|
group_sites = forms.BooleanField(
|
||||||
|
label =_('Group Sites'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
help_text=_('Draws a rectangle around Devices that belong to the '
|
||||||
|
'same site.')
|
||||||
|
)
|
||||||
|
group_locations = forms.BooleanField(
|
||||||
|
label =_('Group Locations'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
help_text=_('Draws a rectangle around Devices that belong to the '
|
||||||
|
'same location.')
|
||||||
|
)
|
||||||
|
group_racks = forms.BooleanField(
|
||||||
|
label =_('Group Racks'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
help_text=_('Draws a rectangle around Devices that belong to the '
|
||||||
|
'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,
|
||||||
@@ -555,9 +670,36 @@ 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
|
||||||
fields = [
|
fields = [
|
||||||
'user_id', 'ignore_cable_type', 'preselected_device_roles', 'preselected_tags', 'save_coords', 'show_unconnected', 'show_cables', 'show_logical_connections', 'show_single_cable_logical_conns', 'show_neighbors', 'show_circuit', 'show_power', 'show_wireless', 'draw_default_layout'
|
'user_id', 'ignore_cable_type', 'preselected_device_roles', 'preselected_tags',
|
||||||
]
|
'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'
|
||||||
|
]
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 4.2.10 on 2024-03-02 16:26
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('netbox_topology_views', '0006_powerpanelcoordinate_powerfeedcoordinate_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='group_locations',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='group_racks',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='group_sites',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -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:
|
||||||
@@ -41,6 +42,8 @@ class RoleImage(ChangeLoggingMixin, ExportTemplatesMixin, EventRulesMixin):
|
|||||||
|
|
||||||
__role: Optional[Role] = None
|
__role: Optional[Role] = None
|
||||||
|
|
||||||
|
_netbox_private = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def role(self) -> Role:
|
def role(self) -> Role:
|
||||||
if self.__role:
|
if self.__role:
|
||||||
@@ -111,6 +114,8 @@ class CoordinateGroup(NetBoxModel):
|
|||||||
blank = True,
|
blank = True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_netbox_private = True
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
|
|
||||||
@@ -138,6 +143,8 @@ class Coordinate(NetBoxModel):
|
|||||||
'Smaller values correspond to a position further up on the monitor.',
|
'Smaller values correspond to a position further up on the monitor.',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_netbox_private = True
|
||||||
|
|
||||||
def get_or_create_default_group(group_id):
|
def get_or_create_default_group(group_id):
|
||||||
# Default group named "default" must always exist in order to make sure
|
# Default group named "default" must always exist in order to make sure
|
||||||
# that coordinate values can be stored even if no coordinate group has been
|
# that coordinate values can be stored even if no coordinate group has been
|
||||||
@@ -187,6 +194,8 @@ class CircuitCoordinate(NetBoxModel):
|
|||||||
'Smaller values correspond to a position further up on the monitor.',
|
'Smaller values correspond to a position further up on the monitor.',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_netbox_private = True
|
||||||
|
|
||||||
def get_or_create_default_group(group_id):
|
def get_or_create_default_group(group_id):
|
||||||
# Default group named "default" must always exist in order to make sure
|
# Default group named "default" must always exist in order to make sure
|
||||||
# that coordinate values can be stored even if no coordinate group has been
|
# that coordinate values can be stored even if no coordinate group has been
|
||||||
@@ -236,6 +245,8 @@ class PowerPanelCoordinate(NetBoxModel):
|
|||||||
'Smaller values correspond to a position further up on the monitor.',
|
'Smaller values correspond to a position further up on the monitor.',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_netbox_private = True
|
||||||
|
|
||||||
def get_or_create_default_group(group_id):
|
def get_or_create_default_group(group_id):
|
||||||
# Default group named "default" must always exist in order to make sure
|
# Default group named "default" must always exist in order to make sure
|
||||||
# that coordinate values can be stored even if no coordinate group has been
|
# that coordinate values can be stored even if no coordinate group has been
|
||||||
@@ -285,6 +296,8 @@ class PowerFeedCoordinate(NetBoxModel):
|
|||||||
'Smaller values correspond to a position further up on the monitor.',
|
'Smaller values correspond to a position further up on the monitor.',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_netbox_private = True
|
||||||
|
|
||||||
def get_or_create_default_group(group_id):
|
def get_or_create_default_group(group_id):
|
||||||
# Default group named "default" must always exist in order to make sure
|
# Default group named "default" must always exist in order to make sure
|
||||||
# that coordinate values can be stored even if no coordinate group has been
|
# that coordinate values can be stored even if no coordinate group has been
|
||||||
@@ -319,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(
|
||||||
@@ -374,9 +387,33 @@ class IndividualOptions(NetBoxModel):
|
|||||||
show_wireless = models.BooleanField(
|
show_wireless = models.BooleanField(
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
group_sites = models.BooleanField(
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
group_locations = models.BooleanField(
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
group_racks = models.BooleanField(
|
||||||
|
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
|
||||||
|
|
||||||
def __str___(self):
|
def __str___(self):
|
||||||
return f"{self.user_id}"
|
return f"{self.user_id}"
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
from extras.plugins import PluginMenu, PluginMenuItem, PluginMenuButton
|
from netbox.plugins import PluginMenu, PluginMenuItem, PluginMenuButton
|
||||||
from utilities.choices import ButtonColorChoices
|
|
||||||
|
|
||||||
coordinategroup_buttons = (
|
coordinategroup_buttons = (
|
||||||
PluginMenuButton(
|
PluginMenuButton(
|
||||||
link='plugins:netbox_topology_views:coordinategroup_add',
|
link='plugins:netbox_topology_views:coordinategroup_add',
|
||||||
title='Add',
|
title='Add',
|
||||||
icon_class='mdi mdi-plus-thick',
|
icon_class='mdi mdi-plus-thick',
|
||||||
color=ButtonColorChoices.GREEN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinategroup']
|
permissions=['netbox_topology_views.add_coordinategroup']
|
||||||
),
|
),
|
||||||
PluginMenuButton(
|
PluginMenuButton(
|
||||||
link='plugins:netbox_topology_views:coordinategroup_import',
|
link='plugins:netbox_topology_views:coordinategroup_import',
|
||||||
title='Import',
|
title='Import',
|
||||||
icon_class='mdi mdi-upload',
|
icon_class='mdi mdi-upload',
|
||||||
color=ButtonColorChoices.CYAN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinategroup']
|
permissions=['netbox_topology_views.add_coordinategroup']
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -23,14 +20,12 @@ circuitcoordinate_buttons = (
|
|||||||
link='plugins:netbox_topology_views:circuitcoordinate_add',
|
link='plugins:netbox_topology_views:circuitcoordinate_add',
|
||||||
title='Add',
|
title='Add',
|
||||||
icon_class='mdi mdi-plus-thick',
|
icon_class='mdi mdi-plus-thick',
|
||||||
color=ButtonColorChoices.GREEN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinate']
|
permissions=['netbox_topology_views.add_coordinate']
|
||||||
),
|
),
|
||||||
PluginMenuButton(
|
PluginMenuButton(
|
||||||
link='plugins:netbox_topology_views:circuitcoordinate_import',
|
link='plugins:netbox_topology_views:circuitcoordinate_import',
|
||||||
title='Import',
|
title='Import',
|
||||||
icon_class='mdi mdi-upload',
|
icon_class='mdi mdi-upload',
|
||||||
color=ButtonColorChoices.CYAN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinate']
|
permissions=['netbox_topology_views.add_coordinate']
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -40,14 +35,12 @@ powerpanelcoordinate_buttons = (
|
|||||||
link='plugins:netbox_topology_views:powerpanelcoordinate_add',
|
link='plugins:netbox_topology_views:powerpanelcoordinate_add',
|
||||||
title='Add',
|
title='Add',
|
||||||
icon_class='mdi mdi-plus-thick',
|
icon_class='mdi mdi-plus-thick',
|
||||||
color=ButtonColorChoices.GREEN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinate']
|
permissions=['netbox_topology_views.add_coordinate']
|
||||||
),
|
),
|
||||||
PluginMenuButton(
|
PluginMenuButton(
|
||||||
link='plugins:netbox_topology_views:powerpanelcoordinate_import',
|
link='plugins:netbox_topology_views:powerpanelcoordinate_import',
|
||||||
title='Import',
|
title='Import',
|
||||||
icon_class='mdi mdi-upload',
|
icon_class='mdi mdi-upload',
|
||||||
color=ButtonColorChoices.CYAN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinate']
|
permissions=['netbox_topology_views.add_coordinate']
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -57,14 +50,12 @@ powerfeedcoordinate_buttons = (
|
|||||||
link='plugins:netbox_topology_views:powerfeedcoordinate_add',
|
link='plugins:netbox_topology_views:powerfeedcoordinate_add',
|
||||||
title='Add',
|
title='Add',
|
||||||
icon_class='mdi mdi-plus-thick',
|
icon_class='mdi mdi-plus-thick',
|
||||||
color=ButtonColorChoices.GREEN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinate']
|
permissions=['netbox_topology_views.add_coordinate']
|
||||||
),
|
),
|
||||||
PluginMenuButton(
|
PluginMenuButton(
|
||||||
link='plugins:netbox_topology_views:powerfeedcoordinate_import',
|
link='plugins:netbox_topology_views:powerfeedcoordinate_import',
|
||||||
title='Import',
|
title='Import',
|
||||||
icon_class='mdi mdi-upload',
|
icon_class='mdi mdi-upload',
|
||||||
color=ButtonColorChoices.CYAN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinate']
|
permissions=['netbox_topology_views.add_coordinate']
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -74,14 +65,12 @@ coordinate_buttons = (
|
|||||||
link='plugins:netbox_topology_views:coordinate_add',
|
link='plugins:netbox_topology_views:coordinate_add',
|
||||||
title='Add',
|
title='Add',
|
||||||
icon_class='mdi mdi-plus-thick',
|
icon_class='mdi mdi-plus-thick',
|
||||||
color=ButtonColorChoices.GREEN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinate']
|
permissions=['netbox_topology_views.add_coordinate']
|
||||||
),
|
),
|
||||||
PluginMenuButton(
|
PluginMenuButton(
|
||||||
link='plugins:netbox_topology_views:coordinate_import',
|
link='plugins:netbox_topology_views:coordinate_import',
|
||||||
title='Import',
|
title='Import',
|
||||||
icon_class='mdi mdi-upload',
|
icon_class='mdi mdi-upload',
|
||||||
color=ButtonColorChoices.CYAN,
|
|
||||||
permissions=['netbox_topology_views.add_coordinate']
|
permissions=['netbox_topology_views.add_coordinate']
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -69,12 +69,136 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
title: htmlTitle(node.title)
|
title: htmlTitle(node.title)
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const group_sites = topologyData.options.group_sites
|
||||||
|
const group_locations = topologyData.options.group_locations
|
||||||
|
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) => {
|
||||||
if (coordSaveCheckbox == null) return
|
dragMode = false;
|
||||||
if (!coordSaveCheckbox.checked) return
|
// 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
|
||||||
|
|
||||||
Promise.allSettled(
|
Promise.allSettled(
|
||||||
Object.entries(graph.getPositions(params.nodes)).map(
|
Object.entries(graph.getPositions(params.nodes)).map(
|
||||||
@@ -133,6 +257,227 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
graph.on('beforeDrawing', (canvascontext) => {
|
||||||
|
if (gridSize > 0) {
|
||||||
|
drawGrid(canvascontext);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
graph.on('afterDrawing', (canvascontext) => {
|
||||||
|
allRectangles = [];
|
||||||
|
if(group_sites != null && group_sites == 'on') { drawGroupRectangles(canvascontext, groupedNodeSites, siteRectParams); }
|
||||||
|
if(group_locations != null && group_locations == 'on') { drawGroupRectangles(canvascontext, groupedNodeLocations, locationRectParams); }
|
||||||
|
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) => {
|
||||||
|
allRectangles.forEach(key => {
|
||||||
|
// Is the mouse pointer inside of the current rectangle?
|
||||||
|
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 - 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
|
||||||
|
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 + 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
|
||||||
|
let arr = [];
|
||||||
|
if(key.category == "Site") {
|
||||||
|
groupedNodeSites.forEach(subArray => {
|
||||||
|
subArray.forEach(element => {
|
||||||
|
if (element[1] == key.id) {
|
||||||
|
arr.push(element[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(key.category == "Location") {
|
||||||
|
groupedNodeLocations.forEach(subArray => {
|
||||||
|
subArray.forEach(element => {
|
||||||
|
if (element[1] === key.id) {
|
||||||
|
arr.push(element[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(key.category == "Rack") {
|
||||||
|
groupedNodeRacks.forEach(subArray => {
|
||||||
|
subArray.forEach(element => {
|
||||||
|
if (element[1] === key.id) {
|
||||||
|
arr.push(element[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(key.category == "Virtual Chassis") {
|
||||||
|
groupedNodeVirtualchassis.forEach(subArray => {
|
||||||
|
subArray.forEach(element => {
|
||||||
|
if (element[1] === key.id) {
|
||||||
|
arr.push(element[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
graph.selectNodes(arr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 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
|
||||||
|
function combineNodeInfo(typeId, type) {
|
||||||
|
let nodesArray = [];
|
||||||
|
// Extract node ids and node type ids from all nodes
|
||||||
|
for (let [key, value] of nodes._data) {
|
||||||
|
if (value[typeId] != undefined) {
|
||||||
|
nodesArray.push([value.id, value[typeId], value[type], value.label_num_lines]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Split single array above into arrays grouped by node id
|
||||||
|
let groupedNodeArray = nodesArray.reduce((acc, value) => {
|
||||||
|
let key = value[1]; // node id
|
||||||
|
acc[key] = acc[key] || [];
|
||||||
|
acc[key].push(value);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
return Object.values(groupedNodeArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
var allRectangles = [];
|
||||||
|
/* Draw a single rectangle with given parameters
|
||||||
|
rectangle expects an object that consists of the following keys:
|
||||||
|
ctx: canvas context on which the rectangle should be drawn
|
||||||
|
x: x-coordinate of top left point of the rectangle
|
||||||
|
y: y-coordinate of top left point of the rectangle
|
||||||
|
width: width of rectangle
|
||||||
|
height: height of rectangle
|
||||||
|
lineWidth: border width
|
||||||
|
color: border color
|
||||||
|
text: a string to be placed where you want it to be
|
||||||
|
textPaddingX: x-position of the text
|
||||||
|
textPaddingY: y-position of the text
|
||||||
|
font: text font */
|
||||||
|
function drawGroupRectangle(rectangle) {
|
||||||
|
// Draw rectangle
|
||||||
|
rectangle.ctx.beginPath();
|
||||||
|
rectangle.ctx.lineWidth = rectangle.lineWidth;
|
||||||
|
rectangle.ctx.strokeStyle = rectangle.color;
|
||||||
|
rectangle.ctx.rect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
|
||||||
|
rectangle.ctx.stroke();
|
||||||
|
// Draw text
|
||||||
|
rectangle.ctx.font = rectangle.font;
|
||||||
|
rectangle.ctx.fillStyle = rectangle.color;
|
||||||
|
rectangle.ctx.fillText(rectangle.text, rectangle.x + rectangle.textPaddingX, rectangle.y + rectangle.textPaddingY);
|
||||||
|
|
||||||
|
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//virtualchassis)
|
||||||
|
rectParams expects an object that consists of the following keys:
|
||||||
|
lineWidth: border width (string)
|
||||||
|
color: border color (string)
|
||||||
|
paddingX: rectangle x-padding, calculated from the center of a node (int)
|
||||||
|
paddingY: rectangle y-padding, calculated from the center of a node (int)
|
||||||
|
textPaddingX: text x-padding, calculated from the lower left point of the text (int)
|
||||||
|
textPaddingY: text y-padding, calculated from the lower left point of the text (int)
|
||||||
|
font: css-like font size and font (string) */
|
||||||
|
function drawGroupRectangles(canvascontext, groupedNodes, rectParams) {
|
||||||
|
for(let value of Object.entries(groupedNodes)) {
|
||||||
|
const rectangles = [];
|
||||||
|
const xValues = [];
|
||||||
|
const yValues = [];
|
||||||
|
const yValuesWithLabel = [];
|
||||||
|
const labelLineHeight = 16;
|
||||||
|
|
||||||
|
// Get coordinates for every node in a given group
|
||||||
|
for(let val of value[1]) {
|
||||||
|
xValues.push(graph.getPosition(val[0]).x);
|
||||||
|
yValues.push(graph.getPosition(val[0]).y);
|
||||||
|
yValuesWithLabel.push(yValues[yValues.length -1] + val[3] * labelLineHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
const minX = Math.min(...xValues);
|
||||||
|
const maxX = Math.max(...xValues);
|
||||||
|
const minY = Math.min(...yValues);
|
||||||
|
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({
|
||||||
|
ctx: canvascontext,
|
||||||
|
x: rectX,
|
||||||
|
y: rectY,
|
||||||
|
width: rectSizeX,
|
||||||
|
height: rectSizeY,
|
||||||
|
lineWidth: rectParams.lineWidth,
|
||||||
|
color: rectParams.color,
|
||||||
|
text: value[1][0][2],
|
||||||
|
textPaddingX: rectParams.textPaddingX,
|
||||||
|
textPaddingY: rectParams.textPaddingY,
|
||||||
|
font: rectParams.font,
|
||||||
|
id: value[1][0][1],
|
||||||
|
category: rectParams.category
|
||||||
|
});
|
||||||
|
|
||||||
|
rectangles.forEach(function(rectangle) {
|
||||||
|
drawGroupRectangle(rectangle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let groupedNodeSites = combineNodeInfo('site_id', 'site');
|
||||||
|
let siteRectParams = {
|
||||||
|
lineWidth: "5",
|
||||||
|
color: "red",
|
||||||
|
paddingX: 84,
|
||||||
|
paddingY: 84,
|
||||||
|
textPaddingX: 8,
|
||||||
|
textPaddingY: -8,
|
||||||
|
font: "14px helvetica",
|
||||||
|
category: "Site"
|
||||||
|
}
|
||||||
|
|
||||||
|
let groupedNodeLocations = combineNodeInfo('location_id', 'location');
|
||||||
|
let locationRectParams = {
|
||||||
|
lineWidth: "5",
|
||||||
|
color: "#337ab7",
|
||||||
|
paddingX: 77,
|
||||||
|
paddingY: 77,
|
||||||
|
textPaddingX: 22,
|
||||||
|
textPaddingY: 29,
|
||||||
|
font: "14px helvetica",
|
||||||
|
category: "Location"
|
||||||
|
}
|
||||||
|
|
||||||
|
let groupedNodeRacks = combineNodeInfo('rack_id', 'rack');
|
||||||
|
let rackRectParams = {
|
||||||
|
lineWidth: "5",
|
||||||
|
color: "green",
|
||||||
|
paddingX: 70,
|
||||||
|
paddingY: 70,
|
||||||
|
textPaddingX: 15,
|
||||||
|
textPaddingY: 36,
|
||||||
|
font: "14px helvetica",
|
||||||
|
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
|
||||||
@@ -174,12 +519,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 {
|
||||||
@@ -208,17 +553,17 @@ const observer = new MutationObserver((mutations) =>
|
|||||||
if (
|
if (
|
||||||
!graph ||
|
!graph ||
|
||||||
mutation.type !== 'attributes' ||
|
mutation.type !== 'attributes' ||
|
||||||
mutation.attributeName !== 'data-netbox-color-mode' ||
|
mutation.attributeName !== 'data-bs-theme' ||
|
||||||
!(mutation.target instanceof HTMLElement)
|
!(mutation.target instanceof HTMLElement)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
const { netboxColorMode } = mutation.target.dataset
|
const netboxColorMode = mutation.target.dataset.bsTheme
|
||||||
options.nodes.font.color = netboxColorMode === 'dark' ? '#fff' : '#000'
|
options.nodes.font.color = netboxColorMode === 'dark' ? '#fff' : '#000'
|
||||||
graph.setOptions(options)
|
graph.setOptions(options)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
observer.observe(document.documentElement, {
|
observer.observe(document.body, {
|
||||||
attributes: true,
|
attributes: true,
|
||||||
attributeFilter: ['data-netbox-color-mode']
|
attributeFilter: ['data-bs-theme']
|
||||||
})
|
})
|
||||||
|
|||||||
+1331
-900
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": "3.9.0",
|
"version": "4.2.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,18 +1,18 @@
|
|||||||
|
|
||||||
from extras.plugins import PluginTemplateExtension
|
from netbox.plugins import PluginTemplateExtension
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from packaging import version
|
from packaging import version
|
||||||
|
|
||||||
NETBOX_CURRENT_VERSION = version.parse(settings.VERSION)
|
NETBOX_CURRENT_VERSION = version.parse(settings.RELEASE.version)
|
||||||
|
|
||||||
|
|
||||||
class SiteButtons(PluginTemplateExtension):
|
class SiteButtons(PluginTemplateExtension):
|
||||||
model = 'dcim.site'
|
models = ('dcim.site', )
|
||||||
def buttons(self):
|
def buttons(self):
|
||||||
return self.render('netbox_topology_views/site_button.html')
|
return self.render('netbox_topology_views/site_button.html')
|
||||||
|
|
||||||
class LocationButtons(PluginTemplateExtension):
|
class LocationButtons(PluginTemplateExtension):
|
||||||
model = 'dcim.location'
|
models = ('dcim.location', )
|
||||||
def buttons(self):
|
def buttons(self):
|
||||||
return self.render('netbox_topology_views/location_button.html')
|
return self.render('netbox_topology_views/location_button.html')
|
||||||
|
|
||||||
|
|||||||
@@ -8,15 +8,15 @@
|
|||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
{% block extra_controls %}{% endblock %}
|
{% block extra_controls %}{% endblock %}
|
||||||
<a id="btnDownloadXml" class="btn btn-sm btn-info" href="#">
|
<a id="btnDownloadXml" class="btn btn-info" href="#">
|
||||||
<i class="mdi mdi-download"></i>
|
<i class="mdi mdi-download"></i>
|
||||||
Download XML
|
Download XML
|
||||||
</a>
|
</a>
|
||||||
<a id="btnDownloadImage" class="btn btn-sm btn-info" href="#">
|
<a id="btnDownloadImage" class="btn btn-info" href="#">
|
||||||
<i class="mdi mdi-download"></i>
|
<i class="mdi mdi-download"></i>
|
||||||
Download PNG
|
Download PNG
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-sm btn-danger" data-bs-dismiss="modal">
|
<a class="btn btn-danger" data-bs-dismiss="modal">
|
||||||
<i class="mdi mdi-close-thick"></i>
|
<i class="mdi mdi-close-thick"></i>
|
||||||
Close
|
Close
|
||||||
</a>
|
</a>
|
||||||
@@ -40,5 +40,6 @@
|
|||||||
var is_htmx = true;
|
var is_htmx = true;
|
||||||
var brokenImage = '{{ broken_image }}';
|
var brokenImage = '{{ broken_image }}';
|
||||||
var topologyData = {{ topology_data | safe }};
|
var topologyData = {{ topology_data | safe }};
|
||||||
|
const basePath = '{{ basepath }}';
|
||||||
</script>
|
</script>
|
||||||
<script src="{% static 'netbox_topology_views/js/app.js' %}?ver={{ epoch }} " defer></script>
|
<script src="{% static 'netbox_topology_views/js/app.js' %}?ver={{ epoch }} " defer></script>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<link rel="stylesheet" href="{% static 'netbox_topology_views/css/app.css' %}">
|
<link rel="stylesheet" href="{% static 'netbox_topology_views/css/app.css' %}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content-wrapper %}
|
{% block content %}
|
||||||
<form id="images" class="container py-4">
|
<form id="images" class="container py-4">
|
||||||
<div class="d-flex flex-wrap justify-content-center gap-3 mb-2">
|
<div class="d-flex flex-wrap justify-content-center gap-3 mb-2">
|
||||||
{% for role in roles %}
|
{% for role in roles %}
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
<button class="btn btn-primary" type="submit">Save</button>
|
<button class="btn btn-primary" type="submit">Save</button>
|
||||||
</form>
|
</form>
|
||||||
{% include 'netbox_topology_views/toasts.html' %}
|
{% include 'netbox_topology_views/toasts.html' %}
|
||||||
{% endblock content-wrapper %}
|
{% endblock content %}
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{% extends 'base/layout.html' %}
|
{% extends 'generic/_base.html' %}
|
||||||
{% load buttons %}
|
{% load buttons %}
|
||||||
{% load render_table from django_tables2 %}
|
{% load render_table from django_tables2 %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
{% block extra_controls %}{% endblock %}
|
{% block extra_controls %}{% endblock %}
|
||||||
<a id="btnDownloadXml" class="btn btn-sm btn-info" href="#">
|
<a id="btnDownloadXml" class="btn btn-info" href="#">
|
||||||
<i class="mdi mdi-download"></i>
|
<i class="mdi mdi-download"></i>
|
||||||
Download XML
|
Download XML
|
||||||
</a>
|
</a>
|
||||||
<a id="btnDownloadImage" class="btn btn-sm btn-info" href="#">
|
<a id="btnDownloadImage" class="btn btn-info" href="#">
|
||||||
<i class="mdi mdi-download"></i>
|
<i class="mdi mdi-download"></i>
|
||||||
Download PNG
|
Download PNG
|
||||||
</a>
|
</a>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
{% endblock controls %}
|
{% endblock controls %}
|
||||||
|
|
||||||
{% block tabs %}
|
{% block tabs %}
|
||||||
<ul class="nav nav-tabs px-3" id="tabswrapper">
|
<ul class="nav nav-tabs" id="tabswrapper">
|
||||||
{% block tab_items %}
|
{% block tab_items %}
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link active" id="network-tab" data-bs-toggle="tab" data-bs-target="#networks" type="button" role="tab" aria-controls="filters-form" aria-selected="true">
|
<button class="nav-link active" id="network-tab" data-bs-toggle="tab" data-bs-target="#networks" type="button" role="tab" aria-controls="filters-form" aria-selected="true">
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
{% endblock tabs %}
|
{% endblock tabs %}
|
||||||
|
|
||||||
{% block content-wrapper %}
|
{% block content %}
|
||||||
{% with config=settings.PLUGINS_CONFIG.netbox_topology_views %}
|
{% with config=settings.PLUGINS_CONFIG.netbox_topology_views %}
|
||||||
<div class="tab-content" id="tabcontentwrapper">
|
<div class="tab-content" id="tabcontentwrapper">
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endblock content-wrapper %}
|
{% endblock content %}
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -85,10 +85,9 @@
|
|||||||
resizeCanvas();
|
resizeCanvas();
|
||||||
|
|
||||||
function resizeCanvas() {
|
function resizeCanvas() {
|
||||||
heightToSubtract = getElementHeight('.navbar') +
|
heightToSubtract = getElementHeight('.page-header') +
|
||||||
getElementHeight('.title-container') +
|
getElementHeight('#tabswrapper') +
|
||||||
getElementHeight('#tabswrapper') +
|
getElementHeight('#filterwrapper') +
|
||||||
getElementHeight('#filterwrapper') +
|
|
||||||
getElementHeight('.footer') +
|
getElementHeight('.footer') +
|
||||||
getElementPadding('#tabcontentwrapper');
|
getElementPadding('#tabcontentwrapper');
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<a role="button" class="btn btn-sm btn-primary" title="Topology" href="#" hx-get="/plugins/netbox_topology_views/topology/?location_id={{ object.id }}&show_cables=on&show_unconnected=on" hx-target="#htmx-modal-content" data-bs-toggle="modal" data-bs-target="#htmx-modal">
|
<a role="button" class="btn btn-primary" title="Topology" href="#" hx-get="/plugins/netbox_topology_views/topology/?location_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>
|
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||||
Topology
|
Topology
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<a role="button" class="btn btn-sm btn-primary" title="Topology" href="#" hx-get="/plugins/netbox_topology_views/topology/?site_id={{ object.id }}&show_cables=on&show_unconnected=on" hx-target="#htmx-modal-content" data-bs-toggle="modal" data-bs-target="#htmx-modal">
|
<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>
|
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||||
Topology
|
Topology
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -107,9 +107,13 @@ def get_model_role(model: Type[Model]) -> Role:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_query_settings(request):
|
def get_query_settings(request):
|
||||||
|
filter_id = ''
|
||||||
|
if "filter_id" in request.GET:
|
||||||
|
filter_id = request.GET["filter_id"]
|
||||||
|
|
||||||
save_coords = False
|
save_coords = False
|
||||||
if "save_coords" in request.GET:
|
if "save_coords" in request.GET:
|
||||||
if request.GET["save_coords"] == "on":
|
if request.GET["save_coords"] == "True":
|
||||||
save_coords = True
|
save_coords = True
|
||||||
# General options overrides
|
# General options overrides
|
||||||
if save_coords == True and settings.PLUGINS_CONFIG["netbox_topology_views"]["allow_coordinates_saving"] == False:
|
if save_coords == True and settings.PLUGINS_CONFIG["netbox_topology_views"]["allow_coordinates_saving"] == False:
|
||||||
@@ -119,47 +123,88 @@ 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"] == "on":
|
if request.GET["show_unconnected"] == "True":
|
||||||
show_unconnected = True
|
show_unconnected = True
|
||||||
|
|
||||||
show_power = False
|
show_power = False
|
||||||
if "show_power" in request.GET:
|
if "show_power" in request.GET:
|
||||||
if request.GET["show_power"] == "on":
|
if request.GET["show_power"] == "True":
|
||||||
show_power = True
|
show_power = True
|
||||||
|
|
||||||
show_circuit = False
|
show_circuit = False
|
||||||
if "show_circuit" in request.GET:
|
if "show_circuit" in request.GET:
|
||||||
if request.GET["show_circuit"] == "on":
|
if request.GET["show_circuit"] == "True":
|
||||||
show_circuit = True
|
show_circuit = True
|
||||||
|
|
||||||
show_logical_connections = False
|
show_logical_connections = False
|
||||||
if "show_logical_connections" in request.GET:
|
if "show_logical_connections" in request.GET:
|
||||||
if request.GET["show_logical_connections"] == "on" :
|
if request.GET["show_logical_connections"] == "True" :
|
||||||
show_logical_connections = True
|
show_logical_connections = True
|
||||||
|
|
||||||
show_single_cable_logical_conns = False
|
show_single_cable_logical_conns = False
|
||||||
if "show_single_cable_logical_conns" in request.GET:
|
if "show_single_cable_logical_conns" in request.GET:
|
||||||
if request.GET["show_single_cable_logical_conns"] == "on" :
|
if request.GET["show_single_cable_logical_conns"] == "True" :
|
||||||
show_single_cable_logical_conns = True
|
show_single_cable_logical_conns = True
|
||||||
|
|
||||||
show_cables = False
|
show_cables = False
|
||||||
if "show_cables" in request.GET:
|
if "show_cables" in request.GET:
|
||||||
if request.GET["show_cables"] == "on" :
|
if request.GET["show_cables"] == "True" :
|
||||||
show_cables = True
|
show_cables = True
|
||||||
|
|
||||||
show_wireless = False
|
show_wireless = False
|
||||||
if "show_wireless" in request.GET:
|
if "show_wireless" in request.GET:
|
||||||
if request.GET["show_wireless"] == "on" :
|
if request.GET["show_wireless"] == "True" :
|
||||||
show_wireless = True
|
show_wireless = True
|
||||||
|
|
||||||
|
group_sites = False
|
||||||
|
if "group_sites" in request.GET:
|
||||||
|
if request.GET["group_sites"] == "True" :
|
||||||
|
group_sites = True
|
||||||
|
|
||||||
|
group_locations = False
|
||||||
|
if "group_locations" in request.GET:
|
||||||
|
if request.GET["group_locations"] == "True" :
|
||||||
|
group_locations = True
|
||||||
|
|
||||||
|
group_racks = False
|
||||||
|
if "group_racks" in request.GET:
|
||||||
|
if request.GET["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"] == "on" :
|
if request.GET["show_neighbors"] == "True" :
|
||||||
show_neighbors = True
|
show_neighbors = True
|
||||||
|
|
||||||
return save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, 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]
|
||||||
|
|||||||
+161
-41
@@ -4,7 +4,6 @@ from typing import DefaultDict, Dict, Optional, Union
|
|||||||
import time
|
import time
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
from utilities.htmx import is_htmx
|
|
||||||
from circuits.models import Circuit, CircuitTermination, ProviderNetwork
|
from circuits.models import Circuit, CircuitTermination, ProviderNetwork
|
||||||
from dcim.models import (
|
from dcim.models import (
|
||||||
Cable,
|
Cable,
|
||||||
@@ -27,8 +26,9 @@ from django.db.models.functions import Lower
|
|||||||
from django.http import HttpRequest, HttpResponseRedirect, QueryDict
|
from django.http import HttpRequest, HttpResponseRedirect, QueryDict
|
||||||
from django.shortcuts import render, get_object_or_404
|
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
|
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 +78,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)
|
||||||
@@ -92,12 +92,15 @@ def get_image_for_entity(entity: Union[Device, Circuit, PowerPanel, PowerFeed]):
|
|||||||
return RoleImage.objects.get(**query).get_image_url()
|
return RoleImage.objects.get(**query).get_image_url()
|
||||||
except RoleImage.DoesNotExist:
|
except RoleImage.DoesNotExist:
|
||||||
return find_image_url(
|
return find_image_url(
|
||||||
entity.device_role.slug if is_device else get_model_slug(entity.__class__)
|
entity.role.slug if is_device else get_model_slug(entity.__class__)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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,15 +149,15 @@ 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 += (
|
||||||
f"<tr><th>Type: </th><td>{device.device_type.model}</td></tr>"
|
f"<tr><th>Type: </th><td>{device.device_type.model}</td></tr>"
|
||||||
)
|
)
|
||||||
if device.device_role.name is not None:
|
if device.role.name is not None:
|
||||||
node_content += (
|
node_content += (
|
||||||
f"<tr><th>Role: </th><td>{device.device_role.name}</td></tr>"
|
f"<tr><th>Role: </th><td>{device.role.name}</td></tr>"
|
||||||
)
|
)
|
||||||
if device.serial != "":
|
if device.serial != "":
|
||||||
node_content += f"<tr><th>Serial: </th><td>{device.serial}</td></tr>"
|
node_content += f"<tr><th>Serial: </th><td>{device.serial}</td></tr>"
|
||||||
@@ -180,8 +183,21 @@ def create_node(
|
|||||||
|
|
||||||
node["id"] = device.pk
|
node["id"] = device.pk
|
||||||
|
|
||||||
if device.device_role.color != "":
|
if device.site is not None:
|
||||||
node["color.border"] = "#" + device.device_role.color
|
node["site"] = device.site.name
|
||||||
|
node["site_id"] = device.site_id
|
||||||
|
if device.location is not None:
|
||||||
|
node["location"] = device.location.name
|
||||||
|
node["location_id"] = device.location_id
|
||||||
|
if device.rack is not None:
|
||||||
|
node["rack"] = device.rack.name
|
||||||
|
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 != "":
|
||||||
|
node["color.border"] = "#" + device.role.color
|
||||||
|
|
||||||
model_class = getattr(netbox_topology_views.models, model_name)
|
model_class = getattr(netbox_topology_views.models, model_name)
|
||||||
|
|
||||||
@@ -216,10 +232,26 @@ 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.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),
|
||||||
|
}
|
||||||
|
|
||||||
|
label_items = []
|
||||||
|
for item in node_label_items:
|
||||||
|
if 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
|
||||||
|
|
||||||
@@ -228,6 +260,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,
|
||||||
@@ -290,6 +323,9 @@ def create_edge(
|
|||||||
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
|
||||||
|
|
||||||
|
|
||||||
@@ -317,6 +353,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,
|
||||||
@@ -325,7 +362,14 @@ def get_topology_data(
|
|||||||
show_neighbors: bool,
|
show_neighbors: bool,
|
||||||
show_power: bool,
|
show_power: bool,
|
||||||
show_wireless: bool,
|
show_wireless: bool,
|
||||||
|
group_sites: bool,
|
||||||
|
group_locations: 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 = []
|
||||||
@@ -338,6 +382,7 @@ def get_topology_data(
|
|||||||
nodes_devices = {}
|
nodes_devices = {}
|
||||||
edges = []
|
edges = []
|
||||||
nodes = []
|
nodes = []
|
||||||
|
options = {}
|
||||||
edge_ids = 0
|
edge_ids = 0
|
||||||
nodes_circuits: Dict[int, Circuit] = {}
|
nodes_circuits: Dict[int, Circuit] = {}
|
||||||
nodes_powerpanel: Dict[int, PowerPanel] = {}
|
nodes_powerpanel: Dict[int, PowerPanel] = {}
|
||||||
@@ -346,8 +391,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]
|
||||||
|
|
||||||
@@ -379,8 +422,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 (
|
||||||
@@ -401,14 +444,14 @@ def get_topology_data(
|
|||||||
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 = {
|
||||||
@@ -422,6 +465,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,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -448,7 +492,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(
|
||||||
@@ -491,6 +535,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,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -498,10 +543,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(
|
||||||
@@ -529,7 +574,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
|
||||||
|
|
||||||
@@ -539,11 +584,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:
|
||||||
@@ -609,6 +654,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,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -648,9 +694,23 @@ 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,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if group_locations:
|
||||||
|
options['group_locations'] = 'on'
|
||||||
|
if group_racks:
|
||||||
|
options['group_racks'] = 'on'
|
||||||
|
if group_sites:
|
||||||
|
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:
|
||||||
nodes_devices[qs_device.pk] = qs_device
|
nodes_devices[qs_device.pk] = qs_device
|
||||||
@@ -658,11 +718,12 @@ 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
|
||||||
results["group"] = group_id
|
results["group"] = group_id
|
||||||
|
results["options"] = options
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@@ -675,7 +736,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
|
||||||
@@ -688,10 +749,41 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
|
|
||||||
if request.GET:
|
if request.GET:
|
||||||
|
|
||||||
save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, 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
|
||||||
|
if "filter_id" in request.GET and request.GET["filter_id"] != '':
|
||||||
|
try:
|
||||||
|
saved_filter = SavedFilter.objects.get(pk=filter_id)
|
||||||
|
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 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_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_single_cable_logical_conns == False and 'show_single_cable_logical_conns' in saved_filter_params: show_single_cable_logical_conns = saved_filter_params['show_single_cable_logical_conns']
|
||||||
|
if show_cables == False and 'show_cables' in saved_filter_params: show_cables = saved_filter_params['show_cables']
|
||||||
|
if show_wireless == False and 'show_wireless' in saved_filter_params: show_wireless = saved_filter_params['show_wireless']
|
||||||
|
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_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 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
|
||||||
|
pass
|
||||||
|
except Exception as 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"]
|
||||||
|
|
||||||
@@ -699,6 +791,7 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
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,
|
||||||
@@ -708,37 +801,57 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
show_circuit=show_circuit,
|
show_circuit=show_circuit,
|
||||||
show_power=show_power,
|
show_power=show_power,
|
||||||
show_wireless=show_wireless,
|
show_wireless=show_wireless,
|
||||||
|
group_sites=group_sites,
|
||||||
|
group_locations=group_locations,
|
||||||
|
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,
|
||||||
)
|
)
|
||||||
|
|
||||||
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.show_unconnected: q['show_unconnected'] = "True"
|
||||||
|
if individualOptions.show_cables: q['show_cables'] = "True"
|
||||||
|
if individualOptions.show_logical_connections: q['show_logical_connections'] = "True"
|
||||||
|
if individualOptions.show_single_cable_logical_conns: q['show_single_cable_logical_conns'] = "True"
|
||||||
|
if individualOptions.show_neighbors: q['show_neighbors'] = "True"
|
||||||
|
if individualOptions.show_circuit: q['show_circuit'] = "True"
|
||||||
|
if individualOptions.show_power: q['show_power'] = "True"
|
||||||
|
if individualOptions.show_wireless: q['show_wireless'] = "True"
|
||||||
|
if individualOptions.group_sites: q['group_sites'] = "True"
|
||||||
|
if individualOptions.group_locations: q['group_locations'] = "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.save_coords: q['save_coords'] = "on"
|
|
||||||
if individualOptions.show_unconnected: q['show_unconnected'] = "on"
|
|
||||||
if individualOptions.show_cables: q['show_cables'] = "on"
|
|
||||||
if individualOptions.show_logical_connections: q['show_logical_connections'] = "on"
|
|
||||||
if individualOptions.show_single_cable_logical_conns: q['show_single_cable_logical_conns'] = "on"
|
|
||||||
if individualOptions.show_neighbors: q['show_neighbors'] = "on"
|
|
||||||
if individualOptions.show_circuit: q['show_circuit'] = "on"
|
|
||||||
if individualOptions.show_power: q['show_power'] = "on"
|
|
||||||
if individualOptions.show_wireless: q['show_wireless'] = "on"
|
|
||||||
if individualOptions.draw_default_layout:
|
if individualOptions.draw_default_layout:
|
||||||
q['draw_init'] = "true"
|
q['draw_init'] = "True"
|
||||||
else:
|
else:
|
||||||
q['draw_init'] = "false"
|
q['draw_init'] = "False"
|
||||||
|
|
||||||
query_string = q.urlencode()
|
query_string = q.urlencode()
|
||||||
return HttpResponseRedirect(f"{request.path}?{query_string}")
|
return HttpResponseRedirect(f"{request.path}?{query_string}")
|
||||||
|
|
||||||
|
|
||||||
if is_htmx(request):
|
if htmx_partial(request):
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"netbox_topology_views/htmx_topology.html",
|
"netbox_topology_views/htmx_topology.html",
|
||||||
@@ -1083,7 +1196,14 @@ class TopologyIndividualOptionsView(PermissionRequiredMixin, View):
|
|||||||
'show_circuit': queryset.show_circuit,
|
'show_circuit': queryset.show_circuit,
|
||||||
'show_power': queryset.show_power,
|
'show_power': queryset.show_power,
|
||||||
'show_wireless': queryset.show_wireless,
|
'show_wireless': queryset.show_wireless,
|
||||||
|
'group_sites': queryset.group_sites,
|
||||||
|
'group_locations': queryset.group_locations,
|
||||||
|
'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="3.9.0",
|
version="4.2.1",
|
||||||
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