EGI data transfer: mock login process with reload

This commit is contained in:
argirok 2022-05-10 15:39:21 +03:00
parent fff6a016a8
commit 3b3f1e38d7
2 changed files with 69 additions and 17 deletions

View File

@ -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: `
<a (click)="open()"> Transfer data to EGI storage</a>
<a (click)="open()"
[title]="'Egi Transfer service'"
[attr.uk-tooltip]="'pos: right; cls: uk-active landing-action-tooltip landing-action-tooltip-portal uk-text-small uk-padding-small'"
> <span icon="cloud-upload"></span>
<span class="uk-icon-button uk-icon landing-action-button landing-action-button-portal">
<span uk-icon="cloud-upload"></span>
</span>
</a>
<!-- This is the modal -->
@ -16,7 +27,7 @@ declare var UIkit;
<div class="uk-modal-dialog uk-modal-body uk-width-expand">
<button class="uk-modal-close-default" type="button" uk-close (click)="close()"></button>
<div class="uk-padding">
<div *ngIf="!loggedIn" class="">
<div *ngIf="!accessToken" class="">
<div class="uk-width-1-1 uk-text-center">
<h2 class="uk-modal-title">Title</h2>
</div>
@ -26,12 +37,12 @@ declare var UIkit;
laboris nisi ut aliquip ex ea commodo consequat.
</div>
<div class="uk-text-center">
<button *ngIf="!loggedIn" class="uk-button uk-button-default" (click)="checkin()">EGI
<button *ngIf="!accessToken" class="uk-button uk-button-default" (click)="checkin()">EGI
checkin
</button>
</div>
</div>
<div *ngIf="loggedIn" class="">
<div *ngIf="accessToken" class="">
<div class="uk-width-1-1 uk-text-center">
<h2 class="uk-modal-title">Title</h2>
</div>
@ -50,7 +61,7 @@ declare var UIkit;
<div>
<p class="uk-text-meta">Lorem ipsum ....</p>
<div input [(value)]="destinationPath" placeholder="Give a destination path..."
[validators]="validators[0]"></div>
[validators]="validators[0]"></div>
<button (click)="parse()"
class="uk-button uk-button-primary uk-margin-top"
[class.uk-disabled]="destinationPath.length == 0 || status == 'success' ||status == 'loading' ">
@ -86,24 +97,36 @@ declare var UIkit;
`
})
export class EGIDataTransfer {
export class EGIDataTransferComponent {
subscriptions = [];
loggedIn = false;
sourceUrl = "https://doi.org/10.5281/zenodo.6507535";
accessToken = null;
@Input() dois;
loginURL = "http://rudie.di.uoa.gr:8580/openid_connect_login"
sourceUrl = null;
destinationPath = "";
destinationURL = "https://egi.storage.eu";
downloadElements = null;
isOpen = false;
@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) {
constructor(private http: HttpClient, private location: Location, private userManagementsService: UserManagementService, private _router: Router) {
}
ngOnInit() {
console.log(COOKIE.getCookie("EGISession"))
this.accessToken = COOKIE.getCookie("EGISession");
for(let doi of this.dois){
console.log(doi)
if(doi.indexOf("zenodo.")!=-1){
this.sourceUrl = "https://doi.org/" + doi;
break;
}
}
}
ngOnDestroy() {
@ -123,16 +146,25 @@ export class EGIDataTransfer {
this.destinationPath = "";
this.message = null;
this.status = "init";
if(this._router.url.indexOf("&egiTransfer")){
this.location.go(this._router.url.split("&egiTransfer")[0]);
}
}
checkin(){
this.loggedIn = true;
// 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;
}
parse(){
// check get user info
// .pipe(catch(error: any) => {
// return Observable.throw(new Error(error.status));
// }))
this.status = "loading";
this.status = "loading";
this.subscriptions.push(this.http.get(this.APIURL + "/user/info").subscribe(
res => {
console.log(res)

View File

@ -0,0 +1,20 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {EGIDataTransferComponent} from "./transferData.component";
import {InputModule} from "../openaireLibrary/sharedComponents/input/input.module";
@NgModule({
imports: [
CommonModule, FormsModule, InputModule,
],
declarations: [
EGIDataTransferComponent
],
exports: [
EGIDataTransferComponent
]
})
export class EGIDataTransferModule { }