Merge branch '1416-timerboard-datatables' into 'master'

[CHANGE] Timertables to Datatables

Closes #1416

See merge request allianceauth/allianceauth!1676
This commit is contained in:
Ariel Rin 2025-01-18 03:50:34 +00:00
commit 1b6cf98885
2 changed files with 98 additions and 75 deletions

View File

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

View File

@ -25,7 +25,7 @@
{% endblock header_nav_collapse_right %} {% endblock header_nav_collapse_right %}
{% block content %} {% block content %}
<div> <div class="allianceauth-timerboard">
<div class="col-lg-12 text-center mb-3"> <div class="col-lg-12 text-center mb-3">
<div class="badge bg-primary text-start"> <div class="badge bg-primary text-start">
<span>{% translate "Current Eve Time:" %}</span> <span>{% translate "Current Eve Time:" %}</span>
@ -42,7 +42,7 @@
</div> </div>
<div class="card-body"> <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>
</div> </div>
{% endif %} {% endif %}
@ -56,7 +56,7 @@
<div class="card-body"> <div class="card-body">
{% if future_timers %} {% if future_timers %}
{% include "timerboard/timertable.html" with timers=future_timers %} {% include "timerboard/timertable.html" with id="future-timers" timers=future_timers %}
{% else %} {% else %}
<div class="alert alert-warning text-center"> <div class="alert alert-warning text-center">
{% translate "No upcoming timers." %} {% translate "No upcoming timers." %}
@ -74,7 +74,7 @@
<div class="card-body"> <div class="card-body">
{% if past_timers %} {% if past_timers %}
{% include "timerboard/timertable.html" with timers=past_timers %} {% include "timerboard/timertable.html" with id="past-timers" timers=past_timers %}
{% else %} {% else %}
<div class="alert alert-warning text-center"> <div class="alert alert-warning text-center">
{% translate "No past timers." %} {% translate "No past timers." %}
@ -85,9 +85,14 @@
</div> </div>
{% endblock content %} {% endblock content %}
{% block extra_css %}
{% include "bundles/datatables-css-bs5.html" %}
{% endblock extra_css %}
{% block extra_javascript %} {% block extra_javascript %}
{% include "bundles/moment-js.html" with locale=True %} {% include "bundles/moment-js.html" with locale=True %}
{% include "bundles/timers-js.html" %} {% include "bundles/timers-js.html" %}
{% include "bundles/datatables-js-bs5.html" %}
<script> <script>
const timers = [ const timers = [
@ -168,5 +173,19 @@
// Start timed updates // Start timed updates
setInterval(timedUpdate, 1000); 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> </script>
{% endblock extra_javascript %} {% endblock extra_javascript %}