2022-04-28 12:35:02 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2023-01-11 14:23:16 +01:00
|
|
|
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog';
|
2022-04-28 12:35:02 +02:00
|
|
|
import { InfoSectionType } from 'src/app/modules/info-section/info-section.component';
|
|
|
|
|
import { WarnDialogComponent } from 'src/app/modules/warn-dialog/warn-dialog.component';
|
2022-11-14 16:41:25 +01:00
|
|
|
import { Domain, DomainValidationType } from 'src/app/proto/generated/zitadel/org_pb';
|
2022-04-28 12:35:02 +02:00
|
|
|
import { Breadcrumb, BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service';
|
|
|
|
|
import { ManagementService } from 'src/app/services/mgmt.service';
|
|
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
|
|
|
|
|
|
import { AddDomainDialogComponent } from './add-domain-dialog/add-domain-dialog.component';
|
|
|
|
|
import { DomainVerificationComponent } from './domain-verification/domain-verification.component';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'cnsl-domains',
|
|
|
|
|
templateUrl: './domains.component.html',
|
|
|
|
|
styleUrls: ['./domains.component.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class DomainsComponent implements OnInit {
|
|
|
|
|
public domains: Domain.AsObject[] = [];
|
|
|
|
|
public primaryDomain: string = '';
|
|
|
|
|
public InfoSectionType: any = InfoSectionType;
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private mgmtService: ManagementService,
|
|
|
|
|
private toast: ToastService,
|
|
|
|
|
private dialog: MatDialog,
|
|
|
|
|
breadcrumbService: BreadcrumbService,
|
|
|
|
|
) {
|
|
|
|
|
const bread: Breadcrumb = {
|
|
|
|
|
type: BreadcrumbType.ORG,
|
|
|
|
|
routerLink: ['/org'],
|
|
|
|
|
};
|
feat: console flat navigation, settings (#3581)
* instance routing
* instance naming
* org list
* rm isonsystem
* breadcrumb type
* routing
* instance members
* fragment refresh org
* settings pages
* settings list, sidenav grouping, i18n
* org-settings, policy changes
* lint
* grid
* rename grid
* fallback to general
* cleanup
* general settings, remove cards
* sidenav for settings, label policy
* i18n
* header, nav backbuild
* general, project nav rehaul
* login text background adapt
* org nav anim
* org, instance settings, fix policy layout, roles
* i18n, active route for project
* lint
2022-05-09 15:01:36 +02:00
|
|
|
breadcrumbService.setBreadcrumb([bread]);
|
2022-04-28 12:35:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
this.loadDomains();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 addNewDomain(): void {
|
|
|
|
|
const dialogRef = this.dialog.open(AddDomainDialogComponent, {
|
|
|
|
|
data: {},
|
|
|
|
|
width: '400px',
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-14 16:41:25 +01:00
|
|
|
dialogRef.afterClosed().subscribe((domainName) => {
|
|
|
|
|
if (domainName) {
|
2022-04-28 12:35:02 +02:00
|
|
|
this.mgmtService
|
2022-11-14 16:41:25 +01:00
|
|
|
.addOrgDomain(domainName)
|
2022-04-28 12:35:02 +02:00
|
|
|
.then(() => {
|
|
|
|
|
this.toast.showInfo('ORG.TOAST.DOMAINADDED', true);
|
2022-11-14 16:41:25 +01:00
|
|
|
this.verifyDomain({
|
|
|
|
|
domainName: domainName,
|
|
|
|
|
validationType: DomainValidationType.DOMAIN_VALIDATION_TYPE_UNSPECIFIED,
|
|
|
|
|
});
|
2022-04-28 12:35:02 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
|
this.loadDomains();
|
|
|
|
|
}, 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',
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-14 16:41:25 +01:00
|
|
|
dialogRef.afterClosed().subscribe((del) => {
|
|
|
|
|
if (del) {
|
2022-04-28 12:35:02 +02:00
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-14 16:41:25 +01:00
|
|
|
public verifyDomain(domain: Partial<Domain.AsObject>): void {
|
2022-04-28 12:35:02 +02:00
|
|
|
const dialogRef = this.dialog.open(DomainVerificationComponent, {
|
|
|
|
|
data: {
|
|
|
|
|
domain: domain,
|
|
|
|
|
},
|
|
|
|
|
width: '500px',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dialogRef.afterClosed().subscribe((reload: boolean) => {
|
|
|
|
|
if (reload) {
|
|
|
|
|
this.loadDomains();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|