Merge pull request #721 from JackDandy/feature/ChangeManageFailed

Add "Order" table column and list failed from newest to oldest by def…
This commit is contained in:
JackDandy 2016-06-22 14:46:45 +01:00 committed by GitHub
commit abb6a52d32
4 changed files with 119 additions and 105 deletions

View file

@ -90,6 +90,10 @@
* Change CPU throttling on General Config/Advanced to "Disabled" by default for new installs
* Change provider OMGWTFNZBS api url and auto reject nuked releases
* Change Search Provider page to load torrent settings only when Search torrents is enabled in Search Settings
* Add "Order" table column and list failed from newest to oldest wherever possible on Manage Failed Downloads
* Add number of items shown to Manage Failed Downloads table footer and indicate if number of shown items is limited
* Add sorting to "Provider" column and fix sorting of "Remove" column on Manage Failed Downloads
* Fix "Limit" drop down on Manage Failed Downloads
### 0.11.12 (2016-06-20 02:20:00 UTC)

View file

@ -14,74 +14,66 @@
#import os.path
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl')
<script type="text/javascript">
<!--
\$(document).ready(function()
{
\$('#failedTable:has(tbody tr)').tablesorter({
widgets: ['zebra'],
sortList: [[0,0]],
headers: { 3: { sorter: false } }
});
\$('#limit').change(function(){
url = '$sbRoot/manage/failedDownloads/?limit='+\$(this).val()
window.location.href = url
});
});
//-->
</script>
<script type="text/javascript" src="$sbRoot/js/failedDownloads.js?v=$sbPID"></script>
<style>
.tablesorter .tablesorter-header{padding: 4px 18px 4px 5px}
</style>
#if $varExists('header')
#if $varExists('header')
<h1 class="header">$header</h1>
#else
#else
<h1 class="title">$title</h1>
#end if
#set selected = ' selected="selected"'
<div class="h2footer pull-right"><b>Limit:</b>
<select id="limit" name="limit" class="form-control form-control-inline input-sm">
<option value="0"#if '0' == $limit then $selected else ''#>All</option>
<option value="100"#if '100' == $limit then $selected else ''#>100</option>
<option value="250"#if '250' == $limit then $selected else ''#>250</option>
<option value="500"#if '500' == $limit then $selected else ''#>500</option>
</select>
</div>
<div class="h2footer pull-right"><b>Limit:</b>
<select id="limit" name="limit" class="form-control form-control-inline input-sm">
<option value="0"#if '0' == $limit then $selected else ''#>All</option>
<option value="100"#if '100' == $limit then $selected else ''#>100</option>
<option value="250"#if '250' == $limit then $selected else ''#>250</option>
<option value="500"#if '500' == $limit then $selected else ''#>500</option>
</select>
</div>
<table id="failedTable" class="sickbeardTable tablesorter" border="0">
<thead>
<tr>
<th class="text-nowrap text-left" style="width:75%">Release</th>
<th style="width:10%">Size</th>
<th style="width:14%">Provider</th>
<th style="width:1%">Remove<br />
<input id="removeCheck" type="checkbox" class="bulkCheck">
</th>
</tr>
</thead>
<table id="failedTable" class="sickbeardTable tablesorter" border="0">
<thead>
<tr>
<th style="width:1%">Order</th>
<th class="text-nowrap text-left" style="width:74%">Release</th>
<th style="width:10%">Size</th>
<th style="width:14%">Provider</th>
<th style="width:1%;padding: 4px 18px">Remove<br />
<input id="removeCheck" type="checkbox" class="bulkCheck">
</th>
</tr>
</thead>
<tfoot>
<tr>
<td rowspan="1" colspan="4">
<input id="submitMassRemove" type="button" class="btn pull-right" value="Submit">
</td>
</tr>
</tfoot>
#set $oldest = $len($failedResults)
<tfoot>
<tr>
<td colspan="4" class="text-left">
$oldest items shown#if $getVar('over_limit', False)#, more are available by changing the limit#end if#
</td>
<td>
<input id="submitMassRemove" type="button" class="btn" value="Submit">
</td>
</tr>
</tfoot>
<tbody>
#for $hItem in $failedResults
<tr>
<td class="text-nowrap text-left">#echo re.sub('"', '', $hItem['release'])#</td>
<td>#echo ($hItem['size'], '?')[-1 == $hItem['size']]#</td>
#set $provider = $providers.getProviderClass($generic.GenericProvider.make_id($hItem['provider']))
#if None is not $provider:
<td><img src="$sbRoot/images/providers/<%= provider.image_name() %>" width="16" height="16" alt="$provider.name" title="$provider.name" /></td>
#else
<td><img src="$sbRoot/images/providers/missing.png" width="16" height="16" alt="missing provider" title="missing provider" /></td>
#end if
<td><input type="checkbox" class="removeCheck" id="remove-#echo re.sub('"', '___', $hItem['release'])#" /></td>
</tr>
<tbody>
#set $order = $oldest
#for $hItem in $failedResults[::-1]
#set $provider = $providers.getProviderClass($generic.GenericProvider.make_id($hItem['provider']))
#set $provider_name = None is not $provider and $provider.name or 'missing provider'
#set $provider_image = None is not $provider and $provider.image_name() or 'missing.png'
<tr>
<td data-order="$order">#echo 1 == $order and 'Newest' or $oldest == $order and 'Oldest' or '-'##set $order -= 1#</td>
<td class="text-nowrap text-left">#echo re.sub('"', '', $hItem['release'])#</td>
<td>#echo ($hItem['size'], '?')[-1 == $hItem['size']]#</td>
<td><img src="$sbRoot/images/providers/$provider_image" width="16" height="16" alt="$provider_name" title="$provider_name"></td>
<td data-order="0"><input type="checkbox" class="removeCheck" id="remove-#echo re.sub('"', '___', $hItem['release'])#"></td>
</tr>
#end for
</tbody>
</table>
</tbody>
</table>
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl')
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl')

