import { EventEmitter, OnDestroy, ElementRef, ChangeDetectorRef, ApplicationRef, Injector, EnvironmentInjector } from '@angular/core'; import { BaseAngularComponent } from '@memberjunction/ng-base-types'; import { MJDashboardEntity, MJDashboardPartTypeEntity, MJDashboardCategoryEntity } from '@memberjunction/core-entities'; import { BreadcrumbNavigateEvent } from '../breadcrumb/dashboard-breadcrumb.component'; import { DashboardConfig, DashboardPanel, PanelConfig, PanelInteractionEvent, DashboardConfigChangedEvent, DashboardNavRequestEvent } from '../models/dashboard-types'; import { LayoutLocation } from '../services/golden-layout-wrapper.service'; import * as i0 from "@angular/core"; export type DashboardLayoutReadyState = 'pending-dashboard' | 'pending-parts' | 'waiting-for-size' | 'initializing' | 'ready' | 'error'; export interface DashboardLayoutLifecycleEvent { state: DashboardLayoutReadyState; dashboardId?: string; reason?: string; error?: Error; } /** * Main dashboard viewer component. * Renders a configurable dashboard with draggable/resizable panels using Golden Layout. * * This component is GENERIC and has no routing dependencies. * Navigation events are bubbled up for the parent component to handle. */ export declare class DashboardViewerComponent extends BaseAngularComponent implements OnDestroy { private readonly cdr; private readonly appRef; private readonly injector; private readonly environmentInjector; private _dashboard; private _dashboardId; /** The dashboard entity to display */ set dashboard(value: MJDashboardEntity | null); get dashboard(): MJDashboardEntity | null; /** Alternative: Load dashboard by ID */ set dashboardId(value: string | null); get dashboardId(): string | null; /** Whether the dashboard is in edit mode */ private _isEditing; set isEditing(value: boolean); get isEditing(): boolean; /** Whether to show the toolbar */ private _showToolbar; set showToolbar(value: boolean); get showToolbar(): boolean; /** Whether to auto-save layout changes */ private _autoSave; set autoSave(value: boolean); get autoSave(): boolean; /** Whether to show the breadcrumb navigation */ showBreadcrumb: boolean; /** Whether to show the "Open in Tab" button (for embedded dashboards) */ showOpenInTabButton: boolean; /** Whether to show the Edit button */ showEditButton: boolean; /** All categories for breadcrumb path resolution */ Categories: MJDashboardCategoryEntity[]; /** * Computed: Should the toolbar be visible? * Auto-hides when showToolbar=false OR when all toolbar elements are disabled */ get shouldShowToolbar(): boolean; /** Emitted when dashboard configuration changes */ configChanged: EventEmitter; /** Emitted when a panel requests navigation to another resource */ navigationRequested: EventEmitter; /** Emitted when a panel interaction occurs */ panelInteraction: EventEmitter; /** Emitted when the dashboard is saved */ dashboardSaved: EventEmitter; /** Emitted when an error occurs */ error: EventEmitter<{ message: string; error?: Error; }>; /** Emitted when edit mode changes */ editModeChanged: EventEmitter; /** Emitted when user navigates via breadcrumb */ breadcrumbNavigate: EventEmitter; /** Emitted when user clicks "Open in Tab" button */ openInTab: EventEmitter<{ dashboardId: string; dashboardName: string; }>; /** Emitted as the Golden Layout viewer moves through dashboard/layout readiness states. */ layoutLifecycle: EventEmitter; /** Emitted once Golden Layout has initialized with a non-zero container and updated its size. */ layoutReady: EventEmitter; /** Emitted when layout initialization is deferred because the container cannot be initialized yet. */ layoutDeferred: EventEmitter<{ reason: string; }>; layoutContainer: ElementRef; isLoading: boolean; config: DashboardConfig | null; partTypes: MJDashboardPartTypeEntity[]; hasUnsavedChanges: boolean; /** * Helper to check if layout has any panels (for template use). * Panels are stored in componentState within the layout tree. */ get hasPanels(): boolean; private readonly _destroy$; private readonly _panelComponents; private _glService; /** Promise that resolves when part types are loaded - used to ensure layout waits for part types */ private _partTypesLoaded; private _layoutReadyPromise; private _resolveLayoutReady; private _rejectLayoutReady; private _layoutInitGeneration; private _layoutReadyTimer; private _resolveDeferredLayoutInit; private _rejectDeferredLayoutInit; private _deferredLayoutInitTimer; constructor(cdr: ChangeDetectorRef, appRef: ApplicationRef, injector: Injector, environmentInjector: EnvironmentInjector); ngOnDestroy(): void; /** * Toggle edit mode */ toggleEditMode(): void; /** * Add a new panel to the dashboard. * The panel is stored in GL's componentState - no separate panels array. */ addPanel(partTypeId: string, panelConfig: PanelConfig, title: string, icon?: string, location?: LayoutLocation): Promise; /** * Remove a panel from the dashboard. * Panels live in GL's componentState, so removing from GL removes the panel. */ removePanel(panelId: string): void; /** * Save the current dashboard configuration */ save(): Promise; /** * Refresh all panels */ refreshAllPanels(): Promise; /** * Resolves when the current dashboard's Golden Layout instance has initialized * against a non-zero container and completed its first size update. */ waitForLayoutReady(): Promise; /** * Get the current configuration */ getConfig(): DashboardConfig | null; /** * Get available part types */ getPartTypes(): MJDashboardPartTypeEntity[]; /** * Get a panel by ID. * Extracts panel from the layout's componentState (single source of truth). */ getPanel(panelId: string): DashboardPanel | null; /** * Get the part type for a panel */ getPartTypeForPanel(panelId: string): MJDashboardPartTypeEntity | null; /** * Update a panel's configuration. * Since panels live in componentState within the layout, we need to * update the layout tree directly or reinitialize with updated data. */ updatePanelConfig(panelId: string, newConfig: PanelConfig, title?: string, icon?: string): void; /** * Recursively update a panel's config within the layout tree */ private updatePanelInLayout; /** * Handle add panel button click - emits event for parent to show dialog */ onAddPanelClick(): void; /** * Handle "Open in Tab" button click - emits event for parent to open dashboard in its own tab */ onOpenInTabClick(): void; /** * Handle breadcrumb navigation */ onBreadcrumbNavigate(event: BreadcrumbNavigateEvent): void; private loadPartTypes; private loadDashboardById; private onDashboardChanged; private parseOrCreateConfig; private initializeLayout; /** ResizeObserver used to wait for a zero-size container to gain a size before init. */ private _layoutSizeObserver; /** * Wait (via ResizeObserver) until the layout container has a non-zero size, then * (re)initialize. Used when initializeLayout() is called while the container is * still 0×0 — e.g. during a cached-component reattach on browser back/forward — * where GoldenLayout would otherwise bind panels that never receive a 'show' event. */ private waitForLayoutContainerSize; private cancelDeferredLayoutInit; private failDeferredLayoutInit; private clearDeferredLayoutInitTimer; private startLayoutReadyCycle; private resolveLayoutReady; private rejectLayoutReady; private clearLayoutReadyTimer; private emitLayoutLifecycle; /** Flag to prevent panel removal during layout reinit */ private _isReinitializing; private destroyLayout; private subscribeToLayoutEvents; private onLayoutChanged; private onPanelClosed; private onPanelSelected; /** * Create a panel component from the DashboardPanel data. * Panel comes directly from GL's componentState - no lookup needed. */ private createPanelComponent; /** * Create a dynamic part component using ClassFactory */ private createDynamicPartComponent; private createPartHeader; private renderPartContent; private renderWebURLPart; private renderViewPart; private renderQueryPart; private renderArtifactPart; private renderPlaceholderPart; private onConfigurePart; private onRemovePart; /** * Confirm removal of a panel (called by parent after confirmation dialog) */ confirmRemovePanel(panelId: string): void; private destroyPanelComponent; private updatePanelEditModes; private markDirty; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } //# sourceMappingURL=dashboard-viewer.component.d.ts.map