[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.

This commit is contained in:
Konstantina Galouni 2023-01-04 13:27:49 +02:00
parent 7666b55b6c
commit 50543311f2
2 changed files with 17 additions and 16 deletions

View File

@ -62,14 +62,14 @@
[validators]="URLValidators" class=""></div> [validators]="URLValidators" class=""></div>
<ng-container <ng-container
*ngIf="selectedDestination.auth == 'password' || selectedDestination.auth == 'keys'"> *ngIf="selectedDestination.authType == 'password' || selectedDestination.authType == 'keys'">
<p class="uk-text-meta uk-text-xsmall uk-margin-remove-bottom uk-margin-top">Provide <p class="uk-text-meta uk-text-xsmall uk-margin-remove-bottom uk-margin-top">Provide
authentication if needed:</p> authentication if needed:</p>
<div class="uk-grid uk-child-width-1-2"> <div class="uk-grid uk-child-width-1-2">
<div input [(value)]="destinationAuthUser" [placeholder]="'Give ' + (selectedDestination.auth == <div input [(value)]="destinationAuthUser" [placeholder]="'Give ' + (selectedDestination.authType ==
'password'? 'username':'access key') " 'password'? 'username':'access key') "
class=""></div> class=""></div>
<div input [(value)]="destinationAuthPass" [placeholder]="'Give ' + (selectedDestination.auth == <div input [(value)]="destinationAuthPass" [placeholder]="'Give ' + (selectedDestination.authType ==
'password'? 'password':'secret key') " 'password'? 'password':'secret key') "
class=""></div> class=""></div>
</div> </div>
@ -87,7 +87,7 @@
</div> </div>
<!-- </div>--> <!-- </div>-->
<ng-container *ngIf="selectedDestination.id == 'ftp'"> <ng-container *ngIf="selectedDestination.destination == 'ftp'">
<p>Comming soon!</p> <p>Comming soon!</p>
</ng-container> </ng-container>

View File

@ -43,8 +43,9 @@ export class EGIDataTransferComponent {
destinationAuthUser = ""; destinationAuthUser = "";
destinationAuthPass = ""; destinationAuthPass = "";
destinationPath = ""; destinationPath = "";
destinationOptions = properties.eoscDataTransferDestinations; destinationOptions = properties.eoscDataTransferDestinations.map(dest => {return {"label": dest.destination, "value": dest}});
selectedDestination:{label :string, id: string, auth: 'token' | 'password' | 'keys'} = null; selectedDestination:{ kind: string, destination: string, description: string, authType: 'token' | 'password' | 'keys',
canBrowse: boolean, transferWith: string} = null;
folders = {}; folders = {};
files = {}; files = {};
downloadElements = null; downloadElements = null;
@ -83,7 +84,7 @@ export class EGIDataTransferComponent {
if(this.accessToken) { if(this.accessToken) {
if (this.selectedDestinationId) { if (this.selectedDestinationId) {
for (let option of this.destinationOptions) { for (let option of this.destinationOptions) {
if (this.selectedDestinationId == option.value.id) { if (this.selectedDestinationId == option.value.destination) {
this.selectedDestination = option.value; this.selectedDestination = option.value;
} }
} }
@ -167,7 +168,7 @@ export class EGIDataTransferComponent {
// console.log(this.selectedDestination) // console.log(this.selectedDestination)
this.status = "loading"; this.status = "loading";
let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); 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 => { res => {
// console.log(res) // console.log(res)
let body = { let body = {
@ -193,7 +194,7 @@ export class EGIDataTransferComponent {
} }
let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); 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, headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken,
'Authorization-Storage': btoa(this.destinationAuthUser + ':' + this.destinationAuthPass)}); 'Authorization-Storage': btoa(this.destinationAuthUser + ':' + this.destinationAuthPass)});
} }
@ -210,7 +211,7 @@ export class EGIDataTransferComponent {
this.egiTransferModal.okButton = false; this.egiTransferModal.okButton = false;
this.message = ` this.message = `
<!--div class="uk-text-large uk-margin-bottom">Data transfer has began!</div--> <!--div class="uk-text-large uk-margin-bottom">Data transfer has began!</div-->
<div>Transfer of ` + this.downloadElements.length + ` files to `+this.selectedDestination.label+` has began.`; <div>Transfer of ` + this.downloadElements.length + ` files to `+this.selectedDestination.description+` has began.`;
/*this.message += ` <div class=" uk-overflow-auto uk-height-xsmall" > /*this.message += ` <div class=" uk-overflow-auto uk-height-xsmall" >
<ul> <ul>
`; `;
@ -264,7 +265,7 @@ export class EGIDataTransferComponent {
this.jobStatus = res; this.jobStatus = res;
this.message = ` this.message = `
<!--div class="uk-text-large uk-margin-bottom">Data transfer has began!</div--> <!--div class="uk-text-large uk-margin-bottom">Data transfer has began!</div-->
<div>Transfer of ` + this.downloadElements.length + ` files to ` + this.selectedDestination.label+` has began.`; <div>Transfer of ` + this.downloadElements.length + ` files to ` + this.selectedDestination.description+` has began.`;
/*this.message += ` <div class=" uk-overflow-auto uk-height-xsmall" > /*this.message += ` <div class=" uk-overflow-auto uk-height-xsmall" >
<ul> <ul>
`; `;
@ -322,7 +323,7 @@ export class EGIDataTransferComponent {
} }
hasBrowse(){ hasBrowse(){
let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); 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 => { res => {
console.log(res); console.log(res);
} }
@ -332,7 +333,7 @@ export class EGIDataTransferComponent {
getFolder(folderPath){ getFolder(folderPath){
//TODO is this necessary? //TODO is this necessary?
let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); 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 => { res => {
this.folders[folderPath]= res; this.folders[folderPath]= res;
this.folders[folderPath]['isOpen'] = true; this.folders[folderPath]['isOpen'] = true;
@ -347,7 +348,7 @@ export class EGIDataTransferComponent {
} }
this.getFolder(folderPath); this.getFolder(folderPath);
let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); 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 => { res => {
this.files[folderPath]= res['elements']; this.files[folderPath]= res['elements'];
} }
@ -356,7 +357,7 @@ export class EGIDataTransferComponent {
} }
createFolder(){ createFolder(){
let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); 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( encodeURIComponent(this.destinationUrl + this.destinationPath + "test1/") , {headers: headers}).subscribe(
res => { res => {
console.log(res); console.log(res);
@ -367,7 +368,7 @@ export class EGIDataTransferComponent {
deleteFolder(){ deleteFolder(){
let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); 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 => { res => {
console.log(res); console.log(res);
} }