diff --git a/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js b/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js index 72f48ebcda..e928fdb806 100644 --- a/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js @@ -1,7 +1,7 @@ (function () { 'use strict'; angular.module('theHiveControllers').controller('CaseTasksItemCtrl', - function ($scope, $rootScope, $state, $stateParams, $timeout, $uibModal, SecuritySrv, ModalSrv, CaseSrv, AuthenticationSrv, OrganisationSrv, CaseTabsSrv, CaseTaskSrv, PSearchSrv, TaskLogSrv, NotificationSrv, CortexSrv, StatSrv, task) { + function ($scope, $rootScope, $state, $stateParams, $timeout, $uibModal, PaginatedQuerySrv, SecuritySrv, ModalSrv, CaseSrv, AuthenticationSrv, OrganisationSrv, CaseTabsSrv, CaseTaskSrv, PSearchSrv, TaskLogSrv, NotificationSrv, CortexSrv, StatSrv, task) { var caseId = $stateParams.caseId, taskId = $stateParams.itemId; @@ -15,8 +15,8 @@ message: '' }; $scope.sortOptions = { - '+startDate': 'Oldest first', - '-startDate': 'Newest first' + '+date': 'Oldest first', + '-date': 'Newest first' }; $scope.state = { editing: false, @@ -24,7 +24,7 @@ dropdownOpen: false, attachmentCollapsed: true, logMissing: '', - sort: '-startDate' + sort: '-date' }; $scope.markdownEditorOptions = { @@ -35,51 +35,24 @@ $scope.initScope = function () { - $scope.logs = PSearchSrv(caseId, 'case_task_log', { + $scope.logs = new PaginatedQuerySrv({ + root: caseId, + objectType: 'case_task_log', + version: 'v1', scope: $scope, - filter: { - _and: [{ - _parent: { - _type: 'case_task', - _query: { - _id: taskId - } - } - }, { - _not: { - 'status': 'Deleted' - } - }] - }, - 'sort': $scope.state.sort, - 'pageSize': 10, - onUpdate: function() { - var ids = _.pluck($scope.logs.values, 'id'); - - StatSrv.getPromise({ - objectType: 'connector/cortex/action', - field: 'objectId', - limit: 1000, - skipTotal: true, - query: { - _and: [{ - _field: 'objectType', - _value: 'case_task_log' - }, - { - _in: { - _field: 'objectId', - _values: ids - } - }] - } - }).then(function(response) { - var counts = response.data; - _.each($scope.logs.values, function(log) { - log.nbActions = counts[log.id] ? counts[log.id].count : 0; - }); - }); - } + sort: $scope.state.sort, + loadAll: false, + pageSize: 10, + operations: [ + { + '_name': 'getTask', + 'idOrName': taskId + }, + { + '_name': 'logs' + } + ], + extraData: ['actionCount'] }); var connectors = $scope.appConfig.connectors; diff --git a/frontend/app/scripts/directives/logEntry.js b/frontend/app/scripts/directives/logEntry.js index c59d08eb22..570370d187 100644 --- a/frontend/app/scripts/directives/logEntry.js +++ b/frontend/app/scripts/directives/logEntry.js @@ -77,7 +77,7 @@ scope.confirmDropLog = function() { TaskLogSrv.delete({ - logId: scope.log.id + logId: scope.log._id }).$promise.then(function() { scope.deleteModal.dismiss(); }); @@ -89,7 +89,7 @@ scope.updateLog = function() { return TaskLogSrv.update({ - logId: scope.log.id + logId: scope.log._id }, {message: scope.log.message}, function() {}, function(response) { NotificationSrv.error('CaseTaskLog', response.data, response.status); }); diff --git a/frontend/app/views/directives/log-entry.html b/frontend/app/views/directives/log-entry.html index a65f1de562..7c4852d7b4 100644 --- a/frontend/app/views/directives/log-entry.html +++ b/frontend/app/views/directives/log-entry.html @@ -65,10 +65,10 @@ -
+