mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-28 01:52:16 +00:00
* resourceowner header, i18n * password policy validators, roles required field * use angular pattern instead of custom validator * user detail fixes, mfa qr code, add org * use mgmt for mfa list * fetch owned projects * search project * seperate owned from granted projects * lint * fix granted project grid * refactor project detail * disable zitadel apps * refactor project contributors * changed i18n * hide meta nav * mobile meta layout * refactor contributor name * refactor org contributors * org i18n, org member detail view * fix uninitialized phone, email * fix: create role, add contributors to granted pjs * initialize address * contributor 18n * add tab module
101 lines
3.8 KiB
TypeScript
101 lines
3.8 KiB
TypeScript
import { Component, Input, OnInit } from '@angular/core';
|
|
import { MatDialog } from '@angular/material/dialog';
|
|
import { Router } from '@angular/router';
|
|
import { BehaviorSubject, from, of } from 'rxjs';
|
|
import { catchError, finalize, map } from 'rxjs/operators';
|
|
import { User } from 'src/app/proto/generated/auth_pb';
|
|
import {
|
|
ProjectGrantView,
|
|
ProjectMemberSearchResponse,
|
|
ProjectMemberView,
|
|
ProjectState,
|
|
ProjectType,
|
|
ProjectView,
|
|
} from 'src/app/proto/generated/management_pb';
|
|
import { ProjectService } from 'src/app/services/project.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
import {
|
|
CreationType,
|
|
MemberCreateDialogComponent,
|
|
} from '../../../modules/add-member-dialog/member-create-dialog.component';
|
|
|
|
@Component({
|
|
selector: 'app-project-contributors',
|
|
templateUrl: './project-contributors.component.html',
|
|
styleUrls: ['./project-contributors.component.scss'],
|
|
})
|
|
export class ProjectContributorsComponent implements OnInit {
|
|
@Input() public project!: ProjectView.AsObject | ProjectGrantView.AsObject;
|
|
@Input() public projectType!: ProjectType;
|
|
|
|
@Input() public disabled: boolean = false;
|
|
|
|
public totalResult: number = 0;
|
|
public membersSubject: BehaviorSubject<ProjectMemberView.AsObject[]>
|
|
= new BehaviorSubject<ProjectMemberView.AsObject[]>([]);
|
|
public ProjectState: any = ProjectState;
|
|
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
|
|
constructor(private projectService: ProjectService,
|
|
private dialog: MatDialog,
|
|
private toast: ToastService,
|
|
private router: Router) { }
|
|
|
|
public ngOnInit(): void {
|
|
console.log('project grant members');
|
|
const promise: Promise<ProjectMemberSearchResponse> | undefined =
|
|
this.projectType === ProjectType.PROJECTTYPE_OWNED ?
|
|
this.projectService.SearchProjectMembers(this.project.projectId, 100, 0) :
|
|
this.projectType === ProjectType.PROJECTTYPE_GRANTED ?
|
|
this.projectService.SearchProjectGrantMembers(this.project.projectId,
|
|
this.project.projectId, 100, 0) : undefined;
|
|
if (promise) {
|
|
from(promise).pipe(
|
|
map(resp => {
|
|
this.totalResult = resp.toObject().totalResult;
|
|
return resp.toObject().resultList;
|
|
}),
|
|
catchError(() => of([])),
|
|
finalize(() => this.loadingSubject.next(false)),
|
|
).subscribe(members => {
|
|
console.log(members);
|
|
this.membersSubject.next(members);
|
|
});
|
|
}
|
|
}
|
|
|
|
public openAddMember(): void {
|
|
const dialogRef = this.dialog.open(MemberCreateDialogComponent, {
|
|
data: {
|
|
creationType: CreationType.PROJECT_OWNED,
|
|
projectId: this.project.projectId,
|
|
},
|
|
width: '400px',
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe(resp => {
|
|
if (resp) {
|
|
const users: User.AsObject[] = resp.users;
|
|
const roles: string[] = resp.roles;
|
|
|
|
if (users && users.length && roles && roles.length) {
|
|
Promise.all(users.map(user => {
|
|
return this.projectService.AddProjectMember(this.project.projectId, user.id, roles);
|
|
})).then(() => {
|
|
this.toast.showError('members added');
|
|
}).catch(error => {
|
|
this.toast.showError(error.message);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public showDetail(): void {
|
|
if (this.project?.state === ProjectState.PROJECTSTATE_ACTIVE) {
|
|
this.router.navigate(['projects', this.project.projectId, 'members']);
|
|
}
|
|
}
|
|
}
|