From 27d7c7c118a363c2db3deb8ee13ff8801ebed3a8 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 11 Aug 2022 12:58:20 +0300 Subject: [PATCH] [Connect Admin | Library | new-theme]: Added call to purge browser cache when updating content of community. 1. env-properties.ts & environments/: Added property "deleteBrowserCacheUrl". 2. clear-cache.service.ts: Added method "purgeBrowserCache()" to purge browser cache for a specific community. 3. entities.component.ts & menu.component.ts & pages.component.ts & affiliations.component.ts & edit-community.component.ts add-content-providers.component.ts & remove-content-providers.component.ts & add-projects.component.ts & remove-projects.component.ts & subjects-edit-form.component.ts & personal-info.component.ts & customization.component.ts: Call "_clearCacheService.purgeBrowserCache()" when adding/updating/deleting content of a specific community. 4. connect-admin-customization.module.ts: Added CommunitiesService in providers. 5. connect-admin-customization.component.ts: Added button to purge browser cache for all communities and connect. --- dashboard/entity/entities.component.ts | 4 ++++ dashboard/menu/menu.component.ts | 6 ++++++ dashboard/page/pages.component.ts | 4 ++++ services/clear-cache.service.ts | 10 ++++++++++ utils/properties/env-properties.ts | 1 + 5 files changed, 25 insertions(+) diff --git a/dashboard/entity/entities.component.ts b/dashboard/entity/entities.component.ts index 77f02a29..89a184e8 100644 --- a/dashboard/entity/entities.component.ts +++ b/dashboard/entity/entities.component.ts @@ -203,6 +203,7 @@ export class EntitiesComponent implements OnInit { NotificationHandler.rise('Entities have been successfully deleted'); this.showLoading = false; this._clearCacheService.clearCache("entities deleted"); + this._clearCacheService.purgeBrowserCache("entities deleted", this.portal); }, error => this.handleUpdateError('System error deleting the selected entities', error) ); @@ -244,6 +245,7 @@ export class EntitiesComponent implements OnInit { this.entityUpdatedSuccessfully(entity); NotificationHandler.rise('Entity ' + entity.name + ' has been successfully updated'); this._clearCacheService.clearCache("entity updated"); + this._clearCacheService.purgeBrowserCache("entity updated", this.portal); }, error => this.handleUpdateError('System error updating entity', error) ); @@ -253,6 +255,7 @@ export class EntitiesComponent implements OnInit { this.entitySavedSuccessfully(entity); NotificationHandler.rise('Entity ' + entity.name + ' has been successfully created'); this._clearCacheService.clearCache("entity saved"); + this._clearCacheService.purgeBrowserCache("entity saved", this.portal) }, error => this.handleUpdateError('System error creating entity', error) ); @@ -343,6 +346,7 @@ export class EntitiesComponent implements OnInit { } this.applyCheck(false); this._clearCacheService.clearCache("entity's status changed"); + this._clearCacheService.purgeBrowserCache("entity's status changed", this.portal); }, error => this.handleUpdateError('System error changing the status of the selected entity(-ies)', error) ); diff --git a/dashboard/menu/menu.component.ts b/dashboard/menu/menu.component.ts index 186f77b7..8991429f 100644 --- a/dashboard/menu/menu.component.ts +++ b/dashboard/menu/menu.component.ts @@ -265,6 +265,7 @@ export class MenuComponent implements OnInit { NotificationHandler.rise("Menu item have been successfully deleted"); this.showLoading = false; this._clearCacheService.clearCache("Menu item deleted"); + this._clearCacheService.purgeBrowserCache("Menu item deleted", this.portal); }, error => this.handleError("Server error deleting menu item", error) ) @@ -306,6 +307,7 @@ export class MenuComponent implements OnInit { this.menuItemSavedSuccessfully(menuItem, true); NotificationHandler.rise('Menu item ' + menuItem.title + ' has been successfully created'); this._clearCacheService.clearCache("Menu item saved"); + this._clearCacheService.purgeBrowserCache("Menu item saved", this.portal); }, error => this.handleError("System error creating menu item", error) ) @@ -317,6 +319,7 @@ export class MenuComponent implements OnInit { this.menuItemSavedSuccessfully(menuItem, false); NotificationHandler.rise('Menu item ' + menuItem.title + ' has been successfully updated'); this._clearCacheService.clearCache("Menu item updated"); + this._clearCacheService.purgeBrowserCache("Menu item updated", this.portal); }, error => this.handleError("System error updating menu item", error) ) @@ -383,6 +386,7 @@ export class MenuComponent implements OnInit { this._helpContentService.reorderMenuItems(temp, this.portal).subscribe(() => { HelperFunctions.swap(this.featuredMenuItems, index, newIndex); this._clearCacheService.clearCache("Menu items reordered"); + this._clearCacheService.purgeBrowserCache("Menu items reordered", this.portal); }, error => { this.handleError("System error reordering menu items", error); }); @@ -395,6 +399,7 @@ export class MenuComponent implements OnInit { this._helpContentService.reorderMenuItems(temp, this.portal).subscribe(() => { HelperFunctions.swap(children && children.length ? children : this.normalMenuItems, index, newIndex); this._clearCacheService.clearCache("Menu items reordered"); + this._clearCacheService.purgeBrowserCache("Menu items reordered", this.portal); }, error => { this.handleError("System error reordering menu items", error); }); @@ -410,6 +415,7 @@ export class MenuComponent implements OnInit { this.showNormalMenu = status; } this._clearCacheService.clearCache("Menu toggled"); + this._clearCacheService.purgeBrowserCache("Menu toggled", this.portal); }, error => { this.handleError("System error toggling menu", error); }) diff --git a/dashboard/page/pages.component.ts b/dashboard/page/pages.component.ts index 4e328d18..15e55350 100644 --- a/dashboard/page/pages.component.ts +++ b/dashboard/page/pages.component.ts @@ -250,6 +250,7 @@ export class PagesComponent implements OnInit { NotificationHandler.rise('Pages have been successfully deleted'); this.showLoading = false; this._clearCacheService.clearCache("Pages deleted"); + this._clearCacheService.purgeBrowserCache("Pages deleted", this.portal); }, error => this.handleUpdateError('System error deleting the selected pages', error) )); @@ -317,6 +318,7 @@ export class PagesComponent implements OnInit { this.pageSavedSuccessfully(page, true); NotificationHandler.rise('Page ' + page.name + ' has been successfully created'); this._clearCacheService.clearCache("Page saved"); + this._clearCacheService.purgeBrowserCache("Page saved", this.portal); }, error => this.handleUpdateError('System error creating page', error) )); @@ -326,6 +328,7 @@ export class PagesComponent implements OnInit { this.pageSavedSuccessfully(page, false); NotificationHandler.rise('Page ' + page.name + ' has been successfully updated'); this._clearCacheService.clearCache("Page updated"); + this._clearCacheService.purgeBrowserCache("Page updated", this.portal); }, error => this.handleUpdateError('System error updating page', error) )); @@ -410,6 +413,7 @@ export class PagesComponent implements OnInit { } this.applyCheck(false); this._clearCacheService.clearCache("Page's status changed"); + this._clearCacheService.purgeBrowserCache("Page's status changed", this.portal); }, error => this.handleUpdateError('System error changing the status of the selected page(s)', error) )); diff --git a/services/clear-cache.service.ts b/services/clear-cache.service.ts index 98458ab9..1e1c39f4 100644 --- a/services/clear-cache.service.ts +++ b/services/clear-cache.service.ts @@ -17,4 +17,14 @@ export class ClearCacheService { ); } } + + purgeBrowserCache(message: string = null, pid: string) { + if(properties.deleteBrowserCacheUrl) { + let url = properties.deleteBrowserCacheUrl.replace("{pid}", pid); + this.http.get(url).subscribe( + res => console.log((message ? message + ": " : "") + "Browser Cache purged!"), + err => console.log((message ? message + ": " : "") + "Browser Cache could not be purged ", err) + ); + } + } } diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index 302c00cb..520e3dca 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -69,6 +69,7 @@ export interface EnvProperties { feedbackmailForMissingEntities?: string; cacheUrl?: string; deleteCacheUrl?: string; + deleteBrowserCacheUrl?: string; monitorServiceAPIURL?: string; adminToolsAPIURL?: string; adminToolsCommunity?: string;