mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-04 06:16:23 -06:00
Add rack layout
This commit is contained in:
@@ -38,16 +38,11 @@ class RackNumberingPanel(panels.ObjectPanel):
|
|||||||
desc_units = attrs.BooleanAttr('desc_units', label=_('Descending units'))
|
desc_units = attrs.BooleanAttr('desc_units', label=_('Descending units'))
|
||||||
|
|
||||||
|
|
||||||
class RackWeightPanel(panels.ObjectPanel):
|
|
||||||
weight = attrs.NumericAttr('weight', unit_accessor='get_weight_unit_display', label=_('Weight'))
|
|
||||||
max_weight = attrs.NumericAttr('max_weight', unit_accessor='get_weight_unit_display', label=_('Maximum weight'))
|
|
||||||
|
|
||||||
|
|
||||||
class RackPanel(panels.ObjectPanel):
|
class RackPanel(panels.ObjectPanel):
|
||||||
region = attrs.NestedObjectAttr('site.region', label=_('Region'), linkify=True)
|
region = attrs.NestedObjectAttr('site.region', label=_('Region'), linkify=True)
|
||||||
site = attrs.ObjectAttr('site', label=_('Site'), linkify=True, grouped_by='group')
|
site = attrs.ObjectAttr('site', label=_('Site'), linkify=True, grouped_by='group')
|
||||||
location = attrs.NestedObjectAttr('location', label=_('Location'), linkify=True)
|
location = attrs.NestedObjectAttr('location', label=_('Location'), linkify=True)
|
||||||
facility = attrs.TextAttr('facility', label=_('Facility'))
|
facility = attrs.TextAttr('facility', label=_('Facility ID'))
|
||||||
tenant = attrs.ObjectAttr('tenant', label=_('Tenant'), linkify=True, grouped_by='group')
|
tenant = attrs.ObjectAttr('tenant', label=_('Tenant'), linkify=True, grouped_by='group')
|
||||||
status = attrs.ChoiceAttr('status', label=_('Status'))
|
status = attrs.ChoiceAttr('status', label=_('Status'))
|
||||||
rack_type = attrs.ObjectAttr('rack_type', label=_('Rack type'), linkify=True, grouped_by='manufacturer')
|
rack_type = attrs.ObjectAttr('rack_type', label=_('Rack type'), linkify=True, grouped_by='manufacturer')
|
||||||
@@ -60,6 +55,12 @@ class RackPanel(panels.ObjectPanel):
|
|||||||
power_utilization = attrs.UtilizationAttr('get_power_utilization', label=_('Power utilization'))
|
power_utilization = attrs.UtilizationAttr('get_power_utilization', label=_('Power utilization'))
|
||||||
|
|
||||||
|
|
||||||
|
class RackWeightPanel(panels.ObjectPanel):
|
||||||
|
weight = attrs.NumericAttr('weight', unit_accessor='get_weight_unit_display', label=_('Weight'))
|
||||||
|
max_weight = attrs.NumericAttr('max_weight', unit_accessor='get_weight_unit_display', label=_('Maximum weight'))
|
||||||
|
total_weight = attrs.NumericAttr('total_weight', unit_accessor='get_weight_unit_display', label=_('Total weight'))
|
||||||
|
|
||||||
|
|
||||||
class RackRolePanel(panels.OrganizationalObjectPanel):
|
class RackRolePanel(panels.OrganizationalObjectPanel):
|
||||||
color = attrs.ColorAttr('color')
|
color = attrs.ColorAttr('color')
|
||||||
|
|
||||||
|
|||||||
+26
-1
@@ -21,7 +21,7 @@ from ipam.tables import InterfaceVLANTable, VLANTranslationRuleTable
|
|||||||
from netbox.object_actions import *
|
from netbox.object_actions import *
|
||||||
from netbox.ui import actions, layout
|
from netbox.ui import actions, layout
|
||||||
from netbox.ui.panels import (
|
from netbox.ui.panels import (
|
||||||
CommentsPanel, NestedGroupObjectPanel, ObjectsTablePanel, PluginContentPanel, RelatedObjectsPanel,
|
CommentsPanel, NestedGroupObjectPanel, ObjectsTablePanel, PluginContentPanel, RelatedObjectsPanel, TemplatePanel,
|
||||||
)
|
)
|
||||||
from netbox.views import generic
|
from netbox.views import generic
|
||||||
from utilities.forms import ConfirmationForm
|
from utilities.forms import ConfirmationForm
|
||||||
@@ -1043,6 +1043,31 @@ class RackElevationListView(generic.ObjectListView):
|
|||||||
@register_model_view(Rack)
|
@register_model_view(Rack)
|
||||||
class RackView(GetRelatedModelsMixin, generic.ObjectView):
|
class RackView(GetRelatedModelsMixin, generic.ObjectView):
|
||||||
queryset = Rack.objects.prefetch_related('site__region', 'tenant__group', 'location', 'role')
|
queryset = Rack.objects.prefetch_related('site__region', 'tenant__group', 'location', 'role')
|
||||||
|
layout = layout.Layout(
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
panels.RackPanel(),
|
||||||
|
panels.RackDimensionsPanel(_('Dimensions')),
|
||||||
|
panels.RackNumberingPanel(_('Numbering')),
|
||||||
|
panels.RackWeightPanel(_('Weight')),
|
||||||
|
CustomFieldsPanel(),
|
||||||
|
TagsPanel(),
|
||||||
|
CommentsPanel(),
|
||||||
|
ImageAttachmentsPanel(),
|
||||||
|
PluginContentPanel('left_page'),
|
||||||
|
),
|
||||||
|
layout.Column(
|
||||||
|
TemplatePanel('dcim/panels/rack_elevations.html'),
|
||||||
|
RelatedObjectsPanel(),
|
||||||
|
PluginContentPanel('right_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
PluginContentPanel('full_width_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
peer_racks = Rack.objects.restrict(request.user, 'view').filter(site=instance.site)
|
peer_racks = Rack.objects.restrict(request.user, 'view').filter(site=instance.site)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ __all__ = (
|
|||||||
'RelatedObjectsPanel',
|
'RelatedObjectsPanel',
|
||||||
'Panel',
|
'Panel',
|
||||||
'PluginContentPanel',
|
'PluginContentPanel',
|
||||||
|
'TemplatePanel',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -142,6 +143,13 @@ class ObjectsTablePanel(Panel):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TemplatePanel(Panel):
|
||||||
|
|
||||||
|
def __init__(self, template_name, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.template_name = template_name
|
||||||
|
|
||||||
|
|
||||||
class PluginContentPanel(Panel):
|
class PluginContentPanel(Panel):
|
||||||
|
|
||||||
def __init__(self, method, **kwargs):
|
def __init__(self, method, **kwargs):
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
<div class="text-end mb-4">
|
||||||
|
<select class="btn btn-outline-secondary no-ts rack-view">
|
||||||
|
<option value="images-and-labels" selected="selected">{% trans "Images and Labels" %}</option>
|
||||||
|
<option value="images-only">{% trans "Images only" %}</option>
|
||||||
|
<option value="labels-only">{% trans "Labels only" %}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="row" style="margin-bottom: 20px">
|
||||||
|
<div class="col col-md-6 col-sm-6 col-xs-12 text-center">
|
||||||
|
<div style="margin-left: 30px">
|
||||||
|
<h2 class="h4">{% trans "Front" %}</h2>
|
||||||
|
{% include 'dcim/inc/rack_elevation.html' with face='front' extra_params=svg_extra %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col col-md-6 col-sm-6 col-xs-12 text-center">
|
||||||
|
<div style="margin-left: 30px">
|
||||||
|
<h2 class="h4">{% trans "Rear" %}</h2>
|
||||||
|
{% include 'dcim/inc/rack_elevation.html' with face='rear' extra_params=svg_extra %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user