mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-17 01:02:18 -06:00
Define UI layout for Module view
This commit is contained in:
@@ -151,6 +151,16 @@ class DeviceTypePanel(panels.ObjectAttributesPanel):
|
|||||||
rear_image = attrs.ImageAttr('rear_image')
|
rear_image = attrs.ImageAttr('rear_image')
|
||||||
|
|
||||||
|
|
||||||
|
class ModulePanel(panels.ObjectAttributesPanel):
|
||||||
|
device = attrs.RelatedObjectAttr('device', linkify=True)
|
||||||
|
device_type = attrs.RelatedObjectAttr('device.device_type', linkify=True, grouped_by='manufacturer')
|
||||||
|
module_bay = attrs.NestedObjectAttr('module_bay')
|
||||||
|
status = attrs.ChoiceAttr('status')
|
||||||
|
description = attrs.TextAttr('description')
|
||||||
|
serial = attrs.TextAttr('serial', label=_('Serial number'), style='font-monospace', copy_button=True)
|
||||||
|
asset_tag = attrs.TextAttr('asset_tag', style='font-monospace', copy_button=True)
|
||||||
|
|
||||||
|
|
||||||
class ModuleTypeProfilePanel(panels.ObjectAttributesPanel):
|
class ModuleTypeProfilePanel(panels.ObjectAttributesPanel):
|
||||||
name = attrs.TextAttr('name')
|
name = attrs.TextAttr('name')
|
||||||
description = attrs.TextAttr('description')
|
description = attrs.TextAttr('description')
|
||||||
|
|||||||
@@ -2821,6 +2821,21 @@ class ModuleListView(generic.ObjectListView):
|
|||||||
@register_model_view(Module)
|
@register_model_view(Module)
|
||||||
class ModuleView(GetRelatedModelsMixin, generic.ObjectView):
|
class ModuleView(GetRelatedModelsMixin, generic.ObjectView):
|
||||||
queryset = Module.objects.all()
|
queryset = Module.objects.all()
|
||||||
|
layout = layout.SimpleLayout(
|
||||||
|
left_panels=[
|
||||||
|
panels.ModulePanel(),
|
||||||
|
TagsPanel(),
|
||||||
|
CommentsPanel(),
|
||||||
|
],
|
||||||
|
right_panels=[
|
||||||
|
Panel(
|
||||||
|
title=_('Module Type'),
|
||||||
|
template_name='dcim/panels/module_type.html',
|
||||||
|
),
|
||||||
|
RelatedObjectsPanel(),
|
||||||
|
CustomFieldsPanel(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block contentx %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-12 col-md-6">
|
<div class="col col-12 col-md-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|||||||
27
netbox/templates/dcim/panels/module_type.html
Normal file
27
netbox/templates/dcim/panels/module_type.html
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{% extends "ui/panels/_base.html" %}
|
||||||
|
{% load helpers i18n %}
|
||||||
|
|
||||||
|
{% block panel_content %}
|
||||||
|
<table class="table table-hover attr-table">
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{% trans "Manufacturer" %}</th>
|
||||||
|
<td>{{ object.module_type.manufacturer|linkify }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{% trans "Model" %}</th>
|
||||||
|
<td>{{ object.module_type|linkify }}</td>
|
||||||
|
</tr>
|
||||||
|
{% for k, v in object.module_type.attributes.items %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{{ k }}</th>
|
||||||
|
<td>
|
||||||
|
{% if v is True or v is False %}
|
||||||
|
{% checkmark v %}
|
||||||
|
{% else %}
|
||||||
|
{{ v|placeholder }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
{% endblock panel_content %}
|
||||||
Reference in New Issue
Block a user