mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 04:49:36 -07:00
Remember tab when going back on library and user pages
This commit is contained in:
parent
66d45293e6
commit
28e4151157
2 changed files with 495 additions and 462 deletions
|
@ -71,11 +71,11 @@ DOCUMENTATION :: END
|
||||||
% endif
|
% endif
|
||||||
</div>
|
</div>
|
||||||
<div class="user-info-nav">
|
<div class="user-info-nav">
|
||||||
<ul class="user-info-nav">
|
<ul class="user-info-nav" role="tablist">
|
||||||
<li class="active"><a href="#profile" data-toggle="tab">Profile</a></li>
|
<li class="active"><a href="#tabs-profile" role="tab" data-toggle="tab">Profile</a></li>
|
||||||
<li><a id="history-tab-btn" href="#libraryHistory" data-toggle="tab">History</a></li>
|
<li><a id="history-tab-btn" href="#tabs-history" role="tab" data-toggle="tab">History</a></li>
|
||||||
% if _session['user_group'] == 'admin':
|
% if _session['user_group'] == 'admin':
|
||||||
<li><a id="media-info-tab-btn" href="#libraryMediaInfo" data-toggle="tab">Media Info</a></li>
|
<li><a id="media-info-tab-btn" href="#tabs-mediainfo" role="tab" data-toggle="tab">Media Info</a></li>
|
||||||
% endif
|
% endif
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -83,7 +83,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" id="profile">
|
<div role="tabpanel" class="tab-pane active" id="tabs-profile">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -169,7 +169,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="libraryHistory">
|
<div role="tabpanel" class="tab-pane" id="tabs-history">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -221,7 +221,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="libraryMediaInfo">
|
<div role="tabpanel" class="tab-pane" id="tabs-mediainfo">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -366,8 +366,253 @@ DOCUMENTATION :: END
|
||||||
<script src="${http_root}js/tables/history_table.js${cache_param}"></script>
|
<script src="${http_root}js/tables/history_table.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/tables/media_info_table.js${cache_param}"></script>
|
<script src="${http_root}js/tables/media_info_table.js${cache_param}"></script>
|
||||||
<script>
|
<script>
|
||||||
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
|
$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadHistoryTable() {
|
||||||
|
// Build watch history table
|
||||||
|
history_table_options.ajax = {
|
||||||
|
url: 'get_history',
|
||||||
|
type: 'post',
|
||||||
|
data: function ( d ) {
|
||||||
|
return {
|
||||||
|
json_data: JSON.stringify( d ),
|
||||||
|
section_id: section_id,
|
||||||
|
user_id: "${_session['user_id']}" == "None" ? null : "${_session['user_id']}"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
history_table = $('#history_table-SID-${data["section_id"]}').DataTable(history_table_options);
|
||||||
|
|
||||||
|
var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark', exclude: [0, 11] });
|
||||||
|
$(colvis.button()).appendTo('#button-bar-history');
|
||||||
|
|
||||||
|
clearSearchButton('history_table-SID-${data["section_id"]}', history_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('a[href="#tabs-history"]').on('shown.bs.tab', function() {
|
||||||
|
loadHistoryTable();
|
||||||
|
});
|
||||||
|
|
||||||
|
% if _session['user_group'] == 'admin':
|
||||||
|
function loadMediaInfoTable() {
|
||||||
|
// Build media info table
|
||||||
|
media_info_table_options.ajax = {
|
||||||
|
url: 'get_library_media_info',
|
||||||
|
type: 'post',
|
||||||
|
data: function ( d ) {
|
||||||
|
return {
|
||||||
|
json_data: JSON.stringify( d ),
|
||||||
|
section_id: section_id,
|
||||||
|
refresh: refresh_table
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
media_info_table = $('#media_info_table-SID-${data["section_id"]}').DataTable(media_info_table_options);
|
||||||
|
|
||||||
|
var colvis = new $.fn.dataTable.ColVis(media_info_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' });
|
||||||
|
$(colvis.button()).appendTo('#button-bar-media-info');
|
||||||
|
|
||||||
|
clearSearchButton('media_info_table-SID-${data["section_id"]}', media_info_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('a[href="#tabs-mediainfo"]').on('shown.bs.tab', function() {
|
||||||
|
loadMediaInfoTable();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#refresh-media-info-table").click(function () {
|
||||||
|
media_info_child_table = {};
|
||||||
|
refresh_table = true;
|
||||||
|
refresh_child_tables = true;
|
||||||
|
media_info_table.draw();
|
||||||
|
refresh_table = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#edit-library-tooltip").tooltip();
|
||||||
|
|
||||||
|
// Load edit library modal
|
||||||
|
$("#toggle-edit-library-modal").click(function() {
|
||||||
|
$("#edit-library-tooltip").tooltip('hide');
|
||||||
|
$.ajax({
|
||||||
|
url: 'edit_library_dialog',
|
||||||
|
data: { section_id: section_id },
|
||||||
|
cache: false,
|
||||||
|
async: true,
|
||||||
|
complete: function(xhr, status) {
|
||||||
|
$("#edit-library-modal").html(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#row-edit-mode').on('click', function() {
|
||||||
|
$('#row-edit-mode-alert').fadeIn(200);
|
||||||
|
|
||||||
|
if ($(this).hasClass('active')) {
|
||||||
|
if (history_to_delete.length > 0) {
|
||||||
|
$('#deleteCount').text(history_to_delete.length);
|
||||||
|
$('#confirm-modal-delete').modal();
|
||||||
|
$('#confirm-modal-delete').one('click', '#confirm-delete', function () {
|
||||||
|
history_to_delete.forEach(function(row, idx) {
|
||||||
|
$.ajax({
|
||||||
|
url: 'delete_history_rows',
|
||||||
|
type: 'POST',
|
||||||
|
data: { row_id: row },
|
||||||
|
async: true,
|
||||||
|
success: function (data) {
|
||||||
|
var msg = "History deleted";
|
||||||
|
showMsg(msg, false, true, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
history_table.draw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.delete-control').each(function () {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
$('#row-edit-mode-alert').fadeOut(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
history_to_delete = [];
|
||||||
|
$('.delete-control').each(function() {
|
||||||
|
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
$(this).removeClass('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
% endif
|
||||||
|
|
||||||
|
$("#refresh-history-list").click(function () {
|
||||||
|
history_table.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
function recentlyWatched() {
|
||||||
|
// Populate recently watched
|
||||||
|
$.ajax({
|
||||||
|
url: 'library_recently_watched',
|
||||||
|
async: true,
|
||||||
|
data: {
|
||||||
|
section_id: section_id,
|
||||||
|
limit: 50
|
||||||
|
},
|
||||||
|
complete: function(xhr, status) {
|
||||||
|
$("#library-recently-watched").html(xhr.responseText);
|
||||||
|
highlightWatchedScrollerButton();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function recentlyAdded() {
|
||||||
|
// Populate recently added
|
||||||
|
$.ajax({
|
||||||
|
url: 'library_recently_added',
|
||||||
|
async: true,
|
||||||
|
data: {
|
||||||
|
section_id: section_id,
|
||||||
|
limit: 50
|
||||||
|
},
|
||||||
|
complete: function(xhr, status) {
|
||||||
|
$("#library-recently-added").html(xhr.responseText);
|
||||||
|
highlightAddedScrollerButton();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
recentlyWatched();
|
||||||
|
recentlyAdded();
|
||||||
|
|
||||||
|
function highlightWatchedScrollerButton() {
|
||||||
|
var scroller = $("#recently-watched-row-scroller");
|
||||||
|
var numElems = scroller.find("li").length;
|
||||||
|
scroller.width(numElems * 175);
|
||||||
|
if (scroller.width() > $("#library-recently-watched").width()) {
|
||||||
|
$("#recently-watched-page-right").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#recently-watched-page-right").addClass("disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlightAddedScrollerButton() {
|
||||||
|
var scroller = $("#recently-added-row-scroller");
|
||||||
|
var numElems = scroller.find("li").length;
|
||||||
|
scroller.width(numElems * 175);
|
||||||
|
if (scroller.width() > $("#library-recently-added").width()) {
|
||||||
|
$("#recently-added-page-right").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#recently-added-page-right").addClass("disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(window).resize(function() {
|
||||||
|
highlightWatchedScrollerButton();
|
||||||
|
highlightAddedScrollerButton();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('div.art-face').animate({ opacity: 0.2 }, { duration: 1000 });
|
||||||
|
|
||||||
|
var leftTotalWatched = 0;
|
||||||
|
$(".paginate-watched").click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var scroller = $("#recently-watched-row-scroller");
|
||||||
|
var containerWidth = $("#library-recently-watched").width();
|
||||||
|
var scrollAmount = $(this).data("id") * parseInt(containerWidth / 175) * 175;
|
||||||
|
var leftMax = Math.min(-parseInt(scroller.width()) + Math.abs(scrollAmount), 0);
|
||||||
|
|
||||||
|
leftTotalWatched = Math.max(Math.min(leftTotalWatched + scrollAmount, 0), leftMax);
|
||||||
|
scroller.animate({ left: leftTotalWatched }, 250);
|
||||||
|
|
||||||
|
if (leftTotalWatched == 0) {
|
||||||
|
$("#recently-watched-page-left").addClass("disabled").blur();
|
||||||
|
} else {
|
||||||
|
$("#recently-watched-page-left").removeClass("disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftTotalWatched == leftMax) {
|
||||||
|
$("#recently-watched-page-right").addClass("disabled").blur();
|
||||||
|
} else {
|
||||||
|
$("#recently-watched-page-right").removeClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var leftTotalAdded = 0;
|
||||||
|
$(".paginate-added").click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var scroller = $("#recently-added-row-scroller");
|
||||||
|
var containerWidth = $("#library-recently-added").width();
|
||||||
|
var scrollAmount = $(this).data("id") * parseInt(containerWidth / 175) * 175;
|
||||||
|
var leftMax = Math.min(-parseInt(scroller.width()) + Math.abs(scrollAmount), 0);
|
||||||
|
|
||||||
|
leftTotalAdded = Math.max(Math.min(leftTotalAdded + scrollAmount, 0), leftMax);
|
||||||
|
scroller.animate({ left: leftTotalAdded }, 250);
|
||||||
|
|
||||||
|
if (leftTotalAdded == 0) {
|
||||||
|
$("#recently-added-page-left").addClass("disabled").blur();
|
||||||
|
} else {
|
||||||
|
$("#recently-added-page-left").removeClass("disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftTotalAdded == leftMax) {
|
||||||
|
$("#recently-added-page-right").addClass("disabled").blur();
|
||||||
|
} else {
|
||||||
|
$("#recently-added-page-right").removeClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#edit-library-tooltip").tooltip();
|
|
||||||
|
// Javascript to enable link to tab
|
||||||
|
var hash = document.location.hash;
|
||||||
|
var prefix = "tab_";
|
||||||
|
if (hash) {
|
||||||
|
$('.user-info-nav a[href='+hash.replace(prefix,"")+']').tab('show').trigger('show.bs.tab');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Change hash for page-reload
|
||||||
|
$('.user-info-nav a').on('shown.bs.tab', function (e) {
|
||||||
|
window.location.hash = e.target.hash.replace("#", "#" + prefix);
|
||||||
|
});
|
||||||
|
|
||||||
// Populate watch time stats
|
// Populate watch time stats
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -389,237 +634,6 @@ DOCUMENTATION :: END
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadHistoryTable() {
|
|
||||||
// Build watch history table
|
|
||||||
history_table_options.ajax = {
|
|
||||||
url: 'get_history',
|
|
||||||
type: 'post',
|
|
||||||
data: function ( d ) {
|
|
||||||
return {
|
|
||||||
json_data: JSON.stringify( d ),
|
|
||||||
section_id: section_id,
|
|
||||||
user_id: "${_session['user_id']}" == "None" ? null : "${_session['user_id']}"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
history_table = $('#history_table-SID-${data["section_id"]}').DataTable(history_table_options);
|
|
||||||
|
|
||||||
var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark', exclude: [0, 11] });
|
|
||||||
$(colvis.button()).appendTo('#button-bar-history');
|
|
||||||
|
|
||||||
clearSearchButton('history_table-SID-${data["section_id"]}', history_table);
|
|
||||||
}
|
|
||||||
|
|
||||||
$( "#history-tab-btn" ).one( "click", function() {
|
|
||||||
loadHistoryTable();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|
||||||
$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
|
|
||||||
});
|
|
||||||
|
|
||||||
% if _session['user_group'] == 'admin':
|
|
||||||
function loadMediaInfoTable() {
|
|
||||||
// Build media info table
|
|
||||||
media_info_table_options.ajax = {
|
|
||||||
url: 'get_library_media_info',
|
|
||||||
type: 'post',
|
|
||||||
data: function ( d ) {
|
|
||||||
return {
|
|
||||||
json_data: JSON.stringify( d ),
|
|
||||||
section_id: section_id,
|
|
||||||
refresh: refresh_table
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
media_info_table = $('#media_info_table-SID-${data["section_id"]}').DataTable(media_info_table_options);
|
|
||||||
|
|
||||||
var colvis = new $.fn.dataTable.ColVis(media_info_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' });
|
|
||||||
$(colvis.button()).appendTo('#button-bar-media-info');
|
|
||||||
|
|
||||||
clearSearchButton('media_info_table-SID-${data["section_id"]}', media_info_table);
|
|
||||||
}
|
|
||||||
|
|
||||||
$( "#media-info-tab-btn" ).one( "click", function() {
|
|
||||||
loadMediaInfoTable();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#refresh-media-info-table").click(function () {
|
|
||||||
media_info_child_table = {};
|
|
||||||
refresh_table = true;
|
|
||||||
refresh_child_tables = true;
|
|
||||||
media_info_table.draw();
|
|
||||||
refresh_table = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Load edit library modal
|
|
||||||
$("#toggle-edit-library-modal").click(function() {
|
|
||||||
$("#edit-library-tooltip").tooltip('hide');
|
|
||||||
$.ajax({
|
|
||||||
url: 'edit_library_dialog',
|
|
||||||
data: { section_id: section_id },
|
|
||||||
cache: false,
|
|
||||||
async: true,
|
|
||||||
complete: function(xhr, status) {
|
|
||||||
$("#edit-library-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#row-edit-mode').on('click', function() {
|
|
||||||
$('#row-edit-mode-alert').fadeIn(200);
|
|
||||||
|
|
||||||
if ($(this).hasClass('active')) {
|
|
||||||
if (history_to_delete.length > 0) {
|
|
||||||
$('#deleteCount').text(history_to_delete.length);
|
|
||||||
$('#confirm-modal-delete').modal();
|
|
||||||
$('#confirm-modal-delete').one('click', '#confirm-delete', function () {
|
|
||||||
history_to_delete.forEach(function(row, idx) {
|
|
||||||
$.ajax({
|
|
||||||
url: 'delete_history_rows',
|
|
||||||
type: 'POST',
|
|
||||||
data: { row_id: row },
|
|
||||||
async: true,
|
|
||||||
success: function (data) {
|
|
||||||
var msg = "History deleted";
|
|
||||||
showMsg(msg, false, true, 2000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
history_table.draw();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.delete-control').each(function () {
|
|
||||||
$(this).addClass('hidden');
|
|
||||||
$('#row-edit-mode-alert').fadeOut(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
history_to_delete = [];
|
|
||||||
$('.delete-control').each(function() {
|
|
||||||
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
|
|
||||||
$(this).removeClass('hidden');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
% endif
|
|
||||||
|
|
||||||
$("#refresh-history-list").click(function () {
|
|
||||||
history_table.draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
function recentlyWatched() {
|
|
||||||
// Populate recently watched
|
|
||||||
$.ajax({
|
|
||||||
url: 'library_recently_watched',
|
|
||||||
async: true,
|
|
||||||
data: {
|
|
||||||
section_id: section_id,
|
|
||||||
limit: 50
|
|
||||||
},
|
|
||||||
complete: function(xhr, status) {
|
|
||||||
$("#library-recently-watched").html(xhr.responseText);
|
|
||||||
highlightWatchedScrollerButton();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function recentlyAdded() {
|
|
||||||
// Populate recently added
|
|
||||||
$.ajax({
|
|
||||||
url: 'library_recently_added',
|
|
||||||
async: true,
|
|
||||||
data: {
|
|
||||||
section_id: section_id,
|
|
||||||
limit: 50
|
|
||||||
},
|
|
||||||
complete: function(xhr, status) {
|
|
||||||
$("#library-recently-added").html(xhr.responseText);
|
|
||||||
highlightAddedScrollerButton();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
recentlyWatched();
|
|
||||||
recentlyAdded();
|
|
||||||
|
|
||||||
function highlightWatchedScrollerButton() {
|
|
||||||
var scroller = $("#recently-watched-row-scroller");
|
|
||||||
var numElems = scroller.find("li").length;
|
|
||||||
scroller.width(numElems * 175);
|
|
||||||
if (scroller.width() > $("#library-recently-watched").width()) {
|
|
||||||
$("#recently-watched-page-right").removeClass("disabled");
|
|
||||||
} else {
|
|
||||||
$("#recently-watched-page-right").addClass("disabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function highlightAddedScrollerButton() {
|
|
||||||
var scroller = $("#recently-added-row-scroller");
|
|
||||||
var numElems = scroller.find("li").length;
|
|
||||||
scroller.width(numElems * 175);
|
|
||||||
if (scroller.width() > $("#library-recently-added").width()) {
|
|
||||||
$("#recently-added-page-right").removeClass("disabled");
|
|
||||||
} else {
|
|
||||||
$("#recently-added-page-right").addClass("disabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(window).resize(function() {
|
|
||||||
highlightWatchedScrollerButton();
|
|
||||||
highlightAddedScrollerButton();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('div.art-face').animate({ opacity: 0.2 }, { duration: 1000 });
|
|
||||||
|
|
||||||
var leftTotalWatched = 0;
|
|
||||||
$(".paginate-watched").click(function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var scroller = $("#recently-watched-row-scroller");
|
|
||||||
var containerWidth = $("#library-recently-watched").width();
|
|
||||||
var scrollAmount = $(this).data("id") * parseInt(containerWidth / 175) * 175;
|
|
||||||
var leftMax = Math.min(-parseInt(scroller.width()) + Math.abs(scrollAmount), 0);
|
|
||||||
|
|
||||||
leftTotalWatched = Math.max(Math.min(leftTotalWatched + scrollAmount, 0), leftMax);
|
|
||||||
scroller.animate({ left: leftTotalWatched }, 250);
|
|
||||||
|
|
||||||
if (leftTotalWatched == 0) {
|
|
||||||
$("#recently-watched-page-left").addClass("disabled").blur();
|
|
||||||
} else {
|
|
||||||
$("#recently-watched-page-left").removeClass("disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leftTotalWatched == leftMax) {
|
|
||||||
$("#recently-watched-page-right").addClass("disabled").blur();
|
|
||||||
} else {
|
|
||||||
$("#recently-watched-page-right").removeClass("disabled");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var leftTotalAdded = 0;
|
|
||||||
$(".paginate-added").click(function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var scroller = $("#recently-added-row-scroller");
|
|
||||||
var containerWidth = $("#library-recently-added").width();
|
|
||||||
var scrollAmount = $(this).data("id") * parseInt(containerWidth / 175) * 175;
|
|
||||||
var leftMax = Math.min(-parseInt(scroller.width()) + Math.abs(scrollAmount), 0);
|
|
||||||
|
|
||||||
leftTotalAdded = Math.max(Math.min(leftTotalAdded + scrollAmount, 0), leftMax);
|
|
||||||
scroller.animate({ left: leftTotalAdded }, 250);
|
|
||||||
|
|
||||||
if (leftTotalAdded == 0) {
|
|
||||||
$("#recently-added-page-left").addClass("disabled").blur();
|
|
||||||
} else {
|
|
||||||
$("#recently-added-page-left").removeClass("disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leftTotalAdded == leftMax) {
|
|
||||||
$("#recently-added-page-right").addClass("disabled").blur();
|
|
||||||
} else {
|
|
||||||
$("#recently-added-page-right").removeClass("disabled");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -61,19 +61,19 @@ DOCUMENTATION :: END
|
||||||
% endif
|
% endif
|
||||||
</div>
|
</div>
|
||||||
<div class="user-info-nav">
|
<div class="user-info-nav">
|
||||||
<ul class="user-info-nav">
|
<ul class="user-info-nav" role="tablist">
|
||||||
<li class="active"><a href="#profile" data-toggle="tab">Profile</a></li>
|
<li class="active"><a href="#tabs-profile" role="tab" data-toggle="tab">Profile</a></li>
|
||||||
<li><a id="history-tab-btn" href="#userHistory" data-toggle="tab">History</a></li>
|
<li><a id="history-tab-btn" href="#tabs-history" role="tab" data-toggle="tab">History</a></li>
|
||||||
<li><a id="sync-tab-btn" href="#userSyncItems" data-toggle="tab">Synced Items</a></li>
|
<li><a id="sync-tab-btn" href="#tabs-synceditems" role="tab" data-toggle="tab">Synced Items</a></li>
|
||||||
<li><a id="ip-tab-btn" href="#userAddresses" data-toggle="tab">IP Addresses</a></li>
|
<li><a id="ip-tab-btn" href="#tabs-ipaddresses" role="tab" data-toggle="tab">IP Addresses</a></li>
|
||||||
<li><a id="login-tab-btn" href="#userLogins" data-toggle="tab">Tautulli Logins</a></li>
|
<li><a id="login-tab-btn" href="#tabs-tautullilogins" role="tab" data-toggle="tab">Tautulli Logins</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" id="profile">
|
<div role="tabpanel" class="tab-pane active" id="tabs-profile">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -134,7 +134,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="userHistory">
|
<div role="tabpanel" class="tab-pane" id="tabs-history">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -200,7 +200,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="userSyncItems">
|
<div role="tabpanel" class="tab-pane" id="tabs-synceditems">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -240,7 +240,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="userAddresses">
|
<div role="tabpanel" class="tab-pane" id="tabs-ipaddresses">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -271,7 +271,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="userLogins">
|
<div role="tabpanel" class="tab-pane" id="tabs-tautullilogins">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -369,23 +369,246 @@ DOCUMENTATION :: END
|
||||||
<script src="${http_root}js/dataTables.bootstrap.min.js"></script>
|
<script src="${http_root}js/dataTables.bootstrap.min.js"></script>
|
||||||
<script src="${http_root}js/dataTables.bootstrap.pagination.js"></script>
|
<script src="${http_root}js/dataTables.bootstrap.pagination.js"></script>
|
||||||
% if data:
|
% if data:
|
||||||
|
<script>
|
||||||
|
% if str(data['user_id']).isdigit():
|
||||||
|
var user_id = ${data['user_id']};
|
||||||
|
% else:
|
||||||
|
var user_id = null;
|
||||||
|
% endif
|
||||||
|
|
||||||
|
var username = '${data['username'].replace("'", "\\'")}';
|
||||||
|
</script>
|
||||||
<script src="${http_root}js/moment-with-locale.js"></script>
|
<script src="${http_root}js/moment-with-locale.js"></script>
|
||||||
<script src="${http_root}js/tables/history_table.js${cache_param}"></script>
|
<script src="${http_root}js/tables/history_table.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/tables/user_ips.js${cache_param}"></script>
|
<script src="${http_root}js/tables/user_ips.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/tables/sync_table.js${cache_param}"></script>
|
<script src="${http_root}js/tables/sync_table.js${cache_param}"></script>
|
||||||
<script src="${http_root}js/tables/login_logs.js${cache_param}"></script>
|
<script src="${http_root}js/tables/login_logs.js${cache_param}"></script>
|
||||||
<script>
|
<script>
|
||||||
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
|
$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('a[href="#tabs-profile"]').on('shown.bs.tab', function() {
|
||||||
|
var media_type = null;
|
||||||
|
loadHistoryTable(media_type);
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadHistoryTable(media_type) {
|
||||||
|
// Build watch history table
|
||||||
|
history_table_options.ajax = {
|
||||||
|
url: 'get_history',
|
||||||
|
type: 'post',
|
||||||
|
data: function ( d ) {
|
||||||
|
return {
|
||||||
|
json_data: JSON.stringify( d ),
|
||||||
|
user_id: user_id,
|
||||||
|
media_type: media_type
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
history_table = $('#history_table-UID-${data["user_id"]}').DataTable(history_table_options);
|
||||||
|
history_table.column(2).visible(false);
|
||||||
|
|
||||||
|
var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark', exclude: [0, 11] });
|
||||||
|
$(colvis.button()).appendTo('#button-bar-history');
|
||||||
|
|
||||||
|
clearSearchButton('history_table-UID-${data["user_id"]}', history_table);
|
||||||
|
|
||||||
|
$('#media_type-selection').on('change', function () {
|
||||||
|
$('#media_type-selection > label').removeClass('active');
|
||||||
|
selected_filter = $('input[name=media_type-filter]:checked', '#media_type-selection');
|
||||||
|
$(selected_filter).closest('label').addClass('active');
|
||||||
|
media_type = $(selected_filter).val();
|
||||||
|
history_table.draw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('a[href="#tabs-history"]').on('shown.bs.tab', function() {
|
||||||
|
var media_type = null;
|
||||||
|
loadHistoryTable(media_type);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('a[href="#tabs-synceditems"]').on('shown.bs.tab', function() {
|
||||||
|
// Build user sync table
|
||||||
|
sync_table_options.ajax = {
|
||||||
|
url: 'get_sync',
|
||||||
|
data: function(d) {
|
||||||
|
d.user_id = user_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sync_table = $('#sync_table-UID-${data["user_id"]}').DataTable(sync_table_options);
|
||||||
|
sync_table.column(1).visible(false);
|
||||||
|
|
||||||
|
var colvis_sync = new $.fn.dataTable.ColVis( sync_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' } );
|
||||||
|
$( colvis_sync.button() ).appendTo('#button-bar-sync');
|
||||||
|
|
||||||
|
clearSearchButton('sync_table-UID-${data["user_id"]}', sync_table);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('a[href="#tabs-ipaddresses"]').on('shown.bs.tab', function() {
|
||||||
|
// Build user IP table
|
||||||
|
user_ip_table_options.ajax = {
|
||||||
|
url: 'get_user_ips',
|
||||||
|
type: 'post',
|
||||||
|
data: function ( d ) {
|
||||||
|
return {
|
||||||
|
json_data: JSON.stringify( d ),
|
||||||
|
user_id: user_id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user_ip_table = $('#user_ip_table-UID-${data["user_id"]}').DataTable(user_ip_table_options);
|
||||||
|
|
||||||
|
clearSearchButton('user_ip_table-UID-${data["user_id"]}', user_ip_table);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('a[href="#tabs-tautullilogins"]').on('shown.bs.tab', function() {
|
||||||
|
// Build user login table
|
||||||
|
login_log_table_options.ajax = {
|
||||||
|
url: 'get_user_logins',
|
||||||
|
data: function(d) {
|
||||||
|
d.user_id = user_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
login_log_table = $('#login_log_table-UID-${data["user_id"]}').DataTable(login_log_table_options);
|
||||||
|
login_log_table.columns([1, 2]).visible(false);
|
||||||
|
|
||||||
|
var colvis_login = new $.fn.dataTable.ColVis( login_log_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' } );
|
||||||
|
$( colvis_login.button() ).appendTo('#button-bar-login');
|
||||||
|
|
||||||
|
clearSearchButton('login_log_table-UID-${data["user_id"]}', login_log_table);
|
||||||
|
});
|
||||||
|
|
||||||
|
% if _session['user_group'] == 'admin':
|
||||||
|
$("#edit-user-tooltip").tooltip();
|
||||||
|
|
||||||
|
// Load edit user modal
|
||||||
|
$("#toggle-edit-user-modal").click(function() {
|
||||||
|
$("#edit-user-tooltip").tooltip('hide');
|
||||||
|
$.ajax({
|
||||||
|
url: 'edit_user_dialog',
|
||||||
|
data: { user_id: user_id },
|
||||||
|
cache: false,
|
||||||
|
async: true,
|
||||||
|
complete: function(xhr, status) {
|
||||||
|
$("#edit-user-modal").html(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#row-edit-mode').on('click', function() {
|
||||||
|
$('#row-edit-mode-alert').fadeIn(200);
|
||||||
|
|
||||||
|
if ($(this).hasClass('active')) {
|
||||||
|
if (history_to_delete.length > 0) {
|
||||||
|
$('#deleteCount').text(history_to_delete.length);
|
||||||
|
$('#confirm-modal-delete').modal();
|
||||||
|
$('#confirm-modal-delete').one('click', '#confirm-delete', function () {
|
||||||
|
history_to_delete.forEach(function(row, idx) {
|
||||||
|
$.ajax({
|
||||||
|
url: 'delete_history_rows',
|
||||||
|
type: 'POST',
|
||||||
|
data: { row_id: row },
|
||||||
|
async: true,
|
||||||
|
success: function (data) {
|
||||||
|
var msg = "History deleted";
|
||||||
|
showMsg(msg, false, true, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
history_table.draw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.delete-control').each(function () {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
$('#row-edit-mode-alert').fadeOut(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
history_to_delete = [];
|
||||||
|
$('.delete-control').each(function() {
|
||||||
|
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
$(this).removeClass('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
% endif
|
||||||
|
|
||||||
|
$("#refresh-history-list").click(function () {
|
||||||
|
history_table.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
function recentlyWatched() {
|
||||||
|
// Populate recently watched
|
||||||
|
$.ajax({
|
||||||
|
url: 'get_user_recently_watched',
|
||||||
|
async: true,
|
||||||
|
data: {
|
||||||
|
user_id: user_id,
|
||||||
|
limit: 50
|
||||||
|
},
|
||||||
|
complete: function(xhr, status) {
|
||||||
|
$("#user-recently-watched").html(xhr.responseText);
|
||||||
|
highlightWatchedScrollerButton();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
recentlyWatched();
|
||||||
|
|
||||||
|
function highlightWatchedScrollerButton() {
|
||||||
|
var scroller = $("#recently-watched-row-scroller");
|
||||||
|
var numElems = scroller.find("li").length;
|
||||||
|
scroller.width(numElems * 175);
|
||||||
|
if (scroller.width() > $("#user-recently-watched").width()) {
|
||||||
|
$("#recently-watched-page-right").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#recently-watched-page-right").addClass("disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(window).resize(function() {
|
||||||
|
highlightWatchedScrollerButton();
|
||||||
|
});
|
||||||
|
|
||||||
|
var leftTotal = 0;
|
||||||
|
$(".paginate").click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var scroller = $("#recently-watched-row-scroller");
|
||||||
|
var containerWidth = $("#user-recently-watched").width();
|
||||||
|
var scrollAmount = $(this).data("id") * parseInt(containerWidth / 175) * 175;
|
||||||
|
var leftMax = Math.min(-parseInt(scroller.width()) + Math.abs(scrollAmount), 0);
|
||||||
|
|
||||||
|
leftTotal = Math.max(Math.min(leftTotal + scrollAmount, 0), leftMax);
|
||||||
|
scroller.animate({ left: leftTotal }, 250);
|
||||||
|
|
||||||
|
if (leftTotal == 0) {
|
||||||
|
$("#recently-watched-page-left").addClass("disabled").blur();
|
||||||
|
} else {
|
||||||
|
$("#recently-watched-page-left").removeClass("disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftTotal == leftMax) {
|
||||||
|
$("#recently-watched-page-right").addClass("disabled").blur();
|
||||||
|
} else {
|
||||||
|
$("#recently-watched-page-right").removeClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
% if str(data['user_id']).isdigit():
|
// Javascript to enable link to tab
|
||||||
var user_id = ${data['user_id']};
|
var hash = document.location.hash;
|
||||||
% else:
|
var prefix = "tab_";
|
||||||
var user_id = null;
|
if (hash) {
|
||||||
% endif
|
$('.user-info-nav a[href='+hash.replace(prefix,"")+']').tab('show').trigger('show.bs.tab');
|
||||||
|
}
|
||||||
|
|
||||||
var username = '${data['username'].replace("'", "\\'")}';
|
// Change hash for page-reload
|
||||||
|
$('.user-info-nav a').on('shown.bs.tab', function (e) {
|
||||||
$("#edit-user-tooltip").tooltip();
|
window.location.hash = e.target.hash.replace("#", "#" + prefix);
|
||||||
|
});
|
||||||
|
|
||||||
// Populate watch time stats
|
// Populate watch time stats
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -407,210 +630,6 @@ DOCUMENTATION :: END
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadHistoryTable(media_type) {
|
|
||||||
// Build watch history table
|
|
||||||
history_table_options.ajax = {
|
|
||||||
url: 'get_history',
|
|
||||||
type: 'post',
|
|
||||||
data: function ( d ) {
|
|
||||||
return {
|
|
||||||
json_data: JSON.stringify( d ),
|
|
||||||
user_id: user_id,
|
|
||||||
media_type: media_type
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
history_table = $('#history_table-UID-${data["user_id"]}').DataTable(history_table_options);
|
|
||||||
history_table.column(2).visible(false);
|
|
||||||
|
|
||||||
var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark', exclude: [0, 11] });
|
|
||||||
$(colvis.button()).appendTo('#button-bar-history');
|
|
||||||
|
|
||||||
clearSearchButton('history_table-UID-${data["user_id"]}', history_table);
|
|
||||||
|
|
||||||
$('#media_type-selection').on('change', function () {
|
|
||||||
$('#media_type-selection > label').removeClass('active');
|
|
||||||
selected_filter = $('input[name=media_type-filter]:checked', '#media_type-selection');
|
|
||||||
$(selected_filter).closest('label').addClass('active');
|
|
||||||
media_type = $(selected_filter).val();
|
|
||||||
history_table.draw();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$( "#history-tab-btn" ).one( "click", function() {
|
|
||||||
var media_type = null;
|
|
||||||
loadHistoryTable(media_type);
|
|
||||||
});
|
|
||||||
|
|
||||||
$( "#ip-tab-btn" ).one( "click", function() {
|
|
||||||
// Build user IP table
|
|
||||||
user_ip_table_options.ajax = {
|
|
||||||
url: 'get_user_ips',
|
|
||||||
type: 'post',
|
|
||||||
data: function ( d ) {
|
|
||||||
return {
|
|
||||||
json_data: JSON.stringify( d ),
|
|
||||||
user_id: user_id
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
user_ip_table = $('#user_ip_table-UID-${data["user_id"]}').DataTable(user_ip_table_options);
|
|
||||||
|
|
||||||
clearSearchButton('user_ip_table-UID-${data["user_id"]}', user_ip_table);
|
|
||||||
});
|
|
||||||
|
|
||||||
$( "#sync-tab-btn" ).one( "click", function() {
|
|
||||||
// Build user sync table
|
|
||||||
sync_table_options.ajax = {
|
|
||||||
url: 'get_sync',
|
|
||||||
data: function(d) {
|
|
||||||
d.user_id = user_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sync_table = $('#sync_table-UID-${data["user_id"]}').DataTable(sync_table_options);
|
|
||||||
sync_table.column(1).visible(false);
|
|
||||||
|
|
||||||
var colvis_sync = new $.fn.dataTable.ColVis( sync_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' } );
|
|
||||||
$( colvis_sync.button() ).appendTo('#button-bar-sync');
|
|
||||||
|
|
||||||
clearSearchButton('sync_table-UID-${data["user_id"]}', sync_table);
|
|
||||||
});
|
|
||||||
|
|
||||||
$( "#login-tab-btn" ).one( "click", function() {
|
|
||||||
// Build user login table
|
|
||||||
login_log_table_options.ajax = {
|
|
||||||
url: 'get_user_logins',
|
|
||||||
data: function(d) {
|
|
||||||
d.user_id = user_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
login_log_table = $('#login_log_table-UID-${data["user_id"]}').DataTable(login_log_table_options);
|
|
||||||
login_log_table.columns([1, 2]).visible(false);
|
|
||||||
|
|
||||||
var colvis_login = new $.fn.dataTable.ColVis( login_log_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' } );
|
|
||||||
$( colvis_login.button() ).appendTo('#button-bar-login');
|
|
||||||
|
|
||||||
clearSearchButton('login_log_table-UID-${data["user_id"]}', login_log_table);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|
||||||
$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
|
|
||||||
});
|
|
||||||
|
|
||||||
% if _session['user_group'] == 'admin':
|
|
||||||
// Load edit user modal
|
|
||||||
$("#toggle-edit-user-modal").click(function() {
|
|
||||||
$("#edit-user-tooltip").tooltip('hide');
|
|
||||||
$.ajax({
|
|
||||||
url: 'edit_user_dialog',
|
|
||||||
data: { user_id: user_id },
|
|
||||||
cache: false,
|
|
||||||
async: true,
|
|
||||||
complete: function(xhr, status) {
|
|
||||||
$("#edit-user-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#row-edit-mode').on('click', function() {
|
|
||||||
$('#row-edit-mode-alert').fadeIn(200);
|
|
||||||
|
|
||||||
if ($(this).hasClass('active')) {
|
|
||||||
if (history_to_delete.length > 0) {
|
|
||||||
$('#deleteCount').text(history_to_delete.length);
|
|
||||||
$('#confirm-modal-delete').modal();
|
|
||||||
$('#confirm-modal-delete').one('click', '#confirm-delete', function () {
|
|
||||||
history_to_delete.forEach(function(row, idx) {
|
|
||||||
$.ajax({
|
|
||||||
url: 'delete_history_rows',
|
|
||||||
type: 'POST',
|
|
||||||
data: { row_id: row },
|
|
||||||
async: true,
|
|
||||||
success: function (data) {
|
|
||||||
var msg = "History deleted";
|
|
||||||
showMsg(msg, false, true, 2000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
history_table.draw();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.delete-control').each(function () {
|
|
||||||
$(this).addClass('hidden');
|
|
||||||
$('#row-edit-mode-alert').fadeOut(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
history_to_delete = [];
|
|
||||||
$('.delete-control').each(function() {
|
|
||||||
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
|
|
||||||
$(this).removeClass('hidden');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
% endif
|
|
||||||
|
|
||||||
$("#refresh-history-list").click(function () {
|
|
||||||
history_table.draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
function recentlyWatched() {
|
|
||||||
// Populate recently watched
|
|
||||||
$.ajax({
|
|
||||||
url: 'get_user_recently_watched',
|
|
||||||
async: true,
|
|
||||||
data: {
|
|
||||||
user_id: user_id,
|
|
||||||
limit: 50
|
|
||||||
},
|
|
||||||
complete: function(xhr, status) {
|
|
||||||
$("#user-recently-watched").html(xhr.responseText);
|
|
||||||
highlightWatchedScrollerButton();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
recentlyWatched();
|
|
||||||
|
|
||||||
function highlightWatchedScrollerButton() {
|
|
||||||
var scroller = $("#recently-watched-row-scroller");
|
|
||||||
var numElems = scroller.find("li").length;
|
|
||||||
scroller.width(numElems * 175);
|
|
||||||
if (scroller.width() > $("#user-recently-watched").width()) {
|
|
||||||
$("#recently-watched-page-right").removeClass("disabled");
|
|
||||||
} else {
|
|
||||||
$("#recently-watched-page-right").addClass("disabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(window).resize(function() {
|
|
||||||
highlightWatchedScrollerButton();
|
|
||||||
});
|
|
||||||
|
|
||||||
var leftTotal = 0;
|
|
||||||
$(".paginate").click(function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var scroller = $("#recently-watched-row-scroller");
|
|
||||||
var containerWidth = $("#user-recently-watched").width();
|
|
||||||
var scrollAmount = $(this).data("id") * parseInt(containerWidth / 175) * 175;
|
|
||||||
var leftMax = Math.min(-parseInt(scroller.width()) + Math.abs(scrollAmount), 0);
|
|
||||||
|
|
||||||
leftTotal = Math.max(Math.min(leftTotal + scrollAmount, 0), leftMax);
|
|
||||||
scroller.animate({ left: leftTotal }, 250);
|
|
||||||
|
|
||||||
if (leftTotal == 0) {
|
|
||||||
$("#recently-watched-page-left").addClass("disabled").blur();
|
|
||||||
} else {
|
|
||||||
$("#recently-watched-page-left").removeClass("disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leftTotal == leftMax) {
|
|
||||||
$("#recently-watched-page-right").addClass("disabled").blur();
|
|
||||||
} else {
|
|
||||||
$("#recently-watched-page-right").removeClass("disabled");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
% endif
|
% endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue