[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>
</div> </div>
<!-- Destination --> <!-- Destination -->
<div class="destination"> <div *ngIf="destinationOptions" class="destination">
<!-- --> <!-- -->
Testing:<br> Testing:<br>
https://dcache-demo.desy.de:2443 https://dcache-demo.desy.de:2443

View File

@ -43,14 +43,14 @@ export class EGIDataTransferComponent {
destinationAuthUser = ""; destinationAuthUser = "";
destinationAuthPass = ""; destinationAuthPass = "";
destinationPath = ""; 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', selectedDestination:{ kind: string, destination: string, description: string, authType: 'token' | 'password' | 'keys',
canBrowse: boolean, transferWith: string} = null; canBrowse: boolean, transferWith: string} = null;
folders = {}; folders = {};
files = {}; files = {};
downloadElements = null; downloadElements = null;
@Input() isOpen = false; @Input() isOpen = false;
@Input() selectedDestinationId = "dcache"; // @Input() selectedDestinationId = "dcache";
@ViewChild('egiTransferModal') egiTransferModal; @ViewChild('egiTransferModal') egiTransferModal;
APIURL = properties.eoscDataTransferAPI; APIURL = properties.eoscDataTransferAPI;
status: "loading" | "success" | "errorParser" | "errorUser" | "errorTransfer" | "init" | "canceled" = "init"; status: "loading" | "success" | "errorParser" | "errorUser" | "errorTransfer" | "init" | "canceled" = "init";
@ -82,15 +82,24 @@ export class EGIDataTransferComponent {
open(){ open(){
this.accessToken = COOKIE.getCookie("EGIAccessToken"); this.accessToken = COOKIE.getCookie("EGIAccessToken");
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.destination) { // if (this.selectedDestinationId == option.value.destination) {
this.selectedDestination = option.value; // this.selectedDestination = option.value;
} // }
} // }
} else { // } else {
this.selectedDestination = this.destinationOptions[0].value; // 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];
} }
));
for (let doi of this.dois) { for (let doi of this.dois) {
this.sourceUrls.push(this.doiPrefix + doi); this.sourceUrls.push(this.doiPrefix + doi);
@ -129,7 +138,7 @@ export class EGIDataTransferComponent {
} }
init(){ init(){
this.destinationPath = ""; this.destinationPath = "";
this.selectedDestination = this.destinationOptions[0].value; // this.selectedDestination = this.destinationOptions[0].value;
this.selectedSourceUrl = this.sourceUrls[0]; this.selectedSourceUrl = this.sourceUrls[0];
this.message = null; this.message = null;
this.status = "init"; this.status = "init";