@c8y/tutorial 1021.80.1 → 1022.3.2

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.
Files changed (86) hide show
  1. package/cumulocity.config.ts +23 -1
  2. package/package.json +13 -12
  3. package/src/__mocks/index.ts +168 -1
  4. package/src/app/app.config.ts +59 -0
  5. package/src/bootstrap.ts +13 -9
  6. package/src/bottom-drawer/bottom-drawer-content-example.component.html +28 -0
  7. package/src/bottom-drawer/bottom-drawer-content-example.component.ts +33 -0
  8. package/src/bottom-drawer/bottom-drawer-example.component.html +7 -0
  9. package/src/bottom-drawer/bottom-drawer-example.component.ts +33 -0
  10. package/src/bottom-drawer/bottom-drawer.providers.ts +17 -0
  11. package/src/breadcrumbs/index.ts +13 -1
  12. package/src/client-interceptor/index.ts +16 -1
  13. package/src/component-styles/syntactically-awesome-style-sheets-example/syntactically-awesome-style-sheets-example.component.scss +4 -2
  14. package/src/countdown/countdown-example.module.ts +1 -1
  15. package/src/dashboard/widget-guide-context-dashboard/widget-guide-context-dashboard.component.ts +1 -9
  16. package/src/date-time-range/date-time-range-example.component.ts +0 -1
  17. package/src/dynamic-forms/index.ts +13 -1
  18. package/src/grids/index.ts +13 -1
  19. package/src/grids/server-grid-example/last-updated-data-grid-column/last-updated.cell-renderer.component.ts +2 -1
  20. package/src/grids/server-grid-example/server-grid-example.component.html +2 -1
  21. package/src/grids/tree-grid-example/client-tree-grid-example.component.html +18 -0
  22. package/src/grids/tree-grid-example/client-tree-grid-example.component.ts +169 -0
  23. package/src/grids/tree-grid-example/client-tree-grid.data.ts +147 -0
  24. package/src/grids/tree-grid-example/server-tree-grid-example.component.html +30 -0
  25. package/src/grids/tree-grid-example/server-tree-grid-example.component.ts +156 -0
  26. package/src/grids/tree-grid-example/server-tree-grid-example.service.ts +255 -0
  27. package/src/grids/tree-grid-example/tree-grid-example-tab.factory.ts +31 -0
  28. package/src/grids/tree-grid-example/tree-grid-example.module.ts +36 -0
  29. package/src/hello/index.ts +18 -1
  30. package/src/hooks/action/logout-action/logout-action.component.ts +3 -4
  31. package/src/hooks/generic-wizard/minimal-setup/minimal-setup.component.ts +4 -1
  32. package/src/hooks/generic-wizard/minimal-setup/multiple-entries-one.component.ts +9 -2
  33. package/src/hooks/generic-wizard/minimal-setup/multiple-entries-two.component.ts +9 -2
  34. package/src/hooks/generic-wizard/wizard.module.ts +9 -2
  35. package/src/hooks/index.ts +13 -1
  36. package/src/hooks/navigator/index.ts +12 -1
  37. package/src/hooks/route/index.ts +42 -1
  38. package/src/hooks/stepper/basic-view/basic-view.component.ts +11 -2
  39. package/src/hooks/stepper/stepper-hook.module.ts +7 -2
  40. package/src/hooks/stepper/steps/step1.component.ts +26 -3
  41. package/src/hooks/stepper/steps/step2.component.ts +4 -1
  42. package/src/hooks/widget-config/additional-config/additional-config.component.ts +16 -0
  43. package/src/hooks/widget-config/basic-view/basic-edit.component.html +18 -0
  44. package/src/hooks/widget-config/basic-view/basic-edit.component.ts +31 -0
  45. package/src/hooks/widget-config/widget-config.providers.ts +59 -0
  46. package/src/i18n.ts +3 -0
  47. package/src/lazy/index.ts +38 -1
  48. package/src/lazy-widget/index.ts +26 -1
  49. package/src/list/index.ts +13 -1
  50. package/src/main.ts +7 -10
  51. package/src/maps/{map-examples.module.ts → index.ts} +4 -9
  52. package/src/provider-configuration/index.ts +0 -2
  53. package/src/provider-configuration/introduction-example/{introduction.module.ts → index.ts} +5 -7
  54. package/src/redirect-to-last-route/index.ts +16 -1
  55. package/src/redirect-to-last-route/redirect-to-last-route-guard.service.ts +11 -2
  56. package/src/selector/alarm-event-selector-example/alarm-event-selector.module.ts +1 -1
  57. package/src/selector/asset-selector-example/general-example/asset-selector-example.component.ts +1 -2
  58. package/src/translations/index.ts +13 -1
  59. package/src/user-menu/index.ts +23 -1
  60. package/src/widget/demo-widget-config.component.ts +11 -3
  61. package/src/widget/demo-widget.component.ts +6 -2
  62. package/src/widget/index.ts +41 -1
  63. package/src/widget-resolvers/alternative-event.resolver.ts +8 -2
  64. package/src/widget-resolvers/index.ts +47 -1
  65. package/src/widget-resolvers/widget-resolvers-config/widget-resolvers-config.component.ts +7 -3
  66. package/src/widget-resolvers/widget-resolvers.component.ts +5 -1
  67. package/src/__mocks/mock.module.ts +0 -173
  68. package/src/app/app.module.ts +0 -76
  69. package/src/breadcrumbs/breadcrumbs.module.ts +0 -14
  70. package/src/client-interceptor/client-interceptor.module.ts +0 -12
  71. package/src/dynamic-forms/dynamic-forms.module.ts +0 -16
  72. package/src/grids/grids.module.ts +0 -17
  73. package/src/hello/hello.module.ts +0 -20
  74. package/src/hooks/hooks.module.ts +0 -19
  75. package/src/hooks/navigator/navigator.module.ts +0 -21
  76. package/src/hooks/route/route.module.ts +0 -51
  77. package/src/lazy/lazy-routing.module.ts +0 -21
  78. package/src/lazy/lazy.hooks.ts +0 -24
  79. package/src/lazy-widget/lazy-widget.module.ts +0 -30
  80. package/src/list/lists.module.ts +0 -17
  81. package/src/redirect-to-last-route/redirect-to-last-route.module.ts +0 -20
  82. package/src/translations/translations.module.ts +0 -18
  83. package/src/user-menu/user-menu.module.ts +0 -13
  84. package/src/user-menu/user-menu.ts +0 -26
  85. package/src/widget/demo-widget.module.ts +0 -55
  86. package/src/widget-resolvers/widget-resolvers.module.ts +0 -52
