mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
Merge pull request #3453 from marshmalien/feat-toolbar-sort-application-tokens-list
Add sort to application tokens list Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
@@ -41,7 +41,9 @@ function ApplicationsStrings (BaseString) {
|
|||||||
|
|
||||||
ns.sort = {
|
ns.sort = {
|
||||||
NAME_ASCENDING: t.s('Name (Ascending)'),
|
NAME_ASCENDING: t.s('Name (Ascending)'),
|
||||||
NAME_DESCENDING: t.s('Name (Descending)')
|
NAME_DESCENDING: t.s('Name (Descending)'),
|
||||||
|
USERNAME_ASCENDING: t.s('Username (Ascending)'),
|
||||||
|
USERNAME_DESCENDING: t.s('Username (Descending)')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,14 @@ function ApplicationsRun ($stateExtender, strings) {
|
|||||||
controllerAs: 'vm'
|
controllerAs: 'vm'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
params: {
|
||||||
|
application_search: {
|
||||||
|
value: {
|
||||||
|
order_by: 'name',
|
||||||
|
page_size: 10
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
searchPrefix: 'application',
|
searchPrefix: 'application',
|
||||||
resolve: {
|
resolve: {
|
||||||
resolvedModels: [
|
resolvedModels: [
|
||||||
@@ -291,8 +299,8 @@ function ApplicationsRun ($stateExtender, strings) {
|
|||||||
params: {
|
params: {
|
||||||
user_search: {
|
user_search: {
|
||||||
value: {
|
value: {
|
||||||
order_by: 'user',
|
order_by: 'user__username',
|
||||||
page_size: 20
|
page_size: 10
|
||||||
},
|
},
|
||||||
dynamic: true
|
dynamic: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,32 +7,71 @@ function ListApplicationsUsersController (
|
|||||||
$filter,
|
$filter,
|
||||||
$scope,
|
$scope,
|
||||||
Dataset,
|
Dataset,
|
||||||
resolvedModels,
|
|
||||||
strings,
|
strings,
|
||||||
$stateParams,
|
$state,
|
||||||
GetBasePath
|
GetBasePath
|
||||||
) {
|
) {
|
||||||
const vm = this || {};
|
const vm = this || {};
|
||||||
// const application = resolvedModels;
|
|
||||||
|
|
||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
|
|
||||||
// smart-search
|
// smart-search
|
||||||
const name = 'users';
|
const name = 'users';
|
||||||
const iterator = 'user';
|
const iterator = 'user';
|
||||||
const key = 'user_dataset';
|
let paginateQuerySet = {};
|
||||||
|
|
||||||
$scope.list = { iterator, name, basePath: 'applications' };
|
vm.user_dataset = Dataset.data;
|
||||||
$scope.collection = { iterator };
|
vm.users = Dataset.data.results;
|
||||||
$scope.tokenBasePath = `${GetBasePath('applications')}${$stateParams.application_id}/tokens`;
|
vm.list = { iterator, name, basePath: 'applications' };
|
||||||
$scope[key] = Dataset.data;
|
vm.basePath = `${GetBasePath('applications')}${$state.params.application_id}/tokens`;
|
||||||
vm.usersCount = Dataset.data.count;
|
|
||||||
$scope[name] = Dataset.data.results;
|
$scope.$on('updateDataset', (e, dataset, queryset) => {
|
||||||
$scope.$on('updateDataset', (e, dataset) => {
|
vm.user_dataset = dataset;
|
||||||
$scope[key] = dataset;
|
vm.users = dataset.results;
|
||||||
$scope[name] = dataset.results;
|
paginateQuerySet = queryset;
|
||||||
vm.usersCount = dataset.count;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.$watchCollection('$state.params', () => {
|
||||||
|
setToolbarSort();
|
||||||
|
});
|
||||||
|
|
||||||
|
const toolbarSortDefault = {
|
||||||
|
label: `${strings.get('sort.USERNAME_ASCENDING')}`,
|
||||||
|
value: 'user__username'
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.toolbarSortOptions = [
|
||||||
|
toolbarSortDefault,
|
||||||
|
{
|
||||||
|
label: `${strings.get('sort.USERNAME_DESCENDING')}`,
|
||||||
|
value: '-user__username'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
function setToolbarSort () {
|
||||||
|
const orderByValue = _.get($state.params, 'user_search.order_by');
|
||||||
|
const sortValue = _.find(vm.toolbarSortOptions, (option) => option.value === orderByValue);
|
||||||
|
if (sortValue) {
|
||||||
|
vm.toolbarSortValue = sortValue;
|
||||||
|
} else {
|
||||||
|
vm.toolbarSortValue = toolbarSortDefault;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.onToolbarSort = (sort) => {
|
||||||
|
vm.toolbarSortValue = sort;
|
||||||
|
const queryParams = Object.assign(
|
||||||
|
{},
|
||||||
|
$state.params.user_search,
|
||||||
|
paginateQuerySet,
|
||||||
|
{ order_by: sort.value }
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update URL with params
|
||||||
|
$state.go('.', {
|
||||||
|
user_search: queryParams
|
||||||
|
}, { notify: false, location: 'replace' });
|
||||||
|
};
|
||||||
|
|
||||||
vm.getLastUsed = user => {
|
vm.getLastUsed = user => {
|
||||||
const lastUsed = _.get(user, 'last_used');
|
const lastUsed = _.get(user, 'last_used');
|
||||||
|
|
||||||
@@ -56,9 +95,8 @@ ListApplicationsUsersController.$inject = [
|
|||||||
'$filter',
|
'$filter',
|
||||||
'$scope',
|
'$scope',
|
||||||
'Dataset',
|
'Dataset',
|
||||||
'resolvedModels',
|
|
||||||
'ApplicationsStrings',
|
'ApplicationsStrings',
|
||||||
'$stateParams',
|
'$state',
|
||||||
'GetBasePath'
|
'GetBasePath'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,23 @@
|
|||||||
<smart-search
|
<smart-search
|
||||||
class="at-List-search"
|
class="at-List-search"
|
||||||
django-model="users"
|
django-model="users"
|
||||||
base-path="{{ tokenBasePath }}"
|
base-path="{{ vm.basePath }}"
|
||||||
iterator="user"
|
iterator="user"
|
||||||
list="list"
|
list="vm.list"
|
||||||
dataset="user_dataset"
|
dataset="vm.user_dataset"
|
||||||
collection="collection"
|
collection="vm.users"
|
||||||
search-tags="searchTags">
|
search-tags="searchTags">
|
||||||
</smart-search>
|
</smart-search>
|
||||||
</div>
|
</div>
|
||||||
|
<at-list-toolbar
|
||||||
<at-list results="users">
|
ng-if="vm.users.length > 0"
|
||||||
<at-row ng-repeat="user in users">
|
sort-only="true"
|
||||||
|
sort-value="vm.toolbarSortValue"
|
||||||
|
sort-options="vm.toolbarSortOptions"
|
||||||
|
on-sort="vm.onToolbarSort">
|
||||||
|
</at-list-toolbar>
|
||||||
|
<at-list results="vm.users">
|
||||||
|
<at-row ng-repeat="user in vm.users">
|
||||||
<div class="at-Row-items">
|
<div class="at-Row-items">
|
||||||
<at-row-item
|
<at-row-item
|
||||||
header-value="{{ user.summary_fields.user.username | sanitize }}"
|
header-value="{{ user.summary_fields.user.username | sanitize }}"
|
||||||
@@ -29,3 +35,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</at-row>
|
</at-row>
|
||||||
</at-list>
|
</at-list>
|
||||||
|
<paginate
|
||||||
|
collection="vm.users"
|
||||||
|
dataset="vm.user_dataset"
|
||||||
|
iterator="user"
|
||||||
|
base-path="{{ vm.basePath }}">
|
||||||
|
</paginate>
|
||||||
|
|||||||
Reference in New Issue
Block a user