Skip to content

Commit

Permalink
#1911 Update alert counter on alert create/update/delete
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Apr 15, 2021
1 parent 707b40e commit 907e2d6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 52 deletions.
1 change: 0 additions & 1 deletion frontend/app/scripts/controllers/RootCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ angular.module('theHiveControllers').controller('RootCtrl',
name: 'unread-alert-count'
}
},
guard: UtilsSrv.hasAddDeleteEvents,
onUpdate: function (data) {
$scope.unreadAlertCount = data;
}
Expand Down
7 changes: 3 additions & 4 deletions frontend/app/scripts/controllers/alert/AlertListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,10 @@
self.menu.markAsUnread = temp.length === 1 && temp[0] === true;

// TODO nadouani: don't rely on alert status
self.menu.createNewCase = temp.indexOf('Imported') === -1;
self.menu.mergeInCase = temp.indexOf('Imported') === -1;

temp = _.without(_.uniq(_.pluck(self.selection, 'case')), null, undefined);
temp = _.without(_.uniq(_.pluck(self.selection, 'caseId')), null, undefined);

self.menu.createNewCase = temp.length === 0;
self.menu.mergeInCase = temp.length === 0;
self.menu.delete = temp.length === 0;
};

Expand Down
96 changes: 49 additions & 47 deletions frontend/app/views/partials/case/case.alerts.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
</div>
</div>

<div class="case-links" ng-show="alerts.length > 0" ng-init="filteredLinks = (alerts | filter:filtering | orderBy:sorting.field)">
<div class="case-links" ng-show="alerts.length > 0"
ng-init="filteredLinks = (alerts | filter:filtering | orderBy:sorting.field)">
<div class="mv-s" ng-if="alertStats">
<span class="label label-lg label-default mr-xxs clickable"
ng-click="filterBy('');"
<span class="label label-lg label-default mr-xxs clickable" ng-click="filterBy('');"
ng-class="{'label-primary': currentFilter===''}">All ({{alerts.length || 0}})</span>

<span><strong>Type:</strong></span>
<span class="label label-lg label-default mr-xxs clickable"
ng-repeat="statsItem in alertStats.type"
<span class="label label-lg label-default mr-xxs clickable" ng-repeat="statsItem in alertStats.type"
ng-click="filterBy('type', statsItem.key)"
ng-class="{'label-primary': currentFilter===statsItem.key}">{{statsItem.key}} ({{statsItem.value}})</span>

