2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
2018-02-05 14:14:59 +01:00
|
|
|
import { Router, ActivatedRoute} from '@angular/router';
|
2017-12-19 13:53:46 +01:00
|
|
|
import { Meta} from '../../angular2-meta';
|
|
|
|
import {PiwikService} from '../utils/piwik/piwik.service';
|
2018-02-05 14:14:59 +01:00
|
|
|
import{EnvProperties} from '../utils/properties/env-properties';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'deposit',
|
|
|
|
templateUrl: 'deposit.component.html'
|
|
|
|
})
|
|
|
|
|
|
|
|
export class DepositComponent {
|
|
|
|
@Input() compatibility: string = '';
|
|
|
|
@Input() mapUrl: string = null; // optional in case i-frame is needed
|
|
|
|
@Input() searchBySubjects: boolean = false; // optional: in case search by subjects is needed
|
|
|
|
|
|
|
|
|
|
|
|
public status: number;
|
|
|
|
|
|
|
|
// Type of entity: Publication or Research Data
|
|
|
|
@Input() requestFor: string = "Publications";
|
|
|
|
|
|
|
|
// url's needed for information text
|
|
|
|
public openAccess: string;
|
|
|
|
public openAccessRepo: string;
|
|
|
|
public fp7Guidlines: string;
|
|
|
|
public h2020Guidlines: string;
|
|
|
|
public ercGuidlines: string;
|
|
|
|
public helpdesk: string;
|
|
|
|
|
|
|
|
// Id of the new selected organization to be searched
|
|
|
|
public selectedId: string = "";
|
|
|
|
|
|
|
|
public warningMessage: string = "";
|
|
|
|
|
|
|
|
piwiksub:any;
|
2018-02-05 14:14:59 +01:00
|
|
|
properties:EnvProperties;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
constructor ( private route: ActivatedRoute, private _router: Router, private _meta: Meta, private _piwikService:PiwikService) {
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
this.updateTitle("Deposit "+this.requestFor);
|
|
|
|
this.updateDescription("Openaire, repositories, open access, content provider, compatibility, organization, deposit "+ this.requestFor);
|
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
ngOnInit() {
|
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
|
|
|
this.openAccess = this.properties.openAccess;
|
|
|
|
this.openAccessRepo = this.properties.openAccessRepo;
|
|
|
|
this.fp7Guidlines = this.properties.fp7Guidlines
|
|
|
|
this.h2020Guidlines = this.properties.h2020Guidlines
|
|
|
|
this.ercGuidlines = this.properties.ercGuidlines
|
|
|
|
this.helpdesk = this.properties.helpdesk;
|
|
|
|
this.updateUrl(data.envSpecific.baseLink+this._router.url);
|
|
|
|
|
|
|
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
|
|
|
this.piwiksub = this._piwikService.trackView("Deposit "+this.requestFor).subscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
if(this.piwiksub){
|
|
|
|
this.piwiksub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public organizationSelected(id: string) {
|
|
|
|
console.info("organization selected");
|
|
|
|
if(id && id.length > 0){
|
|
|
|
if(this.requestFor == "Publications") {
|
|
|
|
this._router.navigate( ['participate/deposit-publications-result'], { queryParams: { "organizationId": id } } );
|
|
|
|
} else if(this.requestFor == "Research Data") {
|
|
|
|
this._router.navigate( ['participate/deposit-datasets-result'], { queryParams: { "organizationId": id } } );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.warningMessage = "No organization selected";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public valueChanged($event){
|
|
|
|
this.selectedId = $event.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
private updateDescription(description:string){
|
|
|
|
this._meta.updateMeta("description", description);
|
|
|
|
this._meta.updateProperty("og:description", description);
|
|
|
|
}
|
|
|
|
private updateTitle(title:string){
|
|
|
|
var _prefix ="OpenAIRE | ";
|
|
|
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
|
|
|
this._meta.setTitle(_title );
|
|
|
|
this._meta.updateProperty("og:title",_title);
|
|
|
|
}
|
|
|
|
private updateUrl(url:string){
|
|
|
|
this._meta.updateProperty("og:url", url);
|
|
|
|
}
|
|
|
|
}
|