Remove obsolete content-wrapper template block

This commit is contained in:
Jeremy Stretch 2024-01-09 15:22:41 -05:00
parent 58628aa086
commit a88919c927
14 changed files with 638 additions and 669 deletions

View File

@ -23,8 +23,3 @@
</ul> </ul>
{% endblock %} {% endblock %}
{% block content-wrapper %}
<div class="tab-content">
{% block content %}{% endblock %}
</div>
{% endblock %}

View File

@ -171,17 +171,13 @@ Blocks:
</div> </div>
{# /Page header #} {# /Page header #}
{# Page body #} {# Page body #}
{% block page %} {% block page %}
<div class="page-body"> <div class="page-body">
<div class="container-xl tab-content py-3"> <div class="container-xl tab-content py-3">
{# Page content #} {# Page content #}
{# TODO: Remove content-wrapper block #} {% block content %}{% endblock %}
{% block content-wrapper %}
{% block content %}{% endblock %}
{% endblock %}
{# /Page content #} {# /Page content #}
{# Bottom banner #} {# Bottom banner #}

View File

@ -5,8 +5,7 @@
{% block title %}{{ title }}{% endblock %} {% block title %}{{ title }}{% endblock %}
{% block content-wrapper %} {% block content %}
<div class="tab-content">
{# Connections list #} {# Connections list #}
<div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab"> <div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
@ -25,5 +24,4 @@
</div> </div>
{% endif %} {% endif %}
</div> {% endblock content %}
{% endblock content-wrapper %}

View File

@ -36,56 +36,54 @@
</div> </div>
{% endblock %} {% endblock %}
{% block content-wrapper %} {% block content %}
<div class="tab-content">
{% if filter_form %} {% if filter_form %}
{% applied_filters model filter_form request.GET %} {% applied_filters model filter_form request.GET %}
{% endif %}
{# Rack elevations #}
<div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
{% if page %}
<div style="white-space: nowrap; overflow-x: scroll;">
{% for rack in page %}
<div style="display: inline-block; margin-right: 12px">
<div style="margin-left: 30px">
<div class="text-center">
<strong><a href="{% url 'dcim:rack' pk=rack.pk %}">{{ rack.name }}</a></strong>
{% if rack.role %}
<br /><span class="badge my-3" style="color: {{ rack.role.color|fgcolor }}; background-color: #{{ rack.role.color }}">{{ rack.role }}</span>
{% endif %}
{% if rack.facility_id %}
<br /><small class="text-muted">{{ rack.facility_id }}</small>
{% endif %}
</div>
{% include 'dcim/inc/rack_elevation.html' with object=rack face=rack_face %}
<div class="clearfix"></div>
<div class="text-center">
<strong><a href="{% url 'dcim:rack' pk=rack.pk %}">{{ rack.name }}</a></strong>
{% if rack.facility_id %}
<small class="text-muted">({{ rack.facility_id }})</small>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
<br />
{% include 'inc/paginator.html' %}
{% else %}
<p>{% trans "No Racks Found" %}</p>
{% endif %} {% endif %}
{# Rack elevations #}
<div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
{% if page %}
<div style="white-space: nowrap; overflow-x: scroll;">
{% for rack in page %}
<div style="display: inline-block; margin-right: 12px">
<div style="margin-left: 30px">
<div class="text-center">
<strong><a href="{% url 'dcim:rack' pk=rack.pk %}">{{ rack.name }}</a></strong>
{% if rack.role %}
<br /><span class="badge my-3" style="color: {{ rack.role.color|fgcolor }}; background-color: #{{ rack.role.color }}">{{ rack.role }}</span>
{% endif %}
{% if rack.facility_id %}
<br /><small class="text-muted">{{ rack.facility_id }}</small>
{% endif %}
</div>
{% include 'dcim/inc/rack_elevation.html' with object=rack face=rack_face %}
<div class="clearfix"></div>
<div class="text-center">
<strong><a href="{% url 'dcim:rack' pk=rack.pk %}">{{ rack.name }}</a></strong>
{% if rack.facility_id %}
<small class="text-muted">({{ rack.facility_id }})</small>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
<br />
{% include 'inc/paginator.html' %}
{% else %}
<p>{% trans "No Racks Found" %}</p>
{% endif %}
</div>
{# Filter form #}
{% if filter_form %}
<div class="tab-pane show" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab">
{% include 'inc/filter_list.html' %}
</div>
{% endif %}
</div> </div>
{% endblock content-wrapper %}
{# Filter form #}
{% if filter_form %}
<div class="tab-pane show" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab">
{% include 'inc/filter_list.html' %}
</div>
{% endif %}
{% endblock content %}
{% block modals %}{% endblock %} {% block modals %}{% endblock %}

View File

@ -9,106 +9,104 @@
{% endblocktrans %} {% endblocktrans %}
{% endblock %} {% endblock %}
{% block content-wrapper %} {% block content %}
<div class="tab-content"> <div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="object-list-tab">
<div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="object-list-tab"> <form action="" method="post" enctype="multipart/form-data" class="form-object-edit">
<form action="" method="post" enctype="multipart/form-data" class="form-object-edit"> {% for form in formset %}
{% for form in formset %} {% render_errors form %}
{% render_errors form %} {% endfor %}
{% endfor %}
{% csrf_token %} {% csrf_token %}
{{ pk_form.pk }} {{ pk_form.pk }}
{{ formset.management_form }} {{ formset.management_form }}
<div class="field-group my-5"> <div class="field-group my-5">
<div class="row"> <div class="row">
<h5 class="col-9 offset-3">{% trans "Virtual Chassis" %}</h5> <h5 class="col-9 offset-3">{% trans "Virtual Chassis" %}</h5>
</div>
{% render_field vc_form.name %}
{% render_field vc_form.domain %}
{% render_field vc_form.description %}
{% render_field vc_form.master %}
{% render_field vc_form.tags %}
</div> </div>
{% render_field vc_form.name %}
{% render_field vc_form.domain %}
{% render_field vc_form.description %}
{% render_field vc_form.master %}
{% render_field vc_form.tags %}
</div>
<div class="field-group my-5"> <div class="field-group my-5">
{% render_field vc_form.comments %} {% render_field vc_form.comments %}
</div> </div>
{% if vc_form.custom_fields %}
<div class="field-group mb-5">
<div class="row">
<h5 class="col-9 offset-3">{% trans "Custom Fields" %}</h5>
</div>
{% render_custom_fields vc_form %}
</div>
{% endif %}
{% if vc_form.custom_fields %}
<div class="field-group mb-5"> <div class="field-group mb-5">
<h5 class="text-center">{% trans "Members" %}</h5> <div class="row">
<table class="table"> <h5 class="col-9 offset-3">{% trans "Custom Fields" %}</h5>
<thead> </div>
<tr> {% render_custom_fields vc_form %}
<th>{% trans "Device" %}</th>
<th>{% trans "ID" %}</th>
<th>{% trans "Rack/Unit" %}</th>
<th>{% trans "Serial" %}</th>
<th>{% trans "Position" %}</th>
<th>{% trans "Priority" %}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for form in formset %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
{% with device=form.instance virtual_chassis=vc_form.instance %}
<tr>
<td>{{ device|linkify }}</td>
<td>{{ device.pk }}</td>
<td>
{% if device.rack %}
{{ device.rack }} / {{ device.position|floatformat }}
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
<td>{{ device.serial|placeholder }}</td>
<td>
{{ form.vc_position }}
{% if form.vc_position.errors %}
<br /><small class="text-danger">{{ form.vc_position.errors.0 }}</small>
{% endif %}
</td>
<td>
{{ form.vc_priority }}
{% if form.vc_priority.errors %}
<br /><small class="text-danger">{{ form.vc_priority.errors.0 }}</small>
{% endif %}
</td>
<td>
{% if virtual_chassis.pk %}
<a href="{% url 'dcim:virtualchassis_remove_member' pk=device.pk %}?return_url={% url 'dcim:virtualchassis_edit' pk=virtual_chassis.pk %}" class="btn btn-danger{% if virtual_chassis.master == device %} disabled{% endif %}">
<span class="mdi mdi-trash-can-outline" aria-hidden="true"></span>
</a>
{% endif %}
</td>
</tr>
{% endwith %}
{% endfor %}
</tbody>
</table>
</div> </div>
<div class="text-end"> {% endif %}
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
{% if vc_form.instance.pk %} <div class="field-group mb-5">
<button type="submit" name="_update" class="btn btn-primary">{% trans "Save" %}</button> <h5 class="text-center">{% trans "Members" %}</h5>
{% else %} <table class="table">
<button type="submit" name="_create" class="btn btn-primary">{% trans "Create" %}</button> <thead>
{% endif %} <tr>
</div> <th>{% trans "Device" %}</th>
</form> <th>{% trans "ID" %}</th>
</div> <th>{% trans "Rack/Unit" %}</th>
<th>{% trans "Serial" %}</th>
<th>{% trans "Position" %}</th>
<th>{% trans "Priority" %}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for form in formset %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
{% with device=form.instance virtual_chassis=vc_form.instance %}
<tr>
<td>{{ device|linkify }}</td>
<td>{{ device.pk }}</td>
<td>
{% if device.rack %}
{{ device.rack }} / {{ device.position|floatformat }}
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
<td>{{ device.serial|placeholder }}</td>
<td>
{{ form.vc_position }}
{% if form.vc_position.errors %}
<br /><small class="text-danger">{{ form.vc_position.errors.0 }}</small>
{% endif %}
</td>
<td>
{{ form.vc_priority }}
{% if form.vc_priority.errors %}
<br /><small class="text-danger">{{ form.vc_priority.errors.0 }}</small>
{% endif %}
</td>
<td>
{% if virtual_chassis.pk %}
<a href="{% url 'dcim:virtualchassis_remove_member' pk=device.pk %}?return_url={% url 'dcim:virtualchassis_edit' pk=virtual_chassis.pk %}" class="btn btn-danger{% if virtual_chassis.master == device %} disabled{% endif %}">
<span class="mdi mdi-trash-can-outline" aria-hidden="true"></span>
</a>
{% endif %}
</td>
</tr>
{% endwith %}
{% endfor %}
</tbody>
</table>
</div>
<div class="text-end">
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
{% if vc_form.instance.pk %}
<button type="submit" name="_update" class="btn btn-primary">{% trans "Save" %}</button>
{% else %}
<button type="submit" name="_create" class="btn btn-primary">{% trans "Create" %}</button>
{% endif %}
</div>
</form>
</div> </div>
{% endblock %} {% endblock content %}

View File

@ -3,9 +3,9 @@
{% block title %}{% trans "Change Log" %}{% endblock %} {% block title %}{% trans "Change Log" %}{% endblock %}
{% block content-wrapper %} {% block content %}
{{ block.super }} {{ block.super }}
<div class="text-muted px-3"> <div class="text-muted px-3">
{% trans "Change log retention" %}: {% if config.CHANGELOG_RETENTION %}{{ config.CHANGELOG_RETENTION }} {% trans "days" %}{% else %}{% trans "Indefinite" %}{% endif %} {% trans "Change log retention" %}: {% if config.CHANGELOG_RETENTION %}{{ config.CHANGELOG_RETENTION }} {% trans "days" %}{% else %}{% trans "Indefinite" %}{% endif %}
</div> </div>
{% endblock %} {% endblock content %}

View File

@ -23,113 +23,111 @@
</div> </div>
{% endblock controls %} {% endblock controls %}
{% block content-wrapper %} {% block content %}
<div class="tab-content"> {% for module in report_modules %}
{% for module in report_modules %} <div class="card">
<div class="card"> <h5 class="card-header" id="module{{ module.pk }}">
<h5 class="card-header" id="module{{ module.pk }}"> {% if perms.extras.delete_reportmodule %}
{% if perms.extras.delete_reportmodule %} <div class="float-end">
<div class="float-end"> <a href="{% url 'extras:reportmodule_delete' pk=module.pk %}" class="btn btn-danger">
<a href="{% url 'extras:reportmodule_delete' pk=module.pk %}" class="btn btn-danger"> <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {% trans "Delete" %}
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {% trans "Delete" %} </a>
</a> </div>
</div> {% endif %}
{% endif %} <i class="mdi mdi-file-document-outline"></i> {{ module }}
<i class="mdi mdi-file-document-outline"></i> {{ module }} </h5>
</h5> <div class="card-body">
<div class="card-body"> {% include 'inc/sync_warning.html' with object=module %}
{% include 'inc/sync_warning.html' with object=module %} {% if module.reports %}
{% if module.reports %} <table class="table table-hover table-headings reports">
<table class="table table-hover table-headings reports"> <thead>
<thead> <tr>
<tr> <th width="250">{% trans "Name" %}</th>
<th width="250">{% trans "Name" %}</th> <th>{% trans "Description" %}</th>
<th>{% trans "Description" %}</th> <th>{% trans "Last Run" %}</th>
<th>{% trans "Last Run" %}</th> <th>{% trans "Status" %}</th>
<th>{% trans "Status" %}</th> <th width="120"></th>
<th width="120"></th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> {% with jobs=module.get_latest_jobs %}
{% with jobs=module.get_latest_jobs %} {% for report_name, report in module.reports.items %}
{% for report_name, report in module.reports.items %} {% with last_job=jobs|get_key:report.class_name %}
{% with last_job=jobs|get_key:report.class_name %} <tr>
<tr> <td>
<a href="{% url 'extras:report' module=module.python_name name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
</td>
<td>{{ report.description|markdown|placeholder }}</td>
{% if last_job %}
<td> <td>
<a href="{% url 'extras:report' module=module.python_name name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a> <a href="{% url 'extras:report_result' job_pk=last_job.pk %}">{{ last_job.created|annotated_date }}</a>
</td> </td>
<td>{{ report.description|markdown|placeholder }}</td>
{% if last_job %}
<td>
<a href="{% url 'extras:report_result' job_pk=last_job.pk %}">{{ last_job.created|annotated_date }}</a>
</td>
<td>
{% badge last_job.get_status_display last_job.get_status_color %}
</td>
{% else %}
<td class="text-muted">{% trans "Never" %}</td>
<td>
{% if report.is_valid %}
{{ ''|placeholder }}
{% else %}
<span class="badge text-bg-danger" title="{% trans "Report has no test methods" %}">
{% trans "Invalid" %}
</span>
{% endif %}
</td>
{% endif %}
<td> <td>
{% if perms.extras.run_report and report.is_valid %} {% badge last_job.get_status_display last_job.get_status_color %}
<div class="float-end noprint"> </td>
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post"> {% else %}
{% csrf_token %} <td class="text-muted">{% trans "Never" %}</td>
<button type="submit" name="_run" class="btn btn-primary" style="width: 110px"> <td>
{% if last_job %} {% if report.is_valid %}
<i class="mdi mdi-replay"></i> {% trans "Run Again" %} {{ ''|placeholder }}
{% else %} {% else %}
<i class="mdi mdi-play"></i> {% trans "Run Report" %} <span class="badge text-bg-danger" title="{% trans "Report has no test methods" %}">
{% endif %} {% trans "Invalid" %}
</button> </span>
</form>
</div>
{% endif %} {% endif %}
</td> </td>
{% endif %}
<td>
{% if perms.extras.run_report and report.is_valid %}
<div class="float-end noprint">
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
{% csrf_token %}
<button type="submit" name="_run" class="btn btn-primary" style="width: 110px">
{% if last_job %}
<i class="mdi mdi-replay"></i> {% trans "Run Again" %}
{% else %}
<i class="mdi mdi-play"></i> {% trans "Run Report" %}
{% endif %}
</button>
</form>
</div>
{% endif %}
</td>
</tr>
{% for method, stats in last_job.data.items %}
<tr>
<td colspan="4" class="method">
<span class="ps-3">{{ method }}</span>
</td>
<td class="text-end text-nowrap report-stats">
<span class="badge text-bg-success">{{ stats.success }}</span>
<span class="badge text-bg-info">{{ stats.info }}</span>
<span class="badge text-bg-warning">{{ stats.warning }}</span>
<span class="badge text-bg-danger">{{ stats.failure }}</span>
</td>
</tr> </tr>
{% for method, stats in last_job.data.items %} {% endfor %}
<tr> {% endwith %}
<td colspan="4" class="method"> {% endfor %}
<span class="ps-3">{{ method }}</span> {% endwith %}
</td> </tbody>
<td class="text-end text-nowrap report-stats"> </table>
<span class="badge text-bg-success">{{ stats.success }}</span> {% else %}
<span class="badge text-bg-info">{{ stats.info }}</span> <div class="alert alert-warning" role="alert">
<span class="badge text-bg-warning">{{ stats.warning }}</span> <i class="mdi mdi-alert"></i> Could not load reports from {{ module.name }}
<span class="badge text-bg-danger">{{ stats.failure }}</span> </div>
</td>
</tr>
{% endfor %}
{% endwith %}
{% endfor %}
{% endwith %}
</tbody>
</table>
{% else %}
<div class="alert alert-warning" role="alert">
<i class="mdi mdi-alert"></i> Could not load reports from {{ module.name }}
</div>
{% endif %}
</div>
</div>
{% empty %}
<div class="alert alert-info" role="alert">
<h4 class="alert-heading">{% trans "No Reports Found" %}</h4>
{% if perms.extras.add_reportmodule %}
{% url 'extras:reportmodule_add' as create_report_url %}
{% blocktrans trimmed %}
Get started by <a href="{{ create_report_url }}">creating a report</a> from an uploaded file or data source.
{% endblocktrans %}
{% endif %} {% endif %}
</div> </div>
{% endfor %} </div>
</div> {% empty %}
{% endblock content-wrapper %} <div class="alert alert-info" role="alert">
<h4 class="alert-heading">{% trans "No Reports Found" %}</h4>
{% if perms.extras.add_reportmodule %}
{% url 'extras:reportmodule_add' as create_report_url %}
{% blocktrans trimmed %}
Get started by <a href="{{ create_report_url }}">creating a report</a> from an uploaded file or data source.
{% endblocktrans %}
{% endif %}
</div>
{% endfor %}
{% endblock content %}

View File

@ -2,13 +2,13 @@
{% load buttons %} {% load buttons %}
{% load perms %} {% load perms %}
{% block content-wrapper %} {% block content %}
<div class="row p-3"> <div class="row">
<div class="col col-md-12"{% if not job.completed %} hx-get="{% url 'extras:report_result' job_pk=job.pk %}" hx-trigger="load delay:0.5s, every 5s"{% endif %}> <div class="col col-md-12"{% if not job.completed %} hx-get="{% url 'extras:report_result' job_pk=job.pk %}" hx-trigger="load delay:0.5s, every 5s"{% endif %}>
{% include 'extras/htmx/report_result.html' %} {% include 'extras/htmx/report_result.html' %}
</div> </div>
</div> </div>
{% endblock %} {% endblock content %}
{% block controls %} {% block controls %}
<div class="controls"> <div class="controls">

View File

@ -22,80 +22,78 @@
</ul> </ul>
{% endblock tabs %} {% endblock tabs %}
{% block content-wrapper %} {% block content %}
<div class="tab-content"> {% for module in script_modules %}
{% for module in script_modules %} <div class="card">
<div class="card"> <h5 class="card-header" id="module{{ module.pk }}">
<h5 class="card-header" id="module{{ module.pk }}"> {% if perms.extras.delete_scriptmodule %}
{% if perms.extras.delete_scriptmodule %} <div class="float-end">
<div class="float-end"> <a href="{% url 'extras:scriptmodule_delete' pk=module.pk %}" class="btn btn-danger">
<a href="{% url 'extras:scriptmodule_delete' pk=module.pk %}" class="btn btn-danger"> <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {% trans "Delete" %}
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {% trans "Delete" %} </a>
</a> </div>
</div> {% endif %}
{% endif %} <i class="mdi mdi-file-document-outline"></i> {{ module }}
<i class="mdi mdi-file-document-outline"></i> {{ module }} </h5>
</h5> <div class="card-body">
<div class="card-body"> {% include 'inc/sync_warning.html' with object=module %}
{% include 'inc/sync_warning.html' with object=module %} {% if not module.scripts %}
{% if not module.scripts %} <div class="alert alert-warning d-flex align-items-center" role="alert">
<div class="alert alert-warning d-flex align-items-center" role="alert"> <i class="mdi mdi-alert"></i>
<i class="mdi mdi-alert"></i> {% blocktrans trimmed with file_path=module.full_path %}
{% blocktrans trimmed with file_path=module.full_path %} Script file at <code class="mx-1">{{ file_path }}</code> could not be loaded.
Script file at <code class="mx-1">{{ file_path }}</code> could not be loaded. {% endblocktrans %}
{% endblocktrans %} </div>
</div> {% else %}
{% else %} <table class="table table-hover table-headings reports">
<table class="table table-hover table-headings reports"> <thead>
<thead> <tr>
<tr> <th width="250">{% trans "Name" %}</th>
<th width="250">{% trans "Name" %}</th> <th>{% trans "Description" %}</th>
<th>{% trans "Description" %}</th> <th>{% trans "Last Run" %}</th>
<th>{% trans "Last Run" %}</th> <th class="text-end">{% trans "Status" %}</th>
<th class="text-end">{% trans "Status" %}</th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> {% with jobs=module.get_latest_jobs %}
{% with jobs=module.get_latest_jobs %} {% for script_name, script_class in module.scripts.items %}
{% for script_name, script_class in module.scripts.items %} <tr>
<tr> <td>
<td> <a href="{% url 'extras:script' module=module.python_name name=script_name %}" name="script.{{ script_name }}">{{ script_class.name }}</a>
<a href="{% url 'extras:script' module=module.python_name name=script_name %}" name="script.{{ script_name }}">{{ script_class.name }}</a> </td>
</td> <td>
<td> {{ script_class.Meta.description|markdown|placeholder }}
{{ script_class.Meta.description|markdown|placeholder }} </td>
</td> {% with last_result=jobs|get_key:script_class.class_name %}
{% with last_result=jobs|get_key:script_class.class_name %} {% if last_result %}
{% if last_result %} <td>
<td> <a href="{% url 'extras:script_result' job_pk=last_result.pk %}">{{ last_result.created|annotated_date }}</a>
<a href="{% url 'extras:script_result' job_pk=last_result.pk %}">{{ last_result.created|annotated_date }}</a> </td>
</td> <td class="text-end">
<td class="text-end"> {% badge last_result.get_status_display last_result.get_status_color %}
{% badge last_result.get_status_display last_result.get_status_color %} </td>
</td> {% else %}
{% else %} <td class="text-muted">{% trans "Never" %}</td>
<td class="text-muted">{% trans "Never" %}</td> <td class="text-end">{{ ''|placeholder }}</td>
<td class="text-end">{{ ''|placeholder }}</td> {% endif %}
{% endif %} {% endwith %}
{% endwith %} </tr>
</tr> {% endfor %}
{% endfor %} {% endwith %}
{% endwith %} </tbody>
</tbody> </table>
</table>
{% endif %}
</div>
</div>
{% empty %}
<div class="alert alert-info">
<h4 class="alert-heading">{% trans "No Scripts Found" %}</h4>
{% if perms.extras.add_scriptmodule %}
{% url 'extras:scriptmodule_add' as create_script_url %}
{% blocktrans trimmed %}
Get started by <a href="{{ create_script_url }}">creating a script</a> from an uploaded file or data source.
{% endblocktrans %}
{% endif %} {% endif %}
</div> </div>
{% endfor %} </div>
</div> {% empty %}
{% endblock content-wrapper %} <div class="alert alert-info">
<h4 class="alert-heading">{% trans "No Scripts Found" %}</h4>
{% if perms.extras.add_scriptmodule %}
{% url 'extras:scriptmodule_add' as create_script_url %}
{% blocktrans trimmed %}
Get started by <a href="{{ create_script_url }}">creating a script</a> from an uploaded file or data source.
{% endblocktrans %}
{% endif %}
</div>
{% endfor %}
{% endblock content %}

View File

@ -36,7 +36,7 @@
</div> </div>
{% endblock controls %} {% endblock controls %}
{% block content-wrapper %} {% block tabs %}
<ul class="nav nav-tabs px-3" role="tablist"> <ul class="nav nav-tabs px-3" role="tablist">
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<a href="#log" role="tab" data-bs-toggle="tab" class="nav-link active">{% trans "Log" %}</a> <a href="#log" role="tab" data-bs-toggle="tab" class="nav-link active">{% trans "Log" %}</a>
@ -45,20 +45,21 @@
<a href="#source" role="tab" data-bs-toggle="tab" class="nav-link">{% trans "Source" %}</a> <a href="#source" role="tab" data-bs-toggle="tab" class="nav-link">{% trans "Source" %}</a>
</li> </li>
</ul> </ul>
<div class="tab-content mb-3"> {% endblock %}
<div role="tabpanel" class="tab-pane active" id="log">
<div class="row"> {% block content %}
<div class="col col-md-12"{% if not job.completed %} hx-get="{% url 'extras:script_result' job_pk=job.pk %}" hx-trigger="load delay:0.5s, every 5s"{% endif %}> <div role="tabpanel" class="tab-pane active" id="log">
{% include 'extras/htmx/script_result.html' %} <div class="row">
</div> <div class="col col-md-12"{% if not job.completed %} hx-get="{% url 'extras:script_result' job_pk=job.pk %}" hx-trigger="load delay:0.5s, every 5s"{% endif %}>
{% include 'extras/htmx/script_result.html' %}
</div> </div>
</div> </div>
<div role="tabpanel" class="tab-pane" id="source">
<p><code>{{ script.filename }}</code></p>
<pre class="block">{{ script.source }}</pre>
</div>
</div> </div>
{% endblock content-wrapper %} <div role="tabpanel" class="tab-pane" id="source">
<p><code>{{ script.filename }}</code></p>
<pre class="block">{{ script.source }}</pre>
</div>
{% endblock content %}
{% block modals %} {% block modals %}
{% include 'inc/htmx_modal.html' %} {% include 'inc/htmx_modal.html' %}

View File

@ -24,53 +24,49 @@
</ul> </ul>
{% endblock %} {% endblock %}
{% block content-wrapper %} {% block content %}
<div class="tab-content">
{% block content %}
{# Component creation form #} {# Component creation form #}
<div class="tab-pane show active" id="component-form" role="tabpanel" aria-labelledby="component-form-tab"> <div class="tab-pane show active" id="component-form" role="tabpanel" aria-labelledby="component-form-tab">
<form action="" method="post" class="form form-horizontal"> <form action="" method="post" class="form form-horizontal">
{% csrf_token %} {% csrf_token %}
{% if request.POST.return_url %} {% if request.POST.return_url %}
<input type="hidden" name="return_url" value="{{ request.POST.return_url }}" /> <input type="hidden" name="return_url" value="{{ request.POST.return_url }}" />
{% endif %} {% endif %}
{% for field in form.hidden_fields %} {% for field in form.hidden_fields %}
{{ field }} {{ field }}
{% endfor %} {% endfor %}
<div class="row"> <div class="row">
<div class="col col-md-12 col-lg-10 offset-lg-1"> <div class="col col-md-12 col-lg-10 offset-lg-1">
<div class="card"> <div class="card">
<h5 class="card-header">{{ model_name|title }} {% trans "to Add" %}</h5> <h5 class="card-header">{{ model_name|title }} {% trans "to Add" %}</h5>
<div class="card-body"> <div class="card-body">
{% for field in form.visible_fields %} {% for field in form.visible_fields %}
{% render_field field %} {% render_field field %}
{% endfor %} {% endfor %}
</div>
</div>
<div class="form-group text-end">
<div class="col col-md-12">
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
<button type="submit" name="_create" class="btn btn-primary">{% trans "Create" %}</button>
</div>
</div>
</div> </div>
</div> </div>
<div class="form-group text-end">
</form> <div class="col col-md-12">
</div> <a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
<button type="submit" name="_create" class="btn btn-primary">{% trans "Create" %}</button>
{# Selected objects list #} </div>
<div class="tab-pane" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
<div class="card">
<div class="card-body table-responsive">
{% render_table table 'inc/table.html' %}
</div> </div>
</div> </div>
</div> </div>
{% endblock %} </form>
</div> </div>
{% endblock %}
{# Selected objects list #}
<div class="tab-pane" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
<div class="card">
<div class="card-body table-responsive">
{% render_table table 'inc/table.html' %}
</div>
</div>
</div>
{% endblock content %}

View File

@ -32,105 +32,101 @@ Context:
</ul> </ul>
{% endblock tabs %} {% endblock tabs %}
{% block content-wrapper %} {% block content %}
<div class="tab-content">
{% block content %}
{# Edit form #} {# Edit form #}
<div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="edit-form-tab"> <div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="edit-form-tab">
<form action="" method="post" class="form form-horizontal mt-5"> <form action="" method="post" class="form form-horizontal mt-5">
{% csrf_token %} {% csrf_token %}
{% if request.POST.return_url %} {% if request.POST.return_url %}
<input type="hidden" name="return_url" value="{{ request.POST.return_url }}" /> <input type="hidden" name="return_url" value="{{ request.POST.return_url }}" />
{% endif %} {% endif %}
{% for field in form.hidden_fields %} {% for field in form.hidden_fields %}
{{ field }} {{ field }}
{% endfor %} {% endfor %}
{% if form.fieldsets %} {% if form.fieldsets %}
{# Render grouped fields according to declared fieldsets #} {# Render grouped fields according to declared fieldsets #}
{% for group, fields in form.fieldsets %} {% for group, fields in form.fieldsets %}
<div class="field-group mb-5"> <div class="field-group mb-5">
<div class="row"> <div class="row">
<h5 class="col-9 offset-3"> <h5 class="col-9 offset-3">
{% if group %}{{ group }}{% else %}{{ model|meta:"verbose_name"|bettertitle }}{% endif %} {% if group %}{{ group }}{% else %}{{ model|meta:"verbose_name"|bettertitle }}{% endif %}
</h5> </h5>
</div> </div>
{% for name in fields %} {% for name in fields %}
{% with field=form|getfield:name %} {% with field=form|getfield:name %}
{% if field.name in form.nullable_fields %} {% if field.name in form.nullable_fields %}
{% render_field field bulk_nullable=True %} {% render_field field bulk_nullable=True %}
{% else %} {% else %}
{% render_field field %} {% render_field field %}
{% endif %} {% endif %}
{% endwith %} {% endwith %}
{% endfor %}
</div>
{% endfor %} {% endfor %}
</div>
{% endfor %}
{# Render tag add/remove fields #} {# Render tag add/remove fields #}
{% if form.add_tags and form.remove_tags %} {% if form.add_tags and form.remove_tags %}
<div class="field-group mb-5"> <div class="field-group mb-5">
<div class="row"> <div class="row">
<h5 class="col-9 offset-3">{% trans "Tags" %}</h5> <h5 class="col-9 offset-3">{% trans "Tags" %}</h5>
</div> </div>
{% render_field form.add_tags %} {% render_field form.add_tags %}
{% render_field form.remove_tags %} {% render_field form.remove_tags %}
</div> </div>
{% endif %} {% endif %}
{# Render custom fields #} {# Render custom fields #}
{% if form.custom_fields %} {% if form.custom_fields %}
<div class="field-group mb-5"> <div class="field-group mb-5">
<div class="row"> <div class="row">
<h5 class="col-9 offset-3">{% trans "Custom Fields" %}</h5> <h5 class="col-9 offset-3">{% trans "Custom Fields" %}</h5>
</div> </div>
{% render_custom_fields form %} {% render_custom_fields form %}
</div> </div>
{% endif %} {% endif %}
{# Render comments #} {# Render comments #}
{% if form.comments %} {% if form.comments %}
<div class="field-group mb-5"> <div class="field-group mb-5">
<div class="row"> <div class="row">
<h5 class="col-9 offset-3">{% trans "Comments" %}</h5> <h5 class="col-9 offset-3">{% trans "Comments" %}</h5>
</div> </div>
{% render_field form.comments bulk_nullable=True %} {% render_field form.comments bulk_nullable=True %}
</div> </div>
{% endif %} {% endif %}
{% else %}
{# Render all fields #}
{% for field in form.visible_fields %}
{% if field.name in form.nullable_fields %}
{% render_field field bulk_nullable=True %}
{% else %} {% else %}
{% render_field field %}
{# Render all fields #}
{% for field in form.visible_fields %}
{% if field.name in form.nullable_fields %}
{% render_field field bulk_nullable=True %}
{% else %}
{% render_field field %}
{% endif %}
{% endfor %}
{% endif %} {% endif %}
{% endfor %}
<div class="text-end"> {% endif %}
<button type="submit" name="_apply" class="btn btn-primary">{% trans "Apply" %}</button>
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
</div>
</form> <div class="text-end">
<button type="submit" name="_apply" class="btn btn-primary">{% trans "Apply" %}</button>
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
</div> </div>
{# Selected objects list #} </form>
<div class="tab-pane" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
<div class="card">
<div class="card-body table-responsive">
{% render_table table 'inc/table.html' %}
</div>
</div>
</div>
{% endblock content %}
</div> </div>
{% endblock content-wrapper %}
{# Selected objects list #}
<div class="tab-pane" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
<div class="card">
<div class="card-body table-responsive">
{% render_table table 'inc/table.html' %}
</div>
</div>
</div>
{% endblock content %}

View File

@ -33,44 +33,21 @@ Context:
</ul> </ul>
{% endblock tabs %} {% endblock tabs %}
{% block content-wrapper %} {% block content %}
<div class="tab-content">
{# Data Import Form #} {# Data Import Form #}
<div class="tab-pane show active" id="import-form" role="tabpanel" aria-labelledby="import-form-tab"> <div class="tab-pane show active" id="import-form" role="tabpanel" aria-labelledby="import-form-tab">
<div class="row"> <div class="row">
<div class="col col-md-12 col-lg-10 offset-lg-1">
<form action="" method="post" enctype="multipart/form-data" class="form">
{% csrf_token %}
<input type="hidden" name="import_method" value="direct" />
{% render_field form.data %}
{% render_field form.format %}
{% render_field form.csv_delimiter %}
<div class="form-group">
<div class="col col-md-12 text-end">
<button type="submit" name="data_submit" class="btn btn-primary">{% trans "Submit" %}</button>
{% if return_url %}
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
{% endif %}
</div>
</div>
</form>
</div>
</div>
</div>
{# File Upload Form #}
<div class="tab-pane show" id="upload-form" role="tabpanel" aria-labelledby="upload-form-tab">
<div class="col col-md-12 col-lg-10 offset-lg-1"> <div class="col col-md-12 col-lg-10 offset-lg-1">
<form action="" method="post" enctype="multipart/form-data" class="form"> <form action="" method="post" enctype="multipart/form-data" class="form">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="import_method" value="upload" /> <input type="hidden" name="import_method" value="direct" />
{% render_field form.upload_file %} {% render_field form.data %}
{% render_field form.format %} {% render_field form.format %}
{% render_field form.csv_delimiter %} {% render_field form.csv_delimiter %}
<div class="form-group"> <div class="form-group">
<div class="col col-md-12 text-end"> <div class="col col-md-12 text-end">
<button type="submit" name="file_submit" class="btn btn-primary">{% trans "Submit" %}</button> <button type="submit" name="data_submit" class="btn btn-primary">{% trans "Submit" %}</button>
{% if return_url %} {% if return_url %}
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a> <a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
{% endif %} {% endif %}
@ -79,130 +56,151 @@ Context:
</form> </form>
</div> </div>
</div> </div>
{# DataFile Form #}
<div class="tab-pane show" id="datafile-form" role="tabpanel" aria-labelledby="datafile-form-tab">
<div class="col col-md-12 col-lg-10 offset-lg-1">
<form action="" method="post" enctype="multipart/form-data" class="form">
{% csrf_token %}
<input type="hidden" name="import_method" value="datafile" />
{% render_field form.data_source %}
{% render_field form.data_file %}
{% render_field form.format %}
{% render_field form.csv_delimiter %}
<div class="form-group">
<div class="col col-md-12 text-end">
<button type="submit" name="file_submit" class="btn btn-primary">{% trans "Submit" %}</button>
{% if return_url %}
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
{% endif %}
</div>
</div>
</form>
</div>
</div>
{% if fields %}
<div class="row my-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">
{% trans "Field Options" %}
</h5>
<div class="card-body">
<table class="table">
<tr>
<th>{% trans "Field" %}</th>
<th>{% trans "Required" %}</th>
<th>{% trans "Accessor" %}</th>
<th>{% trans "Description" %}</th>
</tr>
{% for name, field in fields.items %}
<tr>
<td>
<code>{% if field.required %}<strong>{% endif %}{{ name }}{% if field.required %}</strong>{% endif %}</code>
</td>
<td>
{% if field.required %}
{% checkmark True true="Required" %}
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
<td>
{% if field.to_field_name %}
<code>{{ field.to_field_name }}</code>
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
<td>
{% if field.STATIC_CHOICES %}
<button type="button" class="btn btn-link float-end" data-bs-toggle="modal" data-bs-target="#{{ name }}_choices">
<i class="mdi mdi-help-circle"></i>
</button>
<div class="modal fade" id="{{ name }}_choices" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><code>{{ name }}</code> {% trans "Choices" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table table-striped">
<tr>
<th>{% trans "Import Value" %}</th>
<th>{% trans "Label" %}</th>
</tr>
{% for value, label in field.choices %}
{% if value %}
<tr>
<td>
<samp>{{ value }}</samp>
</td>
<td>
{{ label }}
</td>
</tr>
{% endif %}
{% endfor %}
</table>
</div>
</div>
</div>
</div>
{% endif %}
{% if field.help_text %}
{{ field.help_text }}<br />
{% elif field.label %}
{{ field.label }}<br />
{% endif %}
{% if field|widget_type == 'dateinput' %}
<small class="text-muted">{% trans "Format: YYYY-MM-DD" %}</small>
{% elif field|widget_type == 'checkboxinput' %}
<small class="text-muted">{% trans "Specify true or false" %}</small>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
</div>
<p class="small text-muted">
<i class="mdi mdi-check-bold text-success"></i>
{% blocktrans trimmed %}
Required fields <strong>must</strong> be specified for all objects.
{% endblocktrans %}
</p>
<p class="small text-muted">
<i class="mdi mdi-information-outline"></i>
{% blocktrans trimmed with example="vrf.rd" %}
Related objects may be referenced by any unique attribute. For example, <code>{{ example }}</code> would identify a VRF by its route distinguisher.
{% endblocktrans %}
</p>
{% endif %}
</div> </div>
{% endblock content-wrapper %}
{# File Upload Form #}
<div class="tab-pane show" id="upload-form" role="tabpanel" aria-labelledby="upload-form-tab">
<div class="col col-md-12 col-lg-10 offset-lg-1">
<form action="" method="post" enctype="multipart/form-data" class="form">
{% csrf_token %}
<input type="hidden" name="import_method" value="upload" />
{% render_field form.upload_file %}
{% render_field form.format %}
{% render_field form.csv_delimiter %}
<div class="form-group">
<div class="col col-md-12 text-end">
<button type="submit" name="file_submit" class="btn btn-primary">{% trans "Submit" %}</button>
{% if return_url %}
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
{% endif %}
</div>
</div>
</form>
</div>
</div>
{# DataFile Form #}
<div class="tab-pane show" id="datafile-form" role="tabpanel" aria-labelledby="datafile-form-tab">
<div class="col col-md-12 col-lg-10 offset-lg-1">
<form action="" method="post" enctype="multipart/form-data" class="form">
{% csrf_token %}
<input type="hidden" name="import_method" value="datafile" />
{% render_field form.data_source %}
{% render_field form.data_file %}
{% render_field form.format %}
{% render_field form.csv_delimiter %}
<div class="form-group">
<div class="col col-md-12 text-end">
<button type="submit" name="file_submit" class="btn btn-primary">{% trans "Submit" %}</button>
{% if return_url %}
<a href="{{ return_url }}" class="btn btn-outline-danger">{% trans "Cancel" %}</a>
{% endif %}
</div>
</div>
</form>
</div>
</div>
{% if fields %}
<div class="row my-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">
{% trans "Field Options" %}
</h5>
<div class="card-body">
<table class="table">
<tr>
<th>{% trans "Field" %}</th>
<th>{% trans "Required" %}</th>
<th>{% trans "Accessor" %}</th>
<th>{% trans "Description" %}</th>
</tr>
{% for name, field in fields.items %}
<tr>
<td>
<code>{% if field.required %}<strong>{% endif %}{{ name }}{% if field.required %}</strong>{% endif %}</code>
</td>
<td>
{% if field.required %}
{% checkmark True true="Required" %}
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
<td>
{% if field.to_field_name %}
<code>{{ field.to_field_name }}</code>
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
<td>
{% if field.STATIC_CHOICES %}
<button type="button" class="btn btn-link float-end" data-bs-toggle="modal" data-bs-target="#{{ name }}_choices">
<i class="mdi mdi-help-circle"></i>
</button>
<div class="modal fade" id="{{ name }}_choices" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><code>{{ name }}</code> {% trans "Choices" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table table-striped">
<tr>
<th>{% trans "Import Value" %}</th>
<th>{% trans "Label" %}</th>
</tr>
{% for value, label in field.choices %}
{% if value %}
<tr>
<td>
<samp>{{ value }}</samp>
</td>
<td>
{{ label }}
</td>
</tr>
{% endif %}
{% endfor %}
</table>
</div>
</div>
</div>
</div>
{% endif %}
{% if field.help_text %}
{{ field.help_text }}<br />
{% elif field.label %}
{{ field.label }}<br />
{% endif %}
{% if field|widget_type == 'dateinput' %}
<small class="text-muted">{% trans "Format: YYYY-MM-DD" %}</small>
{% elif field|widget_type == 'checkboxinput' %}
<small class="text-muted">{% trans "Specify true or false" %}</small>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
</div>
<p class="small text-muted">
<i class="mdi mdi-check-bold text-success"></i>
{% blocktrans trimmed %}
Required fields <strong>must</strong> be specified for all objects.
{% endblocktrans %}
</p>
<p class="small text-muted">
<i class="mdi mdi-information-outline"></i>
{% blocktrans trimmed with example="vrf.rd" %}
Related objects may be referenced by any unique attribute. For example, <code>{{ example }}</code> would identify a VRF by its route distinguisher.
{% endblocktrans %}
</p>
{% endif %}
{% endblock content %}

View File

@ -45,46 +45,43 @@ Context:
</ul> </ul>
{% endblock tabs %} {% endblock tabs %}
{% block content-wrapper %} {% block content %}
<div class="tab-content"> <div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="object-list-tab">
<div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="object-list-tab">
{# Warn about missing prerequisite objects #} {# Warn about missing prerequisite objects #}
{% if prerequisite_model %} {% if prerequisite_model %}
{% include 'inc/missing_prerequisites.html' %} {% include 'inc/missing_prerequisites.html' %}
{% endif %} {% endif %}
<form action="" method="post" enctype="multipart/form-data" class="form-object-edit mt-5"> <form action="" method="post" enctype="multipart/form-data" class="form-object-edit mt-5">
{% csrf_token %} {% csrf_token %}
<div id="form_fields"> <div id="form_fields">
{% block form %} {% block form %}
{% include 'htmx/form.html' %} {% include 'htmx/form.html' %}
{% endblock form %} {% endblock form %}
</div> </div>
<div class="text-end my-3"> <div class="text-end my-3">
{% block buttons %} {% block buttons %}
<a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a> <a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
{% if object.pk %} {% if object.pk %}
<button type="submit" name="_update" class="btn btn-primary"> <button type="submit" name="_update" class="btn btn-primary">
{% trans "Save" %} {% trans "Save" %}
</button> </button>
{% else %} {% else %}
<button type="submit" name="_create" class="btn btn-primary"> <button type="submit" name="_create" class="btn btn-primary">
{% trans "Create" %} {% trans "Create" %}
</button> </button>
<button type="submit" name="_addanother" class="btn btn-outline-primary"> <button type="submit" name="_addanother" class="btn btn-outline-primary">
{% trans "Create & Add Another" %} {% trans "Create & Add Another" %}
</button> </button>
{% endif %} {% endif %}
{% endblock buttons %} {% endblock buttons %}
</div> </div>
</form> </form>
</div>
</div> </div>
{% endblock content %}
{% endblock content-wrapper %}
{% block modals %} {% block modals %}
{% include 'inc/htmx_modal.html' with size='lg' %} {% include 'inc/htmx_modal.html' with size='lg' %}