1
|
import {Component, Input} from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
import { Router } from '@angular/router';
|
4
|
import {OpenaireProperties} from '../utils/properties/openaireProperties';
|
5
|
import { Meta} from '../../angular2-meta';
|
6
|
import {PiwikService} from '../utils/piwik/piwik.service';
|
7
|
|
8
|
|
9
|
@Component({
|
10
|
selector: 'deposit',
|
11
|
templateUrl: 'deposit.component.html'
|
12
|
})
|
13
|
|
14
|
export class DepositComponent {
|
15
|
@Input() compatibility: string = '';
|
16
|
@Input() mapUrl: string = null; // optional in case i-frame is needed
|
17
|
@Input() searchBySubjects: boolean = false; // optional: in case search by subjects is needed
|
18
|
|
19
|
|
20
|
public status: number;
|
21
|
|
22
|
// Type of entity: Publication or Research Data
|
23
|
@Input() requestFor: string = "Publications";
|
24
|
|
25
|
// url's needed for information text
|
26
|
public openAccess: string;
|
27
|
public openAccessRepo: string;
|
28
|
public fp7Guidlines: string;
|
29
|
public h2020Guidlines: string;
|
30
|
public ercGuidlines: string;
|
31
|
public helpdesk: string;
|
32
|
|
33
|
// Id of the new selected organization to be searched
|
34
|
public selectedId: string = "";
|
35
|
|
36
|
public warningMessage: string = "";
|
37
|
|
38
|
piwiksub:any;
|
39
|
|
40
|
constructor (private _router: Router, private _meta: Meta, private _piwikService:PiwikService) {
|
41
|
|
42
|
this.openAccess = OpenaireProperties.getOpenAccess();
|
43
|
this.openAccessRepo = OpenaireProperties.getOpenAccessRepo();
|
44
|
this.fp7Guidlines = OpenaireProperties.getFP7Guidlines();
|
45
|
this.h2020Guidlines = OpenaireProperties.getH2020Guidlines();
|
46
|
this.ercGuidlines = OpenaireProperties.getERCGuidlines();
|
47
|
this.helpdesk = OpenaireProperties.getHelpdesk();
|
48
|
this.updateTitle("Deposit "+this.requestFor);
|
49
|
this.updateDescription("Openaire, repositories, open access, content provider, compatibility, organization, deposit "+ this.requestFor);
|
50
|
this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url);
|
51
|
if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){
|
52
|
this.piwiksub = this._piwikService.trackView("Deposit "+this.requestFor).subscribe();
|
53
|
}
|
54
|
}
|
55
|
ngOnDestroy() {
|
56
|
if(this.piwiksub){
|
57
|
this.piwiksub.unsubscribe();
|
58
|
}
|
59
|
}
|
60
|
|
61
|
public organizationSelected(id: string) {
|
62
|
console.info("organization selected");
|
63
|
if(id && id.length > 0){
|
64
|
if(this.requestFor == "Publications") {
|
65
|
this._router.navigate( ['participate/deposit-publications-result'], { queryParams: { "organizationId": id } } );
|
66
|
} else if(this.requestFor == "Research Data") {
|
67
|
this._router.navigate( ['participate/deposit-datasets-result'], { queryParams: { "organizationId": id } } );
|
68
|
}
|
69
|
} else {
|
70
|
this.warningMessage = "No organization selected";
|
71
|
}
|
72
|
}
|
73
|
|
74
|
public valueChanged($event){
|
75
|
this.selectedId = $event.value;
|
76
|
}
|
77
|
|
78
|
private updateDescription(description:string){
|
79
|
this._meta.updateMeta("description", description);
|
80
|
this._meta.updateProperty("og:description", description);
|
81
|
}
|
82
|
private updateTitle(title:string){
|
83
|
var _prefix ="OpenAIRE | ";
|
84
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
85
|
this._meta.setTitle(_title );
|
86
|
this._meta.updateProperty("og:title",_title);
|
87
|
}
|
88
|
private updateUrl(url:string){
|
89
|
this._meta.updateProperty("og:url", url);
|
90
|
}
|
91
|
}
|