mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-03 01:18:51 +00:00
fix(console): new colorpicker, remove icons logo font (#1826)
* custom color picker, delete font * delete asset, i18n * escape deep styles * ts, proto * remove fallback img, color clickable, remove font * stylelint * fix spinner * fix deprecated chipinput.input * improve logo on login * fix qr code * always use black on white for qr code * fix header and footer css Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
co-authored by
Livio Amstutz
parent
255139862d
commit
59af02b2f3
+140
-31
@@ -17,9 +17,9 @@ import {
|
||||
} from 'src/app/proto/generated/zitadel/management_pb';
|
||||
import { LabelPolicy } from 'src/app/proto/generated/zitadel/policy_pb';
|
||||
import { AdminService } from 'src/app/services/admin.service';
|
||||
import { AssetEndpoint, AssetService, AssetType } from 'src/app/services/asset.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { DownloadEndpoint, UploadEndpoint, UploadService } from 'src/app/services/upload.service';
|
||||
|
||||
import { CnslLinks } from '../../links/links.component';
|
||||
import { IAM_COMPLEXITY_LINK, IAM_LOGIN_POLICY_LINK, IAM_POLICY_LINK } from '../../policy-grid/policy-links';
|
||||
@@ -82,6 +82,7 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
||||
public Theme: any = Theme;
|
||||
public Preview: any = Preview;
|
||||
public ColorType: any = ColorType;
|
||||
public AssetType: any = AssetType;
|
||||
|
||||
public refreshPreview: EventEmitter<void> = new EventEmitter();
|
||||
public loadingImages: boolean = false;
|
||||
@@ -90,7 +91,7 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
private injector: Injector,
|
||||
private uploadService: UploadService,
|
||||
private assetService: AssetService,
|
||||
private sanitizer: DomSanitizer,
|
||||
) {
|
||||
this.sub = this.route.data.pipe(switchMap(data => {
|
||||
@@ -133,17 +134,17 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
||||
if (theme === Theme.DARK) {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return this.handleUploadPromise(this.uploadService.upload(UploadEndpoint.MGMTDARKLOGO, formData));
|
||||
return this.handleUploadPromise(this.assetService.upload(AssetEndpoint.MGMTDARKLOGO, formData));
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return this.handleUploadPromise(this.uploadService.upload(UploadEndpoint.IAMDARKLOGO, formData));
|
||||
return this.handleUploadPromise(this.assetService.upload(AssetEndpoint.IAMDARKLOGO, formData));
|
||||
}
|
||||
}
|
||||
if (theme === Theme.LIGHT) {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return this.handleUploadPromise(this.uploadService.upload(UploadEndpoint.MGMTLIGHTLOGO, formData));
|
||||
return this.handleUploadPromise(this.assetService.upload(AssetEndpoint.MGMTLOGO, formData));
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return this.handleUploadPromise(this.uploadService.upload(UploadEndpoint.IAMLIGHTLOGO, formData));
|
||||
return this.handleUploadPromise(this.assetService.upload(AssetEndpoint.IAMLOGO, formData));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,13 +158,87 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
||||
formData.append('file', file);
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return this.uploadService.upload(UploadEndpoint.MGMTFONT, formData);
|
||||
return this.handleFontUploadPromise(this.assetService.upload(AssetEndpoint.MGMTFONT, formData));
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return this.uploadService.upload(UploadEndpoint.IAMFONT, formData);
|
||||
return this.handleFontUploadPromise(this.assetService.upload(AssetEndpoint.IAMFONT, formData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public deleteFont(): Promise<any> {
|
||||
const handler = (prom: Promise<any>) => prom.then(() => {
|
||||
this.toast.showInfo('POLICY.TOAST.DELETESUCCESS', true);
|
||||
setTimeout(() => {
|
||||
this.loadingImages = true;
|
||||
this.getPreviewData().then(data => {
|
||||
|
||||
if (data.policy) {
|
||||
this.previewData = data.policy;
|
||||
this.loadPreviewImages();
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}).catch(error => this.toast.showError(error));
|
||||
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return handler((this.service as ManagementService).removeLabelPolicyFont());
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return handler((this.service as AdminService).removeLabelPolicyFont());
|
||||
}
|
||||
}
|
||||
|
||||
public deleteAsset(type: AssetType, theme: Theme): any {
|
||||
const previewHandler = (prom: Promise<any>) => {
|
||||
return prom.then(() => {
|
||||
this.toast.showInfo('POLICY.TOAST.DELETESUCCESS', true);
|
||||
setTimeout(() => {
|
||||
this.loadingImages = true;
|
||||
this.getPreviewData().then(data => {
|
||||
|
||||
if (data.policy) {
|
||||
this.previewData = data.policy;
|
||||
this.loadPreviewImages();
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}).catch(error => this.toast.showError(error));
|
||||
};
|
||||
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
if (type === AssetType.LOGO) {
|
||||
if (theme === Theme.DARK) {
|
||||
return previewHandler(this.service.removeLabelPolicyLogoDark());
|
||||
} else if (theme === Theme.LIGHT) {
|
||||
return previewHandler(this.service.removeLabelPolicyLogo());
|
||||
}
|
||||
} else if (type === AssetType.ICON) {
|
||||
if (theme === Theme.DARK) {
|
||||
return previewHandler(this.service.removeLabelPolicyIconDark());
|
||||
} else if (theme === Theme.LIGHT) {
|
||||
return previewHandler(this.service.removeLabelPolicyIcon());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
if (type === AssetType.LOGO) {
|
||||
if (theme === Theme.DARK) {
|
||||
return previewHandler(this.service.removeLabelPolicyLogoDark());
|
||||
} else if (theme === Theme.LIGHT) {
|
||||
return previewHandler(this.service.removeLabelPolicyLogo());
|
||||
}
|
||||
} else if (type === AssetType.ICON) {
|
||||
if (theme === Theme.DARK) {
|
||||
return previewHandler(this.service.removeLabelPolicyIconDark());
|
||||
} else if (theme === Theme.LIGHT) {
|
||||
return previewHandler(this.service.removeLabelPolicyIcon());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public toggleHoverIcon(theme: Theme, isHovering: boolean): void {
|
||||
if (theme === Theme.DARK) {
|
||||
this.isHoveringOverDarkIcon = isHovering;
|
||||
@@ -182,26 +257,39 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
||||
if (theme === Theme.DARK) {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
this.handleUploadPromise(this.uploadService.upload(UploadEndpoint.MGMTDARKICON, formData));
|
||||
this.handleUploadPromise(this.assetService.upload(AssetEndpoint.MGMTDARKICON, formData));
|
||||
break;
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
this.handleUploadPromise(this.uploadService.upload(UploadEndpoint.IAMDARKICON, formData));
|
||||
this.handleUploadPromise(this.assetService.upload(AssetEndpoint.IAMDARKICON, formData));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (theme === Theme.LIGHT) {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
this.handleUploadPromise(this.uploadService.upload(UploadEndpoint.MGMTLIGHTICON, formData));
|
||||
this.handleUploadPromise(this.assetService.upload(AssetEndpoint.MGMTICON, formData));
|
||||
break;
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
this.handleUploadPromise(this.uploadService.upload(UploadEndpoint.IAMLIGHTICON, formData));
|
||||
this.handleUploadPromise(this.assetService.upload(AssetEndpoint.IAMICON, formData));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private handleFontUploadPromise(task: Promise<any>): Promise<any> {
|
||||
return task.then(() => {
|
||||
this.toast.showInfo('POLICY.TOAST.UPLOADSUCCESS', true);
|
||||
setTimeout(() => {
|
||||
this.getPreviewData().then(data => {
|
||||
if (data.policy) {
|
||||
this.previewData = data.policy;
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}).catch(error => this.toast.showError(error));
|
||||
}
|
||||
|
||||
private handleUploadPromise(task: Promise<any>): Promise<any> {
|
||||
return task.then(() => {
|
||||
this.toast.showInfo('POLICY.TOAST.UPLOADSUCCESS', true);
|
||||
@@ -250,63 +338,86 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
private loadImages(): void {
|
||||
const promises: Promise<any>[] = [];
|
||||
if (this.serviceType === PolicyComponentServiceType.ADMIN) {
|
||||
if (this.data.logoUrlDark) {
|
||||
this.loadAsset('darkLogo', DownloadEndpoint.IAMDARKLOGOPREVIEW);
|
||||
promises.push(this.loadAsset('darkLogo', AssetEndpoint.IAMDARKLOGO));
|
||||
}
|
||||
if (this.data.iconUrlDark) {
|
||||
this.loadAsset('darkIcon', DownloadEndpoint.IAMDARKICONPREVIEW);
|
||||
promises.push(this.loadAsset('darkIcon', AssetEndpoint.IAMDARKICON));
|
||||
}
|
||||
if (this.data.logoUrl) {
|
||||
this.loadAsset('logo', DownloadEndpoint.IAMLOGOPREVIEW);
|
||||
promises.push(this.loadAsset('logo', AssetEndpoint.IAMLOGO));
|
||||
}
|
||||
if (this.data.iconUrl) {
|
||||
this.loadAsset('icon', DownloadEndpoint.IAMICONPREVIEW);
|
||||
promises.push(this.loadAsset('icon', AssetEndpoint.IAMICON));
|
||||
}
|
||||
} else if (this.serviceType === PolicyComponentServiceType.MGMT) {
|
||||
if (this.data.logoUrlDark) {
|
||||
this.loadAsset('darkLogo', DownloadEndpoint.MGMTDARKLOGOPREVIEW);
|
||||
promises.push(this.loadAsset('darkLogo', AssetEndpoint.MGMTDARKLOGO));
|
||||
}
|
||||
if (this.data.iconUrlDark) {
|
||||
this.loadAsset('darkIcon', DownloadEndpoint.MGMTDARKICONPREVIEW);
|
||||
promises.push(this.loadAsset('darkIcon', AssetEndpoint.MGMTDARKICON));
|
||||
}
|
||||
if (this.data.logoUrl) {
|
||||
this.loadAsset('logo', DownloadEndpoint.MGMTLOGOPREVIEW);
|
||||
promises.push(this.loadAsset('logo', AssetEndpoint.MGMTLOGO));
|
||||
}
|
||||
if (this.data.iconUrl) {
|
||||
this.loadAsset('icon', DownloadEndpoint.MGMTICONPREVIEW);
|
||||
promises.push(this.loadAsset('icon', AssetEndpoint.MGMTICON));
|
||||
}
|
||||
}
|
||||
|
||||
if (promises.length) {
|
||||
Promise.all(promises).then(() => {
|
||||
this.loadingImages = false;
|
||||
}).catch(error => {
|
||||
this.loadingImages = false;
|
||||
});
|
||||
} else {
|
||||
this.loadingImages = false;
|
||||
}
|
||||
}
|
||||
|
||||
private loadPreviewImages(): void {
|
||||
const promises: Promise<any>[] = [];
|
||||
|
||||
if (this.serviceType === PolicyComponentServiceType.ADMIN) {
|
||||
if (this.previewData.logoUrlDark) {
|
||||
this.loadAsset('previewDarkLogo', DownloadEndpoint.IAMDARKLOGOPREVIEW);
|
||||
promises.push(this.loadAsset('previewDarkLogo', AssetEndpoint.IAMDARKLOGOPREVIEW));
|
||||
}
|
||||
if (this.previewData.iconUrlDark) {
|
||||
this.loadAsset('previewDarkIcon', DownloadEndpoint.IAMDARKICONPREVIEW);
|
||||
promises.push(this.loadAsset('previewDarkIcon', AssetEndpoint.IAMDARKICONPREVIEW));
|
||||
}
|
||||
if (this.previewData.logoUrl) {
|
||||
this.loadAsset('previewLogo', DownloadEndpoint.IAMLOGOPREVIEW);
|
||||
promises.push(this.loadAsset('previewLogo', AssetEndpoint.IAMLOGOPREVIEW));
|
||||
}
|
||||
if (this.previewData.iconUrl) {
|
||||
this.loadAsset('previewIcon', DownloadEndpoint.IAMICONPREVIEW);
|
||||
promises.push(this.loadAsset('previewIcon', AssetEndpoint.IAMICONPREVIEW));
|
||||
}
|
||||
} else if (this.serviceType === PolicyComponentServiceType.MGMT) {
|
||||
if (this.previewData.logoUrlDark) {
|
||||
this.loadAsset('previewDarkLogo', DownloadEndpoint.MGMTDARKLOGOPREVIEW);
|
||||
promises.push(this.loadAsset('previewDarkLogo', AssetEndpoint.MGMTDARKLOGOPREVIEW));
|
||||
}
|
||||
if (this.previewData.iconUrlDark) {
|
||||
this.loadAsset('previewDarkIcon', DownloadEndpoint.MGMTDARKICONPREVIEW);
|
||||
promises.push(this.loadAsset('previewDarkIcon', AssetEndpoint.MGMTDARKICONPREVIEW));
|
||||
}
|
||||
if (this.previewData.logoUrl) {
|
||||
this.loadAsset('previewLogo', DownloadEndpoint.MGMTLOGOPREVIEW);
|
||||
promises.push(this.loadAsset('previewLogo', AssetEndpoint.MGMTLOGOPREVIEW));
|
||||
}
|
||||
if (this.previewData.iconUrl) {
|
||||
this.loadAsset('previewIcon', DownloadEndpoint.MGMTICONPREVIEW);
|
||||
promises.push(this.loadAsset('previewIcon', AssetEndpoint.MGMTICONPREVIEW));
|
||||
}
|
||||
}
|
||||
|
||||
if (promises.length) {
|
||||
Promise.all(promises).then(() => {
|
||||
this.loadingImages = false;
|
||||
}).catch(error => {
|
||||
this.loadingImages = false;
|
||||
});
|
||||
} else {
|
||||
this.loadingImages = false;
|
||||
}
|
||||
}
|
||||
|
||||
public ngOnDestroy(): void {
|
||||
@@ -340,14 +451,12 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
private loadAsset(imagekey: string, url: string): Promise<any> {
|
||||
return this.uploadService.load(`${url}`).then(data => {
|
||||
return this.assetService.load(`${url}`).then(data => {
|
||||
const objectURL = URL.createObjectURL(data);
|
||||
this.images[imagekey] = this.sanitizer.bypassSecurityTrustUrl(objectURL);
|
||||
this.refreshPreview.emit();
|
||||
this.loadingImages = false;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
this.loadingImages = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user