dashboard: Make app list columns sortable

This commit is contained in:
Johannes Zellner
2024-04-09 13:51:43 +02:00
parent 62faf616c5
commit 5460a64951
3 changed files with 33 additions and 9 deletions

View File

@@ -32,6 +32,8 @@ angular.module('Application').controller('AppsController', ['$scope', '$translat
$scope.showFilter = false;
$scope.filterActive = false;
$scope.view = 'list';
$scope.orderBy = 'location'; // or app, status, sso
$scope.orderByReverse = false;
$scope.allUsers = [];
$scope.allGroups = [];
@@ -46,8 +48,23 @@ angular.module('Application').controller('AppsController', ['$scope', '$translat
if (tr['app.states.updateAvailable']) $scope.states[3].label = tr['app.states.updateAvailable'];
});
// for sorting of the app grid items
$scope.labelOrFQDN = function (item) {
$scope.setOrderBy = function (by) {
if (by === $scope.orderBy) {
$scope.orderByReverse = !$scope.orderByReverse;
} else {
$scope.orderBy = by;
$scope.orderByReverse = false;
}
localStorage.appsOrderBy = by;
localStorage.appsOrderByReverse = $scope.orderByReverse ? 'true' : '';
};
// for sorting/grouping
$scope.orderByFilter = function (item) {
if ($scope.orderBy === 'app') return item.manifest.title || 'App Link';
if ($scope.orderBy === 'status') return item.installationState + '-' + item.runState;
if ($scope.orderBy === 'sso') return item.sso;
return item.label || item.fqdn;
};
@@ -271,6 +288,9 @@ angular.module('Application').controller('AppsController', ['$scope', '$translat
$scope.setView(localStorage.appsView);
$scope.orderBy = localStorage.appsOrderBy;
$scope.orderByReverse = !!localStorage.appsOrderByReverse;
if (!$scope.user.isAtLeastAdmin) return;
// load local settings and apply tag filter