import {Component, Input} from '@angular/core'; import {Router, ActivatedRoute} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; import {Observable} from 'rxjs'; import {EnvProperties} from '../utils/properties/env-properties'; import {PiwikService} from '../utils/piwik/piwik.service'; import { SEOService } from '../sharedComponents/SEO/SEO.service'; import {ZenodoInformationClass} from './utils/zenodoInformation.class'; @Component({ selector: 'deposit', templateUrl: 'deposit.component.html' }) export class DepositComponent { @Input() zenodoInformation: ZenodoInformationClass; @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; url=null; constructor (private route: ActivatedRoute, private _router: Router, private _meta: Meta, private _title: Title, private _piwikService:PiwikService, private seoService: SEOService ) { var title = "Deposit "+this.requestFor; var description = "Openaire, repositories, open access, content provider, compatibility, organization, deposit "+ this.requestFor; this.updateTitle(title); this.updateDescription(description); } ngOnInit() { this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false); this.updateUrl(data.envSpecific.baseLink+this._router.url); this.url = data.envSpecific.baseLink+this._router.url; 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; 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) { 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.updateTag({content:description},"name='description'"); this._meta.updateTag({content:description},"property='og:description'"); } private updateTitle(title:string) { var _prefix ="OpenAIRE | "; var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title); this._title.setTitle(_title); this._meta.updateTag({content:_title},"property='og:title'"); } private updateUrl(url:string) { this._meta.updateTag({content:url},"property='og:url'"); } }