View file

@ -1,60 +1,75 @@
$(document).ready(function(){
$('#submitMassRemove').click(function(){
$(document).ready(function() {
var removeArr = new Array()
$('#limit').change(function() {
window.location.href = sbRoot + '/manage/failedDownloads/?limit=' + $(this).val();
});
$('.removeCheck').each(function() {
if (this.checked == true) {
removeArr.push($(this).attr('id').split('-')[1])
}
});
$('#submitMassRemove').click(function() {
if (removeArr.length == 0)
return false
var removeArr = [];
url = sbRoot + '/manage/failedDownloads?toRemove='+removeArr.join('|')
$('.removeCheck').each(function() {
if (!0 == this.checked) {
removeArr.push($(this).attr('id').split('-')[1])
}
});
window.location.href = url
if (0 == removeArr.length)
return !1;
});
window.location.href = sbRoot + '/manage/failedDownloads?toRemove=' + removeArr.join('|');
});
$('.bulkCheck').click(function(){
$('.bulkCheck').click(function() {
var bulkCheck = this;
var whichBulkCheck = $(bulkCheck).attr('id');
var bulkCheck = this, whichBulkCheck = $(bulkCheck).attr('id');
$('.'+whichBulkCheck+':visible').each(function(){
this.checked = bulkCheck.checked
});
});
$('.' + whichBulkCheck + ':visible').each(function() {
this.checked = bulkCheck.checked
});
});
['.removeCheck'].forEach(function(name) {
var lastCheck = null;
['.removeCheck'].forEach(function(name) {
$(name).click(function(event) {
var lastCheck = null;
if(!lastCheck || !event.shiftKey) {
lastCheck = this;
return;
}
$(name).click(function(event) {
var check = this;
var found = 0;
var table$ = $('#failedTable');
if(!lastCheck || !event.shiftKey) {
lastCheck = this;
$(this).parent('td').attr('data-order', this.checked ? '1' : '0');
table$.trigger('update');
return;
}
$(name+':visible').each(function() {
switch (found) {
case 2: return false;
case 1:
this.checked = lastCheck.checked;
}
var check = this, found = 0;
if (this == check || this == lastCheck)
found++;
});
$(name + ':visible').each(function() {
switch (found) {
case 2:
return !1;
case 1:
this.checked = lastCheck.checked;
$(this).parent('td').attr('data-order', this.checked ? '1' : '0');
}
});
if (this == check || this == lastCheck)
found++;
});
});
table$.trigger('update');
});
});
$('#failedTable:has(tbody tr)').tablesorter({
widgets: ['zebra'],
sortList: [[0,0]],
sortAppend: [[0,0]],
textExtraction: {
0: function(node) { return $(node).attr('data-order'); },
3: function(node) { return $(node).find('img').attr('title'); },
4: function(node) { return $(node).attr('data-order'); }}
});
});

View file

@ -3886,10 +3886,12 @@ class Manage(MainHandler):
myDB = db.DBConnection('failed.db')
if limit == '0':
sqlResults = myDB.select('SELECT * FROM failed')
sql = 'SELECT * FROM failed ORDER BY ROWID DESC'
limit = helpers.tryInt(limit, 100)
if not limit:
sql_results = myDB.select(sql)
else:
sqlResults = myDB.select('SELECT * FROM failed LIMIT ?', [limit])
sql_results = myDB.select(sql + ' LIMIT ?', [limit + 1])
toRemove = toRemove.split('|') if toRemove is not None else []
@ -3901,8 +3903,9 @@ class Manage(MainHandler):
return self.redirect('/manage/failedDownloads/')
t = PageTemplate(headers=self.request.headers, file='manage_failedDownloads.tmpl')
t.failedResults = sqlResults
t.limit = limit
t.over_limit = limit and len(sql_results) > limit
t.failedResults = t.over_limit and sql_results[0:-1] or sql_results
t.limit = str(limit)
t.submenu = self.ManageMenu()
return t.respond()