Skip to content

Commit

Permalink
#609 Add responder menu in alerts list page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jul 12, 2018
1 parent 0291aeb commit 17667a8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
28 changes: 27 additions & 1 deletion ui/app/scripts/controllers/alert/AlertListCtrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
'use strict';
angular.module('theHiveControllers')
.controller('AlertListCtrl', function($scope, $q, $state, $uibModal, TagSrv, CaseTemplateSrv, AlertingSrv, NotificationSrv, FilteringSrv, Severity) {
.controller('AlertListCtrl', function($scope, $q, $state, $uibModal, TagSrv, CaseTemplateSrv, AlertingSrv, NotificationSrv, FilteringSrv, CortexSrv, Severity) {
var self = this;

self.list = [];
Expand Down Expand Up @@ -94,6 +94,7 @@
searchQuery: self.filtering.buildQuery() || ''
};
self.lastSearch = null;
self.responders = null;

$scope.$watch('$vm.list.pageSize', function (newValue) {
self.filtering.setPageSize(newValue);
Expand Down Expand Up @@ -209,6 +210,31 @@
}
};

this.getResponders = function(eventId, force) {
if(!force && this.responders !== null) {
return;
}

this.responders = null;
CortexSrv.getResponders('alert', eventId)
.then(function(responders) {
self.responders = responders;
})
.catch(function(err) {
NotificationSrv.error('AlertList', response.data, response.status);
})
};

this.runResponder = function(responderId, event) {
CortexSrv.runResponder(responderId, 'alert', _.pick(event, 'id', 'tlp', ))
.then(function(response) {
NotificationSrv.log(['Responder', response.data.responderName, 'started successfully on alert', event.title].join(' '), 'success');
})
.catch(function(response) {
NotificationSrv.error('CaseList', response.data, response.status);
});
};

self.load = function() {
var config = {
scope: $scope,
Expand Down
20 changes: 19 additions & 1 deletion ui/app/views/partials/alert/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h3 class="box-title">List of alerts ({{$vm.list.total || 0}} of {{alertEvents.c
<th width="80px">Severity</th>
<th width="80px">Attributes</th>
<th style="width: 160px">Date</th>
<th style="width: 120px"></th>
<th style="width: 160px"></th>
</tr>
</thead>

Expand Down Expand Up @@ -110,6 +110,24 @@ <h3 class="box-title">List of alerts ({{$vm.list.total || 0}} of {{alertEvents.c
<a class="btn btn-xs btn-icon btn-clear" href ng-click="$vm.markAsRead(event)" uib-tooltip="Mark as unread" ng-if="$vm.canMarkAsUnread(event)">
<i class="text-info text-20 fa fa-envelope-open-o"></i>
</a>
<span class="btn btn-xs btn-icon btn-clear" uib-dropdown>
<a href class="text-primary noline nowrap" ng-click="$vm.getResponders(event.id, true)" uib-dropdown-toggle>
<i class="text-info text-20 fa fa-cog"></i>
</a>
<ul class="dropdown-menu align-right" uib-dropdown-menu>
<li ng-if="$vm.responders && $vm.responders.length === 0">
<a href ng-click="$vm.getResponders(event.id, true)">
<strong><i class="fa fa-refresh mr-xxs"></i> No responders available</strong>
</a>
</li>
<li ng-repeat="responder in $vm.responders">
<a href ng-click="$vm.runResponder(responder.id, event)">
<strong>{{responder.name}}</strong>
<br>
<small>{{responder.description}}</small></a>
</li>
</ul>
</span>
</div>
</td>
</tr>
Expand Down

0 comments on commit 17667a8

Please sign in to comment.