@memberjunction/ng-base-application 0.0.1 → 2.121.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/application-manager.d.ts +118 -0
- package/dist/lib/application-manager.js +312 -0
- package/dist/lib/application-manager.js.map +1 -0
- package/dist/lib/base-application.d.ts +98 -0
- package/dist/lib/base-application.js +234 -0
- package/dist/lib/base-application.js.map +1 -0
- package/dist/lib/golden-layout-manager.d.ts +190 -0
- package/dist/lib/golden-layout-manager.js +505 -0
- package/dist/lib/golden-layout-manager.js.map +1 -0
- package/dist/lib/interfaces/nav-item.interface.d.ts +29 -0
- package/dist/lib/interfaces/nav-item.interface.js +2 -0
- package/dist/lib/interfaces/nav-item.interface.js.map +1 -0
- package/dist/lib/interfaces/tab-request.interface.d.ts +21 -0
- package/dist/lib/interfaces/tab-request.interface.js +2 -0
- package/dist/lib/interfaces/tab-request.interface.js.map +1 -0
- package/dist/lib/interfaces/workspace-configuration.interface.d.ts +98 -0
- package/dist/lib/interfaces/workspace-configuration.interface.js +23 -0
- package/dist/lib/interfaces/workspace-configuration.interface.js.map +1 -0
- package/dist/lib/tab.service.d.ts +55 -0
- package/dist/lib/tab.service.js +132 -0
- package/dist/lib/tab.service.js.map +1 -0
- package/dist/lib/workspace-state-manager.d.ts +118 -0
- package/dist/lib/workspace-state-manager.js +535 -0
- package/dist/lib/workspace-state-manager.js.map +1 -0
- package/dist/public-api.d.ts +14 -0
- package/dist/public-api.js +17 -0
- package/dist/public-api.js.map +1 -0
- package/package.json +41 -6
- package/README.md +0 -45
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { Metadata, RunView } from '@memberjunction/core';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for application definitions in MemberJunction Explorer.
|
|
4
|
+
*
|
|
5
|
+
* Applications can extend this class to provide dynamic behavior
|
|
6
|
+
* for navigation items, colors, default tabs, and lifecycle hooks.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { RegisterClass } from '@memberjunction/global';
|
|
11
|
+
*
|
|
12
|
+
* @RegisterClass(BaseApplication, 'CRMApplication')
|
|
13
|
+
* export class CRMApplication extends BaseApplication {
|
|
14
|
+
* override GetNavItems(): NavItem[] {
|
|
15
|
+
* const items = super.GetNavItems();
|
|
16
|
+
* // Add dynamic items based on permissions
|
|
17
|
+
* return items;
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export class BaseApplication {
|
|
23
|
+
/** Application ID from database */
|
|
24
|
+
ID = '';
|
|
25
|
+
/** Application name */
|
|
26
|
+
Name = '';
|
|
27
|
+
/** Application description */
|
|
28
|
+
Description = '';
|
|
29
|
+
/** Font Awesome icon class */
|
|
30
|
+
Icon = '';
|
|
31
|
+
/** Hex color code for theming */
|
|
32
|
+
Color = '';
|
|
33
|
+
/** JSON string of default navigation items */
|
|
34
|
+
DefaultNavItems = '';
|
|
35
|
+
/** TypeScript class name for ClassFactory */
|
|
36
|
+
ClassName = '';
|
|
37
|
+
/** Default sequence position when adding to new user's User Applications */
|
|
38
|
+
DefaultSequence = 100;
|
|
39
|
+
/** Application lifecycle status - only Active apps are shown to users */
|
|
40
|
+
Status = 'Active';
|
|
41
|
+
/** How the application appears in navigation */
|
|
42
|
+
NavigationStyle = 'App Switcher';
|
|
43
|
+
/** Position of permanent nav icon when NavigationStyle is Nav Bar or Both */
|
|
44
|
+
TopNavLocation = null;
|
|
45
|
+
/** When true, hide the Nav Bar icon when this application is active */
|
|
46
|
+
HideNavBarIconWhenActive = false;
|
|
47
|
+
/** URL-friendly slug for the application (e.g., "data-explorer" for "Data Explorer") */
|
|
48
|
+
Path = '';
|
|
49
|
+
/** When true, Path is automatically generated from Name on save */
|
|
50
|
+
AutoUpdatePath = true;
|
|
51
|
+
constructor(data) {
|
|
52
|
+
if (data) {
|
|
53
|
+
Object.assign(this, data);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
_defaultNavItems = null;
|
|
57
|
+
/**
|
|
58
|
+
* Returns navigation items for this application.
|
|
59
|
+
* Override in subclass for dynamic behavior based on permissions, context, etc.
|
|
60
|
+
*/
|
|
61
|
+
GetNavItems() {
|
|
62
|
+
if (this._defaultNavItems) {
|
|
63
|
+
return this._defaultNavItems;
|
|
64
|
+
}
|
|
65
|
+
if (this.DefaultNavItems) {
|
|
66
|
+
try {
|
|
67
|
+
this._defaultNavItems = JSON.parse(this.DefaultNavItems);
|
|
68
|
+
return this._defaultNavItems;
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
console.error(`Failed to parse DefaultNavItems for ${this.Name}:`, e);
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the application color for theming.
|
|
79
|
+
* Override in subclass for dynamic color based on context.
|
|
80
|
+
*/
|
|
81
|
+
GetColor() {
|
|
82
|
+
return this.Color || '#757575';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates the default tab request when user switches to this app.
|
|
86
|
+
* If app has navigation items, uses the first nav item.
|
|
87
|
+
* If app has no nav items, loads the first available dashboard preference for this app.
|
|
88
|
+
* Override in subclass for custom default tab logic.
|
|
89
|
+
*/
|
|
90
|
+
async CreateDefaultTab() {
|
|
91
|
+
const navItems = this.GetNavItems();
|
|
92
|
+
if (navItems.length > 0) {
|
|
93
|
+
const firstItem = navItems[0];
|
|
94
|
+
const tabRequest = {
|
|
95
|
+
ApplicationId: this.ID,
|
|
96
|
+
Title: firstItem.Label
|
|
97
|
+
};
|
|
98
|
+
// Handle resource-based nav items
|
|
99
|
+
if (firstItem.ResourceType) {
|
|
100
|
+
tabRequest.ResourceType = firstItem.ResourceType;
|
|
101
|
+
tabRequest.ResourceRecordId = firstItem.RecordID;
|
|
102
|
+
// Put resourceType in Configuration so it gets stored properly
|
|
103
|
+
tabRequest.Configuration = {
|
|
104
|
+
resourceType: firstItem.ResourceType,
|
|
105
|
+
recordId: firstItem.RecordID,
|
|
106
|
+
...(firstItem.Configuration || {})
|
|
107
|
+
};
|
|
108
|
+
// For Custom resource types, include the DriverClass
|
|
109
|
+
if (firstItem.ResourceType === 'Custom' && firstItem.DriverClass) {
|
|
110
|
+
tabRequest.Configuration.driverClass = firstItem.DriverClass;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Handle route-based nav items (legacy)
|
|
114
|
+
else if (firstItem.Route) {
|
|
115
|
+
tabRequest.Route = firstItem.Route;
|
|
116
|
+
// Include query params in the configuration if present
|
|
117
|
+
if (firstItem.queryParams) {
|
|
118
|
+
tabRequest.Configuration = { queryParams: firstItem.queryParams };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return tabRequest;
|
|
122
|
+
}
|
|
123
|
+
// No nav items defined - try to load default dashboard for this app
|
|
124
|
+
return await this.loadDefaultDashboard();
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Loads the default dashboard for this app from DashboardUserPreference.
|
|
128
|
+
* Uses a simple cascading pattern:
|
|
129
|
+
* For the app scope: return user preferences if they exist, otherwise system defaults
|
|
130
|
+
* Returns null if no dashboards are available.
|
|
131
|
+
*/
|
|
132
|
+
async loadDefaultDashboard() {
|
|
133
|
+
try {
|
|
134
|
+
const md = new Metadata();
|
|
135
|
+
const rv = new RunView();
|
|
136
|
+
const entity = md.EntityByName('MJ: Dashboard User Preferences');
|
|
137
|
+
const currentUserId = md.CurrentUser?.ID;
|
|
138
|
+
if (!currentUserId) {
|
|
139
|
+
console.log(`[${this.Name}] No current user, returning null`);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
// Build the cascading filter following the legacy pattern:
|
|
143
|
+
// Show user preferences for this app, OR show system defaults if user has no preferences
|
|
144
|
+
const userFilter = `UserID='${currentUserId}' AND Scope='App' AND ApplicationID='${this.ID}'`;
|
|
145
|
+
const baseCondition = `Scope='App' AND ApplicationID='${this.ID}'`;
|
|
146
|
+
// Single query that returns:
|
|
147
|
+
// 1. User preferences if they exist for this app
|
|
148
|
+
// 2. System defaults (UserID IS NULL) if user has no preferences for this app
|
|
149
|
+
const filter = `(${userFilter})
|
|
150
|
+
OR
|
|
151
|
+
(UserID IS NULL AND ${baseCondition} AND
|
|
152
|
+
NOT EXISTS (SELECT 1 FROM [${entity.SchemaName}].vwDashboardUserPreferences dup2
|
|
153
|
+
WHERE ${userFilter}))`;
|
|
154
|
+
const result = await rv.RunView({
|
|
155
|
+
EntityName: 'MJ: Dashboard User Preferences',
|
|
156
|
+
ExtraFilter: filter,
|
|
157
|
+
OrderBy: 'DisplayOrder ASC',
|
|
158
|
+
MaxRows: 1,
|
|
159
|
+
ResultType: 'entity_object'
|
|
160
|
+
});
|
|
161
|
+
if (result.Success && result.Results && result.Results.length > 0) {
|
|
162
|
+
const preference = result.Results[0];
|
|
163
|
+
if (preference.DashboardID) {
|
|
164
|
+
return {
|
|
165
|
+
ApplicationId: this.ID,
|
|
166
|
+
Title: this.Name, // Use app name instead of dashboard name
|
|
167
|
+
ResourceType: 'Dashboards',
|
|
168
|
+
ResourceRecordId: preference.DashboardID,
|
|
169
|
+
Configuration: {
|
|
170
|
+
resourceType: 'Dashboards',
|
|
171
|
+
recordId: preference.DashboardID,
|
|
172
|
+
appName: this.Name, // Mark this as an app-level dashboard
|
|
173
|
+
isAppDefault: true // Flag to indicate this is the app's default view
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
console.log(`[${this.Name}] No results found. Success:`, result.Success, 'Results:', result.Results?.length);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
console.error(`[${this.Name}] Error loading default dashboard:`, error);
|
|
184
|
+
}
|
|
185
|
+
// No dashboard configured - fall back to Data Explorer filtered by this application
|
|
186
|
+
return this.createDataExplorerTab();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Creates a Data Explorer tab filtered to entities within this application.
|
|
190
|
+
* Used as a fallback when no dashboard or nav items are configured.
|
|
191
|
+
*/
|
|
192
|
+
createDataExplorerTab() {
|
|
193
|
+
return {
|
|
194
|
+
ApplicationId: this.ID,
|
|
195
|
+
Title: this.Name,
|
|
196
|
+
ResourceType: 'Dashboards',
|
|
197
|
+
ResourceRecordId: 'DataExplorer',
|
|
198
|
+
Configuration: {
|
|
199
|
+
resourceType: 'Dashboards',
|
|
200
|
+
dashboardType: 'DataExplorer',
|
|
201
|
+
appName: this.Name,
|
|
202
|
+
appIcon: this.Icon,
|
|
203
|
+
isAppDefault: true,
|
|
204
|
+
// Pass filter configuration for Data Explorer
|
|
205
|
+
entityFilter: {
|
|
206
|
+
applicationId: this.ID
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Called when this application becomes the active app.
|
|
213
|
+
* Override in subclass for custom initialization logic.
|
|
214
|
+
*/
|
|
215
|
+
async OnActivate() {
|
|
216
|
+
// Default: no-op
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Called when user navigates away from this application.
|
|
220
|
+
* Override in subclass for cleanup logic.
|
|
221
|
+
*/
|
|
222
|
+
async OnDeactivate() {
|
|
223
|
+
// Default: no-op
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Called to check if user has permission for a specific action.
|
|
227
|
+
* Override in subclass for permission checks.
|
|
228
|
+
*/
|
|
229
|
+
HasPermission(action) {
|
|
230
|
+
// Default: allow all
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=base-application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-application.js","sourceRoot":"","sources":["../../src/lib/base-application.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,E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,EAAE,YAAY;gBAC1B,aAAa,EAAE,cAAc;gBAC7B,OAAO,EAAE,IAAI,CAAC,IAAI;gBAClB,OAAO,EAAE,IAAI,CAAC,IAAI;gBAClB,YAAY,EAAE,IAAI;gBAClB,8CAA8C;gBAC9C,YAAY,EAAE;oBACZ,aAAa,EAAE,IAAI,CAAC,EAAE;iBACvB;aACF;SACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU;QACd,iBAAiB;IACnB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY;QAChB,iBAAiB;IACnB,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,MAAc;QAC1B,qBAAqB;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { LayoutConfig as WorkspaceLayoutConfig } from './interfaces/workspace-configuration.interface';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
interface GLComponentContainer {
|
|
5
|
+
state: Record<string, unknown>;
|
|
6
|
+
tab?: {
|
|
7
|
+
element: HTMLElement;
|
|
8
|
+
};
|
|
9
|
+
on(event: string, callback: () => void): void;
|
|
10
|
+
close(): void;
|
|
11
|
+
focus(): void;
|
|
12
|
+
setTitle(title: string): void;
|
|
13
|
+
}
|
|
14
|
+
interface GLResolvedLayoutConfig {
|
|
15
|
+
root: GLLayoutNode;
|
|
16
|
+
}
|
|
17
|
+
interface GLLayoutNode {
|
|
18
|
+
type: string;
|
|
19
|
+
content?: GLLayoutNode[];
|
|
20
|
+
componentType?: string;
|
|
21
|
+
componentState?: Record<string, unknown>;
|
|
22
|
+
width?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
isClosable?: boolean;
|
|
25
|
+
title?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* State stored in each Golden Layout component
|
|
29
|
+
*/
|
|
30
|
+
export interface TabComponentState {
|
|
31
|
+
tabId: string;
|
|
32
|
+
appId: string;
|
|
33
|
+
appColor: string;
|
|
34
|
+
title: string;
|
|
35
|
+
route: string;
|
|
36
|
+
isPinned: boolean;
|
|
37
|
+
isLoaded: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Event emitted when a tab is shown
|
|
41
|
+
*/
|
|
42
|
+
export interface TabShownEvent {
|
|
43
|
+
tabId: string;
|
|
44
|
+
container: GLComponentContainer;
|
|
45
|
+
isFirstShow: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Event emitted when layout changes
|
|
49
|
+
*/
|
|
50
|
+
export interface LayoutChangedEvent {
|
|
51
|
+
layout: GLResolvedLayoutConfig;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Manages Golden Layout instance and provides Angular integration.
|
|
55
|
+
*
|
|
56
|
+
* Handles:
|
|
57
|
+
* - Layout initialization and destruction
|
|
58
|
+
* - Tab creation with app-specific styling
|
|
59
|
+
* - Lazy loading of tab content
|
|
60
|
+
* - Layout serialization/deserialization
|
|
61
|
+
* - Tab events (show, hide, close)
|
|
62
|
+
*/
|
|
63
|
+
export declare class GoldenLayoutManager {
|
|
64
|
+
private layout;
|
|
65
|
+
private containerElement;
|
|
66
|
+
private tabShown$;
|
|
67
|
+
private tabClosed$;
|
|
68
|
+
private layoutChanged$;
|
|
69
|
+
private activeTab$;
|
|
70
|
+
private tabDoubleClicked;
|
|
71
|
+
private tabRightClicked;
|
|
72
|
+
private loadedTabs;
|
|
73
|
+
private containerMap;
|
|
74
|
+
/**
|
|
75
|
+
* Observable for tab shown events (for lazy loading)
|
|
76
|
+
*/
|
|
77
|
+
get TabShown(): Observable<TabShownEvent>;
|
|
78
|
+
/**
|
|
79
|
+
* Observable for tab closed events
|
|
80
|
+
*/
|
|
81
|
+
get TabClosed(): Observable<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Observable for layout changed events
|
|
84
|
+
*/
|
|
85
|
+
get LayoutChanged(): Observable<LayoutChangedEvent>;
|
|
86
|
+
/**
|
|
87
|
+
* Observable for active tab changes
|
|
88
|
+
*/
|
|
89
|
+
get ActiveTab(): Observable<string | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Observable for tab double-click events (to toggle pin status)
|
|
92
|
+
*/
|
|
93
|
+
get TabDoubleClicked(): Observable<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Observable for tab right-click events (to show context menu)
|
|
96
|
+
*/
|
|
97
|
+
get TabRightClicked(): Observable<{
|
|
98
|
+
tabId: string;
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Initialize Golden Layout in the specified container element
|
|
104
|
+
*/
|
|
105
|
+
Initialize(element: HTMLElement): void;
|
|
106
|
+
/**
|
|
107
|
+
* Destroy the Golden Layout instance
|
|
108
|
+
*/
|
|
109
|
+
Destroy(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Add a new tab to the layout
|
|
112
|
+
* Adds to existing stack if one exists, otherwise creates new stack
|
|
113
|
+
*/
|
|
114
|
+
AddTab(state: TabComponentState): void;
|
|
115
|
+
/**
|
|
116
|
+
* Remove a tab from the layout
|
|
117
|
+
*/
|
|
118
|
+
RemoveTab(tabId: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* Focus a tab by ID
|
|
121
|
+
*/
|
|
122
|
+
FocusTab(tabId: string): void;
|
|
123
|
+
/**
|
|
124
|
+
* Update tab style (pin state, title, etc.)
|
|
125
|
+
*/
|
|
126
|
+
UpdateTabStyle(tabId: string, state: Partial<TabComponentState>): void;
|
|
127
|
+
/**
|
|
128
|
+
* Load layout from configuration
|
|
129
|
+
*/
|
|
130
|
+
LoadLayout(config: WorkspaceLayoutConfig): void;
|
|
131
|
+
/**
|
|
132
|
+
* Save current layout to configuration format
|
|
133
|
+
*/
|
|
134
|
+
SaveLayout(): WorkspaceLayoutConfig;
|
|
135
|
+
/**
|
|
136
|
+
* Get container for a tab
|
|
137
|
+
*/
|
|
138
|
+
GetContainer(tabId: string): GLComponentContainer | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Check if tab content has been loaded
|
|
141
|
+
*/
|
|
142
|
+
IsTabLoaded(tabId: string): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Mark tab as loaded
|
|
145
|
+
*/
|
|
146
|
+
MarkTabLoaded(tabId: string): void;
|
|
147
|
+
/**
|
|
148
|
+
* Mark tab as not loaded (forces reload on next show)
|
|
149
|
+
*/
|
|
150
|
+
MarkTabNotLoaded(tabId: string): void;
|
|
151
|
+
/**
|
|
152
|
+
* Get all tab IDs currently in the layout
|
|
153
|
+
*/
|
|
154
|
+
GetAllTabIds(): string[];
|
|
155
|
+
/**
|
|
156
|
+
* Bind component event listener (called by Golden Layout)
|
|
157
|
+
*/
|
|
158
|
+
private bindComponentEventListener;
|
|
159
|
+
/**
|
|
160
|
+
* Unbind component event listener (called by Golden Layout)
|
|
161
|
+
*/
|
|
162
|
+
private unbindComponentEventListener;
|
|
163
|
+
/**
|
|
164
|
+
* Apply visual styles to a tab
|
|
165
|
+
*/
|
|
166
|
+
private applyTabStyles;
|
|
167
|
+
/**
|
|
168
|
+
* Refresh styles for all tabs (after drag/drop)
|
|
169
|
+
*/
|
|
170
|
+
private refreshAllTabStyles;
|
|
171
|
+
/**
|
|
172
|
+
* Find first stack in layout
|
|
173
|
+
*/
|
|
174
|
+
private findFirstStack;
|
|
175
|
+
/**
|
|
176
|
+
* Convert workspace layout config to Golden Layout config
|
|
177
|
+
*/
|
|
178
|
+
private convertToGoldenLayoutConfig;
|
|
179
|
+
/**
|
|
180
|
+
* Sanitize a layout node to ensure all values are Golden Layout compatible
|
|
181
|
+
*/
|
|
182
|
+
private sanitizeLayoutNode;
|
|
183
|
+
/**
|
|
184
|
+
* Convert Golden Layout config to workspace layout config
|
|
185
|
+
*/
|
|
186
|
+
private convertFromGoldenLayoutConfig;
|
|
187
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GoldenLayoutManager, never>;
|
|
188
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<GoldenLayoutManager>;
|
|
189
|
+
}
|
|
190
|
+
export {};
|