style(templates): Refactor HTML structure for improved readability and consistency

This commit is contained in:
Ross
2026-05-18 11:16:26 +01:00
parent 026350f9d4
commit dbf0fc262c
6 changed files with 333 additions and 334 deletions
+13 -13
View File
@@ -5,19 +5,19 @@
{% block content %} {% block content %}
<div class="container-fluid"> <div class="container-fluid">
<div class="d-flex align-items-start justify-content-between mb-3"> <div class="d-flex align-items-start justify-content-between mb-3">
<h2 class="mb-0">Collections</h2> <h2 class="mb-0">Collections</h2>
{% if request.user.is_staff %} {% if request.user.is_staff %}
<a class="btn btn-sm btn-primary" href="{% url 'atlas:exam_create' %}">Create collection</a> <a class="btn btn-sm btn-primary" href="{% url 'atlas:exam_create' %}">Create collection</a>
{% endif %} {% endif %}
</div>
<p class="mb-3">Manage and browse case collections. Use filters to narrow results.</p>
{% render_table table %}
{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
</div> </div>
<p class="mb-3">Manage and browse case collections. Use filters to narrow results.</p>
{% render_table table %}
{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
</div>
{% endblock %} {% endblock %}
+21 -22
View File
@@ -34,42 +34,41 @@
{% render_table table %} {% render_table table %}
</div> </div>
<script> <script>
document.getElementById('bulk-delete-form').addEventListener('submit', function(e) { document.getElementById('bulk-delete-form').addEventListener('submit', function(e) {
// Remove any previously added hidden inputs // Remove any previously added hidden inputs
document.querySelectorAll('#bulk-delete-form input[name="series_ids"]').forEach(el => el.remove()); document.querySelectorAll('#bulk-delete-form input[name="series_ids"]').forEach(el => el.remove());
// Find all checked checkboxes // Find all checked checkboxes
const checked = document.querySelectorAll('input[name="selection"]:checked'); const checked = document.querySelectorAll('input[name="selection"]:checked');
if (checked.length === 0) { if (checked.length === 0) {
alert("Please select at least one series to delete."); alert("Please select at least one series to delete.");
e.preventDefault(); e.preventDefault();
return false; return false;
} }
// Add hidden inputs for each checked series // Add hidden inputs for each checked series
checked.forEach(cb => { checked.forEach(cb => {
const hidden = document.createElement('input'); const hidden = document.createElement('input');
hidden.type = 'hidden'; hidden.type = 'hidden';
hidden.name = 'series_ids'; hidden.name = 'series_ids';
hidden.value = cb.value; hidden.value = cb.value;
this.appendChild(hidden); this.appendChild(hidden);
}); });
}); });
</script> </script>
<div id="exam-options"></div> <div id="exam-options"></div>
{% endblock %} {% endblock %}
{% block js %} {% block js %}
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
}); });
</script> </script>
{% endblock %} {% endblock %}
{% block css %} {% block css %}
<style> <style>
</style> </style>
{% endblock css %} {% endblock css %}
+189 -189
View File
@@ -5,199 +5,199 @@
{% block content_container_class %}container-fluid content-wide px-3{% endblock %} {% block content_container_class %}container-fluid content-wide px-3{% endblock %}
{% block title %} {% block title %}
Atlas Task Overview Atlas Task Overview
{% endblock title %} {% endblock title %}
{% block content %} {% block content %}
<div class="container-fluid py-3 px-3"> <div class="container-fluid py-3 px-3">
<style> <style>
.task-overview-table { .task-overview-table {
min-width: 1650px; min-width: 1650px;
}
.task-overview-table th,
.task-overview-table td {
white-space: nowrap;
vertical-align: middle;
}
.task-overview-table .task-col,
.task-overview-table .generated-col,
.task-overview-table .error-col,
.task-overview-table .actions-col {
white-space: normal;
}
.task-overview-table .generated-col {
min-width: 220px;
}
</style>
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2 mb-3">
<h2 class="h4 mb-0">Atlas Task Overview</h2>
<div class="d-flex gap-2">
<a class="btn btn-outline-secondary btn-sm" href="?status=all">All</a>
<a class="btn btn-outline-warning btn-sm" href="?status=active">Active</a>
<a class="btn btn-outline-success btn-sm" href="?status=completed">Completed</a>
<a class="btn btn-outline-danger btn-sm" href="?status=failed">Failed</a>
</div>
</div>
{% if backend_missing %}
<div class="alert alert-warning">
django_tasks_db backend is not available in this environment. Install and migrate it to see task records.
</div>
{% endif %}
<div class="row g-2 mb-3">
<div class="col-md-4">
<div class="card border-warning">
<div class="card-body py-2">
<div class="small text-muted">Active</div>
<div class="h4 mb-0 text-warning">{{ counts.active }}</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card border-success">
<div class="card-body py-2">
<div class="small text-muted">Completed</div>
<div class="h4 mb-0 text-success">{{ counts.completed }}</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card border-danger">
<div class="card-body py-2">
<div class="small text-muted">Failed</div>
<div class="h4 mb-0 text-danger">{{ counts.failed }}</div>
</div>
</div>
</div>
</div>
<form method="post" class="mb-3">
{% csrf_token %}
<div class="d-flex flex-wrap align-items-center gap-2 mb-2">
<select class="form-select form-select-sm" name="task_action" style="max-width: 320px;">
<option value="">Choose task action...</option>
<option value="reset_failed">Reset FAILED to READY</option>
<option value="reset_selected">Reset selected to READY (skip RUNNING)</option>
<option value="delete_completed">Delete selected COMPLETED</option>
<option value="delete_failed">Delete selected FAILED</option>
<option value="delete_selected_all">Delete ALL selected (including RUNNING)</option>
</select>
<button type="submit" class="btn btn-sm btn-primary">Apply to selected</button>
<div class="form-check ms-2">
<input class="form-check-input" type="checkbox" id="select-all-tasks">
<label class="form-check-label small" for="select-all-tasks">Select all</label>
</div>
</div>
<div class="table-responsive">
<table class="table table-sm table-striped align-middle task-overview-table">
<thead>
<tr>
<th style="width: 36px;"></th>
<th class="task-col">Task</th>
<th>Status</th>
<th class="generated-col">Generated Series</th>
<th>Queue</th>
<th>Enqueued</th>
<th>Started</th>
<th>Finished</th>
<th>Worker</th>
<th class="error-col">Error</th>
<th class="actions-col">Actions</th>
</tr>
</thead>
<tbody>
{% for task in tasks %}
<tr>
<td>
<input class="form-check-input task-select" type="checkbox" name="task_ids" value="{{ task.id }}">
</td>
<td class="task-col">
<div class="small fw-semibold">{{ task.task_path }}</div>
<div class="small text-muted">{{ task.id }}</div>
</td>
<td>
{% if task.status == "FAILED" %}
<span class="badge bg-danger">{{ task.status }}</span>
{% elif task.status == "SUCCESSFUL" %}
<span class="badge bg-success">{{ task.status }}</span>
{% elif task.status == "RUNNING" or task.status == "READY" %}
<span class="badge bg-warning text-dark">{{ task.status }}</span>
{% else %}
<span class="badge bg-secondary">{{ task.status }}</span>
{% endif %}
</td>
<td class="small generated-col">
{% if task.generated_series %}
{% for series in task.generated_series %}
<a class="d-block" target="_blank" href="{{ series.url }}">{{ series.description }}</a>
{% endfor %}
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
<td>{{ task.queue_name }}</td>
<td class="small">{{ task.enqueued_at|date:"Y-m-d H:i:s" }}</td>
<td class="small">{{ task.started_at|date:"Y-m-d H:i:s" }}</td>
<td class="small">{{ task.finished_at|date:"Y-m-d H:i:s" }}</td>
<td class="small">{{ task.worker_ids }}</td>
<td class="small text-danger error-col">{{ task.exception_class_path|default:"" }}</td>
<td class="small actions-col">
{% if task.traceback %}
<button
class="btn btn-outline-danger btn-sm"
type="button"
data-bs-toggle="collapse"
data-bs-target="#traceback-{{ task.id }}"
aria-expanded="false"
aria-controls="traceback-{{ task.id }}"
>
View full traceback
</button>
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
</tr>
{% if task.traceback %}
<tr class="collapse" id="traceback-{{ task.id }}">
<td></td>
<td colspan="10">
<div class="border rounded bg-dark-subtle p-2">
<div class="small fw-semibold mb-1">Full traceback</div>
<pre class="small mb-0" style="white-space: pre-wrap;">{{ task.traceback }}</pre>
</div>
</td>
</tr>
{% endif %}
{% empty %}
<tr>
<td colspan="11" class="text-muted">No tasks found for this filter.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</form>
<script>
(function () {
const selectAll = document.getElementById('select-all-tasks');
const rows = Array.from(document.querySelectorAll('.task-select'));
if (!selectAll || !rows.length) {
return;
} }
selectAll.addEventListener('change', function () { .task-overview-table th,
rows.forEach((cb) => { .task-overview-table td {
cb.checked = selectAll.checked; white-space: nowrap;
vertical-align: middle;
}
.task-overview-table .task-col,
.task-overview-table .generated-col,
.task-overview-table .error-col,
.task-overview-table .actions-col {
white-space: normal;
}
.task-overview-table .generated-col {
min-width: 220px;
}
</style>
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2 mb-3">
<h2 class="h4 mb-0">Atlas Task Overview</h2>
<div class="d-flex gap-2">
<a class="btn btn-outline-secondary btn-sm" href="?status=all">All</a>
<a class="btn btn-outline-warning btn-sm" href="?status=active">Active</a>
<a class="btn btn-outline-success btn-sm" href="?status=completed">Completed</a>
<a class="btn btn-outline-danger btn-sm" href="?status=failed">Failed</a>
</div>
</div>
{% if backend_missing %}
<div class="alert alert-warning">
django_tasks_db backend is not available in this environment. Install and migrate it to see task records.
</div>
{% endif %}
<div class="row g-2 mb-3">
<div class="col-md-4">
<div class="card border-warning">
<div class="card-body py-2">
<div class="small text-muted">Active</div>
<div class="h4 mb-0 text-warning">{{ counts.active }}</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card border-success">
<div class="card-body py-2">
<div class="small text-muted">Completed</div>
<div class="h4 mb-0 text-success">{{ counts.completed }}</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card border-danger">
<div class="card-body py-2">
<div class="small text-muted">Failed</div>
<div class="h4 mb-0 text-danger">{{ counts.failed }}</div>
</div>
</div>
</div>
</div>
<form method="post" class="mb-3">
{% csrf_token %}
<div class="d-flex flex-wrap align-items-center gap-2 mb-2">
<select class="form-select form-select-sm" name="task_action" style="max-width: 320px;">
<option value="">Choose task action...</option>
<option value="reset_failed">Reset FAILED to READY</option>
<option value="reset_selected">Reset selected to READY (skip RUNNING)</option>
<option value="delete_completed">Delete selected COMPLETED</option>
<option value="delete_failed">Delete selected FAILED</option>
<option value="delete_selected_all">Delete ALL selected (including RUNNING)</option>
</select>
<button type="submit" class="btn btn-sm btn-primary">Apply to selected</button>
<div class="form-check ms-2">
<input class="form-check-input" type="checkbox" id="select-all-tasks">
<label class="form-check-label small" for="select-all-tasks">Select all</label>
</div>
</div>
<div class="table-responsive">
<table class="table table-sm table-striped align-middle task-overview-table">
<thead>
<tr>
<th style="width: 36px;"></th>
<th class="task-col">Task</th>
<th>Status</th>
<th class="generated-col">Generated Series</th>
<th>Queue</th>
<th>Enqueued</th>
<th>Started</th>
<th>Finished</th>
<th>Worker</th>
<th class="error-col">Error</th>
<th class="actions-col">Actions</th>
</tr>
</thead>
<tbody>
{% for task in tasks %}
<tr>
<td>
<input class="form-check-input task-select" type="checkbox" name="task_ids" value="{{ task.id }}">
</td>
<td class="task-col">
<div class="small fw-semibold">{{ task.task_path }}</div>
<div class="small text-muted">{{ task.id }}</div>
</td>
<td>
{% if task.status == "FAILED" %}
<span class="badge bg-danger">{{ task.status }}</span>
{% elif task.status == "SUCCESSFUL" %}
<span class="badge bg-success">{{ task.status }}</span>
{% elif task.status == "RUNNING" or task.status == "READY" %}
<span class="badge bg-warning text-dark">{{ task.status }}</span>
{% else %}
<span class="badge bg-secondary">{{ task.status }}</span>
{% endif %}
</td>
<td class="small generated-col">
{% if task.generated_series %}
{% for series in task.generated_series %}
<a class="d-block" target="_blank" href="{{ series.url }}">{{ series.description }}</a>
{% endfor %}
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
<td>{{ task.queue_name }}</td>
<td class="small">{{ task.enqueued_at|date:"Y-m-d H:i:s" }}</td>
<td class="small">{{ task.started_at|date:"Y-m-d H:i:s" }}</td>
<td class="small">{{ task.finished_at|date:"Y-m-d H:i:s" }}</td>
<td class="small">{{ task.worker_ids }}</td>
<td class="small text-danger error-col">{{ task.exception_class_path|default:"" }}</td>
<td class="small actions-col">
{% if task.traceback %}
<button
class="btn btn-outline-danger btn-sm"
type="button"
data-bs-toggle="collapse"
data-bs-target="#traceback-{{ task.id }}"
aria-expanded="false"
aria-controls="traceback-{{ task.id }}"
>
View full traceback
</button>
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
</tr>
{% if task.traceback %}
<tr class="collapse" id="traceback-{{ task.id }}">
<td></td>
<td colspan="10">
<div class="border rounded bg-dark-subtle p-2">
<div class="small fw-semibold mb-1">Full traceback</div>
<pre class="small mb-0" style="white-space: pre-wrap;">{{ task.traceback }}</pre>
</div>
</td>
</tr>
{% endif %}
{% empty %}
<tr>
<td colspan="11" class="text-muted">No tasks found for this filter.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</form>
<script>
(function () {
const selectAll = document.getElementById('select-all-tasks');
const rows = Array.from(document.querySelectorAll('.task-select'));
if (!selectAll || !rows.length) {
return;
}
selectAll.addEventListener('change', function () {
rows.forEach((cb) => {
cb.checked = selectAll.checked;
});
}); });
}); })();
})(); </script>
</script> </div>
</div>
{% endblock content %} {% endblock content %}
+73 -73
View File
@@ -47,78 +47,78 @@
<details> <details>
<summary>Edit CID exams</summary> <summary>Edit CID exams</summary>
<p>This should be done via the exams pages one via group management.</p> <p>This should be done via the exams pages one via group management.</p>
<p>Select exams below to add user(s) to (or edit existing user(s)).</p> <p>Select exams below to add user(s) to (or edit existing user(s)).</p>
<div class="exam-selectors"> <div class="exam-selectors">
<span> <span>
Physics Exams<br /> Physics Exams<br />
<select id="physics-exams" multiple="multiple"> <select id="physics-exams" multiple="multiple">
{% for name, id in physics_exams %} {% for name, id in physics_exams %}
<option value="{{id}}">{{name}}</option> <option value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</span> </span>
<span> <span>
Rapid Exams<br /> Rapid Exams<br />
<select id="rapid-exams" multiple="multiple"> <select id="rapid-exams" multiple="multiple">
{% for name, id in rapid_exams %} {% for name, id in rapid_exams %}
<option value="{{id}}">{{name}}</option> <option value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</span> </span>
<span> <span>
Sba Exams<br /> Sba Exams<br />
<select id="sbas-exams" multiple="multiple"> <select id="sbas-exams" multiple="multiple">
{% for name, id in sba_exams %} {% for name, id in sba_exams %}
<option value="{{id}}">{{name}}</option> <option value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</span> </span>
<span> <span>
Long Exams<br /> Long Exams<br />
<select id="longs-exams" multiple="multiple"> <select id="longs-exams" multiple="multiple">
{% for name, id in longs_exams %} {% for name, id in longs_exams %}
<option value="{{id}}">{{name}}</option> <option value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</span> </span>
<span> <span>
Anatomy Exams<br /> Anatomy Exams<br />
<select id="anatomy-exams" multiple="multiple"> <select id="anatomy-exams" multiple="multiple">
{% for name, id in anatomy_exams %} {% for name, id in anatomy_exams %}
<option value="{{id}}">{{name}}</option> <option value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</span> </span>
<span> <span>
Shorts Exams<br /> Shorts Exams<br />
<select id="shorts-exams" multiple="multiple"> <select id="shorts-exams" multiple="multiple">
{% for name, id in shorts_exams %} {% for name, id in shorts_exams %}
<option value="{{id}}">{{name}}</option> <option value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</span> </span>
<span> <span>
CaseCollection Exams<br /> CaseCollection Exams<br />
<select id="casecollection-exams" multiple="multiple"> <select id="casecollection-exams" multiple="multiple">
{% for name, id in casecollection_exams %} {% for name, id in casecollection_exams %}
<option value="{{id}}">{{name}}</option> <option value="{{id}}">{{name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</span> </span>
</div> </div>
<button id="add-exams-selected-cids">Add selected exams</button> <button id="add-exams-selected-cids">Add selected exams</button>
<button id="change-exams-selected-cids">Change selected exams</button> <button id="change-exams-selected-cids">Change selected exams</button>
<button id="clear-exams-selected-cids">Clear selected exams</button> <button id="clear-exams-selected-cids">Clear selected exams</button>
</details> </details>
</details> </details>
@@ -183,20 +183,20 @@
}) })
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) { .done(function (data) {
console.log(data); console.log(data);
if (data.status == "success") { if (data.status == "success") {
toastr.info('Added/Updated'); toastr.info('Added/Updated');
location.reload(); location.reload();
} else { } else {
toastr.error(data.details) toastr.error(data.details)
} }
// show some message according to the response. // show some message according to the response.
// For eg. A message box showing that the status has been changed // For eg. A message box showing that the status has been changed
}) })
.always(function () { .always(function () {
console.log('[Done]'); console.log('[Done]');
}) })
} }
+27 -27
View File
@@ -16,41 +16,41 @@
<div id="htmx-info"></div> <div id="htmx-info"></div>
<div id="htmx-options"></div> <div id="htmx-options"></div>
<button id="bulk-delete-supervisors-button" <button id="bulk-delete-supervisors-button"
title="Deletes the supervisors of all selected users" title="Deletes the supervisors of all selected users"
hx-post="{% url 'generic:users_bulk_delete_supervisors' %}" hx-post="{% url 'generic:users_bulk_delete_supervisors' %}"
hx-include="[name='selection']" hx-include="[name='selection']"
hx-confirm="This will delete supervisors from all selected users, are you sure you wish to continue?" hx-confirm="This will delete supervisors from all selected users, are you sure you wish to continue?"
hx-target="#htmx-info" hx-target="#htmx-info"
_='on click put "" into #htmx-options' _='on click put "" into #htmx-options'
>Delete supervisors</button> >Delete supervisors</button>
<button id="bulk-edit-grade-button" <button id="bulk-edit-grade-button"
hx-post="{% url 'generic:users_bulk_edit' %}" hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']" hx-include="[name='selection']"
hx-target="#htmx-options" hx-target="#htmx-options"
title="Changes the selected users grade." title="Changes the selected users grade."
>Edit grade</button> >Edit grade</button>
<button id="bulk-add-group-button" <button id="bulk-add-group-button"
hx-post="{% url 'generic:users_bulk_edit' %}" hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']" hx-include="[name='selection']"
hx-target="#htmx-options" hx-target="#htmx-options"
title="Adds the selected user to a group." title="Adds the selected user to a group."
>Add group</button> >Add group</button>
<button id="bulk-remove-group-button" <button id="bulk-remove-group-button"
hx-post="{% url 'generic:users_bulk_edit' %}" hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']" hx-include="[name='selection']"
hx-target="#htmx-options" hx-target="#htmx-options"
title="Removes the selected user from a group." title="Removes the selected user from a group."
>Remove group</button> >Remove group</button>
<button id="bulk-deactivate-user-button" <button id="bulk-deactivate-user-button"
hx-post="{% url 'generic:users_bulk_edit' %}" hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']" hx-include="[name='selection']"
hx-target="#htmx-options" hx-target="#htmx-options"
hx-confirm="This will deactivate all selected users, are you sure you wish to continue?" hx-confirm="This will deactivate all selected users, are you sure you wish to continue?"
title="Deactivates the selected users" title="Deactivates the selected users"
>Deactivate</button> >Deactivate</button>
</details> </details>
+10 -10
View File
@@ -13,15 +13,15 @@
<div class="mb-2 mb-md-0"> <div class="mb-2 mb-md-0">
<div class="btn-toolbar" role="toolbar"> <div class="btn-toolbar" role="toolbar">
{% if user.is_superuser %} {% if user.is_superuser %}
<div class="btn-group me-2" role="group"> <div class="btn-group me-2" role="group">
<button id="delete-selected-btn" class="btn btn-danger btn-sm" <button id="delete-selected-btn" class="btn btn-danger btn-sm"
hx-post="{% url 'generic:bulk_delete_questions' %}" hx-post="{% url 'generic:bulk_delete_questions' %}"
hx-include="[name='selection']:checked" hx-include="[name='selection']:checked"
hx-vals='{"app":"{{ app_name|escapejs }}"}' hx-vals='{"app":"{{ app_name|escapejs }}"}'
hx-target="#action-result" hx-target="#action-result"
hx-swap="innerHTML" hx-swap="innerHTML"
hx-confirm="Are you sure you want to delete the selected questions? This action cannot be undone.">Delete selected</button> hx-confirm="Are you sure you want to delete the selected questions? This action cannot be undone.">Delete selected</button>
</div> </div>
{% endif %} {% endif %}
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button id="button-select-add-exam" class="btn btn-outline-primary btn-sm" <button id="button-select-add-exam" class="btn btn-outline-primary btn-sm"
@@ -41,7 +41,7 @@
</div> </div>
{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %} {% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
<!-- Minibar: small visible strip when panel is collapsed --> <!-- Minibar: small visible strip when panel is collapsed -->
{% endblock %} {% endblock %}