2021-04-13 16:25:51 +02:00
|
|
|
import {
|
2022-04-12 14:05:53 +02:00
|
|
|
AfterViewInit,
|
|
|
|
ChangeDetectorRef,
|
2021-04-13 16:25:51 +02:00
|
|
|
Component,
|
|
|
|
ElementRef,
|
|
|
|
HostListener,
|
|
|
|
Input,
|
2022-04-16 09:47:30 +02:00
|
|
|
QueryList, ViewChild,
|
2022-04-12 14:05:53 +02:00
|
|
|
ViewChildren
|
2021-04-13 16:25:51 +02:00
|
|
|
} from '@angular/core';
|
2020-03-17 18:48:02 +01:00
|
|
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
2021-02-10 10:33:36 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2024-10-09 08:54:41 +02:00
|
|
|
import {ParsingFunctions} from "./parsingFunctions.class";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-03-16 14:09:46 +01:00
|
|
|
selector: 'showIdentifiers',
|
|
|
|
template: `
|
2022-03-15 12:13:28 +01:00
|
|
|
<!-- <div class="uk-text-muted">Persistent Identifiers</div> -->
|
2022-04-16 09:47:30 +02:00
|
|
|
<ng-template #identifiers_template let-modal="modal">
|
2021-04-13 14:33:40 +02:00
|
|
|
<ng-container *ngFor="let key of keys let i=index">
|
2022-04-16 09:47:30 +02:00
|
|
|
<!-- <div [class.uk-margin-bottom]="modal" [class.multi-line-ellipsis]="!modal" [class.lines-2]="keys.length === 1" [class.line-1]="keys.length > 1">-->
|
|
|
|
<div class="uk-flex-inline uk-flex-wrap uk-margin-medium-right"
|
|
|
|
[class.multi-line-ellipsis]="!modal" [class.lines-2]="keys.length === 1" [class.line-1]="keys.length > 1"
|
|
|
|
[class.uk-margin-bottom]="modal">
|
|
|
|
<p class="uk-margin-remove">
|
|
|
|
<span #content [id]="key" [class.uk-flex]="modal">
|
2022-06-27 11:00:30 +02:00
|
|
|
<span class="uk-text-meta uk-text-small" [class.uk-text-uppercase]="key != 're3data'">{{key}}: </span>
|
2022-04-16 09:47:30 +02:00
|
|
|
<span [class.uk-margin-small-left]="modal">
|
|
|
|
<ng-container *ngFor="let item of identifiers.get(key) let j=index">
|
2024-10-09 08:54:41 +02:00
|
|
|
<a *ngIf="parsingFunctions.identifierTypes.indexOf(key) != -1"
|
2024-03-04 12:14:09 +01:00
|
|
|
[href]="getUrl(key, item) + item" target="_blank" class="uk-display-inline-block custom-external">
|
2022-04-16 09:47:30 +02:00
|
|
|
{{item}}
|
|
|
|
</a>
|
|
|
|
<ng-container *ngIf="(j !== (identifiers.get(key).length - 1))">, </ng-container>
|
|
|
|
</ng-container>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<!-- </div>-->
|
2020-03-16 14:09:46 +01:00
|
|
|
</ng-container>
|
2022-04-16 09:47:30 +02:00
|
|
|
</ng-template>
|
|
|
|
|
|
|
|
<div class="uk-height-max-medium uk-overflow-auto uk-text-small">
|
|
|
|
<ng-container *ngTemplateOutlet="identifiers_template; context: { modal: false}"></ng-container>
|
2021-04-13 14:33:40 +02:00
|
|
|
</div>
|
|
|
|
<div *ngIf="isLarge && showViewAll" class="uk-text-right uk-margin-small-top">
|
2022-06-09 15:45:39 +02:00
|
|
|
<a (click)="openIdentifiersModal()" class="view-more-less-link">View all</a>
|
2021-04-13 14:33:40 +02:00
|
|
|
</div>
|
2022-04-16 09:47:30 +02:00
|
|
|
|
2023-02-22 22:13:46 +01:00
|
|
|
<modal-alert *ngIf="!isMobile" #identifiersModal>
|
2022-04-20 16:40:18 +02:00
|
|
|
<div class="uk-text-small">
|
2022-04-16 09:47:30 +02:00
|
|
|
<ng-container *ngTemplateOutlet="identifiers_template; context: { modal: true}"></ng-container>
|
|
|
|
</div>
|
|
|
|
</modal-alert>
|
2023-02-22 22:13:46 +01:00
|
|
|
|
2023-08-21 12:59:20 +02:00
|
|
|
<fs-modal *ngIf="isMobile" #identifiersModal classTitle="uk-tile-default uk-border-bottom">
|
2023-02-22 22:13:46 +01:00
|
|
|
<div class="uk-text-small">
|
|
|
|
<ng-container *ngTemplateOutlet="identifiers_template; context: { modal: true}"></ng-container>
|
|
|
|
</div>
|
|
|
|
</fs-modal>
|
2020-03-16 14:09:46 +01:00
|
|
|
`
|
|
|
|
})
|
2021-04-13 16:25:51 +02:00
|
|
|
export class ShowIdentifiersComponent implements AfterViewInit {
|
2023-02-22 22:13:46 +01:00
|
|
|
@Input() isMobile: boolean = false;
|
2020-03-16 14:09:46 +01:00
|
|
|
@Input() identifiers: Map<string, string[]>;
|
2021-04-13 14:33:40 +02:00
|
|
|
@Input() showViewAll: boolean = false;
|
|
|
|
large: Map<string, boolean> = new Map<string, boolean>();
|
|
|
|
properties: EnvProperties = properties;
|
2021-04-13 16:25:51 +02:00
|
|
|
@ViewChildren("content", { read: ElementRef }) types: QueryList<ElementRef>;
|
2022-04-16 09:47:30 +02:00
|
|
|
@ViewChild('identifiersModal') identifiersModal;
|
2024-10-09 08:54:41 +02:00
|
|
|
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
|
2021-04-16 13:45:42 +02:00
|
|
|
constructor(private cdr: ChangeDetectorRef) {
|
|
|
|
}
|
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
onResize(event) {
|
|
|
|
this.checkLarge();
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
ngAfterViewInit() {
|
|
|
|
this.checkLarge();
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
checkLarge() {
|
|
|
|
let overflow = (this.keys.length === 1?42:21);
|
|
|
|
if(typeof document !== "undefined") {
|
|
|
|
this.keys.forEach(key => {
|
2021-04-13 16:25:51 +02:00
|
|
|
let type = this.types.find(type => type.nativeElement.id === key);
|
2021-04-16 13:45:42 +02:00
|
|
|
this.large.set(key, type && type.nativeElement.offsetHeight > overflow);
|
2021-04-13 14:33:40 +02:00
|
|
|
});
|
2021-04-16 13:45:42 +02:00
|
|
|
this.cdr.detectChanges();
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
get isLarge() {
|
|
|
|
for(let key of this.keys) {
|
|
|
|
if (this.large.get(key)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
public get keys(): string[] {
|
|
|
|
return Array.from(this.identifiers.keys()).sort((a: string, b: string) => {
|
|
|
|
if (a === 'doi') {
|
2020-03-16 14:09:46 +01:00
|
|
|
return -1;
|
2021-04-13 14:33:40 +02:00
|
|
|
} else if (b === 'doi') {
|
2020-03-16 14:09:46 +01:00
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-04-16 09:47:30 +02:00
|
|
|
|
2024-03-04 12:14:09 +01:00
|
|
|
public getUrl(key: string, value: string): string {
|
|
|
|
if(value.includes("http://") || value.includes("https://")) {
|
|
|
|
return "";
|
|
|
|
}
|
2024-10-09 08:54:41 +02:00
|
|
|
if(key == "doi" || key == "Digital Object Identifier") {
|
2022-04-16 09:47:30 +02:00
|
|
|
return properties.doiURL;
|
|
|
|
} else if(key == "pmc") {
|
|
|
|
return properties.pmcURL;
|
|
|
|
} else if(key == "pmid") {
|
|
|
|
return properties.pmidURL;
|
|
|
|
} else if(key == "handle") {
|
|
|
|
return properties.handleURL;
|
2022-05-16 16:01:35 +02:00
|
|
|
} else if(key == "re3data") {
|
|
|
|
return properties.r3DataURL;
|
2023-10-06 11:22:00 +02:00
|
|
|
} else if(key == "swhid") {
|
|
|
|
return properties.swhURL;
|
2024-03-04 12:14:09 +01:00
|
|
|
} else if(key == "ROR") {
|
|
|
|
return properties.rorURL;
|
|
|
|
} else if(key == "ISNI") {
|
|
|
|
return properties.isniURL;
|
|
|
|
} else if(key == "Wikidata") {
|
|
|
|
return properties.wikiDataURL;
|
|
|
|
} else if(key == "FundRef") {
|
|
|
|
return properties.fundRefURL;
|
2022-04-16 09:47:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public openIdentifiersModal() {
|
2023-02-22 22:13:46 +01:00
|
|
|
if(this.isMobile) {
|
|
|
|
this.identifiersModal.okButton = false;
|
|
|
|
this.identifiersModal.title = "Persistent Identifiers";
|
|
|
|
this.identifiersModal.open();
|
|
|
|
} else {
|
|
|
|
this.identifiersModal.cancelButton = false;
|
|
|
|
this.identifiersModal.okButton = false;
|
|
|
|
this.identifiersModal.alertTitle = "Persistent Identifiers";
|
|
|
|
this.identifiersModal.open();
|
|
|
|
}
|
2022-04-16 09:47:30 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|