mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Add setting to selectively hide library statistics cards on the homepage
This commit is contained in:
parent
8a989d71ca
commit
078f4babf5
5 changed files with 89 additions and 7 deletions
|
@ -29,6 +29,7 @@
|
|||
</div>
|
||||
</div>
|
||||
% endif
|
||||
% if config['home_library_cards'] > 'library_statistics':
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="padded-header" id="library-statistics-header">
|
||||
|
@ -40,6 +41,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
<div class='row'>
|
||||
<div class="col-md-12">
|
||||
<div class="padded-header">
|
||||
|
|
|
@ -93,7 +93,7 @@ available_notification_agents = notifiers.available_notification_agents()
|
|||
|
||||
<div class="form-group">
|
||||
<label for="home_stats_cards">Cards</label>
|
||||
<p class="help-block">Select the cards to show in the watch statistics on the home page.</p>
|
||||
<p class="help-block">Select the cards to show in the watch statistics on the home page. Select none to disable.</p>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<select multiple class="form-control" id="home_stats_cards" name="home_stats_cards" data-parsley-trigger="change">
|
||||
|
@ -137,7 +137,24 @@ available_notification_agents = notifiers.available_notification_agents()
|
|||
</label>
|
||||
<p class="help-block">Use play duration instead of play count to generate statistics.</p>
|
||||
</div>
|
||||
|
||||
<div class="padded-header">
|
||||
<h3>Library Statistics</h3>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="home_library_cards">Cards</label>
|
||||
<p class="help-block">Select the cards to show in the library statistics on the home page. Select none to disable.</p>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<select multiple class="form-control" id="home_library_cards" name="home_library_cards" data-parsley-trigger="change">
|
||||
<option id="card-library_statistics" value="library_statistics" class="hidden" selected>Library Statistics</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p><input type="button" class="btn btn-bright save-button" value="Save" data-success="Changes saved successfully"></p>
|
||||
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="tabs-3">
|
||||
<div class="padded-header">
|
||||
|
@ -1215,6 +1232,34 @@ $(document).ready(function() {
|
|||
}).on('mousemove', function(e) {
|
||||
e.preventDefault()
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: 'get_server_children',
|
||||
data: { },
|
||||
async: true,
|
||||
complete: function (xhr, status) {
|
||||
server_children_info = $.parseJSON(xhr.responseText);
|
||||
libraries_list = server_children_info.libraries_list;
|
||||
for (var i in libraries_list) {
|
||||
title = libraries_list[i].title;
|
||||
key = libraries_list[i].key;
|
||||
$('#home_library_cards').append('<option id="card-' + key + '" value="' + key + '">' + title + '</option>')
|
||||
}
|
||||
var cards = "${config['home_library_cards']}".split(/[\s,]+/);
|
||||
cards.forEach(function (item) {
|
||||
$('#card-'+item).prop('selected', !$(this).prop('selected'));
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#home_library_cards').on('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
var scroll = this.scrollTop;
|
||||
e.target.selected = !e.target.selected;
|
||||
this.scrollTop = scroll;
|
||||
}).on('mousemove', function(e) {
|
||||
e.preventDefault()
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</%def>
|
||||
|
|
|
@ -82,10 +82,11 @@ _CONFIG_DEFINITIONS = {
|
|||
'GROWL_ON_RESUME': (int, 'Growl', 0),
|
||||
'GROWL_ON_BUFFER': (int, 'Growl', 0),
|
||||
'GROWL_ON_WATCHED': (int, 'Growl', 0),
|
||||
'HOME_LIBRARY_CARDS': (str, 'General', 'library_statistics_first'),
|
||||
'HOME_STATS_LENGTH': (int, 'General', 30),
|
||||
'HOME_STATS_TYPE': (int, 'General', 0),
|
||||
'HOME_STATS_COUNT': (int, 'General', 5),
|
||||
'HOME_STATS_CARDS': (str, 'General', 'top_tv, popular_tv, top_movies, popular_movies, top_music, popular_music, top_users, top_platforms, last_watched'),
|
||||
'HOME_STATS_CARDS': (str, 'General', 'watch_statistics_first'),
|
||||
'HTTPS_CERT': (str, 'General', ''),
|
||||
'HTTPS_KEY': (str, 'General', ''),
|
||||
'HTTP_HOST': (str, 'General', '0.0.0.0'),
|
||||
|
|
|
@ -1270,13 +1270,15 @@ class PmsConnect(object):
|
|||
return output
|
||||
|
||||
"""
|
||||
Return processed and validated server statistics.
|
||||
Return processed and validated library statistics.
|
||||
|
||||
Output: array
|
||||
"""
|
||||
def get_library_stats(self):
|
||||
def get_library_stats(self, library_cards=''):
|
||||
server_libraries = self.get_server_children()
|
||||
|
||||
library_keys = library_cards.split(', ')
|
||||
|
||||
server_library_stats = []
|
||||
|
||||
if server_libraries['libraries_count'] != '0':
|
||||
|
@ -1285,7 +1287,10 @@ class PmsConnect(object):
|
|||
for library in libraries_list:
|
||||
library_type = library['type']
|
||||
section_key = library['key']
|
||||
if section_key in library_keys:
|
||||
library_list = self.get_library_children(library_type, section_key)
|
||||
else:
|
||||
continue
|
||||
|
||||
if library_list['library_count'] != '0':
|
||||
library_stats = {'title': library['title'],
|
||||
|
|
|
@ -67,6 +67,7 @@ class WebInterface(object):
|
|||
config = {
|
||||
"home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH,
|
||||
"home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS,
|
||||
"home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS,
|
||||
"pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER
|
||||
}
|
||||
return serve_template(templatename="index.html", title="Home", config=config)
|
||||
|
@ -140,7 +141,10 @@ class WebInterface(object):
|
|||
@cherrypy.expose
|
||||
def library_stats(self, **kwargs):
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
stats_data = pms_connect.get_library_stats()
|
||||
|
||||
library_cards = plexpy.CONFIG.HOME_LIBRARY_CARDS
|
||||
|
||||
stats_data = pms_connect.get_library_stats(library_cards=library_cards)
|
||||
|
||||
return serve_template(templatename="library_stats.html", title="Library Stats", data=stats_data)
|
||||
|
||||
|
@ -479,6 +483,7 @@ class WebInterface(object):
|
|||
"home_stats_type": checked(plexpy.CONFIG.HOME_STATS_TYPE),
|
||||
"home_stats_count": plexpy.CONFIG.HOME_STATS_COUNT,
|
||||
"home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS,
|
||||
"home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS,
|
||||
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
|
||||
"buffer_wait": plexpy.CONFIG.BUFFER_WAIT
|
||||
}
|
||||
|
@ -535,6 +540,10 @@ class WebInterface(object):
|
|||
if kwargs['home_stats_cards'] != 'watch_statistics':
|
||||
kwargs['home_stats_cards'] = ', '.join(kwargs['home_stats_cards'])
|
||||
|
||||
if 'home_library_cards' in kwargs:
|
||||
if kwargs['home_library_cards'] != 'library_statistics':
|
||||
kwargs['home_library_cards'] = ', '.join(kwargs['home_library_cards'])
|
||||
|
||||
plexpy.CONFIG.process_kwargs(kwargs)
|
||||
|
||||
# Write the config
|
||||
|
@ -1132,6 +1141,26 @@ class WebInterface(object):
|
|||
else:
|
||||
logger.warn('Unable to retrieve data.')
|
||||
|
||||
@cherrypy.expose
|
||||
def get_server_children(self, **kwargs):
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_server_children()
|
||||
|
||||
if plexpy.CONFIG.HOME_LIBRARY_CARDS == '':
|
||||
library_keys = ['library_statistics']
|
||||
for library in result['libraries_list']:
|
||||
library_keys.append(library['key'])
|
||||
|
||||
plexpy.CONFIG.HOME_LIBRARY_CARDS = ', '.join(library_keys)
|
||||
plexpy.CONFIG.write()
|
||||
|
||||
if result:
|
||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||
return json.dumps(result)
|
||||
else:
|
||||
logger.warn('Unable to retrieve data.')
|
||||
|
||||
@cherrypy.expose
|
||||
def get_activity(self, **kwargs):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue