Skip to content

Commit

Permalink
#1328 Fix the sorting in observables list.
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed May 20, 2020
1 parent f566d79 commit aad8f31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 12 additions & 6 deletions frontend/app/scripts/controllers/case/CaseObservablesCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,22 @@
});
};

$scope.sortBy = function(field) {
if($scope.artifacts.sort.substr(1) !== field) {
$scope.artifacts.sort = '+' + field;
$scope.sortByField = function(field) {
var context = this.filtering.context;
var currentSort = Array.isArray(context.sort) ? context.sort[0] : context.sort;
var sort = null;

if(currentSort.substr(1) !== field) {
sort = ['+' + field];
} else {
$scope.artifacts.sort = ($scope.artifacts.sort === '+' + field) ? '-'+field : '+'+field;
sort = [(currentSort === '+' + field) ? '-'+field : '+'+field];
}

$scope.artifacts.sort = sort;
$scope.artifacts.update();
$scope.filtering.setSort(sort);
};

$scope.keys = function(obj) {
return _.keys(obj || {});
};
Expand Down Expand Up @@ -191,7 +197,7 @@
$scope.analyzersList.selected[analyzer.name] = false;
});
});
}
}
};

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ <h4>Observable List ({{artifacts.total || 0}} of {{artifactStats.count}})</h4>
<th style="width: 15px"></th>
<th style="width: 15px"></th>
<th style="width: 100px">
<a href class="text-default" ng-click="sortBy('dataType')">
<a href class="text-default" ng-click="sortByField('dataType')">
Type
<i ng-show="artifacts.sort !== '+dataType' && artifacts.sort !== '-dataType'" class="fa fa-sort"></i>
<i ng-show="artifacts.sort === '+dataType'" class="fa fa-caret-up"></i>
<i ng-show="artifacts.sort === '-dataType'" class="fa fa-caret-down"></i>
</a>
</th>
<th>
<a href class="text-default" ng-click="sortBy('data')">
<a href class="text-default" ng-click="sortByField('data')">
Value/Filename
<i ng-show="artifacts.sort !== '+data' && artifacts.sort !== '-data'" class="fa fa-sort"></i>
<i ng-show="artifacts.sort === '+data'" class="fa fa-caret-up"></i>
<i ng-show="artifacts.sort === '-data'" class="fa fa-caret-down"></i>
</a>
</th>
<th style="width: 120px">
<a href class="text-default" ng-click="sortBy('startDate')">
<a href class="text-default" ng-click="sortByField('startDate')">
Date Added
<i ng-show="artifacts.sort !== '+startDate' && artifacts.sort !== '-startDate'" class="fa fa-sort"></i>
<i ng-show="artifacts.sort === '+startDate'" class="fa fa-caret-up"></i>
Expand Down

0 comments on commit aad8f31

Please sign in to comment.