Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adfcc802c2 | ||
|
|
133cb1d9fc | ||
|
|
e4d1383e8c | ||
|
|
ffe594a5f9 | ||
|
|
4a12037ac4 | ||
|
|
f08df4fd52 | ||
|
|
2e43166949 | ||
|
|
86a8daf45e | ||
|
|
f706db754c | ||
|
|
c49270fab0 | ||
|
|
6ff2b60bb4 | ||
|
|
ef1ad4d607 | ||
|
|
a1d28e922d | ||
|
|
d9d2e4dd59 |
No files matched your search
@@ -1,3 +1,5 @@
|
||||
include LICENSE
|
||||
include NOTICE
|
||||
recursive-include netbox_topology_views/static *
|
||||
recursive-include netbox_topology_views/templates *
|
||||
recursive-include netbox_topology_views/api *
|
||||
|
||||
@@ -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.
|
||||
@@ -1,90 +1,111 @@
|
||||
# MRB NetBox Topology Views
|
||||
|
||||
Ein angepasster Fork von **NetBox Topology Views** mit erweiterten Rack-Ansichten,
|
||||
interaktiver Kabelverfolgung und zusätzlichen Netzwerk-Icons.
|
||||
A customised fork of **NetBox Topology Views** with extended rack views,
|
||||
interactive cable tracing and additional network icons.
|
||||
|
||||
Das Plugin erzeugt Topologien aus den in NetBox gepflegten Geräten, Ports und
|
||||
Kabeln. Neben der klassischen Topologie bietet dieser Fork eine vollständige
|
||||
Darstellung einzelner oder mehrerer Racks einschließlich Vorderseite,
|
||||
Rückseite und Verkabelung.
|
||||
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.
|
||||
|
||||
## Vorteile dieses Forks
|
||||
> **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).
|
||||
|
||||
- Ein oder mehrere Racks gemeinsam anzeigen
|
||||
- Geräte positionsgenau anhand ihrer Höheneinheiten darstellen
|
||||
- Vorder- und Rückseite eines Racks getrennt betrachten
|
||||
- Rackübergreifende und externe Kabelverbindungen erkennen
|
||||
- Geräte in der Kabeltopologie frei verschieben
|
||||
- Geräte in der Kabeltopologie innerhalb jedes Racks nach ihrer Rackposition sortieren
|
||||
- Kabeltopologie in den Browser-Vollbildmodus schalten
|
||||
- Kabeltopologie zwischen 50 und 200 Prozent zoomen und im Vollbild scrollen
|
||||
- Geräte in der Kabeltopologie mit rund 5 mm Abstand darstellen
|
||||
- P2P-WirelessLinks und Multi-Access-WLANs als violette, gestrichelte Funkstrecken darstellen
|
||||
- Manuelle Positionen pro Rack-Auswahl im Browser speichern
|
||||
- Verbindungen eines Geräts beim Hover weiß hervorheben
|
||||
- Alle verbundenen Ports und Gegenstellen eines Geräts anzeigen
|
||||
- Schnittstellen eines Kabels beim Hover anzeigen
|
||||
- Geräte und Kabel direkt aus der Topologie in NetBox öffnen
|
||||
- Einzelne Racks, alle Racks oder die Kabeltopologie als SVG, PNG und draw.io exportieren
|
||||
- Exporte grundsätzlich mit transparentem Hintergrund erzeugen
|
||||
- Farben von Rackansicht und Export an den aktiven Light- oder Dark-Mode anpassen
|
||||
- Topologie als PNG oder diagrams.net/draw.io-XML exportieren
|
||||
- Zusätzliche Icons für Network-, Leaf-, Spine- und Aggregation-Switche
|
||||
- Unterstützung für helle und dunkle NetBox-Themes
|
||||
| | |
|
||||
|---|---|
|
||||
| **Plugin name** | `netbox_topology_views` |
|
||||
| **Package** | `netbox-topology-views` |
|
||||
| **NetBox** | `4.7.x` |
|
||||
| **Python** | see `setup.py` |
|
||||
| **Repository** | <https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views> |
|
||||
|
||||
## Änderungen gegenüber dem Original
|
||||
## Screenshots
|
||||
|
||||
Dieser Fork ergänzt insbesondere:
|
||||
Cable topology of a site, arranged with a coordinate group:
|
||||
|
||||
1. Die neue Menükategorie **Weitere Ansichten**.
|
||||
2. Eine Rack-Ansicht mit Filtern für Site, Location und mehrere Racks.
|
||||
3. Positionsgenaue Rack-Elevations für Vorder- und Rückseite.
|
||||
4. Eine Kabeltabelle mit A- und B-Terminierungen.
|
||||
5. Eine interaktive, verschiebbare Kabeltopologie unter den Racks.
|
||||
6. Hover-Hervorhebung und Port-zu-Port-Verfolgung für Geräte und Kabel.
|
||||
7. Lokal gespeicherte Gerätepositionen und eine Funktion zum Zurücksetzen.
|
||||
8. Ein erweitertes, skalierbares SVG-Iconset für Switch-Rollen.
|
||||
9. Transparente SVG-, PNG- und draw.io-Exporte für Rack- und Topologieansichten.
|
||||
10. Anpassungen für die Verwendung mit NetBox 4.6, darunter die geänderte
|
||||
`Rack.units`-Property.
|
||||

