Skip to content

Commit

Permalink
#1410 Use StreamQuerySrv for waitingTasks and myTasks menues
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jul 22, 2020
1 parent 3c0ebae commit 8ffb94b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
3 changes: 2 additions & 1 deletion frontend/app/scripts/controllers/MainPageCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
filter: self.filtering.buildQuery(),
baseFilter: self.defaultFilter,
operations: self.queryOperations,
extraData: ['case']
extraData: ['case'],
name: $stateParams.viewId
});
};

Expand Down
46 changes: 25 additions & 21 deletions frontend/app/scripts/controllers/RootCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Controller for main page
*/
angular.module('theHiveControllers').controller('RootCtrl',
function($scope, $rootScope, $timeout, $uibModal, $location, $state, AuthenticationSrv, AlertingSrv, StreamSrv, StreamStatSrv, CaseSrv, CaseTemplateSrv, CustomFieldsSrv, NotificationSrv, AppLayoutSrv, VersionSrv, currentUser, appConfig) {
function($scope, $rootScope, $timeout, $uibModal, $location, $state, AuthenticationSrv, AlertingSrv, StreamSrv, StreamQuerySrv, CaseSrv, CaseTemplateSrv, CustomFieldsSrv, NotificationSrv, AppLayoutSrv, VersionSrv, currentUser, appConfig) {
'use strict';

if(currentUser === 520) {
Expand Down Expand Up @@ -54,36 +54,40 @@ angular.module('theHiveControllers').controller('RootCtrl',
$scope.templates = templates;
});

$scope.myCurrentTasks = StreamStatSrv({
StreamQuerySrv('v1', [
{_name: 'currentUser'},
{_name: 'tasks'},
{_name: 'filter', _ne: {_field: 'status', _value: 'Completed'}},
{_name: 'count'}
], {
scope: $scope,
rootId: 'any',
objectType: 'case_task',
query: {
'_and': [
{
'_in': {
'_field': 'status',
'_values': ['Waiting', 'InProgress']
}
},
{
'owner': $scope.currentUser.login
}
]
params: {
name: 'my-tasks.stats'
}
},
result: {},
objectType: 'case_task',
field: 'status'
onUpdate: function(updates) {
$scope.myCurrentTasksCount = updates;
}
});

$scope.waitingTasks = StreamStatSrv({
StreamQuerySrv('v1', [
{_name: 'waitingTask'},
{_name: 'count'}
], {
scope: $scope,
rootId: 'any',
objectType: 'case_task',
query: {
'status': 'Waiting'
params: {
name: 'waiting-tasks.stats'
}
},
result: {},
objectType: 'case_task',
field: 'status'
onUpdate: function(updates) {
$scope.waitingTasksCount = updates;
}
});

// Get Alert counts
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/views/components/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
</li>
<li ui-sref-active="active">
<a ui-sref="app.main({viewId: 'mytasks'})">My tasks
<span class="badge alert-danger">{{myCurrentTasks.count}}</span>
<span class="badge alert-danger">{{myCurrentTasksCount}}</span>
</a>
</li>
<li ui-sref-active="active">
<a ui-sref="app.main({viewId: 'waitingtasks'})">Waiting tasks
<span class="badge alert-danger">{{waitingTasks.count}}</span>
<span class="badge alert-danger">{{waitingTasksCount}}</span>
</a>
</li>
<li ui-sref-active="active">
Expand Down

0 comments on commit 8ffb94b

Please sign in to comment.