Compare commits

..
1 Commits
Author SHA1 Message Date
MrBlakeandClaude Opus 5.5 adfcc802c2 docs: state fork, original authors and licenses
Follow the attribution requirements of the Apache License 2.0 and of
CC BY-SA 4.0 (device icons) for this fork of
mattieserver/netbox-topology-views:

- add a NOTICE file crediting Mattijs Vanhaverbeke and contributors, the icon
  license and the bundled third-party libraries (vis-network, vis-data,
  vis-util, Hammer.js)
- mark every file changed since upstream v4.5.1 as modified (section 4b)
- add a visible fork notice and a section on origin, credits and licenses to
  the README, including the CC BY-SA 4.0 license of the icons added here
- point the package URL to this fork (with an Upstream link), add MrBlake as
  maintainer and replace the placeholder author email
- ship LICENSE and NOTICE in the package

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 15:52:13 +01:00
46 changed files with 329 additions and 1473 deletions

No files matched your search

+3 -2
View File
@@ -1,5 +1,6 @@
include LICENSE
include NOTICE
recursive-include netbox_topology_views/static *
recursive-include netbox_topology_views/templates *
recursive-include netbox_topology_views/api *
prune netbox_topology_views/api/__pycache__
recursive-include netbox_topology_views/locale *.po *.mo
prune netbox_topology_views/api/__pycache__
+31
View File
@@ -0,0 +1,31 @@
MRB NetBox Topology Views
Original work: NetBox Topology Views by Mattijs Vanhaverbeke and contributors
Modifications Copyright 2026 MrBlake
This product is a modified version of NetBox Topology Views
(https://github.com/mattieserver/netbox-topology-views), based on its release v4.5.1.
The original work is licensed under the Apache License, Version 2.0. The
modifications are distributed under the same license; see the LICENSE file.
Files that were changed in this fork carry a notice stating that they were
modified. The complete history, including all original commits, is available at
https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
Device icons
------------
The SVG icons in netbox_topology_views/static/netbox_topology_views/img/ are
licensed under the Creative Commons Attribution-ShareAlike 4.0 International
license (CC BY-SA 4.0); see the LICENSE file in that directory. They were created
by the contributors of NetBox Topology Views. The icons network-switch.svg,
leaf-switch.svg, spine-switch.svg and aggregation-switch.svg were added in this
fork and are also licensed under CC BY-SA 4.0.
Third-party software
--------------------
netbox_topology_views/static/netbox_topology_views/js/app.js bundles:
- vis-network 9.1.10, vis-data 7.1.9, vis-util 5.0.7 (Apache-2.0 OR MIT)
- Hammer.js (MIT)
Their copyright and license notices are retained in the bundle.
This fork is maintained independently and is not affiliated with or endorsed
by Mattijs Vanhaverbeke, the original contributors or NetBox Labs.
+28 -12
View File
@@ -7,6 +7,12 @@ The plugin builds topologies from the devices, ports and cables maintained in
NetBox. In addition to the classic topology, this fork provides a complete view
of one or more racks including front, rear and cabling.
> **Fork notice:** This is a modified version of
> [NetBox Topology Views](https://github.com/mattieserver/netbox-topology-views) by
> **Mattijs Vanhaverbeke** and contributors, licensed under the [Apache License 2.0](LICENSE).
> It is maintained independently and is not affiliated with or endorsed by the original
> author. See [Origin, credits and licenses](#origin-credits-and-licenses).
| | |
|---|---|
| **Plugin name** | `netbox_topology_views` |
@@ -222,19 +228,29 @@ Rack view: `dcim.view_rack`, `dcim.view_device`, `dcim.view_cable`.
Saving classic topology coordinates additionally requires the corresponding
permissions on `netbox_topology_views.coordinate`.
## Origin and credits
## Origin, credits and licenses
This project is a fork of the open-source plugin
[NetBox Topology Views](https://github.com/mattieserver/netbox-topology-views).
The original plugin was created by **Mattijs Vanhaverbeke**. Most of the classic
topology view, data models, filters and export functions are based on his work
and the contributions to the original project.
**Original project:** [NetBox Topology Views](https://github.com/mattieserver/netbox-topology-views),
created by **Mattijs Vanhaverbeke** and developed with its contributors. Most of the classic
topology view, data models, filters and export functions are based on their work. This fork
is based on release v4.5.1, and the complete original commit history is retained in this
repository. The changes are listed in [Changes compared to the original](#changes-compared-to-the-original).
This fork is developed independently and is not officially affiliated with the
original author or the NetBox project.
**This fork:** maintained by MrBlake at
[git.mrblake.cc/MrBlake/mrb-netbox-topology-views](https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views).
It is not affiliated with or endorsed by the original author, the original contributors or
NetBox Labs. Please report problems with this fork
[here](https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views/issues), not to the original project.
## License
**Licenses:**
Like the original, this project is licensed under the
[Apache License 2.0](LICENSE). Existing copyright, license and attribution
notices of the original project are retained.
| Part | License |
|---|---|
| Source code (original and modifications) | [Apache License 2.0](LICENSE) |
| Device icons in `netbox_topology_views/static/netbox_topology_views/img/` | [CC BY-SA 4.0](netbox_topology_views/static/netbox_topology_views/img/LICENSE), by the contributors of NetBox Topology Views; the icons `network-switch`, `leaf-switch`, `spine-switch` and `aggregation-switch` were added in this fork under the same license |
| vis-network, vis-data, vis-util (bundled in `js/app.js`) | Apache-2.0 OR MIT |
| Hammer.js (bundled in `js/app.js`) | MIT |
The [NOTICE](NOTICE) file lists the copyright holders. The original copyright and license
notices are retained, and every file changed in this fork carries a notice stating that it
was modified.
+5 -5
View File
@@ -1,14 +1,14 @@
from django.utils.translation import gettext_lazy as _
# Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
# Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files.
from netbox.plugins import PluginConfig
class TopologyViewsConfig(PluginConfig):
name = "netbox_topology_views"
verbose_name = _("Topology views")
description = _("A plugin to render topology maps")
verbose_name = "Topology views"
description = "A plugin to render topology maps"
version = "4.5.2"
author = "Mattijs Vanhaverbeke, Codex & Claude"
author_email = "[email protected]"
author = "Mattijs Vanhaverbeke (original), MrBlake (fork)"
base_url = "netbox_topology_views"
min_version = "4.7.0"
max_version = "4.7.99"
+15 -16
View File
@@ -1,4 +1,3 @@
from django.utils.translation import gettext_lazy as _
from utilities.choices import ChoiceSet
class NodeLabelItems(ChoiceSet):
@@ -19,19 +18,19 @@ class NodeLabelItems(ChoiceSet):
ASSET_TAG = 'assettag'
CHOICES = [
(DEVICE_NAME, _('Device Name')),
(DEVICE_TYPE, _('Device Type')),
(ROLE, _('Role')),
(DESCRIPTION, _('Description')),
(PRIMARY_IPV4, _('Primary IPv4')),
(PRIMARY_IPV6, _('Primary IPv6')),
(OUT_OF_BAND_IP, _('Out-of-band IP')),
(PLATFORM, _('Platform')),
(SERIAL, _('Serial')),
(TENANT, _('Tenant')),
(SITE, _('Site')),
(LOCATION, _('Location')),
(RACK, _('Rack')),
(VIRTUAL_CHASSIS, _('Virtual Chassis')),
(ASSET_TAG, _('Asset Tag')),
(DEVICE_NAME, 'Device Name'),
(DEVICE_TYPE, 'Device Type'),
(ROLE, 'Role'),
(DESCRIPTION, 'Description'),
(PRIMARY_IPV4, 'Primary IPv4'),
(PRIMARY_IPV6, 'Primary IPv6'),
(OUT_OF_BAND_IP, 'Out-of-band IP'),
(PLATFORM, 'Platform'),
(SERIAL, 'Serial'),
(TENANT, 'Tenant'),
(SITE, 'Site'),
(LOCATION, 'Location'),
(RACK, 'Rack'),
(VIRTUAL_CHASSIS, 'Virtual Chassis'),
(ASSET_TAG, 'Asset Tag'),
]
+22 -23
View File
@@ -3,7 +3,6 @@ from circuits.models import Circuit
from dcim.choices import DeviceStatusChoices
from dcim.models import Device, DeviceRole, Location, Rack, Region, Site, SiteGroup, Manufacturer, DeviceType, Platform, PowerPanel, PowerFeed
from django.db.models import Q
from django.utils.translation import gettext_lazy as _
from extras.filtersets import LocalConfigContextFilterSet
from extras.models import ConfigTemplate
from netbox.filtersets import NetBoxModelFilterSet
@@ -14,58 +13,58 @@ from netbox_topology_views.models import CoordinateGroup, Coordinate, CircuitCoo
class DeviceFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilterSet, LocalConfigContextFilterSet):
q = django_filters.CharFilter(
method="search",
label=_("Search"),
label="Search",
)
manufacturer_id = django_filters.ModelMultipleChoiceFilter(
field_name='device_type__manufacturer',
queryset=Manufacturer.objects.all(),
label=_("Manufacturer (ID)"),
label="Manufacturer (ID)",
)
manufacturer = django_filters.ModelMultipleChoiceFilter(
field_name='device_type__manufacturer__slug',
queryset=Manufacturer.objects.all(),
to_field_name='slug',
label=_("Manufacturer (slug)"),
label="Manufacturer (slug)",
)
device_type_id = django_filters.ModelMultipleChoiceFilter(
queryset=DeviceType.objects.all(),
label=_("Device type (ID)"),
label="Device type (ID)",
)
role_id = django_filters.ModelMultipleChoiceFilter(
field_name="role_id",
queryset=DeviceRole.objects.all(),
label=_("Role (ID)"),
label="Role (ID)",
)
platform_id = django_filters.ModelMultipleChoiceFilter(
queryset=Platform.objects.all(),
label=_("Platform (ID)"),
label="Platform (ID)",
)
region_id = TreeNodeMultipleChoiceFilter(
queryset=Region.objects.all(),
field_name="site__region",
lookup_expr="in",
label=_("Region (ID)"),
label="Region (ID)",
)
site_group_id = TreeNodeMultipleChoiceFilter(
queryset=SiteGroup.objects.all(),
field_name="site__group",
lookup_expr="in",
label=_("Site Group (ID)"),
label="Site Group (ID)",
)
site_id = django_filters.ModelMultipleChoiceFilter(
queryset=Site.objects.all(),
label=_("Site (ID)"),
label="Site (ID)",
)
location_id = TreeNodeMultipleChoiceFilter(
queryset=Location.objects.all(),
field_name="location",
lookup_expr="in",
label=_("Location (ID)"),
label="Location (ID)",
)
rack_id = django_filters.ModelMultipleChoiceFilter(
queryset=Rack.objects.all(),
field_name="rack_id",
label=_("Rack (ID)"),
label="Rack (ID)",
)
status = django_filters.MultipleChoiceFilter(
choices=DeviceStatusChoices,
@@ -73,50 +72,50 @@ class DeviceFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilter
)
mac_address = MultiValueMACAddressFilter(
field_name='interfaces__mac_addresses__mac_address',
label=_("MAC address"),
label="MAC address",
)
serial = MultiValueCharFilter(
lookup_expr='iexact'
)
console_ports = django_filters.BooleanFilter(
method='_console_ports',
label=_("Has console ports"),
label="Has console ports",
)
console_server_ports = django_filters.BooleanFilter(
method='_console_server_ports',
label=_("Has console server ports"),
label="Has console server ports",
)
power_ports = django_filters.BooleanFilter(
method='_power_ports',
label=_("Has power ports"),
label="Has power ports",
)
power_outlets = django_filters.BooleanFilter(
method='_power_outlets',
label=_("Has power outlets"),
label="Has power outlets",
)
interfaces = django_filters.BooleanFilter(
method='_interfaces',
label=_("Has interfaces"),
label="Has interfaces",
)
pass_through_ports = django_filters.BooleanFilter(
method='_pass_through_ports',
label=_("Has pass-through ports"),
label="Has pass-through ports",
)
config_template_id = django_filters.ModelMultipleChoiceFilter(
queryset=ConfigTemplate.objects.all(),
label=_("Config template (ID)"),
label="Config template (ID)",
)
has_primary_ip = django_filters.BooleanFilter(
method='_has_primary_ip',
label=_("Has a primary IP"),
label="Has a primary IP",
)
has_oob_ip = django_filters.BooleanFilter(
method='_has_oob_ip',
label=_("Has an out-of-band IP"),
label="Has an out-of-band IP",
)
virtual_chassis_member = django_filters.BooleanFilter(
method='_virtual_chassis_member',
label=_("Is a virtual chassis member"),
label="Is a virtual chassis member",
)
class Meta:
+9 -6
View File
@@ -1,3 +1,6 @@
# Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
# Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files.
from cProfile import label
from django import forms
from django.conf import settings
@@ -158,7 +161,7 @@ class DeviceFilterForm(
platform_id = DynamicModelMultipleChoiceField(
queryset=Platform.objects.all(),
required=False,
null_option=_('None'),
null_option='None',
label=_('Platform')
)
console_ports = forms.NullBooleanField(
@@ -648,7 +651,7 @@ class IndividualOptionsForm(NetBoxModelForm):
'are displayed as yellow dotted lines.')
)
show_single_cable_logical_conns = forms.BooleanField(
label = _('Show redundant Cable and Logical Connection'),
label = ('Show redundant Cable and Logical Connection'),
required = False,
initial=False,
help_text=_('Shows a logical connection (in addition to a cable), '
@@ -693,28 +696,28 @@ class IndividualOptionsForm(NetBoxModelForm):
'same virtual chassis.')
)
draw_default_layout = forms.BooleanField(
label = _('Draw Default Layout'),
label = ('Draw Default Layout'),
required=False,
initial=False,
help_text=_('Enable this option if you want to draw the topology on '
'the initial load (when you go to the topology plugin page).')
)
straight_cables = forms.BooleanField(
label=_('Use Straight Cables'),
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.')
)
draw_termination_labels = forms.BooleanField(
label=_('Termination Labels'),
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'),
label=('Cable Labels'),
required=False,
initial=False,
help_text=_('Enable this option if you want to draw a cable labels.')
File diff suppressed because it is too large. Load diff
+33 -60
View File
@@ -9,7 +9,6 @@ from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.templatetags.static import static
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from netbox.models import NetBoxModel
from netbox.models.features import (
ChangeLoggingMixin,
@@ -30,15 +29,13 @@ from netbox_topology_views.choices import NodeLabelItems
class RoleImage(ChangeLoggingMixin, ExportTemplatesMixin, EventRulesMixin):
class Meta:
verbose_name = _('role image')
verbose_name_plural = _('role images')
indexes = [
models.Index(fields=["content_type", "object_id"]),
]
objects: "models.Manager[RoleImage]"
image = models.CharField(_("Path within the netbox static directory"), max_length=255)
image = models.CharField("Path within the netbox static directory", max_length=255)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField(null=True, blank=True)
@@ -108,13 +105,11 @@ class CoordinateGroup(NetBoxModel):
This allows different visualizations with the same devices.
"""
name = models.CharField(
verbose_name=_('name'),
max_length=100,
unique=True,
)
description = models.CharField(
verbose_name=_('description'),
max_length=255,
blank = True,
)
@@ -123,8 +118,6 @@ class CoordinateGroup(NetBoxModel):
class Meta:
ordering = ['name']
verbose_name = _('coordinate group')
verbose_name_plural = _('coordinate groups')
def __str__(self):
return self.name
@@ -138,18 +131,16 @@ class Coordinate(NetBoxModel):
position. Devices belong to one or more coordinate groups. They have to
be unique together.
"""
device = models.ForeignKey(Device, on_delete=models.CASCADE, verbose_name=_('device'))
group = models.ForeignKey(CoordinateGroup, on_delete=models.CASCADE, verbose_name=_('group'))
device = models.ForeignKey(Device, on_delete=models.CASCADE)
group = models.ForeignKey(CoordinateGroup, on_delete=models.CASCADE)
x = models.IntegerField(
verbose_name=_('X'),
help_text=_('X-coordinate of the device (horizontal) on the canvas. '
'Smaller values correspond to a position further to the left on the monitor.'),
help_text='X-coordinate of the device (horizontal) on the canvas. '
'Smaller values correspond to a position further to the left on the monitor.',
)
y = models.IntegerField(
verbose_name=_('Y'),
help_text=_('Y-coordinate of the device (vertical) on the canvas. '
'Smaller values correspond to a position further up on the monitor.'),
help_text='Y-coordinate of the device (vertical) on the canvas. '
'Smaller values correspond to a position further up on the monitor.',
)
_netbox_private = True
@@ -165,9 +156,9 @@ class Coordinate(NetBoxModel):
else:
group = CoordinateGroup(
name="default",
description=_("Automatically generated default group. If you delete "
description="Automatically generated default group. If you delete "
"this group, all default coordinates are gone for good but "
"the group itself will be re-created.")
"the group itself will be re-created."
)
group.save()
group_id = group.pk
@@ -178,8 +169,6 @@ class Coordinate(NetBoxModel):
class Meta:
ordering = ['group', 'device']
unique_together = ('device', 'group')
verbose_name = _('device coordinate')
verbose_name_plural = _('device coordinates')
def __str__(self):
return f'{self.x};{self.y}'
@@ -193,18 +182,16 @@ class CircuitCoordinate(NetBoxModel):
position. Devices belong to one or more coordinate groups. They have to
be unique together.
"""
device = models.ForeignKey(Circuit, on_delete=models.CASCADE, verbose_name=_('circuit'))
group = models.ForeignKey(CoordinateGroup, on_delete=models.CASCADE, verbose_name=_('group'))
device = models.ForeignKey(Circuit, on_delete=models.CASCADE)
group = models.ForeignKey(CoordinateGroup, on_delete=models.CASCADE)
x = models.IntegerField(
verbose_name=_('X'),
help_text=_('X-coordinate of the device (horizontal) on the canvas. '
'Smaller values correspond to a position further to the left on the monitor.'),
help_text='X-coordinate of the device (horizontal) on the canvas. '
'Smaller values correspond to a position further to the left on the monitor.',
)
y = models.IntegerField(
verbose_name=_('Y'),
help_text=_('Y-coordinate of the device (vertical) on the canvas. '
'Smaller values correspond to a position further up on the monitor.'),
help_text='Y-coordinate of the device (vertical) on the canvas. '
'Smaller values correspond to a position further up on the monitor.',
)
_netbox_private = True
@@ -220,9 +207,9 @@ class CircuitCoordinate(NetBoxModel):
else:
group = CoordinateGroup(
name="default",
description=_("Automatically generated default group. If you delete "
description="Automatically generated default group. If you delete "
"this group, all default coordinates are gone for good but "
"the group itself will be re-created.")
"the group itself will be re-created."
)
group.save()
group_id = group.pk
@@ -233,8 +220,6 @@ class CircuitCoordinate(NetBoxModel):
class Meta:
ordering = ['group', 'device']
unique_together = ('device', 'group')
verbose_name = _('circuit coordinate')
verbose_name_plural = _('circuit coordinates')
def __str__(self):
return f'{self.x};{self.y}'
@@ -248,18 +233,16 @@ class PowerPanelCoordinate(NetBoxModel):
position. Devices belong to one or more coordinate groups. They have to
be unique together.
"""
device = models.ForeignKey(PowerPanel, on_delete=models.CASCADE, verbose_name=_('power panel'))
group = models.ForeignKey(CoordinateGroup, on_delete=models.CASCADE, verbose_name=_('group'))
device = models.ForeignKey(PowerPanel, on_delete=models.CASCADE)
group = models.ForeignKey(CoordinateGroup, on_delete=models.CASCADE)
x = models.IntegerField(
verbose_name=_('X'),
help_text=_('X-coordinate of the device (horizontal) on the canvas. '
'Smaller values correspond to a position further to the left on the monitor.'),
help_text='X-coordinate of the device (horizontal) on the canvas. '
'Smaller values correspond to a position further to the left on the monitor.',
)
y = models.IntegerField(
verbose_name=_('Y'),
help_text=_('Y-coordinate of the device (vertical) on the canvas. '
'Smaller values correspond to a position further up on the monitor.'),
help_text='Y-coordinate of the device (vertical) on the canvas. '
'Smaller values correspond to a position further up on the monitor.',
)
_netbox_private = True
@@ -275,9 +258,9 @@ class PowerPanelCoordinate(NetBoxModel):
else:
group = CoordinateGroup(
name="default",
description=_("Automatically generated default group. If you delete "
description="Automatically generated default group. If you delete "
"this group, all default coordinates are gone for good but "
"the group itself will be re-created.")
"the group itself will be re-created."
)
group.save()
group_id = group.pk
@@ -288,8 +271,6 @@ class PowerPanelCoordinate(NetBoxModel):
class Meta:
ordering = ['group', 'device']
unique_together = ('device', 'group')
verbose_name = _('power panel coordinate')
verbose_name_plural = _('power panel coordinates')
def __str__(self):
return f'{self.x};{self.y}'
@@ -303,18 +284,16 @@ class PowerFeedCoordinate(NetBoxModel):
position. Devices belong to one or more coordinate groups. They have to
be unique together.
"""
device = models.ForeignKey(PowerFeed, on_delete=models.CASCADE, verbose_name=_('power feed'))
group = models.ForeignKey(CoordinateGroup, on_delete=models.CASCADE, verbose_name=_('group'))
device = models.ForeignKey(PowerFeed, on_delete=models.CASCADE)
group = models.ForeignKey(CoordinateGroup, on_delete=models.CASCADE)
x = models.IntegerField(
verbose_name=_('X'),
help_text=_('X-coordinate of the device (horizontal) on the canvas. '
'Smaller values correspond to a position further to the left on the monitor.'),
help_text='X-coordinate of the device (horizontal) on the canvas. '
'Smaller values correspond to a position further to the left on the monitor.',
)
y = models.IntegerField(
verbose_name=_('Y'),
help_text=_('Y-coordinate of the device (vertical) on the canvas. '
'Smaller values correspond to a position further up on the monitor.'),
help_text='Y-coordinate of the device (vertical) on the canvas. '
'Smaller values correspond to a position further up on the monitor.',
)
_netbox_private = True
@@ -330,9 +309,9 @@ class PowerFeedCoordinate(NetBoxModel):
else:
group = CoordinateGroup(
name="default",
description=_("Automatically generated default group. If you delete "
description="Automatically generated default group. If you delete "
"this group, all default coordinates are gone for good but "
"the group itself will be re-created.")
"the group itself will be re-created."
)
group.save()
group_id = group.pk
@@ -343,8 +322,6 @@ class PowerFeedCoordinate(NetBoxModel):
class Meta:
ordering = ['group', 'device']
unique_together = ('device', 'group')
verbose_name = _('power feed coordinate')
verbose_name_plural = _('power feed coordinates')
def __str__(self):
return f'{self.x};{self.y}'
@@ -444,9 +421,5 @@ class IndividualOptions(NetBoxModel):
_netbox_private = True
class Meta:
verbose_name = _('individual options')
verbose_name_plural = _('individual options')
def __str___(self):
return f"{self.user_id}"
+26 -25
View File
@@ -1,16 +1,17 @@
from django.utils.translation import gettext_lazy as _
# Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
# Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files.
from netbox.plugins import PluginMenu, PluginMenuItem, PluginMenuButton
coordinategroup_buttons = (
PluginMenuButton(
link='plugins:netbox_topology_views:coordinategroup_add',
title=_('Add'),
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=['netbox_topology_views.add_coordinategroup']
),
PluginMenuButton(
link='plugins:netbox_topology_views:coordinategroup_import',
title=_('Import'),
title='Import',
icon_class='mdi mdi-upload',
permissions=['netbox_topology_views.add_coordinategroup']
)
@@ -19,13 +20,13 @@ coordinategroup_buttons = (
circuitcoordinate_buttons = (
PluginMenuButton(
link='plugins:netbox_topology_views:circuitcoordinate_add',
title=_('Add'),
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=['netbox_topology_views.add_coordinate']
),
PluginMenuButton(
link='plugins:netbox_topology_views:circuitcoordinate_import',
title=_('Import'),
title='Import',
icon_class='mdi mdi-upload',
permissions=['netbox_topology_views.add_coordinate']
)
@@ -34,13 +35,13 @@ circuitcoordinate_buttons = (
powerpanelcoordinate_buttons = (
PluginMenuButton(
link='plugins:netbox_topology_views:powerpanelcoordinate_add',
title=_('Add'),
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=['netbox_topology_views.add_coordinate']
),
PluginMenuButton(
link='plugins:netbox_topology_views:powerpanelcoordinate_import',
title=_('Import'),
title='Import',
icon_class='mdi mdi-upload',
permissions=['netbox_topology_views.add_coordinate']
)
@@ -49,13 +50,13 @@ powerpanelcoordinate_buttons = (
powerfeedcoordinate_buttons = (
PluginMenuButton(
link='plugins:netbox_topology_views:powerfeedcoordinate_add',
title=_('Add'),
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=['netbox_topology_views.add_coordinate']
),
PluginMenuButton(
link='plugins:netbox_topology_views:powerfeedcoordinate_import',
title=_('Import'),
title='Import',
icon_class='mdi mdi-upload',
permissions=['netbox_topology_views.add_coordinate']
)
@@ -64,45 +65,45 @@ powerfeedcoordinate_buttons = (
coordinate_buttons = (
PluginMenuButton(
link='plugins:netbox_topology_views:coordinate_add',
title=_('Add'),
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=['netbox_topology_views.add_coordinate']
),
PluginMenuButton(
link='plugins:netbox_topology_views:coordinate_import',
title=_('Import'),
title='Import',
icon_class='mdi mdi-upload',
permissions=['netbox_topology_views.add_coordinate']
)
)
menu = PluginMenu(
label=_('Topology Views'),
label='Topology Views',
icon_class="mdi mdi-sitemap",
groups=(
(_('Topology'),
('TOPOLOGY',
(
PluginMenuItem(link="plugins:netbox_topology_views:home", link_text=_("Topology"), permissions=["dcim.view_site", "dcim.view_device"]),
PluginMenuItem(link="plugins:netbox_topology_views:home", link_text="Topology", permissions=["dcim.view_site", "dcim.view_device"]),
),
),
(_('More views'),
('WEITERE ANSICHTEN',
(
PluginMenuItem(link="plugins:netbox_topology_views:rack_elevation", link_text=_("Rack view"), permissions=["dcim.view_rack", "dcim.view_device", "dcim.view_cable"]),
PluginMenuItem(link="plugins:netbox_topology_views:rack_elevation", link_text="Rack-Ansicht", permissions=["dcim.view_rack", "dcim.view_device", "dcim.view_cable"]),
),
),
(_('Coordinates'),
('COORDINATES',
(
PluginMenuItem(link="plugins:netbox_topology_views:coordinategroup_list", link_text=_("Coordinate Groups"), buttons=coordinategroup_buttons, permissions=['netbox_topology_views.view_coordinategroup']),
PluginMenuItem(link="plugins:netbox_topology_views:coordinate_list", link_text=_("Device Coordinates"), buttons=coordinate_buttons, permissions=['netbox_topology_views.view_coordinate']),
PluginMenuItem(link="plugins:netbox_topology_views:powerfeedcoordinate_list", link_text=_("Power Feed Coords"), buttons=powerfeedcoordinate_buttons, permissions=['netbox_topology_views.view_coordinate']),
PluginMenuItem(link="plugins:netbox_topology_views:powerpanelcoordinate_list", link_text=_("Power Panel Coords"), buttons=powerpanelcoordinate_buttons, permissions=['netbox_topology_views.view_coordinate']),
PluginMenuItem(link="plugins:netbox_topology_views:circuitcoordinate_list", link_text=_("Circuit Coordinates"), buttons=circuitcoordinate_buttons, permissions=['netbox_topology_views.view_coordinate']),
PluginMenuItem(link="plugins:netbox_topology_views:coordinategroup_list", link_text="Coordinate Groups", buttons=coordinategroup_buttons, permissions=['netbox_topology_views.view_coordinategroup']),
PluginMenuItem(link="plugins:netbox_topology_views:coordinate_list", link_text="Device Coordinates", buttons=coordinate_buttons, permissions=['netbox_topology_views.view_coordinate']),
PluginMenuItem(link="plugins:netbox_topology_views:powerfeedcoordinate_list", link_text="Power Feed Coords", buttons=powerfeedcoordinate_buttons, permissions=['netbox_topology_views.view_coordinate']),
PluginMenuItem(link="plugins:netbox_topology_views:powerpanelcoordinate_list", link_text="Power Panel Coords", buttons=powerpanelcoordinate_buttons, permissions=['netbox_topology_views.view_coordinate']),
PluginMenuItem(link="plugins:netbox_topology_views:circuitcoordinate_list", link_text="Circuit Coordinates", buttons=circuitcoordinate_buttons, permissions=['netbox_topology_views.view_coordinate']),
),
),
(_('Preferences'),
('PREFERENCES',
(
PluginMenuItem(link="plugins:netbox_topology_views:images", link_text=_("Images"), permissions=[ "dcim.view_site","dcim.view_devicerole"]),
PluginMenuItem(link="plugins:netbox_topology_views:individualoptions", link_text=_("Individual Options"), permissions=['netbox_topology_views.change_individualoptions']),
PluginMenuItem(link="plugins:netbox_topology_views:images", link_text="Images", permissions=[ "dcim.view_site","dcim.view_devicerole"]),
PluginMenuItem(link="plugins:netbox_topology_views:individualoptions", link_text="Individual Options", permissions=['netbox_topology_views.change_individualoptions']),
),
),
),
@@ -1 +1,3 @@
/* Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files. */
#visgraph{height:64vh;border:1px solid #ced4da}html[data-netbox-color-mode=dark] #visgraph{background-color:#212529;border:1px solid #495057}.image-dropdown img{width:64px;height:64px}.image-dropdown-content{display:flex;flex-wrap:wrap;gap:.5rem;padding-inline:.5rem;width:50vw;max-width:32rem}.image-dropdown-content>img{cursor:pointer}.rack-elevation-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(34rem,1fr));gap:1rem}.rack-card{border:1px solid var(--tblr-border-color,#ced4da);border-radius:.4rem;background:var(--tblr-bg-surface,#fff);padding:1rem}.rack-card>header{display:flex;justify-content:space-between;margin-bottom:.75rem}.rack-faces{display:grid;grid-template-columns:1fr 1fr;gap:.75rem}.rack-face-title{text-align:center;font-size:.75rem;text-transform:uppercase;margin-bottom:.25rem}.rack-frame{display:flex;height:calc(var(--rack-units)*14px);min-height:280px;max-height:70vh;border:4px solid #3b4654;background:repeating-linear-gradient(to top,rgba(127,127,127,.14) 0,rgba(127,127,127,.14) 1px,transparent 1px,transparent calc(100%/var(--rack-units)))}.rack-unit-labels{width:2rem;display:flex;flex-direction:column;justify-content:space-around;font-size:.55rem;text-align:center;color:var(--tblr-secondary,#667382)}.rack-device-area{position:relative;flex:1;border-left:1px solid #3b4654}.rack-device{position:absolute;left:3px;right:3px;min-height:2px;overflow:hidden;padding:1px 5px;border:2px solid #1685fc;border-radius:3px;background:#162e45;color:#fff;line-height:1.1;text-decoration:none}.rack-device:hover{filter:brightness(1.25);color:#fff;z-index:2}.rack-device span,.rack-device small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rack-device small{font-size:.6rem;opacity:.8}@media(max-width:700px){.rack-elevation-grid{grid-template-columns:1fr}.rack-faces{grid-template-columns:1fr}}
@@ -1 +1 @@
(()=>{var w=(o,t)=>()=>(o&&(t=o(o=0)),t);var f=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var l=(o,t,e)=>new Promise((r,s)=>{var c=n=>{try{a(e.next(n))}catch(i){s(i)}},g=n=>{try{a(e.throw(n))}catch(i){s(i)}},a=n=>n.done?r(n.value):Promise.resolve(n.value).then(c,g);a((e=e.apply(o,t)).next())});var u,d=w(()=>{u={success:o=>{let t=document.querySelector("#topology-plugin-success-toast");if(!t)return console.error("Could not find toast component!");let e=t.querySelector("span");e.textContent=o,new window.Toast(t).show()},error:o=>{let t=document.querySelector("#topology-plugin-error-toast");if(!t)return console.error("Could not find toast component!");let e=t.querySelector("span");e.textContent=o,new window.Toast(t).show()}}});var y=f(p=>{d();var m={};document.querySelector("form#images").addEventListener("submit",o=>l(null,null,function*(){o.preventDefault();try{let t=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/images/save/",{method:"POST",body:JSON.stringify(m),headers:{"X-CSRFToken":window.CSRF_TOKEN,"Content-Type":"application/json"}});if(!t.ok)throw new Error(yield t.text());u.success(window.topologyI18n?.savedSettings??"Saved settings")}catch(t){console.dir(t),u.error(t.message)}}));document.querySelectorAll("form#images .dropdown-menu img").forEach(o=>{o.addEventListener("click",t=>{var c;if(!(t.currentTarget instanceof HTMLElement))return;let{dataset:{role:e,image:r}}=t.currentTarget;m[e]=r;let s=(c=t.currentTarget.closest(".dropdown"))==null?void 0:c.querySelector(`#dropdownMenuButton${e}`);s&&(s.innerHTML=`<img src="${r}" />`)})})});y();})();
(()=>{var w=(o,t)=>()=>(o&&(t=o(o=0)),t);var f=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var l=(o,t,e)=>new Promise((r,s)=>{var c=n=>{try{a(e.next(n))}catch(i){s(i)}},g=n=>{try{a(e.throw(n))}catch(i){s(i)}},a=n=>n.done?r(n.value):Promise.resolve(n.value).then(c,g);a((e=e.apply(o,t)).next())});var u,d=w(()=>{u={success:o=>{let t=document.querySelector("#topology-plugin-success-toast");if(!t)return console.error("Could not find toast component!");let e=t.querySelector("span");e.textContent=o,new window.Toast(t).show()},error:o=>{let t=document.querySelector("#topology-plugin-error-toast");if(!t)return console.error("Could not find toast component!");let e=t.querySelector("span");e.textContent=o,new window.Toast(t).show()}}});var y=f(p=>{d();var m={};document.querySelector("form#images").addEventListener("submit",o=>l(null,null,function*(){o.preventDefault();try{let t=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/images/save/",{method:"POST",body:JSON.stringify(m),headers:{"X-CSRFToken":window.CSRF_TOKEN,"Content-Type":"application/json"}});if(!t.ok)throw new Error(yield t.text());u.success("Saved settings")}catch(t){console.dir(t),u.error(t.message)}}));document.querySelectorAll("form#images .dropdown-menu img").forEach(o=>{o.addEventListener("click",t=>{var c;if(!(t.currentTarget instanceof HTMLElement))return;let{dataset:{role:e,image:r}}=t.currentTarget;m[e]=r;let s=(c=t.currentTarget.closest(".dropdown"))==null?void 0:c.querySelector(`#dropdownMenuButton${e}`);s&&(s.innerHTML=`<img src="${r}" />`)})})});y();})();
@@ -1,3 +1,5 @@
/* Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files. */
#visgraph {
height: 64vh;
border: 1px solid #ced4da
@@ -15,7 +15,7 @@ document.querySelector('form#images').addEventListener('submit', async (e) => {
})
if (!res.ok) throw new Error(await res.text())
toast.success(window.topologyI18n?.savedSettings ?? 'Saved settings')
toast.success('Saved settings')
} catch (err) {
console.dir(err)
toast.error(err.message)
+1 -2
View File
@@ -1,5 +1,4 @@
import django_tables2 as tables
from django.utils.translation import gettext_lazy as _
from netbox.tables import NetBoxTable, ChoiceFieldColumn
from netbox_topology_views.models import CoordinateGroup, Coordinate, CircuitCoordinate, PowerPanelCoordinate, PowerFeedCoordinate
@@ -8,7 +7,7 @@ class CoordinateGroupListTable(NetBoxTable):
name = tables.Column(
linkify=True
)
devices = tables.Column(verbose_name=_('Devices'))
devices = tables.Column()
class Meta(NetBoxTable.Meta):
model = CoordinateGroup
@@ -1,33 +1,32 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load plugins %}
{% block title %}{% trans "Topology Views Coordinates" %}{% endblock title %}
{% block title %}Topology Views Coordinates{% endblock title %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Coordinates" %}
Coordinates
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Group" %}</th>
<th scope="row">Group</th>
<td>{{ object.group|linkify }}</td>
</tr>
<tr>
<th scope="row">{% trans "Circuit" %}</th>
<th scope="row">Circuit</th>
<td>{{ object.device|linkify }}</td>
</tr>
<tr>
<th scope="row">{% trans "X-Coordinate" %}</th>
<th scope="row">X-Coordinate</th>
<td>{{ object.x }}</td>
</tr>
<tr>
<th scope="row">{% trans "Y-Coordinate" %}</th>
<th scope="row">Y-Coordinate</th>
<td>{{ object.y }}</td>
</tr>
</table>
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Add new Circuit Coordinates" %}{% endblock title %}
{% block title %}Add new Circuit Coordinates{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Edit Circuit Coordinates" %}{% endblock title %}
{% block title %}Edit Circuit Coordinates{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_list.html' %}
{% load i18n %}
{% block title %}{% trans "Circuit Coordinates" %}{% endblock title %}
{% block title %}Circuit Coordinates{% endblock title %}
@@ -1,33 +1,32 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load plugins %}
{% block title %}{% trans "Topology Views Coordinates" %}{% endblock title %}
{% block title %}Topology Views Coordinates{% endblock title %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Coordinates" %}
Coordinates
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Group" %}</th>
<th scope="row">Group</th>
<td>{{ object.group|linkify }}</td>
</tr>
<tr>
<th scope="row">{% trans "Device" %}</th>
<th scope="row">Device</th>
<td>{{ object.device|linkify }}</td>
</tr>
<tr>
<th scope="row">{% trans "X-Coordinate" %}</th>
<th scope="row">X-Coordinate</th>
<td>{{ object.x }}</td>
</tr>
<tr>
<th scope="row">{% trans "Y-Coordinate" %}</th>
<th scope="row">Y-Coordinate</th>
<td>{{ object.y }}</td>
</tr>
</table>
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Add new Device Coordinates" %}{% endblock title %}
{% block title %}Add new Device Coordinates{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Edit Device Coordinates" %}{% endblock title %}
{% block title %}Edit Device Coordinates{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_list.html' %}
{% load i18n %}
{% block title %}{% trans "Device Coordinates" %}{% endblock title %}
{% block title %}Device Coordinates{% endblock title %}
@@ -1,26 +1,25 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load plugins %}
{% load render_table from django_tables2 %}
{% block title %}{% trans "Topology Views Coordinate Group" %}{% endblock title %}
{% block title %}Topology Views Coordinate Group{% endblock title %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Coordinate Group" %}
Coordinate Group
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">{% trans "Description" %}</th>
<th scope="row">Description</th>
<td>{{ object.description|placeholder }}</td>
</tr>
</table>
@@ -36,7 +35,7 @@
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Circuit Coordinates" %}</h5>
<h5 class="card-header">Circuit Coordinates</h5>
<div class="card-body table-responsive">
{% render_table circuitcoordinates_table %}
</div>
@@ -44,7 +43,7 @@
</div>
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Power Panel Coordinates" %}</h5>
<h5 class="card-header">Power Panel Coordinates</h5>
<div class="card-body table-responsive">
{% render_table powerpanelcoordinates_table %}
</div>
@@ -52,7 +51,7 @@
</div>
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Power Feed Coordinates" %}</h5>
<h5 class="card-header">Power Feed Coordinates</h5>
<div class="card-body table-responsive">
{% render_table powerfeedcoordinates_table %}
</div>
@@ -60,7 +59,7 @@
</div>
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Device Coordinates" %}</h5>
<h5 class="card-header">Device Coordinates</h5>
<div class="card-body table-responsive">
{% render_table coordinates_table %}
</div>
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Add a new Coordinate Group" %}{% endblock title %}
{% block title %}Add a new Coordinate Group{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Edit Coordinate Group" %}{% endblock title %}
{% block title %}Edit Coordinate Group{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_list.html' %}
{% load i18n %}
{% block title %}{% trans "Coordinate Groups" %}{% endblock title %}
{% block title %}Coordinate Groups{% endblock title %}
@@ -1,11 +1,10 @@
{% extends 'base/layout.html' %}
{% load i18n %}
{% load buttons %}
{% load render_table from django_tables2 %}
{% load helpers %}
{% load static %}
{% block title %}{% trans "Topology Views Images" %}{% endblock %}
{% block title %}Topology Views Images{% endblock %}
{% block head %}
<link rel="stylesheet" href="{% static 'netbox_topology_views/css/app.css' %}">
@@ -21,7 +20,7 @@
{% if role.image %}
<img src="{{ role.image }}" />
{% else %}
{% trans "Image" %}
Image
{% endif %}
</button>
<div class="dropdown-menu mt-2" aria-labelledby="dropdownMenuButton{{ role.id }}">
@@ -37,7 +36,7 @@
{% endfor %}
</div>
<button class="btn btn-primary" type="submit">{% trans "Save" %}</button>
<button class="btn btn-primary" type="submit">Save</button>
</form>
{% include 'netbox_topology_views/toasts.html' %}
{% endblock content %}
@@ -45,7 +44,6 @@
{% block javascript %}
<script type="text/javascript">
const basePath = '{{ basepath }}';
window.topologyI18n = {savedSettings: '{{ _("Saved settings")|escapejs }}'};
</script>
<script src="{% static 'netbox_topology_views/js/images.js' %}" defer></script>
{% endblock javascript %}
@@ -1,12 +1,11 @@
{% extends 'generic/_base.html' %}
{% load i18n %}
{% load buttons %}
{% load render_table from django_tables2 %}
{% load static %}
{% load perms %}
{% load helpers %}
{% block title %}{% trans "Topology Views" %}{% endblock %}
{% block title %}Topology Views{% endblock %}
{% block head %}
<link rel="stylesheet" href="{% static 'netbox_topology_views/css/vendor.css' %}">
@@ -19,11 +18,11 @@
{% block extra_controls %}{% endblock %}
<a id="btnDownloadXml" class="btn btn-info" href="#">
<i class="mdi mdi-download"></i>
{% trans "Download XML" %}
Download XML
</a>
<a id="btnDownloadImage" class="btn btn-info" href="#">
<i class="mdi mdi-download"></i>
{% trans "Download PNG" %}
Download PNG
</a>
</div>
</div>
@@ -34,13 +33,13 @@
{% block tab_items %}
<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">
{% trans "Network" %}
Network
</button>
</li>
{% if filter_form %}
<li class="nav-item" role="presentation">
<button class="nav-link" id="filters-form-tab" data-bs-toggle="tab" data-bs-target="#filters-form" type="button" role="tab" aria-controls="object-list" aria-selected="false">
{% trans "Filters" %}
Filters
{% if filter_form %}{% badge filter_form.changed_data|length bg_color="blue" %}{% endif %}
</button>
</li>
@@ -63,11 +62,11 @@
<div class="tab-pane show active" id="networks" role="tabpanel" aria-labelledby="network-tab">
<div class="panel-body">
{% if filter_required %}
<div class="bg-warning text-white p-2">{% trans 'Nothing to display! Set filters and hit search button or set "Draw Default Layout" in your individual options.' %}</div>
<div class="bg-warning text-white p-2">Nothing to display! Set filters and hit search button or set "Draw Default Layout" in your individual options.</div>
{% endif %}
{% if empty_result %}
<div class="bg-warning text-white p-2">{% trans "Empty result set! Please review your filter settings." %}</div>
<div class="bg-info text-white p-2">{% trans 'Hint: Some options may produce an empty result. Use at least "Show Unconnected/Cables/Logical Connections".' %}</div>
<div class="bg-warning text-white p-2">Empty result set! Please review your filter settings.</div>
<div class="bg-info text-white p-2">Hint: Some options may produce an empty result. Use at least "Show Unconnected/Cables/Logical Connections".</div>
{% endif %}
<div id="visgraph"></div>
</div>
@@ -1,6 +1,5 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Topology Views Individual Options" %}{% endblock %}
{% block title %}Topology Views Individual Options{% endblock %}
{% block tabs %} {% endblock tabs %}
@@ -1,5 +1,4 @@
{% load i18n %}
<a role="button" class="btn btn-primary" title="{% trans "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">
<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>
{% trans "Topology" %}
Topology
</a>
@@ -1,33 +1,32 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load plugins %}
{% block title %}{% trans "Topology Views Coordinates" %}{% endblock title %}
{% block title %}Topology Views Coordinates{% endblock title %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Coordinates" %}
Coordinates
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Group" %}</th>
<th scope="row">Group</th>
<td>{{ object.group|linkify }}</td>
</tr>
<tr>
<th scope="row">{% trans "Power Feed" %}</th>
<th scope="row">Power Feed</th>
<td>{{ object.device|linkify }}</td>
</tr>
<tr>
<th scope="row">{% trans "X-Coordinate" %}</th>
<th scope="row">X-Coordinate</th>
<td>{{ object.x }}</td>
</tr>
<tr>
<th scope="row">{% trans "Y-Coordinate" %}</th>
<th scope="row">Y-Coordinate</th>
<td>{{ object.y }}</td>
</tr>
</table>
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Add new Power Feed Coordinates" %}{% endblock title %}
{% block title %}Add new Power Feed Coordinates{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Edit Power Feed Coordinates" %}{% endblock title %}
{% block title %}Edit Power Feed Coordinates{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_list.html' %}
{% load i18n %}
{% block title %}{% trans "Power Feed Coordinates" %}{% endblock title %}
{% block title %}Power Feed Coordinates{% endblock title %}
@@ -1,33 +1,32 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load plugins %}
{% block title %}{% trans "Topology Views Coordinates" %}{% endblock title %}
{% block title %}Topology Views Coordinates{% endblock title %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Coordinates" %}
Coordinates
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Group" %}</th>
<th scope="row">Group</th>
<td>{{ object.group|linkify }}</td>
</tr>
<tr>
<th scope="row">{% trans "Power Panel" %}</th>
<th scope="row">Power Panel</th>
<td>{{ object.device|linkify }}</td>
</tr>
<tr>
<th scope="row">{% trans "X-Coordinate" %}</th>
<th scope="row">X-Coordinate</th>
<td>{{ object.x }}</td>
</tr>
<tr>
<th scope="row">{% trans "Y-Coordinate" %}</th>
<th scope="row">Y-Coordinate</th>
<td>{{ object.y }}</td>
</tr>
</table>
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Add new Power Panel Coordinates" %}{% endblock title %}
{% block title %}Add new Power Panel Coordinates{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block title %}{% trans "Edit Power Panel Coordinates" %}{% endblock title %}
{% block title %}Edit Power Panel Coordinates{% endblock title %}
@@ -1,4 +1,3 @@
{% extends 'generic/object_list.html' %}
{% load i18n %}
{% block title %}{% trans "Power Panel Coordinates" %}{% endblock title %}
{% block title %}Power Panel Coordinates{% endblock title %}
@@ -1,9 +1,8 @@
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load i18n %}
{% load static %}
{% block title %}{% trans "Rack view" %}{% endblock %}
{% block title %}Rack-Ansicht{% endblock %}
{% block head %}
<link rel="stylesheet" href="{% static 'netbox_topology_views/css/app.css' %}">
@@ -12,7 +11,7 @@
{% block content %}
<div class="card mb-3">
<div class="card-header"><strong>{% trans "Select racks" %}</strong></div>
<div class="card-header"><strong>Racks auswählen</strong></div>
<div class="card-body">
<form method="get">
<div class="row g-3">
@@ -26,8 +25,8 @@
{% endfor %}
</div>
<div class="mt-3">
<button class="btn btn-primary" type="submit"><i class="mdi mdi-magnify"></i> {% trans "Show" %}</button>
<a class="btn btn-outline-secondary" href="{% url 'plugins:netbox_topology_views:rack_elevation' %}">{% trans "Reset" %}</a>
<button class="btn btn-primary" type="submit"><i class="mdi mdi-magnify"></i> Anzeigen</button>
<a class="btn btn-outline-secondary" href="{% url 'plugins:netbox_topology_views:rack_elevation' %}">Zurücksetzen</a>
</div>
</form>
</div>
@@ -35,7 +34,7 @@
{% if racks %}
<div class="d-flex justify-content-end align-items-center gap-2 mb-3 flex-wrap">
<strong class="me-2">{% trans "Export all racks:" %}</strong>
<strong class="me-2">Alle Racks exportieren:</strong>
<button class="btn btn-sm btn-outline-primary rack-export" data-format="svg" data-scope="all">SVG</button>
<button class="btn btn-sm btn-outline-primary rack-export" data-format="png" data-scope="all">PNG</button>
<button class="btn btn-sm btn-outline-primary rack-export" data-format="drawio" data-scope="all">draw.io</button>
@@ -46,7 +45,7 @@
<header>
<div><a href="{{ rack.get_absolute_url }}"><strong>{{ rack.name }}</strong></a><br>
<small>{{ rack.site }}{% if rack.location %} · {{ rack.location }}{% endif %} · {{ rack.u_height }}U</small></div>
<div class="btn-group" aria-label="{% blocktrans with name=rack.name %}Export {{ name }}{% endblocktrans %}">
<div class="btn-group" aria-label="{{ rack.name }} exportieren">
<button class="btn btn-sm btn-outline-secondary rack-export" data-format="svg" data-scope="{{ rack.pk }}">SVG</button>
<button class="btn btn-sm btn-outline-secondary rack-export" data-format="png" data-scope="{{ rack.pk }}">PNG</button>
<button class="btn btn-sm btn-outline-secondary rack-export" data-format="drawio" data-scope="{{ rack.pk }}">draw.io</button>
@@ -85,16 +84,16 @@
<div id="rack-topology-card" class="card mt-4">
<div class="card-header d-flex justify-content-between align-items-center">
<strong>{% trans "Cable topology" %}</strong>
<strong>Kabeltopologie</strong>
<div class="d-flex gap-2 align-items-center">
<div class="d-flex gap-3 align-items-center rack-topology-kind-toggles">
<div class="form-check form-check-inline mb-0">
<input class="form-check-input" type="checkbox" id="rack-topology-show-wireless" checked>
<label class="form-check-label" for="rack-topology-show-wireless">{% trans "Wireless/WLAN" %}</label>
<label class="form-check-label" for="rack-topology-show-wireless">Funk/WLAN</label>
</div>
<div class="form-check form-check-inline mb-0">
<input class="form-check-input" type="checkbox" id="rack-topology-show-power" checked>
<label class="form-check-label" for="rack-topology-show-power">{% trans "Power" %}</label>
<label class="form-check-label" for="rack-topology-show-power">Strom</label>
</div>
</div>
<div class="btn-group">
@@ -102,21 +101,21 @@
<button class="btn btn-sm btn-outline-primary topology-export" data-format="png">PNG</button>
<button class="btn btn-sm btn-outline-primary topology-export" data-format="drawio">draw.io</button>
</div>
<div class="btn-group" aria-label="{% trans "Zoom topology" %}">
<button id="rack-topology-zoom-out" class="btn btn-sm btn-outline-secondary" type="button" title="{% trans "Zoom out" %}"><i class="mdi mdi-minus"></i></button>
<button id="rack-topology-zoom-reset" class="btn btn-sm btn-outline-secondary" type="button" title="{% trans "Reset zoom" %}"><span id="rack-topology-zoom-label">100%</span></button>
<button id="rack-topology-zoom-in" class="btn btn-sm btn-outline-secondary" type="button" title="{% trans "Zoom in" %}"><i class="mdi mdi-plus"></i></button>
<div class="btn-group" aria-label="Topologie zoomen">
<button id="rack-topology-zoom-out" class="btn btn-sm btn-outline-secondary" type="button" title="Verkleinern"><i class="mdi mdi-minus"></i></button>
<button id="rack-topology-zoom-reset" class="btn btn-sm btn-outline-secondary" type="button" title="Zoom zurücksetzen"><span id="rack-topology-zoom-label">100%</span></button>
<button id="rack-topology-zoom-in" class="btn btn-sm btn-outline-secondary" type="button" title="Vergrößern"><i class="mdi mdi-plus"></i></button>
</div>
<button id="rack-topology-reset" class="btn btn-sm btn-outline-secondary" type="button">
<i class="mdi mdi-restore"></i> {% trans "Reset positions" %}
<i class="mdi mdi-restore"></i> Positionen zurücksetzen
</button>
<button id="rack-topology-fullscreen" class="btn btn-sm btn-outline-secondary" type="button">
<i class="mdi mdi-fullscreen"></i> {% trans "Full screen" %}
<i class="mdi mdi-fullscreen"></i> Vollbild
</button>
</div>
</div>
<div class="card-body">
<div id="rack-topology" class="rack-topology" aria-label="{% trans "Topology of the selected racks" %}">
<div id="rack-topology" class="rack-topology" aria-label="Topologie der ausgewählten Racks">
<svg class="rack-topology-lines" aria-hidden="true"></svg>
<div class="rack-topology-columns"></div>
<div class="rack-topology-tooltip" role="tooltip"></div>
@@ -125,13 +124,12 @@
</div>
{{ rack_topology|json_script:"rack-topology-data" }}
{{ rack_export|json_script:"rack-export-data" }}
{{ i18n|json_script:"rack-i18n-data" }}
<div class="card mt-4">
<div class="card-header"><strong>{% trans "Cabling of the displayed racks" %}</strong> <span class="badge rack-cable-count">{{ cables|length }}</span></div>
<div class="card-header"><strong>Verkabelung der angezeigten Racks</strong> <span class="badge rack-cable-count">{{ cables|length }}</span></div>
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead><tr><th>{% trans "Cable" %}</th><th>{% trans "A side" %}</th><th>{% trans "B side" %}</th><th>{% trans "Type" %}</th><th>{% trans "Status" %}</th></tr></thead>
<thead><tr><th>Kabel</th><th>A-Seite</th><th>B-Seite</th><th>Typ</th><th>Status</th></tr></thead>
<tbody>
{% for row in cables %}
<tr>
@@ -140,15 +138,15 @@
<td>{% if row.b %}<strong>{{ row.b.device_name }}</strong><br><small>{{ row.b.name }}</small>{% else %}—{% endif %}</td>
<td>{{ row.cable.type|default:'—' }}</td><td>{{ row.cable.get_status_display }}</td>
</tr>
{% empty %}<tr><td colspan="5" class="text-muted text-center py-4">{% trans "No cabling found." %}</td></tr>{% endfor %}
{% empty %}<tr><td colspan="5" class="text-muted text-center py-4">Keine Verkabelung gefunden.</td></tr>{% endfor %}
</tbody>
</table>
</div>
</div>
{% elif has_selection %}
<div class="alert alert-warning">{% trans "No occupied racks were found for this selection. Enable “Include empty racks” to show empty racks as well." %}</div>
<div class="alert alert-warning">Für diese Auswahl wurden keine belegten Racks gefunden. Aktiviere „Leere Racks einschließen“, um auch leere Racks zu sehen.</div>
{% else %}
<div class="alert alert-info">{% trans "Select one or more racks, or narrow the view by site and location." %}</div>
<div class="alert alert-info">Wähle ein oder mehrere Racks oder grenze die Ansicht über Standort und Location ein.</div>
{% endif %}
{% endblock %}
@@ -159,7 +157,6 @@
const source = document.getElementById('rack-topology-data');
if (!root || !source) return;
const data = JSON.parse(source.textContent);
const t = JSON.parse(document.getElementById('rack-i18n-data').textContent);
const isWirelessEdge = edge => edge.kind === 'wireless' || edge.kind === 'wireless-lan';
const isPowerEdge = edge => edge.kind === 'power';
const showWirelessCheckbox = document.getElementById('rack-topology-show-wireless');
@@ -221,9 +218,9 @@
const groups = new Map();
data.nodes.forEach(node => {
const groupKey = node.rack_id ? `rack-${node.rack_id}` : `external-${node.rack_name || t.external}`;
const groupKey = node.rack_id ? `rack-${node.rack_id}` : `external-${node.rack_name || 'Extern'}`;
if (!groups.has(groupKey)) groups.set(groupKey, {
name: node.rack_name || t.external,
name: node.rack_name || 'Extern',
rackUnits: node.rack_u_height || null,
descUnits: Boolean(node.rack_desc_units),
nodes: [],
@@ -326,7 +323,7 @@
path.addEventListener('mouseenter', event => {
setEdgeHighlighted(path, true);
showTooltip(
`<strong>${isWirelessEdge(edge) ? 'WLAN · ' : isPowerEdge(edge) ? `${t.power} · ` : ''}${escapeHtml(edge.label)}</strong>` +
`<strong>${isWirelessEdge(edge) ? 'WLAN · ' : isPowerEdge(edge) ? 'Strom · ' : ''}${escapeHtml(edge.label)}</strong>` +
`<span>${escapeHtml(edge.from_device)} · ${escapeHtml(edge.from_port)}</span>` +
`<span>↔ ${escapeHtml(edge.to_device)} · ${escapeHtml(edge.to_port)}</span>`,
event.target
@@ -355,9 +352,9 @@
const localPort = outgoing ? edge.from_port : edge.to_port;
const remoteDevice = outgoing ? edge.to_device : edge.from_device;
const remotePort = outgoing ? edge.to_port : edge.from_port;
return `<li><strong>${escapeHtml(localPort)}</strong><span>→ ${escapeHtml(remoteDevice)} · ${escapeHtml(remotePort)}</span><small>${isWirelessEdge(edge) ? 'WLAN · ' : isPowerEdge(edge) ? `${t.power} · ` : ''}${escapeHtml(edge.label)}</small></li>`;
return `<li><strong>${escapeHtml(localPort)}</strong><span>→ ${escapeHtml(remoteDevice)} · ${escapeHtml(remotePort)}</span><small>${isWirelessEdge(edge) ? 'WLAN · ' : isPowerEdge(edge) ? 'Strom · ' : ''}${escapeHtml(edge.label)}</small></li>`;
}).join('');
showTooltip(`<strong>${escapeHtml(t.connections)} (${connections.length})</strong><ul>${rows || `<li>${escapeHtml(t.noConnections)}</li>`}</ul>`, node);
showTooltip(`<strong>Verbindungen (${connections.length})</strong><ul>${rows || '<li>Keine Verbindungen</li>'}</ul>`, node);
});
node.addEventListener('mouseleave', () => {
svg.querySelectorAll('.rack-topology-edge').forEach(path => {
@@ -415,8 +412,8 @@
document.addEventListener('fullscreenchange', () => {
const active = document.fullscreenElement === topologyCard;
fullscreenButton.innerHTML = active
? `<i class="mdi mdi-fullscreen-exit"></i> ${escapeHtml(t.exitFullScreen)}`
: `<i class="mdi mdi-fullscreen"></i> ${escapeHtml(t.fullScreen)}`;
? '<i class="mdi mdi-fullscreen-exit"></i> Vollbild verlassen'
: '<i class="mdi mdi-fullscreen"></i> Vollbild';
requestAnimationFrame(drawEdges);
});
const setTopologyZoom = value => {
@@ -460,7 +457,7 @@
const bottomUnits = bottom / 100 * rackUnits;
const startingUnit = Number(rack.starting_unit) || 1;
return {
name: device.dataset.deviceName || device.querySelector('span')?.textContent || t.device,
name: device.dataset.deviceName || device.querySelector('span')?.textContent || 'Gerät',
type: device.dataset.deviceType || '',
position: rack.desc_units
? startingUnit + rackUnits - deviceHeight - bottomUnits
@@ -491,7 +488,7 @@
vertex(`${rack.site}${rack.location ? ` · ${rack.location}` : ''} · ${rack.u_height}U`, `text;html=1;strokeColor=none;fillColor=none;align=left;fontSize=10;fontColor=${palette.muted};`, baseX, 24, rackWidth, 20);
['front', 'rear'].forEach((face, faceIndex) => {
const x = baseX + labelWidth + faceIndex * (faceWidth + faceGap);
vertex(face === 'front' ? t.front.toUpperCase() : t.rear.toUpperCase(), `text;html=1;strokeColor=none;fillColor=none;align=center;fontSize=10;fontColor=${palette.muted};`, x, 38, faceWidth, 17);
vertex(face === 'front' ? 'VORDERSEITE' : 'RÜCKSEITE', `text;html=1;strokeColor=none;fillColor=none;align=center;fontSize=10;fontColor=${palette.muted};`, x, 38, faceWidth, 17);
vertex('', `rounded=0;html=1;fillColor=none;strokeColor=${palette.frame};strokeWidth=4;`, x, header, faceWidth, rackHeight);
for (let row = 0; row < rack.u_height; row++) {
const y = header + row * unit;
@@ -528,7 +525,7 @@
content += `<text x="${baseX}" y="39" fill="${palette.muted}" font-family="sans-serif" font-size="11">${xmlEscape(rack.site)}${rack.location ? ` · ${xmlEscape(rack.location)}` : ''} · ${rack.u_height}U</text>`;
['front', 'rear'].forEach((face, faceIndex) => {
const x = baseX + labelWidth + faceIndex * (faceWidth + faceGap);
content += `<text x="${x + faceWidth / 2}" y="51" text-anchor="middle" fill="${palette.muted}" font-family="sans-serif" font-size="10">${face === 'front' ? t.front.toUpperCase() : t.rear.toUpperCase()}</text>`;
content += `<text x="${x + faceWidth / 2}" y="51" text-anchor="middle" fill="${palette.muted}" font-family="sans-serif" font-size="10">${face === 'front' ? 'VORDERSEITE' : 'RÜCKSEITE'}</text>`;
content += `<rect x="${x}" y="${header}" width="${faceWidth}" height="${rackHeight}" fill="none" stroke="${palette.frame}" stroke-width="4"/>`;
for (let row = 0; row < rack.u_height; row++) {
const y = header + row * unit;
@@ -591,7 +588,7 @@
if (!a || !b) return;
const bend = Math.max(30, Math.abs(b.x - a.x) * .35);
const dashPattern = isWirelessEdge(edge) ? '7 7' : isPowerEdge(edge) ? '2 4' : null;
const edgeLabelPrefix = isWirelessEdge(edge) ? 'WLAN · ' : isPowerEdge(edge) ? `${t.power} · ` : '';
const edgeLabelPrefix = isWirelessEdge(edge) ? 'WLAN · ' : isPowerEdge(edge) ? 'Strom · ' : '';
edgeContent += `<path d="M ${a.x} ${a.y} C ${a.x + bend} ${a.y}, ${b.x - bend} ${b.y}, ${b.x} ${b.y}" fill="none" stroke="${xmlEscape(edge.color)}" stroke-width="3"${dashPattern ? ` stroke-dasharray="${dashPattern}"` : ''}/>`;
const sourceId = nodeCells.get(edge.from), targetId = nodeCells.get(edge.to);
if (sourceId && targetId) {
@@ -640,11 +637,11 @@
document.querySelectorAll('.rack-export').forEach(button => button.addEventListener('click', () => {
const selectedRacks = button.dataset.scope === 'all' ? rackData : rackData.filter(rack => String(rack.id) === button.dataset.scope);
const racks = renderedRackData(selectedRacks);
const name = button.dataset.scope === 'all' ? 'racks-all' : `rack-${safeName(racks[0]?.name)}`;
const name = button.dataset.scope === 'all' ? 'racks-gesamt' : `rack-${safeName(racks[0]?.name)}`;
exportGraphic(buildRackSvg(racks), button.dataset.format, name);
}));
document.querySelectorAll('.topology-export').forEach(button => button.addEventListener('click', () => {
exportGraphic(buildTopologySvg(), button.dataset.format, 'rack-topology');
exportGraphic(buildTopologySvg(), button.dataset.format, 'rack-topologie');
}));
showWirelessCheckbox?.addEventListener('change', applyKindVisibility);
showPowerCheckbox?.addEventListener('change', applyKindVisibility);
@@ -1,4 +1,3 @@
{% load i18n %}
<div id="django-messages" class="toast-container">
<div
id="topology-plugin-error-toast"
@@ -11,13 +10,13 @@
<div class="d-flex">
<div class="toast-body">
😢
<span>{% trans "Error" %}</span>
<span>Error</span>
</div>
<button
type="button"
class="btn-close me-2 m-auto"
data-bs-dismiss="toast"
aria-label="{% trans "Close" %}"
aria-label="Close"
></button>
</div>
</div>
@@ -32,13 +31,13 @@
<div class="d-flex">
<div class="toast-body">
👍
<span>{% trans "Success" %}</span>
<span>Success</span>
</div>
<button
type="button"
class="btn-close me-2 m-auto"
data-bs-dismiss="toast"
aria-label="{% trans "Close" %}"
aria-label="Close"
></button>
</div>
</div>
+2
View File
@@ -1,3 +1,5 @@
# Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
# Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files.
from django.urls import path
from django.views.generic.base import RedirectView
from netbox.views.generic import ObjectChangeLogView
+4 -3
View File
@@ -1,3 +1,5 @@
# Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
# Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files.
from dataclasses import dataclass
from functools import lru_cache
from pathlib import Path
@@ -12,7 +14,6 @@ from django.db.models import Model
from django.templatetags.static import static
from django.utils.text import camel_case_to_spaces, re_camel_case
from django.contrib import messages
from django.utils.translation import gettext as _
IMAGE_DIR = Path(settings.STATIC_ROOT) / "netbox_topology_views/img"
if sys.version_info >= (3,9,0):
@@ -118,7 +119,7 @@ def get_query_settings(request):
# General options overrides
if save_coords == True and settings.PLUGINS_CONFIG["netbox_topology_views"]["allow_coordinates_saving"] == False:
save_coords = False
messages.warning(request, _("Coordinate saving not allowed. Setting has been overridden"))
messages.warning(request, "Coordinate saving not allowed. Setting has been overridden")
elif settings.PLUGINS_CONFIG["netbox_topology_views"]["always_save_coordinates"] == True:
save_coords = True
@@ -344,7 +345,7 @@ def export_data_to_xml(data: dict):
if noPositionX > 0:
mxcell = doc.createElement('mxCell')
mxcell.setAttribute('id', 'noPositionWarning')
mxcell.setAttribute('value', _('One or more icons are misplaced. This happens if no coordinates are stored for a device. Turn on coordinates saving and make sure to drag all icons in the topology to a specific position before exporting to XML.'))
mxcell.setAttribute('value', 'One or more icons are misplaced. This happens if no coordinates are stored for a device. Turn on coordinates saving and make sure to drag all icons in the topology to a specific position before exporting to XML.')
mxcell.setAttribute('style', 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#FF0000;fontStyle=0;fontSize=35;labelBackgroundColor=#FFFF99;labelBorderColor=none;strokeWidth=20;')
mxcell.setAttribute('vertex', '1')
mxcell.setAttribute('parent', '1')
+38 -55
View File
@@ -1,3 +1,5 @@
# Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
# Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files.
import json
from functools import reduce
from typing import DefaultDict, Dict, Optional, Union
@@ -26,7 +28,6 @@ from django.db.models import Q, QuerySet, Count
from django.db.models.functions import Lower
from django.http import HttpRequest, HttpResponseRedirect, QueryDict
from django.shortcuts import render, get_object_or_404
from django.utils.translation import gettext as _
from django.views.generic import View
from extras.models import Tag, SavedFilter
from wireless.models import WirelessLAN, WirelessLink
@@ -113,20 +114,20 @@ def create_node(
if device.provider is not None:
node_content += (
f"<tr><th>{_('Provider')}: </th><td>{device.provider.name}</td></tr>"
f"<tr><th>Provider: </th><td>{device.provider.name}</td></tr>"
)
if device.type is not None:
node_content += f"<tr><th>{_('Type')}: </th><td>{device.type.name}</td></tr>"
node_content += f"<tr><th>Type: </th><td>{device.type.name}</td></tr>"
elif isinstance(device, PowerPanel):
dev_name = device.name
node["id"] = f"p{device.pk}"
model_name = 'PowerPanelCoordinate'
if device.site is not None:
node_content += f"<tr><th>{_('Site')}: </th><td>{device.site.name}</td></tr>"
node_content += f"<tr><th>Site: </th><td>{device.site.name}</td></tr>"
if device.location is not None:
node_content += (
f"<tr><th>{_('Location')}: </th><td>{device.location.name}</td></tr>"
f"<tr><th>Location: </th><td>{device.location.name}</td></tr>"
)
elif isinstance(device, PowerFeed):
dev_name = device.name
@@ -135,18 +136,18 @@ def create_node(
if device.power_panel is not None:
node_content += (
f"<tr><th>{_('Power Panel')}: </th><td>{device.power_panel.name}</td></tr>"
f"<tr><th>Power Panel: </th><td>{device.power_panel.name}</td></tr>"
)
if device.type is not None:
node_content += f"<tr><th>{_('Type')}: </th><td>{device.type}</td></tr>"
node_content += f"<tr><th>Type: </th><td>{device.type}</td></tr>"
if device.supply is not None:
node_content += f"<tr><th>{_('Supply')}: </th><td>{device.supply}</td></tr>"
node_content += f"<tr><th>Supply: </th><td>{device.supply}</td></tr>"
if device.phase is not None:
node_content += f"<tr><th>{_('Phase')}: </th><td>{device.phase}</td></tr>"
node_content += f"<tr><th>Phase: </th><td>{device.phase}</td></tr>"
if device.amperage is not None:
node_content += f"<tr><th>{_('Amperage')}: </th><td>{device.amperage}</td></tr>"
node_content += f"<tr><th>Amperage: </th><td>{device.amperage}</td></tr>"
if device.voltage is not None:
node_content += f"<tr><th>{_('Voltage')}: </th><td>{device.voltage}</td></tr>"
node_content += f"<tr><th>Voltage: </th><td>{device.voltage}</td></tr>"
else:
model_name = 'Coordinate'
dev_name = device.name
@@ -155,32 +156,32 @@ def create_node(
if device.device_type is not None:
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.role.name is not None:
node_content += (
f"<tr><th>{_('Role')}: </th><td>{device.role.name}</td></tr>"
f"<tr><th>Role: </th><td>{device.role.name}</td></tr>"
)
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>"
if device.primary_ip is not None:
node_content += (
f"<tr><th>{_('IP Address')}: </th><td>{device.primary_ip.address}</td></tr>"
f"<tr><th>IP Address: </th><td>{device.primary_ip.address}</td></tr>"
)
if device.site is not None:
node_content += f"<tr><th>{_('Site')}: </th><td>{device.site.name}</td></tr>"
node_content += f"<tr><th>Site: </th><td>{device.site.name}</td></tr>"
if device.location is not None:
node_content += (
f"<tr><th>{_('Location')}: </th><td>{device.location.name}</td></tr>"
f"<tr><th>Location: </th><td>{device.location.name}</td></tr>"
)
if device.rack is not None:
node_content += f"<tr><th>{_('Rack')}: </th><td>{device.rack.name}</td></tr>"
node_content += f"<tr><th>Rack: </th><td>{device.rack.name}</td></tr>"
if device.position is not None:
if device.face is not None:
node_content += f"<tr><th>{_('Position')}: </th><td>{device.position} ({device.face})</td></tr>"
node_content += f"<tr><th>Position: </th><td>{device.position} ({device.face})</td></tr>"
else:
node_content += (
f"<tr><th>{_('Position')}: </th><td>{device.position}</td></tr>"
f"<tr><th>Position: </th><td>{device.position}</td></tr>"
)
node["id"] = device.pk
@@ -283,22 +284,22 @@ def create_edge(
interface: Optional[Interface] = None,
):
cable_a_name = (
_("termination A name unknown")
"device A name unknown"
if termination_a["termination_name"] is None
else termination_a["termination_name"]
)
cable_a_dev_name = (
_("device A name unknown")
"device A name unknown"
if termination_a["termination_device_name"] is None
else termination_a["termination_device_name"]
)
cable_b_name = (
_("termination B name unknown")
"device A name unknown"
if termination_b["termination_name"] is None
else termination_b["termination_name"]
)
cable_b_dev_name = (
_("device B name unknown")
"cable B name unknown"
if termination_b["termination_device_name"] is None
else termination_b["termination_device_name"]
)
@@ -308,29 +309,29 @@ def create_edge(
edge["from"] = termination_a["device_id"]
edge["to"] = termination_b["device_id"]
edge["color"] = '#2b7ce9'
title = _("Cable")
title = "Cable"
if circuit is not None:
edge["dashes"] = True
title = _("Circuit provider: %(provider)s<br>Termination") % {"provider": circuit['provider_name']}
title = f"Circuit provider: {circuit['provider_name']}<br>Termination"
elif wireless is not None:
edge["dashes"] = LinePattern().wireless
title = _("Wireless Connection")
title = "Wireless Connection"
elif power is not None:
edge["dashes"] = LinePattern().power
title = _("Power Connection")
title = "Power Connection"
elif interface is not None:
title = _("Interface Connection")
title = "Interface Connection"
edge["width"] = 3
edge["dashes"] = LinePattern().logical
edge["color"] = '#f1c232'
edge["href"] = interface.get_absolute_url() + "trace"
if cable is not None and hasattr(cable, "label") and cable.label:
cable_label = "<br>" + _("Label: %(label)s") % {"label": cable.label}
cable_label = "<br>Label: " + cable.label
if draw_cable_labels is True:
edge["label"] = cable.label
else:
@@ -338,13 +339,7 @@ def create_edge(
edge[
"title"
] = _("%(title)s between<br>%(device_a)s [%(termination_a)s]<br>%(device_b)s [%(termination_b)s]") % {
"title": title,
"device_a": cable_a_dev_name,
"termination_a": cable_a_name,
"device_b": cable_b_dev_name,
"termination_b": cable_b_name,
} + f" {cable_label}"
] = f"{title} between<br>{cable_a_dev_name} [{cable_a_name}]<br>{cable_b_dev_name} [{cable_b_name}] {cable_label}"
if cable is not None:
edge["href"] = cable.get_absolute_url()
@@ -929,10 +924,10 @@ def _rack_endpoint(termination):
return {
"node_id": f"device-{device.pk}" if device else f"external-{termination._meta.model_name}-{termination.pk}",
"device_id": getattr(device, "pk", None),
"device_name": getattr(device, "name", None) or _("External"),
"device_name": getattr(device, "name", None) or "External",
"name": getattr(termination, "name", str(termination)),
"rack_id": getattr(device, "rack_id", None),
"rack_name": getattr(getattr(device, "rack", None), "name", None) or _("External"),
"rack_name": getattr(getattr(device, "rack", None), "name", None) or "Extern",
"url": device.get_absolute_url() if device else None,
"color": getattr(getattr(device, "role", None), "color", None) or "1685fc",
"position": float(device.position or 1) if device else None,
@@ -1083,8 +1078,8 @@ class RackElevationView(PermissionRequiredMixin, View):
topology_nodes[wlan_node_id] = {
"node_id": wlan_node_id, "device_id": None,
"device_name": f"WLAN · {wireless_lan.ssid}",
"name": wireless_lan.ssid, "subtitle": _("Multi-Access WLAN"),
"rack_id": None, "rack_name": _("Wireless networks"),
"name": wireless_lan.ssid, "subtitle": "Multi-Access WLAN",
"rack_id": None, "rack_name": "Funknetze",
"url": wireless_lan.get_absolute_url(), "color": "8b5cf6",
"position": None, "height": 1, "face": "front", "rack_u_height": None,
"kind": "wireless-lan",
@@ -1109,20 +1104,8 @@ class RackElevationView(PermissionRequiredMixin, View):
"racks": rack_list, "cables": cable_rows,
"rack_topology": {"nodes": list(topology_nodes.values()), "edges": topology_edges},
"rack_export": rack_export,
"faces": (("front", _("Front")), ("rear", _("Rear"))),
"faces": (("front", "Vorderseite"), ("rear", "Rückseite")),
"has_selection": bool(request.GET),
# Labels for the inline script, which cannot use template tags
"i18n": {
"external": _("External"),
"power": _("Power"),
"connections": _("Connections"),
"noConnections": _("No connections"),
"fullScreen": _("Full screen"),
"exitFullScreen": _("Exit full screen"),
"device": _("Device"),
"front": _("Front"),
"rear": _("Rear"),
},
})
@@ -1419,7 +1402,7 @@ class TopologyIndividualOptionsView(PermissionRequiredMixin, View):
form = IndividualOptionsForm(request.POST, instance=instance)
if form.is_valid():
form.save()
messages.success(request, _("Options have been successfully saved"))
messages.success(request, "Options have been sucessfully saved")
else:
messages.error(request, form.errors)
+7 -3
View File
@@ -1,3 +1,5 @@
# Modified by MrBlake for the MRB NetBox Topology Views fork: https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views
# Based on mattieserver/netbox-topology-views (Apache License 2.0). See the LICENSE and NOTICE files.
from pathlib import Path
from setuptools import find_packages, setup
@@ -11,9 +13,10 @@ setup(
description="A NetBox plugin to create Topology maps",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/mattieserver/netbox-topology-views",
url="https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views",
author="Mattijs Vanhaverbeke",
license="Apache 2.0",
maintainer="MrBlake",
license="Apache-2.0",
install_requires=[],
packages=find_packages(),
include_package_data=True,
@@ -24,6 +27,7 @@ setup(
"Programming Language :: Python :: 3 :: Only",
],
project_urls={
"Source": "https://github.com/mattieserver/netbox-topology-views",
"Source": "https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views",
"Upstream": "https://github.com/mattieserver/netbox-topology-views",
},
)
-37
View File
@@ -1,37 +0,0 @@
"""Keeps the NetBox range in README.md in sync with the PluginConfig."""
import ast
import re
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def plugin_versions():
tree = ast.parse((ROOT / "netbox_topology_views" / "__init__.py").read_text())
values = {}
for node in ast.walk(tree):
if isinstance(node, ast.Assign) and isinstance(node.value, ast.Constant):
for target in node.targets:
if isinstance(target, ast.Name) and target.id in ("min_version", "max_version"):
values[target.id] = node.value.value
return values["min_version"], values["max_version"]
def expected_range(min_version, max_version):
upper = re.sub(r"\.99$", ".x", max_version)
if min_version.endswith(".0") and upper == min_version[:-2] + ".x":
return f"`{upper}`"
return f"`{min_version}` – `{upper}`"
class MetadataTest(unittest.TestCase):
def test_readme_matches_plugin_config(self):
readme = (ROOT / "README.md").read_text()
expected = expected_range(*plugin_versions())
self.assertIn(f"| **NetBox** | {expected} |", readme)
self.assertIn(f"- NetBox {expected}", readme)
if __name__ == "__main__":
unittest.main()