Skip to content

Commit

Permalink
Merge pull request #1537 from philborman/master
Browse files Browse the repository at this point in the history
Searchdelay changes, fixes for #1533  #1535  #1536
  • Loading branch information
philborman authored Aug 8, 2018
2 parents a46df1a + 150c3f4 commit 88ace37
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 152 deletions.
39 changes: 25 additions & 14 deletions data/interfaces/bookstrap/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,29 @@
<script src="js/jquery-migrate-1.3.0.min.js"></script>
<script src="js/lazylibrarian-bs.js"></script>
${next.headIncludes()}
<script type="text/javascript">
// Allow the user to reset the filter box
$(document).ready(function () {
// Setup DataTable Defaults
$.extend( $.fn.dataTable.defaults, {
fnInitComplete: function(oSettings, json) {

// Add "Clear Filter" button to Filter
var btnClear = $('<button class="btn btn-sm btn-primary btnClearDataTableFilter" data-toggle="tooltip" data-placement="bottom" title="Clear filter"><i class="fa fa-times" aria-hidden="true"></i></button>');
btnClear.appendTo($('#' + oSettings.sTableId).parents('.dataTables_wrapper').find('.dataTables_filter'));
$('#' + oSettings.sTableId + '_wrapper .btnClearDataTableFilter').click(function () {
$('#' + oSettings.sTableId).dataTable().fnFilter('');
});
}
<script type="text/javascript">
// Allow the user to reset the search filter
$(document).ready(function () {
$.fn.dataTableExt.oApi.clearSearch = function ( oSettings ) {
var table = this;
var clearSearch = $('<i id="Clear" title="Clear" class="fa fa-times" style="height:20px;width:20px;vertical-align:center;cursor:pointer;">&nbsp;</i>');
$(clearSearch).click( function () {
table.fnFilter('');
$('input[type=search]').val('');
});
$(oSettings.nTableWrapper).find('div.dataTables_filter').append(clearSearch);
$(oSettings.nTableWrapper).find('div.dataTables_filter label').css('margin-right', '-20px');
$(oSettings.nTableWrapper).find('div.dataTables_filter input').css('padding-right', '20px');
}
//auto-execute, no code needs to be added
$.fn.dataTable.models.oSettings['aoInitComplete'].push( {
"fn": $.fn.dataTableExt.oApi.clearSearch,
"sName": 'whatever'
});
});
});
</script>

${next.javascriptIncludes()}
<script type="text/javascript">
// Check or uncheck all checkboxes in the same table
Expand Down Expand Up @@ -81,6 +87,11 @@
opacity: 1.0;
filter: alpha(opacity=100); /* For IE8 and earlier */
}
#Clear:hover {
color: #555;
opacity: 1.0;
filter: alpha(opacity=100); /* For IE8 and earlier */
}

