Add transcode decision selection to history tables

This commit is contained in:
JonnyWong16 2021-03-29 13:22:43 -07:00
parent 0b1c4691dc
commit c74b380f99
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
5 changed files with 167 additions and 94 deletions

View file

@ -40,19 +40,33 @@
% endif
<div class="btn-group" data-toggle="buttons" id="media_type-selection">
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-all" value="all" autocomplete="off"> All
<input type="radio" name="media_type-filter" id="history-media_type-all" value="all" autocomplete="off"> All
</label>
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-movie" value="movie" autocomplete="off"> Movies
<input type="radio" name="media_type-filter" id="history-media_type-movie" value="movie" autocomplete="off"> Movies
</label>
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-episode" value="episode" autocomplete="off"> TV Shows
<input type="radio" name="media_type-filter" id="history-media_type-episode" value="episode" autocomplete="off"> TV Shows
</label>
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-track" value="track" autocomplete="off"> Music
<input type="radio" name="media_type-filter" id="history-media_type-track" value="track" autocomplete="off"> Music
</label>
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-live" value="live" autocomplete="off"> Live TV
<input type="radio" name="media_type-filter" id="history-media_type-live" value="live" autocomplete="off"> Live TV
</label>
</div>
<div class="btn-group" data-toggle="buttons" id="transcode_decision-selection">
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-all" value="all" autocomplete="off"> All
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-direct_play" value="direct play" autocomplete="off"> Direct Play
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-direct_stream" value="direct stream" autocomplete="off"> Direct Stream
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-transcode" value="transcode" autocomplete="off"> Transcode
</label>
</div>
<div class="btn-group">
@ -137,7 +151,7 @@
}
});
function loadHistoryTable(media_type, selected_user_id) {
function loadHistoryTable(media_type, transcode_decision, selected_user_id) {
history_table_options.ajax = {
url: 'get_history',
type: 'POST',
@ -145,6 +159,7 @@
return {
json_data: JSON.stringify(d),
media_type: media_type,
transcode_decision: transcode_decision,
user_id: selected_user_id
};
}
@ -161,26 +176,41 @@
$('#media_type-selection').on('change', function () {
$('#media_type-selection > label').removeClass('active');
selected_filter = $('input[name=media_type-filter]:checked', '#media_type-selection');
var selected_filter = $('input[name=media_type-filter]:checked', '#media_type-selection');
$(selected_filter).closest('label').addClass('active');
media_type = $(selected_filter).val();
setLocalStorage('history_media_type', media_type);
history_table.draw();
});
$('#transcode_decision-selection').on('change', function () {
$('#transcode_decision-selection > label').removeClass('active');
var selected_filter = $('input[name=transcode_decision-filter]:checked', '#transcode_decision-selection');
$(selected_filter).closest('label').addClass('active');
transcode_decision = $(selected_filter).val();
setLocalStorage('history_transcode_decision', transcode_decision);
history_table.draw();
});
$('#history-user').on('change', function () {
selected_user_id = $(this).val() || null;
history_table.draw();
});
}
var media_type = getLocalStorage('history_media_type', 'all');
var selected_user_id = "${_session['user_group']}" == "admin" ? null : "${_session['user_id']}";
$('#history-' + media_type).prop('checked', true);
$('#history-' + media_type).closest('label').addClass('active');
var media_type = getLocalStorage('history_media_type', 'all');
var history_media_type = $('#history-media_type-' + media_type);
history_media_type.prop('checked', true);
history_media_type.closest('label').addClass('active');
loadHistoryTable(media_type, selected_user_id);
var transcode_decision = getLocalStorage('history_transcode_decision', 'all');
var history_transcode_decision = $('#history-transcode_decision-' + transcode_decision.replace(' ', '_'));
history_transcode_decision.prop('checked', true);
history_transcode_decision.closest('label').addClass('active');
loadHistoryTable(media_type, transcode_decision, selected_user_id);
% if _session['user_group'] == 'admin':
$('#row-edit-mode').on('click', function() {

View file

@ -615,6 +615,20 @@ DOCUMENTATION :: END
</button>&nbsp;
</div>
% endif
<div class="btn-group" data-toggle="buttons" id="transcode_decision-selection">
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-all" value="all" autocomplete="off"> All
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-direct_play" value="direct play" autocomplete="off"> Direct Play
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-direct_stream" value="direct stream" autocomplete="off"> Direct Stream
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-transcode" value="transcode" autocomplete="off"> Transcode
</label>
</div>
<div class="btn-group">
<button class="btn btn-dark refresh-history-button" id="refresh-history-list"><i class="fa fa-refresh"></i> Refresh history</button>
</div>
@ -809,84 +823,53 @@ DOCUMENTATION :: END
%>
<script src="${http_root}js/tables/history_table.js${cache_param}"></script>
<script src="${http_root}js/tables/export_table.js${cache_param}"></script>
% if data['live']:
<script>
function get_history() {
history_table_options.ajax = {
url: 'get_history',
type: 'POST',
data: function ( d ) {
return {
json_data: JSON.stringify( d ),
guid: "${data['guid']}",
user_id: "${history_user_id}"
};
}
}
}
</script>
% elif data['media_type'] in ('show', 'artist'):
<script>
function get_history() {
history_table_options.ajax = {
url: 'get_history',
type: 'POST',
data: function ( d ) {
return {
json_data: JSON.stringify( d ),
grandparent_rating_key: "${data['rating_key']}",
user_id: "${history_user_id}"
};
}
}
}
</script>
% elif data['media_type'] in ('season', 'album'):
<script>
function get_history() {
history_table_options.ajax = {
url: 'get_history',
type: 'POST',
data: function ( d ) {
return {
json_data: JSON.stringify( d ),
parent_rating_key: "${data['rating_key']}",
user_id: "${history_user_id}"
};
}
}
}
</script>
% elif data['media_type'] in ('movie', 'episode', 'track'):
<script>
function get_history() {
history_table_options.ajax = {
url: 'get_history',
type: 'POST',
data: function ( d ) {
return {
json_data: JSON.stringify( d ),
rating_key: "${data['rating_key']}",
user_id: "${history_user_id}"
};
}
}
}
</script>
% endif
% if data['media_type'] in ('movie', 'show', 'season', 'episode', 'artist', 'album', 'track'):
<script>
function loadHistoryTable() {
get_history();
function loadHistoryTable(transcode_decision) {
// Build watch history table
history_table_options.ajax = {
url: 'get_history',
type: 'POST',
data: function (d) {
return {
json_data: JSON.stringify(d),
transcode_decision: transcode_decision,
user_id: "${history_user_id}",
% if data['live']:
guid: "${data['guid']}
% elif data['media_type'] in ('show', 'artist'):
grandparent_rating_key: "${data['rating_key']}"
% elif data['media_type'] in ('season', 'album'):
parent_rating_key: "${data['rating_key']}"
% elif data['media_type'] in ('movie', 'episode', 'track'):
rating_key: "${data['rating_key']}"
% endif
};
}
}
history_table = $('#history_table-RK-${data["rating_key"]}').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, 12] });
$(colvis.button()).appendTo('#button-bar-history');
clearSearchButton('history_table-RK-${data["rating_key"]}', history_table);
$('#transcode_decision-selection').on('change', function () {
$('#transcode_decision-selection > label').removeClass('active');
var selected_filter = $('input[name=transcode_decision-filter]:checked', '#transcode_decision-selection');
$(selected_filter).closest('label').addClass('active');
transcode_decision = $(selected_filter).val();
setLocalStorage('info_${data["rating_key"]}_history_transcode_decision', transcode_decision);
history_table.draw();
});
}
var transcode_decision = getLocalStorage('info_${data["rating_key"]}_history_transcode_decision', 'all');
var history_transcode_decision = $('#history-transcode_decision-' + transcode_decision.replace(' ', '_'));
history_transcode_decision.prop('checked', true);
history_transcode_decision.closest('label').addClass('active');
$(document).ready(function () {
loadHistoryTable();
loadHistoryTable(transcode_decision);
});
$("#refresh-history-list").click(function () {

View file

@ -217,6 +217,20 @@ DOCUMENTATION :: END
</button>&nbsp;
</div>
% endif
<div class="btn-group" data-toggle="buttons" id="transcode_decision-selection">
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-all" value="all" autocomplete="off"> All
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-direct_play" value="direct play" autocomplete="off"> Direct Play
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-direct_stream" value="direct stream" autocomplete="off"> Direct Stream
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-transcode" value="transcode" autocomplete="off"> Transcode
</label>
</div>
<div class="btn-group">
<button class="btn btn-dark refresh-history-button" id="refresh-history-list"><i class="fa fa-refresh"></i> Refresh history</button>
</div>
@ -557,7 +571,7 @@ DOCUMENTATION :: END
$(".inactive-library-tooltip").tooltip();
function loadHistoryTable() {
function loadHistoryTable(transcode_decision) {
// Build watch history table
history_table_options.ajax = {
url: 'get_history',
@ -566,7 +580,8 @@ DOCUMENTATION :: END
return {
json_data: JSON.stringify( d ),
section_id: section_id,
user_id: "${history_user_id}"
user_id: "${history_user_id}",
transcode_decision: transcode_decision
};
}
};
@ -576,11 +591,25 @@ DOCUMENTATION :: END
$(colvis.button()).appendTo('#button-bar-history');
clearSearchButton('history_table-SID-${data["section_id"]}', history_table);
$('#transcode_decision-selection').on('change', function () {
$('#transcode_decision-selection > label').removeClass('active');
var selected_filter = $('input[name=transcode_decision-filter]:checked', '#transcode_decision-selection');
$(selected_filter).closest('label').addClass('active');
transcode_decision = $(selected_filter).val();
setLocalStorage('library_' + section_id + 'history_transcode_decision', transcode_decision);
history_table.draw();
});
}
$('#nav-tabs-history').on('shown.bs.tab', function() {
if (typeof(history_table) === 'undefined') {
loadHistoryTable();
var transcode_decision = getLocalStorage('library_' + section_id + 'history_transcode_decision', 'all');
var history_transcode_decision = $('#history-transcode_decision-' + transcode_decision.replace(' ', '_'));
history_transcode_decision.prop('checked', true);
history_transcode_decision.closest('label').addClass('active');
loadHistoryTable(transcode_decision);
}
});

View file

@ -169,19 +169,33 @@ DOCUMENTATION :: END
% endif
<div class="btn-group" data-toggle="buttons" id="media_type-selection">
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-all" value="all" autocomplete="off"> All
<input type="radio" name="media_type-filter" id="history-media_type-all" value="all" autocomplete="off"> All
</label>
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-movie" value="movie" autocomplete="off"> Movies
<input type="radio" name="media_type-filter" id="history-media_type-movie" value="movie" autocomplete="off"> Movies
</label>
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-episode" value="episode" autocomplete="off"> TV Shows
<input type="radio" name="media_type-filter" id="history-media_type-episode" value="episode" autocomplete="off"> TV Shows
</label>
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-track" value="track" autocomplete="off"> Music
<input type="radio" name="media_type-filter" id="history-media_type-track" value="track" autocomplete="off"> Music
</label>
<label class="btn btn-dark">
<input type="radio" name="media_type-filter" id="history-live" value="live" autocomplete="off"> Live TV
<input type="radio" name="media_type-filter" id="history-media_type-live" value="live" autocomplete="off"> Live TV
</label>
</div>
<div class="btn-group" data-toggle="buttons" id="transcode_decision-selection">
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-all" value="all" autocomplete="off"> All
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-direct_play" value="direct play" autocomplete="off"> Direct Play
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-direct_stream" value="direct stream" autocomplete="off"> Direct Stream
</label>
<label class="btn btn-dark">
<input type="radio" name="transcode_decision-filter" id="history-transcode_decision-transcode" value="transcode" autocomplete="off"> Transcode
</label>
</div>
<div class="btn-group">
@ -525,7 +539,7 @@ DOCUMENTATION :: END
$(".inactive-user-tooltip").tooltip();
function loadHistoryTable(media_type) {
function loadHistoryTable(media_type, transcode_decision) {
// Build watch history table
history_table_options.ajax = {
url: 'get_history',
@ -534,7 +548,8 @@ DOCUMENTATION :: END
return {
json_data: JSON.stringify( d ),
user_id: user_id,
media_type: media_type
media_type: media_type,
transcode_decision: transcode_decision
};
}
};
@ -548,20 +563,36 @@ DOCUMENTATION :: END
$('#media_type-selection').on('change', function () {
$('#media_type-selection > label').removeClass('active');
selected_filter = $('input[name=media_type-filter]:checked', '#media_type-selection');
var selected_filter = $('input[name=media_type-filter]:checked', '#media_type-selection');
$(selected_filter).closest('label').addClass('active');
media_type = $(selected_filter).val();
setLocalStorage('user_' + user_id + '-history_media_type', media_type);
history_table.draw();
});
$('#transcode_decision-selection').on('change', function () {
$('#transcode_decision-selection > label').removeClass('active');
var selected_filter = $('input[name=transcode_decision-filter]:checked', '#transcode_decision-selection');
$(selected_filter).closest('label').addClass('active');
transcode_decision = $(selected_filter).val();
setLocalStorage('user_' + user_id + 'history_transcode_decision', transcode_decision);
history_table.draw();
});
}
$('#nav-tabs-history').on('shown.bs.tab', function() {
if (typeof(history_table) === 'undefined') {
var media_type = getLocalStorage('user_' + user_id + '-history_media_type', 'all');
$('#history-' + media_type).prop('checked', true);
$('#history-' + media_type).closest('label').addClass('active');
loadHistoryTable(media_type);
var history_media_type = $('#history-media_type-' + media_type);
history_media_type.prop('checked', true);
history_media_type.closest('label').addClass('active');
var transcode_decision = getLocalStorage('user_' + user_id + 'history_transcode_decision', 'all');
var history_transcode_decision = $('#history-transcode_decision-' + transcode_decision.replace(' ', '_'));
history_transcode_decision.prop('checked', true);
history_transcode_decision.closest('label').addClass('active');
loadHistoryTable(media_type, transcode_decision);
}
});

View file

@ -1963,7 +1963,7 @@ class WebInterface(object):
custom_where.append(['session_history_metadata.live', '1'])
if 'transcode_decision' in kwargs:
transcode_decision = kwargs.get('transcode_decision', '')
if transcode_decision:
if transcode_decision != 'all':
custom_where.append(['session_history_media_info.transcode_decision', transcode_decision])
if 'guid' in kwargs:
guid = kwargs.get('guid', '').split('?')[0]