mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Add user filter to the synced table
This commit is contained in:
parent
9100e25a21
commit
d29a12b6db
6 changed files with 71 additions and 24 deletions
|
@ -114,7 +114,7 @@
|
|||
$.ajax({
|
||||
url: 'get_user_names',
|
||||
type: 'get',
|
||||
dataType: "json",
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
var select = $('#history-user');
|
||||
data.sort(function (a, b) {
|
||||
|
@ -130,7 +130,6 @@
|
|||
function loadHistoryTable(media_type, selected_user_id) {
|
||||
history_table_options.ajax = {
|
||||
url: 'get_history',
|
||||
type: 'post',
|
||||
data: function (d) {
|
||||
return {
|
||||
json_data: JSON.stringify(d),
|
||||
|
@ -138,9 +137,13 @@
|
|||
user_id: selected_user_id
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
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] });
|
||||
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);
|
||||
|
@ -160,7 +163,7 @@
|
|||
}
|
||||
|
||||
var media_type = null;
|
||||
var selected_user_id = "${_session['user_id']}" == "None" ? null : "${_session['user_id']}"
|
||||
var selected_user_id = "${_session['user_id']}" == "None" ? null : "${_session['user_id']}";
|
||||
loadHistoryTable(media_type, selected_user_id);
|
||||
|
||||
% if _session['user_group'] == 'admin':
|
||||
|
|
|
@ -21,7 +21,7 @@ history_table_options = {
|
|||
"infoFiltered": "<span class='hidden-md hidden-sm hidden-xs'>(filtered from _MAX_ total entries)</span>",
|
||||
"emptyTable": "No data in table",
|
||||
"loadingRecords": '<i class="fa fa-refresh fa-spin"></i> Loading items...</div>'
|
||||
},
|
||||
},
|
||||
"pagingType": "full_numbers",
|
||||
"stateSave": true,
|
||||
"processing": false,
|
||||
|
@ -172,7 +172,7 @@ history_table_options = {
|
|||
},
|
||||
"width": "33%",
|
||||
"className": "datatable-wrap"
|
||||
},
|
||||
},
|
||||
{
|
||||
"targets": [7],
|
||||
"data":"started",
|
||||
|
@ -322,7 +322,7 @@ history_table_options = {
|
|||
$(row).addClass('current-activity-row');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Parent table platform modal
|
||||
$('.history_table').on('click', '> tbody > tr > td.modal-control', function () {
|
||||
|
|
|
@ -98,7 +98,7 @@ sync_table_options = {
|
|||
"data": "total_size",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (cellData > 0 ) {
|
||||
megabytes = Math.round((cellData/1024)/1024, 0)
|
||||
megabytes = Math.round((cellData/1024)/1024, 0);
|
||||
$(td).html(megabytes + 'MB');
|
||||
} else {
|
||||
$(td).html('0MB');
|
||||
|
@ -144,14 +144,16 @@ sync_table_options = {
|
|||
var msg = "<i class='fa fa-refresh fa-spin'></i> Fetching rows...";
|
||||
showMsg(msg, false, false, 0)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$('#sync_table').on('click', 'td.delete-control > .edit-sync-toggles > button.delete-sync', function () {
|
||||
var tr = $(this).parents('tr');
|
||||
var row = sync_table.row(tr);
|
||||
var rowData = row.data();
|
||||
|
||||
var index_delete = syncs_to_delete.findIndex(x => x.client_id == rowData['client_id'] && x.sync_id == rowData['sync_id']);
|
||||
var index_delete = syncs_to_delete.findIndex(function (x) {
|
||||
return x.client_id === rowData['client_id'] && x.sync_id === rowData['sync_id'];
|
||||
});
|
||||
|
||||
if (index_delete === -1) {
|
||||
syncs_to_delete.push({ client_id: rowData['client_id'], sync_id: rowData['sync_id'] });
|
||||
|
|
|
@ -27,6 +27,16 @@
|
|||
</button> 
|
||||
</div>
|
||||
% endif
|
||||
% if _session['user_group'] == 'admin':
|
||||
<div class="btn-group" id="user-selection">
|
||||
<label>
|
||||
<select name="sync-user" id="sync-user" class="btn" style="color: inherit;">
|
||||
<option value="">All Users</option>
|
||||
<option disabled>────────────</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
% endif
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-dark refresh-syncs-button" id="refresh-syncs-list"><i class="fa fa-refresh"></i> Refresh synced items</button>
|
||||
</div>
|
||||
|
@ -87,17 +97,45 @@
|
|||
<script src="${http_root}js/tables/sync_table.js${cache_param}"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
sync_table_options.ajax = {
|
||||
url: 'get_sync',
|
||||
data: function (d) {
|
||||
d.user_id = "${_session['user_id']}" == "None" ? null : "${_session['user_id']}"
|
||||
// Load user ids and names (for the selector)
|
||||
$.ajax({
|
||||
url: 'get_user_names',
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
var select = $('#sync-user');
|
||||
data.sort(function (a, b) {
|
||||
return a.friendly_name.localeCompare(b.friendly_name);
|
||||
});
|
||||
data.forEach(function (item) {
|
||||
select.append('<option value="' + item.user_id + '">' +
|
||||
item.friendly_name + '</option>');
|
||||
});
|
||||
}
|
||||
}
|
||||
sync_table = $('#sync_table').DataTable(sync_table_options);
|
||||
var colvis = new $.fn.dataTable.ColVis( sync_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark', exclude: [0] } );
|
||||
$( colvis.button() ).appendTo('div.colvis-button-bar');
|
||||
});
|
||||
|
||||
clearSearchButton('sync_table', sync_table);
|
||||
function loadSyncTable(selected_user_id) {
|
||||
sync_table_options.ajax = {
|
||||
url: 'get_sync?user_id=' + selected_user_id
|
||||
};
|
||||
sync_table = $('#sync_table').DataTable(sync_table_options);
|
||||
var colvis = new $.fn.dataTable.ColVis(sync_table, {
|
||||
buttonText: '<i class="fa fa-columns"></i> Select columns',
|
||||
buttonClass: 'btn btn-dark',
|
||||
exclude: [0]
|
||||
});
|
||||
$(colvis.button()).appendTo('div.colvis-button-bar');
|
||||
|
||||
clearSearchButton('sync_table', sync_table);
|
||||
|
||||
$('#sync-user').on('change', function () {
|
||||
selected_user_id = $(this).val() || null;
|
||||
sync_table.ajax.url('get_sync?user_id=' + selected_user_id).load();
|
||||
});
|
||||
}
|
||||
|
||||
var selected_user_id = "${_session['user_id']}" == "None" ? null : "${_session['user_id']}";
|
||||
loadSyncTable(selected_user_id);
|
||||
|
||||
% if _session['user_group'] == 'admin':
|
||||
$('#row-edit-mode').on('click', function() {
|
||||
|
|
|
@ -384,6 +384,11 @@ class PlexTV(object):
|
|||
elif rating_key_filter is not None:
|
||||
rating_key_filter = [str(rating_key_filter)]
|
||||
|
||||
if isinstance(user_id_filter, list):
|
||||
user_id_filter = [str(k) for k in user_id_filter]
|
||||
elif user_id_filter is not None:
|
||||
user_id_filter = [str(user_id_filter)]
|
||||
|
||||
sync_list = self.get_plextv_sync_lists(machine_id, output_format='xml')
|
||||
user_data = users.Users()
|
||||
|
||||
|
@ -423,7 +428,7 @@ class PlexTV(object):
|
|||
device_last_seen = helpers.get_xml_attr(device, 'lastSeenAt')
|
||||
|
||||
# Filter by user_id
|
||||
if user_id_filter and str(user_id_filter) != device_user_id:
|
||||
if user_id_filter and device_user_id not in user_id_filter:
|
||||
continue
|
||||
|
||||
for synced in a.getElementsByTagName('SyncItems'):
|
||||
|
|
|
@ -2201,9 +2201,8 @@ class WebInterface(object):
|
|||
@cherrypy.tools.json_out()
|
||||
@requireAuth()
|
||||
def get_sync(self, machine_id=None, user_id=None, **kwargs):
|
||||
|
||||
if not machine_id:
|
||||
machine_id = plexpy.CONFIG.PMS_IDENTIFIER
|
||||
if user_id == 'null':
|
||||
user_id = None
|
||||
|
||||
plex_tv = plextv.PlexTV()
|
||||
result = plex_tv.get_synced_items(machine_id=machine_id, user_id_filter=user_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue