mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
renaming things in admin
This commit is contained in:
53
public/app/features/admin/AdminListUsersCtrl.ts
Normal file
53
public/app/features/admin/AdminListUsersCtrl.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
export default class AdminListUsersCtrl {
|
||||
users: any;
|
||||
pages = [];
|
||||
perPage = 50;
|
||||
page = 1;
|
||||
totalPages: number;
|
||||
showPaging = false;
|
||||
query: any;
|
||||
navModel: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private $scope, private backendSrv, navModelSrv) {
|
||||
this.navModel = navModelSrv.getNav('cfg', 'admin', 'global-users', 1);
|
||||
this.query = '';
|
||||
this.getUsers();
|
||||
}
|
||||
|
||||
getUsers() {
|
||||
this.backendSrv
|
||||
.get(`/api/users/search?perpage=${this.perPage}&page=${this.page}&query=${this.query}`)
|
||||
.then(result => {
|
||||
this.users = result.users;
|
||||
this.page = result.page;
|
||||
this.perPage = result.perPage;
|
||||
this.totalPages = Math.ceil(result.totalCount / result.perPage);
|
||||
this.showPaging = this.totalPages > 1;
|
||||
this.pages = [];
|
||||
|
||||
for (let i = 1; i < this.totalPages + 1; i++) {
|
||||
this.pages.push({ page: i, current: i === this.page });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
navigateToPage(page) {
|
||||
this.page = page.page;
|
||||
this.getUsers();
|
||||
}
|
||||
|
||||
deleteUser(user) {
|
||||
this.$scope.appEvent('confirm-modal', {
|
||||
title: 'Delete',
|
||||
text: 'Do you want to delete ' + user.login + '?',
|
||||
icon: 'fa-trash',
|
||||
yesText: 'Delete',
|
||||
onConfirm: () => {
|
||||
this.backendSrv.delete('/api/admin/users/' + user.id).then(() => {
|
||||
this.getUsers();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user