Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8aea42c50b | ||
|
|
f56b8a4aec | ||
|
|
3aa2bab141 | ||
|
|
6c4106e428 | ||
|
|
3d97f649d9 | ||
|
|
d10ced8157 | ||
|
|
9d4ef31bdd | ||
|
|
e20f250425 |
@@ -57,7 +57,7 @@ systemctl restart netbox
|
|||||||
|
|
||||||
| netbox version | netbox-topology-views version |
|
| netbox version | netbox-topology-views version |
|
||||||
| -------------- | ----------------------------- |
|
| -------------- | ----------------------------- |
|
||||||
| = 4.5.X | = v4.5.0 |
|
| = 4.5.X | = v4.5.1 |
|
||||||
| = 4.4.X | = v4.4.0 |
|
| = 4.4.X | = v4.4.0 |
|
||||||
| = 4.3.X | = v4.3.0 |
|
| = 4.3.X | = v4.3.0 |
|
||||||
| = 4.2.1 | = v4.2.1 |
|
| = 4.2.1 | = v4.2.1 |
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package_name: netbox-topology-views
|
|||||||
compatibility:
|
compatibility:
|
||||||
- release: 4.5.0
|
- release: 4.5.0
|
||||||
netbox_min: 4.5.0
|
netbox_min: 4.5.0
|
||||||
netbox_max: 4.5.1
|
netbox_max: 4.5.5
|
||||||
- release: 4.4.0
|
- release: 4.4.0
|
||||||
netbox_min: 4.4.0
|
netbox_min: 4.4.0
|
||||||
netbox_max: 4.4.3
|
netbox_max: 4.4.3
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ 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 = "A plugin to render topology maps"
|
||||||
version = "4.5.0"
|
version = "4.5.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,7 @@ class PowerFeedCoordinateSerializer(NetBoxModelSerializer):
|
|||||||
class IndividualOptionsSerializer(NetBoxModelSerializer):
|
class IndividualOptionsSerializer(NetBoxModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IndividualOptions
|
model = IndividualOptions
|
||||||
fields = ("ignore_cable_type", "save_coords", "show_unconnected", "show_cables", "show_logical_connections", "show_single_cable_logical_conns", "show_neighbors", "show_circuit", "show_power", "show_wireless", "group_sites", "group_locations", "group_racks", "group_virtualchassis", "draw_default_layout", "straight_cables", "grid_size", "node_label_items")
|
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",
|
||||||
|
"draw_termination_labels", "draw_cable_labels", "grid_size", "node_label_items")
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class ExportTopoToXML(BaseViewSet, ViewSet):
|
|||||||
|
|
||||||
if request.GET:
|
if request.GET:
|
||||||
|
|
||||||
filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, grid_size, node_label_items = get_query_settings(request)
|
filter_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, draw_termination_labels, draw_cable_labels, grid_size, node_label_items = get_query_settings(request)
|
||||||
|
|
||||||
# Read options from saved filters as NetBox does not handle custom plugin filters
|
# Read options from saved filters as NetBox does not handle custom plugin filters
|
||||||
if "filter_id" in request.GET and request.GET["filter_id"] != '':
|
if "filter_id" in request.GET and request.GET["filter_id"] != '':
|
||||||
@@ -136,7 +136,9 @@ class ExportTopoToXML(BaseViewSet, ViewSet):
|
|||||||
if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks']
|
if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks']
|
||||||
if group_virtualchassis == False and 'group_virtualchassis' in saved_filter_params: group_virtualchassis = saved_filter_params['group_virtualchassis']
|
if group_virtualchassis == False and 'group_virtualchassis' in saved_filter_params: group_virtualchassis = saved_filter_params['group_virtualchassis']
|
||||||
if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors']
|
if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors']
|
||||||
if straight_cables == False and 'straight_cables' in saved_filter_params: show_neighbors = saved_filter_params['straight_cables']
|
if straight_cables == False and 'straight_cables' in saved_filter_params: straight_cables = saved_filter_params['straight_cables']
|
||||||
|
if draw_termination_labels == False and 'draw_termination_labels' in saved_filter_params: draw_termination_labels = saved_filter_params['draw_termination_labels']
|
||||||
|
if draw_cable_labels == False and 'draw_cable_labels' in saved_filter_params: draw_cable_labels = saved_filter_params['draw_cable_labels']
|
||||||
if grid_size == 0 and 'grid_size' in saved_filter_params: grid_size = saved_filter_params['grid_size']
|
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']
|
if node_label_items == () and 'node_label_items' in saved_filter_params: node_label_items = saved_filter_params['node_label_items']
|
||||||
except SavedFilter.DoesNotExist: # filter_id not found
|
except SavedFilter.DoesNotExist: # filter_id not found
|
||||||
@@ -170,6 +172,8 @@ class ExportTopoToXML(BaseViewSet, ViewSet):
|
|||||||
group_virtualchassis=group_virtualchassis,
|
group_virtualchassis=group_virtualchassis,
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
straight_cables=straight_cables,
|
straight_cables=straight_cables,
|
||||||
|
draw_termination_labels=draw_termination_labels,
|
||||||
|
draw_cable_labels=draw_cable_labels,
|
||||||
grid_size=grid_size,
|
grid_size=grid_size,
|
||||||
node_label_items=node_label_items,
|
node_label_items=node_label_items,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class NodeLabelItems(ChoiceSet):
|
|||||||
LOCATION = 'location'
|
LOCATION = 'location'
|
||||||
RACK = 'rack'
|
RACK = 'rack'
|
||||||
VIRTUAL_CHASSIS = 'virtualchassis'
|
VIRTUAL_CHASSIS = 'virtualchassis'
|
||||||
|
ASSET_TAG = 'assettag'
|
||||||
|
|
||||||
CHOICES = [
|
CHOICES = [
|
||||||
(DEVICE_NAME, 'Device Name'),
|
(DEVICE_NAME, 'Device Name'),
|
||||||
@@ -31,4 +32,5 @@ class NodeLabelItems(ChoiceSet):
|
|||||||
(LOCATION, 'Location'),
|
(LOCATION, 'Location'),
|
||||||
(RACK, 'Rack'),
|
(RACK, 'Rack'),
|
||||||
(VIRTUAL_CHASSIS, 'Virtual Chassis'),
|
(VIRTUAL_CHASSIS, 'Virtual Chassis'),
|
||||||
|
(ASSET_TAG, 'Asset Tag'),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -35,12 +35,13 @@ class DeviceFilterForm(
|
|||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag'),
|
FieldSet('q', 'filter_id', 'tag'),
|
||||||
FieldSet(
|
FieldSet(
|
||||||
'group', 'ignore_cable_type', 'save_coords', 'show_unconnected', 'show_cables', 'show_logical_connections',
|
'group', 'ignore_cable_type', 'save_coords', 'show_unconnected', 'show_cables', 'show_wireless',
|
||||||
'show_single_cable_logical_conns', 'show_neighbors',
|
'show_logical_connections', 'show_single_cable_logical_conns', 'show_neighbors',
|
||||||
'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis', 'straight_cables', 'grid_size', 'node_label_items', name=_("Options")
|
'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis', 'straight_cables',
|
||||||
|
'draw_termination_labels', 'draw_cable_labels', 'grid_size', 'node_label_items', name=_("Options")
|
||||||
),
|
),
|
||||||
FieldSet(
|
FieldSet(
|
||||||
'show_circuit', 'show_power', 'show_wireless', name=_("Additional filter-independent types (non-devices)")
|
'show_circuit', 'show_power', name=_("Additional filter-independent types (non-devices)")
|
||||||
),
|
),
|
||||||
FieldSet('id', name=_("Device")),
|
FieldSet('id', name=_("Device")),
|
||||||
FieldSet('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', name=_("Location")),
|
FieldSet('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', name=_("Location")),
|
||||||
@@ -264,7 +265,12 @@ class DeviceFilterForm(
|
|||||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
show_wireless = forms.NullBooleanField(
|
||||||
|
label =_('Show Wireless Links'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
show_logical_connections = forms.NullBooleanField(
|
show_logical_connections = forms.NullBooleanField(
|
||||||
label =_('Show Logical Connections'), required=False, initial=False,
|
label =_('Show Logical Connections'), required=False, initial=False,
|
||||||
widget=forms.Select(
|
widget=forms.Select(
|
||||||
@@ -313,6 +319,18 @@ class DeviceFilterForm(
|
|||||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
draw_termination_labels = forms.BooleanField(
|
||||||
|
label=_('Termination Labels'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
draw_cable_labels = forms.BooleanField(
|
||||||
|
label=_('Cable Labels'), required=False, initial=False,
|
||||||
|
widget=forms.Select(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
grid_size = forms.IntegerField(
|
grid_size = forms.IntegerField(
|
||||||
label=_('Grid Size'),
|
label=_('Grid Size'),
|
||||||
required=False,
|
required=False,
|
||||||
@@ -342,13 +360,6 @@ class DeviceFilterForm(
|
|||||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
show_wireless = forms.NullBooleanField(
|
|
||||||
label =_('Show Wireless Links'), required=False, initial=False,
|
|
||||||
help_text=_('All Wireless Links will be displayed. Wireless Links cannot be filtered.'),
|
|
||||||
widget=forms.Select(
|
|
||||||
choices=BOOLEAN_WITH_BLANK_CHOICES
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
class CoordinateGroupsForm(NetBoxModelForm):
|
class CoordinateGroupsForm(NetBoxModelForm):
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
@@ -530,6 +541,7 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'save_coords',
|
'save_coords',
|
||||||
'show_unconnected',
|
'show_unconnected',
|
||||||
'show_cables',
|
'show_cables',
|
||||||
|
'show_wireless',
|
||||||
'show_logical_connections',
|
'show_logical_connections',
|
||||||
'show_single_cable_logical_conns',
|
'show_single_cable_logical_conns',
|
||||||
'show_neighbors',
|
'show_neighbors',
|
||||||
@@ -539,6 +551,8 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'group_virtualchassis',
|
'group_virtualchassis',
|
||||||
'draw_default_layout',
|
'draw_default_layout',
|
||||||
'straight_cables',
|
'straight_cables',
|
||||||
|
'draw_termination_labels',
|
||||||
|
'draw_cable_labels',
|
||||||
'grid_size',
|
'grid_size',
|
||||||
'node_label_items',
|
'node_label_items',
|
||||||
),
|
),
|
||||||
@@ -546,7 +560,6 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
(
|
(
|
||||||
'show_circuit',
|
'show_circuit',
|
||||||
'show_power',
|
'show_power',
|
||||||
'show_wireless',
|
|
||||||
name=_("Additional filter-independent types (non-devices)")
|
name=_("Additional filter-independent types (non-devices)")
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -600,6 +613,13 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'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_wireless = forms.BooleanField(
|
||||||
|
label =_('Show Wireless Links'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
help_text=_('Displays wireless connections. These connections are '
|
||||||
|
'displayed as blue dotted lines.')
|
||||||
|
)
|
||||||
show_logical_connections = forms.BooleanField(
|
show_logical_connections = forms.BooleanField(
|
||||||
label =_('Show Logical Connections'),
|
label =_('Show Logical Connections'),
|
||||||
required=False,
|
required=False,
|
||||||
@@ -667,6 +687,19 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
help_text=_('Enable this option if you want to draw cables as straight lines '
|
help_text=_('Enable this option if you want to draw cables as straight lines '
|
||||||
'instead of curves.')
|
'instead of curves.')
|
||||||
)
|
)
|
||||||
|
draw_termination_labels = forms.BooleanField(
|
||||||
|
label=('Termination Labels'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
help_text=_('Enable this option if you want to draw a label on each '
|
||||||
|
'cable end.')
|
||||||
|
)
|
||||||
|
draw_cable_labels = forms.BooleanField(
|
||||||
|
label=('Cable Labels'),
|
||||||
|
required=False,
|
||||||
|
initial=False,
|
||||||
|
help_text=_('Enable this option if you want to draw a cable labels.')
|
||||||
|
)
|
||||||
grid_size = forms.IntegerField(
|
grid_size = forms.IntegerField(
|
||||||
label=_('Grid Size'),
|
label=_('Grid Size'),
|
||||||
required=True,
|
required=True,
|
||||||
@@ -700,22 +733,14 @@ class IndividualOptionsForm(NetBoxModelForm):
|
|||||||
'color of the cable. This option depends on \'Show Cables\'. '
|
'color of the cable. This option depends on \'Show Cables\'. '
|
||||||
'Be aware that Power Feeds cannot be filtered.')
|
'Be aware that Power Feeds cannot be filtered.')
|
||||||
)
|
)
|
||||||
show_wireless = forms.BooleanField(
|
|
||||||
label =_('Show Wireless Links'),
|
|
||||||
required=False,
|
|
||||||
initial=False,
|
|
||||||
help_text=_('Displays wireless connections. These connections are '
|
|
||||||
'displayed as blue dotted lines. '
|
|
||||||
'Be aware that Wireless Links cannot be filtered.')
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IndividualOptions
|
model = IndividualOptions
|
||||||
fields = [
|
fields = [
|
||||||
'user_id', 'ignore_cable_type', 'preselected_device_roles', 'preselected_tags',
|
'user_id', 'ignore_cable_type', 'preselected_device_roles', 'preselected_tags',
|
||||||
'save_coords', 'show_unconnected', 'show_cables', 'show_logical_connections',
|
'save_coords', 'show_unconnected', 'show_cables', 'show_wireless',
|
||||||
'show_single_cable_logical_conns', 'show_neighbors',
|
'show_logical_connections', 'show_single_cable_logical_conns', 'show_neighbors',
|
||||||
'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis',
|
'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis',
|
||||||
'draw_default_layout', 'straight_cables', 'grid_size', 'node_label_items',
|
'draw_default_layout', 'straight_cables', 'draw_termination_labels', 'draw_cable_labels',
|
||||||
'show_circuit', 'show_power', 'show_wireless'
|
'grid_size', 'node_label_items', 'show_circuit', 'show_power'
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.9 on 2026-02-19 18:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('netbox_topology_views', '0011_individualoptions_node_label_items'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='draw_termination_labels',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.12 on 2026-03-26 07:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('netbox_topology_views', '0012_individualoptions_draw_termination_labels'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='individualoptions',
|
||||||
|
name='draw_cable_labels',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -405,6 +405,12 @@ class IndividualOptions(NetBoxModel):
|
|||||||
straight_cables = models.BooleanField(
|
straight_cables = models.BooleanField(
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
draw_termination_labels = models.BooleanField(
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
draw_cable_labels = models.BooleanField(
|
||||||
|
default=False
|
||||||
|
)
|
||||||
grid_size = models.PositiveSmallIntegerField(
|
grid_size = models.PositiveSmallIntegerField(
|
||||||
default=0
|
default=0
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,44 @@
|
|||||||
import { DataSet } from 'vis-data/esnext'
|
import { DataSet } from 'vis-data/esnext'
|
||||||
import { Network } from 'vis-network/esnext'
|
import { Network } from 'vis-network/esnext'
|
||||||
|
|
||||||
|
function generatePortSVG(text) {
|
||||||
|
// pre-calculate text width
|
||||||
|
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||||
|
const textEl = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
||||||
|
|
||||||
|
const fontFamily = 'helvetica';
|
||||||
|
const fontSize = 14;
|
||||||
|
textEl.textContent = text;
|
||||||
|
textEl.setAttribute('font-family', fontFamily);
|
||||||
|
textEl.setAttribute('font-size', fontSize + 'px');
|
||||||
|
svg.appendChild(textEl);
|
||||||
|
document.body.appendChild(svg);
|
||||||
|
|
||||||
|
const textWidth = textEl.getComputedTextLength();
|
||||||
|
textEl.remove();
|
||||||
|
svg.remove();
|
||||||
|
|
||||||
|
const rectPadding = 2;
|
||||||
|
const rectBorderWidth = 2;
|
||||||
|
const rectX = rectBorderWidth / 2;
|
||||||
|
const rectY = rectBorderWidth / 2;
|
||||||
|
const rectWidth = textWidth + rectBorderWidth + rectPadding * 2;
|
||||||
|
const rectHeight = fontSize + rectBorderWidth + rectPadding * 2;
|
||||||
|
const svgHeight = rectHeight + rectY + rectBorderWidth / 2;
|
||||||
|
const svgWidth = rectWidth + rectX + rectBorderWidth / 2;
|
||||||
|
const textX = svgWidth / 2 ;
|
||||||
|
const textY = svgHeight / 2;
|
||||||
|
|
||||||
|
// generate SVG
|
||||||
|
return 'data:image/svg+xml;charset=utf-8,' +
|
||||||
|
encodeURIComponent(
|
||||||
|
'<svg xmlns="http://www.w3.org/2000/svg" width="' + (svgWidth) + '" height="' + (svgHeight) + '">' +
|
||||||
|
'<rect x="' + rectX + '" y="' + rectY + '" rx="4" ry="4" width="' + (rectWidth) + '" height="' + (rectHeight) + '" fill="#ffdf3f" stroke="#ffc93f" stroke-width="' + (rectBorderWidth) + '" style="opacity:0.5"/>' +
|
||||||
|
'<text x="' + textX + '" y="' + textY + '" font-family="' + fontFamily + '" font-size="' + (fontSize) + '" fill="black" text-anchor="middle" dominant-baseline="middle">' + text + '</text>' +
|
||||||
|
'</svg>'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
interaction: {
|
interaction: {
|
||||||
hover: true,
|
hover: true,
|
||||||
@@ -62,7 +100,21 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
const edges = new DataSet(
|
const edges = new DataSet(
|
||||||
topologyData.edges.map((node) => ({
|
topologyData.edges.map((node) => ({
|
||||||
...node,
|
...node,
|
||||||
title: htmlTitle(node.title)
|
title: htmlTitle(node.title),
|
||||||
|
...(node.drawTerminationLabel && {
|
||||||
|
arrows: {
|
||||||
|
from: {
|
||||||
|
enabled: true,
|
||||||
|
type: "image",
|
||||||
|
src: generatePortSVG(node.cable_a_name)
|
||||||
|
},
|
||||||
|
to: {
|
||||||
|
enabled: true,
|
||||||
|
type: "image",
|
||||||
|
src: generatePortSVG(node.cable_b_name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+11
-9
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "netbox_topology_views",
|
"name": "netbox_topology_views",
|
||||||
"version": "4.3.0",
|
"version": "4.5.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "netbox_topology_views",
|
"name": "netbox_topology_views",
|
||||||
"version": "4.3.0",
|
"version": "4.5.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vis-data": "^7.1.9",
|
"vis-data": "^7.1.9",
|
||||||
"vis-network": "^9.1.9",
|
"vis-network": "^9.1.9",
|
||||||
@@ -904,10 +904,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/immutable": {
|
"node_modules/immutable": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.5.tgz",
|
||||||
"integrity": "sha512-qHKXW1q6liAk1Oys6umoaZbDRqjcjgSrbnrifHsfsttza7zcvRAsL7mMV6xWcyhwQy7Xj5v4hhbr6b+iDYwlmQ==",
|
"integrity": "sha512-t7xcm2siw+hlUM68I+UEOK+z84RzmN59as9DZ7P1l0994DKUWV7UXBMQZVxaoMSRQ+PBZbHCOoBt7a2wxOMt+A==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/is-core-module": {
|
"node_modules/is-core-module": {
|
||||||
"version": "2.16.1",
|
"version": "2.16.1",
|
||||||
@@ -990,10 +991,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
|
||||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.6"
|
"node": ">=8.6"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "netbox_topology_views",
|
"name": "netbox_topology_views",
|
||||||
"version": "4.5.0",
|
"version": "4.5.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"bundle": "node bundle.js",
|
"bundle": "node bundle.js",
|
||||||
"bundle:styles": "node bundle.js --styles",
|
"bundle:styles": "node bundle.js --styles",
|
||||||
|
|||||||
@@ -196,6 +196,16 @@ def get_query_settings(request):
|
|||||||
if request.GET["straight_cables"] == "True":
|
if request.GET["straight_cables"] == "True":
|
||||||
straight_cables = True
|
straight_cables = True
|
||||||
|
|
||||||
|
draw_termination_labels = False
|
||||||
|
if "draw_termination_labels" in request.GET:
|
||||||
|
if request.GET["draw_termination_labels"] == "True":
|
||||||
|
draw_termination_labels = True
|
||||||
|
|
||||||
|
draw_cable_labels = False
|
||||||
|
if "draw_cable_labels" in request.GET:
|
||||||
|
if request.GET["draw_cable_labels"] == "True":
|
||||||
|
draw_cable_labels = True
|
||||||
|
|
||||||
grid_size = 0
|
grid_size = 0
|
||||||
if "grid_size" in request.GET:
|
if "grid_size" in request.GET:
|
||||||
grid_size = request.GET.getlist('grid_size')
|
grid_size = request.GET.getlist('grid_size')
|
||||||
@@ -204,7 +214,7 @@ def get_query_settings(request):
|
|||||||
if "node_label_items" in request.GET:
|
if "node_label_items" in request.GET:
|
||||||
node_label_items = request.GET.getlist('node_label_items')
|
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
|
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, draw_termination_labels, draw_cable_labels, grid_size, node_label_items
|
||||||
|
|
||||||
class LinePattern():
|
class LinePattern():
|
||||||
wireless = [2, 10, 2, 10]
|
wireless = [2, 10, 2, 10]
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ def create_node(
|
|||||||
NodeLabelItems.LOCATION: getattr(device, 'location', None),
|
NodeLabelItems.LOCATION: getattr(device, 'location', None),
|
||||||
NodeLabelItems.RACK: getattr(device, 'rack', None),
|
NodeLabelItems.RACK: getattr(device, 'rack', None),
|
||||||
NodeLabelItems.VIRTUAL_CHASSIS: getattr(device, 'virtual_chassis', None),
|
NodeLabelItems.VIRTUAL_CHASSIS: getattr(device, 'virtual_chassis', None),
|
||||||
|
NodeLabelItems.ASSET_TAG: getattr(device, 'asset_tag', None),
|
||||||
}
|
}
|
||||||
|
|
||||||
label_items = []
|
label_items = []
|
||||||
@@ -269,6 +270,8 @@ def create_edge(
|
|||||||
termination_a: Dict,
|
termination_a: Dict,
|
||||||
termination_b: Dict,
|
termination_b: Dict,
|
||||||
straight_cables: bool,
|
straight_cables: bool,
|
||||||
|
draw_termination_labels: bool,
|
||||||
|
draw_cable_labels: 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,
|
||||||
@@ -324,6 +327,8 @@ def create_edge(
|
|||||||
|
|
||||||
if cable is not None and hasattr(cable, "label") and cable.label:
|
if cable is not None and hasattr(cable, "label") and cable.label:
|
||||||
cable_label = "<br>Label: " + cable.label
|
cable_label = "<br>Label: " + cable.label
|
||||||
|
if draw_cable_labels is True:
|
||||||
|
edge["label"] = cable.label
|
||||||
else:
|
else:
|
||||||
cable_label = ""
|
cable_label = ""
|
||||||
|
|
||||||
@@ -339,6 +344,12 @@ def create_edge(
|
|||||||
# if straight_cables == True: edge["smooth"] = False
|
# if straight_cables == True: edge["smooth"] = False
|
||||||
edge["smooth"] = not straight_cables
|
edge["smooth"] = not straight_cables
|
||||||
|
|
||||||
|
if draw_termination_labels is True:
|
||||||
|
edge["drawTerminationLabel"] = True
|
||||||
|
edge["cable_a_name"] = cable_a_name
|
||||||
|
edge["cable_b_name"] = cable_b_name
|
||||||
|
|
||||||
|
|
||||||
return edge
|
return edge
|
||||||
|
|
||||||
|
|
||||||
@@ -381,6 +392,8 @@ def get_topology_data(
|
|||||||
group_virtualchassis: bool,
|
group_virtualchassis: bool,
|
||||||
group_id,
|
group_id,
|
||||||
straight_cables: bool,
|
straight_cables: bool,
|
||||||
|
draw_termination_labels: bool,
|
||||||
|
draw_cable_labels: bool,
|
||||||
grid_size: list,
|
grid_size: list,
|
||||||
node_label_items: list,
|
node_label_items: list,
|
||||||
):
|
):
|
||||||
@@ -479,6 +492,8 @@ def get_topology_data(
|
|||||||
termination_a=termination_a,
|
termination_a=termination_a,
|
||||||
termination_b=termination_b,
|
termination_b=termination_b,
|
||||||
straight_cables=straight_cables,
|
straight_cables=straight_cables,
|
||||||
|
draw_termination_labels=draw_termination_labels,
|
||||||
|
draw_cable_labels=draw_cable_labels,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -549,6 +564,8 @@ def get_topology_data(
|
|||||||
termination_b=termination_b,
|
termination_b=termination_b,
|
||||||
power=True,
|
power=True,
|
||||||
straight_cables=straight_cables,
|
straight_cables=straight_cables,
|
||||||
|
draw_termination_labels=draw_termination_labels,
|
||||||
|
draw_cable_labels=draw_cable_labels,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -587,7 +604,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, straight_cables=straight_cables))
|
edges.append(create_edge(edge_id=edge_ids, termination_a=termination_a, termination_b=termination_b, interface=interface, straight_cables=straight_cables, draw_termination_labels=draw_termination_labels, draw_cable_labels=draw_cable_labels))
|
||||||
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
|
||||||
|
|
||||||
@@ -668,6 +685,8 @@ def get_topology_data(
|
|||||||
termination_a=termination_a,
|
termination_a=termination_a,
|
||||||
termination_b=termination_b,
|
termination_b=termination_b,
|
||||||
straight_cables=straight_cables,
|
straight_cables=straight_cables,
|
||||||
|
draw_termination_labels=draw_termination_labels,
|
||||||
|
draw_cable_labels=draw_cable_labels,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -708,6 +727,8 @@ def get_topology_data(
|
|||||||
termination_b=termination_b,
|
termination_b=termination_b,
|
||||||
wireless=wireless,
|
wireless=wireless,
|
||||||
straight_cables=straight_cables,
|
straight_cables=straight_cables,
|
||||||
|
draw_termination_labels=draw_termination_labels,
|
||||||
|
draw_cable_labels=draw_cable_labels,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -762,7 +783,7 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
|
|
||||||
if request.GET:
|
if request.GET:
|
||||||
|
|
||||||
filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, grid_size, node_label_items = get_query_settings(request)
|
filter_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, draw_termination_labels, draw_cable_labels, grid_size, node_label_items = get_query_settings(request)
|
||||||
|
|
||||||
filter_required = True
|
filter_required = True
|
||||||
empty_result = False
|
empty_result = False
|
||||||
@@ -788,6 +809,8 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
if group_virtualchassis == False and 'group_virtualchassis' in saved_filter_params: group_virtualchassis = saved_filter_params['group_virtualchassis']
|
if group_virtualchassis == False and 'group_virtualchassis' in saved_filter_params: group_virtualchassis = saved_filter_params['group_virtualchassis']
|
||||||
if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors']
|
if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors']
|
||||||
if straight_cables == False and 'straight_cables' in saved_filter_params: straight_cables = saved_filter_params['straight_cables']
|
if straight_cables == False and 'straight_cables' in saved_filter_params: straight_cables = saved_filter_params['straight_cables']
|
||||||
|
if draw_termination_labels == False and 'draw_termination_labels' in saved_filter_params: draw_termination_labels = saved_filter_params['draw_termination_labels']
|
||||||
|
if draw_cable_labels == False and 'draw_cable_labels' in saved_filter_params: draw_cable_labels = saved_filter_params['draw_cable_labels']
|
||||||
if grid_size == 0 and 'grid_size' in saved_filter_params: grid_size = saved_filter_params['grid_size']
|
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']
|
if node_label_items == () and 'node_label_items' in saved_filter_params: node_label_items = saved_filter_params['node_label_items']
|
||||||
except SavedFilter.DoesNotExist: # filter_id not found
|
except SavedFilter.DoesNotExist: # filter_id not found
|
||||||
@@ -825,6 +848,8 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
group_virtualchassis=group_virtualchassis,
|
group_virtualchassis=group_virtualchassis,
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
straight_cables=straight_cables,
|
straight_cables=straight_cables,
|
||||||
|
draw_termination_labels=draw_termination_labels,
|
||||||
|
draw_cable_labels=draw_cable_labels,
|
||||||
grid_size=grid_size,
|
grid_size=grid_size,
|
||||||
node_label_items=node_label_items,
|
node_label_items=node_label_items,
|
||||||
)
|
)
|
||||||
@@ -835,7 +860,7 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
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('slug', flat=True)
|
||||||
ignore_cable_type = IndividualOptions.objects.get(id=individualOptions.id).ignore_cable_type.translate({ord(i): None for i in '[]\''}).split(', ')
|
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 = []
|
if ignore_cable_type == ['']: ignore_cable_type = []
|
||||||
|
|
||||||
@@ -858,6 +883,8 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
|||||||
if individualOptions.group_racks: q['group_racks'] = "True"
|
if individualOptions.group_racks: q['group_racks'] = "True"
|
||||||
if individualOptions.group_virtualchassis: q['group_virtualchassis'] = "True"
|
if individualOptions.group_virtualchassis: q['group_virtualchassis'] = "True"
|
||||||
if individualOptions.straight_cables: q['straight_cables'] = "True"
|
if individualOptions.straight_cables: q['straight_cables'] = "True"
|
||||||
|
if individualOptions.draw_termination_labels: q['draw_termination_labels'] = "True"
|
||||||
|
if individualOptions.draw_cable_labels: q['draw_cable_labels'] = "True"
|
||||||
if individualOptions.grid_size: q['grid_size'] = individualOptions.grid_size
|
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(', ')
|
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 = []
|
if node_label_items == ['']: node_label_items = []
|
||||||
@@ -1211,6 +1238,8 @@ class TopologyIndividualOptionsView(PermissionRequiredMixin, View):
|
|||||||
'group_virtualchassis': queryset.group_virtualchassis,
|
'group_virtualchassis': queryset.group_virtualchassis,
|
||||||
'draw_default_layout': queryset.draw_default_layout,
|
'draw_default_layout': queryset.draw_default_layout,
|
||||||
'straight_cables': queryset.straight_cables,
|
'straight_cables': queryset.straight_cables,
|
||||||
|
'draw_termination_labels': queryset.draw_termination_labels,
|
||||||
|
'draw_cable_labels': queryset.draw_cable_labels,
|
||||||
'grid_size': queryset.grid_size,
|
'grid_size': queryset.grid_size,
|
||||||
'node_label_items': tuple(queryset.node_label_items.translate({ord(i): None for i in '[]\''}).split(', ')),
|
'node_label_items': tuple(queryset.node_label_items.translate({ord(i): None for i in '[]\''}).split(', ')),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ long_description = readme.read_text()
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="netbox-topology-views",
|
name="netbox-topology-views",
|
||||||
version="4.5.0",
|
version="4.5.1",
|
||||||
description="An NetBox plugin to create Topology maps",
|
description="A 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",
|
||||||
url="https://github.com/mattieserver/netbox-topology-views",
|
url="https://github.com/mattieserver/netbox-topology-views",
|
||||||
|
|||||||
Reference in New Issue
Block a user