mirror of https://github.com/Jackett/Jackett
always show search results table and clear results filter on search
This commit is contained in:
parent
ba14fab0a1
commit
132fa71e35
|
@ -645,6 +645,7 @@ function showSearch(selectedIndexer) {
|
||||||
$("#modals").append(releaseDialog);
|
$("#modals").append(releaseDialog);
|
||||||
|
|
||||||
releaseDialog.on('shown.bs.modal', function () {
|
releaseDialog.on('shown.bs.modal', function () {
|
||||||
|
updateSearchResultTable($('#searchResults'), []);
|
||||||
releaseDialog.find('#searchquery').focusWithoutScrolling();
|
releaseDialog.find('#searchquery').focusWithoutScrolling();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -693,75 +694,14 @@ function showSearch(selectedIndexer) {
|
||||||
Category: releaseDialog.find('#searchCategory').val(),
|
Category: releaseDialog.find('#searchCategory').val(),
|
||||||
Tracker: releaseDialog.find('#searchTracker').val().replace("'", "").replace("'", ""),
|
Tracker: releaseDialog.find('#searchTracker').val().replace("'", "").replace("'", ""),
|
||||||
};
|
};
|
||||||
$('#searchResults').empty();
|
|
||||||
|
|
||||||
$('#jackett-search-perform').html($('#spinner').html());
|
$('#jackett-search-perform').html($('#spinner').html());
|
||||||
var jqxhr = $.post("search", queryObj, function (data) {
|
var jqxhr = $.post("search", queryObj, function (data) {
|
||||||
$('#jackett-search-perform').html('Search trackers');
|
$('#jackett-search-perform').html('Search trackers');
|
||||||
var resultsTemplate = Handlebars.compile($("#jackett-search-results").html());
|
var searchResults = $('#searchResults');
|
||||||
var results = $('#searchResults');
|
searchResults.empty();
|
||||||
results.html($(resultsTemplate(data)));
|
var datatable = updateSearchResultTable(searchResults, data).search('').columns().search('').draw();
|
||||||
results.find('tr.jackett-search-results-row').each(function () { updateReleasesRow(this); });
|
searchResults.find('div.dataTables_filter input').focusWithoutScrolling();
|
||||||
|
|
||||||
results.find('table').DataTable(
|
|
||||||
{
|
|
||||||
"stateSave": true,
|
|
||||||
"pageLength": 20,
|
|
||||||
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],
|
|
||||||
"order": [[0, "desc"]],
|
|
||||||
"columnDefs": [
|
|
||||||
{
|
|
||||||
"targets": 0,
|
|
||||||
"visible": false,
|
|
||||||
"searchable": false,
|
|
||||||
"type": 'date'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"targets": 1,
|
|
||||||
"visible": true,
|
|
||||||
"searchable": false,
|
|
||||||
"iDataSort": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"targets": 4,
|
|
||||||
"visible": false,
|
|
||||||
"searchable": false,
|
|
||||||
"type": 'num'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"targets": 5,
|
|
||||||
"visible": true,
|
|
||||||
"searchable": false,
|
|
||||||
"iDataSort": 4
|
|
||||||
}
|
|
||||||
],
|
|
||||||
initComplete: function () {
|
|
||||||
var count = 0;
|
|
||||||
this.api().columns().every(function () {
|
|
||||||
count++;
|
|
||||||
if (count === 3 || count === 8) {
|
|
||||||
var column = this;
|
|
||||||
var select = $('<select><option value=""></option></select>')
|
|
||||||
.appendTo($(column.footer()).empty())
|
|
||||||
.on('change', function () {
|
|
||||||
var val = $.fn.dataTable.util.escapeRegex(
|
|
||||||
$(this).val()
|
|
||||||
);
|
|
||||||
|
|
||||||
column
|
|
||||||
.search(val ? '^' + val + '$' : '', true, false)
|
|
||||||
.draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
column.data().unique().sort().each(function (d, j) {
|
|
||||||
select.append('<option value="' + d + '">' + d + '</option>')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
results.find('div.dataTables_filter input').focusWithoutScrolling();
|
|
||||||
|
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
$('#jackett-search-perform').html('Search trackers');
|
$('#jackett-search-perform').html('Search trackers');
|
||||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||||
|
@ -775,6 +715,71 @@ function showSearch(selectedIndexer) {
|
||||||
releaseDialog.modal("show");
|
releaseDialog.modal("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateSearchResultTable(element, results) {
|
||||||
|
var resultsTemplate = Handlebars.compile($("#jackett-search-results").html());
|
||||||
|
element.html($(resultsTemplate(results)));
|
||||||
|
element.find('tr.jackett-search-results-row').each(function () { updateReleasesRow(this); });
|
||||||
|
|
||||||
|
var datatable = element.find('table').DataTable(
|
||||||
|
{
|
||||||
|
"stateSave": true,
|
||||||
|
"pageLength": 20,
|
||||||
|
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],
|
||||||
|
"order": [[0, "desc"]],
|
||||||
|
"columnDefs": [
|
||||||
|
{
|
||||||
|
"targets": 0,
|
||||||
|
"visible": false,
|
||||||
|
"searchable": false,
|
||||||
|
"type": 'date'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": 1,
|
||||||
|
"visible": true,
|
||||||
|
"searchable": false,
|
||||||
|
"iDataSort": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": 4,
|
||||||
|
"visible": false,
|
||||||
|
"searchable": false,
|
||||||
|
"type": 'num'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": 5,
|
||||||
|
"visible": true,
|
||||||
|
"searchable": false,
|
||||||
|
"iDataSort": 4
|
||||||
|
}
|
||||||
|
],
|
||||||
|
initComplete: function () {
|
||||||
|
var count = 0;
|
||||||
|
this.api().columns().every(function () {
|
||||||
|
count++;
|
||||||
|
if (count === 3 || count === 8) {
|
||||||
|
var column = this;
|
||||||
|
var select = $('<select><option value=""></option></select>')
|
||||||
|
.appendTo($(column.footer()).empty())
|
||||||
|
.on('change', function () {
|
||||||
|
var val = $.fn.dataTable.util.escapeRegex(
|
||||||
|
$(this).val()
|
||||||
|
);
|
||||||
|
|
||||||
|
column
|
||||||
|
.search(val ? '^' + val + '$' : '', true, false)
|
||||||
|
.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
column.data().unique().sort().each(function (d, j) {
|
||||||
|
select.append('<option value="' + d + '">' + d + '</option>')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return datatable;
|
||||||
|
}
|
||||||
|
|
||||||
function bindUIButtons() {
|
function bindUIButtons() {
|
||||||
$('body').on('click', '.downloadlink', function (e, b) {
|
$('body').on('click', '.downloadlink', function (e, b) {
|
||||||
$(e.target).addClass('jackettdownloaded');
|
$(e.target).addClass('jackettdownloaded');
|
||||||
|
|
Loading…
Reference in New Issue