feat: add offline SVG export for rack elevations

Adds a "SVG offline" download button on the rack detail page. It
reuses NetBox's own rack-elevation REST endpoint to render the SVG,
then strips embedded <a>/xlink:href links (which point at internal,
relative NetBox URLs and are useless once the file is saved) so the
result renders identically when opened standalone in any SVG viewer.

Gated by the new offline_svg_export_enabled plugin setting (on by
default).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 14:22:04 +02:00
co-authored by Claude Sonnet 5
parent 35ca661ed0
commit 3768417be6
9 changed files with 186 additions and 6 deletions
+25 -2
View File
@@ -19,7 +19,12 @@ from .navigation_helpers import (
normalize_preferences,
normalize_sidebar_width,
)
from .runtime import connection_vlans_enabled, navigation_customization_enabled, tenant_filter_enabled
from .runtime import (
connection_vlans_enabled,
navigation_customization_enabled,
offline_svg_export_enabled,
tenant_filter_enabled,
)
class UtilitiesGlobalContent(PluginTemplateExtension):
@@ -147,4 +152,22 @@ class ConnectionVLANContent(PluginTemplateExtension):
)
template_extensions = [UtilitiesGlobalContent, DeviceUtilitiesContent, ConnectionVLANContent]
class RackUtilitiesContent(PluginTemplateExtension):
models = ["dcim.rack"]
def buttons(self):
if not offline_svg_export_enabled():
return ""
rack = self.context["object"]
return self.render(
"netbox_utilities/rack_offline_svg_buttons.html",
{"rack": rack},
)
template_extensions = [
UtilitiesGlobalContent,
DeviceUtilitiesContent,
ConnectionVLANContent,
RackUtilitiesContent,
]