1
|
import {Component, Input} from '@angular/core';
|
2
|
import {Router, ActivatedRoute} from '@angular/router';
|
3
|
import {Title, Meta} from '@angular/platform-browser';
|
4
|
|
5
|
import {Observable} from 'rxjs';
|
6
|
|
7
|
import {EnvProperties} from '../utils/properties/env-properties';
|
8
|
|
9
|
import {PiwikService} from '../utils/piwik/piwik.service';
|
10
|
import { SEOService } from '../sharedComponents/SEO/SEO.service';
|
11
|
|
12
|
import {ZenodoInformationClass} from './utils/zenodoInformation.class';
|
13
|
|
14
|
@Component({
|
15
|
selector: 'deposit',
|
16
|
templateUrl: 'deposit.component.html'
|
17
|
})
|
18
|
|
19
|
export class DepositComponent {
|
20
|
@Input() zenodoInformation: ZenodoInformationClass;
|
21
|
@Input() compatibility: string = '';
|
22
|
@Input() mapUrl: string = null; // optional in case i-frame is needed
|
23
|
@Input() searchBySubjects: boolean = false; // optional: in case search by subjects is needed
|
24
|
@Input() piwikSiteId = null;
|
25
|
|
26
|
public status: number;
|
27
|
|
28
|
// Type of entity: Publication or Research Data
|
29
|
@Input() requestFor: string = "Publications";
|
30
|
|
31
|
// url's needed for information text
|
32
|
public openAccess: string;
|
33
|
public openAccessRepo: string;
|
34
|
public fp7Guidlines: string;
|
35
|
public h2020Guidlines: string;
|
36
|
public ercGuidlines: string;
|
37
|
public helpdesk: string;
|
38
|
|
39
|
// Id of the new selected organization to be searched
|
40
|
public selectedId: string = "";
|
41
|
|
42
|
public warningMessage: string = "";
|
43
|
|
44
|
piwiksub:any;
|
45
|
properties:EnvProperties;
|
46
|
url=null;
|
47
|
constructor (private route: ActivatedRoute, private _router: Router,
|
48
|
private _meta: Meta, private _title: Title,
|
49
|
private _piwikService:PiwikService,
|
50
|
private seoService: SEOService ) {
|
51
|
|
52
|
var title = "Deposit "+this.requestFor;
|
53
|
var description = "Openaire, repositories, open access, content provider, compatibility, organization, deposit "+ this.requestFor;
|
54
|
this.updateTitle(title);
|
55
|
this.updateDescription(description);
|
56
|
}
|
57
|
ngOnInit() {
|
58
|
this.route.data
|
59
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
60
|
this.properties = data.envSpecific;
|
61
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false);
|
62
|
this.updateUrl(data.envSpecific.baseLink+this._router.url);
|
63
|
this.url = data.envSpecific.baseLink+this._router.url;
|
64
|
|
65
|
this.openAccess = this.properties.openAccess;
|
66
|
this.openAccessRepo = this.properties.openAccessRepo;
|
67
|
this.fp7Guidlines = this.properties.fp7Guidlines
|
68
|
this.h2020Guidlines = this.properties.h2020Guidlines
|
69
|
this.ercGuidlines = this.properties.ercGuidlines
|
70
|
this.helpdesk = this.properties.helpdesk;
|
71
|
|
72
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
73
|
this.piwiksub = this._piwikService.trackView(this.properties, "Deposit "+this.requestFor, this.piwikSiteId).subscribe();
|
74
|
}
|
75
|
});
|
76
|
}
|
77
|
ngOnDestroy() {
|
78
|
if(this.piwiksub){
|
79
|
this.piwiksub.unsubscribe();
|
80
|
}
|
81
|
}
|
82
|
|
83
|
public organizationSelected(id: string) {
|
84
|
if(id && id.length > 0){
|
85
|
if(this.requestFor == "Publications") {
|
86
|
this._router.navigate( ['participate/deposit-publications-result'], { queryParams: { "organizationId": id } } );
|
87
|
} else if(this.requestFor == "Research Data") {
|
88
|
this._router.navigate( ['participate/deposit-datasets-result'], { queryParams: { "organizationId": id } } );
|
89
|
}
|
90
|
} else {
|
91
|
this.warningMessage = "No organization selected";
|
92
|
}
|
93
|
}
|
94
|
|
95
|
public valueChanged($event) {
|
96
|
this.selectedId = $event.value;
|
97
|
}
|
98
|
|
99
|
private updateDescription(description:string) {
|
100
|
this._meta.updateTag({content:description},"name='description'");
|
101
|
this._meta.updateTag({content:description},"property='og:description'");
|
102
|
}
|
103
|
private updateTitle(title:string) {
|
104
|
var _prefix ="OpenAIRE | ";
|
105
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
106
|
this._title.setTitle(_title);
|
107
|
this._meta.updateTag({content:_title},"property='og:title'");
|
108
|
}
|
109
|
private updateUrl(url:string) {
|
110
|
this._meta.updateTag({content:url},"property='og:url'");
|
111
|
}
|
112
|
}
|