mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-06 10:58:48 +00:00
feat(console): custom domain (#1624)
* fix: custom domain * rem logs * Update console/src/assets/i18n/de.json * Update console/src/assets/i18n/en.json Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
co-authored by
Livio Amstutz
parent
8a91c239bb
commit
e64af04747
@@ -11,8 +11,12 @@
|
||||
</button>
|
||||
|
||||
<div *ngFor="let domain of domains" class="domain">
|
||||
<span *ngIf="canwrite$ | async" (click)="verifyDomain(domain)"
|
||||
<span *ngIf="(canwrite$ | async) && (['custom_domain'] | hasFeature | async); else noCustom" (click)="verifyDomain(domain)"
|
||||
class="title">{{domain.domainName}}</span>
|
||||
|
||||
<ng-template #noCustom>
|
||||
<span class="title disabled">{{domain.domainName}}</span>
|
||||
</ng-template>
|
||||
<span *ngIf="(canwrite$ | async) == false" class="title disabled">{{domain?.domainName}}</span>
|
||||
|
||||
<i matTooltip="verified" *ngIf="domain.isVerified" class="verified las la-check-circle"></i>
|
||||
@@ -26,7 +30,12 @@
|
||||
class="las la-trash"></i></button>
|
||||
</div>
|
||||
<p class="new-desc">{{'ORG.PAGES.ORGDOMAIN.VERIFICATION' | translate}}</p>
|
||||
<button [disabled]="(canwrite$ | async) == false" matTooltip="Add domain" mat-raised-button
|
||||
|
||||
<cnsl-info-section type="WARN" *ngIf="(['custom_domain'] | hasFeature | async) == false" class="custom-domain-deactivated">
|
||||
{{'ORG.PAGES.CUSTOMDOMAINFEATUREMISSING' | translate}}
|
||||
</cnsl-info-section>
|
||||
|
||||
<button [disabled]="(canwrite$ | async) == false || (['custom_domain'] | hasFeature | async) == false" matTooltip="Add domain" mat-raised-button
|
||||
color="primary" (click)="addNewDomain()">{{'ORG.DOMAINS.NEW' | translate}}
|
||||
</button>
|
||||
</app-card>
|
||||
|
||||
@@ -71,11 +71,11 @@ h2 {
|
||||
.title {
|
||||
font-size: 16px;
|
||||
margin-right: 1rem;
|
||||
cursor: pointer;
|
||||
|
||||
&:not(.disabled) {
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,3 +119,7 @@ h2 {
|
||||
font-size: 14px;
|
||||
color: #818a8a;
|
||||
}
|
||||
|
||||
.custom-domain-deactivated {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
@@ -22,206 +22,204 @@ import { DomainVerificationComponent } from './domain-verification/domain-verifi
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-org-detail',
|
||||
templateUrl: './org-detail.component.html',
|
||||
styleUrls: ['./org-detail.component.scss'],
|
||||
selector: 'app-org-detail',
|
||||
templateUrl: './org-detail.component.html',
|
||||
styleUrls: ['./org-detail.component.scss'],
|
||||
})
|
||||
export class OrgDetailComponent implements OnInit {
|
||||
public org!: Org.AsObject;
|
||||
public PolicyComponentServiceType: any = PolicyComponentServiceType;
|
||||
public org!: Org.AsObject;
|
||||
public PolicyComponentServiceType: any = PolicyComponentServiceType;
|
||||
|
||||
public OrgState: any = OrgState;
|
||||
public ChangeType: any = ChangeType;
|
||||
public OrgState: any = OrgState;
|
||||
public ChangeType: any = ChangeType;
|
||||
|
||||
public domains: Domain.AsObject[] = [];
|
||||
public primaryDomain: string = '';
|
||||
public domains: Domain.AsObject[] = [];
|
||||
public primaryDomain: string = '';
|
||||
|
||||
// members
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
public totalMemberResult: number = 0;
|
||||
public membersSubject: BehaviorSubject<Member.AsObject[]>
|
||||
= new BehaviorSubject<Member.AsObject[]>([]);
|
||||
public PolicyGridType: any = PolicyGridType;
|
||||
// members
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
public totalMemberResult: number = 0;
|
||||
public membersSubject: BehaviorSubject<Member.AsObject[]>
|
||||
= new BehaviorSubject<Member.AsObject[]>([]);
|
||||
public PolicyGridType: any = PolicyGridType;
|
||||
|
||||
public features!: Features.AsObject;
|
||||
public features!: Features.AsObject;
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog,
|
||||
public translate: TranslateService,
|
||||
public mgmtService: ManagementService,
|
||||
private toast: ToastService,
|
||||
private router: Router,
|
||||
) {
|
||||
constructor(
|
||||
private dialog: MatDialog,
|
||||
public translate: TranslateService,
|
||||
public mgmtService: ManagementService,
|
||||
private toast: ToastService,
|
||||
private router: Router,
|
||||
) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.getData();
|
||||
}
|
||||
|
||||
private async getData(): Promise<void> {
|
||||
this.mgmtService.getMyOrg().then((resp) => {
|
||||
if (resp.org) {
|
||||
this.org = resp.org;
|
||||
}
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
this.loadMembers();
|
||||
this.loadDomains();
|
||||
this.loadFeatures();
|
||||
}
|
||||
|
||||
public loadDomains(): void {
|
||||
this.mgmtService.listOrgDomains().then(result => {
|
||||
this.domains = result.resultList;
|
||||
this.primaryDomain = this.domains.find(domain => domain.isPrimary)?.domainName ?? '';
|
||||
});
|
||||
}
|
||||
|
||||
public setPrimary(domain: Domain.AsObject): void {
|
||||
this.mgmtService.setPrimaryOrgDomain(domain.domainName).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.SETPRIMARY', true);
|
||||
this.loadDomains();
|
||||
}).catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
|
||||
public changeState(event: MatButtonToggleChange | any): void {
|
||||
if (event.value === OrgState.ORG_STATE_ACTIVE) {
|
||||
this.mgmtService.reactivateOrg().then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.REACTIVATED', true);
|
||||
}).catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (event.value === OrgState.ORG_STATE_INACTIVE) {
|
||||
this.mgmtService.deactivateOrg().then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.DEACTIVATED', true);
|
||||
}).catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.getData();
|
||||
}
|
||||
public addNewDomain(): void {
|
||||
const dialogRef = this.dialog.open(AddDomainDialogComponent, {
|
||||
data: {},
|
||||
width: '400px',
|
||||
});
|
||||
|
||||
private async getData(): Promise<void> {
|
||||
this.mgmtService.getMyOrg().then((resp) => {
|
||||
if (resp.org) {
|
||||
this.org = resp.org;
|
||||
}
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
this.loadMembers();
|
||||
this.loadDomains();
|
||||
this.loadFeatures();
|
||||
}
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.mgmtService.addOrgDomain(resp).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.DOMAINADDED', true);
|
||||
|
||||
public loadDomains(): void {
|
||||
this.mgmtService.listOrgDomains().then(result => {
|
||||
this.domains = result.resultList;
|
||||
this.primaryDomain = this.domains.find(domain => domain.isPrimary)?.domainName ?? '';
|
||||
});
|
||||
}
|
||||
|
||||
public setPrimary(domain: Domain.AsObject): void {
|
||||
this.mgmtService.setPrimaryOrgDomain(domain.domainName).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.SETPRIMARY', true);
|
||||
setTimeout(() => {
|
||||
this.loadDomains();
|
||||
}).catch((error) => {
|
||||
}, 1000);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public removeDomain(domain: string): void {
|
||||
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
||||
data: {
|
||||
confirmKey: 'ACTIONS.DELETE',
|
||||
cancelKey: 'ACTIONS.CANCEL',
|
||||
titleKey: 'ORG.DOMAINS.DELETE.TITLE',
|
||||
descriptionKey: 'ORG.DOMAINS.DELETE.DESCRIPTION',
|
||||
},
|
||||
width: '400px',
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.mgmtService.removeOrgDomain(domain).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.DOMAINREMOVED', true);
|
||||
const index = this.domains.findIndex(d => d.domainName === domain);
|
||||
if (index > -1) {
|
||||
this.domains.splice(index, 1);
|
||||
}
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public openAddMember(): void {
|
||||
const dialogRef = this.dialog.open(MemberCreateDialogComponent, {
|
||||
data: {
|
||||
creationType: CreationType.ORG,
|
||||
},
|
||||
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.mgmtService.addOrgMember(user.id, roles);
|
||||
})).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.MEMBERADDED', true);
|
||||
setTimeout(() => {
|
||||
this.loadMembers();
|
||||
}, 1000);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
|
||||
public changeState(event: MatButtonToggleChange | any): void {
|
||||
if (event.value === OrgState.ORG_STATE_ACTIVE) {
|
||||
this.mgmtService.reactivateOrg().then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.REACTIVATED', true);
|
||||
}).catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (event.value === OrgState.ORG_STATE_INACTIVE) {
|
||||
this.mgmtService.deactivateOrg().then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.DEACTIVATED', true);
|
||||
}).catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public addNewDomain(): void {
|
||||
const dialogRef = this.dialog.open(AddDomainDialogComponent, {
|
||||
data: {},
|
||||
width: '400px',
|
||||
});
|
||||
public showDetail(): void {
|
||||
this.router.navigate(['org/members']);
|
||||
}
|
||||
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.mgmtService.addOrgDomain(resp).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.DOMAINADDED', true);
|
||||
public verifyDomain(domain: Domain.AsObject): void {
|
||||
const dialogRef = this.dialog.open(DomainVerificationComponent, {
|
||||
data: {
|
||||
domain: domain,
|
||||
},
|
||||
width: '500px',
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.loadDomains();
|
||||
}, 1000);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
dialogRef.afterClosed().subscribe((reload) => {
|
||||
if (reload) {
|
||||
this.loadDomains();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public removeDomain(domain: string): void {
|
||||
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
||||
data: {
|
||||
confirmKey: 'ACTIONS.DELETE',
|
||||
cancelKey: 'ACTIONS.CANCEL',
|
||||
titleKey: 'ORG.DOMAINS.DELETE.TITLE',
|
||||
descriptionKey: 'ORG.DOMAINS.DELETE.DESCRIPTION',
|
||||
},
|
||||
width: '400px',
|
||||
});
|
||||
public loadMembers(): void {
|
||||
this.loadingSubject.next(true);
|
||||
from(this.mgmtService.listOrgMembers(100, 0)).pipe(
|
||||
map(resp => {
|
||||
if (resp.details?.totalResult) {
|
||||
this.totalMemberResult = resp.details?.totalResult;
|
||||
}
|
||||
return resp.resultList;
|
||||
}),
|
||||
catchError(() => of([])),
|
||||
finalize(() => this.loadingSubject.next(false)),
|
||||
).subscribe(members => {
|
||||
this.membersSubject.next(members);
|
||||
});
|
||||
}
|
||||
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.mgmtService.removeOrgDomain(domain).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.DOMAINREMOVED', true);
|
||||
const index = this.domains.findIndex(d => d.domainName === domain);
|
||||
if (index > -1) {
|
||||
this.domains.splice(index, 1);
|
||||
}
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public openAddMember(): void {
|
||||
const dialogRef = this.dialog.open(MemberCreateDialogComponent, {
|
||||
data: {
|
||||
creationType: CreationType.ORG,
|
||||
},
|
||||
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.mgmtService.addOrgMember(user.id, roles);
|
||||
})).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.MEMBERADDED', true);
|
||||
setTimeout(() => {
|
||||
this.loadMembers();
|
||||
}, 1000);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public showDetail(): void {
|
||||
this.router.navigate(['org/members']);
|
||||
}
|
||||
|
||||
public verifyDomain(domain: Domain.AsObject): void {
|
||||
const dialogRef = this.dialog.open(DomainVerificationComponent, {
|
||||
data: {
|
||||
domain: domain,
|
||||
},
|
||||
width: '500px',
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((reload) => {
|
||||
if (reload) {
|
||||
this.loadDomains();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public loadMembers(): void {
|
||||
this.loadingSubject.next(true);
|
||||
from(this.mgmtService.listOrgMembers(100, 0)).pipe(
|
||||
map(resp => {
|
||||
if (resp.details?.totalResult) {
|
||||
this.totalMemberResult = resp.details?.totalResult;
|
||||
}
|
||||
return resp.resultList;
|
||||
}),
|
||||
catchError(() => of([])),
|
||||
finalize(() => this.loadingSubject.next(false)),
|
||||
).subscribe(members => {
|
||||
this.membersSubject.next(members);
|
||||
});
|
||||
}
|
||||
|
||||
public loadFeatures(): void {
|
||||
this.loadingSubject.next(true);
|
||||
this.mgmtService.getFeatures().then(resp => {
|
||||
if (resp.features) {
|
||||
this.features = resp.features;
|
||||
}
|
||||
});
|
||||
}
|
||||
public loadFeatures(): void {
|
||||
this.loadingSubject.next(true);
|
||||
this.mgmtService.getFeatures().then(resp => {
|
||||
if (resp.features) {
|
||||
this.features = resp.features;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user