[Library | data-transfer-v2]: transferData.component: Get destinationOptions from API (/storage/types).

This commit is contained in:
Konstantina Galouni 2023-01-05 19:14:26 +02:00
parent 161052d97c
commit 3c20944aec
2 changed files with 21 additions and 12 deletions

View File

@ -43,7 +43,7 @@
</div>
</div>
<!-- Destination -->
<div class="destination">
<div *ngIf="destinationOptions" class="destination">
<!-- -->
Testing:<br>
https://dcache-demo.desy.de:2443

View File

@ -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<any>) => {
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";