diff --git a/error-interceptor.service.ts b/error-interceptor.service.ts index d56c557d..1ad66661 100644 --- a/error-interceptor.service.ts +++ b/error-interceptor.service.ts @@ -6,13 +6,11 @@ import {Session} from "./login/utils/helper.class"; import {Router} from "@angular/router"; import {LoginErrorCodes} from "./login/utils/guardHelper.class"; import {properties} from "../../environments/environment"; -import {isArray} from "util"; @Injectable() export class ErrorInterceptorService implements HttpInterceptor { - private static UNAUTHORIZED_WHITELIST = [properties.userInfoUrl, properties.orcidAPIURL, properties.registryUrl + 'verification/']; - + private static UNAUTHORIZED_WHITELIST = [properties.userInfoUrl, properties.orcidAPIURL, properties.registryUrl? (properties.registryUrl + 'verification/'):null, properties.eoscDataTransferAPI].filter(value => !!value); constructor(private router: Router) { } diff --git a/utils/dataTransfer/transferData.component.html b/utils/dataTransfer/transferData.component.html new file mode 100644 index 00000000..af183472 --- /dev/null +++ b/utils/dataTransfer/transferData.component.html @@ -0,0 +1,154 @@ + + + + + + + + + + +
+
+ You have requested to send the data corresponding to the DOI {{selectedSourceUrl.split(doiPrefix)[1]}} to a cloud storage using the EOSC Data Transfer service +
+
+ +
+

Available Zenodo DOI URLs:

+
+
+
{{this.downloadElements.length}} files found:
+
+
    +
  • {{ element.name}} +
  • +
+
+
-
+
+
+ +
+

Please select the Destination Storage type:

+
+
+
+ In order to send data to a Cloud Storage, you would need to be authenticated, please login via EGI check-in. +
+
+ +
+
+ + +

Provide the corresponding storage destination path:

+
+
+

or browse and select the folder

+
+ +
+ +
+
+ +

Comming soon!

+
+
+ +
+
+
+
+ + + +
+
+
+
+ +
+ +
+ + + + +
+
+ + + + + + + + +
+ + {{file['name']}} + {{(file.createdAt?file.createdAt:file.modifiedAt) |date : 'medium'}} +
+
+ + +
+ +
+
diff --git a/utils/dataTransfer/transferData.component.ts b/utils/dataTransfer/transferData.component.ts index cfca8f14..a305267c 100644 --- a/utils/dataTransfer/transferData.component.ts +++ b/utils/dataTransfer/transferData.component.ts @@ -11,110 +11,25 @@ declare var UIkit; @Component({ selector: 'egi-transfer-data', - template: ` - - - - - - - - - -
-
- In order to send data to a Cloud Storage, you would need to be authenticated, please login via EGI check-in. -
-
- -
-
-
-
- You have requested to send the data corresponding to the DOI {{selectedSourceUrl.split(doiPrefix)[1]}} to a cloud storage using the EOSC Data Transfer service -
-
-
-

Available Zenodo DOI URLs:

-
-
-
{{this.downloadElements.length}} files found:
-
-
    -
  • {{ element.name}} -
  • -
-
-
-
-
-
-
-

Please select the Destination Storage type and provide the corresponding storage destination path.

-
-
- - -
-
-
-
- - - -
-
-
-
- -
- -
-
-
- - ` + templateUrl:'./transferData.component.html' }) export class EGIDataTransferComponent { subscriptions = []; - accessToken = null; + accessToken = {}; @Input() dois; loginURL = properties.environment == "development"? "http://rudie.di.uoa.gr:8580/openid_connect_login":"https://explore.eosc-portal.eu/egi-login-service/openid_connect_login" - sourceUrls = [] + sourceUrls = []; selectedSourceUrl = null; - destinationPath = ""; - destinationOptions = [{label: "EGI dCache (dcache-demo.desy.de)", value: {label: "EGI dCache (dcache-demo.desy.de)", url: "https://dcache-demo.desy.de:2443", id: "dcache" , webpage:"https://dcache-demo.desy.de"} }]; + destinationPath = ""; + destinationOptions = properties.eoscDataTransferDestinations; selectedDestination = null; - + folders = {}; + files = {}; downloadElements = null; @Input() isOpen = false; + @Input() selectedDestinationId = "dcache"; @ViewChild('egiTransferModal') egiTransferModal; - APIURL = "https://eosc-data-transfer.vm.fedcloud.eu" - // APIURL = "https://virtserver.swaggerhub.com/thebe14/eosc-future-data-transfer/1.0.0"; + APIURL = properties.eoscDataTransferAPI; status: "loading" | "success" | "errorParser" | "errorUser" | "errorTransfer" | "init" | "canceled" = "init"; message; doiPrefix = properties.doiURL; @@ -141,23 +56,33 @@ export class EGIDataTransferComponent { } open(){ - this.accessToken = COOKIE.getCookie("EGIAccessToken"); - if(this.accessToken) { - for (let doi of this.dois) { - if (doi.indexOf("zenodo.") != -1) { - this.sourceUrls.push(this.doiPrefix + doi); + if(this.selectedDestinationId){ + for( let option of this.destinationOptions){ + if(this.selectedDestinationId == option.value.id){ + this.selectedDestination = option.value; } } - try { - this.sourceUrls.sort(function (a, b) { - return Number(b.split("zenodo.")[1]) - Number(a.split("zenodo.")[1]); - }); - }catch (e){} - - this.selectedSourceUrl = this.sourceUrls[0]; + }else{ this.selectedDestination = this.destinationOptions[0].value; - this.parse(); } + if(this.selectedDestination.cookieName && COOKIE.getCookie(this.selectedDestination.cookieName)) { + this.accessToken[this.selectedDestination.id] = COOKIE.getCookie(this.selectedDestination.cookieName); + } + for (let doi of this.dois) { + if (doi.indexOf("zenodo.") != -1) { + this.sourceUrls.push(this.doiPrefix + doi); + } + } + try { + this.sourceUrls.sort(function (a, b) { + return Number(b.split("zenodo.")[1]) - Number(a.split("zenodo.")[1]); + }); + }catch (e){} + + this.selectedSourceUrl = this.sourceUrls[0]; + + this.parse(); + this.isOpen = true; this.egiTransferModal.cancelButton = false; this.egiTransferModal.okButton = false; @@ -216,7 +141,7 @@ export class EGIDataTransferComponent { transfer() { // console.log(this.selectedDestination) this.status = "loading"; - let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); this.subscriptions.push(this.http.get(this.APIURL + "/user/info?dest="+this.selectedDestination.id, {headers: headers}).subscribe( res => { // console.log(res) @@ -242,7 +167,7 @@ export class EGIDataTransferComponent { body.files.push(file); } - let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); this.subscriptions.push(this.http.post(this.APIURL + "/transfers" ,body, {headers: headers}).subscribe( res => { // console.log(res) @@ -302,7 +227,7 @@ export class EGIDataTransferComponent { if(this.jobId){ - let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); let source = this.http.get(this.APIURL + "/transfer/" +this.jobId , {headers: headers}).pipe(delay(5000)); this.subscriptions.push(source.pipe(repeat(3)).subscribe( res => { @@ -353,9 +278,7 @@ export class EGIDataTransferComponent { cancel(){ if(this.jobId){ - - - let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); this.subscriptions.push(this.http.delete(this.APIURL + "/transfer/" +this.jobId , {headers: headers}).subscribe( res => { console.log(res); @@ -367,21 +290,58 @@ export class EGIDataTransferComponent { )); } } - browse(){ - - - - 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.destinationPath) , {headers: headers}).subscribe( + hasBrowse(){ + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); + this.subscriptions.push(this.http.get(this.APIURL + "/storage/info?dest="+this.selectedDestination.id+"&seUrl="+encodeURIComponent(this.selectedDestination.url + this.destinationPath) , {headers: headers}).subscribe( res => { console.log(res); - this.jobStatus = res; - this.statusMessage = res['jobState'] + (res['reason']?(" :" + res['reason']):""); - this.jobId = null; - this.status = "canceled"; } )); + } + getFolder(folderPath){ + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); + this.subscriptions.push(this.http.get(this.APIURL + "/storage/folder?dest="+this.selectedDestination.id+"&seUrl="+encodeURIComponent(this.selectedDestination.url + folderPath) , {headers: headers}).subscribe( + res => { + this.folders[folderPath]= res; + this.folders[folderPath]['isOpen'] = true; + } + )); + + } + browseFolder(folderPath){ + if(this.folders[folderPath]){ + this.folders[folderPath].isOpen = !this.folders[folderPath].isOpen; + return; + } + this.getFolder(folderPath); + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); + this.subscriptions.push(this.http.get(this.APIURL + "/storage/folder/list?dest="+this.selectedDestination.id+"&folderUrl="+encodeURIComponent(this.selectedDestination.url + folderPath) , {headers: headers}).subscribe( + res => { + this.files[folderPath]= res['elements']; + } + )); + + } + createFolder(){ + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); + this.subscriptions.push(this.http.post(this.APIURL + "/storage/folder?dest="+this.selectedDestination.id+"&seUrl="+ + encodeURIComponent(this.selectedDestination.url + this.destinationPath + "test1/") , {headers: headers}).subscribe( + res => { + console.log(res); + } + )); + + } + deleteFolder(){ + + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken[this.selectedDestination.id]}); + this.subscriptions.push(this.http.delete(this.APIURL + "/storage/folder?dest="+this.selectedDestination.id+"&seUrl="+encodeURIComponent(this.selectedDestination.url + this.destinationPath + "test1/") , {headers: headers}).subscribe( + res => { + console.log(res); + } + )); + } private parseFilename(url){ let filename = url.split("/")[url.split("/").length - 1]; diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index 520e3dca..f0f7aacf 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -142,4 +142,6 @@ export interface EnvProperties { footerGrantText?: string; egiNotebookLink?: string; connectPortalUrl?; + eoscDataTransferAPI?; + eoscDataTransferDestinations?; }