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 %}
<div class="container-fluid">
<div class="d-flex align-items-start justify-content-between mb-3">
<h2 class="mb-0">Collections</h2>
{% if request.user.is_staff %}
<a class="btn btn-sm btn-primary" href="{% url 'atlas:exam_create' %}">Create collection</a>
{% endif %}
<div class="container-fluid">
<div class="d-flex align-items-start justify-content-between mb-3">
<h2 class="mb-0">Collections</h2>
{% if request.user.is_staff %}
<a class="btn btn-sm btn-primary" href="{% url 'atlas:exam_create' %}">Create collection</a>
{% 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>
<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 %}
+21 -22
View File
@@ -34,42 +34,41 @@
{% render_table table %}
</div>
<script>
document.getElementById('bulk-delete-form').addEventListener('submit', function(e) {
<script>
document.getElementById('bulk-delete-form').addEventListener('submit', function(e) {
// 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
const checked = document.querySelectorAll('input[name="selection"]:checked');
if (checked.length === 0) {
alert("Please select at least one series to delete.");
e.preventDefault();
return false;
}
const checked = document.querySelectorAll('input[name="selection"]:checked');
if (checked.length === 0) {
alert("Please select at least one series to delete.");
e.preventDefault();
return false;
}
// Add hidden inputs for each checked series
checked.forEach(cb => {
const hidden = document.createElement('input');
hidden.type = 'hidden';
hidden.name = 'series_ids';
hidden.value = cb.value;
this.appendChild(hidden);
});
});
</script>
checked.forEach(cb => {
const hidden = document.createElement('input');
hidden.type = 'hidden';
hidden.name = 'series_ids';
hidden.value = cb.value;
this.appendChild(hidden);
});
});
</script>
<div id="exam-options"></div>
{% endblock %}
{% block js %}
<script>
document.addEventListener('DOMContentLoaded', function() {
});
document.addEventListener('DOMContentLoaded', function() {
});
</script>
{% endblock %}
{% block css %}
<style>
</style>
</style>
{% endblock css %}
+189 -189
View File
@@ -5,199 +5,199 @@
{% block content_container_class %}container-fluid content-wide px-3{% endblock %}
{% block title %}
Atlas Task Overview
Atlas Task Overview
{% endblock title %}
{% block content %}
<div class="container-fluid py-3 px-3">
<style>
.task-overview-table {
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;
<div class="container-fluid py-3 px-3">
<style>
.task-overview-table {
min-width: 1650px;
}
selectAll.addEventListener('change', function () {
rows.forEach((cb) => {
cb.checked = selectAll.checked;
.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 () {
rows.forEach((cb) => {
cb.checked = selectAll.checked;
});
});
});
})();
</script>
</div>
})();
</script>
</div>
{% endblock content %}
+72 -72
View File
@@ -47,77 +47,77 @@
<details>
<summary>Edit CID exams</summary>
<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>
<div class="exam-selectors">
<span>
Physics Exams<br />
<select id="physics-exams" multiple="multiple">
{% for name, id in physics_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
<p>Select exams below to add user(s) to (or edit existing user(s)).</p>
<div class="exam-selectors">
<span>
Physics Exams<br />
<select id="physics-exams" multiple="multiple">
{% for name, id in physics_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Rapid Exams<br />
<select id="rapid-exams" multiple="multiple">
{% for name, id in rapid_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Rapid Exams<br />
<select id="rapid-exams" multiple="multiple">
{% for name, id in rapid_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Sba Exams<br />
<select id="sbas-exams" multiple="multiple">
{% for name, id in sba_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Sba Exams<br />
<select id="sbas-exams" multiple="multiple">
{% for name, id in sba_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Long Exams<br />
<select id="longs-exams" multiple="multiple">
{% for name, id in longs_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Long Exams<br />
<select id="longs-exams" multiple="multiple">
{% for name, id in longs_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Anatomy Exams<br />
<select id="anatomy-exams" multiple="multiple">
{% for name, id in anatomy_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Anatomy Exams<br />
<select id="anatomy-exams" multiple="multiple">
{% for name, id in anatomy_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Shorts Exams<br />
<select id="shorts-exams" multiple="multiple">
{% for name, id in shorts_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
Shorts Exams<br />
<select id="shorts-exams" multiple="multiple">
{% for name, id in shorts_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
CaseCollection Exams<br />
<select id="casecollection-exams" multiple="multiple">
{% for name, id in casecollection_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
<span>
CaseCollection Exams<br />
<select id="casecollection-exams" multiple="multiple">
{% for name, id in casecollection_exams %}
<option value="{{id}}">{{name}}</option>
{% endfor %}
</select>
</span>
</select>
</span>
</div>
<button id="add-exams-selected-cids">Add selected exams</button>
<button id="change-exams-selected-cids">Change selected exams</button>
<button id="clear-exams-selected-cids">Clear selected exams</button>
</div>
<button id="add-exams-selected-cids">Add selected exams</button>
<button id="change-exams-selected-cids">Change selected exams</button>
<button id="clear-exams-selected-cids">Clear selected exams</button>
</details>
</details>
@@ -183,20 +183,20 @@
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
console.log(data);
if (data.status == "success") {
toastr.info('Added/Updated');
location.reload();
} else {
toastr.error(data.details)
}
if (data.status == "success") {
toastr.info('Added/Updated');
location.reload();
} else {
toastr.error(data.details)
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
})
.always(function () {
console.log('[Done]');
})
console.log('[Done]');
})
}
+23 -23
View File
@@ -16,40 +16,40 @@
<div id="htmx-info"></div>
<div id="htmx-options"></div>
<button id="bulk-delete-supervisors-button"
title="Deletes the supervisors of all selected users"
hx-post="{% url 'generic:users_bulk_delete_supervisors' %}"
hx-include="[name='selection']"
hx-confirm="This will delete supervisors from all selected users, are you sure you wish to continue?"
hx-target="#htmx-info"
_='on click put "" into #htmx-options'
title="Deletes the supervisors of all selected users"
hx-post="{% url 'generic:users_bulk_delete_supervisors' %}"
hx-include="[name='selection']"
hx-confirm="This will delete supervisors from all selected users, are you sure you wish to continue?"
hx-target="#htmx-info"
_='on click put "" into #htmx-options'
>Delete supervisors</button>
<button id="bulk-edit-grade-button"
hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']"
hx-target="#htmx-options"
title="Changes the selected users grade."
hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']"
hx-target="#htmx-options"
title="Changes the selected users grade."
>Edit grade</button>
<button id="bulk-add-group-button"
hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']"
hx-target="#htmx-options"
title="Adds the selected user to a group."
hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']"
hx-target="#htmx-options"
title="Adds the selected user to a group."
>Add group</button>
<button id="bulk-remove-group-button"
hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']"
hx-target="#htmx-options"
title="Removes the selected user from a group."
hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']"
hx-target="#htmx-options"
title="Removes the selected user from a group."
>Remove group</button>
<button id="bulk-deactivate-user-button"
hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']"
hx-target="#htmx-options"
hx-confirm="This will deactivate all selected users, are you sure you wish to continue?"
title="Deactivates the selected users"
hx-post="{% url 'generic:users_bulk_edit' %}"
hx-include="[name='selection']"
hx-target="#htmx-options"
hx-confirm="This will deactivate all selected users, are you sure you wish to continue?"
title="Deactivates the selected users"
>Deactivate</button>
</details>
+10 -10
View File
@@ -13,15 +13,15 @@
<div class="mb-2 mb-md-0">
<div class="btn-toolbar" role="toolbar">
{% if user.is_superuser %}
<div class="btn-group me-2" role="group">
<button id="delete-selected-btn" class="btn btn-danger btn-sm"
hx-post="{% url 'generic:bulk_delete_questions' %}"
hx-include="[name='selection']:checked"
hx-vals='{"app":"{{ app_name|escapejs }}"}'
hx-target="#action-result"
hx-swap="innerHTML"
hx-confirm="Are you sure you want to delete the selected questions? This action cannot be undone.">Delete selected</button>
</div>
<div class="btn-group me-2" role="group">
<button id="delete-selected-btn" class="btn btn-danger btn-sm"
hx-post="{% url 'generic:bulk_delete_questions' %}"
hx-include="[name='selection']:checked"
hx-vals='{"app":"{{ app_name|escapejs }}"}'
hx-target="#action-result"
hx-swap="innerHTML"
hx-confirm="Are you sure you want to delete the selected questions? This action cannot be undone.">Delete selected</button>
</div>
{% endif %}
<div class="btn-group" role="group">
<button id="button-select-add-exam" class="btn btn-outline-primary btn-sm"
@@ -41,7 +41,7 @@
</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 -->
{% endblock %}