import { AfterContentChecked, AfterViewInit, ChangeDetectorRef, Component, Inject, OnDestroy, OnInit, PLATFORM_ID, ViewChild } from "@angular/core"; import {Subscription} from "rxjs"; import {Meta, Title} from "@angular/platform-browser"; import {ActivatedRoute, Router} from "@angular/router"; import {OpenaireEntities} from "../../utils/properties/searchFields"; import {SEOService} from "../../sharedComponents/SEO/SEO.service"; import {properties} from "../../../../environments/environment"; import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; import {HelperService} from "../../utils/helper/helper.service"; import {LayoutService} from "../../dashboard/sharedComponents/sidebar/layout.service"; import {isPlatformServer} from "@angular/common"; declare var ResizeObserver; @Component({ selector: 'terminology', template: `

Terminology and
construction.

Terminology and
construction.

`, styleUrls: ['terminology.component.less'] }) export class TerminologyComponent implements OnInit, OnDestroy, AfterViewInit, AfterContentChecked { public tab: 'entities' | 'attributes' = 'entities'; private subscriptions: any[] = []; public openaireEntities = OpenaireEntities; public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources - Terminology and construction', keepFormat: true}]; public graph_offset: number = 0; public graph_height: number = 0; @ViewChild("graph_element") graph_element; public contentSections: string[] = ['entities', 'inherited-and-inferred-attributes', 'constructed-attributes']; public activeSection: string; public properties = properties; public divContents: any; isMobile: boolean = false; isServer: boolean; constructor(private seoService: SEOService, private meta: Meta, private router: Router, private route: ActivatedRoute, private title: Title, private cdr: ChangeDetectorRef, private helper: HelperService, private layoutService: LayoutService, @Inject(PLATFORM_ID) private platform: any) { this.isServer = isPlatformServer(this.platform); } ngOnInit() { this.subscriptions.push(this.route.params.subscribe(params => { const description = "Monitor | Terminology and construction"; const title = "Monitor | Terminology and construction"; this.metaTags(title, description); this.breadcrumbs[0].route = '/' + (params['stakeholder']?params['stakeholder']:''); this.breadcrumbs[0].name = (params['stakeholder']?'dashboard':'home'); })); this.subscriptions.push(this.route.fragment.subscribe(fragment => { if(fragment) { this.activeSection = fragment; } else { this.activeSection = 'entities'; } })); this.layoutService.isMobile.subscribe(isMobile => { this.isMobile = isMobile; this.cdr.detectChanges(); }); this.getDivContents(); } ngAfterViewInit() { if (typeof document !== 'undefined') { if(this.graph_element) { this.observeGraphElement(); } } } ngAfterContentChecked() { if(this.graph_element && typeof document !== 'undefined') { this.graph_offset = this.calcGraphOffset(this.graph_element.nativeElement); } } ngOnDestroy() { this.subscriptions.forEach(subscription => { if (subscription instanceof Subscription) { subscription.unsubscribe(); } }); } private getDivContents() { this.subscriptions.push(this.helper.getDivHelpContents(this.properties, 'monitor', '/methodology/terminology').subscribe(contents => { this.divContents = contents; })); } public observeGraphElement() { let resizeObs = new ResizeObserver(entries => { entries.forEach(entry => { setTimeout(() => { this.graph_offset = this.calcGraphOffset(entry.target); this.cdr.detectChanges(); }); }) }); this.subscriptions.push(resizeObs); resizeObs.observe(this.graph_element.nativeElement); } calcGraphOffset(element) { this.graph_height = element.offsetHeight; return window.innerHeight-this.graph_height; } metaTags(title, description) { const url = properties.domain + properties.baseLink + this.router.url; this.seoService.createLinkForCanonicalURL(url, false); this.meta.updateTag({content: url}, "property='og:url'"); this.meta.updateTag({content: description}, "name='description'"); this.meta.updateTag({content: description}, "property='og:description'"); this.meta.updateTag({content: title}, "property='og:title'"); this.title.setTitle(title); } }