Skip to content

Commit c5471a1

Browse files
committed
Define UI layout for Module view
1 parent 976b76d commit c5471a1

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

netbox/dcim/ui/panels.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ class DeviceTypePanel(panels.ObjectAttributesPanel):
151151
rear_image = attrs.ImageAttr('rear_image')
152152

153153

154+
class ModulePanel(panels.ObjectAttributesPanel):
155+
device = attrs.RelatedObjectAttr('device', linkify=True)
156+
device_type = attrs.RelatedObjectAttr('device.device_type', linkify=True, grouped_by='manufacturer')
157+
module_bay = attrs.NestedObjectAttr('module_bay')
158+
status = attrs.ChoiceAttr('status')
159+
description = attrs.TextAttr('description')
160+
serial = attrs.TextAttr('serial', label=_('Serial number'), style='font-monospace', copy_button=True)
161+
asset_tag = attrs.TextAttr('asset_tag', style='font-monospace', copy_button=True)
162+
163+
154164
class ModuleTypeProfilePanel(panels.ObjectAttributesPanel):
155165
name = attrs.TextAttr('name')
156166
description = attrs.TextAttr('description')

netbox/dcim/views.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,6 +2821,21 @@ class ModuleListView(generic.ObjectListView):
28212821
@register_model_view(Module)
28222822
class ModuleView(GetRelatedModelsMixin, generic.ObjectView):
28232823
queryset = Module.objects.all()
2824+
layout = layout.SimpleLayout(
2825+
left_panels=[
2826+
panels.ModulePanel(),
2827+
TagsPanel(),
2828+
CommentsPanel(),
2829+
],
2830+
right_panels=[
2831+
Panel(
2832+
title=_('Module Type'),
2833+
template_name='dcim/panels/module_type.html',
2834+
),
2835+
RelatedObjectsPanel(),
2836+
CustomFieldsPanel(),
2837+
],
2838+
)
28242839

28252840
def get_extra_context(self, request, instance):
28262841
return {

netbox/templates/dcim/module.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
{% endif %}
4848
{% endblock %}
4949

50-
{% block content %}
50+
{% block contentx %}
5151
<div class="row">
5252
<div class="col col-12 col-md-6">
5353
<div class="card">
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{% extends "ui/panels/_base.html" %}
2+
{% load helpers i18n %}
3+
4+
{% block panel_content %}
5+
<table class="table table-hover attr-table">
6+
<tr>
7+
<th scope="row">{% trans "Manufacturer" %}</th>
8+
<td>{{ object.module_type.manufacturer|linkify }}</td>
9+
</tr>
10+
<tr>
11+
<th scope="row">{% trans "Model" %}</th>
12+
<td>{{ object.module_type|linkify }}</td>
13+
</tr>
14+
{% for k, v in object.module_type.attributes.items %}
15+
<tr>
16+
<th scope="row">{{ k }}</th>
17+
<td>
18+
{% if v is True or v is False %}
19+
{% checkmark v %}
20+
{% else %}
21+
{{ v|placeholder }}
22+
{% endif %}
23+
</td>
24+
</tr>
25+
{% endfor %}
26+
</table>
27+
{% endblock panel_content %}

0 commit comments

Comments
 (0)