import {Component, Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; import {Observable} from 'rxjs/Observable'; import {EnvProperties} from '../../utils/properties/env-properties'; import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class'; import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service'; import {SearchPublicationsService} from '../../services/searchPublications.service'; import {SearchDatasetsService} from '../../services/searchDatasets.service'; declare var UIkit:any; @Component({ selector: 'linking-generic', templateUrl: 'linkingGeneric.component.html' }) export class LinkingGenericComponent { @Input() bulkMode: boolean = false; sourceType:string; targetType:string; step:number = 1; contexts=[]; projects=[]; results = []; show = "project"; date='8-6-2016'; keyword: string = ""; linkType:string ="project"; // link type (selected in home page) : project, context, software, etc /* url Parameters for inline linking */ id:string = null; //entity id type:string = null; // entity type (publication or research data) linkTo:string = null; // entity type (project or context or result) entityTypes=["dataset", "publication", "project","context"]; inlineResult:ClaimResult =null; sub:any =null; properties:EnvProperties; constructor (private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService, private _meta: Meta, private _title: Title) { var title = "OpenAIRE | Linking"; this._meta.updateTag({content:title},"property='og:title'"); this._title.setTitle(title); } ngOnInit() { this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; }); if( typeof localStorage !== 'undefined') { if(localStorage.getItem("projects")){ this.projects = JSON.parse(localStorage.getItem("projects")); } if(localStorage.getItem("contexts")){ this.contexts = JSON.parse(localStorage.getItem("contexts")); } if(localStorage.getItem("results")){ this.results = JSON.parse(localStorage.getItem("results")); } localStorage.removeItem("projects"); localStorage.removeItem("contexts"); localStorage.removeItem("results"); } } next(){ if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){ this.show='claim'; } } prev(){ if(this.show == 'claim'){ this.show='result'; } } resultsChange($event) { this.results=$event.value; } projectsChange($event) { this.projects=$event.value; } linkTypeChange($event) { this.linkType =$event.value; this.show="result"; if(this.bulkMode){ this.show="claim"; } } showChange($event) { this.show=$event.value; this.showChangedType($event.value); } showChangedType(type:string) { this.show=type; if(this.show == 'project' || this.show == 'context' || this.show == 'software'){ this.linkType = this.show; } } canProceedToMetadata(){ if(this.results.length == 0){ UIkit.notification({ message : 'No research results selected!
Please select research results to link with projects and/ or ommunities.', status : 'warning', timeout : 1000, pos : 'top-center' }); }else{ this.show = 'claim'; this.step = 3; } } }