feat: honor images-only/labels-only rack view mode in offline SVG export
The rack elevation page's "Bilder und Beschriftungen" dropdown only toggles CSS visibility client-side after the browser already has the SVG, so a freshly server-rendered export had no way to know which mode was selected and always exported everything. apply_rack_view_mode() replicates that filtering server-side by removing the .label text elements (images-only) or the .device-image / .device-image-label elements (labels-only) from the parsed SVG. RackElevationOfflineSVGView now accepts a ?view= query param, and the rack detail page panel syncs its download links to the page's own "select.rack-view" dropdown so the exported file matches what's currently shown. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
20ec9453c2
commit
bfc4382403
6 files changed
+92
-7
No files matched your search
@@ -2,14 +2,36 @@
|
||||
<h2 class="card-header">SVG offline exportieren</h2>
|
||||
<div class="card-body d-flex flex-column gap-2">
|
||||
<a href="{% url 'plugins:netbox_utilities:rack_elevation_offline_svg' pk=rack.pk %}?face=front"
|
||||
class="btn btn-outline-secondary" title="Vorderseite als linkfreie SVG-Datei herunterladen">
|
||||
class="btn btn-outline-secondary netbox-utilities-offline-svg-link" data-face="front"
|
||||
title="Vorderseite als linkfreie SVG-Datei herunterladen">
|
||||
<i class="mdi mdi-download" aria-hidden="true"></i>
|
||||
Vorderseite
|
||||
</a>
|
||||
<a href="{% url 'plugins:netbox_utilities:rack_elevation_offline_svg' pk=rack.pk %}?face=rear"
|
||||
class="btn btn-outline-secondary" title="Rückseite als linkfreie SVG-Datei herunterladen">
|
||||
class="btn btn-outline-secondary netbox-utilities-offline-svg-link" data-face="rear"
|
||||
title="Rückseite als linkfreie SVG-Datei herunterladen">
|
||||
<i class="mdi mdi-download" aria-hidden="true"></i>
|
||||
Rückseite
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
var links = document.querySelectorAll(".netbox-utilities-offline-svg-link");
|
||||
var viewSelect = document.querySelector("select.rack-view");
|
||||
if (!links.length || !viewSelect) {
|
||||
return;
|
||||
}
|
||||
|
||||
function syncLinks() {
|
||||
links.forEach(function (link) {
|
||||
var url = new URL(link.href, window.location.origin);
|
||||
url.searchParams.set("view", viewSelect.value);
|
||||
link.href = url.toString();
|
||||
});
|
||||
}
|
||||
|
||||
viewSelect.addEventListener("change", syncLinks);
|
||||
syncLinks();
|
||||
})();
|
||||
</script>
|
||||
Reference in new issue
Block a user