mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 21:21:15 -07:00
Save home stats config to local storage instead of server
This commit is contained in:
parent
d93390f8ed
commit
018356b85e
5 changed files with 22 additions and 63 deletions
|
@ -44,25 +44,16 @@
|
||||||
<h3 class="pull-left">Watch Statistics</h3>
|
<h3 class="pull-left">Watch Statistics</h3>
|
||||||
<div class="button-bar">
|
<div class="button-bar">
|
||||||
<div class="btn-group pull-left" data-toggle="buttons" id="watch-stats-toggles" style="margin-right: 3px">
|
<div class="btn-group pull-left" data-toggle="buttons" id="watch-stats-toggles" style="margin-right: 3px">
|
||||||
% if config['home_stats_type'] == 0:
|
<label class="btn btn-dark">
|
||||||
<label class="btn btn-dark active">
|
<input type="radio" class="watched-stats-toggle" name="watched-stats-type" id="watched-stats-plays" value="plays" autocomplete="off"> Play Count
|
||||||
<input type="radio" class="watched-stats-toggle" name="watched-stats-type" id="watched-stats-plays" value="0" autocomplete="off" checked> Play Count
|
|
||||||
</label>
|
</label>
|
||||||
<label class="btn btn-dark">
|
<label class="btn btn-dark">
|
||||||
<input type="radio" class="watched-stats-toggle" name="watched-stats-type" id="watched-stats-duration" value="1" autocomplete="off"> Play Duration
|
<input type="radio" class="watched-stats-toggle" name="watched-stats-type" id="watched-stats-duration" value="duration" autocomplete="off"> Play Duration
|
||||||
</label>
|
</label>
|
||||||
% else:
|
|
||||||
<label class="btn btn-dark">
|
|
||||||
<input type="radio" class="watched-stats-toggle" name="watched-stats-type" id="watched-stats-plays" value="0" autocomplete="off"> Play Count
|
|
||||||
</label>
|
|
||||||
<label class="btn btn-dark active">
|
|
||||||
<input type="radio" class="watched-stats-toggle" name="watched-stats-type" id="watched-stats-duration" value="1" autocomplete="off" checked> Play Duration
|
|
||||||
</label>
|
|
||||||
% endif
|
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group pull-left" style="width: 1px; margin-right: 3px" id="watched-stats-days-selection">
|
<div class="input-group pull-left" style="width: 1px; margin-right: 3px" id="watched-stats-days-selection">
|
||||||
<span class="input-group-addon btn-dark inactive">Last</span>
|
<span class="input-group-addon btn-dark inactive">Last</span>
|
||||||
<input type="number" class="form-control number-input" name="watched-stats-days" id="watched-stats-days" value="${config['home_stats_length']}" min="1" data-default="30" data-toggle="tooltip" title="Min: 1 day" />
|
<input type="number" class="form-control number-input" name="watched-stats-days" id="watched-stats-days" value="30" min="1" data-default="30" data-toggle="tooltip" title="Min: 1 day" />
|
||||||
<span class="input-group-addon btn-dark inactive">days</span>
|
<span class="input-group-addon btn-dark inactive">days</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -128,7 +119,7 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group pull-left" style="width: 1px;" id="recently-added-count-selection">
|
<div class="input-group pull-left" style="width: 1px;" id="recently-added-count-selection">
|
||||||
<input type="number" class="form-control number-input" name="recently-added-count" id="recently-added-count" value="${config['home_stats_recently_added_count']}" min="1" max="50" data-default="50" data-toggle="tooltip" title="Min: 1 item<br>Max: 50 items" />
|
<input type="number" class="form-control number-input" name="recently-added-count" id="recently-added-count" value="50" min="1" max="50" data-default="50" data-toggle="tooltip" title="Min: 1 item<br>Max: 50 items" />
|
||||||
<span class="input-group-addon btn-dark inactive">items</span>
|
<span class="input-group-addon btn-dark inactive">items</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -727,20 +718,25 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var time_range = $('#watched-stats-days').val();
|
var stats_type = getLocalStorage('home_stats_type', 'plays');
|
||||||
var stats_type = $('input[name=watched-stats-type]:checked', '#watch-stats-toggles').val();
|
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);
|
getHomeStats(time_range, stats_type);
|
||||||
|
|
||||||
$('input[name=watched-stats-type]').change(function () {
|
$('input[name=watched-stats-type]').change(function () {
|
||||||
stats_type = $(this).filter(':checked').val();
|
stats_type = $(this).filter(':checked').val();
|
||||||
|
setLocalStorage('home_stats_type', stats_type);
|
||||||
getHomeStats(time_range, stats_type);
|
getHomeStats(time_range, stats_type);
|
||||||
$.post('set_home_stats_config', { stats_type: stats_type });
|
|
||||||
});
|
});
|
||||||
$('#watched-stats-days').change(function () {
|
$('#watched-stats-days').change(function () {
|
||||||
forceMinMax($(this));
|
forceMinMax($(this));
|
||||||
time_range = $(this).val();
|
time_range = $(this).val();
|
||||||
|
setLocalStorage('home_stats_days', time_range);
|
||||||
getHomeStats(time_range, stats_type);
|
getHomeStats(time_range, stats_type);
|
||||||
$.post('set_home_stats_config', { time_range: time_range });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#watched-stats-days').tooltip({ container: 'body', placement: 'top', html: true });
|
$('#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 = '';
|
var recently_added_type = '';
|
||||||
|
|
||||||
|
$('#recently-added-count').val(recently_added_count);
|
||||||
|
|
||||||
recentlyAdded(recently_added_count, recently_added_type);
|
recentlyAdded(recently_added_count, recently_added_type);
|
||||||
|
|
||||||
function highlightAddedScrollerButton() {
|
function highlightAddedScrollerButton() {
|
||||||
|
@ -845,8 +845,8 @@
|
||||||
forceMinMax($(this));
|
forceMinMax($(this));
|
||||||
recently_added_count = $(this).val();
|
recently_added_count = $(this).val();
|
||||||
resetScroller();
|
resetScroller();
|
||||||
|
setLocalStorage('home_stats_recently_added_count', recently_added_count);
|
||||||
recentlyAdded(recently_added_count, recently_added_type);
|
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 });
|
$('#recently-added-count').tooltip({ container: 'body', placement: 'top', html: true });
|
||||||
|
|
|
@ -524,7 +524,7 @@ function getLocalStorage(key, default_value) {
|
||||||
var value = localStorage.getItem(key);
|
var value = localStorage.getItem(key);
|
||||||
if (value !== null) {
|
if (value !== null) {
|
||||||
return value
|
return value
|
||||||
} else if (default_value) {
|
} else if (default_value !== undefined) {
|
||||||
setLocalStorage(key, default_value);
|
setLocalStorage(key, default_value);
|
||||||
return default_value
|
return default_value
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,12 +203,8 @@ _CONFIG_DEFINITIONS = {
|
||||||
'HISTORY_TABLE_ACTIVITY': (int, 'General', 1),
|
'HISTORY_TABLE_ACTIVITY': (int, 'General', 1),
|
||||||
'HOME_SECTIONS': (list, 'General', ['current_activity','watch_stats','library_stats','recently_added']),
|
'HOME_SECTIONS': (list, 'General', ['current_activity','watch_stats','library_stats','recently_added']),
|
||||||
'HOME_LIBRARY_CARDS': (list, 'General', ['first_run']),
|
'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', \
|
'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']),
|
'popular_music', 'last_watched', 'top_users', 'top_platforms', 'most_concurrent']),
|
||||||
'HOME_STATS_RECENTLY_ADDED_COUNT': (int, 'General', 50),
|
|
||||||
'HOME_REFRESH_INTERVAL': (int, 'General', 10),
|
'HOME_REFRESH_INTERVAL': (int, 'General', 10),
|
||||||
'HTTPS_CREATE_CERT': (int, 'General', 1),
|
'HTTPS_CREATE_CERT': (int, 'General', 1),
|
||||||
'HTTPS_CERT': (str, 'General', ''),
|
'HTTPS_CERT': (str, 'General', ''),
|
||||||
|
|
|
@ -266,12 +266,6 @@ class DataFactory(object):
|
||||||
|
|
||||||
if grouping is None:
|
if grouping is None:
|
||||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
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:
|
if stats_cards is None:
|
||||||
stats_cards = plexpy.CONFIG.HOME_STATS_CARDS
|
stats_cards = plexpy.CONFIG.HOME_STATS_CARDS
|
||||||
|
|
||||||
|
|
|
@ -173,10 +173,6 @@ class WebInterface(object):
|
||||||
def home(self, **kwargs):
|
def home(self, **kwargs):
|
||||||
config = {
|
config = {
|
||||||
"home_sections": plexpy.CONFIG.HOME_SECTIONS,
|
"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,
|
"home_refresh_interval": plexpy.CONFIG.HOME_REFRESH_INTERVAL,
|
||||||
"pms_name": plexpy.CONFIG.PMS_NAME,
|
"pms_name": plexpy.CONFIG.PMS_NAME,
|
||||||
"pms_is_cloud": plexpy.CONFIG.PMS_IS_CLOUD,
|
"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)
|
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
|
@cherrypy.expose
|
||||||
@requireAuth()
|
@requireAuth()
|
||||||
def library_stats(self, **kwargs):
|
def library_stats(self, **kwargs):
|
||||||
|
@ -1838,16 +1816,7 @@ class WebInterface(object):
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@requireAuth()
|
@requireAuth()
|
||||||
def graphs(self, **kwargs):
|
def graphs(self, **kwargs):
|
||||||
|
return serve_template(templatename="graphs.html", title="Graphs")
|
||||||
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)
|
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue