mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 08:27:32 +00:00
fix: update private labeling (#2048)
This commit is contained in:
@@ -259,7 +259,7 @@
|
|||||||
</cnsl-info-section>
|
</cnsl-info-section>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<mat-slide-toggle class="toggle" color="primary" ngDefaultControl [disabled]="serviceType == PolicyComponentServiceType.MGMT && (['label_policy.watermark'] | hasFeature | async) == false"
|
<mat-slide-toggle class="toggle" color="primary" ngDefaultControl [disabled]="serviceType == PolicyComponentServiceType.MGMT && (['label_policy.watermark'] | hasFeature | async) == false"
|
||||||
[(ngModel)]="previewData.disableWatermark" (change)="saveWatermark()">
|
[(ngModel)]="previewData.disableWatermark" (change)="savePolicy()">
|
||||||
{{'POLICY.DATA.DISABLEWATERMARK' | translate}}
|
{{'POLICY.DATA.DISABLEWATERMARK' | translate}}
|
||||||
</mat-slide-toggle>
|
</mat-slide-toggle>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -354,8 +354,6 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
|||||||
|
|
||||||
this.authService.canUseFeature(['label_policy.private_label']).pipe(take(1)).subscribe((canUse) => {
|
this.authService.canUseFeature(['label_policy.private_label']).pipe(take(1)).subscribe((canUse) => {
|
||||||
this.getPreviewData().then(data => {
|
this.getPreviewData().then(data => {
|
||||||
console.log('preview', data);
|
|
||||||
|
|
||||||
if (data.policy) {
|
if (data.policy) {
|
||||||
this.previewData = data.policy;
|
this.previewData = data.policy;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@@ -371,8 +369,6 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.getData().then(data => {
|
this.getData().then(data => {
|
||||||
console.log('data', data);
|
|
||||||
|
|
||||||
if (data.policy) {
|
if (data.policy) {
|
||||||
this.data = data.policy;
|
this.data = data.policy;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@@ -506,7 +502,6 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
|||||||
|
|
||||||
private loadAsset(imagekey: string, url: string): Promise<any> {
|
private loadAsset(imagekey: string, url: string): Promise<any> {
|
||||||
return this.assetService.load(`${url}`, this.org.id).then(data => {
|
return this.assetService.load(`${url}`, this.org.id).then(data => {
|
||||||
console.log(data);
|
|
||||||
const objectURL = URL.createObjectURL(data);
|
const objectURL = URL.createObjectURL(data);
|
||||||
this.images[imagekey] = this.sanitizer.bypassSecurityTrustUrl(objectURL);
|
this.images[imagekey] = this.sanitizer.bypassSecurityTrustUrl(objectURL);
|
||||||
this.refreshPreview.emit();
|
this.refreshPreview.emit();
|
||||||
@@ -529,6 +524,18 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public savePolicy(): Promise<any> {
|
public savePolicy(): Promise<any> {
|
||||||
|
const reloadPolicy = () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.loadingImages = true;
|
||||||
|
this.getData().then(data => {
|
||||||
|
|
||||||
|
if (data.policy) {
|
||||||
|
this.data = data.policy;
|
||||||
|
this.loadImages();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
switch (this.serviceType) {
|
switch (this.serviceType) {
|
||||||
case PolicyComponentServiceType.MGMT:
|
case PolicyComponentServiceType.MGMT:
|
||||||
if ((this.previewData as LabelPolicy.AsObject).isDefault) {
|
if ((this.previewData as LabelPolicy.AsObject).isDefault) {
|
||||||
@@ -537,6 +544,8 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
|||||||
|
|
||||||
return (this.service as ManagementService).addCustomLabelPolicy(req0).then(() => {
|
return (this.service as ManagementService).addCustomLabelPolicy(req0).then(() => {
|
||||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||||
|
|
||||||
|
reloadPolicy();
|
||||||
}).catch((error: HttpErrorResponse) => {
|
}).catch((error: HttpErrorResponse) => {
|
||||||
this.toast.showError(error);
|
this.toast.showError(error);
|
||||||
});
|
});
|
||||||
@@ -546,6 +555,8 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
|||||||
|
|
||||||
return (this.service as ManagementService).updateCustomLabelPolicy(req1).then(() => {
|
return (this.service as ManagementService).updateCustomLabelPolicy(req1).then(() => {
|
||||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||||
|
|
||||||
|
reloadPolicy();
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.toast.showError(error);
|
this.toast.showError(error);
|
||||||
});
|
});
|
||||||
@@ -554,6 +565,7 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
|||||||
const req = new UpdateLabelPolicyRequest();
|
const req = new UpdateLabelPolicyRequest();
|
||||||
this.overwriteValues(req);
|
this.overwriteValues(req);
|
||||||
return (this.service as AdminService).updateLabelPolicy(req).then(() => {
|
return (this.service as AdminService).updateLabelPolicy(req).then(() => {
|
||||||
|
reloadPolicy();
|
||||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.toast.showError(error);
|
this.toast.showError(error);
|
||||||
@@ -561,42 +573,6 @@ export class PrivateLabelingPolicyComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public saveWatermark(): void {
|
|
||||||
switch (this.serviceType) {
|
|
||||||
case PolicyComponentServiceType.MGMT:
|
|
||||||
if ((this.previewData as LabelPolicy.AsObject).isDefault) {
|
|
||||||
const req0 = new AddCustomLabelPolicyRequest();
|
|
||||||
req0.setDisableWatermark(this.previewData.disableWatermark);
|
|
||||||
|
|
||||||
(this.service as ManagementService).addCustomLabelPolicy(req0).then(() => {
|
|
||||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
||||||
}).catch((error: HttpErrorResponse) => {
|
|
||||||
this.toast.showError(error);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const req1 = new UpdateCustomLabelPolicyRequest();
|
|
||||||
req1.setDisableWatermark(this.previewData.disableWatermark);
|
|
||||||
|
|
||||||
(this.service as ManagementService).updateCustomLabelPolicy(req1).then(() => {
|
|
||||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
||||||
}).catch(error => {
|
|
||||||
this.toast.showError(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PolicyComponentServiceType.ADMIN:
|
|
||||||
const req = new UpdateLabelPolicyRequest();
|
|
||||||
req.setDisableWatermark(this.data.disableWatermark);
|
|
||||||
|
|
||||||
(this.service as AdminService).updateLabelPolicy(req).then(() => {
|
|
||||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
||||||
}).catch(error => {
|
|
||||||
this.toast.showError(error);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public get isDefault(): boolean {
|
public get isDefault(): boolean {
|
||||||
if (this.previewData && this.serviceType === PolicyComponentServiceType.MGMT) {
|
if (this.previewData && this.serviceType === PolicyComponentServiceType.MGMT) {
|
||||||
return (this.previewData as LabelPolicy.AsObject).isDefault;
|
return (this.previewData as LabelPolicy.AsObject).isDefault;
|
||||||
|
Reference in New Issue
Block a user