Skip to content

Commit

Permalink
#1410 Use Alert._id field in alerts list
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jun 27, 2020
1 parent 1848f5c commit b98ef5f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
15 changes: 8 additions & 7 deletions frontend/app/scripts/controllers/alert/AlertListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
};

self.bulkMarkAsRead = function(markAsReadFlag) {
var ids = _.pluck(self.selection, 'id');
var ids = _.pluck(self.selection, '_id');
var fn = angular.noop;
var markAsRead = markAsReadFlag && this.canMarkAsRead(self.selection[0]);

Expand Down Expand Up @@ -157,7 +157,7 @@
okText: 'Yes, remove them',
flavor: 'danger'
}).then(function() {
var ids = _.pluck(self.selection, 'id');
var ids = _.pluck(self.selection, '_id');

AlertingSrv.bulkRemove(ids)
.then(function(/*response*/) {
Expand Down Expand Up @@ -233,11 +233,12 @@
self.menu.follow = temp.length === 1 && temp[0] === false;


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

self.menu.markAsRead = temp.indexOf('Ignored') === -1 && temp.indexOf('Imported') === -1;
self.menu.markAsUnread = temp.indexOf('New') === -1 && temp.indexOf('Updated') === -1;
self.menu.markAsRead = temp.length === 1 && temp[0] === false;
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;

Expand Down Expand Up @@ -276,7 +277,7 @@
};

self.createNewCase = function() {
var alertIds = _.pluck(self.selection, 'id');
var alertIds = _.pluck(self.selection, '_id');

CaseTemplateSrv.list()
.then(function(templates) {
Expand Down Expand Up @@ -364,7 +365,7 @@
});

caseModal.result.then(function(selectedCase) {
return AlertingSrv.bulkMergeInto(_.pluck(self.selection, 'id'), selectedCase.id);
return AlertingSrv.bulkMergeInto(_.pluck(self.selection, '_id'), selectedCase.id);
})
.then(function(response) {
$rootScope.$broadcast('alert:event-imported');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@
if (angular.isFunction(self.onUpdate)) {
self.onUpdate(updates);
}
}
// TODO nadouani: handle the total differently
//self.total = data.length;
}
});

// get the total if not cached
Expand Down
7 changes: 7 additions & 0 deletions frontend/app/views/partials/alert/list/toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@
</button>
<ul class="dropdown-menu" uib-dropdown-menu>
<li>
<!-- TODO nadouani: fix this filter -->
<a ng-click="$vm.filterByNewAndUpdated()">New & Updated events ({{(alertEvents.Updated.count || 0) + (alertEvents.New.count || 0)}})</a>
</li>
<li>
<!-- TODO nadouani: fix this filter -->
<a ng-click="$vm.filterByNewAndUpdated()">New & Updated events ({{(alertEvents.Updated.count || 0) + (alertEvents.New.count || 0)}})</a>
</li>
<li>
<!-- TODO nadouani: fix this filter -->
<a ng-click="$vm.filterByStatus('New')">New events ({{alertEvents.New.count || 0}})</a>
</li>
<li>
<!-- TODO nadouani: fix this filter -->
<a ng-click="$vm.filterByStatus('Updated')">Updated events({{alertEvents.Updated.count || 0}})</a>
</li>

Expand Down

0 comments on commit b98ef5f

Please sign in to comment.