mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Change home cards config to list type
This commit is contained in:
parent
8f367d140f
commit
8ba68dcfcf
9 changed files with 81 additions and 37 deletions
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
% if config['home_stats_cards'] > 'watch_statistics':
|
||||
% if config['home_stats_cards']:
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="padded-header">
|
||||
|
@ -29,7 +29,7 @@
|
|||
</div>
|
||||
</div>
|
||||
% endif
|
||||
% if config['home_library_cards'] > 'library_statistics':
|
||||
% if config['home_library_cards']:
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="padded-header" id="library-statistics-header">
|
||||
|
|
|
@ -18,7 +18,7 @@ from plexpy import helpers
|
|||
<div class='container-fluid'>
|
||||
<div class='table-card-header'>
|
||||
<div class="header-bar">
|
||||
<span><i class="fa fa-book"></i> Logs</span>
|
||||
<span><i class="fa fa-list-alt"></i> Logs</span>
|
||||
</div>
|
||||
<div class="button-bar">
|
||||
<button class="btn btn-dark" id="clear-logs"><i class="fa fa-trash-o"></i> Clear log</button>
|
||||
|
|
|
@ -102,7 +102,6 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
<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">
|
||||
<option id="card-watch_statistics" value="watch_statistics" class="hidden" selected>Watch Statistics</option>
|
||||
<option id="card-top_tv" value="top_tv">Most Watched TV</option>
|
||||
<option id="card-popular_tv" value="popular_tv">Most Popular TV</option>
|
||||
<option id="card-top_movies" value="top_movies">Most Watched Movie</option>
|
||||
|
@ -154,7 +153,6 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
<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>
|
||||
|
@ -1619,7 +1617,7 @@ $(document).ready(function() {
|
|||
var accordion_timeline = new Accordion($('#accordion-timeline'), false);
|
||||
var accordion_scripts = new Accordion($('#accordion-scripts'), false);
|
||||
|
||||
var cards = "${config['home_stats_cards']}".split(/[\s,]+/);
|
||||
var cards = ${config['home_stats_cards']|n};
|
||||
cards.forEach(function (item) {
|
||||
$('#card-'+item).prop('selected', !$(this).prop('selected'));
|
||||
});
|
||||
|
@ -1633,18 +1631,17 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
$.ajax({
|
||||
url: 'get_server_children',
|
||||
url: 'get_library_sections',
|
||||
data: { },
|
||||
async: true,
|
||||
complete: function (xhr, status) {
|
||||
server_children_info = $.parseJSON(xhr.responseText);
|
||||
libraries_list = server_children_info.libraries_list;
|
||||
complete: function (data) {
|
||||
libraries_list = $.parseJSON(data.responseText);
|
||||
for (var i in libraries_list) {
|
||||
title = libraries_list[i].title;
|
||||
key = libraries_list[i].key;
|
||||
var title = libraries_list[i].section_name;
|
||||
var key = libraries_list[i].section_id;
|
||||
$('#home_library_cards').append('<option id="card-' + key + '" value="' + key + '">' + title + '</option>')
|
||||
}
|
||||
var cards = "${config['home_library_cards']}".split(/[\s,]+/);
|
||||
var cards = ${config['home_library_cards']|n};
|
||||
cards.forEach(function (item) {
|
||||
$('#card-' + item).prop('selected', !$(this).prop('selected'));
|
||||
});
|
||||
|
|
|
@ -168,8 +168,11 @@ from plexpy import common
|
|||
<div style="display: none;">
|
||||
<input type="checkbox" name="launch_browser" id="launch_browser" value="1" ${config['launch_browser']}>
|
||||
<input type="checkbox" name="refresh_users_on_startup" id="refresh_users_on_startup" value="1" ${config['refresh_users_on_startup']}>
|
||||
<input type="checkbox" name="refresh_libraries_on_startup" id="refresh_libraries_on_startup" value="1" ${config['refresh_libraries_on_startup']}>
|
||||
<input type="checkbox" name="first_run_complete" id="first_run_complete" value="1" checked>
|
||||
<input type="checkbox" name="check_github" id="check_github" value="1" checked>
|
||||
<input type="text" name="home_stats_cards" id="home_stats_cards" value="first_run_wizard">
|
||||
<input type="text" name="home_library_cards" id="home_library_cards" value="first_run_wizard">
|
||||
</div>
|
||||
</div>
|
||||
<!-- Required fields but hidden -->
|
||||
|
|
|
@ -260,8 +260,6 @@ def initialize_scheduler():
|
|||
Start the scheduled background tasks. Re-schedule if interval settings changed.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
with SCHED_LOCK:
|
||||
|
||||
# Check if scheduler should be started
|
||||
|
@ -435,7 +433,7 @@ def dbcheck():
|
|||
'CREATE TABLE IF NOT EXISTS notify_log (id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
||||
'session_key INTEGER, rating_key INTEGER, user_id INTEGER, user TEXT, '
|
||||
'agent_id INTEGER, agent_name TEXT, on_play INTEGER, on_stop INTEGER, on_watched INTEGER, '
|
||||
'on_pause INTEGER, on_resume INTEGER, on_buffer INTEGER)'
|
||||
'on_pause INTEGER, on_resume INTEGER, on_buffer INTEGER, on_created INTEGER)'
|
||||
)
|
||||
|
||||
# library_sections table :: This table keeps record of the servers library sections
|
||||
|
|
|
@ -118,12 +118,12 @@ _CONFIG_DEFINITIONS = {
|
|||
'GROWL_ON_INTDOWN': (int, 'Growl', 0),
|
||||
'GROWL_ON_EXTUP': (int, 'Growl', 0),
|
||||
'GROWL_ON_INTUP': (int, 'Growl', 0),
|
||||
'HOME_LIBRARY_CARDS': (str, 'General', 'library_statistics_first'),
|
||||
'HOME_LIBRARY_CARDS': (list, 'General', ['first_run']),
|
||||
'HOME_STATS_LENGTH': (int, 'General', 30),
|
||||
'HOME_STATS_TYPE': (int, 'General', 0),
|
||||
'HOME_STATS_COUNT': (int, 'General', 5),
|
||||
'HOME_STATS_CARDS': (str, 'General', 'watch_statistics, top_tv, popular_tv, top_movies, popular_movies, ' \
|
||||
'top_music, popular_music, last_watched, top_users, top_platforms, most_concurrent'),
|
||||
'HOME_STATS_CARDS': (list, 'General', ['top_tv', 'popular_tv', 'top_movies', 'popular_movies', 'top_music', \
|
||||
'popular_music', 'last_watched', 'top_users', 'top_platforms', 'most_concurrent']),
|
||||
'HTTPS_CERT': (str, 'General', ''),
|
||||
'HTTPS_KEY': (str, 'General', ''),
|
||||
'HTTP_HOST': (str, 'General', '0.0.0.0'),
|
||||
|
@ -508,3 +508,17 @@ class Config(object):
|
|||
self.MOVIE_LOGGING_ENABLE = 0
|
||||
self.TV_LOGGING_ENABLE = 0
|
||||
self.CONFIG_VERSION = '1'
|
||||
if self.CONFIG_VERSION == '1':
|
||||
# Change home_stats_cards to list
|
||||
if self.HOME_STATS_CARDS:
|
||||
home_stats_cards = ''.join(self.HOME_STATS_CARDS).split(', ')
|
||||
if 'watch_statistics' in home_stats_cards:
|
||||
home_stats_cards.remove('watch_statistics')
|
||||
self.HOME_STATS_CARDS = home_stats_cards
|
||||
# Change home_library_cards to list
|
||||
if self.HOME_LIBRARY_CARDS:
|
||||
home_library_cards = ''.join(self.HOME_LIBRARY_CARDS).split(', ')
|
||||
if 'library_statistics' in home_library_cards:
|
||||
home_library_cards.remove('library_statistics')
|
||||
self.HOME_LIBRARY_CARDS = home_library_cards
|
||||
self.CONFIG_VERSION = '2'
|
|
@ -158,7 +158,7 @@ class DataFactory(object):
|
|||
|
||||
return dict
|
||||
|
||||
def get_home_stats(self, grouping=0, time_range='30', stats_type=0, stats_count='5', stats_cards='', notify_watched_percent='85'):
|
||||
def get_home_stats(self, grouping=0, time_range='30', stats_type=0, stats_count='5', stats_cards=[], notify_watched_percent='85'):
|
||||
monitor_db = database.MonitorDatabase()
|
||||
|
||||
group_by = 'session_history.reference_id' if grouping else 'session_history.id'
|
||||
|
@ -654,7 +654,7 @@ class DataFactory(object):
|
|||
|
||||
return home_stats
|
||||
|
||||
def get_library_stats(self, library_cards=''):
|
||||
def get_library_stats(self, library_cards=[]):
|
||||
monitor_db = database.MonitorDatabase()
|
||||
|
||||
library_stats = []
|
||||
|
@ -1219,6 +1219,26 @@ class DataFactory(object):
|
|||
|
||||
return True
|
||||
|
||||
def get_library_sections(self):
|
||||
monitor_db = database.MonitorDatabase()
|
||||
|
||||
try:
|
||||
query = 'SELECT section_id, section_name FROM library_sections'
|
||||
result = monitor_db.select(query=query)
|
||||
except:
|
||||
logger.warn("Unable to execute database query for get_library_sections.")
|
||||
return None
|
||||
|
||||
libraries = []
|
||||
for item in result:
|
||||
library = {'section_id': item['section_id'],
|
||||
'section_name': item['section_name']
|
||||
}
|
||||
libraries.append(library)
|
||||
|
||||
return libraries
|
||||
|
||||
|
||||
def update_library_sections(self):
|
||||
from plexpy import pmsconnect
|
||||
|
||||
|
|
|
@ -68,6 +68,12 @@ def refresh_libraries():
|
|||
|
||||
monitor_db.upsert('library_sections', key_dict=section_keys, value_dict=section_values)
|
||||
|
||||
cards.append(section['key'])
|
||||
|
||||
if populate_cards:
|
||||
plexpy.CONFIG.__setattr__('HOME_LIBRARY_CARDS', cards)
|
||||
plexpy.CONFIG.write()
|
||||
|
||||
logger.info("Libraries list refreshed.")
|
||||
else:
|
||||
logger.warn("Unable to refresh libraries list.")
|
||||
|
|
|
@ -80,7 +80,7 @@ class WebInterface(object):
|
|||
config = {
|
||||
"launch_browser": checked(plexpy.CONFIG.LAUNCH_BROWSER),
|
||||
"refresh_users_on_startup": checked(plexpy.CONFIG.REFRESH_USERS_ON_STARTUP),
|
||||
"refresh_librareis_on_startup": checked(plexpy.CONFIG.REFRESH_LIBRARIES_ON_STARTUP),
|
||||
"refresh_libraries_on_startup": checked(plexpy.CONFIG.REFRESH_LIBRARIES_ON_STARTUP),
|
||||
"pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER,
|
||||
"pms_ip": plexpy.CONFIG.PMS_IP,
|
||||
"pms_is_remote": checked(plexpy.CONFIG.PMS_IS_REMOTE),
|
||||
|
@ -133,7 +133,7 @@ class WebInterface(object):
|
|||
time_range = plexpy.CONFIG.HOME_STATS_LENGTH
|
||||
stats_type = plexpy.CONFIG.HOME_STATS_TYPE
|
||||
stats_count = plexpy.CONFIG.HOME_STATS_COUNT
|
||||
stats_cards = plexpy.CONFIG.HOME_STATS_CARDS.split(', ')
|
||||
stats_cards = plexpy.CONFIG.HOME_STATS_CARDS
|
||||
notify_watched_percent = plexpy.CONFIG.NOTIFY_WATCHED_PERCENT
|
||||
|
||||
stats_data = data_factory.get_home_stats(grouping=grouping,
|
||||
|
@ -149,7 +149,7 @@ class WebInterface(object):
|
|||
def library_stats(self, **kwargs):
|
||||
data_factory = datafactory.DataFactory()
|
||||
|
||||
library_cards = plexpy.CONFIG.HOME_LIBRARY_CARDS.split(', ')
|
||||
library_cards = plexpy.CONFIG.HOME_LIBRARY_CARDS
|
||||
|
||||
stats_data = data_factory.get_library_stats(library_cards=library_cards)
|
||||
|
||||
|
@ -476,8 +476,8 @@ class WebInterface(object):
|
|||
"home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH,
|
||||
"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,
|
||||
"home_stats_cards": json.dumps(plexpy.CONFIG.HOME_STATS_CARDS),
|
||||
"home_library_cards": json.dumps(plexpy.CONFIG.HOME_LIBRARY_CARDS),
|
||||
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
|
||||
"buffer_wait": plexpy.CONFIG.BUFFER_WAIT,
|
||||
"group_history_tables": checked(plexpy.CONFIG.GROUP_HISTORY_TABLES)
|
||||
|
@ -544,13 +544,19 @@ class WebInterface(object):
|
|||
refresh_libraries = True
|
||||
refresh_users = True
|
||||
|
||||
if 'home_stats_cards' in kwargs:
|
||||
if kwargs['home_stats_cards'] != 'watch_statistics':
|
||||
kwargs['home_stats_cards'] = ', '.join(kwargs['home_stats_cards'])
|
||||
if 'home_stats_cards' not in kwargs:
|
||||
kwargs['home_stats_cards'] = []
|
||||
elif kwargs['home_stats_cards'] == 'first_run_wizard':
|
||||
kwargs['home_stats_cards'] = plexpy.CONFIG.HOME_STATS_CARDS
|
||||
elif type(kwargs['home_stats_cards']) != list:
|
||||
kwargs['home_stats_cards'] = [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'])
|
||||
if 'home_library_cards' not in kwargs:
|
||||
kwargs['home_library_cards'] = []
|
||||
elif kwargs['home_library_cards'] == 'first_run_wizard':
|
||||
kwargs['home_library_cards'] = plexpy.CONFIG.HOME_LIBRARY_CARDS
|
||||
elif type(kwargs['home_library_cards']) != list:
|
||||
kwargs['home_library_cards'] = [kwargs['home_library_cards']]
|
||||
|
||||
plexpy.CONFIG.process_kwargs(kwargs)
|
||||
|
||||
|
@ -1279,10 +1285,10 @@ class WebInterface(object):
|
|||
logger.warn('Unable to retrieve data.')
|
||||
|
||||
@cherrypy.expose
|
||||
def get_server_children(self, **kwargs):
|
||||
def get_library_sections(self, **kwargs):
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_server_children()
|
||||
data_factory = datafactory.DataFactory()
|
||||
result = data_factory.get_library_sections()
|
||||
|
||||
if result:
|
||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue