Skip to content

Commit

Permalink
#1410 Update alert list and details dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jun 27, 2020
1 parent 558dae9 commit a1e75ae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
14 changes: 7 additions & 7 deletions frontend/app/scripts/controllers/alert/AlertEventCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
angular.module('theHiveControllers')
.controller('AlertEventCtrl', function($scope, $rootScope, $state, $uibModal, $uibModalInstance, ModalUtilsSrv, AuthenticationSrv, CustomFieldsSrv, CaseResolutionStatus, AlertingSrv, NotificationSrv, UiSettingsSrv, clipboard, event, templates, readonly) {
var self = this;
var eventId = event.id;
var eventId = event._id;

self.readonly = readonly;
self.templates = _.pluck(templates, 'name');
Expand Down Expand Up @@ -101,7 +101,7 @@
var field = {};
field[fieldName] = newValue;

return AlertingSrv.update(self.event.id, field)
return AlertingSrv.update(self.event._id, field)
.then(function() {
NotificationSrv.log('Alert updated successfully', 'success');
})
Expand All @@ -112,7 +112,7 @@

self.import = function() {
self.loading = true;
AlertingSrv.create(self.event.id, {
AlertingSrv.create(self.event._id, {
caseTemplate: self.event.caseTemplate
}).then(function(response) {
$uibModalInstance.dismiss();
Expand All @@ -130,7 +130,7 @@

self.mergeIntoCase = function(caseId) {
self.loading = true;
AlertingSrv.mergeInto(self.event.id, caseId)
AlertingSrv.mergeInto(self.event._id, caseId)
.then(function(response) {
$uibModalInstance.dismiss();

Expand Down Expand Up @@ -182,7 +182,7 @@
fn = AlertingSrv.follow;
}

fn(self.event.id).then(function() {
fn(self.event._id).then(function() {
$uibModalInstance.close();
}).catch(function(response) {
NotificationSrv.error('AlertEventCtrl', response.data, response.status);
Expand All @@ -194,7 +194,7 @@
okText: 'Yes, remove it',
flavor: 'danger'
}).then(function() {
AlertingSrv.forceRemove(self.event.id)
AlertingSrv.forceRemove(self.event._id)
.then(function() {
$uibModalInstance.close();
NotificationSrv.log('Alert has been permanently deleted', 'success');
Expand All @@ -218,7 +218,7 @@
fn = AlertingSrv.markAsUnread;
}

fn(this.event.id).then(function( /*data*/ ) {
fn(this.event._id).then(function( /*data*/ ) {
$uibModalInstance.close();
}, function(response) {
NotificationSrv.error('AlertEventCtrl', response.data, response.status);
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/scripts/controllers/alert/AlertListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
fn = AlertingSrv.markAsUnread;
}

fn(event.id).then(function( /*data*/ ) {
fn(event._id).then(function( /*data*/ ) {
}, function(response) {
NotificationSrv.error('AlertListCtrl', response.data, response.status);
});
Expand All @@ -101,7 +101,7 @@
fn = AlertingSrv.follow;
}

fn(event.id).then(function( /*data*/ ) {
fn(event._id).then(function( /*data*/ ) {
}, function(response) {
NotificationSrv.error('AlertListCtrl', response.data, response.status);
});
Expand Down Expand Up @@ -251,7 +251,7 @@
self.selection.push(event);
} else {
self.selection = _.reject(self.selection, function(item) {
return item.id === event.id;
return item._id === event._id;
});
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/app/scripts/services/api/AlertingSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
alertIds: alertIds
});
},

canMarkAsRead: function(event) {
return event.status === 'New' || event.status === 'Updated';
return !!!event.read;
},

canMarkAsUnread: function(event) {
return event.status === 'Imported' || event.status === 'Ignored';
return !!event.read;
},

markAsRead: function(alertId) {
Expand Down
20 changes: 16 additions & 4 deletions frontend/app/views/partials/alert/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ <h3 class="box-title">List of alerts ({{$vm.list.total || 0}} of {{alertEvents.c
<i ng-show="$vm.filtering.context.sort.indexOf('-date') !== -1" class="fa fa-caret-down"></i>
</a>
</th>
<th style="width: 50px">
<a href class="text-default" ng-click="$vm.sortByField('_createdBy')">
By
<i ng-show="$vm.filtering.context.sort.indexOf('+_createdBy') === -1 && $vm.filtering.context.sort.indexOf('-_createdBy') === -1" class="fa fa-sort"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+_createdBy') !== -1" class="fa fa-caret-up"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('-_createdBy') !== -1" class="fa fa-caret-down"></i>
</a>
</th>
<th style="width: 160px"></th>
</tr>
</thead>
Expand All @@ -115,6 +123,7 @@ <h3 class="box-title">List of alerts ({{$vm.list.total || 0}} of {{alertEvents.c
</td>
<td>
<span class="clickable label label-default" ng-class="{'label-danger': event.status==='New', 'label-warning': event.status === 'Updated'}" ng-click="$vm.addFilterValue('status', event.status)">{{::event.status}}</span>
<span class="clickable label label-default" ng-class="{'label-danger': !event.case}">{{event.case ? 'Imported' : 'New'}}</span>
</td>
<td class="wrap">
<div class="case-title">
Expand All @@ -141,10 +150,13 @@ <h3 class="box-title">List of alerts ({{$vm.list.total || 0}} of {{alertEvents.c
<severity active="false" value="event.severity"></severity>
</div>
</td>
<td class="text-center">{{::event.artifacts.length || 0}}</td>
<td class="text-center">{{::event.observableCount || 0}}</td>
<td>
<a href ng-click="$vm.addFilterValue('date', event.date)">{{event.date | shortDate}}</a>
</td>
<td>
<user user-id="event._createdBy" icon-only="true"></user>
</td>
<td class="clearfix">
<div class="pull-right" if-permission="manageAlert">
<a class="btn btn-xs btn-icon btn-clear" href ng-click="$vm.follow(event)" uib-tooltip="{{event.follow ? 'Ignore new updates' : 'Track new updates'}}">
Expand All @@ -156,13 +168,13 @@ <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 ng-if="$vm.appConfig.connectors.cortex.enabled" if-permission="manageAction">
<a href class="text-primary noline nowrap" ng-click="$vm.getResponders(event.id, true)" uib-dropdown-toggle>
<span class="btn btn-xs btn-icon btn-clear" uib-dropdown ng-if="appConfig.connectors.cortex.enabled" if-permission="manageAction">
<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)">
<a href ng-click="$vm.getResponders(event._id, true)">
<strong><i class="fa fa-refresh mr-xxs"></i> No responders available</strong>
</a>
</li>
Expand Down

0 comments on commit a1e75ae

Please sign in to comment.