From 20e10d6720b1c977382dbdd78ba3ae7457f97417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 4 Apr 2019 15:04:06 -0400 Subject: [PATCH] Notification progress bar. --- bazarr/get_episodes.py | 9 ++++----- bazarr/queueconfig.py | 10 +++++++--- views/menu.tpl | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/bazarr/get_episodes.py b/bazarr/get_episodes.py index 49ddc0a4c..c5fc868e8 100644 --- a/bazarr/get_episodes.py +++ b/bazarr/get_episodes.py @@ -49,9 +49,10 @@ def sync_episodes(): # Close database connection c.close() - - for seriesId in seriesIdList: - notifications.write(msg='Getting episodes data for this show: ' + seriesId[1], queue='get_episodes') + + seriesIdListLength = len(seriesIdList) + for i, seriesId in enumerate(seriesIdList, 1): + notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength) # Get episodes data for a series from Sonarr url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr try: @@ -151,8 +152,6 @@ def sync_episodes(): list_missing_subtitles() logging.debug('BAZARR All missing subtitles updated in database.') - - notifications.write(msg='Episodes sync from Sonarr ended.', queue='get_episodes') def SonarrFormatAudioCodec(audioCodec): diff --git a/bazarr/queueconfig.py b/bazarr/queueconfig.py index df81d0c2d..ad33e3218 100644 --- a/bazarr/queueconfig.py +++ b/bazarr/queueconfig.py @@ -10,7 +10,7 @@ class Notify: def __init__(self): self.queue = deque(maxlen=10) - def write(self, msg, type='info', duration='temporary', button='null', queue='main'): + def write(self, msg, type='info', duration='temporary', button='null', queue='main', item=0, length=0): """ :param msg: The message to display. :type msg: str @@ -19,12 +19,16 @@ class Notify: :param duration: The duration of the notification that can be: temporary, permanent :type duration: str :param button: The kind of button desired that can be: null, refresh, restart - :type duration: str + :type button: str :param queue: The name of the notification queue to use. Default is 'main' :type duration: str + :param item: The number of the item for progress bar + :type item: int + :param length: The length of the group of item for progress bar + :type length: int """ - self.queue.append(json.dumps([msg, type, duration, button, queue])) + self.queue.append(json.dumps([msg, type, duration, button, queue, item, length])) def read(self): """ diff --git a/views/menu.tpl b/views/menu.tpl index 4dfdc9f1b..84dc6876b 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -250,6 +250,14 @@ var duration = data[2]; var button = data[3]; var queue = data[4]; + var item = data[5]; + var length = data[6]; + + if (length === 0) { + var message = msg; + } else { + var message = msg + '

' + } if (duration === 'temporary') { timeout = 3000; @@ -269,7 +277,7 @@ } new Noty({ - text: msg, + text: message, progressBar: false, animation: { open: null, @@ -284,6 +292,13 @@ buttons: button, force: true }).show(); + + $('.notification_progress').progress({ + duration : 0, + autoSuccess: false, + value : item, + total : length + }); } }, complete: function (data) {