100 lines
3.5 KiB
TypeScript
100 lines
3.5 KiB
TypeScript
import {Component, Input} from '@angular/core';
|
|
import {Observable} from 'rxjs/Observable';
|
|
import { Router, ActivatedRoute} from '@angular/router';
|
|
import { Meta} from '../sharedComponents/metaService';
|
|
import {PiwikService} from '../utils/piwik/piwik.service';
|
|
import{EnvProperties} from '../utils/properties/env-properties';
|
|
|
|
|
|
@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
|
|
@Input() piwikSiteId = null;
|
|
|
|
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;
|
|
properties:EnvProperties;
|
|
|
|
constructor ( private route: ActivatedRoute, private _router: Router, private _meta: Meta, private _piwikService:PiwikService) {
|
|
|
|
this.updateTitle("Deposit "+this.requestFor);
|
|
this.updateDescription("Openaire, repositories, open access, content provider, compatibility, organization, deposit "+ this.requestFor);
|
|
}
|
|
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(this.properties, "Deposit "+this.requestFor, this.piwikSiteId).subscribe();
|
|
}
|
|
});
|
|
}
|
|
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);
|
|
}
|
|
}
|