Skip to content

Commit

Permalink
#609 WIP Add responder menus to taks list
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jul 11, 2018
1 parent e1aba4b commit aa77164
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
26 changes: 25 additions & 1 deletion ui/app/scripts/controllers/case/CaseTasksCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.controller('CaseTaskDeleteCtrl', CaseTaskDeleteCtrl)
.controller('CaseTasksCtrl', CaseTasksCtrl);

function CaseTasksCtrl($scope, $state, $stateParams, $q, $uibModal, CaseTabsSrv, PSearchSrv, CaseTaskSrv, UserInfoSrv, NotificationSrv) {
function CaseTasksCtrl($scope, $state, $stateParams, $q, $uibModal, CaseTabsSrv, PSearchSrv, CaseTaskSrv, UserInfoSrv, NotificationSrv, CortexSrv) {

CaseTabsSrv.activateTab($state.current.data.tab);

Expand All @@ -15,6 +15,7 @@
$scope.newTask = {
status: 'Waiting'
};
$scope.taskResponders = null;

$scope.tasks = PSearchSrv($scope.caseId, 'case_task', {
scope: $scope,
Expand Down Expand Up @@ -132,6 +133,29 @@
return defer.promise;
};

$scope.getTaskResponders = function(taskId, force) {
if(!force && $scope.taskResponders !== null) {
return;
}

CortexSrv.getResponders('case_task', taskId)
.then(function(responders) {
$scope.taskResponders = responders;
})
.catch(function(err) {
NotificationSrv.error('taskList', response.data, response.status);
})
};

$scope.runResponder = function(responderId, task) {
CortexSrv.runResponder(responderId, 'case_task', _.pick(task, 'id'))
.then(function(response) {
console.log(response);
})
.catch(function(err) {
console.log(err);
});
};
}

function CaseTaskDeleteCtrl($uibModalInstance, title) {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/scripts/controllers/case/CaseTasksItemCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
return;
}

CortexSrv.getResponders('case_task', $scope.caseId)
CortexSrv.getResponders('case_task', $scope.task.id)
.then(function(responders) {
$scope.taskResponders = responders;
})
Expand Down
2 changes: 1 addition & 1 deletion ui/app/views/directives/flow/case.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
<div ng-switch-when="tags">
{{k}}:
<span ng-repeat="tag in v">
<span ng-repeat="tag in v track by $index">
<span class="label label-primary">{{tag}}</span>
</span>
<span ng-if="v.length === 0">
Expand Down
24 changes: 23 additions & 1 deletion ui/app/views/partials/case/case.tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<th>Task</th>
<th style="width: 240px">Date</th>
<th style="width: 200px">Assignee</th>
<th style="width: 200px" class="text-right">Actions</th>
<th style="width: 250px" class="text-right">Actions</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -102,10 +102,32 @@
<i class="fa fa-play"></i>
Start
</span>

<span class="ml-xs" uib-dropdown ng-if="appConfig.connectors.cortex.enabled">
<a href class="text-primary noline nowrap" ng-click="getTaskResponders(task.id)" uib-dropdown-toggle>
<i class="text-primary fa fa-cog"></i>
<!-- Responders
<i class="text-primary fa fa-angle-down"></i> -->
</a>
<ul class="dropdown-menu align-right" uib-dropdown-menu>
<li ng-if="taskResponders && taskResponders.length === 0">
<a href ng-click="getTaskResponders(task.id, true)">
<strong><i class="fa fa-refresh mr-xxs"></i> No responders available</strong>
</a>
</li>
<li ng-repeat="responder in taskResponders">
<a href ng-click="runResponder(responder.id)">
<strong>{{responder.name}}</strong>
<br>
<small>{{responder.description}}</small></a>
</li>
</ul>
</span>
</td>
</tr>
</tbody>
</table>
<psearch control="tasks"></psearch>
<pre>{{taskResponders | json}}</pre>
</div>
</div>

0 comments on commit aa77164

Please sign in to comment.