#myAlert {
display: block;
Expand Down
7 changes: 1 addition & 6 deletions data/interfaces/bookstrap/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<div id="subhead_menu">
<a onclick="self.shutdownQA(this)" class="button btn btn-sm btn-danger" data-toggle="tooltip" data-placement="bottom" title="Terminate the LazyLibrarian process - Be careful if you're doing this remotely"><i class="fa fa-power-off"></i> Shutdown</a>
<a class="button btn btn-sm btn-warning" onclick="self.restartQA(this, '', '')" data-toggle="tooltip" data-placement="bottom" title="Restart LazyLibrarian"><i class="fa fa-sync"></i> Restart</a>
<button class="button btn btn-sm btn-primary" type="button" value="System Info" id="sysinfo"><i class="fa fa-cogs"></i> System Info</button>
<button class="button btn btn-sm btn-primary" type="button" value="Show Jobs" id="show_Jobs"><i class="fa fa-list-ul"></i> Job Status</button>
<button class="button btn btn-sm btn-primary" type="button" value="checkforupdates" id="checkforupdates"><i class="fa fa-list-alt"></i> Check Version</button>
%if lazylibrarian.CONFIG['USER_ACCOUNTS'] == True:
Expand Down Expand Up @@ -389,12 +390,6 @@ <h1>${title}
</select>
</div>
</fieldset>
<br>
<fieldset>
<div class="form-group">
<input type="button" value="System info" id="sysinfo" class="btn btn-default" />
</div>
</fieldset>
</fieldset>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion data/interfaces/bookstrap/managebooks.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ <h1>${title}</h1>
var table = $('#book_table').DataTable(
{
"bAutoWidth": false,
"responsive": true,
"stateSave": true,
"order": [[ 2, 'asc' ]],
"columnDefs":[
Expand Down
6 changes: 5 additions & 1 deletion lazylibrarian/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,11 @@ def logHeader():
header += 'Loglevel: %s\n' % lazylibrarian.LOGLEVEL
header += 'Sys_Encoding: %s\n' % lazylibrarian.SYS_ENCODING
for item in lazylibrarian.CONFIG_GIT:
header += '%s: %s\n' % (item.lower(), lazylibrarian.CONFIG[item])
if item == 'GIT_UPDATED':
timestamp = check_int(lazylibrarian.CONFIG[item], 0)
header += '%s: %s\n' % (item.lower(), time.ctime(timestamp))
else:
header += '%s: %s\n' % (item.lower(), lazylibrarian.CONFIG[item])
header += "Python version: %s\n" % sys.version.split('\n')
# noinspection PyDeprecation
header += "Distribution: %s\n" % str(platform.dist())
Expand Down
69 changes: 42 additions & 27 deletions lazylibrarian/dbupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ def upgrade_needed():
# 35 add OriginalPubDate to books table
# 36 create failedsearch table
# 37 add delete cascade to tables
# 38 change series count and total to integers

db_current_version = 37
db_current_version = 38

if db_version < db_current_version:
return db_current_version
Expand Down Expand Up @@ -143,14 +144,14 @@ def dbupgrade(db_current_version):
# new set of database tables
myDB.action('CREATE TABLE authors (AuthorID TEXT UNIQUE, AuthorName TEXT UNIQUE, ' +
'AuthorImg TEXT, AuthorLink TEXT, DateAdded TEXT, Status TEXT, LastBook TEXT, ' +
'LastBookImg TEXT, LastLink Text, LastDate TEXT, HaveBooks INTEGER, ' +
'TotalBooks INTEGER, AuthorBorn TEXT, AuthorDeath TEXT, UnignoredBooks INTEGER, ' +
'Manual TEXT, GRfollow TEXT)')
'LastBookImg TEXT, LastLink Text, LastDate TEXT, HaveBooks INTEGER DEFAULT 0, ' +
'TotalBooks INTEGER DEFAULT 0, AuthorBorn TEXT, AuthorDeath TEXT, ' +
'UnignoredBooks INTEGER DEFAULT 0, Manual TEXT, GRfollow TEXT)')
myDB.action('CREATE TABLE books (AuthorID TEXT, BookName TEXT, BookSub TEXT, BookDesc TEXT, ' +
'BookGenre TEXT, BookIsbn TEXT, BookPub TEXT, BookRate INTEGER, BookImg TEXT, ' +
'BookPages INTEGER, BookLink TEXT, BookID TEXT UNIQUE, BookFile TEXT, ' +
'BookDate TEXT, BookLang TEXT, BookAdded TEXT, Status TEXT, WorkPage TEXT, ' +
'Manual TEXT, SeriesDisplay TEXT, BookLibrary TEXT, AudioFile TEXT, ' +
'BookGenre TEXT, BookIsbn TEXT, BookPub TEXT, BookRate INTEGER DEFAULT 0, ' +
'BookImg TEXT, BookPages INTEGER DEFAULT 0, BookLink TEXT, BookID TEXT UNIQUE, ' +
'BookFile TEXT, BookDate TEXT, BookLang TEXT, BookAdded TEXT, Status TEXT, ' +
'WorkPage TEXT, Manual TEXT, SeriesDisplay TEXT, BookLibrary TEXT, AudioFile TEXT, ' +
'AudioLibrary TEXT, AudioStatus TEXT, WorkID TEXT, ScanResult TEXT, ' +
'OriginalPubDate TEXT,' +
' CONSTRAINT fk_a FOREIGN KEY (AuthorID) REFERENCES authors (AuthorID) ' +
Expand All @@ -172,7 +173,7 @@ def dbupgrade(db_current_version):
'LT_lang_hits int, GB_lang_change, cache_hits int, bad_lang int, bad_char int, ' +
'uncached int, duplicates int)')
myDB.action('CREATE TABLE series (SeriesID INTEGER UNIQUE, SeriesName TEXT, Status TEXT, ' +
'Have TEXT, Total TEXT)')
'Have INTEGER DEFAULT 0, Total INTEGER DEFAULT 0)')
myDB.action('CREATE TABLE member (SeriesID INTEGER, BookID TEXT, WorkID TEXT, SeriesNum TEXT,' +
' CONSTRAINT fk_b FOREIGN KEY (BookID) REFERENCES books (BookID) ' +
'ON DELETE CASCADE, ' +
Expand All @@ -182,16 +183,16 @@ def dbupgrade(db_current_version):
'UNIQUE (SeriesID,AuthorID),' +
' CONSTRAINT fk_a FOREIGN KEY (AuthorID) REFERENCES authors (AuthorID) ' +
'ON DELETE CASCADE)')
myDB.action('CREATE TABLE downloads (Count INTEGER, Provider TEXT)')
myDB.action('CREATE TABLE downloads (Count INTEGER DEFAULT 0, Provider TEXT)')
myDB.action('CREATE TABLE users (UserID TEXT UNIQUE, UserName TEXT UNIQUE, Password TEXT, ' +
'Email TEXT, Name TEXT, Perms INTEGER, HaveRead TEXT, ToRead TEXT, ' +
'Email TEXT, Name TEXT, Perms INTEGER DEFAULT 0, HaveRead TEXT, ToRead TEXT, ' +
'CalibreRead TEXT, CalibreToRead TEXT, BookType TEXT)')
myDB.action('CREATE TABLE sync (UserID TEXT, Label TEXT, Date TEXT, SyncList TEXT,' +
' CONSTRAINT fk_u FOREIGN KEY (UserID) REFERENCES users (UserID) ' +
'ON DELETE CASCADE)')
myDB.action('CREATE TABLE isbn (Words TEXT, ISBN TEXT)')
myDB.action('CREATE TABLE failedsearch (BookID TEXT, Library TEXT, Time TEXT, ' +
'Interval INTEGER, Count INTEGER,' +
'Interval INTEGER DEFAULT 0, Count INTEGER DEFAULT 0,' +
' CONSTRAINT fk_b FOREIGN KEY (BookID) REFERENCES books (BookID) ' +
'ON DELETE CASCADE)')

Expand Down Expand Up @@ -281,9 +282,9 @@ def db_v3(myDB, upgradelog):
logger.debug(lazylibrarian.UPDATE_MSG)
myDB.action('CREATE TABLE IF NOT EXISTS temp_books (AuthorID TEXT, AuthorName TEXT, \
AuthorLink TEXT, BookName TEXT, BookSub TEXT, BookDesc TEXT, BookGenre TEXT, BookIsbn TEXT, \
BookPub TEXT, BookRate INTEGER, BookImg TEXT, BookPages INTEGER, BookLink TEXT, \
BookID TEXT UNIQUE, BookFile TEXT, BookDate TEXT, BookLang TEXT, BookAdded TEXT, Status TEXT, \
Series TEXT, SeriesNum TEXT, WorkPage TEXT)')
BookPub TEXT, BookRate INTEGER DEFAULT 0, BookImg TEXT, BookPages INTEGER DEFAULT 0, \
BookLink TEXT, BookID TEXT UNIQUE, BookFile TEXT, BookDate TEXT, BookLang TEXT, \
BookAdded TEXT, Status TEXT, Series TEXT, SeriesNum TEXT, WorkPage TEXT)')
myDB.action('INSERT INTO temp_books SELECT AuthorID,AuthorName,AuthorLink,BookName,BookSub, \
BookDesc,BookGenre,BookIsbn,BookPub,BookRate,BookImg,BookPages,BookLink,BookID, \
BookFile,BookDate,BookLang,BookAdded,Status,Series,SeriesNum,WorkPage FROM books')
Expand Down Expand Up @@ -605,9 +606,9 @@ def db_v15(myDB, upgradelog):
lazylibrarian.UPDATE_MSG = 'Removing seriesnum from books table'
myDB.action('CREATE TABLE IF NOT EXISTS temp_table (AuthorID TEXT, AuthorName TEXT, \
AuthorLink TEXT, BookName TEXT, BookSub TEXT, BookDesc TEXT, BookGenre TEXT, BookIsbn TEXT, \
BookPub TEXT, BookRate INTEGER, BookImg TEXT, BookPages INTEGER, BookLink TEXT, \
BookID TEXT UNIQUE, BookFile TEXT, BookDate TEXT, BookLang TEXT, BookAdded TEXT, Status TEXT, \
Series TEXT, WorkPage TEXT, Manual TEXT)')
BookPub TEXT, BookRate INTEGER DEFAULT 0, BookImg TEXT, BookPages INTEGER DEFAULT 0, \
BookLink TEXT, BookID TEXT UNIQUE, BookFile TEXT, BookDate TEXT, BookLang TEXT, \
BookAdded TEXT, Status TEXT, Series TEXT, WorkPage TEXT, Manual TEXT)')
myDB.action('INSERT INTO temp_table SELECT AuthorID, AuthorName, AuthorLink, BookName, \
BookSub, BookDesc, BookGenre, BookIsbn, BookPub, BookRate, BookImg, BookPages, BookLink, BookID, \
BookFile, BookDate, BookLang, BookAdded, Status, Series, WorkPage, Manual from books')
Expand All @@ -624,9 +625,9 @@ def db_v16(myDB, upgradelog):
upgradelog.write("%s v16: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
myDB.action('CREATE TABLE IF NOT EXISTS temp_table (AuthorID TEXT, \
BookName TEXT, BookSub TEXT, BookDesc TEXT, BookGenre TEXT, BookIsbn TEXT, BookPub TEXT, \
BookRate INTEGER, BookImg TEXT, BookPages INTEGER, BookLink TEXT, BookID TEXT UNIQUE, \
BookFile TEXT, BookDate TEXT, BookLang TEXT, BookAdded TEXT, Status TEXT, WorkPage TEXT, \
Manual TEXT)')
BookRate INTEGER DEFAULT 0, BookImg TEXT, BookPages INTEGER DEFAULT 0, BookLink TEXT, \
BookID TEXT UNIQUE, BookFile TEXT, BookDate TEXT, BookLang TEXT, BookAdded TEXT, \
Status TEXT, WorkPage TEXT, Manual TEXT)')
myDB.action('INSERT INTO temp_table SELECT AuthorID, BookName, BookSub, \
BookDesc, BookGenre, BookIsbn, BookPub, BookRate, BookImg, BookPages, BookLink, BookID, \
BookFile, BookDate, BookLang, BookAdded, Status, WorkPage, Manual from books')
Expand Down Expand Up @@ -761,7 +762,7 @@ def db_v21(myDB, upgradelog):
myDB.action('UPDATE books SET AudioStatus="Skipped"')
lazylibrarian.UPDATE_MSG = 'Creating downloads table'
upgradelog.write("%s v21: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
myDB.action('CREATE TABLE IF NOT EXISTS downloads (Count INTEGER, Provider TEXT)')
myDB.action('CREATE TABLE IF NOT EXISTS downloads (Count INTEGER DEFAULT 0, Provider TEXT)')
downloads = myDB.select('SELECT NZBprov from wanted WHERE Status="Processed"')
for download in downloads:
entry = myDB.match('SELECT Count FROM downloads where Provider=?', (download['NZBprov'],))
Expand Down Expand Up @@ -789,7 +790,7 @@ def db_v23(myDB, upgradelog):
upgradelog.write("%s v23: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
cmd = 'CREATE TABLE IF NOT EXISTS users '
cmd += '(UserID TEXT UNIQUE, UserName TEXT UNIQUE, Password TEXT, Email TEXT, '
cmd += 'Name TEXT, Perms INTEGER)'
cmd += 'Name TEXT, Perms INTEGER DEFAULT 0)'
myDB.action(cmd)
cmd = 'INSERT into users (UserID, UserName, Name, Password, Email, Perms) VALUES (?, ?, ?, ?, ?, ?)'
user = lazylibrarian.CONFIG['HTTP_USER']
Expand Down Expand Up @@ -984,7 +985,8 @@ def db_v36(myDB, upgradelog):
if not has_column(myDB, "failedsearch", "Time"):
lazylibrarian.UPDATE_MSG = 'Creating failed search table'
upgradelog.write("%s v36: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
myDB.action('CREATE TABLE failedsearch (BookID TEXT, Library TEXT, Time TEXT, Interval INTEGER, Count INTEGER)')
myDB.action('CREATE TABLE failedsearch (BookID TEXT, Library TEXT, Time TEXT, ' +
'Interval INTEGER DEFAULT 0, Count INTEGER DEFAULT 0)')
upgradelog.write("%s v36: complete\n" % time.ctime())


Expand All @@ -994,8 +996,8 @@ def db_v37(myDB, upgradelog):
myDB.action('DROP TABLE IF EXISTS temp_table')
myDB.action('ALTER TABLE books RENAME TO temp_table')
myDB.action('CREATE TABLE books (AuthorID TEXT, BookName TEXT, BookSub TEXT, BookDesc TEXT, ' +
'BookGenre TEXT, BookIsbn TEXT, BookPub TEXT, BookRate INTEGER, BookImg TEXT, ' +
'BookPages INTEGER, BookLink TEXT, BookID TEXT UNIQUE, BookFile TEXT, ' +
'BookGenre TEXT, BookIsbn TEXT, BookPub TEXT, BookRate INTEGER DEFAULT 0, BookImg TEXT, ' +
'BookPages INTEGER DEFAULT 0, BookLink TEXT, BookID TEXT UNIQUE, BookFile TEXT, ' +
'BookDate TEXT, BookLang TEXT, BookAdded TEXT, Status TEXT, WorkPage TEXT, ' +
'Manual TEXT, SeriesDisplay TEXT, BookLibrary TEXT, AudioFile TEXT, ' +
'AudioLibrary TEXT, AudioStatus TEXT, WorkID TEXT, ScanResult TEXT, ' +
Expand Down Expand Up @@ -1054,9 +1056,22 @@ def db_v37(myDB, upgradelog):

myDB.action('ALTER TABLE failedsearch RENAME TO temp_table')
myDB.action('CREATE TABLE failedsearch (BookID TEXT, Library TEXT, Time TEXT, ' +
'Interval INTEGER, Count INTEGER,' +
'Interval INTEGER DEFAULT 0, Count INTEGER DEFAULT 0,' +
' CONSTRAINT fk_b FOREIGN KEY (BookID) REFERENCES books (BookID) ' +
'ON DELETE CASCADE)')
myDB.action('INSERT INTO failedsearch SELECT BookID,Library,Time,Interval,Count FROM temp_table')
myDB.action('DROP TABLE temp_table')
upgradelog.write("%s v37: complete\n" % time.ctime())


def db_v38(myDB, upgradelog):
lazylibrarian.UPDATE_MSG = 'Changing counters in series table to integers'
upgradelog.write("%s v38: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
myDB.action('DROP TABLE IF EXISTS temp_table')
myDB.action('ALTER TABLE series RENAME TO temp_table')
myDB.action('CREATE TABLE series (SeriesID INTEGER UNIQUE, SeriesName TEXT, Status TEXT, ' +
'Have INTEGER DEFAULT 0, Total INTEGER DEFAULT 0)')
myDB.action('INSERT INTO series SELECT SeriesID,SeriesName,Status,CAST(Have as INTEGER),CAST(Total as INTEGER)' +
' FROM temp_table')
myDB.action('DROP TABLE temp_table')
upgradelog.write("%s v38: complete\n" % time.ctime())
2 changes: 1 addition & 1 deletion lazylibrarian/gr.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def get_author_books(self, authorid=None, authorname=None, bookstatus="Skipped",
if not originalpubdate:
originalpubdate = '0000'

new_status = setStatus(bookid, serieslist, bookstatus)
new_status = setStatus(bookid, serieslist, book_status)
if new_status != book_status:
book_status = new_status

Expand Down
Loading

0 comments on commit 88ace37

Please sign in to comment.