Clean up HTML templates

This commit is contained in:
Jeremy Stretch 2024-01-31 10:06:45 -05:00
parent 22ae06acc8
commit 66a017368c
9 changed files with 254 additions and 272 deletions

View File

@ -275,7 +275,7 @@ class BackgroundQueueListView(UserPassesTestMixin, View):
def get(self, request): def get(self, request):
table = tables.BackgroundQueueTable(get_statistics(run_maintenance_tasks=True)["queues"], user=request.user) table = tables.BackgroundQueueTable(get_statistics(run_maintenance_tasks=True)["queues"], user=request.user)
table.configure(request) table.configure(request)
return render(request, 'core/background_queue_list.html', { return render(request, 'core/rq_queue_list.html', {
'table': table, 'table': table,
}) })
@ -340,7 +340,7 @@ class BackgroundTaskListView(BaseTaskListView):
'status': status, 'status': status,
}) })
return render(request, 'core/background_task_list.html', { return render(request, 'core/rq_task_list.html', {
'table': table, 'table': table,
'queue': queue, 'queue': queue,
'status': status, 'status': status,
@ -377,7 +377,7 @@ class WorkerListView(BaseTaskListView):
'queue': queue, 'queue': queue,
}) })
return render(request, 'core/worker_list.html', { return render(request, 'core/rq_worker_list.html', {
'table': table, 'table': table,
'queue': queue, 'queue': queue,
}) })
@ -404,7 +404,7 @@ class BackgroundTaskDetailView(UserPassesTestMixin, View):
except AttributeError: except AttributeError:
exc_info = None exc_info = None
return render(request, 'core/background_task.html', { return render(request, 'core/rq_task.html', {
'queue': queue, 'queue': queue,
'job': job, 'job': job,
'queue_index': queue_index, 'queue_index': queue_index,
@ -551,7 +551,7 @@ class WorkerDetailView(UserPassesTestMixin, View):
# Convert microseconds to milliseconds # Convert microseconds to milliseconds
worker.total_working_time = worker.total_working_time / 1000 worker.total_working_time = worker.total_working_time / 1000
return render(request, 'core/worker.html', { return render(request, 'core/rq_worker.html', {
'worker': worker, 'worker': worker,
'job': worker.get_current_job(), 'job': worker.get_current_job(),
'total_working_time': worker.total_working_time * 1000, 'total_working_time': worker.total_working_time * 1000,

View File

@ -1,113 +0,0 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load buttons %}
{% load helpers %}
{% load render_table from django_tables2 %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'core:background_queue_list' %}">{% trans 'Background Tasks' %}</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:background_task_list' queue_index=queue_index status=job.get_status %}">{{ queue.name }}</a></li>
{% endblock breadcrumbs %}
{% block title %}{% trans "Job" %} {{ job.id }}{% endblock %}
{% block object_identifier %}{% endblock %}
{% block controls %}
<div class="btn-list mb-2">
{% url 'core:background_task_delete' job_id=job.id as delete_url %}
{% include "buttons/delete.html" with url=delete_url %}
{% if job.is_started %}
<a href="{% url 'core:background_task_stop' job.id %}" class="btn btn-primary">
<i class="mdi mdi-stop-circle-outline"></i> {% trans "Stop" %}
</a>
{% endif %}
{% if job.is_failed %}
<a href="{% url 'core:background_task_requeue' job.id %}" class="btn btn-primary">
<i class="mdi mdi-sync"></i> {% trans "Requeue" %}
</a>
{% endif %}
{% if not job.is_queued and not job.is_failed %}
<a href="{% url 'core:background_task_enqueue' job.id %}" class="btn btn-primary">
<i class="mdi mdi-sync"></i> {% trans "Enqueue" %}
</a>
{% endif %}
</div>
{% endblock controls %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
<li class="nav-item" role="presentation">
<a class="nav-link active" role="tab">{% trans "Job" %}</a>
</li>
</ul>
{% endblock tabs %}
{% block content %}
<div class="row">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Job" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Queue" %}</th>
<td>{{ job.origin|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Timeout" %}</th>
<td>{{ job.timeout|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Result TTL" %}</th>
<td>{{ job.result_ttl|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Created" %}</th>
<td>{{ job.created_at|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "Queued" %}</th>
<td>{{ job.enqueued_at|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "Status" %}</th>
<td>{{ job.get_status|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Callable" %}</th>
<td>{{ object.get_type_display|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Meta" %}</th>
<td>{{ job.meta|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Args" %}</th>
<td>{{ jobs.args|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Kwargs" %}</th>
<td>{{ job.kwargs|placeholder }}</td>
</tr>
{% if dependency_id %}
<tr>
<th scope="row">{% trans "Depends on" %}</th>
<td><a href="{% url 'core:background_task' job.id %}">{{ dependency_id }}</a></td>
</tr>
{% endif %}
{% if exc_info %}
<tr>
<th scope="row">{% trans "Exception" %}</th>
<td><pre>{% if job.exc_info %}{{ job.exc_info|linebreaks }}{% endif %}</pre></td>
</tr>
{% endif %}
</table>
</div>
</div>
</div>
</div>
{% endblock content %}

View File

@ -1,18 +0,0 @@
{% extends 'generic/_base.html' %}
{% load helpers %}
{% load form_helpers %}
{% load i18n %}
{% block title %}
{% trans "Delete" %} {{ object_name }}?
{% endblock %}
{% block content %}
<div class="modal" tabindex="-1" style="display: block; position: static">
<div class="modal-dialog">
<div class="modal-content" >
{% include 'core/htmx/delete_form.html' %}
</div>
</div>
</div>
{% endblock %}

View File

@ -1,14 +1,17 @@
{% extends 'generic/_base.html' %} {% extends 'generic/object_list.html' %}
{% load helpers %}
{% load i18n %} {% load i18n %}
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% block title %}{% trans "Background Tasks" %}{% endblock %} {% block title %}{% trans "Background Queues" %}{% endblock %}
{% block controls %}{% endblock %}
{% block tabs %} {% block tabs %}
<ul class="nav nav-tabs px-3"> <ul class="nav nav-tabs">
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<a class="nav-link active" role="tab">{% trans "Background Tasks" %}</a> <a class="nav-link active" role="tab">
{% trans "Background Queues" %} {% badge table.rows|length %}
</a>
</li> </li>
</ul> </ul>
{% endblock tabs %} {% endblock tabs %}
@ -29,7 +32,3 @@
{% render_table table %} {% render_table table %}
</div> </div>
{% endblock content %} {% endblock content %}
{% block modals %}
{% table_config_form table table_name="ObjectTable" %}
{% endblock modals %}

View File

@ -0,0 +1,117 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load buttons %}
{% load helpers %}
{% load render_table from django_tables2 %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'core:background_queue_list' %}">{% trans 'Background Tasks' %}</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:background_task_list' queue_index=queue_index status=job.get_status %}">{{ queue.name }}</a></li>
{% endblock breadcrumbs %}
{% block title %}{% trans "Job" %} {{ job.id }}{% endblock %}
{% block subtitle %}
<div class="text-secondary fs-5">
<span>{% trans "Created" %} {{ job.created_at|annotated_date }}</span>
</div>
{% endblock subtitle %}
{% block object_identifier %}{% endblock %}
{% block controls %}
<div class="btn-list mb-2">
{% url 'core:background_task_delete' job_id=job.id as delete_url %}
{% include "buttons/delete.html" with url=delete_url %}
{% if job.is_started %}
<a href="{% url 'core:background_task_stop' job.id %}" class="btn btn-primary">
<i class="mdi mdi-stop-circle-outline"></i> {% trans "Stop" %}
</a>
{% endif %}
{% if job.is_failed %}
<a href="{% url 'core:background_task_requeue' job.id %}" class="btn btn-primary">
<i class="mdi mdi-sync"></i> {% trans "Requeue" %}
</a>
{% endif %}
{% if not job.is_queued and not job.is_failed %}
<a href="{% url 'core:background_task_enqueue' job.id %}" class="btn btn-primary">
<i class="mdi mdi-sync"></i> {% trans "Enqueue" %}
</a>
{% endif %}
</div>
{% endblock controls %}
{% block tabs %}
<ul class="nav nav-tabs">
<li class="nav-item" role="presentation">
<a class="nav-link active" role="tab">{% trans "Job" %}</a>
</li>
</ul>
{% endblock tabs %}
{% block content %}
<div class="row">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Job" %}</h5>
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Queue" %}</th>
<td>{{ job.origin|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Timeout" %}</th>
<td>{{ job.timeout|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Result TTL" %}</th>
<td>{{ job.result_ttl|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Created" %}</th>
<td>{{ job.created_at|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "Queued" %}</th>
<td>{{ job.enqueued_at|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "Status" %}</th>
<td>{{ job.get_status|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Callable" %}</th>
<td>{{ object.get_type_display|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Meta" %}</th>
<td>{{ job.meta|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Arguments" %}</th>
<td>{{ jobs.args|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Keyword Arguments" %}</th>
{# TODO: Render as formatted JSON #}
<td>{{ job.kwargs }}</td>
</tr>
{% if dependency_id %}
<tr>
<th scope="row">{% trans "Depends on" %}</th>
<td><a href="{% url 'core:background_task' job.id %}">{{ dependency_id }}</a></td>
</tr>
{% endif %}
{% if exc_info %}
<tr>
<th scope="row">{% trans "Exception" %}</th>
<td><pre>{% if job.exc_info %}{{ job.exc_info|linebreaks }}{% endif %}</pre></td>
</tr>
{% endif %}
</table>
</div>
</div>
</div>
{% endblock content %}

View File

@ -1,25 +1,34 @@
{% extends 'generic/_base.html' %} {% extends 'generic/object_list.html' %}
{% load buttons %} {% load buttons %}
{% load helpers %} {% load helpers %}
{% load i18n %} {% load i18n %}
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% block page-header %} {% block page-header %}
<div class="d-flex justify-content-between align-items-center"> <div class="container-xl">
{# Breadcrumbs #} <div class="d-flex justify-content-between align-items-center mt-2">
<nav class="breadcrumb-container px-3" aria-label="breadcrumb"> {# Breadcrumbs #}
<ol class="breadcrumb"> <nav class="breadcrumb-container" aria-label="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'core:background_queue_list' %}">{% trans 'Background Tasks' %}</a></li> <ol class="breadcrumb">
</ol> <li class="breadcrumb-item">
</nav> <a href="{% url 'core:background_queue_list' %}">{% trans 'Background Queues' %}</a>
</li>
<li class="breadcrumb-item">{{ queue.name }}</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col">
<h2 class="page-title mt-2">{% trans 'Background Tasks' %}</h2>
</div>
</div>
</div> </div>
{{ block.super }}
{% endblock page-header %} {% endblock page-header %}
{% block title %}{{ status|capfirst }} {% trans "Jobs in " %}{{ queue.name }}{% endblock %} {% block title %}{{ status|capfirst }} {% trans "tasks in " %}{{ queue.name }}{% endblock %}
{% block tabs %} {% block tabs %}
<ul class="nav nav-tabs px-3"> <ul class="nav nav-tabs" role="tablist">
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<a class="nav-link active" role="tab">{% trans "Queued Jobs" %}</a> <a class="nav-link active" role="tab">{% trans "Queued Jobs" %}</a>
</li> </li>
@ -27,28 +36,6 @@
{% endblock tabs %} {% endblock tabs %}
{% block content %} {% block content %}
{% comment %}
<div class="row mb-3">
<div class="col-auto ms-auto d-print-none">
{# Table configuration button #}
<div class="table-configure input-group">
<button type="button" data-bs-toggle="modal" title="{% trans "Configure Table" %}" data-bs-target="#ObjectTable_config" class="btn">
<i class="mdi mdi-cog"></i> {% trans "Configure Table" %}
</button>
</div>
</div>
</div>
{# Objects table #}
<div class="card">
<div class="htmx-container table-responsive" id="object_list">
{% include 'htmx/table.html' %}
</div>
</div>
{# /Objects table #}
{% endcomment %}
{# Object list tab #} {# Object list tab #}
<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">
@ -115,7 +102,3 @@
{# /Object list tab #} {# /Object list tab #}
{% endblock content %} {% endblock content %}
{% block modals %}
{% table_config_form table table_name="ObjectTable" %}
{% endblock modals %}

View File

@ -0,0 +1,83 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load render_table from django_tables2 %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'core:background_queue_list' %}">{% trans 'Background Tasks' %}</a></li>
{# <li class="breadcrumb-item"><a href="{% url 'core:background_task_list' queue_index=queue_index status=job.get_status %}">{{ queue.name }}</a></li> #}
{% endblock breadcrumbs %}
{% block title %}{% trans "Worker Info" %} {{ job.id }}{% endblock %}
{% block subtitle %}
<div class="text-secondary fs-5">
<span>{% trans "Created" %} {{ worker.birth_date|annotated_date }}</span>
</div>
{% endblock subtitle %}
{% block object_identifier %}{% endblock %}
{% block controls %}
<div class="controls">
<div class="control-group">
{% block extra_controls %}{% endblock %}
</div>
</div>
{% endblock controls %}
{% block tabs %}
<ul class="nav nav-tabs">
<li class="nav-item" role="presentation">
<a class="nav-link active" role="tab">{% trans "Worker" %}</a>
</li>
</ul>
{% endblock tabs %}
{% block content %}
<div class="row">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Worker" %}</h5>
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<td>{{ worker.name|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "State" %}</th>
<td>{{ worker.get_state|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Birth" %}</th>
<td>{{ worker.birth_date|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "Queues" %}</th>
<td>{{ worker.queue_names|join:", " }}</td>
</tr>
<tr>
<th scope="row">{% trans "PID" %}</th>
<td>{{ worker.pid|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Curent Job" %}</th>
<td>{{ job.func_name|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Successful job count" %}</th>
<td>{{ worker.successful_job_count|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Failed job count" %}</th>
<td>{{ worker.failed_job_count }}</td>
</tr>
<tr>
<th scope="row">{% trans "Total working time (seconds)" %}</th>
<td>{{ total_working_time }}</td>
</tr>
</table>
</div>
</div>
</div>
{% endblock content %}

View File

@ -1,24 +1,35 @@
{% extends 'generic/_base.html' %} {% extends 'generic/object_list.html' %}
{% load helpers %} {% load helpers %}
{% load i18n %} {% load i18n %}
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% block page-header %} {% block page-header %}
<div class="d-flex justify-content-between align-items-center"> <div class="container-xl">
{# Breadcrumbs #} <div class="d-flex justify-content-between align-items-center mt-2">
<nav class="breadcrumb-container px-3" aria-label="breadcrumb"> {# Breadcrumbs #}
<ol class="breadcrumb"> <nav class="breadcrumb-container" aria-label="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'core:background_queue_list' %}">{% trans 'Background Tasks' %}</a></li> <ol class="breadcrumb">
</ol> <li class="breadcrumb-item">
</nav> <a href="{% url 'core:background_queue_list' %}">{% trans 'Background Workers' %}</a>
</li>
<li class="breadcrumb-item">{{ queue.name }}</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col">
<h2 class="page-title mt-2">{% trans 'Background Workers' %}</h2>
</div>
</div>
</div> </div>
{{ block.super }}
{% endblock page-header %} {% endblock page-header %}
{% block title %}{{ status|capfirst }} {% trans "Workers in " %}{{ queue.name }}{% endblock %} {% block title %}{{ status|capfirst }} {% trans "Workers in " %}{{ queue.name }}{% endblock %}
{% block controls %}{% endblock %}
{% block tabs %} {% block tabs %}
<ul class="nav nav-tabs px-3"> <ul class="nav nav-tabs">
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<a class="nav-link active" role="tab">{% trans "Workers" %}</a> <a class="nav-link active" role="tab">{% trans "Workers" %}</a>
</li> </li>

View File

@ -1,80 +0,0 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load render_table from django_tables2 %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'core:background_queue_list' %}">{% trans 'Background Tasks' %}</a></li>
{# <li class="breadcrumb-item"><a href="{% url 'core:background_task_list' queue_index=queue_index status=job.get_status %}">{{ queue.name }}</a></li> #}
{% endblock breadcrumbs %}
{% block title %}{% trans "Worker Info" %} {{ job.id }}{% endblock %}
{% block object_identifier %}{% endblock %}
{% block controls %}
<div class="controls">
<div class="control-group">
{% block extra_controls %}{% endblock %}
</div>
</div>
{% endblock controls %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
<li class="nav-item" role="presentation">
<a class="nav-link active" role="tab">{% trans "Worker" %}</a>
</li>
</ul>
{% endblock tabs %}
{% block content %}
<div class="row">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Worker" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<td>{{ worker.name|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "State" %}</th>
<td>{{ worker.get_state|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Birth" %}</th>
<td>{{ worker.birth_date|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "Queues" %}</th>
<td>{{ queue_names|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "PID" %}</th>
<td>{{ worker.pid|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Curent Job" %}</th>
<td>{{ job.func_name|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Successful job count" %}</th>
<td>{{ worker.successful_job_count|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Failed job count" %}</th>
<td>{{ worker.failed_job_count }}</td>
</tr>
<tr>
<th scope="row">{% trans "Total working time (seconds)" %}</th>
<td>{{ total_working_time }}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
{% endblock content %}