Add footer icon button to switch time layouts.

This commit is contained in:
JackDandy 2018-01-26 20:55:25 +00:00
parent f6113c6ffc
commit 3c0d0f5b00
5 changed files with 80 additions and 11 deletions

View file

@ -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]

View file

@ -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
========================================================================== */

View file

@ -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 <span class="footerhighlight">%s</span>' % (drive, free) for (drive, free) in diskfree])
@ -76,8 +69,15 @@ if min_output:
% (localRoot, str(ep_snatched))
)[0 < ep_snatched]
%>&nbsp;/&nbsp;<span class="footerhighlight">$ep_total</span> episodes downloaded $ep_percentage
| recent search: <span class="footerhighlight">$recent_search_timeleft</span>
| backlog search: <span class="footerhighlight">$next_backlog_timeleft</span>
#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
<br><i class="icon-glyph layout $info[1]" title="Change time layout"></i>
#end if
| $info[0].replace('-', ' '): <span class="footerhighlight $info[0]">$v</span>
#end for
#end for
#if diskfree
#if min_output
<br>free space&nbsp;&nbsp;$avail
@ -103,6 +103,25 @@ if min_output:
#end if
#end if
</div>
<script>
var footerTimeUrl = '$localRoot/getFooterTime';
#raw
$(function(){
$('.footer').find('.layout').click(function(){
$.getJSON(footerTimeUrl, function(data){
var info, footerIcon$ = $('.footer').find('.icon-glyph.layout');
$.each(data, function(i, eventItems){
$.each(eventItems, function(k, v){
info = k.match(/(.*)_(timeleft|time)/);
$('.footer').find('.' + info[1]).html(v);
footerIcon$.removeClass('time').removeClass('timeleft').addClass(info[2])
});
});
});
});
});
#end raw
</script>
</footer>
</body>
</html>

View file

@ -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

View file

@ -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