Skip to content

Commit

Permalink
Merge pull request #938 from pi-hole/fix/query_table_aditional_sortin…
Browse files Browse the repository at this point in the history
…g_by_id

Fix sorting of queries with identical timestamps
  • Loading branch information
AzureMarker committed Sep 11, 2019
2 parents 9035922 + 990260d commit 935edcf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
16 changes: 12 additions & 4 deletions scripts/pi-hole/js/db_queries.js
Expand Up @@ -244,7 +244,6 @@ $(document).ready(function() {
tableApi = $("#all-queries").DataTable( {
"rowCallback": function( row, data, index ){
var blocked, fieldtext, buttontext, color;

switch (data[4])
{
case 1:
Expand Down Expand Up @@ -310,13 +309,23 @@ $(document).ready(function() {
"<'row'<'col-sm-4'l><'col-sm-8'p>>" +
"<'row'<'col-sm-12'<'table-responsive'tr>>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"ajax": {"url": APIstring, "error": handleAjaxError },
"ajax": {
"url": APIstring,
"error": handleAjaxError,
"dataSrc": function(data){
var dataIndex = 0;
return data.data.map(function(x){
x[0] = x[0] * 1e6 + (dataIndex++);
return x;
});
}
},
"autoWidth" : false,
"processing": true,
"deferRender": true,
"order" : [[0, "desc"]],
"columns": [
{ "width" : "15%", "render": function (data, type, full, meta) { if(type === "display"){return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");}else{return data;} }},
{ "width" : "15%", "render": function (data, type, full, meta) { if(type === "display"){return moment.unix(Math.floor(data/1e6)).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");}else{return data;} }},
{ "width" : "10%" },
{ "width" : "40%" },
{ "width" : "20%" },
Expand Down Expand Up @@ -353,4 +362,3 @@ $("#querytime").on("apply.daterangepicker", function(ev, picker) {
$(this).val(picker.startDate.format(dateformat) + " to " + picker.endDate.format(dateformat));
refreshTableData();
});

17 changes: 12 additions & 5 deletions scripts/pi-hole/js/queries.js
Expand Up @@ -152,7 +152,6 @@ $(document).ready(function() {

tableApi = $("#all-queries").DataTable( {
"rowCallback": function( row, data, index ){

// DNSSEC status
var dnssec_status;
switch (data[5])
Expand Down Expand Up @@ -299,12 +298,22 @@ $(document).ready(function() {
"<'row'<'col-sm-4'l><'col-sm-8'p>>" +
"<'row'<'col-sm-12'<'table-responsive'tr>>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"ajax": {"url": APIstring, "error": handleAjaxError },
"ajax": {
"url": APIstring,
"error": handleAjaxError,
"dataSrc": function(data){
var dataIndex = 0;
return data.data.map(function(x){
x[0] = x[0] * 1e6 + (dataIndex++);
return x;
});
}
},
"autoWidth" : false,
"processing": true,
"order" : [[0, "desc"]],
"columns": [
{ "width" : "15%", "render": function (data, type, full, meta) { if(type === "display"){return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");}else{return data;} }},
{ "width" : "15%", "render": function (data, type, full, meta) { if(type === "display"){return moment.unix(Math.floor(data/1e6)).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");}else{return data;} }},
{ "width" : "4%" },
{ "width" : "36%", "render": $.fn.dataTable.render.text() },
{ "width" : "8%", "render": $.fn.dataTable.render.text() },
Expand Down Expand Up @@ -376,5 +385,3 @@ $(document).ready(function() {

$("#resetButton").click( function () { tableApi.search("").draw(); $("#resetButton").hide(); } );
} );


0 comments on commit 935edcf

Please sign in to comment.