<span><strong>Source:</strong></span>
<span class="label label-lg label-default mr-xxs clickable"
ng-repeat="statsItem in alertStats.source"
<span class="label label-lg label-default mr-xxs clickable" ng-repeat="statsItem in alertStats.source"
ng-click="filterBy('source', statsItem.key)"
ng-class="{'label-primary': currentFilter===statsItem.key}">{{statsItem.key}} ({{statsItem.value}})</span>
</div>
Expand All @@ -33,55 +31,57 @@
<thead>
<tr>
<th width="150px">
<a href class="text-default" ng-click="sortBy('sourceRef')">
Reference
<i ng-show="sorting.field !== '+sourceRef' && sorting.field !== '-sourceRef'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+sourceRef'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-sourceRef'" class="fa fa-caret-down"></i>
</a>
<a href class="text-default" ng-click="sortBy('sourceRef')">
Reference
<i ng-show="sorting.field !== '+sourceRef' && sorting.field !== '-sourceRef'"
class="fa fa-sort"></i>
<i ng-show="sorting.field === '+sourceRef'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-sourceRef'" class="fa fa-caret-down"></i>
</a>
</th>
<th width="160px">
<a href class="text-default" ng-click="sortBy('type')">
Type
<i ng-show="sorting.field !== '+type' && sorting.field !== '-type'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+type'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-type'" class="fa fa-caret-down"></i>
</a>
<a href class="text-default" ng-click="sortBy('type')">
Type
<i ng-show="sorting.field !== '+type' && sorting.field !== '-type'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+type'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-type'" class="fa fa-caret-down"></i>
</a>
</th>
<th>
<a href class="text-default" ng-click="sortBy('title')">
Title
<i ng-show="sorting.field !== '+title' && sorting.field !== '-title'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+title'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-title'" class="fa fa-caret-down"></i>
</a>
<a href class="text-default" ng-click="sortBy('title')">
Title
<i ng-show="sorting.field !== '+title' && sorting.field !== '-title'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+title'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-title'" class="fa fa-caret-down"></i>
</a>
</th>
<th width="150px">
<a href class="text-default" ng-click="sortBy('source')">
Source
<i ng-show="sorting.field !== '+source' && sorting.field !== '-source'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+source'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-source'" class="fa fa-caret-down"></i>
</a>
<a href class="text-default" ng-click="sortBy('source')">
Source
<i ng-show="sorting.field !== '+source' && sorting.field !== '-source'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+source'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-source'" class="fa fa-caret-down"></i>
</a>
</th>
<th width="80px">
<a href class="text-default" ng-click="sortBy('severity')">
Severity
<i ng-show="sorting.field !== '+severity' && sorting.field !== '-severity'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+severity'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-severity'" class="fa fa-caret-down"></i>
</a>
<a href class="text-default" ng-click="sortBy('severity')">
Severity
<i ng-show="sorting.field !== '+severity' && sorting.field !== '-severity'"
class="fa fa-sort"></i>
<i ng-show="sorting.field === '+severity'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-severity'" class="fa fa-caret-down"></i>
</a>
</th>
<th width="80px">
Attributes
Attributes
</th>
<th style="width: 160px">
<a href class="text-default" ng-click="sortBy('date')">
Date
<i ng-show="sorting.field !== '+date' && sorting.field !== '-date'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+date'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-date'" class="fa fa-caret-down"></i>
</a>
<a href class="text-default" ng-click="sortBy('date')">
Date
<i ng-show="sorting.field !== '+date' && sorting.field !== '-date'" class="fa fa-sort"></i>
<i ng-show="sorting.field === '+date'" class="fa fa-caret-up"></i>
<i ng-show="sorting.field === '-date'" class="fa fa-caret-down"></i>
</a>
</th>
<th style="width: 60px"></th>
</tr>
Expand Down Expand Up @@ -112,7 +112,7 @@
<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>{{event.date | shortDate}}</td>
<td>
<a class="btn btn-xs btn-icon btn-clear" href ng-click="previewEvent(event)" uib-tooltip="Preview">
Expand All @@ -125,14 +125,16 @@
<div class="case-tags flexwrap">
<span class="mr-xxxs text-muted"><i class="fa fa-tags"></i></span>
<strong class="text-muted mr-xxxs" ng-if="!event.tags || event.tags.length === 0">None</strong>
<span ng-repeat="tag in event.tags track by $index" class="label label-primary mb-xxxs mr-xxxs pointer">{{tag}}</span>
<span ng-repeat="tag in event.tags track by $index"
class="label label-primary mb-xxxs mr-xxxs pointer">{{tag}}</span>
</div>
</td>
<td></td>
</tr>
<tr>
<td colspan="7">
<custom-field-labels custom-fields="event.customFields"><custom-field-labels>
<custom-field-labels custom-fields="event.customFields">
<custom-field-labels>
</td>
<td></td>
</tr>
Expand Down
2 changes: 2 additions & 0 deletions thehive/app/org/thp/thehive/services/AuditSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class AuditSrv @Inject() (
graph: Graph,
authContext: AuthContext
): Try[Unit] = {
auditSrv.create(Audit(Audit.update, alert, Some(Json.obj("caseId" -> `case`._id).toString)), `case`, Some(`case`))
val detailsWithAlert = details + ("fromAlert" -> Json.obj(
"_id" -> alert._id.toString,
"type" -> alert.`type`,
Expand All @@ -299,6 +300,7 @@ class AuditSrv @Inject() (
graph: Graph,
authContext: AuthContext
): Try[Unit] = {
auditSrv.create(Audit(Audit.update, alert, Some(Json.obj("caseId" -> `case`._id).toString)), `case`, Some(`case`))
val detailsWithAlert = details + ("fromAlert" -> Json.obj(
"_id" -> alert._id.toString,
"type" -> alert.`type`,
Expand Down

0 comments on commit 907e2d6

Please sign in to comment.