mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-19 19:48:45 +00:00
* prettier member dialog, iam indicator * changes i18n * fix timestamp conversion, timestamp to date pipe * rm create, update iam policy * add iam policy * add iam section, members component * add iam contributors * gen admin protos * iam member search * update angular * update cdk material * add module for iam members * add iam roles to member dialog * home shortcuts * project view, i18n * lint
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import { SelectionModel } from '@angular/cdk/collections';
|
|
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
|
|
import { MatPaginator } from '@angular/material/paginator';
|
|
import { MatTable } from '@angular/material/table';
|
|
import { tap } from 'rxjs/operators';
|
|
import { ProjectGrant, UserGrant } from 'src/app/proto/generated/management_pb';
|
|
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
|
|
|
import { UserGrantsDataSource } from './user-grants-datasource';
|
|
|
|
@Component({
|
|
selector: 'app-user-grants',
|
|
templateUrl: './user-grants.component.html',
|
|
styleUrls: ['./user-grants.component.scss'],
|
|
})
|
|
export class UserGrantsComponent implements OnInit, AfterViewInit {
|
|
@Input() userId: string = '';
|
|
public grants: UserGrant.AsObject[] = [];
|
|
|
|
public dataSource!: UserGrantsDataSource;
|
|
public selection: SelectionModel<UserGrant.AsObject> = new SelectionModel<UserGrant.AsObject>(true, []);
|
|
@ViewChild(MatPaginator) public paginator!: MatPaginator;
|
|
@ViewChild(MatTable) public table!: MatTable<ProjectGrant.AsObject>;
|
|
constructor(private userService: MgmtUserService) { }
|
|
|
|
public displayedColumns: string[] = ['select', 'orgId', 'projectId', 'creationDate', 'changeDate', 'roleNamesList'];
|
|
|
|
public ngOnInit(): void {
|
|
this.dataSource = new UserGrantsDataSource(this.userService);
|
|
this.dataSource.loadGrants(this.userId, 0, 25);
|
|
}
|
|
|
|
public ngAfterViewInit(): void {
|
|
this.paginator.page
|
|
.pipe(
|
|
tap(() => this.loadGrantsPage()),
|
|
)
|
|
.subscribe();
|
|
|
|
}
|
|
|
|
private loadGrantsPage(): void {
|
|
this.dataSource.loadGrants(
|
|
this.userId,
|
|
this.paginator.pageIndex,
|
|
this.paginator.pageSize,
|
|
);
|
|
}
|
|
|
|
public isAllSelected(): boolean {
|
|
const numSelected = this.selection.selected.length;
|
|
const numRows = this.dataSource.grantsSubject.value.length;
|
|
return numSelected === numRows;
|
|
}
|
|
|
|
public masterToggle(): void {
|
|
this.isAllSelected() ?
|
|
this.selection.clear() :
|
|
this.dataSource.grantsSubject.value.forEach(row => this.selection.select(row));
|
|
}
|
|
}
|