[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>
<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
authentication if needed:</p>
<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') "
class=""></div>
<div input [(value)]="destinationAuthPass" [placeholder]="'Give ' + (selectedDestination.auth ==
<div input [(value)]="destinationAuthPass" [placeholder]="'Give ' + (selectedDestination.authType ==
'password'? 'password':'secret key') "
class=""></div>
</div>
@ -87,7 +87,7 @@
</div>
<!-- </div>-->
<ng-container *ngIf="selectedDestination.id == 'ftp'">
<ng-container *ngIf="selectedDestination.destination == 'ftp'">
<p>Comming soon!</p>
</ng-container>

View File

@ -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 = `
<!--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" >
<ul>
`;
@ -264,7 +265,7 @@ export class EGIDataTransferComponent {
this.jobStatus = res;
this.message = `
<!--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" >
<ul>
`;
@ -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);
}