From 9acc5facb44b317413c11b3fcf8e23757d22077c Mon Sep 17 00:00:00 2001 From: ozgur Date: Mon, 20 Nov 2023 00:26:46 +0000 Subject: [PATCH] fix(url and interceptor): request urls are fixed. --- .../study/files/files.component.html | 6 +++ .../components/study/files/files.component.ts | 9 ++-- .../study/files/rsync/rsync.component.ts | 48 +++++++++---------- .../interceptors/header.interceptor.ts | 10 ++-- .../metabolights/metabolights.service.ts | 12 ++++- 5 files changed, 49 insertions(+), 36 deletions(-) diff --git a/src/app/components/study/files/files.component.html b/src/app/components/study/files/files.component.html index cff45ff8..2da19786 100644 --- a/src/app/components/study/files/files.component.html +++ b/src/app/components/study/files/files.component.html @@ -35,6 +35,12 @@ + + refresh FTP Folder Status + { if (value !== null) { this.isReadOnly = value; - if (this.isReadOnly !== null && this.isReadOnly === false){ - this.loadAccess(); - } } }); this.studyStatus.subscribe((value) => { @@ -116,7 +113,11 @@ export class FilesComponent implements OnInit, OnDestroy, OnChanges { } }); } - + getFolderStatus(){ + if (this.isReadOnly !== null && this.isReadOnly === false){ + this.loadAccess(); + } + } changeforceMetaDataDeleteValue(event) { this.forceMetaDataDelete = event.currentTarget.checked; } diff --git a/src/app/components/study/files/rsync/rsync.component.ts b/src/app/components/study/files/rsync/rsync.component.ts index 75896bc4..4322ba0a 100644 --- a/src/app/components/study/files/rsync/rsync.component.ts +++ b/src/app/components/study/files/rsync/rsync.component.ts @@ -71,30 +71,30 @@ export class RsyncComponent implements OnInit { dry_run: true }; this.updateLastRsyncResponse(initialResponse); - this.ftpService.getRyncStatus(true, this.syncType, this.targetStagingArea).subscribe(dryRunResponse => { - this.ftpService.getRyncStatus(false, this.syncType, this.targetStagingArea).subscribe(syncResponse => { - this.serverReady = true; - if (this.RUNNING_STATES.includes(syncResponse.status)) { - this.currentMode = this.rsyncMode.sync; - this.startRsync(false, this.syncType, this.targetStagingArea); - } else if (this.RUNNING_STATES.includes(dryRunResponse.status)){ - this.currentMode = this.rsyncMode.dryRun; - this.startRsync(true, this.syncType, this.targetStagingArea); - } else if (this.RESULT_READY_STATES.includes(syncResponse.status)){ - this.updateLastRsyncResponse(syncResponse); - } else if (this.RESULT_READY_STATES.includes(dryRunResponse.status)){ - this.updateLastRsyncResponse(dryRunResponse); - } else if (this.DONE_STATES.includes(syncResponse.status)){ - this.updateLastRsyncResponse(syncResponse); - } else if (this.DONE_STATES.includes(dryRunResponse.status)){ - this.updateLastRsyncResponse(dryRunResponse); - } else { - if (this.lastResponse.task_done_timestamp > 0) { - this.updateLastRsyncResponse(this.lastResponse); - } - } - }); - }); + // this.ftpService.getRyncStatus(true, this.syncType, this.targetStagingArea).subscribe(dryRunResponse => { + // this.ftpService.getRyncStatus(false, this.syncType, this.targetStagingArea).subscribe(syncResponse => { + // this.serverReady = true; + // if (this.RUNNING_STATES.includes(syncResponse.status)) { + // this.currentMode = this.rsyncMode.sync; + // this.startRsync(false, this.syncType, this.targetStagingArea); + // } else if (this.RUNNING_STATES.includes(dryRunResponse.status)){ + // this.currentMode = this.rsyncMode.dryRun; + // this.startRsync(true, this.syncType, this.targetStagingArea); + // } else if (this.RESULT_READY_STATES.includes(syncResponse.status)){ + // this.updateLastRsyncResponse(syncResponse); + // } else if (this.RESULT_READY_STATES.includes(dryRunResponse.status)){ + // this.updateLastRsyncResponse(dryRunResponse); + // } else if (this.DONE_STATES.includes(syncResponse.status)){ + // this.updateLastRsyncResponse(syncResponse); + // } else if (this.DONE_STATES.includes(dryRunResponse.status)){ + // this.updateLastRsyncResponse(dryRunResponse); + // } else { + // if (this.lastResponse.task_done_timestamp > 0) { + // this.updateLastRsyncResponse(this.lastResponse); + // } + // } + // }); + // }); } startRsync(dryRun: boolean=false, syncType: string, targetStagingArea: string): void { diff --git a/src/app/services/interceptors/header.interceptor.ts b/src/app/services/interceptors/header.interceptor.ts index 921289f1..af0ca532 100644 --- a/src/app/services/interceptors/header.interceptor.ts +++ b/src/app/services/interceptors/header.interceptor.ts @@ -19,14 +19,11 @@ export class HeaderInterceptor implements HttpInterceptor { request: HttpRequest, next: HttpHandler ): Observable> { - const domain = this.configService?.config?.metabolightsWSURL?.domain; + const endpoint = this.configService?.config?.endpoint; const origin = this.configService.config?.origin; const targetUrl = origin + request.url ; - if (request.url == null || (!targetUrl.startsWith(domain) && !request.url.startsWith(domain))){ - return next.handle(request); - } - - let userToken = localStorage.getItem("userToken"); + if (request.url.startsWith(endpoint) || targetUrl.startsWith(endpoint)){ + let userToken = localStorage.getItem("userToken"); if(userToken === null) { const user = localStorage.getItem("user"); if ( user !== null) { @@ -67,6 +64,7 @@ export class HeaderInterceptor implements HttpInterceptor { }); } } + } return next.handle(request); } diff --git a/src/app/services/metabolights/metabolights.service.ts b/src/app/services/metabolights/metabolights.service.ts index 70323f5a..ec3d9f98 100644 --- a/src/app/services/metabolights/metabolights.service.ts +++ b/src/app/services/metabolights/metabolights.service.ts @@ -168,8 +168,12 @@ export class MetabolightsService extends DataService { // Study validation details getGuides(language) { + let url = this.url.guides; + if (this.url.guides.endsWith("/") === false){ + url = this.url.guides + "/"; + } return this.http - .get(this.url.guides + "I10n/" + language + ".json") + .get(url + "I10n/" + language + ".json") .pipe(catchError(this.handleError)); } @@ -575,8 +579,12 @@ export class MetabolightsService extends DataService { * @returns The ontology details via the Observable. */ getOntologyDetails(value): Observable { + let ontologyUrl = this.url.ontologyDetails; + if (ontologyUrl.endsWith("/") === false){ + ontologyUrl = ontologyUrl + "/"; + } const url = - this.url.ontologyDetails + + ontologyUrl + value.termSource.name + "/terms/" + encodeURI(encodeURIComponent(value.termAccession));