Skip to content

Commit

Permalink
#1410 Use StreamQuerySrv for case alert stats
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jul 22, 2020
1 parent 56f9be7 commit 6f5b879
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
29 changes: 25 additions & 4 deletions frontend/app/scripts/controllers/case/CaseMainCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
}
});

// Stats for case tasks counter
StreamQuerySrv('v1', [
{_name: 'getCase', idOrName: caseId},
{_name: 'tasks'},
Expand All @@ -105,6 +106,7 @@
}
});

// Stats for case observables counter
StreamQuerySrv('v1', [
{_name: 'getCase', idOrName: caseId},
{_name: 'observables'},
Expand All @@ -123,15 +125,34 @@
}
});

$scope.alerts = StreamStatSrv({
// Stats for case observables counter
StreamQuerySrv('v1', [
{_name: 'getCase', idOrName: caseId},
{_name: 'alerts'},
{_name: 'count'}
], {
scope: $scope,
rootId: caseId,
query: { 'case': caseId },
result: {},
objectType: 'alert',
field: 'type'
query: {
params: {
name: 'alert-stats-' + caseId
}
},
onUpdate: function(updates) {
$scope.alertCount = updates;
}
});

// $scope.alerts = StreamStatSrv({
// scope: $scope,
// rootId: caseId,
// query: { 'case': caseId },
// result: {},
// objectType: 'alert',
// field: 'type'
// });

$scope.$on('tasks:task-removed', function(event, task) {
CaseTabsSrv.removeTab('task-' + task._id);
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/views/partials/case/case.panelinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ <h3 class="box-title text-primary">
</strong>
</span>

<span class="ml-xxs text-danger" ng-show="alerts.count > 0"uib-tooltip="Related to">
<span class="ml-xxs text-danger" ng-show="alertCount > 0"uib-tooltip="Related to">
<i class="glyphicon glyphicon-link"></i>
<strong>
<a class="text-danger" href ui-sref="app.case.alerts({caseId:caze._id})">
<ng-pluralize count="alerts.count" when="{'one': '1 alert', 'other': '{} alerts'}"></ng-pluralize>
<ng-pluralize count="alertCount" when="{'one': '1 alert', 'other': '{} alerts'}"></ng-pluralize>
</a>
</strong>
</span>
Expand Down

0 comments on commit 6f5b879

Please sign in to comment.