import { ChangeDetectorRef, Component, ElementRef, HostListener, Input, QueryList, ViewChild, ViewChildren } from '@angular/core'; import {properties} from "../../../../environments/environment"; @Component({ selector: 'showSubjects', template: ` 0) || (eoscSubjects && eoscSubjects.length > 0)"> Subjects by Vocabulary 0"> View all 0) || (otherSubjects && otherSubjects.size > 0)"> 0"> Subjects View all 0">{{subjects.join(', ')}} 0) || (otherSubjects && otherSubjects.size > 0)"> {{key}}: {{subject}} EOSC: {{subject.value}} 0) || (eoscSubjects && eoscSubjects.length > 0)" large="true"> 0"> ` }) export class ShowSubjectsComponent { @Input() subjects: string[]; @Input() otherSubjects: Map; @Input() classifiedSubjects: Map; @Input() eoscSubjects: any[]; isLarge: boolean = false; isClassifiedLarge: boolean = false; properties = properties; specialSubjects = []; @ViewChildren("content", { read: ElementRef }) content: QueryList; @ViewChildren("classifiedContent", { read: ElementRef }) classifiedContent: QueryList; @ViewChild('subjectsModal') subjectsModal; @ViewChild('subjectsByVocabularyModal') subjectsByVocabularyModal; @HostListener('window:resize', ['$event']) onResize(event) { this.checkLarge(); this.checkLargeClassified(); } constructor(private cdr: ChangeDetectorRef) { if(properties.dashboard == "explore") { this.specialSubjects = [ // "Physics::Optics", // "Astrophysics::Cosmology and Extragalactic Astrophysics", // "Computer Science::Information Theory", // "Physics::Accelerator Physics", // "Condensed Matter::Superconductivity", "Physics::Atomic Physics", // "Computer Science::Robotics", // "Computer Science::Computer Science and Game Theory", // "Computer Science::Neural and Evolutionary Computation", "Mathematics::Combinatorics", // "Mathematics::Probability", // "Computer Science::Operating Systems", // "lcsh:Medicine", // "lcsh:Science", // "lcsh:Biology (General)", // "lcsh:Chemistry", // "lcsh:Engineering (General). Civil engineering (General)", // "lcsh:Technology" ]; } } ngOnInit() { } ngAfterViewInit() { setTimeout(() => { this.checkLarge(); this.checkLargeClassified(); }) } 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); } } checkLargeClassified() { this.isClassifiedLarge = false; let overflow = 69; // 2 * label height (27): 54 + grid margin: 15 if(typeof document !== "undefined" && this.classifiedSubjects && this.classifiedContent) { 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; } }); } 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; } } } public getKeys(map) { return map ? Array.from(map.keys()) : []; } getSubjectParameter(param){ return {'f0':'resultsubject','fv0':'"' +(param)+'"', size:50}; } public openSubjectsModal() { this.subjectsModal.cancelButton = false; this.subjectsModal.okButton = false; this.subjectsModal.alertTitle = "Subjects"; this.subjectsModal.open(); } public openSubjectsByVocabularyModal() { this.subjectsByVocabularyModal.cancelButton = false; this.subjectsByVocabularyModal.okButton = false; this.subjectsByVocabularyModal.alertTitle = "Subjects by Vocabulary"; this.subjectsByVocabularyModal.open(); } }
0">{{subjects.join(', ')}}
{{key}}: {{subject}}
EOSC: {{subject.value}}