From 9ad85091edf061d97bc19b60a743d89fa0e3d1dd Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Tue, 14 Jun 2016 11:55:00 +0300 Subject: [PATCH] Add UI to delete alerts (closes #731) --- rd_ui/app/scripts/controllers/alerts.js | 11 +++++++++++ rd_ui/app/views/alerts/edit.html | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) 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 @@
-
+
- + {{$select.selected.name}} - +
@@ -30,7 +30,7 @@
+ class="form-control" ng-disabled="!canEdit">
@@ -40,24 +40,25 @@
- +
-
- +
-
- +
+ +