import { AfterViewInit, Component, ComponentRef, OnDestroy, ViewChild, ViewContainerRef } from '@angular/core'; import { Router } from '@angular/router'; import { Store } from '@ngrx/store'; import { BaseLayoutComponent, BaseToolboxAction } from '@onepoint-yap/dashboard'; import { Observable, Subscription } from 'rxjs'; import { SupervisionActions } from '../../store/supervision.actions'; import { SupervisionSelectors } from '../../store/supervision.selectors'; import { SupervisionIntegrationErrorsSelectComponent } from '../../../supervision/components/supervision-integration-errors/supervision-integration-errors-select/supervision-integration-errors-select.component'; @Component({ selector: 'yap-supervision-layout', templateUrl: './supervision-layout.component.html' }) export class SupervisionLayoutComponent extends BaseLayoutComponent implements AfterViewInit, OnDestroy { baseToolboxTranslation: string; actions$: Observable; subActions$: Observable; panelOpen$: Observable; @ViewChild('supervisionPanel', { static: true, read: ViewContainerRef }) supervisionPanel!: ViewContainerRef; componentRef?: ComponentRef; constructor(store: Store, router: Router) { super(store, router); this.baseToolboxTranslation = '@yap.supervision.'; this.actions$ = this.store.select(SupervisionSelectors.actions); this.subActions$ = this.store.select(SupervisionSelectors.subActions); this.panelOpen$ = this.store.select(SupervisionSelectors.errorDetailsOpen); } override init(): void { this.menus$ = this.store.select(SupervisionSelectors.menus); this.menuOpen$ = this.store.select(SupervisionSelectors.menuOpen); } override highlightMenu(menu: string): void { this.store.dispatch(SupervisionActions.highLightMenu({ menu })); } ngAfterViewInit(): void { if (this.componentRef) { this.supervisionPanel.clear(); } this.componentRef = this.supervisionPanel.createComponent(SupervisionIntegrationErrorsSelectComponent); } override ngOnDestroy() { this.store.dispatch(SupervisionActions.toggleErrorDetails({ error: null, errorDetailsOpen: false })); } }