@@ -0,0 +1,31 @@
1
+ import { AsyncPipe, CommonModule, JsonPipe } from '@angular/common';
2
+ import { Component, inject, OnInit, OnDestroy } from '@angular/core';
3
+ import { CoreModule } from '@c8y/ngx-components';
4
+ import {
5
+ WidgetConfigSectionComponent,
6
+ WidgetConfigService
7
+ } from '@c8y/ngx-components/context-dashboard';
8
+ import { referenceWidgetDefinition } from '../widget-config.providers';
9
+
10
+ /**
11
+ * This is a standard angular component.
12
+ * It simply shows the edit view of the widget.
13
+ */
14
+ @Component({
15
+ selector: 'tut-basic-widget-config-hook-view',
16
+ templateUrl: './basic-edit.component.html',
17
+ standalone: true,
18
+ imports: [CoreModule, CommonModule, WidgetConfigSectionComponent, AsyncPipe, JsonPipe]
19
+ })
20
+ export class BasicEditComponent implements OnInit, OnDestroy {
21
+ widgetConfigService = inject(WidgetConfigService);
22
+
23
+ ngOnInit(): void {
24
+ this.widgetConfigService.initConfig({});
25
+ this.widgetConfigService.selectWidget(referenceWidgetDefinition);
26
+ }
27
+
28
+ ngOnDestroy(): void {
29
+ this.widgetConfigService.deselectWidget();
30
+ }
31
+ }
@@ -0,0 +1,59 @@
1
+ import {
2
+ EmptyComponent,
3
+ NavigatorNode,
4
+ hookComponent,
5
+ hookNavigator,
6
+ hookRoute
7
+ } from '@c8y/ngx-components';
8
+ import { hookWidgetConfig } from '@c8y/ngx-components/context-dashboard';
9
+
10
+ export const referenceWidgetDefinition = {
11
+ id: 'reference.component',
12
+ label:
13
+ 'A configuration is always attached to a component. This is an empty one, just for demo pruposes.',
14
+ description: 'Nothing to describe',
15
+ loadComponent: () => Promise.resolve(EmptyComponent)
16
+ };
17
+
18
+ /**
19
+ * Use our predefined InjectionTokens and provide your own classes to extend behavior
20
+ * and functionality of existing ones. Implement your own NavigationNodes, Tabs, Actions and Breadcrumbs.
21
+ * Note: Hooks should always be implemented in the module where they are used, so that
22
+ * a module can act standalone and has no dependencies on other modules.
23
+ */
24
+ export const widgetConfigHookProviders = [
25
+ hookRoute({
26
+ path: 'hooks/widget-config',
27
+ loadComponent: () => import('./basic-view/basic-edit.component').then(m => m.BasicEditComponent)
28
+ }),
29
+ hookNavigator(
30
+ new NavigatorNode({
31
+ priority: 70,
32
+ path: 'hooks/widget-config',
33
+ icon: 'edit',
34
+ label: 'Widget Config',
35
+ parent: 'Hooks'
36
+ })
37
+ ),
38
+ hookComponent(referenceWidgetDefinition),
39
+ // important
40
+ hookWidgetConfig({
41
+ widgetId: 'reference.component',
42
+ label: 'An additional Configuration for the simple component',
43
+ priority: 100,
44
+ expanded: true,
45
+ loadComponent: () =>
46
+ import('./additional-config/additional-config.component').then(
47
+ m => m.AdditionalConfigComponent
48
+ )
49
+ }),
50
+
51
+ hookWidgetConfig({
52
+ widgetId: 'reference.component',
53
+ label: 'The default asset selector.',
54
+ priority: 10,
55
+ loadComponent: () =>
56
+ import('@c8y/ngx-components/context-dashboard').then(m => m.WidgetAssetSelectorComponent)
57
+ })
58
+ // /important
59
+ ];
package/src/i18n.ts CHANGED
@@ -16,3 +16,6 @@ import '@c8y/ngx-components/locales/pt_BR.po';
16
16
  import '@c8y/ngx-components/locales/zh_CN.po';
