From 3c0d0f5b00357690428e0378545838ed7876d807 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Fri, 26 Jan 2018 20:55:25 +0000 Subject: [PATCH] Add footer icon button to switch time layouts. --- CHANGES.md | 1 + gui/slick/css/style.css | 21 +++++++++++ gui/slick/interfaces/default/inc_bottom.tmpl | 39 +++++++++++++++----- sickbeard/__init__.py | 5 ++- sickbeard/webserve.py | 25 +++++++++++++ 5 files changed, 80 insertions(+), 11 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 34c17dd4..cfd99641 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ * Add a provider error table to page Manage/Media Search * Add failure handling, skip provider for x hour(s) depending on count of failures * Add detection of Too Many Requests (Supporting providers UC and BTN) +* Add footer icon button to switch time layouts [develop changelog] diff --git a/gui/slick/css/style.css b/gui/slick/css/style.css index 0ab227d7..3542c285 100644 --- a/gui/slick/css/style.css +++ b/gui/slick/css/style.css @@ -639,6 +639,27 @@ inc_bottom.tmpl display:inline } +.footer .icon-glyph{ + opacity:0.4;filter:alpha(opacity=40); + float:none; + display:inline-block; + margin:0 0 -2px 0; + height:12px; + width:14px +} +.footer .icon-glyph:hover{ + opacity:0.6;filter:alpha(opacity=60); + cursor:pointer +} +.footer .icon-glyph.timeleft, +.footer .icon-glyph.time:hover{ + background-position:-48px -25px +} +.footer .icon-glyph.time, +.footer .icon-glyph.timeleft:hover{ + background-position:-192px -121px +} + /* ======================================================================= inc_rootDirs.tmpl ========================================================================== */ diff --git a/gui/slick/interfaces/default/inc_bottom.tmpl b/gui/slick/interfaces/default/inc_bottom.tmpl index 1f366b6a..36acea1d 100644 --- a/gui/slick/interfaces/default/inc_bottom.tmpl +++ b/gui/slick/interfaces/default/inc_bottom.tmpl @@ -4,6 +4,7 @@ #from sickbeard import db, sbdatetime #from sickbeard.common import * #from sickbeard.helpers import df +#from sickbeard.webserve import MainHandler <% def sg_var(varname, default=False): return getattr(sickbeard, varname, default) %>#slurp# <% def sg_str(varname, default=''): return getattr(sickbeard, varname, default) %>#slurp# ## @@ -54,14 +55,6 @@ #set $localheader = '' #end try <% -try: - next_backlog_timeleft = str(sickbeard.backlogSearchScheduler.next_backlog_timeleft()).split('.')[0] -except AttributeError: - next_backlog_timeleft = 'soon' -try: - recent_search_timeleft = str(sickbeard.recentSearchScheduler.timeLeft()).split('.')[0] -except AttributeError: - recent_search_timeleft = 'soon' diskfree, min_output = df() if min_output: avail = ', '.join(['%s %s' % (drive, free) for (drive, free) in diskfree]) @@ -76,8 +69,15 @@ if min_output: % (localRoot, str(ep_snatched)) )[0 < ep_snatched] %> / $ep_total episodes downloaded $ep_percentage - | recent search: $recent_search_timeleft - | backlog search: $next_backlog_timeleft +#for i, event in enumerate($MainHandler.getFooterTime(ajax_layout=False)) + #for k, v in event.items() + #set info = re.findall('(.*)_(timeleft|time)', k)[0] + #if not i +
+ #end if + | $info[0].replace('-', ' '): $v + #end for +#end for #if diskfree #if min_output
free space  $avail @@ -103,6 +103,25 @@ if min_output: #end if #end if + diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 896134ac..d4caa92a 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -463,6 +463,7 @@ FANART_LIMIT = None FANART_PANEL = None FANART_RATINGS = {} HOME_LAYOUT = None +FOOTER_TIME_LAYOUT = 0 POSTER_SORTBY = None POSTER_SORTDIR = None DISPLAY_SHOW_VIEWMODE = 0 @@ -574,7 +575,7 @@ def initialize(console_logging=True): # Post processing global KEEP_PROCESSED_DIR # Views - global GUI_NAME, HOME_LAYOUT, POSTER_SORTBY, POSTER_SORTDIR, DISPLAY_SHOW_SPECIALS, \ + global GUI_NAME, HOME_LAYOUT, FOOTER_TIME_LAYOUT, POSTER_SORTBY, POSTER_SORTDIR, DISPLAY_SHOW_SPECIALS, \ EPISODE_VIEW_LAYOUT, EPISODE_VIEW_SORT, EPISODE_VIEW_DISPLAY_PAUSED, \ EPISODE_VIEW_MISSED_RANGE, EPISODE_VIEW_POSTERS, FANART_PANEL, FANART_RATINGS, \ EPISODE_VIEW_VIEWMODE, EPISODE_VIEW_BACKGROUND, EPISODE_VIEW_BACKGROUND_TRANSLUCENT, \ @@ -1153,6 +1154,7 @@ def initialize(console_logging=True): METADATA_KODI = check_setting_str(CFG, 'General', 'metadata_kodi', '0|0|0|0|0|0|0|0|0|0') HOME_LAYOUT = check_setting_str(CFG, 'GUI', 'home_layout', 'poster') + FOOTER_TIME_LAYOUT = check_setting_int(CFG, 'GUI', 'footer_time_layout', 0) POSTER_SORTBY = check_setting_str(CFG, 'GUI', 'poster_sortby', 'name') POSTER_SORTDIR = check_setting_int(CFG, 'GUI', 'poster_sortdir', 1) DISPLAY_SHOW_VIEWMODE = check_setting_int(CFG, 'GUI', 'display_show_viewmode', 0) @@ -1951,6 +1953,7 @@ def save_config(): new_config['GUI']['showlist_tagview'] = SHOWLIST_TAGVIEW new_config['GUI']['home_layout'] = HOME_LAYOUT + new_config['GUI']['footer_time_layout'] = FOOTER_TIME_LAYOUT new_config['GUI']['poster_sortby'] = POSTER_SORTBY new_config['GUI']['poster_sortdir'] = POSTER_SORTDIR diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 7bc70634..50b4e7cf 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -602,6 +602,31 @@ class MainHandler(WebHandler): sickbeard.save_config() + @staticmethod + def getFooterTime(ajax_layout=True, *args, **kwargs): + + now = datetime.datetime.now() + events = [ + ('search-recent', sickbeard.recentSearchScheduler.timeLeft()), + ('search-backlog', sickbeard.backlogSearchScheduler.next_backlog_timeleft()), + ] + + if ajax_layout: + sickbeard.FOOTER_TIME_LAYOUT += 1 + if sickbeard.FOOTER_TIME_LAYOUT == 2: # 2 layouts = time + delta + sickbeard.FOOTER_TIME_LAYOUT = 0 + sickbeard.save_config() + + if 0 == sickbeard.FOOTER_TIME_LAYOUT: + next_event = [{k + '_time': sbdatetime.sbdatetime.sbftime(now + v, markup=True)} for (k, v) in events] + else: + next_event = [{k + '_timeleft': str(v).split('.')[0]} for (k, v) in events] + + if ajax_layout: + next_event = json.dumps(next_event) + + return next_event + def toggleDisplayShowSpecials(self, show): sickbeard.DISPLAY_SHOW_SPECIALS = not sickbeard.DISPLAY_SHOW_SPECIALS