mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Add filtering of media_type from history table
This commit is contained in:
parent
1ff58a85dc
commit
2243cd1de9
4 changed files with 98 additions and 29 deletions
|
@ -77,11 +77,15 @@
|
|||
<script src="interfaces/default/js/tables/history_table.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
function loadHistoryTable(media_type) {
|
||||
history_table_options.ajax = {
|
||||
"url": "get_history",
|
||||
type: "post",
|
||||
url: 'get_history',
|
||||
type: 'post',
|
||||
data: function (d) {
|
||||
return { 'json_data': JSON.stringify( d ) };
|
||||
return {
|
||||
'json_data': JSON.stringify(d),
|
||||
'media_type': media_type
|
||||
};
|
||||
}
|
||||
}
|
||||
history_table = $('#history_table').DataTable(history_table_options);
|
||||
|
@ -90,6 +94,35 @@
|
|||
|
||||
clearSearchButton('history_table', history_table);
|
||||
|
||||
$('#history_table_filter').prepend('<div class="btn-group" data-toggle="buttons" id="media_type-selection" style="padding-right: 15px;"> \
|
||||
<label class="btn btn-dark"> \
|
||||
<input type="radio" name="media_type-filter" id="history-all" value="all" autocomplete="off"> All \
|
||||
</label> \
|
||||
<label class="btn btn-dark"> \
|
||||
<input type="radio" name="media_type-filter" id="history-movies" value="movie" autocomplete="off"> Movies \
|
||||
</label> \
|
||||
<label class="btn btn-dark"> \
|
||||
<input type="radio" name="media_type-filter" id="history-tv_shows" value="episode" autocomplete="off"> TV Shows \
|
||||
</label> \
|
||||
<label class="btn btn-dark"> \
|
||||
<input type="radio" name="media_type-filter" id="history-music" value="track" autocomplete="off"> Music \
|
||||
</label> \
|
||||
</div>');
|
||||
|
||||
$('#media_type-selection').on('change', function () {
|
||||
media_type = $('input[name=media_type-filter]:checked', '#media_type-selection').val();
|
||||
loadHistoryTable(media_type)
|
||||
});
|
||||
$('#media_type-selection > label').removeClass('active');
|
||||
if (media_type == 'all') { $('#history-all').closest('label').addClass('active'); }
|
||||
if (media_type == 'movie') { $('#history-movies').closest('label').addClass('active'); }
|
||||
if (media_type == 'episode') { $('#history-tv_shows').closest('label').addClass('active'); }
|
||||
if (media_type == 'track') { $('#history-music').closest('label').addClass('active'); }
|
||||
}
|
||||
|
||||
var media_type = 'all';
|
||||
loadHistoryTable(media_type)
|
||||
|
||||
$('#row-edit-mode').on('click', function() {
|
||||
$('#row-edit-mode-alert').fadeIn(200);
|
||||
|
||||
|
|
|
@ -319,15 +319,17 @@ from plexpy import helpers
|
|||
}
|
||||
});
|
||||
|
||||
$( "#history-tab-btn" ).one( "click", function() {
|
||||
function loadHistoryTable(media_type) {
|
||||
// Build watch history table
|
||||
history_table_options.ajax = {
|
||||
"url": "get_history",
|
||||
url: 'get_history',
|
||||
type: 'post',
|
||||
data: function ( d ) {
|
||||
return { 'json_data': JSON.stringify( d ),
|
||||
return {
|
||||
'json_data': JSON.stringify( d ),
|
||||
'user_id': user_id,
|
||||
'user': "${data['username']}"
|
||||
'user': "${data['username']}",
|
||||
'media_type': media_type
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -338,6 +340,36 @@ from plexpy import helpers
|
|||
$(colvis.button()).appendTo('#button-bar-history');
|
||||
|
||||
clearSearchButton('history_table', history_table);
|
||||
|
||||
$('#history_table_filter').prepend('<div class="btn-group" data-toggle="buttons" id="media_type-selection" style="padding-right: 15px;"> \
|
||||
<label class="btn btn-dark"> \
|
||||
<input type="radio" name="media_type-filter" id="history-all" value="all" autocomplete="off"> All \
|
||||
</label> \
|
||||
<label class="btn btn-dark"> \
|
||||
<input type="radio" name="media_type-filter" id="history-movies" value="movie" autocomplete="off"> Movies \
|
||||
</label> \
|
||||
<label class="btn btn-dark"> \
|
||||
<input type="radio" name="media_type-filter" id="history-tv_shows" value="episode" autocomplete="off"> TV Shows \
|
||||
</label> \
|
||||
<label class="btn btn-dark"> \
|
||||
<input type="radio" name="media_type-filter" id="history-music" value="track" autocomplete="off"> Music \
|
||||
</label> \
|
||||
</div>');
|
||||
|
||||
$('#media_type-selection').on('change', function () {
|
||||
media_type = $('input[name=media_type-filter]:checked', '#media_type-selection').val();
|
||||
loadHistoryTable(media_type)
|
||||
});
|
||||
$('#media_type-selection > label').removeClass('active');
|
||||
if (media_type == 'all') { $('#history-all').closest('label').addClass('active'); }
|
||||
if (media_type == 'movie') { $('#history-movies').closest('label').addClass('active'); }
|
||||
if (media_type == 'episode') { $('#history-tv_shows').closest('label').addClass('active'); }
|
||||
if (media_type == 'track') { $('#history-music').closest('label').addClass('active'); }
|
||||
}
|
||||
|
||||
$( "#history-tab-btn" ).one( "click", function() {
|
||||
var media_type = 'all';
|
||||
loadHistoryTable(media_type)
|
||||
});
|
||||
|
||||
$( "#ip-tab-btn" ).one( "click", function() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# This file is part of PlexPy.
|
||||
# This file is part of PlexPy.
|
||||
#
|
||||
# PlexPy is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -141,9 +141,12 @@ class DataTables(object):
|
|||
c_where += w[0] + ' = ? AND '
|
||||
|
||||
# The order of our args changes if we are grouping
|
||||
if grouping:
|
||||
args.insert(0, w[1])
|
||||
else:
|
||||
#if grouping:
|
||||
# args.insert(0, w[1])
|
||||
#else:
|
||||
# args.append(w[1])
|
||||
|
||||
# My testing shows that order of args doesn't change
|
||||
args.append(w[1])
|
||||
|
||||
if c_where:
|
||||
|
|
|
@ -571,27 +571,28 @@ class WebInterface(object):
|
|||
|
||||
custom_where = []
|
||||
if user_id:
|
||||
custom_where = [['session_history.user_id', user_id]]
|
||||
custom_where.append(['session_history.user_id', user_id])
|
||||
elif user:
|
||||
custom_where = [['session_history.user', user]]
|
||||
custom_where.append(['session_history.user', user])
|
||||
if 'rating_key' in kwargs:
|
||||
rating_key = kwargs.get('rating_key', "")
|
||||
custom_where = [['session_history.rating_key', rating_key]]
|
||||
custom_where.append(['session_history.rating_key', rating_key])
|
||||
if 'parent_rating_key' in kwargs:
|
||||
rating_key = kwargs.get('parent_rating_key', "")
|
||||
custom_where = [['session_history.parent_rating_key', rating_key]]
|
||||
custom_where.append(['session_history.parent_rating_key', rating_key])
|
||||
if 'grandparent_rating_key' in kwargs:
|
||||
rating_key = kwargs.get('grandparent_rating_key', "")
|
||||
custom_where = [['session_history.grandparent_rating_key', rating_key]]
|
||||
custom_where.append(['session_history.grandparent_rating_key', rating_key])
|
||||
if 'start_date' in kwargs:
|
||||
start_date = kwargs.get('start_date', "")
|
||||
custom_where = [['strftime("%Y-%m-%d", datetime(date, "unixepoch", "localtime"))', start_date]]
|
||||
custom_where.append(['strftime("%Y-%m-%d", datetime(date, "unixepoch", "localtime"))', start_date])
|
||||
if 'reference_id' in kwargs:
|
||||
reference_id = kwargs.get('reference_id', "")
|
||||
custom_where = [['session_history.reference_id', reference_id]]
|
||||
custom_where.append(['session_history.reference_id', reference_id])
|
||||
if 'media_type' in kwargs:
|
||||
media_type = kwargs.get('media_type', "")
|
||||
custom_where = [['session_history_metadata.media_type', media_type]]
|
||||
if media_type != 'all':
|
||||
custom_where.append(['session_history_metadata.media_type', media_type])
|
||||
|
||||
data_factory = datafactory.DataFactory()
|
||||
history = data_factory.get_history(kwargs=kwargs, custom_where=custom_where, grouping=grouping, watched_percent=watched_percent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue