mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 21:03:21 -07:00
Add edit mode to sync table on user page
This commit is contained in:
parent
36ff1fb674
commit
bbc6482c99
3 changed files with 65 additions and 10 deletions
|
@ -146,7 +146,7 @@ sync_table_options = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$('#sync_table').on('click', 'td.delete-control > .edit-sync-toggles > button.delete-sync', function () {
|
$('.sync_table').on('click', 'td.delete-control > .edit-sync-toggles > button.delete-sync', function () {
|
||||||
var tr = $(this).parents('tr');
|
var tr = $(this).parents('tr');
|
||||||
var row = sync_table.row(tr);
|
var row = sync_table.row(tr);
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='table-card-back'>
|
<div class='table-card-back'>
|
||||||
<table class="display" id="sync_table" width="100%">
|
<table class="display sync_table" id="sync_table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left" id="delete_row">Delete</th>
|
<th align="left" id="delete_row">Delete</th>
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
sync_table.draw();
|
sync_table.ajax.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#refresh-syncs-list").click(function() {
|
$("#refresh-syncs-list").click(function() {
|
||||||
sync_table.draw();
|
sync_table.ajax.reload();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
|
@ -213,11 +213,22 @@ DOCUMENTATION :: END
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="button-bar">
|
<div class="button-bar">
|
||||||
|
% if _session['user_group'] == 'admin':
|
||||||
|
<div class="alert alert-danger alert-edit" role="alert" id="sync-row-edit-mode-alert"><i class="fa fa-exclamation-triangle"></i> Select syncs to delete. Data is deleted upon exiting edit mode.</div>
|
||||||
|
<div class="btn-group">
|
||||||
|
<button class="btn btn-danger btn-edit" data-toggle="button" aria-pressed="false" autocomplete="off" id="sync-row-edit-mode">
|
||||||
|
<i class="fa fa-pencil"></i> Edit mode
|
||||||
|
</button> 
|
||||||
|
</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>
|
||||||
<div class="btn-group colvis-button-bar" id="button-bar-sync"></div>
|
<div class="btn-group colvis-button-bar" id="button-bar-sync"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-card-back">
|
<div class="table-card-back">
|
||||||
<table class="display" id="sync_table-UID-${data['user_id']}" width="100%">
|
<table class="display sync_table" id="sync_table-UID-${data['user_id']}" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left" id="state">State</th>
|
<th align="left" id="state">State</th>
|
||||||
|
@ -351,7 +362,7 @@ DOCUMENTATION :: END
|
||||||
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
|
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body" style="text-align: center;">
|
<div class="modal-body" style="text-align: center;">
|
||||||
<p>Are you REALLY sure you want to delete <strong><span id="deleteCount"></span></strong> history item(s)?</p>
|
<p>Are you REALLY sure you want to delete <strong><span id="deleteCount"></span></strong> <span id="deleteType"></span> item(s)?</p>
|
||||||
<p>This is permanent and cannot be undone!</p>
|
<p>This is permanent and cannot be undone!</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -431,10 +442,7 @@ DOCUMENTATION :: END
|
||||||
$('a[href="#tabs-synceditems"]').on('shown.bs.tab', function() {
|
$('a[href="#tabs-synceditems"]').on('shown.bs.tab', function() {
|
||||||
// Build user sync table
|
// Build user sync table
|
||||||
sync_table_options.ajax = {
|
sync_table_options.ajax = {
|
||||||
url: 'get_sync',
|
url: 'get_sync?user_id=' + user_id
|
||||||
data: function(d) {
|
|
||||||
d.user_id = user_id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sync_table = $('#sync_table-UID-${data["user_id"]}').DataTable(sync_table_options);
|
sync_table = $('#sync_table-UID-${data["user_id"]}').DataTable(sync_table_options);
|
||||||
sync_table.column(1).visible(false);
|
sync_table.column(1).visible(false);
|
||||||
|
@ -502,6 +510,7 @@ DOCUMENTATION :: END
|
||||||
if ($(this).hasClass('active')) {
|
if ($(this).hasClass('active')) {
|
||||||
if (history_to_delete.length > 0) {
|
if (history_to_delete.length > 0) {
|
||||||
$('#deleteCount').text(history_to_delete.length);
|
$('#deleteCount').text(history_to_delete.length);
|
||||||
|
$('#deleteType').text('history');
|
||||||
$('#confirm-modal-delete').modal();
|
$('#confirm-modal-delete').modal();
|
||||||
$('#confirm-modal-delete').one('click', '#confirm-delete', function () {
|
$('#confirm-modal-delete').one('click', '#confirm-delete', function () {
|
||||||
history_to_delete.forEach(function(row, idx) {
|
history_to_delete.forEach(function(row, idx) {
|
||||||
|
@ -533,12 +542,58 @@ DOCUMENTATION :: END
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#sync-row-edit-mode').on('click', function() {
|
||||||
|
$('#sync-row-edit-mode-alert').fadeIn(200);
|
||||||
|
|
||||||
|
if ($(this).hasClass('active')) {
|
||||||
|
if (syncs_to_delete.length > 0) {
|
||||||
|
$('#deleteCount').text(syncs_to_delete.length);
|
||||||
|
$('#deleteType').text('sync');
|
||||||
|
$('#confirm-modal-delete').modal();
|
||||||
|
$('#confirm-modal-delete').one('click', '#confirm-delete', function () {
|
||||||
|
syncs_to_delete.forEach(function(row, idx) {
|
||||||
|
$.ajax({
|
||||||
|
url: 'delete_sync_rows',
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
client_id: row.client_id,
|
||||||
|
sync_id: row.sync_id
|
||||||
|
},
|
||||||
|
async: true,
|
||||||
|
success: function (data) {
|
||||||
|
var msg = "Sync deleted";
|
||||||
|
showMsg(msg, false, true, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
sync_table.ajax.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.delete-control').each(function () {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
$('#sync-row-edit-mode-alert').fadeOut(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
syncs_to_delete = [];
|
||||||
|
$('.delete-control').each(function() {
|
||||||
|
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
$(this).removeClass('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
$("#refresh-history-list").click(function () {
|
$("#refresh-history-list").click(function () {
|
||||||
history_table.draw();
|
history_table.draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#refresh-syncs-list").click(function() {
|
||||||
|
sync_table.ajax.reload();
|
||||||
|
});
|
||||||
|
|
||||||
function recentlyWatched() {
|
function recentlyWatched() {
|
||||||
// Populate recently watched
|
// Populate recently watched
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue