mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-27 03:09:31 +02:00
Misc cleanup for layouts
This commit is contained in:
@@ -192,8 +192,14 @@ class DataFileView(generic.ObjectView):
|
|||||||
layout.Column(
|
layout.Column(
|
||||||
panels.DataFilePanel(),
|
panels.DataFilePanel(),
|
||||||
panels.DataFileContentPanel(),
|
panels.DataFileContentPanel(),
|
||||||
|
PluginContentPanel('left_page'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
PluginContentPanel('full_width_page'),
|
||||||
|
)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from netbox.ui.panels import (
|
|||||||
CommentsPanel,
|
CommentsPanel,
|
||||||
ContextTablePanel,
|
ContextTablePanel,
|
||||||
ObjectsTablePanel,
|
ObjectsTablePanel,
|
||||||
|
PluginContentPanel,
|
||||||
RelatedObjectsPanel,
|
RelatedObjectsPanel,
|
||||||
TemplatePanel,
|
TemplatePanel,
|
||||||
)
|
)
|
||||||
@@ -55,11 +56,13 @@ class VRFView(GetRelatedModelsMixin, generic.ObjectView):
|
|||||||
layout.Column(
|
layout.Column(
|
||||||
panels.VRFPanel(),
|
panels.VRFPanel(),
|
||||||
TagsPanel(),
|
TagsPanel(),
|
||||||
|
PluginContentPanel('left_page'),
|
||||||
),
|
),
|
||||||
layout.Column(
|
layout.Column(
|
||||||
RelatedObjectsPanel(),
|
RelatedObjectsPanel(),
|
||||||
CustomFieldsPanel(),
|
CustomFieldsPanel(),
|
||||||
CommentsPanel(),
|
CommentsPanel(),
|
||||||
|
PluginContentPanel('right_page'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
layout.Row(
|
layout.Row(
|
||||||
@@ -70,6 +73,11 @@ class VRFView(GetRelatedModelsMixin, generic.ObjectView):
|
|||||||
ContextTablePanel('export_targets_table', title=_('Export route targets')),
|
ContextTablePanel('export_targets_table', title=_('Export route targets')),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
PluginContentPanel('full_width_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
@@ -169,10 +177,12 @@ class RouteTargetView(generic.ObjectView):
|
|||||||
layout.Column(
|
layout.Column(
|
||||||
panels.RouteTargetPanel(),
|
panels.RouteTargetPanel(),
|
||||||
TagsPanel(),
|
TagsPanel(),
|
||||||
|
PluginContentPanel('left_page'),
|
||||||
),
|
),
|
||||||
layout.Column(
|
layout.Column(
|
||||||
CustomFieldsPanel(),
|
CustomFieldsPanel(),
|
||||||
CommentsPanel(),
|
CommentsPanel(),
|
||||||
|
PluginContentPanel('right_page'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
layout.Row(
|
layout.Row(
|
||||||
@@ -207,6 +217,11 @@ class RouteTargetView(generic.ObjectView):
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
PluginContentPanel('full_width_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,16 @@ class Layout:
|
|||||||
"""
|
"""
|
||||||
def __init__(self, *rows):
|
def __init__(self, *rows):
|
||||||
for i, row in enumerate(rows):
|
for i, row in enumerate(rows):
|
||||||
if type(row) is not Row:
|
if not isinstance(row, Row):
|
||||||
raise TypeError(f"Row {i} must be a Row instance, not {type(row)}.")
|
raise TypeError(f"Row {i} must be a Row instance, not {type(row)}.")
|
||||||
self.rows = rows
|
self.rows = rows
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return iter(self.rows)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"Layout({len(self.rows)} rows)"
|
||||||
|
|
||||||
|
|
||||||
class Row:
|
class Row:
|
||||||
"""
|
"""
|
||||||
@@ -35,10 +41,16 @@ class Row:
|
|||||||
"""
|
"""
|
||||||
def __init__(self, *columns):
|
def __init__(self, *columns):
|
||||||
for i, column in enumerate(columns):
|
for i, column in enumerate(columns):
|
||||||
if type(column) is not Column:
|
if not isinstance(column, Column):
|
||||||
raise TypeError(f"Column {i} must be a Column instance, not {type(column)}.")
|
raise TypeError(f"Column {i} must be a Column instance, not {type(column)}.")
|
||||||
self.columns = columns
|
self.columns = columns
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return iter(self.columns)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"Row({len(self.columns)} columns)"
|
||||||
|
|
||||||
|
|
||||||
class Column:
|
class Column:
|
||||||
"""
|
"""
|
||||||
@@ -53,6 +65,12 @@ class Column:
|
|||||||
raise TypeError(f"Panel {i} must be an instance of a Panel, not {type(panel)}.")
|
raise TypeError(f"Panel {i} must be an instance of a Panel, not {type(panel)}.")
|
||||||
self.panels = panels
|
self.panels = panels
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return iter(self.panels)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"Column({len(self.panels)} panels)"
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Common layouts
|
# Common layouts
|
||||||
|
|||||||
@@ -124,11 +124,11 @@ Context:
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{# Render panel layout declared on view class #}
|
{# Render panel layout declared on view class #}
|
||||||
{% for row in layout.rows %}
|
{% for row in layout %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% for column in row.columns %}
|
{% for column in row %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{% for panel in column.panels %}
|
{% for panel in column %}
|
||||||
{% render panel %}
|
{% render panel %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user