update data transfer service - add selection for dois and destination Storages
This commit is contained in:
parent
4f9fdce645
commit
1927b04d7a
|
@ -1,11 +1,10 @@
|
||||||
import {Component, Input} 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, HttpHeaders} from "@angular/common/http";
|
||||||
import {Validators} from "@angular/forms";
|
import {Validators} from "@angular/forms";
|
||||||
import {Location} from '@angular/common';
|
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 {COOKIE} from "../openaireLibrary/login/utils/helper.class";
|
||||||
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
|
||||||
import {Router} from "@angular/router";
|
import {Router} from "@angular/router";
|
||||||
declare var UIkit;
|
declare var UIkit;
|
||||||
|
|
||||||
|
@ -13,7 +12,7 @@ declare var UIkit;
|
||||||
selector: 'egi-transfer-data',
|
selector: 'egi-transfer-data',
|
||||||
template: `
|
template: `
|
||||||
<a (click)="open()"
|
<a (click)="open()"
|
||||||
[title]="'Egi Transfer service'"
|
[title]="'Transfer Data'"
|
||||||
[attr.uk-tooltip]="'pos: right; cls: uk-active landing-action-tooltip landing-action-tooltip-portal uk-text-small uk-padding-small'"
|
[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 icon="cloud-upload"></span>
|
||||||
<span class="uk-icon-button uk-icon landing-action-button landing-action-button-portal">
|
<span class="uk-icon-button uk-icon landing-action-button landing-action-button-portal">
|
||||||
|
@ -24,12 +23,12 @@ declare var UIkit;
|
||||||
|
|
||||||
<!-- This is the modal -->
|
<!-- This is the modal -->
|
||||||
<div id="modal-example" class="uk-modal uk-open " style="display: block" [class.uk-invisible]="!isOpen">
|
<div id="modal-example" class="uk-modal uk-open " style="display: block" [class.uk-invisible]="!isOpen">
|
||||||
<div class="uk-modal-dialog uk-modal-body uk-width-expand">
|
<div class="uk-modal-dialog uk-modal-body uk-width-expand uk-text-left">
|
||||||
<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="!accessToken" 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">EOSC data transfer service</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-width-1-1 uk-margin-top uk-margin-bottom">
|
<div class="uk-width-1-1 uk-margin-top uk-margin-bottom">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
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.
|
laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-text-center">
|
<div class="uk-text-center">
|
||||||
<button *ngIf="!accessToken" class="uk-button uk-button-default" (click)="checkin()">EGI
|
<button *ngIf="!accessToken" class="uk-button uk-button-default" (click)="checkin()">Login
|
||||||
checkin
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="accessToken" 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">EOSC data transfer service</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-width-1-1 uk-margin-top uk-margin-bottom">
|
<div class="uk-width-1-1 uk-margin-top uk-margin-bottom">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
||||||
|
@ -54,18 +52,27 @@ declare var UIkit;
|
||||||
<div class="uk-grid uk-child-width-1-2 uk-grid-divider">
|
<div class="uk-grid uk-child-width-1-2 uk-grid-divider">
|
||||||
<div class="uk-first-column">
|
<div class="uk-first-column">
|
||||||
<p class="uk-text-meta">Lorem ipsum ....</p>
|
<p class="uk-text-meta">Lorem ipsum ....</p>
|
||||||
<div input [(value)]="sourceUrl" placeholder="Give a Zenodo DOI url..." type="URL"
|
<div input type="select" [(value)]="selectedSourceUrl" placeholder="Zenodo DOI URL" hint="Select..."
|
||||||
label="URL" [validators]="validators"></div>
|
[options]="sourceUrls" (valueChange)="this.parse()"></div>
|
||||||
<!-- <button *ngIf="!downloadElements" (click)="parse()" class="uk-button uk-button-default uk-margin-top" [class.uk-disabled]="sourceUrl.length == 0">Parse</button>-->
|
<div class="uk-margin-top">
|
||||||
|
<div>Files to be transfered:</div>
|
||||||
|
<ul>
|
||||||
|
|
||||||
|
<li *ngFor=" let element of this.downloadElements">{{ element.filename}}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p class="uk-text-meta">Lorem ipsum ....</p>
|
<p class="uk-text-meta">Lorem ipsum ....</p>
|
||||||
|
<div input type="select" [(value)]="selectedDestination" placeholder="Storage" hint="Select..."
|
||||||
|
[options]="destinationOptions"></div>
|
||||||
<div input [(value)]="destinationPath" placeholder="Give a destination path..."
|
<div input [(value)]="destinationPath" placeholder="Give a destination path..."
|
||||||
[validators]="validators[0]"></div>
|
[validators]="validators[0]" class="uk-margin-top"></div>
|
||||||
<button (click)="parse()"
|
<button (click)="transfer()"
|
||||||
class="uk-button uk-button-primary uk-margin-top"
|
class="uk-button uk-button-primary uk-margin-top"
|
||||||
[class.uk-disabled]="destinationPath.length == 0 || status == 'success' ||status == 'loading' ">
|
[class.uk-disabled]="destinationPath.length == 0 || status == 'success' ||status == 'loading' ">
|
||||||
>> Transfer to EGI Storage
|
>> Transfer to Storage
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -102,31 +109,36 @@ export class EGIDataTransferComponent {
|
||||||
accessToken = null;
|
accessToken = null;
|
||||||
@Input() dois;
|
@Input() dois;
|
||||||
loginURL = "http://rudie.di.uoa.gr:8580/openid_connect_login"
|
loginURL = "http://rudie.di.uoa.gr:8580/openid_connect_login"
|
||||||
sourceUrl = null;
|
sourceUrls = []
|
||||||
|
selectedSourceUrl = null;
|
||||||
destinationPath = "";
|
destinationPath = "";
|
||||||
destinationURL = "https://egi.storage.eu";
|
destinationOptions = [{label: "EGI storage", value: { url: "https://egi.storage.eu", id: "egi" } }];
|
||||||
|
selectedDestination = null;
|
||||||
|
|
||||||
downloadElements = null;
|
downloadElements = null;
|
||||||
@Input() 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, private location: Location, private userManagementsService: UserManagementService, private _router: Router) {
|
constructor(private http: HttpClient, private location: Location, private _router: Router) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
console.log(COOKIE.getCookie("EGISession"))
|
console.log(COOKIE.getCookie("EGIAccessToken"))
|
||||||
this.accessToken = COOKIE.getCookie("EGISession");
|
this.accessToken = COOKIE.getCookie("EGIAccessToken");
|
||||||
for(let doi of this.dois){
|
for(let doi of this.dois){
|
||||||
console.log(doi)
|
console.log(doi)
|
||||||
if(doi.indexOf("zenodo.")!=-1){
|
if(doi.indexOf("zenodo.")!=-1){
|
||||||
this.sourceUrl = "https://doi.org/" + doi;
|
this.sourceUrls.push("https://doi.org/" + doi);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
this.selectedSourceUrl = this.sourceUrls[0];
|
||||||
|
this.selectedDestination = this.destinationOptions[0].value;
|
||||||
|
this.parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
@ -142,8 +154,10 @@ export class EGIDataTransferComponent {
|
||||||
}
|
}
|
||||||
close(){
|
close(){
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
this.downloadElements = null;
|
// this.downloadElements = [];
|
||||||
this.destinationPath = "";
|
this.destinationPath = "";
|
||||||
|
this.selectedDestination = this.destinationOptions[0].value;
|
||||||
|
this.selectedSourceUrl = this.sourceUrls[0];
|
||||||
this.message = null;
|
this.message = null;
|
||||||
this.status = "init";
|
this.status = "init";
|
||||||
if(this._router.url.indexOf("&egiTransfer")){
|
if(this._router.url.indexOf("&egiTransfer")){
|
||||||
|
@ -152,23 +166,12 @@ export class EGIDataTransferComponent {
|
||||||
|
|
||||||
}
|
}
|
||||||
checkin(){
|
checkin(){
|
||||||
// this.loggedIn = true;
|
window.location.href = this.loginURL+"?redirect="+ encodeURIComponent("http://scoobydoo.di.uoa.gr:4400"+this._router.url+"&egiTransfer=t");
|
||||||
|
|
||||||
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(){
|
||||||
this.status = "loading";
|
|
||||||
this.subscriptions.push(this.http.get(this.APIURL + "/user/info").subscribe(
|
this.subscriptions.push(this.http.get(this.APIURL + "/parser/zenodo?source=" + this.selectedSourceUrl ).subscribe(
|
||||||
res => {
|
|
||||||
console.log(res)
|
|
||||||
this.subscriptions.push(this.http.get(this.APIURL + "/parser/zenodo?source=" + this.sourceUrl ).subscribe(
|
|
||||||
res => {
|
res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
this.downloadElements = [];
|
this.downloadElements = [];
|
||||||
|
@ -182,7 +185,7 @@ export class EGIDataTransferComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.downloadElements)
|
console.log(this.downloadElements)
|
||||||
this.transfer();
|
// this.transfer();
|
||||||
|
|
||||||
}, error => {
|
}, error => {
|
||||||
this.status = "errorParser";
|
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() {
|
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 = {
|
let body = {
|
||||||
"files": [],
|
"files": [],
|
||||||
"params": {
|
"params": {
|
||||||
|
@ -218,6 +216,7 @@ export class EGIDataTransferComponent {
|
||||||
"retry": 3
|
"retry": 3
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
console.log(this.selectedDestination)
|
||||||
for (let element of this.downloadElements) {
|
for (let element of this.downloadElements) {
|
||||||
|
|
||||||
let file = {
|
let file = {
|
||||||
|
@ -228,7 +227,7 @@ export class EGIDataTransferComponent {
|
||||||
],
|
],
|
||||||
"destinations": [
|
"destinations": [
|
||||||
{
|
{
|
||||||
"url": this.destinationURL + this.destinationPath + element.filename
|
"url": this.selectedDestination.url + this.destinationPath + element.filename
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"filesize": element['size']
|
"filesize": element['size']
|
||||||
|
@ -237,9 +236,8 @@ export class EGIDataTransferComponent {
|
||||||
body.files.push(file);
|
body.files.push(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let headers = new HttpHeaders({'Authorization': 'Bearer '+this.accessToken});
|
||||||
|
this.subscriptions.push(this.http.post(this.APIURL + "/transfer" ,body, {headers: headers}).subscribe(
|
||||||
this.subscriptions.push(this.http.post(this.APIURL + "/transfer" ,body ).subscribe(
|
|
||||||
res => {
|
res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
UIkit.notification('Data transfer has began! ', {
|
UIkit.notification('Data transfer has began! ', {
|
||||||
|
@ -251,8 +249,8 @@ export class EGIDataTransferComponent {
|
||||||
this.status = "success"
|
this.status = "success"
|
||||||
this.message = `
|
this.message = `
|
||||||
<div class="uk-text-large uk-margin-bottom">Data transfer has began!</div>
|
<div class="uk-text-large uk-margin-bottom">Data transfer has began!</div>
|
||||||
<div>Transfering ` + this.downloadElements.length + ` files to <a href="`+ this.destinationURL + this.destinationPath + `" target=_blank> EGI Storage</a>:
|
<div>Transfering ` + this.downloadElements.length + ` files to <a href="`+ this.selectedDestination.url + this.destinationPath + `" target=_blank> EGI Storage</a>:
|
||||||
<ul>
|
<ul>
|
||||||
`;
|
`;
|
||||||
// TODO LATER we can call status for each file and see if the transfer has been complete
|
// TODO LATER we can call status for each file and see if the transfer has been complete
|
||||||
for(let element of this.downloadElements){
|
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){
|
private parseFilename(url){
|
||||||
let filename = url.split("/")[url.split("/").length - 1];
|
let filename = url.split("/")[url.split("/").length - 1];
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {InputModule} from "../openaireLibrary/sharedComponents/input/input.modul
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule, FormsModule, InputModule,
|
CommonModule, FormsModule, InputModule
|
||||||
|
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
|
|
Loading…
Reference in New Issue