|
@ -4,11 +4,19 @@ import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; |
|
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
|
|
|
import { DEFAULT_PAGE_SIZE } from '@ghostfolio/common/config'; |
|
|
import { getDateFormatString, getEmojiFlag } from '@ghostfolio/common/helper'; |
|
|
import { getDateFormatString, getEmojiFlag } from '@ghostfolio/common/helper'; |
|
|
import { AdminUsers, InfoItem, User } from '@ghostfolio/common/interfaces'; |
|
|
import { AdminUsers, InfoItem, User } from '@ghostfolio/common/interfaces'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
|
|
|
|
|
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; |
|
|
import { |
|
|
|
|
|
ChangeDetectorRef, |
|
|
|
|
|
Component, |
|
|
|
|
|
OnDestroy, |
|
|
|
|
|
OnInit, |
|
|
|
|
|
ViewChild |
|
|
|
|
|
} from '@angular/core'; |
|
|
|
|
|
import { MatPaginator, PageEvent } from '@angular/material/paginator'; |
|
|
import { MatTableDataSource } from '@angular/material/table'; |
|
|
import { MatTableDataSource } from '@angular/material/table'; |
|
|
import { |
|
|
import { |
|
|
differenceInSeconds, |
|
|
differenceInSeconds, |
|
@ -24,6 +32,8 @@ import { takeUntil } from 'rxjs/operators'; |
|
|
templateUrl: './admin-users.html' |
|
|
templateUrl: './admin-users.html' |
|
|
}) |
|
|
}) |
|
|
export class AdminUsersComponent implements OnDestroy, OnInit { |
|
|
export class AdminUsersComponent implements OnDestroy, OnInit { |
|
|
|
|
|
@ViewChild(MatPaginator) paginator: MatPaginator; |
|
|
|
|
|
|
|
|
public dataSource = new MatTableDataSource<AdminUsers['users'][0]>(); |
|
|
public dataSource = new MatTableDataSource<AdminUsers['users'][0]>(); |
|
|
public defaultDateFormat: string; |
|
|
public defaultDateFormat: string; |
|
|
public displayedColumns: string[] = []; |
|
|
public displayedColumns: string[] = []; |
|
@ -32,6 +42,8 @@ export class AdminUsersComponent implements OnDestroy, OnInit { |
|
|
public hasPermissionToImpersonateAllUsers: boolean; |
|
|
public hasPermissionToImpersonateAllUsers: boolean; |
|
|
public info: InfoItem; |
|
|
public info: InfoItem; |
|
|
public isLoading = false; |
|
|
public isLoading = false; |
|
|
|
|
|
public pageSize = DEFAULT_PAGE_SIZE; |
|
|
|
|
|
public totalItems = 0; |
|
|
public user: User; |
|
|
public user: User; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
@ -137,19 +149,33 @@ export class AdminUsersComponent implements OnDestroy, OnInit { |
|
|
window.location.reload(); |
|
|
window.location.reload(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public onChangePage(page: PageEvent) { |
|
|
|
|
|
this.fetchUsers({ |
|
|
|
|
|
pageIndex: page.pageIndex |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
public ngOnDestroy() { |
|
|
this.unsubscribeSubject.next(); |
|
|
this.unsubscribeSubject.next(); |
|
|
this.unsubscribeSubject.complete(); |
|
|
this.unsubscribeSubject.complete(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fetchUsers() { |
|
|
private fetchUsers({ pageIndex }: { pageIndex: number } = { pageIndex: 0 }) { |
|
|
this.isLoading = true; |
|
|
this.isLoading = true; |
|
|
|
|
|
|
|
|
|
|
|
if (pageIndex === 0 && this.paginator) { |
|
|
|
|
|
this.paginator.pageIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.adminService |
|
|
this.adminService |
|
|
.fetchUsers() |
|
|
.fetchUsers({ |
|
|
|
|
|
skip: pageIndex * this.pageSize, |
|
|
|
|
|
take: this.pageSize |
|
|
|
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.subscribe(({ users }) => { |
|
|
.subscribe(({ count, users }) => { |
|
|
this.dataSource = new MatTableDataSource(users); |
|
|
this.dataSource = new MatTableDataSource(users); |
|
|
|
|
|
this.totalItems = count; |
|
|
|
|
|
|
|
|
this.isLoading = false; |
|
|
this.isLoading = false; |
|
|
|
|
|
|
|
|