Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add My cases to the navbar #875

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ui/app/scripts/controllers/MainPageCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@
sort: '-startDate',
nparent: 1
});
} else if ($stateParams.viewId === 'mycases') {
$rootScope.title = 'My cases';
$scope.view.data = 'mycases';
$scope.list = PSearchSrv(undefined, 'case', {
scope: $scope,
baseFilter: {
'_and': [{
'_in': {
'_field': 'status',
'_values': ['Open']
}
}, {
'owner': $scope.currentUser.id
}]
},
sort: ['-flag', '-startDate'],
nparent: 1
});
}

// init values
Expand Down
21 changes: 21 additions & 0 deletions ui/app/scripts/controllers/RootCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ angular.module('theHiveControllers').controller('RootCtrl',
field: 'status'
});

$scope.myCases = StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {
'_and': [
{
'_in': {
'_field': 'status',
'_values': ['Open']
}
},
{
'owner': $scope.currentUser.id
}
]
},
result: {},
objectType: 'case',
field: 'status'
});

$scope.waitingTasks = StreamStatSrv({
scope: $scope,
rootId: 'any',
Expand Down
5 changes: 5 additions & 0 deletions ui/app/views/app.main.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div ng-Class="{ 'col-md-9': appLayout.showFlow, 'col-md-12': !appLayout.showFlow}">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title" ng-if="view.data == 'mycases'">My Cases ({{list.total}})</h3>
<h3 class="box-title" ng-if="view.data == 'mytasks'">My tasks ({{list.total}})</h3>
<h3 class="box-title" ng-if="view.data == 'waitingtasks'">Waiting tasks ({{list.total}})</h3>

Expand Down Expand Up @@ -31,6 +32,10 @@ <h3 class="box-title" ng-if="view.data == 'waitingtasks'">Waiting tasks ({{list.
<div ng-include="'views/partials/index-waitingtasks.html'"></div>
</div>

<div class="main-fadein" ng-switch-when="mycases">
<div ng-include="'views/partials/index-mycases.html'"></div>
</div>

<div class="main-fadein" ng-switch-default>
<div ng-include="'views/partials/index-mytasks.html'"></div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions ui/app/views/components/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
</li>
</ul>
</li> -->
<li ui-sref-active="active">
<a ui-sref="app.main({viewId: 'mycases'})">My cases
<span class="badge alert-danger">{{myCases.count}}</span>
</a>
</li>
<li ui-sref-active="active">
<a ui-sref="app.main({viewId: 'mytasks'})">My tasks
<span class="badge alert-danger">{{myCurrentTasks.count}}</span>
Expand Down
40 changes: 40 additions & 0 deletions ui/app/views/partials/index-mycases.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<psearch control="list"></psearch>

<table class="table table-striped table-hover">
<thead>
<tr>
<th class="text-center" style="width: 60px;">Severity</th>
<th>Case</th>
<th width="250px;">Date</th>
</tr>
</thead>

<tbody>
<tr class="pointer task-row"
ng-repeat="value in list.values"
ng-class="{'warning': (value.flag == true)}"
ng-click="openEntity(value)">
<td class="text-center">
<severity active="false" value="value.severity"></severity>
</td>
<td>
<div>
<span ng-if="value.flag"><i class="text-primary glyphicon glyphicon-flag"></i></span>
<span ng-bind="value.title"></span>
</div>
<div ng-show="value.status === 'Open'" class="text-warning">
Opened <em am-time-ago="value.startDate"></em>
</div>
<div>
<small><entity-link value="value.case"></entity-link></small>
</div>
</td>
<td>
{{value.startDate | showDate}}
</td>
</tr>
</tbody>

</table>

<psearch control="list"></psearch>