[CHANGE] Timertables to Datatables

This commit is contained in:
Peter Pfeufer 2025-01-12 17:12:23 +01:00
parent 5ef70bb031
commit 92c2af9975
No known key found for this signature in database
2 changed files with 98 additions and 75 deletions

View File

@ -2,7 +2,8 @@
{% load i18n %}
<div class="table-responsive">
<table class="table">
<table class="table" id="{{ id }}">
<thead>
<tr>
<th class="text-center">{% translate "Details" %}</th>
<th class="text-center">{% translate "Objective" %}</th>
@ -16,7 +17,9 @@
<th class="text-center">{% translate "Action" %}</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for timer in timers %}
<tr class="{% if timer.important == True %}bg-danger bg-opacity-25{% else %}bg-info bg-opacity-25{% endif %}">
<td style="width: 150px;" class="text-center">
@ -77,5 +80,6 @@
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>

View File

@ -25,7 +25,7 @@
{% endblock header_nav_collapse_right %}
{% block content %}
<div>
<div class="allianceauth-timerboard">
<div class="col-lg-12 text-center mb-3">
<div class="badge bg-primary text-start">
<span>{% translate "Current Eve Time:" %}</span>
@ -42,7 +42,7 @@
</div>
<div class="card-body">
{% include "timerboard/timertable.html" with timers=corp_timers %}
{% include "timerboard/timertable.html" with id="corp-timers" timers=corp_timers %}
</div>
</div>
{% endif %}
@ -56,7 +56,7 @@
<div class="card-body">
{% if future_timers %}
{% include "timerboard/timertable.html" with timers=future_timers %}
{% include "timerboard/timertable.html" with id="future-timers" timers=future_timers %}
{% else %}
<div class="alert alert-warning text-center">
{% translate "No upcoming timers." %}
@ -74,7 +74,7 @@
<div class="card-body">
{% if past_timers %}
{% include "timerboard/timertable.html" with timers=past_timers %}
{% include "timerboard/timertable.html" with id="past-timers" timers=past_timers %}
{% else %}
<div class="alert alert-warning text-center">
{% translate "No past timers." %}
@ -85,9 +85,14 @@
</div>
{% endblock content %}
{% block extra_css %}
{% include "bundles/datatables-css-bs5.html" %}
{% endblock extra_css %}
{% block extra_javascript %}
{% include "bundles/moment-js.html" with locale=True %}
{% include "bundles/timers-js.html" %}
{% include "bundles/datatables-js-bs5.html" %}
<script>
const timers = [
@ -168,5 +173,19 @@
// Start timed updates
setInterval(timedUpdate, 1000);
$(document).ready(() => {
const dtOptions = {};
{% if perms.auth.timer_management %}
dtOptions['columnDefs'] = [
{ "orderable": false, "targets": 7 }
];
{% endif %}
$('.allianceauth-timerboard table').each((index, table) => {
$(table).DataTable(dtOptions);
});
});
</script>
{% endblock extra_javascript %}