Skip to content

Commit

Permalink
#170 Take into account new alert status enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Apr 25, 2017
1 parent d451ed0 commit 8500b68
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 44 deletions.
1 change: 0 additions & 1 deletion ui/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@
<script src="scripts/filters/shortDate.js"></script>
<script src="scripts/filters/showDate.js"></script>
<script src="scripts/services/AfkSrv.js"></script>
<script src="scripts/services/AlertSrv.js"></script>
<script src="scripts/services/AlertingSrv.js"></script>
<script src="scripts/services/AnalyzerInfoSrv.js"></script>
<script src="scripts/services/AnalyzerSrv.js"></script>
Expand Down
8 changes: 4 additions & 4 deletions ui/app/scripts/controllers/alert/AlertListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
value: [{
text: 'New'
}, {
text: 'Update'
text: 'Updated'
}],
filter: '(status:"New" OR status:"Update")'
filter: '(status:"New" OR status:"Updated")'
}
},
filterDefs: {
Expand Down Expand Up @@ -232,8 +232,8 @@

temp = _.uniq(_.pluck(self.selection, 'status'));

self.menu.markAsRead = temp.indexOf('Ignore') === -1 && temp.indexOf('Imported') === -1;
self.menu.markAsUnread = temp.indexOf('New') === -1 && temp.indexOf('Update') === -1;
self.menu.markAsRead = temp.indexOf('Ignores') === -1 && temp.indexOf('Imported') === -1;
self.menu.markAsUnread = temp.indexOf('New') === -1 && temp.indexOf('Updated') === -1;

};

Expand Down
25 changes: 0 additions & 25 deletions ui/app/scripts/services/AlertSrv.js

This file was deleted.

15 changes: 6 additions & 9 deletions ui/app/scripts/services/AlertingSrv.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
'use strict';
angular.module('theHiveServices')
.factory('AlertingSrv', function($q, $http, $rootScope, StatSrv, StreamSrv, PSearchSrv) {
.factory('AlertingSrv', function($q, $http, $rootScope, StatSrv, StreamSrv, PSearchSrv, AlertStatus) {

var baseUrl = './api/alert';

Expand All @@ -27,11 +27,11 @@
},

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

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

markAsRead: function(alertId) {
Expand Down Expand Up @@ -98,12 +98,9 @@
statuses: function(query) {
var defer = $q.defer();

$q.resolve([
{text: 'New'},
{text: 'Update'},
{text: 'Imported'},
{text: 'Ignore'}
]).then(function(response) {
$q.resolve(_.map(AlertStatus.values, function(status) {
return { text: status};
})).then(function(response) {
var statuses = [];

statuses = _.filter(response, function(status) {
Expand Down
3 changes: 3 additions & 0 deletions ui/app/scripts/services/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
},
values: ['Unknown', 'Low', 'Medium', 'High']
})
.value('AlertStatus', {
values: ['New', 'Updated', 'Ignored', 'Imported']
})
.value('Tlp', {
keys: {
Red: 3,
Expand Down
4 changes: 2 additions & 2 deletions ui/app/scripts/services/NotificationSrv.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function() {
'use strict';
angular.module('theHiveServices')
.factory('NotificationSrv', function($state, Notification) {
.factory('NotificationSrv', function($state, HtmlSanitizer, Notification) {

function log(message, type) {
Notification[type || 'error'](message);
Notification[type || 'error'](HtmlSanitizer.sanitize(message));
}

return {
Expand Down
4 changes: 2 additions & 2 deletions ui/app/views/partials/alert/event.dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h3 class="modal-title">Alert Preview</h3>
<div class="alert-details">
<h4 class="vpad10 text-primary">
Basic details
<span class="label label-default pull-right" ng-class="{'label-danger': dialog.event.status==='New', 'label-warning': dialog.event.status === 'Update'}">{{dialog.event.status}}</span>
<span class="label label-default pull-right" ng-class="{'label-danger': dialog.event.status==='New', 'label-warning': dialog.event.status === 'Updated'}">{{dialog.event.status}}</span>
</h4>
<dl class="dl-horizontal clear">
<dt>Reference</dt>
Expand Down Expand Up @@ -86,7 +86,7 @@ <h4 class="vpad10 text-primary">
<button class="btn btn-primary pull-right" type="button" ng-disabled="dialog.loading" ng-click="dialog.import()">Import event</button>
<button class="btn btn-default pull-right" type="button"
ng-if="dialog.canMarkAsRead(dialog.event)"
ng-disabled="dialog.loading"
ng-disabled="dialog.loading"
ng-click="dialog.markAsRead(dialog.event)">
<i class="fa fa-envelope"></i> Mark as read
</button>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/views/partials/alert/list/toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<a ng-click="$vm.filterByStatus('New')">New events ({{alertEvents.New.count || 0}})</a>
</li>
<li>
<a ng-click="$vm.filterByStatus('Update')">Updated events({{alertEvents.Update.count || 0}})</a>
<a ng-click="$vm.filterByStatus('Updated')">Updated events({{alertEvents.Updated.count || 0}})</a>
</li>
</ul>
</div>
Expand Down

0 comments on commit 8500b68

Please sign in to comment.