Skip to content

Commit

Permalink
#974 Add the capability to hard delete an Alert
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jul 8, 2019
1 parent d11afde commit 258299c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
20 changes: 19 additions & 1 deletion ui/app/scripts/controllers/alert/AlertEventCtrl.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(function() {
'use strict';
angular.module('theHiveControllers')
.controller('AlertEventCtrl', function($scope, $rootScope, $state, $uibModal, $uibModalInstance, CustomFieldsCacheSrv, CaseResolutionStatus, AlertingSrv, NotificationSrv, UiSettingsSrv, clipboard, event, templates) {
.controller('AlertEventCtrl', function($scope, $rootScope, $state, $uibModal, $uibModalInstance, ModalUtilsSrv, CustomFieldsCacheSrv, CaseResolutionStatus, AlertingSrv, NotificationSrv, UiSettingsSrv, clipboard, event, templates, isAdmin) {
var self = this;
var eventId = event.id;

self.isAdmin = isAdmin;
self.templates = _.pluck(templates, 'name');
self.CaseResolutionStatus = CaseResolutionStatus;
self.event = event;
Expand Down Expand Up @@ -189,6 +190,23 @@
});
};

this.delete = function() {
ModalUtilsSrv.confirm('Remove Alert', 'Are you sure you want to delete this Alert?', {
okText: 'Yes, remove it',
flavor: 'danger'
}).then(function() {
AlertingSrv.forceRemove(self.event.id)
.then(function() {
$uibModalInstance.close();
NotificationSrv.log('Alert has been permanently deleted', 'success');
})
.catch(function(response) {
NotificationSrv.error('AlertEventCtrl', response.data, response.status);
});
});

};

this.canMarkAsRead = AlertingSrv.canMarkAsRead;
this.canMarkAsUnread = AlertingSrv.canMarkAsUnread;

Expand Down
5 changes: 4 additions & 1 deletion ui/app/scripts/controllers/alert/AlertListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

self.urls = VersionSrv.mispUrls();

self.isAdmin = $scope.isAdmin($scope.currentUser);

self.list = [];
self.selection = [];
self.menu = {
Expand Down Expand Up @@ -203,7 +205,8 @@
event: event,
templates: function() {
return CaseTemplateSrv.list();
}
},
isAdmin: self.isAdmin
}
});
};
Expand Down
8 changes: 8 additions & 0 deletions ui/app/scripts/services/AlertingSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
return $http.post(baseUrl + '/' + alertId + '/unfollow');
},

forceRemove: function(alertId) {
return $http.delete(baseUrl + '/' + alertId, {
params: {
force: 1
}
});
},

stats: function(scope) {
var field = 'status',
result = {},
Expand Down
4 changes: 4 additions & 0 deletions ui/app/views/partials/alert/event.dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ <h4 class="vpad10 text-primary">
<i class="fa fa-compress"></i> Merge into case
</button>

<button ng-if="dialog.isAdmin" class="btn btn-danger" type="button" ng-disabled="dialog.loading" ng-click="dialog.delete()">
<i class="fa fa-trash"></i> Delete
</button>

<form name="eventForm" class="form-horizontal pull-right mr-xs" style="width:450px;" ng-submit="dialog.import()">
<div class="form-group">
<label class="col-sm-4 control-label">Import alert as</label>
Expand Down
1 change: 1 addition & 0 deletions ui/app/views/partials/alert/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<h3 class="box-title">List of alerts ({{$vm.list.total || 0}} of {{alertEvents.count}})</h3>
</div>
<div class="box-body">

<div ng-include="'views/partials/alert/list/toolbar.html'"></div>

<div class="mv-s filter-panel" ng-include="'views/partials/alert/list/mini-stats.html'" ng-show="$vm.filtering.context.showStats"></div>
Expand Down

0 comments on commit 258299c

Please sign in to comment.