import { ChangeDetectorRef, Component, ElementRef, HostListener, Input, QueryList, ViewChild, ViewChildren } from '@angular/core'; import {properties} from "../../../../environments/environment"; @Component({ selector: 'showSubjects', template: `
Subjects by Vocabulary
View all
Subjects
View all

{{subjects.join(', ')}}

{{key}}: {{subject}}

` }) export class ShowSubjectsComponent { @Input() subjects: string[]; @Input() otherSubjects: Map; @Input() classifiedSubjects: Map; 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() { 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); this.cdr.detectChanges(); } } checkLargeClassified() { let overflow = 42; if(typeof document !== "undefined") { 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; } }); this.cdr.detectChanges(); } } public getKeys(map) { return 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(); } }