Change approach for declaring object panels

This commit is contained in:
Jeremy Stretch
2025-10-30 10:46:22 -04:00
parent fd3a9a0c37
commit 3890043b06
9 changed files with 198 additions and 158 deletions

View File

@@ -2,25 +2,13 @@
{# Display an object with its parent group #}
<ol class="breadcrumb" aria-label="breadcrumbs">
<li class="breadcrumb-item">
{% if group_url %}
<a href="{{ group_url }}">{{ group }}</a>
{% else %}
{{ object.group }}
{% endif %}
{% if linkify %}{{ group|linkify }}{% else %}{{ group }}{% endif %}
</li>
<li class="breadcrumb-item">
{% if object_url %}
<a href="{{ object_url }}">{{ object }}</a>
{% else %}
{{ object }}
{% endif %}
{% if linkify %}{{ object|linkify }}{% else %}{{ object }}{% endif %}
</li>
</ol>
{% else %}
{# Display only the object #}
{% if object_url %}
<a href="{{ object_url }}">{{ object }}</a>
{% else %}
{{ object }}
{% endif %}
{% if linkify %}{{ object|linkify }}{% else %}{{ object }}{% endif %}
{% endif %}

View File

@@ -1,11 +1,11 @@
<div class="card">
<h2 class="card-header">{{ title }}</h2>
<table class="table table-hover attr-table">
{% for label, attr in attrs.items %}
{% for attr in attrs %}
<tr>
<th scope="row">{{ label }}</th>
<th scope="row">{{ attr.label }}</th>
<td>
<div class="d-flex justify-content-between align-items-start">{{ attr }}</div>
<div class="d-flex justify-content-between align-items-start">{{ attr.value }}</div>
</td>
</tr>
{% endfor %}

View File

@@ -177,7 +177,7 @@
{% plugin_left_page object %}
</div>
<div class="col col-12 col-xl-6">
{{ device_attrs }}
{{ device_panel }}
<div class="card">
<h2 class="card-header">{% trans "Management" %}</h2>
<table class="table table-hover attr-table">

View File

@@ -1,4 +1,4 @@
{% if device.parent_bay %}
{% if value %}
<ol class="breadcrumb" aria-label="breadcrumbs">
<li class="breadcrumb-item">{{ device.parent_bay.device|linkify }}</li>
<li class="breadcrumb-item">{{ device.parent_bay }}</li>

View File

@@ -1,15 +1,15 @@
{% load i18n %}
{% if device.rack %}
{% if value %}
<span>
{{ device.rack|linkify }}
{% if device.rack and device.position %}
(U{{ device.position|floatformat }} / {{ device.get_face_display }})
{% elif device.rack and device.device_type.u_height %}
{{ value|linkify }}
{% if value and object.position %}
(U{{ object.position|floatformat }} / {{ object.get_face_display }})
{% elif value and object.device_type.u_height %}
<span class="badge text-bg-warning">{% trans "Not racked" %}</span>
{% endif %}
</span>
{% if device.rack and device.position %}
<a href="{{ device.rack.get_absolute_url }}?device={{ device.pk }}" class="btn btn-primary btn-sm d-print-none" title="{% trans "Highlight device in rack" %}">
{% if value and object.position %}
<a href="{{ value.get_absolute_url }}?device={{ object.pk }}" class="btn btn-primary btn-sm d-print-none" title="{% trans "Highlight device in rack" %}">
<i class="mdi mdi-view-day-outline"></i>
</a>
{% endif %}