import {Component, Input} from '@angular/core';
import {ZenodoInformationClass} from './utils/zenodoInformation.class';
import {EnvProperties} from "../utils/properties/env-properties";
import {ActivatedRoute, Router} from "@angular/router";
import {PiwikService} from "../utils/piwik/piwik.service";
import {HelperService} from "../utils/helper/helper.service";
@Component({
selector: 'deposit-first-page',
template: `
0" [texts]="pageContents['bottom']">
`
})
export class DepositFirstPageComponent {
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
@Input() piwikSiteId = null;
piwiksub:any;
@Input() communityId = null;
public pageContents = null;
public divContents = null;
public keyword: string;
public depositRoute = "/participate/deposit/search";
public searchPlaceHolder = "Search for repositories by title, country, organization, subject...";
properties:EnvProperties;
constructor (private route: ActivatedRoute, private _piwikService:PiwikService,
private helper: HelperService,
private _router: Router) {}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
//this.getDivContents();
this.getPageContents();
if (!this.zenodoInformation) {
this.zenodoInformation = new ZenodoInformationClass();
}
if (!this.zenodoInformation.shareInZenodoUrl) {
this.zenodoInformation.url = this.properties.zenodo;
}
if (!this.zenodoInformation.name) {
this.zenodoInformation.name = "Zenodo";
}
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, "Deposit your research (first page)", this.piwikSiteId).subscribe();
}
});
}
public getPageContents() {
this.helper.getPageHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
this.pageContents = contents;
})
}
public getDivContents() {
this.helper.getDivHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
this.divContents = contents;
})
}
ngOnDestroy() {
if(this.piwiksub){
this.piwiksub.unsubscribe();
}
}
}