From 3c20944aec78714d59265b1bfebea91b2cadbbb7 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 5 Jan 2023 19:14:26 +0200 Subject: [PATCH] [Library | data-transfer-v2]: transferData.component: Get destinationOptions from API (/storage/types). --- .../dataTransfer/transferData.component.html | 2 +- utils/dataTransfer/transferData.component.ts | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/utils/dataTransfer/transferData.component.html b/utils/dataTransfer/transferData.component.html index 5ebc6e2a..972da1ae 100644 --- a/utils/dataTransfer/transferData.component.html +++ b/utils/dataTransfer/transferData.component.html @@ -43,7 +43,7 @@ -
+
Testing:
https://dcache-demo.desy.de:2443 diff --git a/utils/dataTransfer/transferData.component.ts b/utils/dataTransfer/transferData.component.ts index 8bd841d9..1070e809 100644 --- a/utils/dataTransfer/transferData.component.ts +++ b/utils/dataTransfer/transferData.component.ts @@ -43,14 +43,14 @@ export class EGIDataTransferComponent { destinationAuthUser = ""; destinationAuthPass = ""; destinationPath = ""; - destinationOptions = properties.eoscDataTransferDestinations.map(dest => {return {"label": dest.destination, "value": dest}}); + destinationOptions = null;//properties.eoscDataTransferDestinations.map(dest => {return {"label": dest.destination, "value": dest}}); selectedDestination:{ kind: string, destination: string, description: string, authType: 'token' | 'password' | 'keys', canBrowse: boolean, transferWith: string} = null; folders = {}; files = {}; downloadElements = null; @Input() isOpen = false; - @Input() selectedDestinationId = "dcache"; + // @Input() selectedDestinationId = "dcache"; @ViewChild('egiTransferModal') egiTransferModal; APIURL = properties.eoscDataTransferAPI; status: "loading" | "success" | "errorParser" | "errorUser" | "errorTransfer" | "init" | "canceled" = "init"; @@ -82,15 +82,24 @@ export class EGIDataTransferComponent { open(){ this.accessToken = COOKIE.getCookie("EGIAccessToken"); if(this.accessToken) { - if (this.selectedDestinationId) { - for (let option of this.destinationOptions) { - if (this.selectedDestinationId == option.value.destination) { - this.selectedDestination = option.value; - } + // if (this.selectedDestinationId) { + // for (let option of this.destinationOptions) { + // if (this.selectedDestinationId == option.value.destination) { + // this.selectedDestination = option.value; + // } + // } + // } else { + // this.selectedDestination = this.destinationOptions[0].value; + // } + + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); + this.subscriptions.push(this.http.get(this.APIURL + "/storage/types", {headers: headers}).subscribe( + (res: Array) => { + this.destinationOptions = res.map(dest => {return {"label": dest.destination, "value": dest}}); + this.selectedDestination = res[0]; } - } else { - this.selectedDestination = this.destinationOptions[0].value; - } + )); + for (let doi of this.dois) { this.sourceUrls.push(this.doiPrefix + doi); @@ -129,7 +138,7 @@ export class EGIDataTransferComponent { } init(){ this.destinationPath = ""; - this.selectedDestination = this.destinationOptions[0].value; + // this.selectedDestination = this.destinationOptions[0].value; this.selectedSourceUrl = this.sourceUrls[0]; this.message = null; this.status = "init";