From 262c849383378bd034439aeb0c0d22fdb0f14179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anh=20Tu=E1=BA=A5n?= Date: Sat, 28 Oct 2017 15:38:06 +0700 Subject: Warn before delete users or links --- public/js/AdminCtrl.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/public/js/AdminCtrl.js b/public/js/AdminCtrl.js index 586fb96..4f0b90c 100644 --- a/public/js/AdminCtrl.js +++ b/public/js/AdminCtrl.js @@ -267,14 +267,16 @@ polr.controller('AdminCtrl', function($scope, $compile, $timeout) { // Delete user $scope.deleteUser = function($event, user_id) { - var el = $($event.target); - - apiCall('admin/delete_user', { - 'user_id': user_id, - }, function(new_status) { - toastr.success('User successfully deleted.', 'Success'); - $scope.reloadUserTables(); - }); + if(confirm("Are you sure to delete this user?")){ + var el = $($event.target); + + apiCall('admin/delete_user', { + 'user_id': user_id, + }, function(new_status) { + toastr.success('User successfully deleted.', 'Success'); + $scope.reloadUserTables(); + }); + } }; $scope.changeUserRole = function(role, user_id) { @@ -308,14 +310,16 @@ polr.controller('AdminCtrl', function($scope, $compile, $timeout) { // Delete link $scope.deleteLink = function($event, link_ending) { - var el = $($event.target); - - apiCall('admin/delete_link', { - 'link_ending': link_ending, - }, function(new_status) { - toastr.success('Link successfully deleted.', 'Success'); - $scope.reloadLinkTables(); - }); + if(confirm("Are you sure to delete this link?")){ + var el = $($event.target); + + apiCall('admin/delete_link', { + 'link_ending': link_ending, + }, function(new_status) { + toastr.success('Link successfully deleted.', 'Success'); + $scope.reloadLinkTables(); + }); + } }; // Disable and enable links -- cgit v1.2.3