Skip to content

Commit

Permalink
#1257 Display case duration in case list
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Apr 30, 2020
1 parent 4011d0f commit 19d70d6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions frontend/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
<script src="scripts/directives/user.js"></script>
<script src="scripts/directives/userinfo.js"></script>
<script src="scripts/directives/utils/autofocus.js"></script>
<script src="scripts/filters/duration.js"></script>
<script src="scripts/filters/ellipsis.js"></script>
<script src="scripts/filters/fang.js"></script>
<script src="scripts/filters/filesize.js"></script>
Expand Down
21 changes: 21 additions & 0 deletions frontend/app/scripts/filters/duration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(function() {
'use strict';

angular.module('theHiveFilters').filter('duration', function () {
return function (start, end) {
if (!start) {
return '';
}

if(end) {
// Compute duration between end and start
var duration = moment(end).diff(moment(start));

return moment.duration(duration, 'milliseconds').humanize();
} else {
// Compute duration till now
return moment(start).fromNow(true);
}
};
});
})();
12 changes: 9 additions & 3 deletions frontend/app/views/partials/case/case.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ <h3 class="box-title">List of cases ({{$vm.list.total || 0}} of {{$vm.caseStats.
<user user-id="currentCase.owner" icon-only="true" icon-size="m"></user>
</td>
<td>
<a href ng-click="$vm.addFilterValue('startDate', currentCase.startDate)">
<span uib-tooltip="{{currentCase.startDate | showDate}}" tooltip-popup-delay="500" tooltip-placement="bottom">{{currentCase.startDate | shortDate}}</span>
</a>
<div>
<a href ng-click="$vm.addFilterValue('startDate', currentCase.startDate)">
<span uib-tooltip="{{currentCase.startDate | showDate}}" tooltip-popup-delay="500" tooltip-placement="bottom">{{currentCase.startDate | shortDate}}</span>
</a>
</div>
<div>
<strong ng-if="currentCase.endDate" class="text-success"><i class="fa fa-clock-o"></i> {{currentCase.startDate | duration:currentCase.endDate}}</strong>
<strong ng-if="!currentCase.endDate" class="text-danger"><i class="fa fa-clock-o"></i> {{currentCase.startDate | duration}}</strong>
</div>
</td>
<td if-permission="manageTask" allowed="{{userPermissions}}" ng-if="appConfig.connectors.cortex.enabled">
<span class="ml-xs" uib-dropdown>
Expand Down

0 comments on commit 19d70d6

Please sign in to comment.