17
17
  import '@c8y/ngx-components/locales/zh_TW.po';
18
18
  // import './locales/de.po'; // <- adding additional strings to the german translation.
19
+
20
+ import './translations/locales/pt_BR.po';
21
+ import './translations/locales/it.po';
package/src/lazy/index.ts CHANGED
@@ -1 +1,38 @@
1
- export * from './lazy-routing.module';
1
+ import { hookNavigator, hookRoute, NavigatorNode } from '@c8y/ngx-components';
2
+
3
+ const root = new NavigatorNode({
4
+ label: 'Lazy loaded',
5
+ icon: 'hourglass-start'
6
+ });
7
+
8
+ root.add(
9
+ new NavigatorNode({
10
+ path: '/lazy/one',
11
+ label: 'One',
12
+ icon: 'thermometer'
13
+ })
14
+ );
15
+
16
+ root.add(
17
+ new NavigatorNode({
18
+ path: '/lazy/two',
19
+ label: 'Two',
20
+ icon: 'thermometer-3'
21
+ })
22
+ );
23
+
24
+ export function provideLazySample() {
25
+ return [
26
+ /**
27
+ * Angular Routes.
28
+ * Within this array at least path (url) and components are linked.
29
+ */
30
+ hookRoute([
31
+ {
32
+ path: 'lazy',
33
+ loadChildren: () => import('./lazy-loaded.module').then(m => m.LazyLoadedModule)
34
+ }
35
+ ]),
36
+ hookNavigator(root)
37
+ ];
38
+ }
@@ -1 +1,26 @@
1
- export * from './lazy-widget.module';
1
+ import { hookWidget } from '@c8y/ngx-components';
2
+
3
+ async function loadViewComponent() {
4
+ const { LazyWidgetViewComponent } = await import('./lazy-widget-view');
5
+ return LazyWidgetViewComponent;
6
+ }
7
+
8
+ async function loadConfigComponent() {
9
+ const { LazyWidgetConfigComponent } = await import('./lazy-widget-config');
10
+ return LazyWidgetConfigComponent;
11
+ }
12
+
13
+ export function provideLazyWidget() {
14
+ return [
15
+ hookWidget({
16
+ id: 'tutorial-lazy-widget',
17
+ label: 'Lazy Loaded Widget',
18
+ description: 'Lazy Loaded Widget',
19
+ loadComponent: loadViewComponent,
20
+ loadConfigComponent: loadConfigComponent,
21
+ data: {
22
+ schema: () => import('c8y-schema-loader?interfaceName=WidgetConfig!./widget-config.model')
23
+ }
24
+ })
25
+ ];
26
+ }
package/src/list/index.ts CHANGED
@@ -1 +1,13 @@
1
- export * from './lists.module';
1
+ import { hookNavigator, NavigatorNode } from '@c8y/ngx-components';
2
+
3
+ export function provideListsSampleNavigator() {
4
+ return [
5
+ hookNavigator(
6
+ new NavigatorNode({
7
+ label: 'Lists',
8
+ icon: 'c8y-device',
9
+ priority: 97
10
+ })
11
+ )
12
+ ];
13
+ }
package/src/main.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import './i18n';
2
- import { applyOptions, loadOptions } from '@c8y/bootstrap';
3
2
 
