import {Component, Input, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Meta, Title} from '@angular/platform-browser'; import {EnvProperties} from '../../utils/properties/env-properties'; import {ClaimEntity, ShowOptions} from '../claim-utils/claimHelper.class'; import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service'; import {SearchPublicationsService} from '../../services/searchPublications.service'; import {SearchDatasetsService} from '../../services/searchDatasets.service'; import {SEOService} from '../../sharedComponents/SEO/SEO.service'; import {AlertModal} from "../../utils/modal/alert"; import {HelperFunctions} from "../../utils/HelperFunctions.class"; declare var UIkit:any; @Component({ selector: 'linking-generic', templateUrl: 'linkingGeneric.component.html' }) export class LinkingGenericComponent { @Input() communityId:string= null; sourceType:string; targetType:string; step:number = 1; @Input() results:ClaimEntity[] = []; @Input() inlineEntity:ClaimEntity = null; @Input() showOptions:ShowOptions = new ShowOptions(); //show values: source, result, project, context, claim // linkTo /values: result, project, context // show linkToEntities /values: result, project, context @Input() sources:ClaimEntity[] =[]; sub:any =null; properties:EnvProperties; @Input() localStoragePrefix:string = "linking_"; url=null; @ViewChild(AlertModal) alert; constructor (private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService, private _meta: Meta, private _title: Title, private seoService: SEOService ) { let title = "OpenAIRE | Linking"; this._meta.updateTag({content:title},"property='og:title'"); this._title.setTitle(title); } ngOnInit() { this.showOptions.show = 'source'; if(this.inlineEntity){ this.showOptions.basketShowSources = false; this.showOptions.basketShowLinksTo = true; this.showOptions.show = this.showOptions.linkTo; } this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.url = data.envSpecific.baseLink+this._router.url; this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false); }); if( typeof localStorage !== 'undefined') { this.localStoragePrefix +=(this.communityId?this.communityId+"_":""); if(localStorage.getItem(this.localStoragePrefix + "results")){ this.results = JSON.parse(localStorage.getItem(this.localStoragePrefix + "results")); } if(localStorage.getItem(this.localStoragePrefix + "sources")){ this.sources = JSON.parse(localStorage.getItem(this.localStoragePrefix + "sources")); } } } openSelectionModal() { this.alert.cancelButton = false; this.alert.okButton = false; this.alert.alertTitle = "Select the type of Entity to Link to your sources"; // this.alert.message = "