2022-04-20 16:40:18 +02:00
|
|
|
import {
|
|
|
|
ChangeDetectorRef,
|
|
|
|
Component,
|
|
|
|
ElementRef,
|
|
|
|
HostListener,
|
|
|
|
Input,
|
|
|
|
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: `
|
2022-08-30 10:35:42 +02:00
|
|
|
<ng-container *ngIf="(classifiedSubjects && classifiedSubjects.size > 0) || (eoscSubjects && eoscSubjects.length > 0)">
|
2022-06-15 12:32:22 +02:00
|
|
|
<div class="uk-text-meta">
|
2022-04-20 16:40:18 +02:00
|
|
|
Subjects by Vocabulary
|
|
|
|
</div>
|
2022-06-09 15:45:39 +02:00
|
|
|
<ng-container *ngTemplateOutlet="subjects_by_vocabulary_template; context: {customClasses: 'multi-line-ellipsis lines-2', id: 'content'}"></ng-container>
|
2022-09-08 23:46:44 +02:00
|
|
|
<ng-container *ngIf="eoscSubjects && eoscSubjects.length > 0"><ng-container *ngTemplateOutlet="eosc_subjects_template"></ng-container></ng-container>
|
2022-06-09 15:45:39 +02:00
|
|
|
<div *ngIf="isClassifiedLarge" class="uk-text-right">
|
|
|
|
<a (click)="openSubjectsByVocabularyModal()" class="view-more-less-link">View all</a>
|
2022-04-20 16:40:18 +02:00
|
|
|
</div>
|
2022-06-09 15:45:39 +02:00
|
|
|
|
2022-04-20 16:40:18 +02:00
|
|
|
</ng-container>
|
|
|
|
<ng-container *ngIf="(subjects && subjects.length > 0) || (otherSubjects && otherSubjects.size > 0)">
|
|
|
|
<div class="uk-text-meta uk-margin-small-bottom" [class.uk-margin-medium-top]="classifiedSubjects && classifiedSubjects.size > 0">
|
|
|
|
Subjects
|
|
|
|
</div>
|
|
|
|
<ng-container *ngTemplateOutlet="subjects_template; context: {customClasses: 'multi-line-ellipsis lines-2', id: 'content'}"></ng-container>
|
|
|
|
<div *ngIf="isLarge" class="uk-text-right uk-margin-small-top">
|
2022-06-09 15:45:39 +02:00
|
|
|
<a (click)="openSubjectsModal()" class="view-more-less-link">View all</a>
|
2022-04-20 16:40:18 +02:00
|
|
|
</div>
|
|
|
|
</ng-container>
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
2022-06-15 12:32:22 +02:00
|
|
|
<modal-alert #subjectsModal *ngIf="(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">
|
|
|
|
<p 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>
|
|
|
|
</div>
|
|
|
|
</ng-template>
|
2022-06-09 15:45:39 +02:00
|
|
|
|
2022-08-30 10:35:42 +02:00
|
|
|
<modal-alert #subjectsByVocabularyModal *ngIf="(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>
|
2022-09-08 23:46:44 +02:00
|
|
|
<ng-container *ngIf="eoscSubjects && eoscSubjects.length > 0"><ng-container *ngTemplateOutlet="eosc_subjects_template"></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 {
|
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;
|
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();
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|