4
3
  const barHolder: HTMLElement | null = document.querySelector('body > .init-load');
5
4
  export const removeProgress = () => barHolder?.parentNode?.removeChild(barHolder);
@@ -7,14 +6,12 @@ export const removeProgress = () => barHolder?.parentNode?.removeChild(barHolder
7
6
  applicationSetup();
8
7
 
9
8
  async function applicationSetup() {
10
- await applyOptions({
11
- ...(await loadOptions())
12
- });
9
+ const { loadMetaDataAndPerformBootstrap } = await import('@c8y/bootstrap');
10
+ const loadBootstrapModule = () =>
11
+ import(
12
+ /* webpackPreload: true */
13
+ './bootstrap'
14
+ );
13
15
 
14
- const mod = await import(
15
- /* webpackPreload: true */
16
- './bootstrap'
17
- );
18
- const bootstrapApp = mod.bootstrap;
19
- return bootstrapApp().then(removeProgress);
16
+ loadMetaDataAndPerformBootstrap(loadBootstrapModule).then(removeProgress);
20
17
  }
@@ -1,11 +1,7 @@
1
- import { NgModule } from '@angular/core';
2
1
  import { hookNavigator, NavigatorNode } from '@c8y/ngx-components';
3
2
 
4
- @NgModule({
5
- declarations: [],
6
- imports: [],
7
- exports: [],
8
- providers: [
3
+ export function provideMapExampleNavigator() {
4
+ return [
9
5
  hookNavigator(
10
6
  new NavigatorNode({
11
7
  priority: 20,
@@ -13,6 +9,5 @@ import { hookNavigator, NavigatorNode } from '@c8y/ngx-components';
13
9
  label: 'Map examples'
14
10
  })
15
11
  )
16
- ]
17
- })
18
- export class MapExamplesModule {}
12
+ ];
13
+ }
@@ -1,3 +1 @@
1
1
  export * from './provider-configuration-example/demo-provider.guard';
2
- export * from './introduction-example/introduction.component';
3
- export * from './introduction-example/introduction.module';
@@ -1,8 +1,7 @@
1
- import { NgModule } from '@angular/core';
2
- import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
1
+ import { hookNavigator, hookRoute, NavigatorNode } from '@c8y/ngx-components';
3
2
 
4
- @NgModule({
5
- providers: [
3
+ export function provideProviderConfigurationIntroduction() {
4
+ return [
6
5
  hookRoute({
7
6
  path: 'provider-configuration/introduction-example',
8
7
  loadComponent: () => import('./introduction.component').then(m => m.IntroductionComponent)
@@ -16,6 +15,5 @@ import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
16
15
  parent: 'Provider configuration'
17
16
  })
18
17
  )
19
- ]
20
- })
21
- export class IntroductionModule {}
18
+ ];
19
+ }
@@ -1 +1,16 @@
1
- export * from './redirect-to-last-route.module';
1
+ import { EmptyComponent, hookRoute } from '@c8y/ngx-components';
2
+ import { RedirectToLastRouteGuardService } from './redirect-to-last-route-guard.service';
3
+ import { inject } from '@angular/core';
4
+ import { CanActivateFn } from '@angular/router';
5
+
6
+ export function provideRedirectToLastRoute() {
7
+ return [
8
+ hookRoute({
9
+ path: 'pickLastRoute',
10
+ canActivate: [
11
+ ((...args) => inject(RedirectToLastRouteGuardService).canActivate(...args)) as CanActivateFn
12
+ ],
13
+ component: EmptyComponent
14
+ })
15
+ ];
16
+ }
@@ -9,8 +9,17 @@ export class RedirectToLastRouteGuardService {
9
9
  if (!this.router.config.length) {
10
10
  return false;
11
11
  }
12
- const lastRoute = this.router.config[this.router.config.length - 1];
13
- this.router.navigate([lastRoute.path]);
12
+
13
+ for (let i = this.router.config.length - 1; i >= 0; i--) {
14
+ const route = this.router.config[i];
15
+ if (!route.path || route.path.includes('pickLastRoute')) {
16
+ continue;
17
+ }
18
+
19
+ this.router.navigate([route.path]);
20
+ return false;
21
+ }
22
+
14
23
  return false;
15
24
  };
