diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index 27c24501..6d06e77a 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -44,25 +44,16 @@

Watch Statistics

- % if config['home_stats_type'] == 0: -
Last - + days
@@ -128,7 +119,7 @@
- + items
@@ -727,20 +718,25 @@ }); } - var time_range = $('#watched-stats-days').val(); - var stats_type = $('input[name=watched-stats-type]:checked', '#watch-stats-toggles').val(); + var stats_type = getLocalStorage('home_stats_type', 'plays'); + var time_range = getLocalStorage('home_stats_days', 30); + + $('#watched-stats-' + stats_type).prop('checked', true); + $('#watched-stats-' + stats_type).closest('label').addClass('active'); + $('#watched-stats-days').val(time_range); + getHomeStats(time_range, stats_type); $('input[name=watched-stats-type]').change(function () { stats_type = $(this).filter(':checked').val(); + setLocalStorage('home_stats_type', stats_type); getHomeStats(time_range, stats_type); - $.post('set_home_stats_config', { stats_type: stats_type }); }); $('#watched-stats-days').change(function () { forceMinMax($(this)); time_range = $(this).val(); + setLocalStorage('home_stats_days', time_range); getHomeStats(time_range, stats_type); - $.post('set_home_stats_config', { time_range: time_range }); }); $('#watched-stats-days').tooltip({ container: 'body', placement: 'top', html: true }); @@ -783,8 +779,12 @@ } }); } - var recently_added_count = $('#recently-added-count').val(); + + var recently_added_count = getLocalStorage('home_stats_recently_added_count', 50); var recently_added_type = ''; + + $('#recently-added-count').val(recently_added_count); + recentlyAdded(recently_added_count, recently_added_type); function highlightAddedScrollerButton() { @@ -845,8 +845,8 @@ forceMinMax($(this)); recently_added_count = $(this).val(); resetScroller(); + setLocalStorage('home_stats_recently_added_count', recently_added_count); recentlyAdded(recently_added_count, recently_added_type); - $.post('set_home_stats_config', { recently_added_count: recently_added_count }); }); $('#recently-added-count').tooltip({ container: 'body', placement: 'top', html: true }); diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js index 328f1afc..7414a7de 100644 --- a/data/interfaces/default/js/script.js +++ b/data/interfaces/default/js/script.js @@ -524,7 +524,7 @@ function getLocalStorage(key, default_value) { var value = localStorage.getItem(key); if (value !== null) { return value - } else if (default_value) { + } else if (default_value !== undefined) { setLocalStorage(key, default_value); return default_value } diff --git a/plexpy/config.py b/plexpy/config.py index e5b39fe9..88223f34 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -203,12 +203,8 @@ _CONFIG_DEFINITIONS = { 'HISTORY_TABLE_ACTIVITY': (int, 'General', 1), 'HOME_SECTIONS': (list, 'General', ['current_activity','watch_stats','library_stats','recently_added']), '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': (list, 'General', ['top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', \ 'popular_music', 'last_watched', 'top_users', 'top_platforms', 'most_concurrent']), - 'HOME_STATS_RECENTLY_ADDED_COUNT': (int, 'General', 50), 'HOME_REFRESH_INTERVAL': (int, 'General', 10), 'HTTPS_CREATE_CERT': (int, 'General', 1), 'HTTPS_CERT': (str, 'General', ''), diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index c41ad2b8..3bab202a 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -266,12 +266,6 @@ class DataFactory(object): if grouping is None: grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES - if time_range is None: - time_range = plexpy.CONFIG.HOME_STATS_LENGTH - if stats_type is None: - stats_type = plexpy.CONFIG.HOME_STATS_TYPE - if stats_count is None: - stats_count = plexpy.CONFIG.HOME_STATS_COUNT if stats_cards is None: stats_cards = plexpy.CONFIG.HOME_STATS_CARDS diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 74821017..a8f6b785 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -173,10 +173,6 @@ class WebInterface(object): def home(self, **kwargs): config = { "home_sections": plexpy.CONFIG.HOME_SECTIONS, - "home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH, - "home_stats_type": plexpy.CONFIG.HOME_STATS_TYPE, - "home_stats_count": plexpy.CONFIG.HOME_STATS_COUNT, - "home_stats_recently_added_count": plexpy.CONFIG.HOME_STATS_RECENTLY_ADDED_COUNT, "home_refresh_interval": plexpy.CONFIG.HOME_REFRESH_INTERVAL, "pms_name": plexpy.CONFIG.PMS_NAME, "pms_is_cloud": plexpy.CONFIG.PMS_IS_CLOUD, @@ -301,24 +297,6 @@ class WebInterface(object): return serve_template(templatename="home_stats.html", title="Stats", data=stats_data) - @cherrypy.expose - @requireAuth(member_of("admin")) - def set_home_stats_config(self, time_range=None, stats_type=None, stats_count=None, recently_added_count=None, **kwargs): - if time_range: - plexpy.CONFIG.__setattr__('HOME_STATS_LENGTH', time_range) - plexpy.CONFIG.write() - if stats_type: - plexpy.CONFIG.__setattr__('HOME_STATS_TYPE', stats_type) - plexpy.CONFIG.write() - if stats_count: - plexpy.CONFIG.__setattr__('HOME_STATS_COUNT', stats_count) - plexpy.CONFIG.write() - if recently_added_count: - plexpy.CONFIG.__setattr__('HOME_STATS_RECENTLY_ADDED_COUNT', recently_added_count) - plexpy.CONFIG.write() - - return "Updated home stats config values." - @cherrypy.expose @requireAuth() def library_stats(self, **kwargs): @@ -1838,16 +1816,7 @@ class WebInterface(object): @cherrypy.expose @requireAuth() def graphs(self, **kwargs): - - config = { - "graph_type": plexpy.CONFIG.GRAPH_TYPE, - "graph_days": plexpy.CONFIG.GRAPH_DAYS, - "graph_months": plexpy.CONFIG.GRAPH_MONTHS, - "graph_tab": plexpy.CONFIG.GRAPH_TAB, - "music_logging_enable": plexpy.CONFIG.MUSIC_LOGGING_ENABLE - } - - return serve_template(templatename="graphs.html", title="Graphs", config=config) + return serve_template(templatename="graphs.html", title="Graphs") @cherrypy.expose @cherrypy.tools.json_out()