Also add group delete to user history and info pages

This commit is contained in:
Jonathan Wong 2015-08-23 15:33:41 -07:00
parent 7ba6d704cd
commit 609549f974
3 changed files with 106 additions and 9 deletions

View file

@ -51,7 +51,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
<h4 class="modal-title" id="myModalLabel">Confirm Purge</h4>
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
</div>
<div class="modal-body" style="text-align: center;">
<p>Are you REALLY sure you want to delete this history?</p>
@ -59,7 +59,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-dark" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger btn-ok" data-dismiss="modal" id="confirm-delete">Purge</button>
<button type="button" class="btn btn-danger btn-ok" data-dismiss="modal" id="confirm-delete">Delete</button>
</div>
</div>
</div>

View file

@ -185,7 +185,11 @@ DOCUMENTATION :: END
<span>Watch History for <strong>${data['title']}</strong></span>
</div>
<div class="button-bar">
<button class="btn btn-danger" data-toggle="button" aria-pressed="false" autocomplete="off" id="row-edit-mode"><i class="fa fa-trash-o"></i> Delete mode</button>&nbsp
<span data-toggle="popover" data-placement="left" data-content="Data deleting does not occur until after exiting delete mode." id="delete-message">
<button class="btn btn-danger" data-toggle="button" aria-pressed="false" autocomplete="off" id="row-edit-mode">
<i class="fa fa-trash-o"></i> Delete mode
</button>&nbsp
</span>
<div class="colvis-button-bar hidden-xs"></div>
</div>
</div>
@ -214,6 +218,24 @@ DOCUMENTATION :: END
</div>
<div class="modal fade" id="ip-info-modal" tabindex="-1" role="dialog" aria-labelledby="ip-info-modal">
</div>
<div class="modal fade" id="confirm-modal" tabindex="-1" role="dialog" aria-labelledby="confirm-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
</div>
<div class="modal-body" style="text-align: center;">
<p>Are you REALLY sure you want to delete this history?</p>
<p>This is permanent and cannot be undone!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-dark" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger btn-ok" data-dismiss="modal" id="confirm-delete">Delete</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@ -281,11 +303,38 @@ DOCUMENTATION :: END
clearSearchButton('history_table', history_table);
$('#row-edit-mode').click(function() {
var history_to_purge = [];
$('#row-edit-mode').on('click', function() {
$('#delete-message').popover();
if ($(this).hasClass('active')) {
$('.delete-control').each(function() {
history_to_purge = [];
$('.delete-control button.btn-danger').map(function () {
history_to_purge.push($(this).attr('data-id'));
});
if (history_to_purge.length > 0) {
$('#confirm-modal').modal();
$('#confirm-modal').one('click', '#confirm-delete', function () {
for (var i = 0; i < history_to_purge.length; i++) {
$.ajax({
url: 'delete_history_rows',
data: { row_id: history_to_purge[i] },
async: true,
success: function (data) {
var msg = "User history purged";
showMsg(msg, false, true, 2000);
}
});
}
history_table.draw();
});
}
$('.delete-control').each(function () {
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
$(this).addClass('hidden');
});
} else {
$('.delete-control').each(function() {
$(this).removeClass('hidden');

View file

@ -155,7 +155,11 @@ from plexpy import helpers
</strong></span>
</div>
<div class="button-bar">
<button class="btn btn-danger" data-toggle="button" aria-pressed="false" autocomplete="off" id="row-edit-mode"><i class="fa fa-trash-o"></i> Delete Mode</button>&nbsp
<span data-toggle="popover" data-placement="left" data-content="Data deleting does not occur until after exiting delete mode." id="delete-message">
<button class="btn btn-danger" data-toggle="button" aria-pressed="false" autocomplete="off" id="row-edit-mode">
<i class="fa fa-trash-o"></i> Delete mode
</button>&nbsp
</span>
<div class="colvis-button-bar hidden-xs" id="button-bar-history">
</div>
</div>
@ -227,6 +231,24 @@ from plexpy import helpers
</div>
<div class="modal fade" id="ip-info-modal" tabindex="-1" role="dialog" aria-labelledby="ip-info-modal">
</div>
<div class="modal fade" id="confirm-modal" tabindex="-1" role="dialog" aria-labelledby="confirm-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
</div>
<div class="modal-body" style="text-align: center;">
<p>Are you REALLY sure you want to delete this history?</p>
<p>This is permanent and cannot be undone!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-dark" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger btn-ok" data-dismiss="modal" id="confirm-delete">Delete</button>
</div>
</div>
</div>
</div>
</div>
<footer></footer>
</%def>
@ -368,12 +390,38 @@ from plexpy import helpers
});
});
// Delete mode button
$('#row-edit-mode').click(function() {
var history_to_purge = [];
$('#row-edit-mode').on('click', function() {
$('#delete-message').popover();
if ($(this).hasClass('active')) {
$('.delete-control').each(function() {
history_to_purge = [];
$('.delete-control button.btn-danger').map(function () {
history_to_purge.push($(this).attr('data-id'));
});
if (history_to_purge.length > 0) {
$('#confirm-modal').modal();
$('#confirm-modal').one('click', '#confirm-delete', function () {
for (var i = 0; i < history_to_purge.length; i++) {
$.ajax({
url: 'delete_history_rows',
data: { row_id: history_to_purge[i] },
async: true,
success: function (data) {
var msg = "User history purged";
showMsg(msg, false, true, 2000);
}
});
}
history_table.draw();
});
}
$('.delete-control').each(function () {
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
$(this).addClass('hidden');
});
} else {
$('.delete-control').each(function() {
$(this).removeClass('hidden');