Save state of history media type toggle

This commit is contained in:
JonnyWong16 2018-10-13 22:12:08 -07:00
parent ec7afcdbc4
commit 6e4fa3ef63
3 changed files with 21 additions and 13 deletions

View file

@ -32,17 +32,17 @@
</div>
% endif
<div class="btn-group" data-toggle="buttons" id="media_type-selection">
<label class="btn btn-dark active">
<input type="radio" name="media_type-filter" id="history-all" value="" autocomplete="off"> All
<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
<input type="radio" name="media_type-filter" id="history-movie" 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
<input type="radio" name="media_type-filter" id="history-episode" 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
<input type="radio" name="media_type-filter" id="history-track" value="track" autocomplete="off"> Music
</label>
</div>
<div class="btn-group">
@ -154,6 +154,7 @@
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();
});
@ -163,8 +164,12 @@
});
}
var media_type = null;
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');
loadHistoryTable(media_type, selected_user_id);
% if _session['user_group'] == 'admin':

View file

@ -156,17 +156,17 @@ DOCUMENTATION :: END
</div>
% endif
<div class="btn-group" data-toggle="buttons" id="media_type-selection">
<label class="btn btn-dark active">
<input type="radio" name="media_type-filter" id="history-all" value="" autocomplete="off"> All
<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
<input type="radio" name="media_type-filter" id="history-movie" 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
<input type="radio" name="media_type-filter" id="history-episode" 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
<input type="radio" name="media_type-filter" id="history-track" value="track" autocomplete="off"> Music
</label>
</div>
<div class="btn-group">
@ -435,6 +435,7 @@ DOCUMENTATION :: END
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();
});
}
@ -494,7 +495,9 @@ DOCUMENTATION :: END
$('a[href="#tabs-history"]').on('shown.bs.tab', function() {
if (typeof(history_table) === 'undefined') {
var media_type = null;
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);
}
});

View file

@ -1696,7 +1696,7 @@ class WebInterface(object):
custom_where.append(['session_history_metadata.section_id', section_id])
if 'media_type' in kwargs:
media_type = kwargs.get('media_type', "")
if media_type:
if media_type != 'all':
custom_where.append(['session_history.media_type', media_type])
if 'transcode_decision' in kwargs:
transcode_decision = kwargs.get('transcode_decision', "")