2020-05-13 14:41:43 +02:00
|
|
|
import { SelectionModel } from '@angular/cdk/collections';
|
2020-07-20 15:23:29 +02:00
|
|
|
import { Component, EventEmitter, OnDestroy, Output, ViewChild } from '@angular/core';
|
|
|
|
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
2020-05-13 14:41:43 +02:00
|
|
|
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';
|
2020-08-29 10:43:35 +02:00
|
|
|
import { ManagementService } from 'src/app/services/mgmt.service';
|
2020-05-13 14:41:43 +02:00
|
|
|
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 {
|
2020-07-20 15:23:29 +02:00
|
|
|
@ViewChild(MatPaginator) public paginator!: MatPaginator;
|
2020-05-13 14:41:43 +02:00
|
|
|
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;
|
|
|
|
|
2020-08-29 10:43:35 +02:00
|
|
|
constructor(public translate: TranslateService, private route: ActivatedRoute, private userService: ManagementService,
|
2020-05-13 14:41:43 +02:00
|
|
|
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();
|
feat(console): user memberships, generic member create dialog, fix user autocomplete emitter (#606)
* load manager mgmtservice, user service
* add org memberships
* membership component, generic member creation
* refactor member create dialog
* project autocomplete context
* create batch managers in user component
* project context wrapper
* emit on user removal, preselect user on init
* membership avatar style, service
* auth user memberships, navigate to target
* cursor fix, avatar gen
* lint
* i18n fix
* remove role translations
* membership detail page, i18n
* fix role label i18n, after view init loader
* remove projectid from grant remove
* fix iam race condition
* refresh table ts, fix no permission project search
* change membership colors
* refresh table everywhere, replace assets, routing
* fix logo header size
* lint, fix project grant removal
* timestmp for p mem, user list, grants, p list (#615)
* npm audit
* update deps, resolve vulnerability
* fix tslint config
* update lock
* load 20 changes at once
* Update console/src/assets/i18n/de.json
Co-authored-by: Florian Forster <florian@caos.ch>
* Update console/src/assets/i18n/de.json
Co-authored-by: Florian Forster <florian@caos.ch>
* Update console/src/assets/i18n/en.json
Co-authored-by: Florian Forster <florian@caos.ch>
* membership i18n
Co-authored-by: Florian Forster <florian@caos.ch>
2020-08-24 08:48:47 +02:00
|
|
|
this.dataSource.data = this.userResult.resultList;
|
2020-05-13 14:41:43 +02:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
2020-07-20 15:23:29 +02:00
|
|
|
|
|
|
|
public refreshPage(): void {
|
|
|
|
this.getData(this.paginator.pageSize, this.paginator.pageIndex * this.paginator.pageSize);
|
|
|
|
}
|
2020-05-13 14:41:43 +02:00
|
|
|
}
|