Add filtering of media_type from history table

This commit is contained in:
Jonathan Wong 2015-10-18 11:50:01 -07:00
parent 1ff58a85dc
commit 2243cd1de9
4 changed files with 98 additions and 29 deletions

View file

@ -76,19 +76,52 @@
<script src="interfaces/default/js/moment-with-locale.js"></script>
<script src="interfaces/default/js/tables/history_table.js"></script>
<script>
$(document).ready(function() {
history_table_options.ajax = {
"url": "get_history",
type: "post",
data: function ( d ) {
return { 'json_data': JSON.stringify( d ) };
$(document).ready(function () {
function loadHistoryTable(media_type) {
history_table_options.ajax = {
url: 'get_history',
type: 'post',
data: function (d) {
return {
'json_data': JSON.stringify(d),
'media_type': media_type
};
}
}
}
history_table = $('#history_table').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('div.colvis-button-bar');
history_table = $('#history_table').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('div.colvis-button-bar');
clearSearchButton('history_table', history_table);
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);

View file

@ -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 ),
'user_id': user_id,
'user': "${data['username']}"
return {
'json_data': JSON.stringify( d ),
'user_id': user_id,
'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() {