diff --git a/rd_ui/app/scripts/controllers/alerts.js b/rd_ui/app/scripts/controllers/alerts.js index 342792785..c444e388e 100644 --- a/rd_ui/app/scripts/controllers/alerts.js +++ b/rd_ui/app/scripts/controllers/alerts.js @@ -67,10 +67,12 @@ if ($scope.alertId === "new") { $scope.alert = new Alert({options: {}}); + $scope.canEdit = true; } else { $scope.alert = Alert.get({id: $scope.alertId}, function(alert) { $scope.onQuerySelected(new Query($scope.alert.query)); }); + $scope.canEdit = currentUser.canEdit($scope.alert); } $scope.ops = ['greater than', 'less than', 'equals']; @@ -110,6 +112,15 @@ }); }; + $scope.delete = function() { + $scope.alert.$delete(function() { + $location.path('/alerts'); + growl.addSuccessMessage("Alert deleted."); + }, function() { + growl.addErrorMessage("Failed deleting alert."); + }); + } + }; angular.module('redash.directives').directive('alertSubscriptions', ['$q', '$sce', 'AlertSubscription', 'Destination', 'growl', function ($q, $sce, AlertSubscription, Destination, growl) { diff --git a/rd_ui/app/views/alerts/edit.html b/rd_ui/app/views/alerts/edit.html index 79b439a25..fbc6c5021 100644 --- a/rd_ui/app/views/alerts/edit.html +++ b/rd_ui/app/views/alerts/edit.html @@ -7,10 +7,10 @@