Skip to content

Commit

Permalink
fix(url and interceptor): request urls are fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
oyurekten committed Nov 20, 2023
1 parent 767dc27 commit 9acc5fa
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 36 deletions.
6 changes: 6 additions & 0 deletions src/app/components/study/files/files.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
</span>

<span *ngIf="!isReadOnly && curator" class="is-pulled-right">
<a *ngIf="access == null"
(click)="getFolderStatus()"
class="button is-light"
>
<mat-icon>refresh</mat-icon> <small>FTP Folder Status</small>
</a>
<a
*ngIf="access == 'Read'"
(click)="toggleFolderAccess()"
Expand Down
9 changes: 5 additions & 4 deletions src/app/components/study/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ export class FilesComponent implements OnInit, OnDestroy, OnChanges {
this.readonly.subscribe((value) => {
if (value !== null) {
this.isReadOnly = value;
if (this.isReadOnly !== null && this.isReadOnly === false){
this.loadAccess();
}
}
});
this.studyStatus.subscribe((value) => {
Expand All @@ -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;
}
Expand Down
48 changes: 24 additions & 24 deletions src/app/components/study/files/rsync/rsync.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 4 additions & 6 deletions src/app/services/interceptors/header.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ export class HeaderInterceptor implements HttpInterceptor {
request: HttpRequest<unknown>,
next: HttpHandler
): Observable<HttpEvent<unknown>> {
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) {
Expand Down Expand Up @@ -67,6 +64,7 @@ export class HeaderInterceptor implements HttpInterceptor {
});
}
}
}
return next.handle(request);
}

Expand Down
12 changes: 10 additions & 2 deletions src/app/services/metabolights/metabolights.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -575,8 +579,12 @@ export class MetabolightsService extends DataService {
* @returns The ontology details via the Observable.
*/
getOntologyDetails(value): Observable<any> {
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));
Expand Down

0 comments on commit 9acc5fa

Please sign in to comment.