mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Content server: In the book list hovering over the library name now shows the total number of books in the library. Fixes #1881384 [[Enhancement - Content server] Show number of books in a library](https://bugs.launchpad.net/calibre/+bug/1881384)
This commit is contained in:
parent
e92b93ba80
commit
11d608bf47
@ -1027,6 +1027,12 @@ class Cache(object):
|
||||
return frozenset(self._search('', vl))
|
||||
return frozenset(self._search('', search_restriction))
|
||||
|
||||
@read_api
|
||||
def number_of_books_in_virtual_library(self, vl=None, search_restriction=None):
|
||||
if not vl and not search_restriction:
|
||||
return len(self.fields['uuid'].table.book_col_map)
|
||||
return len(self.books_in_virtual_library(vl, search_restriction))
|
||||
|
||||
@api
|
||||
def get_categories(self, sort='name', book_ids=None, already_fixed=None,
|
||||
first_letter_sort=False):
|
||||
|
@ -539,8 +539,10 @@ def search_result(ctx, rd, db, query, num, offset, sort, sort_order, vl=''):
|
||||
ids = db.multisort(fields=multisort, ids_to_sort=ids)
|
||||
total_num = len(ids)
|
||||
ids = ids[offset:offset+num]
|
||||
num_books = db.number_of_books_in_virtual_library(vl) if query else total_num
|
||||
ans = {
|
||||
'total_num': total_num, 'sort_order':sort_order,
|
||||
'num_books_without_search': num_books,
|
||||
'offset':offset, 'num':len(ids), 'sort':sort,
|
||||
'base_url':ctx.url_for(search, library_id=db.server_library_id),
|
||||
'query': query,
|
||||
|
@ -82,6 +82,13 @@ def set_title(container, text):
|
||||
for bar in bars:
|
||||
bar.firstChild.firstChild.nextSibling.textContent = text
|
||||
|
||||
|
||||
def set_title_tooltip(container, text):
|
||||
bars = get_bars(container)
|
||||
for bar in bars:
|
||||
bar.firstChild.firstChild.nextSibling.title = text
|
||||
|
||||
|
||||
def create_top_bar(container, **kw):
|
||||
create_markup(container)
|
||||
set_left_data(container, **kw)
|
||||
|
@ -34,7 +34,7 @@ from book_list.router import back, home, push_state, update_window_title
|
||||
from book_list.search import (
|
||||
init as init_search_panel, set_apply_search, tb_config_panel_handler
|
||||
)
|
||||
from book_list.top_bar import add_button, create_top_bar
|
||||
from book_list.top_bar import add_button, create_top_bar, set_title_tooltip
|
||||
from book_list.ui import query_as_href, set_panel_handler, show_panel
|
||||
from dom import add_extra_css, build_rule, clear, ensure_id, set_css
|
||||
from modals import error_dialog
|
||||
@ -319,6 +319,8 @@ def check_for_books_loaded():
|
||||
)
|
||||
return
|
||||
create_books_list(container)
|
||||
if library_data.search_result and jstype(library_data.search_result.num_books_without_search) is 'number':
|
||||
set_title_tooltip(this, _('Total number of books: {}').format(library_data.search_result.num_books_without_search))
|
||||
|
||||
|
||||
def init(container_id):
|
||||
|
Loading…
x
Reference in New Issue
Block a user