EGI data transfer: mock login process with reload
This commit is contained in:
parent
fff6a016a8
commit
3b3f1e38d7
|
@ -1,14 +1,25 @@
|
||||||
import {Component} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
import {Subscriber} from "rxjs";
|
import {Subscriber} from "rxjs";
|
||||||
import {HttpClient} from "@angular/common/http";
|
import {HttpClient} from "@angular/common/http";
|
||||||
import {Validators} from "@angular/forms";
|
import {Validators} from "@angular/forms";
|
||||||
|
import {Location} from '@angular/common';
|
||||||
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
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;
|
declare var UIkit;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'egi-transfer-data',
|
selector: 'egi-transfer-data',
|
||||||
template: `
|
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 -->
|
<!-- This is the modal -->
|
||||||
|
@ -16,7 +27,7 @@ declare var UIkit;
|
||||||
<div class="uk-modal-dialog uk-modal-body uk-width-expand">
|
<div class="uk-modal-dialog uk-modal-body uk-width-expand">
|
||||||
<button class="uk-modal-close-default" type="button" uk-close (click)="close()"></button>
|
<button class="uk-modal-close-default" type="button" uk-close (click)="close()"></button>
|
||||||
<div class="uk-padding">
|
<div class="uk-padding">
|
||||||
<div *ngIf="!loggedIn" class="">
|
<div *ngIf="!accessToken" class="">
|
||||||
<div class="uk-width-1-1 uk-text-center">
|
<div class="uk-width-1-1 uk-text-center">
|
||||||
<h2 class="uk-modal-title">Title</h2>
|
<h2 class="uk-modal-title">Title</h2>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,12 +37,12 @@ declare var UIkit;
|
||||||
laboris nisi ut aliquip ex ea commodo consequat.
|
laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-text-center">
|
<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
|
checkin
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="loggedIn" class="">
|
<div *ngIf="accessToken" class="">
|
||||||
<div class="uk-width-1-1 uk-text-center">
|
<div class="uk-width-1-1 uk-text-center">
|
||||||
<h2 class="uk-modal-title">Title</h2>
|
<h2 class="uk-modal-title">Title</h2>
|
||||||
</div>
|
</div>
|
||||||
|
@ -86,24 +97,36 @@ declare var UIkit;
|
||||||
|
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class EGIDataTransfer {
|
export class EGIDataTransferComponent {
|
||||||
subscriptions = [];
|
subscriptions = [];
|
||||||
loggedIn = false;
|
accessToken = null;
|
||||||
sourceUrl = "https://doi.org/10.5281/zenodo.6507535";
|
@Input() dois;
|
||||||
|
loginURL = "http://rudie.di.uoa.gr:8580/openid_connect_login"
|
||||||
|
sourceUrl = null;
|
||||||
destinationPath = "";
|
destinationPath = "";
|
||||||
destinationURL = "https://egi.storage.eu";
|
destinationURL = "https://egi.storage.eu";
|
||||||
downloadElements = null;
|
downloadElements = null;
|
||||||
isOpen = false;
|
@Input() isOpen = false;
|
||||||
APIURL = "https://virtserver.swaggerhub.com/thebe14/eosc-future-data-transfer/1.0.0";
|
APIURL = "https://virtserver.swaggerhub.com/thebe14/eosc-future-data-transfer/1.0.0";
|
||||||
status: "loading" | "success" | "errorParser" | "errorUser" | "errorTransfer" | "init" = "init";
|
status: "loading" | "success" | "errorParser" | "errorUser" | "errorTransfer" | "init" = "init";
|
||||||
message;
|
message;
|
||||||
validators = [Validators.required, StringUtils.urlValidator()];
|
validators = [Validators.required, StringUtils.urlValidator()];
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient, private location: Location, private userManagementsService: UserManagementService, private _router: Router) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
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() {
|
ngOnDestroy() {
|
||||||
|
@ -123,15 +146,24 @@ export class EGIDataTransfer {
|
||||||
this.destinationPath = "";
|
this.destinationPath = "";
|
||||||
this.message = null;
|
this.message = null;
|
||||||
this.status = "init";
|
this.status = "init";
|
||||||
|
if(this._router.url.indexOf("&egiTransfer")){
|
||||||
|
this.location.go(this._router.url.split("&egiTransfer")[0]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
checkin(){
|
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(){
|
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(
|
this.subscriptions.push(this.http.get(this.APIURL + "/user/info").subscribe(
|
||||||
res => {
|
res => {
|
||||||
|
|
|
@ -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 { }
|
Loading…
Reference in New Issue