From 3b3f1e38d78a003f0451b5191f5f64d99122e0f6 Mon Sep 17 00:00:00 2001 From: argirok Date: Tue, 10 May 2022 15:39:21 +0300 Subject: [PATCH 1/4] EGI data transfer: mock login process with reload --- src/app/utils/transferData.component.ts | 66 ++++++++++++++++++------- src/app/utils/transferData.module.ts | 20 ++++++++ 2 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 src/app/utils/transferData.module.ts diff --git a/src/app/utils/transferData.component.ts b/src/app/utils/transferData.component.ts index c78ae54..6a21c7e 100644 --- a/src/app/utils/transferData.component.ts +++ b/src/app/utils/transferData.component.ts @@ -1,14 +1,25 @@ -import {Component} from '@angular/core'; +import {Component, Input} from '@angular/core'; import {Subscriber} from "rxjs"; import {HttpClient} from "@angular/common/http"; import {Validators} from "@angular/forms"; +import {Location} from '@angular/common'; import {StringUtils} from "../openaireLibrary/utils/string-utils.class"; +import {COOKIE, Session} from "../openaireLibrary/login/utils/helper.class"; +import {UserManagementService} from "../openaireLibrary/services/user-management.service"; +import {Router} from "@angular/router"; declare var UIkit; @Component({ selector: 'egi-transfer-data', template: ` - Transfer data to EGI storage + + + + + @@ -16,7 +27,7 @@ declare var UIkit;
-
+

Title

@@ -26,12 +37,12 @@ declare var UIkit; laboris nisi ut aliquip ex ea commodo consequat.
-
-
+

Title

@@ -50,7 +61,7 @@ declare var UIkit;

Lorem ipsum ....

+ [validators]="validators[0]">
-

Title

+

EOSC data transfer service

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut @@ -37,14 +36,13 @@ declare var UIkit; laboris nisi ut aliquip ex ea commodo consequat.
-
-

Title

+

EOSC data transfer service

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut @@ -54,18 +52,27 @@ declare var UIkit;

Lorem ipsum ....

-
- +
+
+
Files to be transfered:
+
    + +
  • {{ element.filename}} +
  • +
+

Lorem ipsum ....

+
-
+
@@ -102,31 +109,36 @@ export class EGIDataTransferComponent { accessToken = null; @Input() dois; loginURL = "http://rudie.di.uoa.gr:8580/openid_connect_login" - sourceUrl = null; + sourceUrls = [] + selectedSourceUrl = null; destinationPath = ""; - destinationURL = "https://egi.storage.eu"; + destinationOptions = [{label: "EGI storage", value: { url: "https://egi.storage.eu", id: "egi" } }]; + selectedDestination = null; + downloadElements = null; @Input() isOpen = false; APIURL = "https://virtserver.swaggerhub.com/thebe14/eosc-future-data-transfer/1.0.0"; status: "loading" | "success" | "errorParser" | "errorUser" | "errorTransfer" | "init" = "init"; message; validators = [Validators.required, StringUtils.urlValidator()]; - constructor(private http: HttpClient, private location: Location, private userManagementsService: UserManagementService, private _router: Router) { + constructor(private http: HttpClient, private location: Location, private _router: Router) { } ngOnInit() { - console.log(COOKIE.getCookie("EGISession")) - this.accessToken = COOKIE.getCookie("EGISession"); + console.log(COOKIE.getCookie("EGIAccessToken")) + this.accessToken = COOKIE.getCookie("EGIAccessToken"); for(let doi of this.dois){ console.log(doi) if(doi.indexOf("zenodo.")!=-1){ - this.sourceUrl = "https://doi.org/" + doi; - break; + this.sourceUrls.push("https://doi.org/" + doi); } } + this.selectedSourceUrl = this.sourceUrls[0]; + this.selectedDestination = this.destinationOptions[0].value; + this.parse(); } ngOnDestroy() { @@ -142,8 +154,10 @@ export class EGIDataTransferComponent { } close(){ this.isOpen = false; - this.downloadElements = null; + // this.downloadElements = []; this.destinationPath = ""; + this.selectedDestination = this.destinationOptions[0].value; + this.selectedSourceUrl = this.sourceUrls[0]; this.message = null; this.status = "init"; if(this._router.url.indexOf("&egiTransfer")){ @@ -152,23 +166,12 @@ export class EGIDataTransferComponent { } checkin(){ - // this.loggedIn = true; - - console.log(COOKIE.getCookie("EGISession")) - // this.accessToken = COOKIE.getCookie("EGISession"); - COOKIE.setCookie("EGISession", "test!!!!!!",10,"/" ); - this.userManagementsService.setRedirectUrl(this._router.url+"&egiTransfer=t"); - // this.location.go("/reload"); - window.location.href = "/reload"; - // window.location.href = this.loginURL; + window.location.href = this.loginURL+"?redirect="+ encodeURIComponent("http://scoobydoo.di.uoa.gr:4400"+this._router.url+"&egiTransfer=t"); } parse(){ - this.status = "loading"; - this.subscriptions.push(this.http.get(this.APIURL + "/user/info").subscribe( - res => { - console.log(res) - this.subscriptions.push(this.http.get(this.APIURL + "/parser/zenodo?source=" + this.sourceUrl ).subscribe( + + this.subscriptions.push(this.http.get(this.APIURL + "/parser/zenodo?source=" + this.selectedSourceUrl ).subscribe( res => { console.log(res) this.downloadElements = []; @@ -182,7 +185,7 @@ export class EGIDataTransferComponent { } console.log(this.downloadElements) - this.transfer(); + // this.transfer(); }, error => { this.status = "errorParser"; @@ -195,21 +198,16 @@ export class EGIDataTransferComponent { } )); - }, error => { - this.status = "errorUser"; - this.message = "User can't be authenticated!"; - UIkit.notification("User can't be authenticated!", { - status: 'error', - timeout: 6000, - pos: 'bottom-right' - }); - } - )); } transfer() { - + 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", {headers: headers}).subscribe( + res => { + console.log(res) let body = { "files": [], "params": { @@ -218,6 +216,7 @@ export class EGIDataTransferComponent { "retry": 3 } }; + console.log(this.selectedDestination) for (let element of this.downloadElements) { let file = { @@ -228,7 +227,7 @@ export class EGIDataTransferComponent { ], "destinations": [ { - "url": this.destinationURL + this.destinationPath + element.filename + "url": this.selectedDestination.url + this.destinationPath + element.filename } ], "filesize": element['size'] @@ -237,9 +236,8 @@ export class EGIDataTransferComponent { body.files.push(file); } - - - this.subscriptions.push(this.http.post(this.APIURL + "/transfer" ,body ).subscribe( + let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken}); + this.subscriptions.push(this.http.post(this.APIURL + "/transfer" ,body, {headers: headers}).subscribe( res => { console.log(res) UIkit.notification('Data transfer has began! ', { @@ -251,8 +249,8 @@ export class EGIDataTransferComponent { this.status = "success" this.message = `
Data transfer has began!
-
Transfering ` + this.downloadElements.length + ` files to EGI Storage: -
    +
    Transfering ` + this.downloadElements.length + ` files to EGI Storage: +
      `; // TODO LATER we can call status for each file and see if the transfer has been complete for(let element of this.downloadElements){ @@ -275,7 +273,17 @@ export class EGIDataTransferComponent { } )); + }, error => { + this.status = "errorUser"; + this.message = "User can't be authenticated!"; + UIkit.notification("User can't be authenticated!", { + status: 'error', + timeout: 6000, + pos: 'bottom-right' + }); + } + )); } private parseFilename(url){ let filename = url.split("/")[url.split("/").length - 1]; diff --git a/src/app/utils/transferData.module.ts b/src/app/utils/transferData.module.ts index 621ebf6..8bc4286 100644 --- a/src/app/utils/transferData.module.ts +++ b/src/app/utils/transferData.module.ts @@ -6,7 +6,7 @@ import {InputModule} from "../openaireLibrary/sharedComponents/input/input.modul @NgModule({ imports: [ - CommonModule, FormsModule, InputModule, + CommonModule, FormsModule, InputModule ], declarations: [ From 31126896451919e6024dd7c0c6bb2bb938d6a8bf Mon Sep 17 00:00:00 2001 From: argirok Date: Wed, 18 May 2022 12:40:51 +0300 Subject: [PATCH 3/4] add reload path --- src/app/app-routing.module.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index d93a365..13e3214 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -89,7 +89,11 @@ const routes: Routes = [ path: 'project-report', loadChildren: () => import('./landingPages/htmlProjectReport/libHtmlProjectReport.module').then(m => m.LibHtmlProjectReportModule) }, - + { + path: 'reload', + loadChildren: () => import('./reload/libReload.module').then(m => m.LibReloadModule), + data: {hasSidebar: false} + }, {path: 'user-info', loadChildren: () => import('./login/libUser.module').then(m => m.LibUserModule)}, {path: 'error', component: OpenaireErrorPageComponent}, {path: '**', pathMatch: 'full', component: OpenaireErrorPageComponent} From cbc205d2d5657f5a5b0e2113eb36c9fcabb8a3e4 Mon Sep 17 00:00:00 2001 From: argirok Date: Wed, 18 May 2022 13:30:00 +0300 Subject: [PATCH 4/4] add eosc data transfer action button in landing update properties --- src/environments/environment.eosc.ts | 3 ++- src/environments/environment.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/environments/environment.eosc.ts b/src/environments/environment.eosc.ts index 908c2bb..af3c8d5 100644 --- a/src/environments/environment.eosc.ts +++ b/src/environments/environment.eosc.ts @@ -8,6 +8,7 @@ export let properties: EnvProperties = { useCache: false, useLongCache: true, showAddThis: true, + enableEoscDataTransfer: true, metricsAPIURL: "https://services.openaire.eu/usagestats/", framesAPIURL: "https://www.openaire.eu/stats3/", statisticsAPIURL: "https://beta.services.openaire.eu/stats-api/", @@ -47,7 +48,7 @@ export let properties: EnvProperties = { vocabulariesAPI: "https://services.openaire.eu/provision/mvc/vocabularies/", piwikBaseUrl: "https://analytics.openaire.eu/piwik.php?idsite=", - piwikSiteId: "582", + piwikSiteId: "594", loginUrl: "https://services.openaire.eu/login-service/openid_connect_login", userInfoUrl: "https://services.openaire.eu/login-service/userInfo", diff --git a/src/environments/environment.ts b/src/environments/environment.ts index efedffb..d033ebb 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -13,6 +13,7 @@ export let properties: EnvProperties = { useCache: true, useLongCache: true, showAddThis: true, + enableEoscDataTransfer: true, metricsAPIURL: "https://beta.services.openaire.eu/usagestats/", framesAPIURL: "https://beta.openaire.eu/stats3/", statisticsAPIURL: "https://beta.services.openaire.eu/stats-api/",