add back remove layout method in admin-customization

Customization: first create css, then save the layout and purge cache (to avoid file not found) - add timeout to load the iframe (to avoid file not found)
This commit is contained in:
argirok 2022-08-12 16:18:36 +03:00
parent 0dbb8b2c75
commit e56a6effd8
3 changed files with 29 additions and 9 deletions

@ -1 +1 @@
Subproject commit 27d7c7c118a363c2db3deb8ee13ff8801ebed3a8 Subproject commit 561c15b8cd52f45ab6d3aa1d125ef69478a81038

View File

@ -31,6 +31,18 @@ declare var UIkit;
</div> </div>
<button (click)="updateCss()" class="uk-button uk-button-danger" [class.uk-disabled]="savingChanges"> Update CSS</button> <button (click)="updateCss()" class="uk-button uk-button-danger" [class.uk-disabled]="savingChanges"> Update CSS</button>
<button (click)="purgeBrowserCache()" class="uk-button uk-button-danger uk-margin-left" [class.uk-disabled]="savingChanges"> Purge Browser Cache</button> <button (click)="purgeBrowserCache()" class="uk-button uk-button-danger uk-margin-left" [class.uk-disabled]="savingChanges"> Purge Browser Cache</button>
<ng-container *ngIf="properties.domain != 'production'">
<hr>
<div class="uk-alert uk-alert-danger uk-margin-top ">
Delete after next deployment
</div>
<div class="uk-alert uk-alert-warning uk-margin-top ">
<div class="uk-text-large">Use to clean up multiple layouts of a community id.</div>
</div>
<div input [(value)]="community" [placeholder]="'e.g. galaxy'"></div>
<button (click)="deleteLayout()" class="uk-button uk-button-danger" [class.uk-disabled]="!community"> Delete layout</button>
</ng-container>
</div> </div>
</div> </div>
@ -111,4 +123,12 @@ export class ConnectAdminCustomizationComponent implements OnInit {
)); ));
this._clearCacheService.purgeBrowserCache("Layout added/ updated", "connect"); this._clearCacheService.purgeBrowserCache("Layout added/ updated", "connect");
} }
deleteLayout(){
if(this.community && this.community.length > 0) {
this.subscriptions.push(this.customizationService.deleteLayout(properties, this.community, "community").subscribe(data => {
}));
}
}
} }

View File

@ -172,13 +172,13 @@ sidebarItems = [{name:"Identity", id : "identity", icon: "desktop_windows" },
this.publishedLayout.layoutOptions = this.copyObject(this.draftCustomizationOptions); this.publishedLayout.layoutOptions = this.copyObject(this.draftCustomizationOptions);
this.publishedCustomizationOptions = this.copyObject(this.publishedLayout.layoutOptions) this.publishedCustomizationOptions = this.copyObject(this.publishedLayout.layoutOptions)
this.publishedLayout.date = new Date(); this.publishedLayout.date = new Date();
this.subscriptions.push(this.layoutService.createCSS(this.communityId,this.properties.connectPortalUrl, this.publishedLayout.date.valueOf(), this.publishedLayout.layoutOptions).subscribe(data => {
this.subscriptions.push(this.layoutService.saveLayout(this.properties, this.communityId, this.publishedLayout).subscribe(layout => { this.subscriptions.push(this.layoutService.saveLayout(this.properties, this.communityId, this.publishedLayout).subscribe(layout => {
this.publishedLayout._id = layout._id; this.publishedLayout._id = layout._id;
this._clearCacheService.purgeBrowserCache("Layout added/ updated", this.communityId); this._clearCacheService.purgeBrowserCache("Layout added/ updated", this.communityId);
setTimeout(() => {
this.subscriptions.push(this.layoutService.createCSS(this.communityId,this.properties.connectPortalUrl, this.publishedLayout.date.valueOf(), this.publishedLayout.layoutOptions).subscribe(data => {
console.log(data)
this.initializeCustomizationOptions(JSON.stringify(this.publishedCustomizationOptions) != this.previewCustomization); this.initializeCustomizationOptions(JSON.stringify(this.publishedCustomizationOptions) != this.previewCustomization);
}, 4000);
this.deleteOldImages(); this.deleteOldImages();
UIkit.notification("Customizations was successfully saved!", { UIkit.notification("Customizations was successfully saved!", {
status: 'success', status: 'success',
@ -240,7 +240,7 @@ sidebarItems = [{name:"Identity", id : "identity", icon: "desktop_windows" },
setTimeout(() => { setTimeout(() => {
this.previewUrl = this.getCommunityUrlSatinized(this.communityId + prefix); this.previewUrl = this.getCommunityUrlSatinized(this.communityId + prefix);
}, 1500); }, 4000);
}, error => { }, error => {