@siemens/dashboards-ng 48.9.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 CHANGED
@@ -61,7 +61,7 @@ import { SiTranslateModule } from '@siemens/element-translate-ng/translate';
61
61
  BrowserModule,
62
62
 
63
63
  // Import this library
64
- SiDashboardsNgModule.forRoot({})
64
+ SiDashboardsNgModule
65
65
  ],
66
66
  providers: [
67
67
  provideNgxTranslateForElement()
@@ -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
- the library module definition.
247
+ your module providers or application config.
201
248
 
202
249
  ```ts
203
- SiDashboardsNgModule.forRoot({
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 when importing
219
- the `SiDashboardsNgModule` using `SiDashboardsNgModule.forRoot({...})`.
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;KAClB,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,KAAC,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;;;;"}
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;;;;"}