2020-05-13 14:41:43 +02:00
|
|
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
|
|
import { Component, EventEmitter, OnDestroy, Output } from '@angular/core';
|
|
|
|
import { PageEvent } from '@angular/material/paginator';
|
|
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
|
|
|
|
import { User, UserSearchResponse } from 'src/app/proto/generated/management_pb';
|
|
|
|
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-user-list',
|
|
|
|
templateUrl: './user-list.component.html',
|
|
|
|
styleUrls: ['./user-list.component.scss'],
|
|
|
|
})
|
|
|
|
export class UserListComponent implements OnDestroy {
|
|
|
|
public dataSource: MatTableDataSource<User.AsObject> = new MatTableDataSource<User.AsObject>();
|
|
|
|
public userResult!: UserSearchResponse.AsObject;
|
|
|
|
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
|
|
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
|
|
|
public displayedColumns: string[] = ['select', 'firstname', 'lastname', 'username', 'email', 'state'];
|
|
|
|
public selection: SelectionModel<User.AsObject> = new SelectionModel<User.AsObject>(true, []);
|
|
|
|
@Output() public changedSelection: EventEmitter<Array<User.AsObject>> = new EventEmitter();
|
|
|
|
|
|
|
|
private subscription?: Subscription;
|
|
|
|
|
|
|
|
constructor(public translate: TranslateService, private route: ActivatedRoute, private userService: MgmtUserService,
|
|
|
|
private toast: ToastService) {
|
|
|
|
this.subscription = this.route.params.subscribe(() => this.getData(10, 0));
|
|
|
|
|
|
|
|
this.selection.changed.subscribe(() => {
|
|
|
|
this.changedSelection.emit(this.selection.selected);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public isAllSelected(): boolean {
|
|
|
|
const numSelected = this.selection.selected.length;
|
|
|
|
const numRows = this.dataSource.data.length;
|
|
|
|
return numSelected === numRows;
|
|
|
|
}
|
|
|
|
|
|
|
|
public masterToggle(): void {
|
|
|
|
this.isAllSelected() ?
|
|
|
|
this.selection.clear() :
|
|
|
|
this.dataSource.data.forEach(row => this.selection.select(row));
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy(): void {
|
|
|
|
this.subscription?.unsubscribe();
|
|
|
|
}
|
|
|
|
|
|
|
|
public changePage(event: PageEvent): void {
|
fix(console): cleanup structure, role guard, paginated requests, cleanup policies, toast i18n, view timestamp, preloading strategy, maennchenfindings, fix passwordchange (#483)
* routes, move grid to list comopnent
* rename app list component, move to project sub
* add owned-project-detail child module
* seperate pipes
* set password validators only if needed
* create org initialize without pwd
* no caps
* self xss message
* fix user table
* fix project member paginator
* fix project members pagination, user grant pag
* move project grants, fix imports
* fix owned project detail imports
* use pipe and directives
* ng content bindings, rem custom schemas
* i18n, fix error toast parameter
* toast i18n
* side background
* fix: sequence, add timestamp
* audit
* fix metanav background
* org domain label
* cleanup policy component
* shorten user grant roles, mk cols visible as bind
* move user components, show otp only if available
* preload modules
* fix password change
* fix org create buttons
* class css
2020-07-16 15:13:36 +02:00
|
|
|
this.getData(event.pageSize, event.pageIndex * event.pageSize);
|
2020-05-13 14:41:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public deactivateSelectedUsers(): void {
|
|
|
|
Promise.all(this.selection.selected.map(value => {
|
|
|
|
return this.userService.DeactivateUser(value.id);
|
|
|
|
})).then(() => {
|
fix(console): cleanup structure, role guard, paginated requests, cleanup policies, toast i18n, view timestamp, preloading strategy, maennchenfindings, fix passwordchange (#483)
* routes, move grid to list comopnent
* rename app list component, move to project sub
* add owned-project-detail child module
* seperate pipes
* set password validators only if needed
* create org initialize without pwd
* no caps
* self xss message
* fix user table
* fix project member paginator
* fix project members pagination, user grant pag
* move project grants, fix imports
* fix owned project detail imports
* use pipe and directives
* ng content bindings, rem custom schemas
* i18n, fix error toast parameter
* toast i18n
* side background
* fix: sequence, add timestamp
* audit
* fix metanav background
* org domain label
* cleanup policy component
* shorten user grant roles, mk cols visible as bind
* move user components, show otp only if available
* preload modules
* fix password change
* fix org create buttons
* class css
2020-07-16 15:13:36 +02:00
|
|
|
this.toast.showInfo('USER.TOAST.SELECTEDDEACTIVATED', true);
|
2020-05-13 14:41:43 +02:00
|
|
|
this.getData(10, 0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public reactivateSelectedUsers(): void {
|
|
|
|
Promise.all(this.selection.selected.map(value => {
|
|
|
|
return this.userService.ReactivateUser(value.id);
|
|
|
|
})).then(() => {
|
fix(console): cleanup structure, role guard, paginated requests, cleanup policies, toast i18n, view timestamp, preloading strategy, maennchenfindings, fix passwordchange (#483)
* routes, move grid to list comopnent
* rename app list component, move to project sub
* add owned-project-detail child module
* seperate pipes
* set password validators only if needed
* create org initialize without pwd
* no caps
* self xss message
* fix user table
* fix project member paginator
* fix project members pagination, user grant pag
* move project grants, fix imports
* fix owned project detail imports
* use pipe and directives
* ng content bindings, rem custom schemas
* i18n, fix error toast parameter
* toast i18n
* side background
* fix: sequence, add timestamp
* audit
* fix metanav background
* org domain label
* cleanup policy component
* shorten user grant roles, mk cols visible as bind
* move user components, show otp only if available
* preload modules
* fix password change
* fix org create buttons
* class css
2020-07-16 15:13:36 +02:00
|
|
|
this.toast.showInfo('USER.TOAST.SELECTEDREACTIVATED', true);
|
2020-05-13 14:41:43 +02:00
|
|
|
this.getData(10, 0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private async getData(limit: number, offset: number): Promise<void> {
|
|
|
|
this.loadingSubject.next(true);
|
|
|
|
this.userService.SearchUsers(limit, offset).then(resp => {
|
|
|
|
this.userResult = resp.toObject();
|
|
|
|
this.dataSource.data = resp.toObject().resultList;
|
|
|
|
this.loadingSubject.next(false);
|
|
|
|
}).catch(error => {
|
2020-07-09 10:54:55 +02:00
|
|
|
this.toast.showError(error);
|
2020-05-13 14:41:43 +02:00
|
|
|
this.loadingSubject.next(false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|