@siemens/dashboards-ng 48.8.0 → 49.0.0-rc.1
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/README.md +58 -17
- package/fesm2022/siemens-dashboards-ng-module-federation.mjs.map +1 -1
- package/fesm2022/siemens-dashboards-ng.mjs +220 -197
- package/fesm2022/siemens-dashboards-ng.mjs.map +1 -1
- package/module-federation/package.json +2 -1
- package/package.json +9 -10
- package/translate/package.json +2 -1
- package/{index.d.ts → types/siemens-dashboards-ng.d.ts} +105 -82
- /package/{module-federation/index.d.ts → types/siemens-dashboards-ng-module-federation.d.ts} +0 -0
- /package/{translate/index.d.ts → types/siemens-dashboards-ng-translate.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -16,8 +16,7 @@ npm install --save @siemens/dashboards-ng gridstack
|
|
|
16
16
|
|
|
17
17
|
### Add libraries to your project
|
|
18
18
|
|
|
19
|
-
The library supports standalone components and modules.
|
|
20
|
-
or module federation still need a module definition.
|
|
19
|
+
The library supports standalone components and modules.
|
|
21
20
|
|
|
22
21
|
### Standalone
|
|
23
22
|
|
|
@@ -62,7 +61,7 @@ import { SiTranslateModule } from '@siemens/element-translate-ng/translate';
|
|
|
62
61
|
BrowserModule,
|
|
63
62
|
|
|
64
63
|
// Import this library
|
|
65
|
-
SiDashboardsNgModule
|
|
64
|
+
SiDashboardsNgModule
|
|
66
65
|
],
|
|
67
66
|
providers: [
|
|
68
67
|
provideNgxTranslateForElement()
|
|
@@ -165,13 +164,14 @@ TranslateModule.forRoot({
|
|
|
165
164
|
### Widget development
|
|
166
165
|
|
|
167
166
|
You can develop your own widgets that are managed by the dashboard. One or multiple widgets
|
|
168
|
-
have to be provided by an Angular module and described by a `Widget` object, that includes
|
|
167
|
+
have to be provided by an Angular module or standalone and described by a `Widget` object, that includes
|
|
169
168
|
the meta information and the Angular widget instance component and editor names that are
|
|
170
169
|
used to instantiate the widget at runtime.
|
|
171
170
|
|
|
172
|
-
The widget instance component
|
|
173
|
-
editor
|
|
174
|
-
module loader function
|
|
171
|
+
The widget instance component must implement the `WidgetInstance` interface and the
|
|
172
|
+
editor must implement the `WidgetInstanceEditor` interface. You must provide either
|
|
173
|
+
a module loader function with module name or a component loader function for standalone components
|
|
174
|
+
that is used to load the widget when needed.
|
|
175
175
|
|
|
176
176
|
The library ships with a [hello-widget](https://github.com/siemens/element/blob/main/projects/dashboards-demo/src/app/widgets/hello-widget/) example for illustration.
|
|
177
177
|
|
|
@@ -184,6 +184,53 @@ The Angular component should export the template as the public attribute `footer
|
|
|
184
184
|
@ViewChild('footer', { static: true }) footer?: TemplateRef<unknown>;
|
|
185
185
|
```
|
|
186
186
|
|
|
187
|
+
### Widget instance ID generation
|
|
188
|
+
|
|
189
|
+
Each widget instance on a dashboard requires a unique ID for identification and persistence. The library
|
|
190
|
+
provides a flexible system for generating these IDs through the `SiWidgetIdProvider` abstract class.
|
|
191
|
+
|
|
192
|
+
#### Default ID generation
|
|
193
|
+
|
|
194
|
+
By default, the library uses `SiWidgetDefaultIdProvider`, which generates unique IDs using
|
|
195
|
+
a RFC4122 version 4 UUID (e.g.,`'550e8400-e29b-41d4-a716-446655440000'`). This default implementation
|
|
196
|
+
uses `crypto.randomUUID()` to ensure cryptographically secure uniqueness with 122 bits of entropy.
|
|
197
|
+
|
|
198
|
+
#### Custom ID generation
|
|
199
|
+
|
|
200
|
+
To implement custom ID generation logic (e.g., UUID-based, sequential or
|
|
201
|
+
context-aware IDs), create a class that extends `SiWidgetIdProvider` and implement the
|
|
202
|
+
`generateWidgetId` method:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import { Injectable } from '@angular/core';
|
|
206
|
+
import { SiWidgetIdProvider } from '@siemens/dashboards-ng';
|
|
207
|
+
|
|
208
|
+
@Injectable()
|
|
209
|
+
export class CustomWidgetIdProvider extends SiWidgetIdProvider {
|
|
210
|
+
override generateWidgetId(widget: WidgetConfig, dashboardId?: string): string {
|
|
211
|
+
// Example: Create a composite ID from dashboard and widget type
|
|
212
|
+
const prefix = dashboardId ?? 'default';
|
|
213
|
+
const timestamp = Date.now();
|
|
214
|
+
return `${prefix}-${widget.widgetId}-${timestamp}`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### Providing a custom ID provider
|
|
220
|
+
|
|
221
|
+
To use your custom ID provider, register it in your application's providers:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
// For standalone applications
|
|
225
|
+
providers: [{ provide: SI_WIDGET_ID_PROVIDER, useClass: CustomWidgetIdProvider }];
|
|
226
|
+
|
|
227
|
+
// For module-based applications
|
|
228
|
+
@NgModule({
|
|
229
|
+
providers: [{ provide: SI_WIDGET_ID_PROVIDER, useClass: CustomWidgetIdProvider }]
|
|
230
|
+
})
|
|
231
|
+
export class AppModule {}
|
|
232
|
+
```
|
|
233
|
+
|
|
187
234
|
### Dashboard persistence
|
|
188
235
|
|
|
189
236
|
The library persists a dashboard configuration by the default `SiDefaultWidgetStorage` implementation
|
|
@@ -197,16 +244,10 @@ providers: [..., { provide: DEFAULT_WIDGET_STORAGE_TOKEN, useValue: localStorage
|
|
|
197
244
|
|
|
198
245
|
For persistence in a backend service, you should implement your own
|
|
199
246
|
[SiWidgetStorage](https://github.com/siemens/element/blob/main/projects/dashboards-ng/src/model/si-widget-storage.ts) and provide it in
|
|
200
|
-
|
|
247
|
+
your module providers or application config.
|
|
201
248
|
|
|
202
249
|
```ts
|
|
203
|
-
|
|
204
|
-
config: {},
|
|
205
|
-
dashboardApi: {
|
|
206
|
-
provide: SiWidgetStorage,
|
|
207
|
-
useClass: CustomWidgetStorage
|
|
208
|
-
}
|
|
209
|
-
});
|
|
250
|
+
providers: [{ provide: SI_WIDGET_STORE, useClass: CustomWidgetStorage }];
|
|
210
251
|
```
|
|
211
252
|
|
|
212
253
|
### Configuration
|
|
@@ -215,8 +256,8 @@ The dashboard is configurable through the Angular inputs of the exposed componen
|
|
|
215
256
|
the usage of the configuration object `Config`, which includes a `GridConfig` and including
|
|
216
257
|
the [GridStackOptions](https://github.com/siemens/element/blob/main/projects/dashboards-ng/src/model/gridstack.model.ts).
|
|
217
258
|
|
|
218
|
-
To configure all dashboard instances, you can leverage dependency injection
|
|
219
|
-
the `
|
|
259
|
+
To configure all dashboard instances, you can leverage dependency injection by providing
|
|
260
|
+
the `SI_DASHBOARD_CONFIGURATION` token in your providers.
|
|
220
261
|
Alternatively, you have the option to configure individual dashboard instances by setting
|
|
221
262
|
the input property `SiFlexibleDashboardComponent.config = {...}`.
|
|
222
263
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siemens-dashboards-ng-module-federation.mjs","sources":["../../../../projects/dashboards-ng/module-federation/index.ts","../../../../projects/dashboards-ng/module-federation/siemens-dashboards-ng-module-federation.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { loadRemoteModule } from '@angular-architects/module-federation';\nimport { ComponentRef, EnvironmentInjector, Injector, ViewContainerRef, Type } from '@angular/core';\nimport { FederatedModule, SetupComponentFn, widgetFactoryRegistry } from '@siemens/dashboards-ng';\nimport { Observable, Subject } from 'rxjs';\n\nconst setupRemoteComponent = <T>(\n factory: FederatedModule,\n componentName: string,\n host: ViewContainerRef,\n injector: Injector,\n environmentInjector: EnvironmentInjector\n): Observable<ComponentRef<T>> => {\n const result = new Subject<ComponentRef<T>>();\n\n loadRemoteModule<Type<T>[]>(factory).then(\n module => {\n const componentType = module[factory[componentName]];\n const widgetInstanceRef = host.createComponent<T>(componentType, {\n injector,\n environmentInjector\n });\n result.next(widgetInstanceRef);\n result.complete();\n },\n rejection => {\n const msg = rejection\n ? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(\n rejection.toString()\n )}`\n : `Loading widget module ${factory.exposedModule} failed`;\n result.error(msg);\n result.complete();\n }\n );\n return result;\n};\n\nexport const registerModuleFederatedWidgetLoader = (): void => {\n widgetFactoryRegistry.register('module-federation', setupRemoteComponent as SetupComponentFn);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAMH,MAAM,oBAAoB,GAAG,CAC3B,OAAwB,EACxB,aAAqB,EACrB,IAAsB,EACtB,QAAkB,EAClB,mBAAwC,KACT;AAC/B,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAmB;IAE7C,gBAAgB,CAAY,OAAO,CAAC,CAAC,IAAI,CACvC,MAAM,IAAG;QACP,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACpD,QAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAI,aAAa,EAAE;YAC/D,QAAQ;YACR;AACD,SAAA,CAAC;AACF,QAAA,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAC9B,MAAM,CAAC,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"siemens-dashboards-ng-module-federation.mjs","sources":["../../../../projects/dashboards-ng/module-federation/index.ts","../../../../projects/dashboards-ng/module-federation/siemens-dashboards-ng-module-federation.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { loadRemoteModule } from '@angular-architects/module-federation';\nimport { ComponentRef, EnvironmentInjector, Injector, ViewContainerRef, Type } from '@angular/core';\nimport { FederatedModule, SetupComponentFn, widgetFactoryRegistry } from '@siemens/dashboards-ng';\nimport { Observable, Subject } from 'rxjs';\n\nconst setupRemoteComponent = <T>(\n factory: FederatedModule,\n componentName: string,\n host: ViewContainerRef,\n injector: Injector,\n environmentInjector: EnvironmentInjector\n): Observable<ComponentRef<T>> => {\n const result = new Subject<ComponentRef<T>>();\n\n loadRemoteModule<Type<T>[]>(factory).then(\n module => {\n const componentType = module[factory[componentName]];\n const widgetInstanceRef = host.createComponent<T>(componentType, {\n injector,\n environmentInjector\n });\n result.next(widgetInstanceRef);\n result.complete();\n },\n rejection => {\n const msg = rejection\n ? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(\n rejection.toString()\n )}`\n : `Loading widget module ${factory.exposedModule} failed`;\n result.error(msg);\n result.complete();\n }\n );\n return result;\n};\n\nexport const registerModuleFederatedWidgetLoader = (): void => {\n widgetFactoryRegistry.register('module-federation', setupRemoteComponent as SetupComponentFn);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAMH,MAAM,oBAAoB,GAAG,CAC3B,OAAwB,EACxB,aAAqB,EACrB,IAAsB,EACtB,QAAkB,EAClB,mBAAwC,KACT;AAC/B,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAmB;IAE7C,gBAAgB,CAAY,OAAO,CAAC,CAAC,IAAI,CACvC,MAAM,IAAG;QACP,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACpD,QAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAI,aAAa,EAAE;YAC/D,QAAQ;YACR;AACD,SAAA,CAAC;AACF,QAAA,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAC9B,MAAM,CAAC,QAAQ,EAAE;IACnB,CAAC,EACD,SAAS,IAAG;QACV,MAAM,GAAG,GAAG;AACV,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,CAAA,aAAA,EAAgB,IAAI,CAAC,SAAS,CAC1E,SAAS,CAAC,QAAQ,EAAE,CACrB,CAAA;AACH,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,SAAS;AAC3D,QAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACjB,MAAM,CAAC,QAAQ,EAAE;AACnB,IAAA,CAAC,CACF;AACD,IAAA,OAAO,MAAM;AACf,CAAC;AAEM,MAAM,mCAAmC,GAAG,MAAW;AAC5D,IAAA,qBAAqB,CAAC,QAAQ,CAAC,mBAAmB,EAAE,oBAAwC,CAAC;AAC/F;;AC3CA;;AAEG;;;;"}
|