mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Add homepage stats toggles
This commit is contained in:
parent
25455e8194
commit
1f55b5457e
8 changed files with 235 additions and 111 deletions
|
@ -253,6 +253,12 @@ fieldset[disabled] .btn-dark.active {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
}
|
}
|
||||||
|
.btn-dark.inactive:hover {
|
||||||
|
color: #d7d7d7;
|
||||||
|
background-color: #3B3B3B;
|
||||||
|
border-color: transparent;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
.btn-dark .badge {
|
.btn-dark .badge {
|
||||||
color: #e5e5e5;
|
color: #e5e5e5;
|
||||||
background-color: #3B3B3B;
|
background-color: #3B3B3B;
|
||||||
|
@ -1865,9 +1871,36 @@ a .library-user-instance-box:hover {
|
||||||
-moz-box-shadow: inset 0 0 0 2px #e9a049;
|
-moz-box-shadow: inset 0 0 0 2px #e9a049;
|
||||||
box-shadow: inset 0 0 0 2px #e9a049;
|
box-shadow: inset 0 0 0 2px #e9a049;
|
||||||
}
|
}
|
||||||
|
#watched-stats-days-selection label {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
#watched-stats-days {
|
||||||
|
margin: 0;
|
||||||
|
width: 75px;
|
||||||
|
height: 34px;
|
||||||
|
}
|
||||||
|
#watched-stats-count {
|
||||||
|
margin: 0;
|
||||||
|
width: 75px;
|
||||||
|
height: 34px;
|
||||||
|
}
|
||||||
|
#recently-added-count {
|
||||||
|
margin: 0;
|
||||||
|
width: 75px;
|
||||||
|
height: 34px;
|
||||||
|
}
|
||||||
|
.home-padded-header {
|
||||||
|
margin: 25px 0;
|
||||||
|
height: 34px;
|
||||||
|
}
|
||||||
|
.home-padded-header h3 {
|
||||||
|
margin-top: 9px;
|
||||||
|
width: 175px;
|
||||||
|
}
|
||||||
.home-platforms {
|
.home-platforms {
|
||||||
}
|
}
|
||||||
.home-platforms ul {
|
.home-platforms ul,
|
||||||
|
.library-platforms ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group" data-toggle="buttons" id="yaxis-selection">
|
<div class="btn-group" style="margin-right: 2px;" data-toggle="buttons" id="yaxis-selection">
|
||||||
% if config['graph_type'] == 'duration':
|
% if config['graph_type'] == 'duration':
|
||||||
<label class="btn btn-dark">
|
<label class="btn btn-dark">
|
||||||
<input type="radio" name="yaxis-options" id="yaxis-count" value="plays" autocomplete="off"> Play Count
|
<input type="radio" name="yaxis-options" id="yaxis-count" value="plays" autocomplete="off"> Play Count
|
||||||
|
@ -37,15 +37,15 @@
|
||||||
</label>
|
</label>
|
||||||
% endif
|
% endif
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group" id="days-selection">
|
<div class="input-group pull-right" style="width: 1px;" id="days-selection">
|
||||||
<label>
|
<span class="input-group-addon btn-dark inactive">Last</span>
|
||||||
<input type="number" name="graph-days" id="graph-days" value="${config['graph_days']}" min="1" /> days
|
<input type="number" class="form-control" name="graph-days" id="graph-days" value="${config['graph_days']}" min="1" data-default="7" data-toggle="tooltip" title="Min: 1 day" />
|
||||||
</label>
|
<span class="input-group-addon btn-dark inactive">days</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group" id="months-selection">
|
<div class="input-group pull-right" style="width: 1px;" id="months-selection">
|
||||||
<label>
|
<span class="input-group-addon btn-dark inactive">Last</span>
|
||||||
<input type="number" name="graph-months" id="graph-months" value="${config['graph_months']}" min="1" /> months
|
<input type="number" class="form-control" name="graph-months" id="graph-months" value="${config['graph_months']}" min="1" data-default="12" data-toggle="tooltip" title="Min: 1 month" />
|
||||||
</label>
|
<span class="input-group-addon btn-dark inactive">months</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -572,11 +572,7 @@
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
current_tab = $(this).attr('href');
|
current_tab = $(this).attr('href');
|
||||||
loadGraphsTab1(current_day_range, yaxis);
|
loadGraphsTab1(current_day_range, yaxis);
|
||||||
$.ajax({
|
$.post('set_graph_config', { graph_tab: current_tab.replace('#','') });
|
||||||
url: 'set_graph_config',
|
|
||||||
data: { graph_tab: current_tab.replace('#','') },
|
|
||||||
async: true
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Tab2 opened
|
// Tab2 opened
|
||||||
|
@ -584,11 +580,7 @@
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
current_tab = $(this).attr('href');
|
current_tab = $(this).attr('href');
|
||||||
loadGraphsTab2(current_day_range, yaxis);
|
loadGraphsTab2(current_day_range, yaxis);
|
||||||
$.ajax({
|
$.post('set_graph_config', { graph_tab: current_tab.replace('#','') });
|
||||||
url: 'set_graph_config',
|
|
||||||
data: { graph_tab: current_tab.replace('#','') },
|
|
||||||
async: true
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Tab3 opened
|
// Tab3 opened
|
||||||
|
@ -596,46 +588,28 @@
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
current_tab = $(this).attr('href');
|
current_tab = $(this).attr('href');
|
||||||
loadGraphsTab3(current_month_range, yaxis);
|
loadGraphsTab3(current_month_range, yaxis);
|
||||||
$.ajax({
|
$.post('set_graph_config', { graph_tab: current_tab.replace('#','') });
|
||||||
url: 'set_graph_config',
|
|
||||||
data: { graph_tab: current_tab.replace('#','') },
|
|
||||||
async: true
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Date range changed
|
// Date range changed
|
||||||
|
$('#graph-days').tooltip({ container: 'body', placement: 'top', html: true });
|
||||||
$('#graph-days').on('change', function() {
|
$('#graph-days').on('change', function() {
|
||||||
current_day_range = Math.round($(this).val());
|
forceMinMax($(this));
|
||||||
$(this).val(current_day_range);
|
current_day_range = $(this).val();
|
||||||
if (current_day_range < 1) {
|
|
||||||
$(this).val(7);
|
|
||||||
current_day_range = 7;
|
|
||||||
}
|
|
||||||
if (current_tab == '#tabs-1') { loadGraphsTab1(current_day_range, yaxis); }
|
if (current_tab == '#tabs-1') { loadGraphsTab1(current_day_range, yaxis); }
|
||||||
if (current_tab == '#tabs-2') { loadGraphsTab2(current_day_range, yaxis); }
|
if (current_tab == '#tabs-2') { loadGraphsTab2(current_day_range, yaxis); }
|
||||||
$('.days').html(current_day_range);
|
$('.days').html(current_day_range);
|
||||||
$.ajax({
|
$.post('set_graph_config', { graph_days: current_day_range });
|
||||||
url: 'set_graph_config',
|
|
||||||
data: { graph_days: current_day_range},
|
|
||||||
async: true
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Month range changed
|
// Month range changed
|
||||||
|
$('#graph-months').tooltip({ container: 'body', placement: 'top', html: true });
|
||||||
$('#graph-months').on('change', function() {
|
$('#graph-months').on('change', function() {
|
||||||
current_month_range = Math.round($(this).val());
|
forceMinMax($(this));
|
||||||
$(this).val(current_month_range);
|
current_month_range = $(this).val();
|
||||||
if (current_month_range < 1) {
|
|
||||||
$(this).val(12);
|
|
||||||
current_month_range = 12;
|
|
||||||
}
|
|
||||||
if (current_tab == '#tabs-3') { loadGraphsTab3(current_month_range, yaxis); }
|
if (current_tab == '#tabs-3') { loadGraphsTab3(current_month_range, yaxis); }
|
||||||
$('.months').html(current_month_range);
|
$('.months').html(current_month_range);
|
||||||
$.ajax({
|
$.post('set_graph_config', { graph_months: current_month_range });
|
||||||
url: 'set_graph_config',
|
|
||||||
data: { graph_months: current_month_range},
|
|
||||||
async: true
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// User changed
|
// User changed
|
||||||
|
@ -652,11 +626,7 @@
|
||||||
if (current_tab == '#tabs-1') { loadGraphsTab1(current_day_range, yaxis); }
|
if (current_tab == '#tabs-1') { loadGraphsTab1(current_day_range, yaxis); }
|
||||||
if (current_tab == '#tabs-2') { loadGraphsTab2(current_day_range, yaxis); }
|
if (current_tab == '#tabs-2') { loadGraphsTab2(current_day_range, yaxis); }
|
||||||
if (current_tab == '#tabs-3') { loadGraphsTab3(current_month_range, yaxis); }
|
if (current_tab == '#tabs-3') { loadGraphsTab3(current_month_range, yaxis); }
|
||||||
$.ajax({
|
$.post('set_graph_config', { graph_type: yaxis });
|
||||||
url: 'set_graph_config',
|
|
||||||
data: { graph_type: yaxis},
|
|
||||||
async: true
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function setGraphFormat(type) {
|
function setGraphFormat(type) {
|
||||||
|
|
|
@ -20,9 +20,40 @@
|
||||||
% elif section == 'watch_stats':
|
% elif section == 'watch_stats':
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="padded-header">
|
<div class="home-padded-header padded-header">
|
||||||
<h3>Watch Statistics <small>Last ${config['home_stats_length']} days</small></h3>
|
<h3 class="pull-left">Watch Statistics</h3>
|
||||||
|
<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 active">
|
||||||
|
<input type="radio" class="watched-stats-toggle" name="watched-stats-type" id="watched-stats-plays" value="0" autocomplete="off" checked> Play Count
|
||||||
|
</label>
|
||||||
|
<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
|
||||||
|
</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">
|
||||||
|
<span class="input-group-addon btn-dark inactive">Last</span>
|
||||||
|
<input type="number" class="form-control" 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" />
|
||||||
|
<span class="input-group-addon btn-dark inactive">days</span>
|
||||||
|
</div>
|
||||||
|
<div class="input-group pull-left" style="width: 1px; margin-right: 3px" id="watched-stats-count-selection">
|
||||||
|
<span class="input-group-addon btn-dark inactive">Top</span>
|
||||||
|
<input type="number" class="form-control" name="watched-stats-count" id="watched-stats-count" value="${config['home_stats_count']}" min="1" max="10" data-default="5" data-toggle="tooltip" title="Min: 1 item<br>Max: 10 items" />
|
||||||
|
<span class="input-group-addon btn-dark inactive">items</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
<div id="home-stats" class="home-platforms">
|
<div id="home-stats" class="home-platforms">
|
||||||
<div class="text-muted"><i class="fa fa-refresh fa-spin"></i> Loading stats...</div>
|
<div class="text-muted"><i class="fa fa-refresh fa-spin"></i> Loading stats...</div>
|
||||||
<br>
|
<br>
|
||||||
|
@ -32,9 +63,14 @@
|
||||||
% elif section == 'library_stats':
|
% elif section == 'library_stats':
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="padded-header" id="library-statistics-header">
|
<div class="home-padded-header padded-header" id="library-statistics-header">
|
||||||
<h3>Library Statistics <small>${config['pms_name']}</small></h3>
|
<h3 class="pull-left">Library Statistics</h3>
|
||||||
|
<span class="btn btn-dark active" style="cursor: default">${config['pms_name']}</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
<div id="library-stats" class="library-platforms">
|
<div id="library-stats" class="library-platforms">
|
||||||
<div class="text-muted"><i class="fa fa-refresh fa-spin"></i> Loading stats...</div>
|
<div class="text-muted"><i class="fa fa-refresh fa-spin"></i> Loading stats...</div>
|
||||||
<br>
|
<br>
|
||||||
|
@ -44,8 +80,9 @@
|
||||||
% elif section == 'recently_added':
|
% elif section == 'recently_added':
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="padded-header">
|
<div class="home-padded-header padded-header">
|
||||||
<ul class="nav nav-header nav-dashboard pull-right" style="margin-top: -12px;">
|
<h3 class="pull-left">Recently Added</h3>
|
||||||
|
<ul class="nav nav-header nav-dashboard pull-right" style="margin-top: -3px;">
|
||||||
<li>
|
<li>
|
||||||
<a href="#" id="recently-added-page-left" class="paginate btn-gray disabled" data-id="+1"><i class="fa fa-lg fa-chevron-left"></i></a>
|
<a href="#" id="recently-added-page-left" class="paginate btn-gray disabled" data-id="+1"><i class="fa fa-lg fa-chevron-left"></i></a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -53,11 +90,26 @@
|
||||||
<a href="#" id="recently-added-page-right" class="paginate btn-gray disabled" data-id="-1"><i class="fa fa-lg fa-chevron-right"></i></a>
|
<a href="#" id="recently-added-page-right" class="paginate btn-gray disabled" data-id="-1"><i class="fa fa-lg fa-chevron-right"></i></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h3>Recently Added <small>
|
<div class="btn-group pull-left" data-toggle="buttons" id="recently-added-toggles" style="margin-right: 3px">
|
||||||
<a href="#" class="toggle-recently-added-type btn-gray disabled" id="toggle-recently-added-movie" data-type="movie">Movies</a>
|
<label class="btn btn-dark disabled" id="recently-added-label-movies">
|
||||||
<a href="#" class="toggle-recently-added-type btn-gray disabled" id="toggle-recently-added-season" data-type="season">TV Shows</a>
|
<input type="checkbox" class="recently-added-toggle" name="recently-added-toggle-movies" id="recently-added-toggle-movies" value="movies" data-type="movie" autocomplete="off"> Movies
|
||||||
<a href="#" class="toggle-recently-added-type btn-gray disabled" id="toggle-recently-added-album" data-type="album">Music</a></small></h3>
|
</label>
|
||||||
|
<label class="btn btn-dark disabled" id="recently-added-label-tv">
|
||||||
|
<input type="checkbox" class="recently-added-toggle" name="recently-added-toggle-tv" id="recently-added-toggle-tv" value="tv" data-type="season" autocomplete="off"> TV Shows
|
||||||
|
</label>
|
||||||
|
<label class="btn btn-dark disabled" id="recently-added-label-music">
|
||||||
|
<input type="checkbox" class="recently-added-toggle" name="recently-added-toggle-music" id="recently-added-toggle-music" value="music" data-type="album" autocomplete="off"> Music
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="input-group pull-left" style="width: 1px;" id="recently-added-count-selection">
|
||||||
|
<input type="number" class="form-control" 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" />
|
||||||
|
<span class="input-group-addon btn-dark inactive">items</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
<div id="recentlyAdded" style="margin-right: -15px;">
|
<div id="recentlyAdded" style="margin-right: -15px;">
|
||||||
<div class="text-muted"><i class="fa fa-refresh fa-spin"></i> Looking for new items...</div>
|
<div class="text-muted"><i class="fa fa-refresh fa-spin"></i> Looking for new items...</div>
|
||||||
<br>
|
<br>
|
||||||
|
@ -345,19 +397,48 @@
|
||||||
% endif
|
% endif
|
||||||
% if 'watch_stats' in config['home_sections']:
|
% if 'watch_stats' in config['home_sections']:
|
||||||
<script>
|
<script>
|
||||||
function getHomeStats(days) {
|
function getHomeStats(time_range, stats_type, stats_count) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'home_stats',
|
url: 'home_stats',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
cache: false,
|
cache: false,
|
||||||
async: true,
|
async: true,
|
||||||
data: { },
|
data: {
|
||||||
|
time_range: time_range,
|
||||||
|
stats_type: stats_type,
|
||||||
|
stats_count: stats_count
|
||||||
|
},
|
||||||
complete: function (xhr, status) {
|
complete: function (xhr, status) {
|
||||||
$("#home-stats").html(xhr.responseText);
|
$("#home-stats").html(xhr.responseText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getHomeStats();
|
|
||||||
|
var time_range = $('#watched-stats-days').val();
|
||||||
|
var stats_type = $('input[name=watched-stats-type]:checked', '#watch-stats-toggles').val();
|
||||||
|
var stats_count = $('#watched-stats-count').val();
|
||||||
|
getHomeStats(time_range, stats_type, stats_count);
|
||||||
|
|
||||||
|
$('input[name=watched-stats-type]').change(function () {
|
||||||
|
stats_type = $(this).filter(':checked').val();
|
||||||
|
getHomeStats(time_range, stats_type, stats_count);
|
||||||
|
$.post('set_home_stats_config', { stats_type: stats_type });
|
||||||
|
});
|
||||||
|
$('#watched-stats-days').change(function () {
|
||||||
|
forceMinMax($(this));
|
||||||
|
time_range = $(this).val();
|
||||||
|
getHomeStats(time_range, stats_type, stats_count);
|
||||||
|
$.post('set_home_stats_config', { time_range: time_range });
|
||||||
|
});
|
||||||
|
$('#watched-stats-count').change(function () {
|
||||||
|
forceMinMax($(this));
|
||||||
|
stats_count = $(this).val();
|
||||||
|
getHomeStats(time_range, stats_type, stats_count);
|
||||||
|
$.post('set_home_stats_config', { stats_count: stats_count });
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#watched-stats-days').tooltip({ container: 'body', placement: 'top', html: true });
|
||||||
|
$('#watched-stats-count').tooltip({ container: 'body', placement: 'top', html: true });
|
||||||
</script>
|
</script>
|
||||||
% endif
|
% endif
|
||||||
% if 'library_stats' in config['home_sections']:
|
% if 'library_stats' in config['home_sections']:
|
||||||
|
@ -379,25 +460,35 @@
|
||||||
% endif
|
% endif
|
||||||
% if 'recently_added' in config['home_sections']:
|
% if 'recently_added' in config['home_sections']:
|
||||||
<script>
|
<script>
|
||||||
function recentlyAdded() {
|
function recentlyAdded(recently_added_count) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'get_recently_added',
|
url: 'get_recently_added',
|
||||||
type: "GET",
|
type: "GET",
|
||||||
async: true,
|
async: true,
|
||||||
data: { count : 50 },
|
data: { count : recently_added_count },
|
||||||
complete: function (xhr, status) {
|
complete: function (xhr, status) {
|
||||||
$("#recentlyAdded").html(xhr.responseText);
|
$("#recentlyAdded").html(xhr.responseText);
|
||||||
highlightAddedScrollerButton();
|
highlightAddedScrollerButton();
|
||||||
if ($('.dashboard-recent-media-instance li[data-type=movie]').length) { $('#toggle-recently-added-movie').removeClass('disabled'); }
|
if ($('.dashboard-recent-media-instance li[data-type=movie]').length) {
|
||||||
if ($('.dashboard-recent-media-instance li[data-type=season]').length) { $('#toggle-recently-added-season').removeClass('disabled'); }
|
$('#recently-added-label-movies').removeClass('disabled').addClass('active');
|
||||||
if ($('.dashboard-recent-media-instance li[data-type=album]').length) { $('#toggle-recently-added-album').removeClass('disabled'); }
|
$('#recently-added-toggle-movies').prop('checked', true);
|
||||||
|
}
|
||||||
|
if ($('.dashboard-recent-media-instance li[data-type=season]').length) {
|
||||||
|
$('#recently-added-label-tv').removeClass('disabled').addClass('active');
|
||||||
|
$('#recently-added-toggle-tv').prop('checked', true);
|
||||||
|
}
|
||||||
|
if ($('.dashboard-recent-media-instance li[data-type=album]').length) {
|
||||||
|
$('#recently-added-label-music').removeClass('disabled').addClass('active');
|
||||||
|
$('#recently-added-toggle-music').prop('checked', true);
|
||||||
|
}
|
||||||
|
|
||||||
$('.toggle-recently-added-type').not('.disabled').click(function () {
|
$('#recently-added-toggles').on('change', '.recently-added-toggle', function () {
|
||||||
var scroller = $("#recently-added-row-scroller");
|
var scroller = $("#recently-added-row-scroller");
|
||||||
var media_type = $(this).data('type');
|
var media_type = $(this).data('type');
|
||||||
var margin_right = $(this).hasClass('text-muted') ? '25px' : 0;
|
var margin_right = $(this).prop('checked') ? '25px' : 0;
|
||||||
var toggle_items = $('.dashboard-recent-media-instance li[data-type=' + media_type + ']');
|
var toggle_items = $('.dashboard-recent-media-instance li[data-type=' + media_type + ']');
|
||||||
var containerWidth = $("body").find(".container-fluid").width();
|
var containerWidth = $("body").find(".container-fluid").width();
|
||||||
|
console.log(margin_right)
|
||||||
|
|
||||||
if (margin_right == 0) {
|
if (margin_right == 0) {
|
||||||
toggle_items.stop().animate({ width: 'toggle', marginRight: margin_right }, 1000, function () {
|
toggle_items.stop().animate({ width: 'toggle', marginRight: margin_right }, 1000, function () {
|
||||||
|
@ -436,7 +527,8 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
recentlyAdded();
|
var recently_added_count = $('#recently-added-count').val();
|
||||||
|
recentlyAdded(recently_added_count);
|
||||||
|
|
||||||
function highlightAddedScrollerButton() {
|
function highlightAddedScrollerButton() {
|
||||||
var scroller = $("#recently-added-row-scroller");
|
var scroller = $("#recently-added-row-scroller");
|
||||||
|
@ -476,6 +568,15 @@
|
||||||
$("#recently-added-page-right").removeClass("disabled");
|
$("#recently-added-page-right").removeClass("disabled");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#recently-added-count').change(function () {
|
||||||
|
forceMinMax($(this));
|
||||||
|
recently_added_count = $(this).val();
|
||||||
|
recentlyAdded(recently_added_count);
|
||||||
|
$.post('set_home_stats_config', { recently_added_count: recently_added_count });
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#recently-added-count').tooltip({ container: 'body', placement: 'top', html: true });
|
||||||
</script>
|
</script>
|
||||||
% endif
|
% endif
|
||||||
% if _session['user_group'] == 'admin' and config['update_show_changelog']:
|
% if _session['user_group'] == 'admin' and config['update_show_changelog']:
|
||||||
|
|
|
@ -496,3 +496,23 @@ function humanFileSize(bytes, si) {
|
||||||
} while (Math.abs(bytes) >= thresh && u < units.length - 1);
|
} while (Math.abs(bytes) >= thresh && u < units.length - 1);
|
||||||
return bytes.toFixed(1) + ' ' + units[u];
|
return bytes.toFixed(1) + ' ' + units[u];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force max/min in number inputs
|
||||||
|
function forceMinMax(elem) {
|
||||||
|
var min = parseInt(elem.attr('min'));
|
||||||
|
var max = parseInt(elem.attr('max'));
|
||||||
|
var val = parseInt(elem.val());
|
||||||
|
var default_val = parseInt(elem.data('default'));
|
||||||
|
if (isNaN(val)) {
|
||||||
|
elem.val(default_val);
|
||||||
|
}
|
||||||
|
else if (min != undefined && val < min) {
|
||||||
|
elem.val(min);
|
||||||
|
}
|
||||||
|
else if (max != undefined && val > max) {
|
||||||
|
elem.val(max);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elem.val(val);
|
||||||
|
}
|
||||||
|
}
|
|
@ -300,32 +300,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="home_stats_length">Time Frame</label>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-2">
|
|
||||||
<input type="text" class="form-control" data-parsley-type="integer" id="home_stats_length" name="home_stats_length" value="${config['home_stats_length']}" size="3" data-parsley-min="0" data-parsley-trigger="change" data-parsley-errors-container="#home_stats_length_error" required>
|
|
||||||
</div>
|
|
||||||
<div id="home_stats_length_error" class="alert alert-danger settings-alert" role="alert"></div>
|
|
||||||
</div>
|
|
||||||
<p class="help-block">Specify the number of days for the watch statistics on the home page. Default is 30 days.</p>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="home_stats_count">Top Lists</label>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-2">
|
|
||||||
<input type="text" class="form-control" data-parsley-type="integer" id="home_stats_count" name="home_stats_count" value="${config['home_stats_count']}" size="3" data-parsley-range="[0,10]" data-parsley-trigger="change" data-parsley-errors-container="#home_stats_count_error" required>
|
|
||||||
</div>
|
|
||||||
<div id="home_stats_count_error" class="alert alert-danger settings-alert" role="alert"></div>
|
|
||||||
</div>
|
|
||||||
<p class="help-block">Specify the number of items to show in the top lists for the watch statistics on the home page. Maximum 10 items, default 5 items, 0 to disable.</p>
|
|
||||||
</div>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="home_stats_type" name="home_stats_type" value="1" ${config['home_stats_type']}> Use Play Duration
|
|
||||||
</label>
|
|
||||||
<p class="help-block">Use play duration instead of play count to generate statistics.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="padded-header">
|
<div class="padded-header">
|
||||||
<h3>Library Statistics</h3>
|
<h3>Library Statistics</h3>
|
||||||
|
|
|
@ -203,6 +203,7 @@ _CONFIG_DEFINITIONS = {
|
||||||
'HOME_STATS_COUNT': (int, 'General', 5),
|
'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),
|
||||||
'HTTPS_CREATE_CERT': (int, 'General', 1),
|
'HTTPS_CREATE_CERT': (int, 'General', 1),
|
||||||
'HTTPS_CERT': (str, 'General', ''),
|
'HTTPS_CERT': (str, 'General', ''),
|
||||||
'HTTPS_CERT_CHAIN': (str, 'General', ''),
|
'HTTPS_CERT_CHAIN': (str, 'General', ''),
|
||||||
|
|
|
@ -255,21 +255,26 @@ class DataFactory(object):
|
||||||
|
|
||||||
return dict
|
return dict
|
||||||
|
|
||||||
def get_home_stats(self, grouping=0, time_range=0, stats_type=0, stats_count=0, stats_cards=[]):
|
def get_home_stats(self, grouping=None, time_range=None, stats_type=None, stats_count=None, stats_cards=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
grouping = grouping or plexpy.CONFIG.GROUP_HISTORY_TABLES
|
if grouping is None:
|
||||||
time_range = time_range or plexpy.CONFIG.HOME_STATS_LENGTH
|
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||||
stats_type = stats_type or plexpy.CONFIG.HOME_STATS_TYPE
|
if time_range is None:
|
||||||
stats_count = stats_count or plexpy.CONFIG.HOME_STATS_COUNT
|
time_range = plexpy.CONFIG.HOME_STATS_LENGTH
|
||||||
stats_cards = stats_cards or plexpy.CONFIG.HOME_STATS_CARDS
|
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
|
||||||
|
|
||||||
movie_watched_percent = plexpy.CONFIG.MOVIE_WATCHED_PERCENT
|
movie_watched_percent = plexpy.CONFIG.MOVIE_WATCHED_PERCENT
|
||||||
tv_watched_percent = plexpy.CONFIG.TV_WATCHED_PERCENT
|
tv_watched_percent = plexpy.CONFIG.TV_WATCHED_PERCENT
|
||||||
music_watched_percent = plexpy.CONFIG.MUSIC_WATCHED_PERCENT
|
music_watched_percent = plexpy.CONFIG.MUSIC_WATCHED_PERCENT
|
||||||
|
|
||||||
group_by = 'session_history.reference_id' if grouping else 'session_history.id'
|
group_by = 'session_history.reference_id' if grouping else 'session_history.id'
|
||||||
sort_type = 'total_plays' if stats_type == 0 else 'total_duration'
|
sort_type = 'total_duration' if helpers.cast_to_int(stats_type) == 1 else 'total_plays'
|
||||||
|
|
||||||
home_stats = []
|
home_stats = []
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,9 @@ class WebInterface(object):
|
||||||
config = {
|
config = {
|
||||||
"home_sections": plexpy.CONFIG.HOME_SECTIONS,
|
"home_sections": plexpy.CONFIG.HOME_SECTIONS,
|
||||||
"home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH,
|
"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,
|
||||||
"pms_name": plexpy.CONFIG.PMS_NAME,
|
"pms_name": plexpy.CONFIG.PMS_NAME,
|
||||||
"pms_use_bif": plexpy.CONFIG.PMS_USE_BIF,
|
"pms_use_bif": plexpy.CONFIG.PMS_USE_BIF,
|
||||||
"update_show_changelog": plexpy.CONFIG.UPDATE_SHOW_CHANGELOG
|
"update_show_changelog": plexpy.CONFIG.UPDATE_SHOW_CHANGELOG
|
||||||
|
@ -308,12 +311,32 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@requireAuth()
|
@requireAuth()
|
||||||
def home_stats(self, **kwargs):
|
def home_stats(self, time_range=30, stats_type=0, stats_count=5, **kwargs):
|
||||||
data_factory = datafactory.DataFactory()
|
data_factory = datafactory.DataFactory()
|
||||||
stats_data = data_factory.get_home_stats()
|
stats_data = data_factory.get_home_stats(time_range=time_range,
|
||||||
|
stats_type=stats_type,
|
||||||
|
stats_count=stats_count)
|
||||||
|
|
||||||
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):
|
||||||
|
@ -2589,9 +2612,6 @@ class WebInterface(object):
|
||||||
"notify_concurrent_by_ip": checked(plexpy.CONFIG.NOTIFY_CONCURRENT_BY_IP),
|
"notify_concurrent_by_ip": checked(plexpy.CONFIG.NOTIFY_CONCURRENT_BY_IP),
|
||||||
"notify_concurrent_threshold": plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD,
|
"notify_concurrent_threshold": plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD,
|
||||||
"home_sections": json.dumps(plexpy.CONFIG.HOME_SECTIONS),
|
"home_sections": json.dumps(plexpy.CONFIG.HOME_SECTIONS),
|
||||||
"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": json.dumps(plexpy.CONFIG.HOME_STATS_CARDS),
|
"home_stats_cards": json.dumps(plexpy.CONFIG.HOME_STATS_CARDS),
|
||||||
"home_library_cards": json.dumps(plexpy.CONFIG.HOME_LIBRARY_CARDS),
|
"home_library_cards": json.dumps(plexpy.CONFIG.HOME_LIBRARY_CARDS),
|
||||||
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
|
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue