Initial NetBox Floor Planner plugin
Drag & drop SVG floor plan designer for NetBox 4.7.2+ with rack/device placement, smart snapping, undo/redo, view mode with status colouring, SVG/PNG export, REST layout API and English/German translations. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
c4dc5d53ce
31 files changed
+3041
No files matched your search
@@ -0,0 +1,22 @@
|
||||
from netbox.plugins import PluginTemplateExtension
|
||||
|
||||
from .models import FloorPlanItem
|
||||
|
||||
|
||||
class RackFloorPlanButton(PluginTemplateExtension):
|
||||
"""Adds a "Show on floor plan" button to racks and devices that are placed on a plan."""
|
||||
models = ['dcim.rack', 'dcim.device']
|
||||
|
||||
def buttons(self):
|
||||
obj = self.context['object']
|
||||
field = 'rack' if obj._meta.model_name == 'rack' else 'device'
|
||||
item = FloorPlanItem.objects.filter(**{field: obj}).select_related('floorplan').first()
|
||||
if item is None:
|
||||
return ''
|
||||
return self.render('netbox_floorplanner/inc/floorplan_button.html', extra_context={
|
||||
'floorplan': item.floorplan,
|
||||
'highlight': f'{field}-{obj.pk}',
|
||||
})
|
||||
|
||||
|
||||
template_extensions = [RackFloorPlanButton]
|
||||
Reference in new issue
Block a user