>fileInput.target.files;
+ if (this.filesToUpload.length == 0) {
+ // this.errorMessage = "There is no selected file to upload.";
+ return;
+ }
+ this.start();
+ }
+
+
+ depositFile() {
+
+ const formData: FormData = new FormData();
+ formData.append('file', this.filesToUpload[0]);
+ const fileName = this.filesToUpload[0].name; // Replace with file name
+
+ let url = `${this.space.links.bucket}/${fileName}`;
+
+
+ const data = {
+ name: fileName,
+ ...formData
+ };
+
+ const headers = new HttpHeaders({
+ 'Content-type': 'application/octet-stream'
+ });
+ let params = new HttpParams();
+ params = params.set('access_token', this.userTokens.zenodoToken);
+ this._http.put(url, {
+ name: fileName,
+ ...formData
+ }, {headers, params}).subscribe((res) => {
+ console.log(res);
+ this.depositInfoModal.cancelButton = false;
+ this.depositInfoModal.okButton = true;
+ this.depositInfoModal.okButtonLeft = false;
+ this.depositInfoModal.alertTitle = "Deposit info";
+ this.depositInfoModal.open();
+ console.log(this.space)
+ // this.publish();
+ }, error => {
+ console.log(error.headers)
+ console.error(error.data)
+ this.deleteSpace();
+ });
+ /* });
+ }*/
+ }
+
+ deleteSpace() {
+ this._http.delete(this.api + "api/deposit/depositions/" + this.space.id + "?access_token=" + this.userTokens.zenodoToken,
+ ).subscribe(res => {
+ console.log(res)
+
+
+ }, error => {
+ console.error(error.message)
+ UIkit.notification({
+ message: 'An error occured while uploading your file. The deposition may not be completed.',
+ status: 'danger',
+ timeout: 6000,
+ pos: 'bottom-right'
+ });
+ })
+ }
+
+ checkAccess(func){
+ if(!this.user){
+ //TODO redirect
+
+ }else{
+ if(this.userTokens){
+ this.getInfo(func);
+ }else{
+ this.authorize();
+ }
+ }
+ }
+
+ getAccessByRefresh(func){
+/*
+ this._http.get(this.depositService + "deposit/zenodo/getTokenByRefresh?token=" + this.userTokens.zenodoRefresh).subscribe(res => {
+ console.log(res)
+ /!*localStorage.setItem('deposit_token', res['access_token']);
+ localStorage.setItem('deposit_refresh', res['refresh_token']);
+ this.message = "Thank you for authorizing OpenAIRE to use your Zenodo account for deposit!
" +
+ "This window will automatically close and you will be ready to deposit.
";
+ if(window && window.opener) {
+ window.opener.postMessage(res,"*");
+ window.close();
+ }
+ setTimeout(() => {
+ this.message += "If this window does not close automatically, please close it and continue!
";
+ }, 3000);*!/
+ }, error =>{
+ console.log(error);
+ })*/
+ this.authorize();
+ }
+}
diff --git a/deposit/deposit-file/deposit-file.module.ts b/deposit/deposit-file/deposit-file.module.ts
new file mode 100644
index 00000000..70474521
--- /dev/null
+++ b/deposit/deposit-file/deposit-file.module.ts
@@ -0,0 +1,20 @@
+import {NgModule} from '@angular/core';
+import {CommonModule} from '@angular/common';
+import {DepositionComponent} from "./deposit-file.component";
+import {AlertModalModule} from "../../utils/modal/alertModal.module";
+
+@NgModule({
+ imports: [
+ CommonModule,
+ AlertModalModule,
+ ],
+ declarations: [
+ DepositionComponent
+ ],
+ providers: [],
+ exports: [
+ DepositionComponent
+ ]
+})
+export class DepositFileModule {
+}
diff --git a/deposit/deposit-grant-redirect/deposit-routing.module.ts b/deposit/deposit-grant-redirect/deposit-routing.module.ts
new file mode 100644
index 00000000..e9ce0f81
--- /dev/null
+++ b/deposit/deposit-grant-redirect/deposit-routing.module.ts
@@ -0,0 +1,17 @@
+import { NgModule } from '@angular/core';
+import { RouterModule } from '@angular/router';
+import {DepositComponent} from "./deposit.component";
+import {LoginGuard} from "../../login/loginGuard.guard";
+import {PreviousRouteRecorder} from "../../utils/piwik/previousRouteRecorder.guard";
+
+
+@NgModule({
+ imports: [
+ RouterModule.forChild([
+ { path: '', component: DepositComponent,
+ // canActivate: [LoginGuard],
+ canDeactivate: [PreviousRouteRecorder] }
+ ])
+ ]
+})
+export class DepositRoutingModule { }
diff --git a/deposit/deposit-grant-redirect/deposit.component.ts b/deposit/deposit-grant-redirect/deposit.component.ts
new file mode 100644
index 00000000..d05c61d2
--- /dev/null
+++ b/deposit/deposit-grant-redirect/deposit.component.ts
@@ -0,0 +1,101 @@
+import { Component } from '@angular/core';
+import {ActivatedRoute, Router} from "@angular/router";
+import {Subscriber, Subscription} from "rxjs";
+import {properties} from "../../../../environments/environment";
+import {Meta, Title} from "@angular/platform-browser";
+import {RouterHelper} from "../../utils/routerHelper.class";
+import {UserManagementService} from "../../services/user-management.service";
+import {HttpClient} from "@angular/common/http";
+
+@Component({
+ selector: 'deposit',
+ template: `
+
+
{{depositMessage}}
+
+
+
+
+
+ `
+})
+
+export class DepositComponent {
+ public subscriptions: Subscription[] = [];
+
+ public showLoading: boolean = false;
+ public message: string = "";
+ public depositMessage: string = "";
+
+ public source: string = "";
+ public code: string = "";
+
+ public gotToken: boolean = false;
+
+ public routerHelper:RouterHelper = new RouterHelper();
+ depositService = "http://localhost:8182/";
+ constructor(private route: ActivatedRoute,
+ private _router: Router,
+ private userManagementService: UserManagementService,
+ private _meta: Meta, private _title: Title, private _http: HttpClient) {}
+
+ ngOnInit() {
+ var description = "Openaire, Deposit, Zenodo";
+ this.updateTitle("Connect with Zenodo");
+ this.updateDescription(description);
+ this.updateUrl( properties.domain + properties.baseLink + this.route.url);
+
+ this.subscriptions.push(this.route.queryParams.subscribe(params => {
+ this.gotToken = false;
+ this.code = params['code'];
+ if (this.code) {
+ this.getToken();
+ } else {
+ this.message = "No code provided to authorize OpenAIRE to deposit in your Zenodo account. Please try again!"
+ }
+ }));
+ }
+
+ ngOnDestroy() {
+ this.subscriptions.forEach(subscription => {
+ if (subscription instanceof Subscriber) {
+ subscription.unsubscribe();
+ }
+ });
+ }
+ public getToken() {
+ this.showLoading = true;
+ console.log(this.code)
+
+ // this._http.get(properties.utilsService + "/deposit/getToken?code=" + this.code).subscribe(res => {
+ this._http.get(this.depositService + "deposit/zenodo/getTokenByCode?code=" + this.code).subscribe(res => {
+ console.log(res)
+ res["code"] = this.code
+ this.message = "Thank you for authorizing OpenAIRE to use your Zenodo account for deposit!
" +
+ "This window will automatically close and you will be ready to deposit.
";
+ if(window && window.opener) {
+ window.opener.postMessage(res,"*");
+ window.close();
+ }
+ setTimeout(() => {
+ this.message += "If this window does not close automatically, please close it and continue!
";
+ }, 3000);
+ })
+
+ }
+
+
+ private updateTitle(title: string) {
+ this._title.setTitle(title);
+ this._meta.updateTag({content: title}, "property='og:title'");
+ }
+
+ private updateDescription(description: string) {
+ this._meta.updateTag({content: description}, "name='description'");
+ this._meta.updateTag({content: description}, "property='og:description'");
+ }
+
+ private updateUrl(url: string) {
+ this._meta.updateTag({content: url}, "property='og:url'");
+ }
+}
diff --git a/deposit/deposit-grant-redirect/deposit.module.ts b/deposit/deposit-grant-redirect/deposit.module.ts
new file mode 100644
index 00000000..588f01b4
--- /dev/null
+++ b/deposit/deposit-grant-redirect/deposit.module.ts
@@ -0,0 +1,16 @@
+import {NgModule} from '@angular/core';
+import {DepositRoutingModule} from "./deposit-routing.module";
+import {DepositComponent} from "./deposit.component";
+import {LoadingModule} from "../../utils/loading/loading.module";
+import {CommonModule} from "@angular/common";
+
+
+@NgModule({
+ imports: [CommonModule, DepositRoutingModule, LoadingModule],
+ declarations:[DepositComponent],
+ exports: [DepositComponent]
+})
+
+
+export class DepositModule {
+}
diff --git a/error-interceptor.service.ts b/error-interceptor.service.ts
index 701c6697..c9569bd5 100644
--- a/error-interceptor.service.ts
+++ b/error-interceptor.service.ts
@@ -11,7 +11,7 @@ import * as url from "url";
@Injectable()
export class ErrorInterceptorService implements HttpInterceptor {
- private static UNAUTHORIZED_WHITELIST = [properties.orcidAPIURL, properties.registryUrl? (properties.registryUrl + 'verification/'):null, properties.eoscDataTransferAPI].filter(value => !!value);
+ private static UNAUTHORIZED_WHITELIST = [properties.orcidAPIURL, properties.registryUrl? (properties.registryUrl + 'verification/'):null, properties.eoscDataTransferAPI, "https://sandbox.zenodo.org/"].filter(value => !!value);
private url: string = null;
constructor(private router: Router) {
diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html
index f3a0de11..3d164096 100644
--- a/landingPages/result/resultLanding.component.html
+++ b/landingPages/result/resultLanding.component.html
@@ -77,7 +77,7 @@
-
diff --git a/landingPages/result/resultLanding.module.ts b/landingPages/result/resultLanding.module.ts
index d1792e55..22dcba83 100644
--- a/landingPages/result/resultLanding.module.ts
+++ b/landingPages/result/resultLanding.module.ts
@@ -39,6 +39,7 @@ import {EntityActionsModule} from "../../utils/entity-actions/entity-actions.mod
import {ResultLandingRoutingModule} from "./resultLanding-routing.module";
import {OrcidCoreModule} from "../../orcid/orcid-core.module";
import {SearchTabModule} from "../../utils/tabs/contents/search-tab.module";
+import {DepositionComponent} from "../../deposit/deposit-file/deposit-file.component";
@NgModule({
imports: [
diff --git a/utils/entity-actions/entity-actions.component.ts b/utils/entity-actions/entity-actions.component.ts
index 36be6079..82459fcb 100644
--- a/utils/entity-actions/entity-actions.component.ts
+++ b/utils/entity-actions/entity-actions.component.ts
@@ -51,6 +51,9 @@ import {EnvProperties} from "../properties/env-properties";
Embed
+
+
+
@@ -92,6 +95,7 @@ export class EntityActionsComponent implements OnInit {
@Input() share: boolean = false;
@Input() cite: boolean = false;
@Input() deposit: boolean = false;
+ @Input() depositFile: boolean = false;
@Input() embed: boolean = false;
@Input() url: string;
@Input() isMobile: boolean = false;
diff --git a/utils/entity-actions/entity-actions.module.ts b/utils/entity-actions/entity-actions.module.ts
index b90cd9b3..ebe4a216 100644
--- a/utils/entity-actions/entity-actions.module.ts
+++ b/utils/entity-actions/entity-actions.module.ts
@@ -7,9 +7,10 @@ import {AlertModalModule} from "../modal/alertModal.module";
import {CiteThisModule} from "../../landingPages/landing-utils/citeThis/citeThis.module";
import {LandingModule} from "../../landingPages/landing-utils/landing.module";
import {InputModule} from "../../sharedComponents/input/input.module";
+import {DepositFileModule} from "../../deposit/deposit-file/deposit-file.module";
@NgModule({
- imports: [CommonModule, IconsModule, AlertModalModule, CiteThisModule, LandingModule, RouterModule, InputModule],
+ imports: [CommonModule, IconsModule, AlertModalModule, CiteThisModule, LandingModule, RouterModule, InputModule, DepositFileModule],
declarations: [EntityActionsComponent],
exports: [EntityActionsComponent]
})