|
||||
|
||||
## Vorschau
|
||||
Rack view with front and rear elevations:
|
||||
|
||||
Die klassische Topologieansicht stammt aus dem ursprünglichen Plugin:
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
- Show one or more racks together
|
||||
- Render devices at their exact rack unit position
|
||||
- View front and rear of a rack separately
|
||||
- Ascending/descending U numbering and custom starting unit are respected automatically
|
||||
- Detect cross-rack and external cable connections
|
||||
- Freely move devices in the cable topology
|
||||
- Sort devices in the cable topology by rack position within each rack
|
||||
- Browser full-screen mode for the cable topology
|
||||
- Zoom the cable topology between 50 and 200 % and scroll in full-screen
|
||||
- Render P2P wireless links and multi-access WLANs as purple dashed radio links
|
||||
- Optionally show/hide wireless links and power cables in the rack view's cable topology, visually distinct from network cables (purple dashed / orange dotted)
|
||||
- Store manual positions per rack selection in the browser
|
||||
- Highlight a device's connections in white on hover
|
||||
- Show all connected ports and peers of a device
|
||||
- Show a cable's terminations on hover
|
||||
- Open devices and cables in NetBox directly from the topology
|
||||
- Export single racks, all racks or the cable topology as SVG, PNG and draw.io — always with transparent background
|
||||
- Colours of rack view and export follow the active light or dark mode
|
||||
- Additional icons for network, leaf, spine and aggregation switches
|
||||
|
||||
### Changes compared to the original
|
||||
|
||||
1. New menu category **More views**.
|
||||
2. A rack view with filters for site, location and multiple racks.
|
||||
3. Position-accurate rack elevations for front and rear.
|
||||
4. A cable table with A and B terminations.
|
||||
5. An interactive, movable cable topology below the racks.
|
||||
6. Hover highlighting and port-to-port tracing for devices and cables.
|
||||
7. Locally stored device positions and a reset function.
|
||||
8. An extended, scalable SVG icon set for switch roles.
|
||||
9. Transparent SVG, PNG and draw.io exports for rack and topology views.
|
||||
10. Adjustments for NetBox 4.6+, including the changed `Rack.units` property.
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation aus Gitea
|
||||
## Compatibility
|
||||
|
||||
Das Plugin kann direkt aus dem `develop`-Branch installiert werden:
|
||||
- NetBox `4.7.x` (`min_version`/`max_version` in `netbox_topology_views/__init__.py`)
|
||||
- Based on NetBox Topology Views `4.5.1`
|
||||
|
||||
Since the upstream release officially targets NetBox 4.5.x, test updates to
|
||||
newer NetBox versions in a staging instance first.
|
||||
|
||||
## Installation
|
||||
|
||||
All paths assume a standard installation under `/opt/netbox`.
|
||||
|
||||
### 1. Install the package
|
||||
|
||||
```bash
|
||||
/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \
|
||||
"git+https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views.git@develop"
|
||||
```
|
||||
|
||||
Für eine reproduzierbare Produktivinstallation sollte statt `develop` ein
|
||||
Release-Tag oder ein bestimmter Commit verwendet werden:
|
||||
For reproducible production installs, replace `develop` with a release tag or a
|
||||
full commit ID.
|
||||
|
||||
### 2. Add the plugin to `local_requirements.txt`
|
||||
|
||||
This makes `upgrade.sh` reinstall the plugin automatically on every NetBox upgrade:
|
||||
|
||||
```bash
|
||||
/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \
|
||||
"git+https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views.git@v4.5.1-mrb.1"
|
||||
grep -qxF "git+https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views.git@develop" /opt/netbox/local_requirements.txt \
|
||||
|| echo "git+https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views.git@develop" | sudo tee -a /opt/netbox/local_requirements.txt
|
||||
```
|
||||
|
||||
Für automatische Neuinstallationen bei einem NetBox-Upgrade wird derselbe
|
||||
Eintrag in `/opt/netbox/local_requirements.txt` hinterlegt:
|
||||
If the repository is private, the NetBox server needs a read-only deploy token
|
||||
or an SSH key. Do not store credentials in `local_requirements.txt`.
|
||||
|
||||
```text
|
||||
git+https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views.git@develop
|
||||
```
|
||||
### 3. Enable the plugin
|
||||
|
||||
Bei einem privaten Gitea-Repository muss der NetBox-Server Zugriff über einen
|
||||
Deploy-Token oder SSH-Key erhalten.
|
||||
|
||||
## NetBox-Konfiguration
|
||||
|
||||
In `netbox/configuration.py` wird das Python-Paket aktiviert:
|
||||
In `/opt/netbox/netbox/netbox/configuration.py`:
|
||||
|
||||
```python
|
||||
PLUGINS = [
|
||||
@@ -100,134 +121,136 @@ PLUGINS_CONFIG = {
|
||||
}
|
||||
```
|
||||
|
||||
Danach werden Migrationen und statische Dateien verarbeitet:
|
||||
If other plugins are already configured, add `netbox_topology_views` to the
|
||||
existing list and dictionary instead of replacing them.
|
||||
|
||||
### 4. Apply migrations, collect static files, restart
|
||||
|
||||
```bash
|
||||
cd /opt/netbox/netbox
|
||||
/opt/netbox/venv/bin/python manage.py migrate
|
||||
/opt/netbox/venv/bin/python manage.py migrate netbox_topology_views
|
||||
/opt/netbox/venv/bin/python manage.py collectstatic --no-input
|
||||
sudo systemctl restart netbox netbox-rq
|
||||
```
|
||||
|
||||
Nach Änderungen an CSS oder Icons kann ein Hard-Reload des Browsers mit
|
||||
`Strg+F5` erforderlich sein.
|
||||
After changes to CSS or icons a hard reload in the browser (`Ctrl+F5`) may be
|
||||
necessary.
|
||||
|
||||
## Aktualisierung
|
||||
## Update
|
||||
|
||||
```bash
|
||||
/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \
|
||||
"git+https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views.git@develop"
|
||||
|
||||
cd /opt/netbox/netbox
|
||||
/opt/netbox/venv/bin/python manage.py migrate
|
||||
/opt/netbox/venv/bin/python manage.py migrate netbox_topology_views
|
||||
/opt/netbox/venv/bin/python manage.py collectstatic --no-input
|
||||
sudo systemctl restart netbox netbox-rq
|
||||
```
|
||||
|
||||
`--force-reinstall` ist derzeit sinnvoll, da der Fork intern noch die
|
||||
Paketversion `4.5.1` verwendet.
|
||||
`--force-reinstall` is required because the fork still uses the internal
|
||||
package version `4.5.2`.
|
||||
|
||||
## Verwendung
|
||||
When NetBox itself is upgraded, `upgrade.sh` reinstalls the plugin from
|
||||
`local_requirements.txt` and runs migrations and `collectstatic`:
|
||||
|
||||
### Klassische Topologie
|
||||
```bash
|
||||
sudo /opt/netbox/upgrade.sh
|
||||
sudo systemctl restart netbox netbox-rq
|
||||
```
|
||||
|
||||
Unter **Plugins → Topology Views → Topology** steht die ursprüngliche,
|
||||
filterbare Topologieansicht zur Verfügung. Sie unterstützt unter anderem:
|
||||
## Uninstall
|
||||
|
||||
- physische Kabel
|
||||
- logische Verbindungen
|
||||
- Nachbargeräte
|
||||
- Circuit-Terminations
|
||||
- Power Feeds
|
||||
- Wireless Links
|
||||
- Coordinate Groups
|
||||
- PNG- und XML-Export
|
||||
1. Remove `"netbox_topology_views"` from `PLUGINS` and `PLUGINS_CONFIG`.
|
||||
2. Remove the line from `/opt/netbox/local_requirements.txt`.
|
||||
3. Uninstall the package and restart NetBox:
|
||||
|
||||
### Rack-Ansicht
|
||||
```bash
|
||||
/opt/netbox/venv/bin/pip uninstall netbox-topology-views
|
||||
sudo systemctl restart netbox netbox-rq
|
||||
```
|
||||
|
||||
Die erweiterte Ansicht befindet sich unter:
|
||||
## Usage
|
||||
|
||||
**Plugins → Topology Views → Weitere Ansichten → Rack-Ansicht**
|
||||
### Classic topology
|
||||
|
||||
Über Site, Location und Rack können ein einzelnes Rack oder mehrere Racks
|
||||
ausgewählt werden. Optional lassen sich auch leere Racks einblenden.
|
||||
**Plugins → Topology Views → Topology** provides the original, filterable
|
||||
topology view. It supports physical cables, logical connections, neighbour
|
||||
devices, circuit terminations, power feeds, wireless links, coordinate groups,
|
||||
and PNG and XML export.
|
||||
|
||||
In der Elevation werden Geräte entsprechend ihrer Position, Gerätehöhe und
|
||||
Rack-Seite dargestellt. Unter den Elevations folgen:
|
||||
### Rack view
|
||||
|
||||
1. die interaktive Kabeltopologie und
|
||||
2. eine tabellarische Übersicht sämtlicher betroffener Kabel.
|
||||
**Plugins → Topology Views → More views → Rack view**
|
||||
|
||||
In der Kabeltopologie können Geräte per Drag-and-drop verschoben werden. Beim
|
||||
Hover über ein Gerät werden dessen Kabel hervorgehoben und alle verbundenen
|
||||
Ports aufgelistet. Beim Hover über ein Kabel erscheinen beide Terminierungen.
|
||||
Ein Klick öffnet das jeweilige NetBox-Objekt.
|
||||
Select a single rack or several racks via site, location and rack; empty racks
|
||||
can be shown optionally. Devices are rendered according to position, height and
|
||||
rack face. Below the elevations follow:
|
||||
|
||||
Über die Export-Schaltflächen können ein einzelnes Rack, alle aktuell
|
||||
angezeigten Racks oder die interaktive Kabeltopologie als SVG, PNG oder
|
||||
draw.io-Datei gespeichert werden. Sämtliche Exportformate werden ohne
|
||||
Hintergrundfläche erzeugt. Im draw.io-Export bleiben Rack-Rahmen, Geräte und
|
||||
Beschriftungen als einzelne Elemente bearbeitbar. Topologiekabel werden als
|
||||
echte Kanten exportiert und folgen den Geräten beim Verschieben in draw.io.
|
||||
1. the interactive cable topology, and
|
||||
2. a table of all involved cables.
|
||||
|
||||
Die Positionen werden im `localStorage` des Browsers gespeichert. Sie gelten
|
||||
damit nur für den jeweiligen Browser und die konkrete Rack-/Filterauswahl.
|
||||
In the cable topology, devices can be moved via drag and drop. Hovering a device
|
||||
highlights its cables and lists all connected ports; hovering a cable shows both
|
||||
terminations. A click opens the NetBox object.
|
||||
|
||||
## Geräte-Icons
|
||||
The export buttons save a single rack, all displayed racks or the cable topology
|
||||
as SVG, PNG or draw.io, always without background. In the draw.io export, rack
|
||||
frames, devices and labels remain individually editable, and topology cables are
|
||||
real edges that follow the devices.
|
||||
|
||||
Das Plugin ordnet Icons anhand des Slugs einer Device Role zu. Dieser Fork
|
||||
liefert zusätzlich folgende SVG-Dateien aus:
|
||||
Positions are stored in the browser's `localStorage` and apply only to that
|
||||
browser and the specific rack/filter selection.
|
||||
|
||||
| Device-Role-Slug | Icon-Datei |
|
||||
With [Netbox-Utilities](https://git.mrblake.cc/MrBlake/Netbox-Utilities)
|
||||
installed, partial-width devices are rendered side by side in the rack view.
|
||||
|
||||
## Device icons
|
||||
|
||||
Icons are assigned by device role slug. This fork additionally ships:
|
||||
|
||||
| Device role slug | Icon file |
|
||||
| --- | --- |
|
||||
| `network-switch` | `network-switch.svg` |
|
||||
| `leaf-switch` | `leaf-switch.svg` |
|
||||
| `spine-switch` | `spine-switch.svg` |
|
||||
| `aggregation-switch` | `aggregation-switch.svg` |
|
||||
|
||||
Eigene Bilder können weiterhin über die Seite **Images** zugeordnet werden.
|
||||
Der Standardpfad lautet `netbox_topology_views/img` innerhalb von
|
||||
`STATIC_ROOT`.
|
||||
Custom images can still be assigned on the **Images** page. The default path is
|
||||
`netbox_topology_views/img` within `STATIC_ROOT`.
|
||||
|
||||
## Berechtigungen
|
||||
## Permissions
|
||||
|
||||
Für die klassische Topologie werden mindestens folgende Rechte benötigt:
|
||||
Classic topology: `dcim.view_site`, `dcim.view_device`.
|
||||
|
||||
- `dcim.view_site`
|
||||
- `dcim.view_device`
|
||||
Rack view: `dcim.view_rack`, `dcim.view_device`, `dcim.view_cable`.
|
||||
|
||||
Für die Rack-Ansicht werden benötigt:
|
||||
Saving classic topology coordinates additionally requires the corresponding
|
||||
permissions on `netbox_topology_views.coordinate`.
|
||||
|
||||
- `dcim.view_rack`
|
||||
- `dcim.view_device`
|
||||
- `dcim.view_cable`
|
||||
## Origin, credits and licenses
|
||||
|
||||
Für das Speichern klassischer Topologiekoordinaten werden zusätzlich die
|
||||
entsprechenden Rechte auf `netbox_topology_views.coordinate` benötigt.
|
||||
**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).
|
||||
|
||||
## Kompatibilität
|
||||
**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.
|
||||
|
||||
Die Basis dieses Forks ist NetBox Topology Views `4.5.1`. Die neuen
|
||||
Rack-Funktionen wurden für den Einsatz mit NetBox `4.6.5` angepasst. Da das
|
||||
ursprüngliche Release offiziell für NetBox 4.5.x ausgewiesen ist, sollten
|
||||
Updates auf neuere NetBox-Versionen zunächst in einer Testumgebung geprüft
|
||||
werden.
|
||||
**Licenses:**
|
||||
|
||||
## Ursprung und Danksagung
|
||||
| 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 |
|
||||
|
||||
Dieses Projekt ist ein Fork des Open-Source-Plugins
|
||||
[NetBox Topology Views](https://github.com/mattieserver/netbox-topology-views).
|
||||
|
||||
Das ursprüngliche Plugin wurde von **Mattijs Vanhaverbeke** erstellt. Der
|
||||
größte Teil der klassischen Topologieansicht, Datenmodelle, Filter und
|
||||
Exportfunktionen basiert auf seiner Arbeit und den Beiträgen des ursprünglichen
|
||||
Projekts.
|
||||
|
||||
Dieser Fork wird unabhängig weiterentwickelt und ist nicht mit dem
|
||||
ursprünglichen Autor oder dem NetBox-Projekt offiziell verbunden.
|
||||
|
||||
## Lizenz
|
||||
|
||||
Das Projekt steht wie das Original unter der
|
||||
[Apache License 2.0](LICENSE). Bestehende Copyright-, Lizenz- und
|
||||
Urheberhinweise des ursprünglichen Projekts bleiben erhalten.
|
||||
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.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 123 KiB |
@@ -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 netbox.plugins import PluginConfig
|
||||
|
||||
|
||||
@@ -5,10 +7,11 @@ class TopologyViewsConfig(PluginConfig):
|
||||
name = "netbox_topology_views"
|
||||
verbose_name = "Topology views"
|
||||
description = "A plugin to render topology maps"
|
||||
version = "4.5.1"
|
||||
author = "Mattijs Vanhaverbeke & LKE"
|
||||
author_email = "[email protected]"
|
||||
version = "4.5.2"
|
||||
author = "Mattijs Vanhaverbeke (original), MrBlake (fork)"
|
||||
base_url = "netbox_topology_views"
|
||||
min_version = "4.7.0"
|
||||
max_version = "4.7.99"
|
||||
required_settings = []
|
||||
default_settings = {
|
||||
"static_image_directory": "netbox_topology_views/img",
|
||||
|
||||
@@ -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 cProfile import label
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
|
||||
@@ -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 netbox.plugins import PluginMenu, PluginMenuItem, PluginMenuButton
|
||||
|
||||
coordinategroup_buttons = (
|
||||
|
||||
@@ -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}}
|
||||
@@ -66,7 +66,7 @@ html[data-netbox-color-mode="dark"] .rack-device {
|
||||
width: 15rem;
|
||||
}
|
||||
.rack-topology-column h4 { text-align: center; font-size: .85rem; }
|
||||
.rack-topology-device-list { display: flex; flex-direction: column; gap: 20px; }
|
||||
.rack-topology-device-list { display: flex; flex-direction: column; gap: 40px; }
|
||||
.rack-topology-node {
|
||||
display: block;
|
||||
padding: .55rem .75rem;
|
||||
@@ -100,22 +100,20 @@ html[data-netbox-color-mode="dark"] .rack-device {
|
||||
transition: opacity .12s, stroke .12s, filter .12s, stroke-width .12s;
|
||||
}
|
||||
.rack-topology-edge.is-highlighted {
|
||||
stroke: #22c55e !important;
|
||||
stroke: var(--topology-highlight-color, #16a34a) !important;
|
||||
stroke-width: 5;
|
||||
opacity: 1;
|
||||
filter: drop-shadow(0 0 5px #22c55e);
|
||||
filter: drop-shadow(0 0 5px var(--topology-highlight-color, #16a34a));
|
||||
}
|
||||
.rack-topology-edge.is-dimmed { opacity: .12; }
|
||||
html[data-bs-theme="dark"] .rack-topology-edge.is-highlighted,
|
||||
body[data-bs-theme="dark"] .rack-topology-edge.is-highlighted,
|
||||
html[data-netbox-color-mode="dark"] .rack-topology-edge.is-highlighted {
|
||||
stroke: #fff !important;
|
||||
filter: drop-shadow(0 0 5px #fff);
|
||||
}
|
||||
.rack-topology-edge.is-wireless {
|
||||
stroke-dasharray: 7 7;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
.rack-topology-edge.is-power {
|
||||
stroke-dasharray: 2 4;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
#rack-topology-card:fullscreen {
|
||||
margin: 0 !important;
|
||||
border: 0;
|
||||
@@ -152,3 +150,10 @@ html[data-netbox-color-mode="dark"] .rack-topology-edge.is-highlighted {
|
||||
border-top: 1px solid var(--tblr-border-color, #ced4da);
|
||||
}
|
||||
.rack-topology-tooltip small { opacity: .65; }
|
||||
.rack-cable-count {
|
||||
min-width: 2rem;
|
||||
margin-left: .35rem;
|
||||
background-color: #52606d !important;
|
||||
color: #fff !important;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -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
|
||||
@@ -62,7 +64,7 @@ html[data-netbox-color-mode=dark] #visgraph {
|
||||
.rack-topology-node strong, .rack-topology-node small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.rack-topology-node small { opacity: .7; }
|
||||
.rack-topology-edge { fill: none; stroke-width: 3; opacity: .8; pointer-events: stroke; cursor: pointer; transition: opacity .12s, stroke .12s, filter .12s, stroke-width .12s; }
|
||||
.rack-topology-edge.is-highlighted { stroke: #22c55e !important; stroke-width: 5; opacity: 1; filter: drop-shadow(0 0 5px #22c55e); }
|
||||
.rack-topology-edge.is-highlighted { stroke: var(--topology-highlight-color, #16a34a) !important; stroke-width: 5; opacity: 1; filter: drop-shadow(0 0 5px var(--topology-highlight-color, #16a34a)); }
|
||||
.rack-topology-edge.is-dimmed { opacity: .12; }
|
||||
.rack-topology-tooltip { display: none; position: absolute; z-index: 10; width: max-content; max-width: 28rem; padding: .65rem .8rem; border: 1px solid var(--tblr-border-color, #ced4da); border-radius: .35rem; background: var(--tblr-bg-surface, #fff); box-shadow: 0 4px 18px rgba(0,0,0,.25); pointer-events: none; }
|
||||
.rack-topology-tooltip.is-visible { display: block; }
|
||||
@@ -70,13 +72,14 @@ html[data-netbox-color-mode=dark] #visgraph {
|
||||
.rack-topology-tooltip ul { margin: .4rem 0 0; padding: 0; list-style: none; }
|
||||
.rack-topology-tooltip li + li { margin-top: .45rem; padding-top: .45rem; border-top: 1px solid var(--tblr-border-color, #ced4da); }
|
||||
.rack-topology-tooltip small { opacity: .65; }
|
||||
.rack-cable-count { min-width: 2rem; margin-left: .35rem; background-color: #52606d !important; color: #fff !important; text-align: center; }
|
||||
|
||||
.rack-frame {
|
||||
border-color: #718096;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.rack-topology-device-list { display: flex; flex-direction: column; gap: 20px; }
|
||||
.rack-topology-device-list { display: flex; flex-direction: column; gap: 40px; }
|
||||
.rack-topology-edge.is-wireless { stroke-dasharray: 7 7; stroke-linecap: round; }
|
||||
#rack-topology-card:fullscreen { margin: 0 !important; border: 0; border-radius: 0; background: var(--tblr-bg-surface, #fff); display: flex; flex-direction: column; overflow: hidden; }
|
||||
#rack-topology-card:fullscreen .card-body { min-height: 0; flex: 1; overflow: hidden; }
|
||||
@@ -85,7 +88,6 @@ html[data-netbox-color-mode=dark] #visgraph {
|
||||
html[data-bs-theme="dark"], body[data-bs-theme="dark"], html[data-netbox-color-mode="dark"] {
|
||||
.rack-frame { border-color: #3b4654; background-color: #212b36; }
|
||||
.rack-device { background: #162e45; color: #fff; }
|
||||
.rack-topology-edge.is-highlighted { stroke: #fff !important; filter: drop-shadow(0 0 5px #fff); }
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
|
||||
@@ -85,7 +85,17 @@
|
||||
<div id="rack-topology-card" class="card mt-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<strong>Kabeltopologie</strong>
|
||||
<div class="d-flex gap-2">
|
||||
<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">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">Strom</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-sm btn-outline-primary topology-export" data-format="svg">SVG</button>
|
||||
<button class="btn btn-sm btn-outline-primary topology-export" data-format="png">PNG</button>
|
||||
@@ -116,7 +126,7 @@
|
||||
{{ rack_export|json_script:"rack-export-data" }}
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header"><strong>Verkabelung der angezeigten Racks</strong> <span class="badge bg-secondary">{{ 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>Kabel</th><th>A-Seite</th><th>B-Seite</th><th>Typ</th><th>Status</th></tr></thead>
|
||||
@@ -148,6 +158,23 @@
|
||||
if (!root || !source) return;
|
||||
const data = JSON.parse(source.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');
|
||||
const showPowerCheckbox = document.getElementById('rack-topology-show-power');
|
||||
const isEdgeVisible = edge => {
|
||||
if (isWirelessEdge(edge)) return showWirelessCheckbox ? showWirelessCheckbox.checked : true;
|
||||
if (isPowerEdge(edge)) return showPowerCheckbox ? showPowerCheckbox.checked : true;
|
||||
return true;
|
||||
};
|
||||
const applyKindVisibility = () => {
|
||||
const showWireless = showWirelessCheckbox ? showWirelessCheckbox.checked : true;
|
||||
root.querySelectorAll('.rack-topology-node').forEach(node => {
|
||||
if (node.dataset.kind === 'wireless-lan') {
|
||||
node.style.display = showWireless ? '' : 'none';
|
||||
}
|
||||
});
|
||||
drawEdges();
|
||||
};
|
||||
const rackData = JSON.parse(document.getElementById('rack-export-data').textContent);
|
||||
const columns = root.querySelector('.rack-topology-columns');
|
||||
const svg = root.querySelector('svg');
|
||||
@@ -160,7 +187,32 @@
|
||||
const zoomResetButton = document.getElementById('rack-topology-zoom-reset');
|
||||
const zoomLabel = document.getElementById('rack-topology-zoom-label');
|
||||
let topologyZoom = 1;
|
||||
const storageKey = `netbox-rack-topology-v2:${window.location.pathname}${window.location.search}`;
|
||||
const activeNetBoxTheme = () => {
|
||||
for (const element of [topologyCard, document.body, document.documentElement]) {
|
||||
const match = getComputedStyle(element).backgroundColor.match(/[\d.]+/g);
|
||||
if (match && match.length >= 3 && (match.length < 4 || Number(match[3]) > 0)) {
|
||||
const [red, green, blue] = match.map(Number);
|
||||
return (.2126 * red + .7152 * green + .0722 * blue) < 140 ? 'dark' : 'light';
|
||||
}
|
||||
}
|
||||
return document.body.dataset.bsTheme || document.documentElement.dataset.bsTheme || 'light';
|
||||
};
|
||||
const topologyHighlightColor = () => activeNetBoxTheme() === 'dark' ? '#ffffff' : '#16a34a';
|
||||
const applyTopologyTheme = () => {
|
||||
root.style.setProperty('--topology-highlight-color', topologyHighlightColor());
|
||||
root.querySelectorAll('.rack-topology-edge.is-highlighted').forEach(path => {
|
||||
path.style.setProperty('stroke', topologyHighlightColor(), 'important');
|
||||
path.style.setProperty('filter', `drop-shadow(0 0 5px ${topologyHighlightColor()})`, 'important');
|
||||
});
|
||||
};
|
||||
applyTopologyTheme();
|
||||
const topologyThemeObserver = new MutationObserver(() => requestAnimationFrame(applyTopologyTheme));
|
||||
topologyThemeObserver.observe(document.body, {attributes: true, attributeFilter: ['data-bs-theme']});
|
||||
topologyThemeObserver.observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ['data-bs-theme', 'data-netbox-color-mode'],
|
||||
});
|
||||
const storageKey = `netbox-rack-topology-v3:${window.location.pathname}${window.location.search}`;
|
||||
let storedPositions = {};
|
||||
try { storedPositions = JSON.parse(localStorage.getItem(storageKey) || '{}'); } catch (_) {}
|
||||
const groups = new Map();
|
||||
@@ -170,6 +222,7 @@
|
||||
if (!groups.has(groupKey)) groups.set(groupKey, {
|
||||
name: node.rack_name || 'Extern',
|
||||
rackUnits: node.rack_u_height || null,
|
||||
descUnits: Boolean(node.rack_desc_units),
|
||||
nodes: [],
|
||||
});
|
||||
groups.get(groupKey).nodes.push(node);
|
||||
@@ -183,13 +236,21 @@
|
||||
column.appendChild(heading);
|
||||
const nodeContainer = document.createElement('div');
|
||||
nodeContainer.className = 'rack-topology-device-list';
|
||||
nodeContainer.style.display = 'flex';
|
||||
nodeContainer.style.flexDirection = 'column';
|
||||
nodeContainer.style.gap = '20px';
|
||||
nodeContainer.style.rowGap = '20px';
|
||||
column.appendChild(nodeContainer);
|
||||
group.nodes.sort((a, b) => (b.position || 0) - (a.position || 0)).forEach(node => {
|
||||
group.nodes.sort((a, b) => group.descUnits
|
||||
? (a.position || 0) - (b.position || 0)
|
||||
: (b.position || 0) - (a.position || 0)
|
||||
).forEach(node => {
|
||||
const item = document.createElement(node.url ? 'a' : 'div');
|
||||
item.className = 'rack-topology-node';
|
||||
item.id = `topology-${node.node_id}`;
|
||||
item.style.setProperty('--node-color', `#${node.color}`);
|
||||
item.dataset.nodeId = node.node_id;
|
||||
if (node.kind) item.dataset.kind = node.kind;
|
||||
if (node.url) item.href = node.url;
|
||||
const nameElement = document.createElement('strong');
|
||||
nameElement.textContent = node.device_name;
|
||||
@@ -217,6 +278,16 @@
|
||||
element.textContent = value == null ? '—' : String(value);
|
||||
return element.innerHTML;
|
||||
};
|
||||
const setEdgeHighlighted = (path, highlighted) => {
|
||||
path.classList.toggle('is-highlighted', highlighted);
|
||||
if (highlighted) {
|
||||
path.style.setProperty('stroke', topologyHighlightColor(), 'important');
|
||||
path.style.setProperty('filter', `drop-shadow(0 0 5px ${topologyHighlightColor()})`, 'important');
|
||||
} else {
|
||||
path.style.removeProperty('stroke');
|
||||
path.style.removeProperty('filter');
|
||||
}
|
||||
};
|
||||
|
||||
const drawEdges = () => {
|
||||
const bounds = root.getBoundingClientRect();
|
||||
@@ -227,6 +298,7 @@
|
||||
svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
|
||||
svg.replaceChildren();
|
||||
data.edges.forEach(edge => {
|
||||
if (!isEdgeVisible(edge)) return;
|
||||
const from = document.getElementById(`topology-${edge.from}`);
|
||||
const to = document.getElementById(`topology-${edge.to}`);
|
||||
if (!from || !to) return;
|
||||
@@ -241,6 +313,7 @@
|
||||
path.setAttribute('stroke', edge.color);
|
||||
path.classList.add('rack-topology-edge');
|
||||
if (isWirelessEdge(edge)) path.classList.add('is-wireless');
|
||||
if (isPowerEdge(edge)) path.classList.add('is-power');
|
||||
path.dataset.from = edge.from;
|
||||
path.dataset.to = edge.to;
|
||||
const title = document.createElementNS('http://www.w3.org/2000/svg', 'title');
|
||||
@@ -248,42 +321,46 @@
|
||||
path.appendChild(title);
|
||||
if (edge.url) path.addEventListener('click', () => window.location.href = edge.url);
|
||||
path.addEventListener('mouseenter', event => {
|
||||
path.classList.add('is-highlighted');
|
||||
setEdgeHighlighted(path, true);
|
||||
showTooltip(
|
||||
`<strong>${isWirelessEdge(edge) ? 'WLAN · ' : ''}${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
|
||||
);
|
||||
});
|
||||
path.addEventListener('mouseleave', () => {
|
||||
path.classList.remove('is-highlighted');
|
||||
setEdgeHighlighted(path, false);
|
||||
hideTooltip();
|
||||
});
|
||||
svg.appendChild(path);
|
||||
});
|
||||
};
|
||||
|
||||
const connectedEdges = nodeId => data.edges.filter(edge => edge.from === nodeId || edge.to === nodeId);
|
||||
const connectedEdges = nodeId => data.edges.filter(edge => isEdgeVisible(edge) && (edge.from === nodeId || edge.to === nodeId));
|
||||
root.querySelectorAll('.rack-topology-node').forEach(node => {
|
||||
const nodeId = node.dataset.nodeId;
|
||||
node.addEventListener('mouseenter', () => {
|
||||
const connections = connectedEdges(nodeId);
|
||||
svg.querySelectorAll('.rack-topology-edge').forEach(path => {
|
||||
path.classList.toggle('is-highlighted', path.dataset.from === nodeId || path.dataset.to === nodeId);
|
||||
path.classList.toggle('is-dimmed', path.dataset.from !== nodeId && path.dataset.to !== nodeId);
|
||||
const connected = path.dataset.from === nodeId || path.dataset.to === nodeId;
|
||||
setEdgeHighlighted(path, connected);
|
||||
path.classList.toggle('is-dimmed', !connected);
|
||||
});
|
||||
const rows = connections.map(edge => {
|
||||
const outgoing = edge.from === nodeId;
|
||||
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 · ' : ''}${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>Verbindungen (${connections.length})</strong><ul>${rows || '<li>Keine Verbindungen</li>'}</ul>`, node);
|
||||
});
|
||||
node.addEventListener('mouseleave', () => {
|
||||
svg.querySelectorAll('.rack-topology-edge').forEach(path => path.classList.remove('is-highlighted', 'is-dimmed'));
|
||||
svg.querySelectorAll('.rack-topology-edge').forEach(path => {
|
||||
setEdgeHighlighted(path, false);
|
||||
path.classList.remove('is-dimmed');
|
||||
});
|
||||
hideTooltip();
|
||||
});
|
||||
|
||||
@@ -354,9 +431,7 @@
|
||||
})[char]);
|
||||
const safeName = value => String(value || 'export').replace(/[^a-z0-9._-]+/gi, '-').replace(/^-|-$/g, '');
|
||||
const exportPalette = () => {
|
||||
const declaredTheme = document.body.dataset.bsTheme ||
|
||||
document.documentElement.dataset.bsTheme ||
|
||||
document.documentElement.dataset.netboxColorMode || '';
|
||||
const declaredTheme = activeNetBoxTheme();
|
||||
const dark = declaredTheme === 'dark' || (!declaredTheme && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
return dark ? {
|
||||
frame: '#52606d', grid: '#667382', heading: '#8fc8ff', muted: '#a9b7c6',
|
||||
@@ -378,11 +453,16 @@
|
||||
const devices = Array.from(card.querySelectorAll('.rack-device')).map(device => {
|
||||
const bottom = Number.parseFloat(device.style.bottom) || 0;
|
||||
const height = Number.parseFloat(device.style.height) || (100 / rackUnits);
|
||||
const deviceHeight = Math.max(height / 100 * rackUnits, 1);
|
||||
const bottomUnits = bottom / 100 * rackUnits;
|
||||
const startingUnit = Number(rack.starting_unit) || 1;
|
||||
return {
|
||||
name: device.dataset.deviceName || device.querySelector('span')?.textContent || 'Gerät',
|
||||
type: device.dataset.deviceType || '',
|
||||
position: bottom / 100 * rackUnits + 1,
|
||||
height: Math.max(height / 100 * rackUnits, 1),
|
||||
position: rack.desc_units
|
||||
? startingUnit + rackUnits - deviceHeight - bottomUnits
|
||||
: startingUnit + bottomUnits,
|
||||
height: deviceHeight,
|
||||
face: device.dataset.face === 'rear' ? 'rear' : 'front',
|
||||
color: device.dataset.deviceColor || '#1685fc',
|
||||
};
|
||||
@@ -403,18 +483,23 @@
|
||||
racks.forEach((rack, rackIndex) => {
|
||||
const baseX = 10 + rackIndex * (rackWidth + rackGap);
|
||||
const rackHeight = rack.u_height * unit;
|
||||
const startingUnit = Number(rack.starting_unit) || 1;
|
||||
vertex(rack.name, `text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=${palette.heading};`, baseX, 0, rackWidth, 25);
|
||||
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' ? '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 u = 1; u <= rack.u_height; u++) {
|
||||
const y = header + rackHeight - u * unit;
|
||||
if (faceIndex === 0) vertex(String(u), `text;html=1;strokeColor=none;fillColor=none;align=right;fontSize=8;fontColor=${palette.muted};`, x - labelWidth, y, labelWidth - 4, unit);
|
||||
for (let row = 0; row < rack.u_height; row++) {
|
||||
const y = header + row * unit;
|
||||
const unitLabel = rack.desc_units ? startingUnit + row : startingUnit + rack.u_height - 1 - row;
|
||||
if (faceIndex === 0) vertex(String(unitLabel), `text;html=1;strokeColor=none;fillColor=none;align=right;fontSize=8;fontColor=${palette.muted};`, x - labelWidth, y, labelWidth - 4, unit);
|
||||
}
|
||||
rack.devices.filter(device => device.face === face).forEach(device => {
|
||||
const y = header + rackHeight - (device.position - 1 + device.height) * unit;
|
||||
const positionOffset = device.position - startingUnit;
|
||||
const y = rack.desc_units
|
||||
? header + positionOffset * unit
|
||||
: header + rackHeight - (positionOffset + device.height) * unit;
|
||||
const h = Math.max(device.height * unit, 4);
|
||||
const value = h >= 31 ? `${device.name}<br><font style="font-size:9px">U${device.position} · ${device.type}</font>` : device.name;
|
||||
vertex(value, `rounded=1;html=1;whiteSpace=wrap;overflow=hidden;align=left;verticalAlign=top;spacingLeft=5;spacingTop=2;fillColor=${palette.deviceFill};strokeColor=${device.color};strokeWidth=2;fontColor=${palette.deviceText};fontSize=11;`, x + 3, y + 1, faceWidth - 6, h - 2);
|
||||
@@ -435,19 +520,24 @@
|
||||
racks.forEach((rack, rackIndex) => {
|
||||
const baseX = 10 + rackIndex * (rackWidth + rackGap);
|
||||
const rackHeight = rack.u_height * unit;
|
||||
const startingUnit = Number(rack.starting_unit) || 1;
|
||||
content += `<text x="${baseX}" y="20" fill="${palette.heading}" font-family="sans-serif" font-size="16" font-weight="700">${xmlEscape(rack.name)}</text>`;
|
||||
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' ? 'VORDERSEITE' : 'RÜCKSEITE'}</text>`;
|
||||
content += `<rect x="${x}" y="${header}" width="${faceWidth}" height="${rackHeight}" fill="none" stroke="${palette.frame}" stroke-width="4"/>`;
|
||||
for (let u = 1; u <= rack.u_height; u++) {
|
||||
const y = header + rackHeight - u * unit;
|
||||
for (let row = 0; row < rack.u_height; row++) {
|
||||
const y = header + row * unit;
|
||||
const unitLabel = rack.desc_units ? startingUnit + row : startingUnit + rack.u_height - 1 - row;
|
||||
content += `<line x1="${x}" y1="${y}" x2="${x + faceWidth}" y2="${y}" stroke="${palette.grid}" stroke-opacity=".35"/>`;
|
||||
if (faceIndex === 0) content += `<text x="${x - 6}" y="${y + 15}" text-anchor="end" fill="${palette.muted}" font-family="sans-serif" font-size="9">${u}</text>`;
|
||||
if (faceIndex === 0) content += `<text x="${x - 6}" y="${y + 15}" text-anchor="end" fill="${palette.muted}" font-family="sans-serif" font-size="9">${unitLabel}</text>`;
|
||||
}
|
||||
rack.devices.filter(device => device.face === face).forEach(device => {
|
||||
const y = header + rackHeight - (device.position - 1 + device.height) * unit;
|
||||
const positionOffset = device.position - startingUnit;
|
||||
const y = rack.desc_units
|
||||
? header + positionOffset * unit
|
||||
: header + rackHeight - (positionOffset + device.height) * unit;
|
||||
const h = Math.max(device.height * unit, 4);
|
||||
content += `<rect x="${x + 3}" y="${y + 1}" width="${faceWidth - 6}" height="${h - 2}" rx="3" fill="${palette.deviceFill}" stroke="${xmlEscape(device.color)}" stroke-width="2"/>`;
|
||||
if (h >= 13) content += `<text x="${x + 9}" y="${y + Math.min(15, h - 4)}" fill="${palette.deviceText}" font-family="sans-serif" font-size="11" font-weight="600">${xmlEscape(device.name.slice(0, 34))}</text>`;
|
||||
@@ -476,6 +566,7 @@
|
||||
drawioCells += `<mxCell id="group-${drawioId++}" value="${xmlEscape(heading.textContent)}" style="text;html=1;strokeColor=none;fillColor=none;align=center;fontStyle=1;fontColor=${palette.heading};" vertex="1" parent="1"><mxGeometry x="${headingX}" y="${headingY}" width="${headingBounds.width}" height="22" as="geometry"/></mxCell>`;
|
||||
});
|
||||
root.querySelectorAll('.rack-topology-node').forEach(node => {
|
||||
if (node.style.display === 'none') return;
|
||||
const bounds = node.getBoundingClientRect();
|
||||
const x = bounds.left - rootBounds.left + root.scrollLeft;
|
||||
const y = bounds.top - rootBounds.top + root.scrollTop;
|
||||
@@ -492,13 +583,16 @@
|
||||
});
|
||||
let edgeContent = '';
|
||||
data.edges.forEach(edge => {
|
||||
if (!isEdgeVisible(edge)) return;
|
||||
const a = positions.get(edge.from), b = positions.get(edge.to);
|
||||
if (!a || !b) return;
|
||||
const bend = Math.max(30, Math.abs(b.x - a.x) * .35);
|
||||
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"${isWirelessEdge(edge) ? ' stroke-dasharray="7 7"' : ''}/>`;
|
||||
const dashPattern = isWirelessEdge(edge) ? '7 7' : isPowerEdge(edge) ? '2 4' : null;
|
||||
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) {
|
||||
drawioCells += `<mxCell id="edge-${drawioId++}" value="${xmlEscape(isWirelessEdge(edge) ? `WLAN · ${edge.label}` : edge.label)}" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;strokeColor=${xmlEscape(edge.color)};strokeWidth=2;fontSize=9;${isWirelessEdge(edge) ? 'dashed=1;dashPattern=7 7;' : ''}" edge="1" parent="1" source="${sourceId}" target="${targetId}"><mxGeometry relative="1" as="geometry"/></mxCell>`;
|
||||
drawioCells += `<mxCell id="edge-${drawioId++}" value="${xmlEscape(`${edgeLabelPrefix}${edge.label}`)}" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;strokeColor=${xmlEscape(edge.color)};strokeWidth=2;fontSize=9;${dashPattern ? `dashed=1;dashPattern=${dashPattern};` : ''}" edge="1" parent="1" source="${sourceId}" target="${targetId}"><mxGeometry relative="1" as="geometry"/></mxCell>`;
|
||||
}
|
||||
});
|
||||
return {svg: svgDocument(width, height, edgeContent + content), drawio: drawioDocument(drawioCells), width, height};
|
||||
@@ -549,7 +643,9 @@
|
||||
document.querySelectorAll('.topology-export').forEach(button => button.addEventListener('click', () => {
|
||||
exportGraphic(buildTopologySvg(), button.dataset.format, 'rack-topologie');
|
||||
}));
|
||||
requestAnimationFrame(drawEdges);
|
||||
showWirelessCheckbox?.addEventListener('change', applyKindVisibility);
|
||||
showPowerCheckbox?.addEventListener('change', applyKindVisibility);
|
||||
requestAnimationFrame(applyKindVisibility);
|
||||
window.addEventListener('resize', drawEdges);
|
||||
root.addEventListener('scroll', drawEdges, {passive: true});
|
||||
})();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -29,9 +31,8 @@ else:
|
||||
|
||||
|
||||
def image_static_url(path: Path) -> str:
|
||||
return static(
|
||||
f"/{path.relative_to(Path(settings.STATIC_ROOT))}"
|
||||
)
|
||||
# No leading slash: static file finders (e.g. the debug toolbar's) reject absolute paths.
|
||||
return static(path.relative_to(Path(settings.STATIC_ROOT)).as_posix())
|
||||
|
||||
|
||||
def get_image_from_url(url: str) -> str:
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
# 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
|
||||
from itertools import chain
|
||||
|
||||
from circuits.models import Circuit, CircuitTermination, ProviderNetwork
|
||||
from dcim.choices import CableTypeChoices
|
||||
from dcim.models import (
|
||||
Cable,
|
||||
CableTermination,
|
||||
@@ -928,9 +931,11 @@ def _rack_endpoint(termination):
|
||||
"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,
|
||||
"height": max(getattr(getattr(device, "device_type", None), "u_height", 1) or 1, 1) if device else 1,
|
||||
"height": float(max(getattr(getattr(device, "device_type", None), "u_height", 1) or 1, 1)) if device else 1,
|
||||
"face": str(device.face or "front").lower() if device else "front",
|
||||
"rack_u_height": getattr(getattr(device, "rack", None), "u_height", None),
|
||||
"rack_desc_units": getattr(getattr(device, "rack", None), "desc_units", False),
|
||||
"rack_starting_unit": getattr(getattr(device, "rack", None), "starting_unit", 1),
|
||||
"subtitle": str(device.device_type) if device else getattr(termination, "name", str(termination)),
|
||||
}
|
||||
|
||||
@@ -965,32 +970,49 @@ class RackElevationView(PermissionRequiredMixin, View):
|
||||
device_ids = []
|
||||
for device in devices.filter(rack_id__in=rack_ids).order_by("rack_id", "position", "name"):
|
||||
device_ids.append(device.pk)
|
||||
height = max(getattr(device.device_type, "u_height", 1) or 1, 1)
|
||||
height = float(max(getattr(device.device_type, "u_height", 1) or 1, 1))
|
||||
rack_height = max(device.rack.u_height or 1, 1)
|
||||
device.elevation_bottom = f"{(float(device.position or 1) - 1) / rack_height * 100:.4f}"
|
||||
rack_start = float(device.rack.starting_unit or 1)
|
||||
position_offset = float(device.position or rack_start) - rack_start
|
||||
if device.rack.desc_units:
|
||||
bottom_units = rack_height - position_offset - height
|
||||
else:
|
||||
bottom_units = position_offset
|
||||
device.elevation_bottom = f"{max(bottom_units, 0) / rack_height * 100:.4f}"
|
||||
device.elevation_height = f"{min(height / rack_height * 100, 100):.4f}"
|
||||
device.elevation_face = str(device.face or "front").lower()
|
||||
rack_devices[device.rack_id].append(device)
|
||||
|
||||
for rack in rack_list:
|
||||
rack.elevation_devices = rack_devices[rack.pk]
|
||||
rack.elevation_unit_labels = range(rack.u_height or 0, 0, -1)
|
||||
rack_start = rack.starting_unit or 1
|
||||
if rack.desc_units:
|
||||
rack.elevation_unit_labels = range(rack_start, rack_start + (rack.u_height or 0))
|
||||
else:
|
||||
rack.elevation_unit_labels = range(
|
||||
rack_start + (rack.u_height or 0) - 1,
|
||||
rack_start - 1,
|
||||
-1,
|
||||
)
|
||||
|
||||
rack_export = []
|
||||
for rack in rack_list:
|
||||
rack_export.append({
|
||||
"id": rack.pk, "name": rack.name, "u_height": rack.u_height,
|
||||
"starting_unit": rack.starting_unit, "desc_units": rack.desc_units,
|
||||
"site": str(rack.site), "location": str(rack.location or ""),
|
||||
"devices": [{
|
||||
"name": device.name or str(device.device_type),
|
||||
"type": str(device.device_type),
|
||||
"position": float(device.position or 1),
|
||||
"height": max(device.device_type.u_height or 1, 1),
|
||||
"height": float(max(device.device_type.u_height or 1, 1)),
|
||||
"face": device.elevation_face,
|
||||
"color": f"#{device.role.color}" if device.role.color else "#1685fc",
|
||||
} for device in rack.elevation_devices],
|
||||
})
|
||||
|
||||
power_component_models = {"powerport", "poweroutlet", "powerfeed"}
|
||||
|
||||
cable_rows = []
|
||||
topology_nodes = {}
|
||||
topology_edges = []
|
||||
@@ -1001,6 +1023,9 @@ class RackElevationView(PermissionRequiredMixin, View):
|
||||
cables = Cable.objects.restrict(request.user, "view").filter(pk__in=cable_ids)
|
||||
for cable in cables.order_by("label", "pk"):
|
||||
a_terms, b_terms = list(cable.a_terminations), list(cable.b_terminations)
|
||||
is_power_cable = cable.type == CableTypeChoices.TYPE_POWER or any(
|
||||
term._meta.model_name in power_component_models for term in a_terms + b_terms
|
||||
)
|
||||
for index in range(max(len(a_terms), len(b_terms), 1)):
|
||||
a = _rack_endpoint(a_terms[index]) if index < len(a_terms) else None
|
||||
b = _rack_endpoint(b_terms[index]) if index < len(b_terms) else None
|
||||
@@ -1010,19 +1035,23 @@ class RackElevationView(PermissionRequiredMixin, View):
|
||||
if endpoint:
|
||||
topology_nodes[endpoint["node_id"]] = endpoint
|
||||
if a and b:
|
||||
default_color = "#f59e0b" if is_power_cable else "#1685fc"
|
||||
topology_edges.append({
|
||||
"from": a["node_id"], "to": b["node_id"],
|
||||
"from_device": a["device_name"], "to_device": b["device_name"],
|
||||
"from_port": a["name"], "to_port": b["name"],
|
||||
"label": cable.label or str(cable),
|
||||
"color": f"#{cable.color}" if cable.color else "#1685fc",
|
||||
"color": f"#{cable.color}" if cable.color else default_color,
|
||||
"url": cable.get_absolute_url(),
|
||||
"kind": "cable",
|
||||
"kind": "power" if is_power_cable else "cable",
|
||||
})
|
||||
|
||||
wireless_device_ids = set(device_ids) | {
|
||||
node["device_id"] for node in topology_nodes.values() if node.get("device_id")
|
||||
}
|
||||
wireless_links = WirelessLink.objects.restrict(request.user, "view").filter(
|
||||
Q(interface_a__device_id__in=device_ids) |
|
||||
Q(interface_b__device_id__in=device_ids)
|
||||
Q(interface_a__device_id__in=wireless_device_ids) |
|
||||
Q(interface_b__device_id__in=wireless_device_ids)
|
||||
).select_related(
|
||||
"interface_a__device__rack", "interface_a__device__role", "interface_a__device__device_type",
|
||||
"interface_b__device__rack", "interface_b__device__role", "interface_b__device__device_type",
|
||||
@@ -1053,6 +1082,7 @@ class RackElevationView(PermissionRequiredMixin, View):
|
||||
"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",
|
||||
}
|
||||
wlan_interfaces = Interface.objects.restrict(request.user, "view").filter(
|
||||
wireless_lans=wireless_lan
|
||||
|
||||
@@ -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
|
||||
@@ -7,13 +9,14 @@ long_description = readme.read_text()
|
||||
|
||||
setup(
|
||||
name="netbox-topology-views",
|
||||
version="4.5.1",
|
||||
version="4.5.2",
|
||||
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",
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user