mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-24 06:55:26 -07:00
Add new user picker to history page
This commit is contained in:
parent
7a9dc6d43b
commit
157dba3006
1 changed files with 36 additions and 5 deletions
|
@ -31,9 +31,7 @@
|
||||||
% if _session['user_group'] == 'admin':
|
% if _session['user_group'] == 'admin':
|
||||||
<div class="btn-group" id="user-selection">
|
<div class="btn-group" id="user-selection">
|
||||||
<label>
|
<label>
|
||||||
<select name="history-user" id="history-user" class="btn" style="color: inherit;">
|
<select name="history-user" id="history-user" multiple>
|
||||||
<option value="">All Users</option>
|
|
||||||
<option disabled>────────────</option>
|
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -121,6 +119,7 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="javascriptIncludes()">
|
<%def name="javascriptIncludes()">
|
||||||
|
<script src="${http_root}js/bootstrap-select.min.js"></script>
|
||||||
<script src="${http_root}js/jquery.dataTables.min.js"></script>
|
<script src="${http_root}js/jquery.dataTables.min.js"></script>
|
||||||
<script src="${http_root}js/dataTables.colVis.js"></script>
|
<script src="${http_root}js/dataTables.colVis.js"></script>
|
||||||
<script src="${http_root}js/dataTables.bootstrap.min.js"></script>
|
<script src="${http_root}js/dataTables.bootstrap.min.js"></script>
|
||||||
|
@ -134,17 +133,40 @@
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
var select = $('#history-user');
|
let select = $('#graph-user');
|
||||||
|
let by_id = {};
|
||||||
data.sort(function (a, b) {
|
data.sort(function (a, b) {
|
||||||
return a.friendly_name.localeCompare(b.friendly_name);
|
return a.friendly_name.localeCompare(b.friendly_name);
|
||||||
});
|
});
|
||||||
data.forEach(function (item) {
|
data.forEach(function (item) {
|
||||||
select.append('<option value="' + item.user_id + '">' +
|
select.append('<option value="' + item.user_id + '">' +
|
||||||
item.friendly_name + '</option>');
|
item.friendly_name + '</option>');
|
||||||
|
by_id[item.user_id] = item.friendly_name;
|
||||||
});
|
});
|
||||||
|
select.selectpicker({
|
||||||
|
countSelectedText: function(sel, total) {
|
||||||
|
if (sel === 0 || sel === total) {
|
||||||
|
return 'All users';
|
||||||
|
} else if (sel > 1) {
|
||||||
|
return sel + ' users';
|
||||||
|
} else {
|
||||||
|
return select.val().map(function(id) {
|
||||||
|
return by_id[id];
|
||||||
|
}).join(', ');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: 'btn-dark',
|
||||||
|
actionsBox: true,
|
||||||
|
selectedTextFormat: 'count',
|
||||||
|
noneSelectedText: 'All users'
|
||||||
|
});
|
||||||
|
select.selectpicker('render');
|
||||||
|
select.selectpicker('selectAll');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let history_user_last_id = undefined;
|
||||||
|
|
||||||
function loadHistoryTable(media_type, transcode_decision, selected_user_id) {
|
function loadHistoryTable(media_type, transcode_decision, selected_user_id) {
|
||||||
history_table_options.ajax = {
|
history_table_options.ajax = {
|
||||||
url: 'get_history',
|
url: 'get_history',
|
||||||
|
@ -187,7 +209,16 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#history-user').on('change', function () {
|
$('#history-user').on('change', function () {
|
||||||
selected_user_id = $(this).val() || null;
|
let val = $(this).val();
|
||||||
|
if (val.length === 0 || val.length === $(this).children().length) {
|
||||||
|
selected_user_id = null; // if all users are selected, just send an empty list
|
||||||
|
} else {
|
||||||
|
selected_user_id = val.join(",");
|
||||||
|
}
|
||||||
|
if (selected_user_id === graph_user_last_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
history_user_last_id = selected_user_id;
|
||||||
history_table.draw();
|
history_table.draw();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue