import {Component, Input, OnInit, ViewChild} from "@angular/core"; import {StringUtils} from "../string-utils.class"; import {RouterHelper} from "../routerHelper.class"; import {properties} from "../../../../environments/environment"; import {Router} from "@angular/router"; import {Option} from "../../sharedComponents/input/input.component"; import {OpenaireEntities} from "../properties/searchFields"; import {EnvProperties} from "../properties/env-properties"; @Component({ selector: 'entity-actions', template: `
Link to
Share
Cite
Deposit
Embed
{{getDynamicContent(embed_research_results_type)}}
For further information contact us at {{properties.helpdeskEmail}}
` }) export class EntityActionsComponent implements OnInit { @Input() result: any; @Input() type: string; @Input() id: string; @Input() linking: boolean = false; @Input() share: boolean = false; @Input() cite: boolean = false; @Input() deposit: boolean = false; @Input() embed: boolean = false; @Input() url: string; @Input() isMobile: boolean = false; public citeThisClicked: boolean; public routerHelper: RouterHelper = new RouterHelper(); @ViewChild('citeModal') citeModal; @ViewChild('embedResultsModal') embedResultsModal; @ViewChild('addThisModal') addThisModal; properties: EnvProperties = properties; openaireEntities = OpenaireEntities; /* Embed */ public embed_research_results_type: string = "result"; public clipboard; public resultTypesForEmbedding: Option[]=[ {label: "All "+OpenaireEntities.RESULTS, value: "result"}, {label: OpenaireEntities.PUBLICATIONS, value: "publication"}, {label: OpenaireEntities.DATASETS, value: "dataset"}, {label: OpenaireEntities.SOFTWARE, value: "software"}, {label: OpenaireEntities.OTHER, value: "other"}]; constructor(private router: Router) { } ngOnInit() { this.createClipboard(); } get linkTo():string { return this.type === 'project'?'result':'project'; } public getTypeName(): string { return StringUtils.getEntityName(this.type, false); } public openCiteModal() { this.citeThisClicked = true; this.citeModal.cancelButton = false; this.citeModal.okButton = false; this.citeModal.alertTitle = "Cite this " + this.getTypeName(); this.citeModal.open(); } public openAddThisModal() { this.addThisModal.cancelButton = false; this.addThisModal.okButton = false; this.addThisModal.alertTitle = "Share this " + this.getTypeName() + " in your social networks"; this.addThisModal.open(); } public openEmbedResultsModal() { this.embedResultsModal.cancelButton = false; this.embedResultsModal.okButton = false; this.embedResultsModal.alertTitle = "Embed results"; this.embedResultsModal.open(); } private createClipboard() { if (typeof window !== 'undefined') { delete this.clipboard; let Clipboard; Clipboard = require('clipboard'); this.clipboard = new Clipboard('.clipboard_btn'); } } getDynamicContent(type: string) { return ""; } isRouteAvailable(routeToCheck: string) { for (let i = 0; i < this.router.config.length; i++) { let routePath: string = this.router.config[i].path; if (routePath == routeToCheck) { return true; } } return false; } }