mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-14 15:52:18 -06:00
Add layouts for DeviceType & ModuleTypeProfile
This commit is contained in:
@@ -112,3 +112,24 @@ class DeviceManagementPanel(panels.ObjectPanel):
|
||||
label=_('Out-of-band IP'),
|
||||
template_name='dcim/device/attrs/ipaddress.html',
|
||||
)
|
||||
|
||||
|
||||
class DeviceTypePanel(panels.ObjectPanel):
|
||||
manufacturer = attrs.ObjectAttr('manufacturer', label=_('Manufacturer'), linkify=True)
|
||||
model = attrs.TextAttr('model', label=_('Model'))
|
||||
part_number = attrs.TextAttr('part_number', label=_('Part number'))
|
||||
default_platform = attrs.ObjectAttr('default_platform', label=_('Default platform'), linkify=True)
|
||||
description = attrs.TextAttr('description', label=_('Description'))
|
||||
u_height = attrs.TextAttr('u_height', format_string='{}U', label=_('Height'))
|
||||
exclude_from_utilization = attrs.BooleanAttr('exclude_from_utilization', label=_('Exclude from utilization'))
|
||||
full_depth = attrs.BooleanAttr('is_full_depth', label=_('Full depth'))
|
||||
weight = attrs.NumericAttr('weight', unit_accessor='get_weight_unit_display', label=_('Weight'))
|
||||
subdevice_role = attrs.ChoiceAttr('subdevice_role', label=_('Parent/child'))
|
||||
airflow = attrs.ChoiceAttr('airflow', label=_('Airflow'))
|
||||
front_image = attrs.ImageAttr('front_image', label=_('Front image'))
|
||||
rear_image = attrs.ImageAttr('rear_image', label=_('Rear image'))
|
||||
|
||||
|
||||
class ModuleTypeProfilePanel(panels.ObjectPanel):
|
||||
name = attrs.TextAttr('name', label=_('Name'))
|
||||
description = attrs.TextAttr('description', label=_('Description'))
|
||||
|
||||
@@ -21,7 +21,7 @@ from ipam.tables import InterfaceVLANTable, VLANTranslationRuleTable
|
||||
from netbox.object_actions import *
|
||||
from netbox.ui import actions, layout
|
||||
from netbox.ui.panels import (
|
||||
CommentsPanel, NestedGroupObjectPanel, ObjectsTablePanel, OrganizationalObjectPanel, RelatedObjectsPanel,
|
||||
CommentsPanel, JSONPanel, NestedGroupObjectPanel, ObjectsTablePanel, OrganizationalObjectPanel, RelatedObjectsPanel,
|
||||
TemplatePanel,
|
||||
)
|
||||
from netbox.views import generic
|
||||
@@ -1308,6 +1308,18 @@ class DeviceTypeListView(generic.ObjectListView):
|
||||
@register_model_view(DeviceType)
|
||||
class DeviceTypeView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
queryset = DeviceType.objects.all()
|
||||
layout = layout.SimpleLayout(
|
||||
left_panels=[
|
||||
panels.DeviceTypePanel(),
|
||||
TagsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
RelatedObjectsPanel(),
|
||||
CustomFieldsPanel(),
|
||||
CommentsPanel(),
|
||||
ImageAttachmentsPanel(),
|
||||
],
|
||||
)
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
return {
|
||||
@@ -1559,6 +1571,34 @@ class ModuleTypeProfileListView(generic.ObjectListView):
|
||||
@register_model_view(ModuleTypeProfile)
|
||||
class ModuleTypeProfileView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
queryset = ModuleTypeProfile.objects.all()
|
||||
layout = layout.SimpleLayout(
|
||||
left_panels=[
|
||||
panels.ModuleTypeProfilePanel(),
|
||||
TagsPanel(),
|
||||
CommentsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
JSONPanel(field_name='schema', title=_('Schema')),
|
||||
CustomFieldsPanel(),
|
||||
],
|
||||
bottom_panels=[
|
||||
ObjectsTablePanel(
|
||||
model='dcim.ModuleType',
|
||||
title=_('Module Types'),
|
||||
filters={
|
||||
'profile_id': lambda ctx: ctx['object'].pk,
|
||||
},
|
||||
actions=[
|
||||
actions.AddObject(
|
||||
'dcim.ModuleType',
|
||||
url_params={
|
||||
'profile': lambda ctx: ctx['object'].pk,
|
||||
}
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@register_model_view(ModuleTypeProfile, 'add', detail=False)
|
||||
|
||||
Reference in New Issue
Block a user