16
25
  }
@@ -10,7 +10,7 @@ import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
10
10
  }),
11
11
  hookNavigator(
12
12
  new NavigatorNode({
13
- label: 'alarm event selector example',
13
+ label: 'Alarm event selector example',
14
14
  path: '/selector/alarm-event-selector-example',
15
15
  icon: 'th-list',
16
16
  priority: 15
@@ -1,7 +1,6 @@
1
1
  import { Component } from '@angular/core';
2
- import { InventoryService } from '@c8y/ngx-components/api';
3
2
  import { BehaviorSubject } from 'rxjs';
4
- import { IIdentified, IManagedObject } from '@c8y/client';
3
+ import { InventoryService, IIdentified, IManagedObject } from '@c8y/client';
5
4
  import { CommonModule } from '@angular/common';
6
5
  import { CoreModule } from '@c8y/ngx-components';
7
6
  import { AssetSelectorModule } from '@c8y/ngx-components/assets-navigator';
@@ -1 +1,13 @@
1
- export * from './translations.module';
1
+ import { hookNavigator, NavigatorNode } from '@c8y/ngx-components';
2
+
3
+ export function provideTranslationsNavigator() {
4
+ return [
5
+ hookNavigator(
6
+ new NavigatorNode({
7
+ priority: 20,
8
+ icon: 'rocket',
9
+ label: 'Translations'
10
+ })
11
+ )
12
+ ];
13
+ }
@@ -1 +1,23 @@
1
- export * from './user-menu.module';
1
+ import { EnvironmentProviders, Provider, inject, provideAppInitializer } from '@angular/core';
2
+ import { AlertService, gettext, UserMenuService } from '@c8y/ngx-components';
3
+
4
+ export function provideUserMenuSample() {
5
+ return [
6
+ provideAppInitializer(() => {
7
+ const initializerFn = ((userMenu: UserMenuService, alert: AlertService) => {
8
+ return () => {
9
+ userMenu.add({
10
+ icon: 'notification',
11
+ label: gettext('Notifications'),
12
+ priority: 0,
13
+ // method to be called when button in user menu is clicked
14
+ click: () => {
15
+ alert.info(gettext('Notification button clicked.'));
16
+ }
17
+ });
18
+ };
19
+ })(inject(UserMenuService), inject(AlertService));
20
+ return initializerFn();
21
+ })
22
+ ] satisfies (Provider | EnvironmentProviders)[];
23
+ }
@@ -1,7 +1,13 @@
1
1
  import { Component, Input } from '@angular/core';
2
- import { ControlContainer, NgForm } from '@angular/forms';
3
- import { DynamicComponent, OnBeforeSave, AlertService } from '@c8y/ngx-components';
2
+ import { ControlContainer, NgForm, FormsModule } from '@angular/forms';
3
+ import {
4
+ DynamicComponent,
5
+ OnBeforeSave,
6
+ AlertService,
7
+ FormGroupComponent
8
+ } from '@c8y/ngx-components';
4
9
  import { omit } from 'lodash';
10
+ import { JsonPipe } from '@angular/common';
5
11
  import { WidgetConfig } from './widget-config.model';
6
12
 
7
13
  @Component({
@@ -30,7 +36,9 @@ import { WidgetConfig } from './widget-config.model';
30
36
  // We connect our parent Form to this form (for disabling the save button)
31
37
  // you can also enable the button by using ContextServiceDashboard.formDisabled
32
38
  // property instead (by default it is enabled).
33
- viewProviders: [{ provide: ControlContainer, useExisting: NgForm }]
39
+ viewProviders: [{ provide: ControlContainer, useExisting: NgForm }],
40
+ standalone: true,
41
+ imports: [FormGroupComponent, FormsModule, JsonPipe]
34
42
  })
35
43
  export class WidgetConfigDemo implements DynamicComponent, OnBeforeSave {
36
44
  /**
@@ -3,8 +3,10 @@ import {
3
3
  DismissAlertStrategy,
4
4
  DynamicComponentAlert,
5
5
  DynamicComponentAlertAggregator,
6
- gettext
6
+ gettext,
7
+ DatePipe
7
8
  } from '@c8y/ngx-components';
9
+ import { NgIf } from '@angular/common';
8
10
  import { WidgetConfig } from './widget-config.model';
9
11
 
10
12
  @Component({
@@ -31,7 +33,9 @@ import { WidgetConfig } from './widget-config.model';
31
33
  font-size: 2em;
32
34
  }
33
35
  `
34
- ]
36
+ ],
37
+ standalone: true,
38
+ imports: [NgIf, DatePipe]
35
39
  })
36
40
  export class WidgetDemo implements OnChanges {
37
41
  @Input() config: WidgetConfig;
@@ -1 +1,41 @@
1
- export * from './demo-widget.module';
1
+ import { DynamicComponentErrorStrategy, hookWidget } from '@c8y/ngx-components';
2
+ import { WidgetDemo } from './demo-widget.component';
3
+ import { WidgetConfigDemo } from './demo-widget-config.component';
4
+
5
+ export function provideDemoWidget() {
6
+ return [
7
+ /**
8
+ * This demo widget provides an example on how
9
+ * to use the hookWidget. The component itself
10
+ * is implemented in the dashboard on the
11
+ * ../hello/hello.component.html by using the
12
+ * dynamic-component tag.
13
+ */
14
+ hookWidget({
15
+ id: 'angular.widget.demo',
16
+ label: 'My angular widget',
17
+ description: 'This is a description from angular',
18
+ component: WidgetDemo,
19
+ configComponent: WidgetConfigDemo,
20
+ errorStrategy: DynamicComponentErrorStrategy.OVERLAY_ERROR,
21
+ /** new Angular-Dashboard definition */
22
+ data: {
23
+ schema: () => import('c8y-schema-loader?interfaceName=WidgetConfig!./widget-config.model'),
24
+ // The settings object can be used to configure the configComponent
25
+ settings: {
26
+ noNewWidgets: false, // Set this to true, to don't allow adding new widgets.
27
+ ng1: {
28
+ options: {
29
+ noDeviceTarget: false, // Set this to true to hide the AngularJS device selector.
30
+ groupsSelectable: false // Set this, if not only devices should be selectable.
31
+ }
32
+ }
33
+ },
34
+ // Settings that are attached to the display component (in this case: WidgetDemo)
35
+ displaySettings: {
36
+ globalTimeContext: true // Set this to true, to add a global time context binding
37
+ }
38
+ }
39
+ })
40
+ ];
41
+ }
@@ -1,7 +1,11 @@
1
1
  import { Injectable } from '@angular/core';
2
2
  import { EventService } from '@c8y/client';
3
3
  import { IEvent } from '@c8y/client';
4
- import { DynamicBulkIIdentifiedResolver, DynamicResolverService } from '@c8y/ngx-components';
4
+ import {
5
+ DynamicBulkIIdentifiedResolver,
6
+ DynamicResolverService,
7
+ gettext
8
+ } from '@c8y/ngx-components';
5
9
 
6
10
  /**
7
11
  * An short alternative to the DynamicEventResolver class using the abstract class DynamicBulkIIdentifiedResolver.
@@ -10,7 +14,9 @@ import { DynamicBulkIIdentifiedResolver, DynamicResolverService } from '@c8y/ngx
10
14
  export class SimpleDynamicEventResolver extends DynamicBulkIIdentifiedResolver<
11
15
  IEvent & { id: string | number }
12
16
  > {
13
- protected typeForErrorMessage = 'event';
17
+ protected errorMessage = gettext(
18
+ 'Unable to retrieve the following event: "{{entityName}}" ({{entityId}}).'
19
+ );
14
20
 
15
21
  constructor(
16
22
  protected dynamicResolver: DynamicResolverService,
@@ -1 +1,47 @@
1
- export * from './widget-resolvers.module';
1
+ import {
2
+ DynamicComponentErrorStrategy,
3
+ DynamicManagedObjectResolver,
4
+ DynamicWidgetDefinition,
5
+ hookWidget
6
+ } from '@c8y/ngx-components';
7
+ import { DynamicEventResolver } from './event.resolver';
8
+ import { SimpleDynamicEventResolver } from './alternative-event.resolver';
9
+ import { PropertiesLibraryResolver } from './event-property.resolver';
10
+
11
+ export function provideWidgetsResolverSample() {
12
+ return [
13
+ hookWidget({
14
+ loadComponent: () =>
15
+ import('./widget-resolvers.component').then(m => m.WidgetResolversComponent),
16
+ loadConfigComponent: () =>
17
+ import('./widget-resolvers-config/widget-resolvers-config.component').then(
18
+ m => m.WidgetResolversConfigComponent
19
+ ),
20
+ id: 'widget-resolvers',
21
+ label: 'Demo Resolver Widget',
22
+ description: 'Widget demonstrating resolvers.',
23
+ resolve: {
24
+ source: DynamicManagedObjectResolver,
25
+ event: DynamicEventResolver || SimpleDynamicEventResolver,
26
+ property: PropertiesLibraryResolver
27
+ },
28
+ errorStrategy: DynamicComponentErrorStrategy.OVERLAY_ERROR,
29
+ data: {
30
+ schema: () => import('c8y-schema-loader?interfaceName=WidgetConfig!./widget-config.model'),
31
+ settings: {
32
+ noNewWidgets: false,
33
+ widgetDefaults: {
34
+ _width: 2,
35
+ _height: 2
36
+ },
37
+ ng1: {
38
+ options: {
39
+ noDeviceTarget: true,
40
+ groupsSelectable: false
41
+ }
42
+ }
43
+ }
44
+ }
45
+ } satisfies DynamicWidgetDefinition)
46
+ ];
47
+ }
@@ -1,16 +1,20 @@
1
1
  import { Component, Input, OnInit } from '@angular/core';
2
- import { ControlContainer, NgForm } from '@angular/forms';
2
+ import { ControlContainer, NgForm, FormsModule } from '@angular/forms';
3
3
  import { EventService, IEvent, IManagedObject, InventoryService } from '@c8y/client';
4
4
  import {
5
5
  DynamicComponent,
6
6
  DynamicComponentAlert,
7
- DynamicComponentAlertAggregator
7
+ DynamicComponentAlertAggregator,
8
+ FormGroupComponent
8
9
  } from '@c8y/ngx-components';
10
+ import { NgFor } from '@angular/common';
9
11
 
10
12
  @Component({
11
13
  selector: 'app-widget-resolvers-config',
12
14
  templateUrl: './widget-resolvers-config.component.html',
13
- viewProviders: [{ provide: ControlContainer, useExisting: NgForm }]
15
+ viewProviders: [{ provide: ControlContainer, useExisting: NgForm }],
16
+ standalone: true,
17
+ imports: [FormGroupComponent, FormsModule, NgFor]
14
18
  })
15
19
  export class WidgetResolversConfigComponent implements OnInit, DynamicComponent {
16
20
  events: IEvent[];
@@ -1,11 +1,15 @@
1
1
  import { Component, Input, OnInit } from '@angular/core';
2
2
  import { IEvent, IManagedObject } from '@c8y/client';
3
3
  import { DynamicComponentAlertAggregator, DynamicComponent } from '@c8y/ngx-components';
4
+ import { FormsModule } from '@angular/forms';
5
+ import { JsonPipe } from '@angular/common';
4
6
  import { WidgetConfig } from './widget-config.model';
5
7
 
6
8
  @Component({
7
9
  selector: 'app-widget-resolvers',
8
- templateUrl: './widget-resolvers.component.html'
10
+ templateUrl: './widget-resolvers.component.html',
11
+ standalone: true,
12
+ imports: [FormsModule, JsonPipe]
9
13
  })
10
14
  export class WidgetResolversComponent implements OnInit, DynamicComponent {
11
15
  @Input() config: WidgetConfig;