Show clickable floor plan previews on location pages
Render a read-only SVG preview of each floor plan server-side and add it as a panel to the location detail page; clicking a preview opens the floor plan. Bump version to 0.1.2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6b47b0fd5b
commit
805aedba52
10 files changed
+162
-6
No files matched your search
@@ -1,6 +1,7 @@
|
||||
from netbox.plugins import PluginTemplateExtension
|
||||
|
||||
from .models import FloorPlanItem
|
||||
from .models import FloorPlan, FloorPlanItem
|
||||
from .preview import render_preview_svg
|
||||
|
||||
|
||||
class RackFloorPlanButton(PluginTemplateExtension):
|
||||
@@ -19,4 +20,18 @@ class RackFloorPlanButton(PluginTemplateExtension):
|
||||
})
|
||||
|
||||
|
||||
template_extensions = [RackFloorPlanButton]
|
||||
class LocationFloorPlanPreview(PluginTemplateExtension):
|
||||
"""Shows clickable previews of the location's floor plans on the location page."""
|
||||
models = ['dcim.location']
|
||||
|
||||
def full_width_page(self):
|
||||
request = self.context['request']
|
||||
plans = FloorPlan.objects.restrict(request.user, 'view').filter(location=self.context['object'])
|
||||
if not plans:
|
||||
return ''
|
||||
return self.render('netbox_floorplanner/inc/location_floorplans.html', extra_context={
|
||||
'previews': [(plan, render_preview_svg(plan)) for plan in plans],
|
||||
})
|
||||
|
||||
|
||||
template_extensions = [RackFloorPlanButton, LocationFloorPlanPreview]
|
||||
Reference in new issue
Block a user