From 50543311f2186435abd77c92ab920b7e37d710da Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 4 Jan 2023 13:27:49 +0200 Subject: [PATCH] [Eosc Explore & Library | data-transfer-v2]: environment.ts: Updated eoscDataTransferDestinations to be like api response. | transferData.component: Updated destinationOptions and selectedDestination according to the updated eoscDataTransferDestinations. --- .../dataTransfer/transferData.component.html | 8 +++--- utils/dataTransfer/transferData.component.ts | 25 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/utils/dataTransfer/transferData.component.html b/utils/dataTransfer/transferData.component.html index 6e835e1b..5ebc6e2a 100644 --- a/utils/dataTransfer/transferData.component.html +++ b/utils/dataTransfer/transferData.component.html @@ -62,14 +62,14 @@ [validators]="URLValidators" class=""> + *ngIf="selectedDestination.authType == 'password' || selectedDestination.authType == 'keys'">

Provide authentication if needed:

-
-
@@ -87,7 +87,7 @@ - +

Comming soon!

diff --git a/utils/dataTransfer/transferData.component.ts b/utils/dataTransfer/transferData.component.ts index eacaa5aa..8bd841d9 100644 --- a/utils/dataTransfer/transferData.component.ts +++ b/utils/dataTransfer/transferData.component.ts @@ -43,8 +43,9 @@ export class EGIDataTransferComponent { destinationAuthUser = ""; destinationAuthPass = ""; destinationPath = ""; - destinationOptions = properties.eoscDataTransferDestinations; - selectedDestination:{label :string, id: string, auth: 'token' | 'password' | 'keys'} = null; + destinationOptions = 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; @@ -83,7 +84,7 @@ export class EGIDataTransferComponent { if(this.accessToken) { if (this.selectedDestinationId) { for (let option of this.destinationOptions) { - if (this.selectedDestinationId == option.value.id) { + if (this.selectedDestinationId == option.value.destination) { this.selectedDestination = option.value; } } @@ -167,7 +168,7 @@ export class EGIDataTransferComponent { // console.log(this.selectedDestination) this.status = "loading"; let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); - this.subscriptions.push(this.http.get(this.APIURL + "/user/info?dest="+this.selectedDestination.id, {headers: headers}).subscribe( + this.subscriptions.push(this.http.get(this.APIURL + "/user/info?dest="+this.selectedDestination.destination, {headers: headers}).subscribe( res => { // console.log(res) let body = { @@ -193,7 +194,7 @@ export class EGIDataTransferComponent { } let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); - if(this.selectedDestination.auth != "token" && this.destinationAuthPass.length > 0 && this.destinationAuthUser.length > 0){ + if(this.selectedDestination.authType != "token" && this.destinationAuthPass.length > 0 && this.destinationAuthUser.length > 0){ headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken, 'Authorization-Storage': btoa(this.destinationAuthUser + ':' + this.destinationAuthPass)}); } @@ -210,7 +211,7 @@ export class EGIDataTransferComponent { this.egiTransferModal.okButton = false; this.message = ` -
Transfer of ` + this.downloadElements.length + ` files to `+this.selectedDestination.label+` has began.`; +
Transfer of ` + this.downloadElements.length + ` files to `+this.selectedDestination.description+` has began.`; /*this.message += `
    `; @@ -264,7 +265,7 @@ export class EGIDataTransferComponent { this.jobStatus = res; this.message = ` -
    Transfer of ` + this.downloadElements.length + ` files to ` + this.selectedDestination.label+` has began.`; +
    Transfer of ` + this.downloadElements.length + ` files to ` + this.selectedDestination.description+` has began.`; /*this.message += `
      `; @@ -322,7 +323,7 @@ export class EGIDataTransferComponent { } hasBrowse(){ let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); - this.subscriptions.push(this.http.get(this.APIURL + "/storage/info?dest="+this.selectedDestination.id+"&seUrl="+encodeURIComponent(this.destinationUrl + this.destinationPath) , {headers: headers}).subscribe( + this.subscriptions.push(this.http.get(this.APIURL + "/storage/info?dest="+this.selectedDestination.destination+"&seUrl="+encodeURIComponent(this.destinationUrl + this.destinationPath) , {headers: headers}).subscribe( res => { console.log(res); } @@ -332,7 +333,7 @@ export class EGIDataTransferComponent { getFolder(folderPath){ //TODO is this necessary? let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); - this.subscriptions.push(this.http.get(this.APIURL + "/storage/folder?dest="+this.selectedDestination.id+"&seUrl="+encodeURIComponent(this.destinationUrl + folderPath) , {headers: headers}).subscribe( + this.subscriptions.push(this.http.get(this.APIURL + "/storage/folder?dest="+this.selectedDestination.destination+"&seUrl="+encodeURIComponent(this.destinationUrl + folderPath) , {headers: headers}).subscribe( res => { this.folders[folderPath]= res; this.folders[folderPath]['isOpen'] = true; @@ -347,7 +348,7 @@ export class EGIDataTransferComponent { } this.getFolder(folderPath); let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); - this.subscriptions.push(this.http.get(this.APIURL + "/storage/folder/list?dest="+this.selectedDestination.id+"&folderUrl="+encodeURIComponent(this.destinationUrl + folderPath) , {headers: headers}).subscribe( + this.subscriptions.push(this.http.get(this.APIURL + "/storage/folder/list?dest="+this.selectedDestination.destination+"&folderUrl="+encodeURIComponent(this.destinationUrl + folderPath) , {headers: headers}).subscribe( res => { this.files[folderPath]= res['elements']; } @@ -356,7 +357,7 @@ export class EGIDataTransferComponent { } createFolder(){ let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); - this.subscriptions.push(this.http.post(this.APIURL + "/storage/folder?dest="+this.selectedDestination.id+"&seUrl="+ + this.subscriptions.push(this.http.post(this.APIURL + "/storage/folder?dest="+this.selectedDestination.destination+"&seUrl="+ encodeURIComponent(this.destinationUrl + this.destinationPath + "test1/") , {headers: headers}).subscribe( res => { console.log(res); @@ -367,7 +368,7 @@ export class EGIDataTransferComponent { deleteFolder(){ let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); - this.subscriptions.push(this.http.delete(this.APIURL + "/storage/folder?dest="+this.selectedDestination.id+"&seUrl="+encodeURIComponent(this.destinationUrl + this.destinationPath + "test1/") , {headers: headers}).subscribe( + this.subscriptions.push(this.http.delete(this.APIURL + "/storage/folder?dest="+this.selectedDestination.destination+"&seUrl="+encodeURIComponent(this.destinationUrl + this.destinationPath + "test1/") , {headers: headers}).subscribe( res => { console.log(res); }