From 8eba807906cc665c9b2cab87d8b9ed37640cccac Mon Sep 17 00:00:00 2001 From: argirok Date: Wed, 27 Mar 2024 09:29:07 +0200 Subject: [PATCH] [pluginsFunctionality | DONE | CHANGED] add property forceCacheReload, for requests that pass from cache (useLongCache=true) check and pass forceReload parameter, get from cache plugin requests --- services/plugins.service.ts | 10 ++++------ utils/configuration/configuration.service.ts | 3 ++- utils/helper/helper.service.ts | 7 ++++--- utils/properties/env-properties.ts | 3 +++ utils/properties/environments/environment.ts | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/services/plugins.service.ts b/services/plugins.service.ts index 98552d0d..3e7dafee 100644 --- a/services/plugins.service.ts +++ b/services/plugins.service.ts @@ -51,13 +51,11 @@ export class PluginsService { return this.http.get>(api + properties.adminToolsPortalType + '/' + pid + '/pluginTemplates/page/' + pageId); } getPluginsByPageRoute(api:string, pid:string, route:string){ - return this.http.get>(api + 'community/' +pid+'/plugins/page/route?route=' + route); + let url = api + 'community/' +pid+'/plugins/page/route?route=' + route; + return this.http.get>((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url) + (properties.forceCacheReload?'&forceReload=true':'')) : url); } getPluginTemplatesByPageRoute(api:string, pid:string, route:string){ - return this.http.get>(api + 'community/' +pid+'/pluginTemplates/page/route?route=' + route); - } - - togglePlugin(id: string, status: boolean, api: string) { - return this.http.post(api + 'plugin/status/' + id, status, CustomOptions.getAuthOptionsWithBody()); + let url = api + 'community/' + pid + '/pluginTemplates/page/route?route=' + route; + return this.http.get>((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url) + (properties.forceCacheReload?'&forceReload=true':'')) : url); } } diff --git a/utils/configuration/configuration.service.ts b/utils/configuration/configuration.service.ts index 6d50c4dc..ad3bfff6 100644 --- a/utils/configuration/configuration.service.ts +++ b/utils/configuration/configuration.service.ts @@ -5,6 +5,7 @@ import {EnvProperties} from "../properties/env-properties"; import {Portal} from "../entities/adminTool/portal"; import {Page} from "../entities/adminTool/page"; import {AdvancedAsyncSubject} from "../AdvancedAsyncSubject"; +import {properties} from "../../../../environments/environment"; @Injectable({providedIn: 'root'}) export class ConfigurationService { @@ -36,7 +37,7 @@ export class ConfigurationService { if (pid == null || this.portal?.getValue()?.static) return; let url = properties.adminToolsAPIURL + "/" + properties.adminToolsPortalType + "/" + pid + "/full"; this.promise = new Promise(resolve => { - this.sub = this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url).subscribe( + this.sub = this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url) + (properties.forceCacheReload?'&forceReload=true':'')) : url).subscribe( (portal: Portal) => { this.portal.next(portal); resolve(); diff --git a/utils/helper/helper.service.ts b/utils/helper/helper.service.ts index f263aed1..ba7a88b0 100644 --- a/utils/helper/helper.service.ts +++ b/utils/helper/helper.service.ts @@ -4,6 +4,7 @@ import {HttpClient} from "@angular/common/http"; import {EnvProperties} from '../properties/env-properties'; import {of} from "rxjs"; +import {properties} from "../../../../environments/environment"; @Injectable() export class HelperService { @@ -25,7 +26,7 @@ export class HelperService { } } - return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url); + return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)+ (properties.forceCacheReload?'&forceReload=true':'')): url); //.map(res => res.json()); } @@ -42,7 +43,7 @@ export class HelperService { let url = properties.adminToolsAPIURL; url += '/' + portalType + '/' + portal + '/pagehelpcontent/grouped?active=true&page=' + ((page_route.indexOf("/"+portal+"/")!=-1 ) ? ("/" + page_route.split("/"+portal+"/")[1]) : page_route); - return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url); + return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)+ (properties.forceCacheReload?'&forceReload=true':'')) : url); }else { return of(null); } @@ -60,7 +61,7 @@ export class HelperService { let url = properties.adminToolsAPIURL; url += '/'+properties.adminToolsPortalType+'/' + communityId + '/divhelpcontent/grouped?active=true&page='+ ((page_route.indexOf("/"+communityId+"/")!=-1 ) ? ("/" + page_route.split("/"+communityId+"/")[1]) : page_route); - return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url); + return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)+ (properties.forceCacheReload?'&forceReload=true':'')): url); }else { return of(null); } diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index f740381d..6f3e2864 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -156,6 +156,9 @@ export interface EnvProperties { zenodoDumpUrl?:string; openOrgsUrl?:string; orcidDiscoverLinksPage?:string; + + //connect dashboards + forceCacheReload?:boolean; } export function checkPropertyValues(properties:EnvProperties){ diff --git a/utils/properties/environments/environment.ts b/utils/properties/environments/environment.ts index fb86e5d4..8ee7c15b 100644 --- a/utils/properties/environments/environment.ts +++ b/utils/properties/environments/environment.ts @@ -115,7 +115,7 @@ export let commonDev: EnvProperties = { loginServiceURL: "http://mpagasas.di.uoa.gr:19080/login-service/", cookieDomain: ".di.uoa.gr", feedbackmail: "kostis30fylloy@gmail.com", - cacheUrl: "http://dl170.madgik.di.uoa.gr:3000/get?url=", + cacheUrl: "http://scoobydoo.di.uoa.gr:3200/get?url=", monitorServiceAPIURL: "http://duffy.di.uoa.gr:19380/uoa-monitor-service", adminToolsAPIURL: "http://duffy.di.uoa.gr:19280/uoa-admin-tools/", datasourcesAPI: "https://beta.services.openaire.eu/openaire/ds/api/",