2023-02-22 13:43:31 +01:00
|
|
|
import {Component, Input, OnInit, ViewChild} from "@angular/core";
|
2023-02-20 15:59:07 +01:00
|
|
|
import {StringUtils} from "../string-utils.class";
|
|
|
|
import {RouterHelper} from "../routerHelper.class";
|
|
|
|
import {properties} from "../../../../environments/environment";
|
2023-02-22 13:43:31 +01:00
|
|
|
import {Router} from "@angular/router";
|
|
|
|
import {Option} from "../../sharedComponents/input/input.component";
|
|
|
|
import {OpenaireEntities} from "../properties/searchFields";
|
|
|
|
import {EnvProperties} from "../properties/env-properties";
|
2023-02-20 15:59:07 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'entity-actions',
|
|
|
|
template: `
|
|
|
|
<div class="uk-grid uk-grid-small uk-child-width-auto" uk-grid>
|
2023-02-22 13:43:31 +01:00
|
|
|
<a *ngIf="linking && isRouteAvailable('participate/direct-claim')"
|
2023-02-20 15:59:07 +01:00
|
|
|
[queryParams]="routerHelper.createQueryParams(['id','type','linkTo'], [id,type,linkTo])"
|
|
|
|
routerLinkActive="router-link-active" routerLink="/participate/direct-claim"
|
|
|
|
[title]="'Link this '+getTypeName()+' to ...'"
|
2023-02-22 13:55:19 +01:00
|
|
|
[attr.uk-tooltip]="'pos: bottom; cls: uk-active uk-text-small uk-padding-small'"
|
2023-02-20 15:59:07 +01:00
|
|
|
class="uk-flex uk-flex-middle uk-flex-center uk-button-link uk-text-bolder">
|
|
|
|
<icon [flex]="true" [ratio]="0.7" name="link_to" visuallyHidden="link"></icon>
|
|
|
|
<span class="uk-margin-xsmall-left">Link to</span>
|
|
|
|
</a>
|
|
|
|
<a *ngIf="share" (click)="openAddThisModal()"
|
|
|
|
class="uk-flex uk-flex-middle uk-flex-center uk-button-link uk-text-bolder">
|
|
|
|
<icon [flex]="true" [ratio]="0.8" name="share" visuallyHidden="share"></icon>
|
|
|
|
<span class="uk-margin-xsmall-left">Share</span>
|
|
|
|
</a>
|
|
|
|
<a *ngIf="cite" (click)="openCiteModal()"
|
|
|
|
class="uk-flex uk-flex-middle uk-flex-center uk-button-link uk-text-bolder">
|
|
|
|
<icon [flex]="true" [ratio]="0.7" name="cite" visuallyHidden="cite"></icon>
|
|
|
|
<span class="uk-margin-xsmall-left">Cite</span>
|
|
|
|
</a>
|
2023-02-22 13:43:31 +01:00
|
|
|
<a *ngIf="deposit && isRouteAvailable('participate/deposit/learn-how')" routerLinkActive="router-link-active" routerLink="/participate/deposit/learn-how"
|
|
|
|
[title]="'Find a repository to deposit or publish your research in Open Access'"
|
|
|
|
[attr.uk-tooltip]="'pos: bottom; cls: uk-active uk-text-small uk-padding-small uk-width-medium'"
|
|
|
|
class="uk-flex uk-flex-middle uk-flex-center uk-button-link uk-text-bolder">
|
|
|
|
<icon flex="true" ratio="0.7" name="upload" visuallyHidden="upload"></icon>
|
|
|
|
<span class="uk-margin-xsmall-left">Deposit</span>
|
|
|
|
</a>
|
|
|
|
<a *ngIf="embed" (click)="openEmbedResultsModal()"
|
|
|
|
class="uk-flex uk-flex-middle uk-flex-center uk-button-link uk-text-bolder">
|
|
|
|
<icon flex="true" ratio="0.8" name="code_off" visuallyHidden="code"></icon>
|
|
|
|
<span class="uk-margin-xsmall-left">Embed</span>
|
|
|
|
</a>
|
2023-02-20 15:59:07 +01:00
|
|
|
<ng-content></ng-content>
|
|
|
|
</div>
|
|
|
|
<modal-alert *ngIf="cite" #citeModal>
|
|
|
|
<citeThis *ngIf="citeThisClicked" [result]="result" [id]="id"
|
2023-02-22 13:43:31 +01:00
|
|
|
[type]="getTypeName().toLowerCase()" [piwikSiteId]="properties.piwikSiteId"></citeThis>
|
2023-02-20 15:59:07 +01:00
|
|
|
</modal-alert>
|
|
|
|
<modal-alert *ngIf="share" #addThisModal classBody="uk-flex uk-flex-center uk-flex-middle">
|
|
|
|
<addThis [url]="url"></addThis>
|
|
|
|
</modal-alert>
|
2023-02-22 13:43:31 +01:00
|
|
|
<modal-alert *ngIf="result" #embedResultsModal large="true">
|
|
|
|
<div class="uk-padding-small uk-margin-small-left uk-margin-small-right">
|
|
|
|
<div class="uk-padding-small uk-padding-remove-vertical">
|
|
|
|
<div input type="select" placeholder="Select content type to embed" inputClass="flat x-small"
|
|
|
|
[options]="resultTypesForEmbedding" [(value)]="embed_research_results_type"></div>
|
|
|
|
<div *ngIf="embed_research_results_type" class="clipboard-wrapper box-content uk-grid uk-margin-auto uk-margin-small-top ">
|
|
|
|
<pre id="dynamic_content_id" class="uk-overflow-auto uk-padding-small uk-padding-remove-vertical uk-margin-top"><code
|
|
|
|
>{{getDynamicContent(embed_research_results_type)}}</code></pre>
|
|
|
|
<div class="uk-width-1-1 uk-padding-small uk-text-right">
|
|
|
|
<a class="uk-link copy clipboard_btn" data-clipboard-target="#dynamic_content_id" title="Copy script">
|
|
|
|
COPY SCRIPT
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="uk-text-small uk-margin-top">
|
|
|
|
For further information contact us at
|
|
|
|
<u><a [href]="'mailto:'+properties.helpdeskEmail" class="uk-link-text">{{properties.helpdeskEmail}}</a></u>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</modal-alert>
|
2023-02-20 15:59:07 +01:00
|
|
|
`
|
|
|
|
})
|
2023-02-22 13:43:31 +01:00
|
|
|
export class EntityActionsComponent implements OnInit {
|
2023-02-20 15:59:07 +01:00
|
|
|
@Input() result: any;
|
|
|
|
@Input() type: string;
|
|
|
|
@Input() id: string;
|
|
|
|
@Input() linking: boolean = false;
|
|
|
|
@Input() share: boolean = false;
|
|
|
|
@Input() cite: boolean = false;
|
2023-02-22 13:43:31 +01:00
|
|
|
@Input() deposit: boolean = false;
|
|
|
|
@Input() embed: boolean = false;
|
2023-02-20 15:59:07 +01:00
|
|
|
@Input() url: string;
|
|
|
|
public citeThisClicked: boolean;
|
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
@ViewChild('citeModal') citeModal;
|
2023-02-22 13:43:31 +01:00
|
|
|
@ViewChild('embedResultsModal') embedResultsModal;
|
|
|
|
@ViewChild('downloadReportModal') downloadReportModal;
|
2023-02-20 15:59:07 +01:00
|
|
|
@ViewChild('addThisModal') addThisModal;
|
2023-02-22 13:43:31 +01:00
|
|
|
properties: EnvProperties = properties;
|
|
|
|
|
|
|
|
|
|
|
|
/* 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) {
|
2023-02-20 15:59:07 +01:00
|
|
|
}
|
2023-02-22 13:43:31 +01:00
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.createClipboard();
|
|
|
|
}
|
|
|
|
|
2023-02-20 15:59:07 +01:00
|
|
|
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();
|
|
|
|
}
|
2023-02-22 13:43:31 +01:00
|
|
|
|
|
|
|
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 "<script type=\"text/javascript\">"
|
|
|
|
+ "\n<!--"
|
|
|
|
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
|
|
|
|
+ "\ndocument.write('<script type=\"text/javascript\""
|
|
|
|
+ " src=\"" + this.properties.widgetLink
|
|
|
|
+ this.result.id + "&type="
|
|
|
|
+ type
|
|
|
|
+ "\"></script>');"
|
|
|
|
+ "\n-->"
|
|
|
|
+ "\n</script>";
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2023-02-20 15:59:07 +01:00
|
|
|
}
|