fixed sort order to work with datatables sorting

This commit is contained in:
2022-01-16 14:49:38 +11:00
parent d8db522d00
commit 28f15ee4e6
3 changed files with 40 additions and 13 deletions

View File

@@ -1,6 +1,15 @@
{% extends "base.html" %}
{% block main_content %}
<link rel="stylesheet" href="{{ url_for( 'internal', filename='upstream/DataTables-1.11.3/css/jquery.dataTables.min.css' ) }}">
<script src="{{url_for( 'internal', filename='upstream/DataTables-1.11.3/js/jquery.dataTables.min.js' )}}"></script>
<style>
table.dataTable tbody td {
padding: 4px 4px;
border-bottom-width: 0px;
}
</style>
<div class="container-fluid">
<h3>Show Job Details</h3>
<dl class="row">
@@ -48,16 +57,16 @@
{% endif %}
</dl>
{{order}}
<table id="jobort_tbl" class="table table-striped table-sm sm-txt" data-toolbar="#toolbar" data-search="true">
<thead><tr class="table-primary"><th>When
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#sort-num-{{order}}"/></svg>
</th><th>Details</th></tr></thead>
<table id="joblog_tbl" class="table table-striped table-sm sm-txt" data-toolbar="#toolbar" data-search="true">
<thead><tr class="table-info"><th>#</th><th>When</th><th>Details</th></tr></thead>
<tbody>
{% for log in logs %}
<tr><td>{{log.log_date|vicdate}}</td><td>{{log.log|safe}}</td></tr>
{% if display_more and loop.index == NEWEST_LOG_LIMIT %}
<tr><td>{{loop.index}}</td><td>{{log.log_date|vicdate}}</td><td>{{log.log|safe}}</td></tr>
{% if display_more and loop.index == OLDEST_LOG_LIMIT %}
<tr>
<td>{{loop.index}}.1</td>
<td class="align-middle">Remaining logs hidden</td>
<td>
<button type="button" class="btn btn-outline-info my-0 py-1 sm-txt" onClick="document.body.innerHTML+='<form id=_fm method=POST action={{url_for('joblog', id=job.id)}}></form>';document.getElementById('_fm').submit();">Show all logs</button>
@@ -71,8 +80,23 @@
{% endblock main_content %}
{% block script_content %}
<script>
{% if refresh and job.pa_job_state != "Completed" %}
setTimeout(function(){ window.location.reload(1); }, 3000 )
{% endif %}
$(document).ready(function() {
$('#joblog_tbl').DataTable(
{
'paging': false, 'info': false,
'order': [[1, "{{order}}"]],
'columnDefs': [
{ 'orderData':[0], 'targets': [1] },
{
'targets': [0],
'visible': false,
'searchable': false
},
]
} );
{% if refresh and job.pa_job_state != "Completed" %}
setTimeout(function(){ window.location.reload(1); }, 3000 )
{% endif %}
} );
</script>
{% endblock script_content %}