2022-04-20 16:40:18 +02:00
|
|
|
import {
|
|
|
|
ChangeDetectorRef,
|
|
|
|
Component,
|
2023-02-20 16:56:02 +01:00
|
|
|
ElementRef, EventEmitter,
|
2022-04-20 16:40:18 +02:00
|
|
|
HostListener,
|
2023-02-20 16:56:02 +01:00
|
|
|
Input, Output,
|
2022-04-20 16:40:18 +02:00
|
|
|
QueryList,
|
|
|
|
ViewChild,
|
|
|
|
ViewChildren
|
|
|
|
} from '@angular/core';
|
2021-11-09 15:02:32 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-03-16 14:09:46 +01:00
|
|
|
selector: 'showSubjects',
|
2022-04-20 16:40:18 +02:00
|
|
|
template: `
|
2024-07-11 15:35:19 +02:00
|
|
|
<!-- <ng-container *ngIf="properties.environment == 'production' && !viewAllSubjects && ((classifiedSubjects && classifiedSubjects.size > 0) || (eoscSubjects && eoscSubjects.length > 0))">-->
|
|
|
|
<!-- <div *ngIf="!viewAllClassifiedSubjects" class="uk-text-meta">-->
|
|
|
|
<!-- Subjects by Vocabulary-->
|
|
|
|
<!-- </div>-->
|
|
|
|
<!-- <ng-container *ngTemplateOutlet="subjects_by_vocabulary_template; context: {customClasses: (isMobile && viewAllClassifiedSubjects) ? '' : 'multi-line-ellipsis lines-2', id: 'content'}"></ng-container>-->
|
|
|
|
<!-- <ng-container *ngIf="eoscSubjects && eoscSubjects.length > 0"><ng-container *ngTemplateOutlet="eosc_subjects_template"></ng-container></ng-container>-->
|
|
|
|
<!-- <div *ngIf="isClassifiedLarge && !viewAllClassifiedSubjects" class="uk-text-right">-->
|
|
|
|
<!-- <a (click)="viewAllSubjectsByVocabularyClicked()" class="view-more-less-link">View all</a>-->
|
|
|
|
<!-- </div>-->
|
|
|
|
<!-- </ng-container>-->
|
2024-01-25 11:31:14 +01:00
|
|
|
|
2023-02-20 16:56:02 +01:00
|
|
|
<ng-container *ngIf="!viewAllClassifiedSubjects && ((subjects && subjects.length > 0) || (otherSubjects && otherSubjects.size > 0))">
|
2024-07-11 15:35:19 +02:00
|
|
|
<div *ngIf="!viewAllSubjects" class="uk-text-meta uk-margin-small-bottom">
|
2023-04-06 11:46:50 +02:00
|
|
|
Keywords
|
2022-04-20 16:40:18 +02:00
|
|
|
</div>
|
2023-02-20 16:56:02 +01:00
|
|
|
<ng-container *ngTemplateOutlet="subjects_template; context: {customClasses: (isMobile && viewAllSubjects) ? '' : 'multi-line-ellipsis lines-2', id: 'content'}"></ng-container>
|
|
|
|
<div *ngIf="isLarge && !viewAllSubjects" class="uk-text-right uk-margin-small-top">
|
|
|
|
<a (click)="viewAllSubjectsClicked()" class="view-more-less-link">View all</a>
|
2022-04-20 16:40:18 +02:00
|
|
|
</div>
|
|
|
|
</ng-container>
|
2024-01-25 11:31:14 +01:00
|
|
|
|
2024-07-11 15:35:19 +02:00
|
|
|
<ng-container *ngIf="!viewAllSubjects && ((eoscSubjects && eoscSubjects.length > 0))">
|
2024-01-25 11:31:14 +01:00
|
|
|
<div class="uk-text-meta uk-margin-small-bottom"
|
|
|
|
[class.uk-margin-medium-top]="(subjects && subjects.length > 0) || (otherSubjects && otherSubjects.size > 0)">
|
|
|
|
EOSC Subjects
|
|
|
|
</div>
|
|
|
|
<div *ngIf="eoscSubjects && eoscSubjects.length > 0">
|
|
|
|
<ng-container *ngTemplateOutlet="eosc_subjects_template; context: {id: 'content'}"></ng-container>
|
|
|
|
</div>
|
|
|
|
</ng-container>
|
2022-04-20 16:40:18 +02:00
|
|
|
|
|
|
|
<ng-template #subjects_template let-customClasses="customClasses" let-id="id">
|
|
|
|
<div class="uk-text-break" [ngClass]="customClasses">
|
|
|
|
<p *ngIf="subjects && subjects.length > 0"><span #content [id]="id">{{subjects.join(', ')}}</span></p>
|
|
|
|
<!-- <span *ngIf="(subjects && subjects.length > 0) && (otherSubjects && otherSubjects.size > 0)">, </span>-->
|
|
|
|
<!-- <span *ngIf="otherSubjects && otherSubjects.size > 0">-->
|
|
|
|
<!-- <span *ngFor="let key of getKeys(otherSubjects); let i=index">-->
|
|
|
|
<!-- <span *ngIf="otherSubjects.get(key).length > 0">-->
|
|
|
|
<!-- <span>{{otherSubjects.get(key).join(', ')}}</span>-->
|
|
|
|
<!-- <span *ngIf="i < (otherSubjects.size - 1)">, </span>-->
|
|
|
|
<!-- </span>-->
|
|
|
|
<!-- </span>-->
|
|
|
|
<!-- </span>-->
|
|
|
|
</div>
|
|
|
|
</ng-template>
|
|
|
|
|
2023-02-20 16:56:02 +01:00
|
|
|
<modal-alert #subjectsModal *ngIf="!isMobile && ((subjects && subjects.length > 0) || (otherSubjects && otherSubjects.size > 0))">
|
2022-04-20 16:40:18 +02:00
|
|
|
<div class="uk-text-small">
|
|
|
|
<ng-container *ngTemplateOutlet="subjects_template"></ng-container>
|
2020-05-26 16:42:47 +02:00
|
|
|
</div>
|
2022-04-20 16:40:18 +02:00
|
|
|
</modal-alert>
|
2022-06-09 15:45:39 +02:00
|
|
|
|
|
|
|
<ng-template #subjects_by_vocabulary_template let-customClasses="customClasses" let-id="id">
|
|
|
|
<div *ngFor="let key of getKeys(classifiedSubjects) let i=index"
|
2022-06-09 16:51:58 +02:00
|
|
|
class="uk-flex-wrap uk-margin-medium-right"
|
2022-06-09 15:45:39 +02:00
|
|
|
[ngClass]="customClasses">
|
2022-06-15 12:32:22 +02:00
|
|
|
<p class="uk-flex uk-flex-middle uk-margin-bottom">
|
|
|
|
<span #classifiedContent [id]="id+'_'+key">
|
|
|
|
<span class="uk-margin-small-top uk-display-inline-block">
|
|
|
|
<span uk-icon="tag"></span>
|
|
|
|
<span class="uk-text-bold uk-margin-small-right"> {{key}}: </span>
|
|
|
|
</span>
|
|
|
|
<span *ngFor="let subject of classifiedSubjects.get(key); let j=index" class="uk-margin-small-top uk-width-auto uk-display-inline-block">
|
|
|
|
<span class="uk-border-rounded uk-label uk-label-small uk-label-primary uk-text-truncate uk-margin-small-right">
|
|
|
|
{{subject}}
|
|
|
|
</span>
|
2022-06-09 15:45:39 +02:00
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</ng-template>
|
2022-08-30 10:35:42 +02:00
|
|
|
|
|
|
|
<ng-template #eosc_subjects_template let-customClasses="customClasses" let-id="id">
|
|
|
|
<div class="uk-flex-wrap uk-margin-medium-right"
|
|
|
|
[ngClass]="customClasses">
|
2024-07-11 15:35:19 +02:00
|
|
|
<!-- <p *ngIf="properties.environment == 'production'" class="uk-flex uk-flex-middle uk-margin-bottom">-->
|
|
|
|
<!-- <span #classifiedContent [id]="id+'_eosc'">-->
|
|
|
|
<!-- <span class="uk-margin-small-top uk-display-inline-block">-->
|
|
|
|
<!-- <span uk-icon="tag"></span>-->
|
|
|
|
<!-- <span class="uk-text-bold uk-margin-small-right"> EOSC: </span>-->
|
|
|
|
<!-- </span>-->
|
|
|
|
<!-- <span *ngFor="let subject of eoscSubjects; let j=index" class="uk-margin-small-top uk-width-auto uk-display-inline-block">-->
|
|
|
|
<!-- <span class="uk-border-rounded uk-label uk-label-small uk-label-primary uk-text-truncate uk-margin-small-right">-->
|
|
|
|
<!-- {{subject.value}}-->
|
|
|
|
<!-- </span>-->
|
|
|
|
<!-- </span>-->
|
|
|
|
<!-- </span>-->
|
|
|
|
<!-- </p>-->
|
2024-01-25 11:31:14 +01:00
|
|
|
|
2024-07-11 15:35:19 +02:00
|
|
|
<p *ngIf="eoscSubjects && eoscSubjects.length > 0">
|
2024-01-25 11:31:14 +01:00
|
|
|
<span #classifiedContent [id]="id+'_eosc'">{{getValue(eoscSubjects).join(', ')}}</span>
|
|
|
|
</p>
|
2022-08-30 10:35:42 +02:00
|
|
|
</div>
|
|
|
|
</ng-template>
|
2022-06-09 15:45:39 +02:00
|
|
|
|
2023-02-20 16:56:02 +01:00
|
|
|
<modal-alert #subjectsByVocabularyModal *ngIf="!isMobile && ((classifiedSubjects && classifiedSubjects.size > 0) || (eoscSubjects && eoscSubjects.length > 0))" large="true">
|
2022-06-09 15:45:39 +02:00
|
|
|
<div class="uk-text-small">
|
|
|
|
<ng-container *ngTemplateOutlet="subjects_by_vocabulary_template"></ng-container>
|
2024-01-25 11:31:14 +01:00
|
|
|
<ng-container *ngIf="eoscSubjects && eoscSubjects.length > 0"><ng-container *ngTemplateOutlet="eosc_subjects_template; context: {id: 'content'}"></ng-container></ng-container>
|
2022-06-09 15:45:39 +02:00
|
|
|
</div>
|
|
|
|
</modal-alert>
|
2020-03-16 14:09:46 +01:00
|
|
|
`
|
|
|
|
})
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
export class ShowSubjectsComponent {
|
2023-02-20 16:56:02 +01:00
|
|
|
@Input() isMobile: boolean = false;
|
2020-03-16 14:09:46 +01:00
|
|
|
@Input() subjects: string[];
|
|
|
|
@Input() otherSubjects: Map<string, string[]>;
|
|
|
|
@Input() classifiedSubjects: Map<string, string[]>;
|
2022-08-30 10:35:42 +02:00
|
|
|
@Input() eoscSubjects: any[];
|
2022-04-20 16:40:18 +02:00
|
|
|
isLarge: boolean = false;
|
2022-06-09 15:45:39 +02:00
|
|
|
isClassifiedLarge: boolean = false;
|
2023-02-20 16:56:02 +01:00
|
|
|
@Input() viewAllSubjects: boolean = false;
|
|
|
|
@Input() viewAllClassifiedSubjects: boolean = false;
|
|
|
|
@Output() viewAllClicked = new EventEmitter();
|
2021-11-09 15:02:32 +01:00
|
|
|
properties = properties;
|
2021-11-11 14:17:39 +01:00
|
|
|
specialSubjects = [];
|
2022-04-20 16:40:18 +02:00
|
|
|
@ViewChildren("content", { read: ElementRef }) content: QueryList<ElementRef>;
|
2022-06-09 15:45:39 +02:00
|
|
|
@ViewChildren("classifiedContent", { read: ElementRef }) classifiedContent: QueryList<ElementRef>;
|
2022-04-20 16:40:18 +02:00
|
|
|
@ViewChild('subjectsModal') subjectsModal;
|
2022-06-09 15:45:39 +02:00
|
|
|
@ViewChild('subjectsByVocabularyModal') subjectsByVocabularyModal;
|
2022-04-20 16:40:18 +02:00
|
|
|
|
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
onResize(event) {
|
|
|
|
this.checkLarge();
|
2022-06-09 15:45:39 +02:00
|
|
|
this.checkLargeClassified();
|
2022-04-20 16:40:18 +02:00
|
|
|
}
|
2021-11-09 15:02:32 +01:00
|
|
|
|
2022-04-20 16:40:18 +02:00
|
|
|
constructor(private cdr: ChangeDetectorRef) {
|
2021-11-24 14:55:54 +01:00
|
|
|
if(properties.dashboard == "explore") {
|
2021-11-11 14:17:39 +01:00
|
|
|
this.specialSubjects = [
|
2021-11-24 14:55:54 +01:00
|
|
|
// "Physics::Optics",
|
|
|
|
// "Astrophysics::Cosmology and Extragalactic Astrophysics",
|
|
|
|
// "Computer Science::Information Theory",
|
|
|
|
// "Physics::Accelerator Physics",
|
|
|
|
// "Condensed Matter::Superconductivity",
|
2021-11-11 14:17:39 +01:00
|
|
|
"Physics::Atomic Physics",
|
2021-11-24 14:55:54 +01:00
|
|
|
// "Computer Science::Robotics",
|
|
|
|
// "Computer Science::Computer Science and Game Theory",
|
|
|
|
// "Computer Science::Neural and Evolutionary Computation",
|
2021-11-11 14:17:39 +01:00
|
|
|
"Mathematics::Combinatorics",
|
2021-11-24 14:55:54 +01:00
|
|
|
// "Mathematics::Probability",
|
|
|
|
// "Computer Science::Operating Systems",
|
|
|
|
// "lcsh:Medicine",
|
|
|
|
// "lcsh:Science",
|
|
|
|
// "lcsh:Biology (General)",
|
|
|
|
// "lcsh:Chemistry",
|
|
|
|
// "lcsh:Engineering (General). Civil engineering (General)",
|
|
|
|
// "lcsh:Technology"
|
2021-11-11 14:17:39 +01:00
|
|
|
];
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
2021-11-09 15:02:32 +01:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
ngOnInit() {
|
|
|
|
}
|
2021-11-09 15:02:32 +01:00
|
|
|
|
2022-04-20 16:40:18 +02:00
|
|
|
ngAfterViewInit() {
|
2022-06-15 12:32:22 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
this.checkLarge();
|
|
|
|
this.checkLargeClassified();
|
|
|
|
})
|
2022-04-20 16:40:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
checkLarge() {
|
|
|
|
let overflow = 42;
|
|
|
|
if(typeof document !== "undefined" && this.content) {
|
|
|
|
let element = this.content.find(content => content.nativeElement.id === "content");
|
|
|
|
this.isLarge = (element && element.nativeElement.offsetHeight > overflow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-09 15:45:39 +02:00
|
|
|
checkLargeClassified() {
|
2022-06-15 12:32:22 +02:00
|
|
|
this.isClassifiedLarge = false;
|
|
|
|
|
|
|
|
let overflow = 69; // 2 * label height (27): 54 + grid margin: 15
|
|
|
|
if(typeof document !== "undefined" && this.classifiedSubjects && this.classifiedContent) {
|
2022-06-09 15:45:39 +02:00
|
|
|
this.getKeys(this.classifiedSubjects).forEach(key => {
|
|
|
|
let tag = this.classifiedContent.find(tag => tag.nativeElement.id === "content_"+key);
|
|
|
|
if(tag && tag.nativeElement.offsetHeight > overflow) {
|
|
|
|
this.isClassifiedLarge = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-08-30 10:35:42 +02:00
|
|
|
if(typeof document !== "undefined" && this.eoscSubjects && this.classifiedContent) {
|
|
|
|
let tag = this.classifiedContent.find(tag => tag.nativeElement.id === "content_eosc");
|
|
|
|
if(tag && tag.nativeElement.offsetHeight > overflow) {
|
|
|
|
this.isClassifiedLarge = true;
|
|
|
|
}
|
|
|
|
}
|
2022-06-09 15:45:39 +02:00
|
|
|
}
|
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
public getKeys(map) {
|
2022-06-15 12:32:22 +02:00
|
|
|
return map ? Array.from(map.keys()) : [];
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
2021-11-09 15:02:32 +01:00
|
|
|
getSubjectParameter(param){
|
2021-12-17 13:35:18 +01:00
|
|
|
return {'f0':'resultsubject','fv0':'"' +(param)+'"', size:50};
|
2021-11-09 15:02:32 +01:00
|
|
|
}
|
2022-04-20 16:40:18 +02:00
|
|
|
|
|
|
|
public openSubjectsModal() {
|
|
|
|
this.subjectsModal.cancelButton = false;
|
|
|
|
this.subjectsModal.okButton = false;
|
|
|
|
this.subjectsModal.alertTitle = "Subjects";
|
|
|
|
this.subjectsModal.open();
|
|
|
|
}
|
2022-06-09 15:45:39 +02:00
|
|
|
|
|
|
|
public openSubjectsByVocabularyModal() {
|
|
|
|
this.subjectsByVocabularyModal.cancelButton = false;
|
|
|
|
this.subjectsByVocabularyModal.okButton = false;
|
|
|
|
this.subjectsByVocabularyModal.alertTitle = "Subjects by Vocabulary";
|
|
|
|
this.subjectsByVocabularyModal.open();
|
|
|
|
}
|
2023-02-20 16:56:02 +01:00
|
|
|
|
|
|
|
public viewAllSubjectsClicked() {
|
|
|
|
if(this.isMobile) {
|
|
|
|
this.viewAllSubjects = true;
|
|
|
|
this.viewAllClicked.emit({
|
2023-04-06 11:46:50 +02:00
|
|
|
subtitle: 'Keywords',
|
2023-02-20 16:56:02 +01:00
|
|
|
id: 'subjects'
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.openSubjectsModal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public viewAllSubjectsByVocabularyClicked() {
|
|
|
|
if(this.isMobile) {
|
|
|
|
this.viewAllClassifiedSubjects = true;
|
|
|
|
this.viewAllClicked.emit({
|
|
|
|
subtitle: 'Subjects by Vocabulary',
|
|
|
|
id: 'classifiedSubjects'
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.openSubjectsByVocabularyModal();
|
|
|
|
}
|
|
|
|
}
|
2024-01-25 11:31:14 +01:00
|
|
|
|
|
|
|
getValue(eosSubjects) {
|
|
|
|
return eosSubjects.map(res => res.value);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|