@c8y/tutorial 1021.81.0 → 1022.4.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 (77) hide show
  1. package/cumulocity.config.ts +16 -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/hello/index.ts +18 -1
  21. package/src/hooks/action/logout-action/logout-action.component.ts +3 -4
  22. package/src/hooks/generic-wizard/minimal-setup/minimal-setup.component.ts +4 -1
  23. package/src/hooks/generic-wizard/minimal-setup/multiple-entries-one.component.ts +9 -2
  24. package/src/hooks/generic-wizard/minimal-setup/multiple-entries-two.component.ts +9 -2
  25. package/src/hooks/generic-wizard/wizard.module.ts +9 -2
  26. package/src/hooks/index.ts +13 -1
  27. package/src/hooks/navigator/index.ts +12 -1
  28. package/src/hooks/route/index.ts +42 -1
  29. package/src/hooks/stepper/basic-view/basic-view.component.ts +11 -2
  30. package/src/hooks/stepper/stepper-hook.module.ts +7 -2
  31. package/src/hooks/stepper/steps/step1.component.ts +26 -3
  32. package/src/hooks/stepper/steps/step2.component.ts +4 -1
  33. package/src/hooks/widget-config/additional-config/additional-config.component.ts +16 -0
  34. package/src/hooks/widget-config/basic-view/basic-edit.component.html +18 -0
  35. package/src/hooks/widget-config/basic-view/basic-edit.component.ts +31 -0
  36. package/src/hooks/widget-config/widget-config.providers.ts +59 -0
  37. package/src/i18n.ts +3 -0
  38. package/src/lazy/index.ts +38 -1
  39. package/src/lazy-widget/index.ts +26 -1
  40. package/src/list/index.ts +13 -1
  41. package/src/main.ts +7 -10
  42. package/src/maps/{map-examples.module.ts → index.ts} +4 -9
  43. package/src/provider-configuration/index.ts +0 -2
  44. package/src/provider-configuration/introduction-example/{introduction.module.ts → index.ts} +5 -7
  45. package/src/redirect-to-last-route/index.ts +16 -1
  46. package/src/redirect-to-last-route/redirect-to-last-route-guard.service.ts +11 -2
  47. package/src/selector/alarm-event-selector-example/alarm-event-selector.module.ts +1 -1
  48. package/src/selector/asset-selector-example/general-example/asset-selector-example.component.ts +1 -2
  49. package/src/translations/index.ts +13 -1
  50. package/src/user-menu/index.ts +23 -1
  51. package/src/widget/demo-widget-config.component.ts +11 -3
  52. package/src/widget/demo-widget.component.ts +6 -2
  53. package/src/widget/index.ts +41 -1
  54. package/src/widget-resolvers/alternative-event.resolver.ts +8 -2
  55. package/src/widget-resolvers/index.ts +47 -1
  56. package/src/widget-resolvers/widget-resolvers-config/widget-resolvers-config.component.ts +7 -3
  57. package/src/widget-resolvers/widget-resolvers.component.ts +5 -1
  58. package/src/__mocks/mock.module.ts +0 -173
  59. package/src/app/app.module.ts +0 -76
  60. package/src/breadcrumbs/breadcrumbs.module.ts +0 -14
  61. package/src/client-interceptor/client-interceptor.module.ts +0 -12
  62. package/src/dynamic-forms/dynamic-forms.module.ts +0 -16
  63. package/src/grids/grids.module.ts +0 -17
  64. package/src/hello/hello.module.ts +0 -20
  65. package/src/hooks/hooks.module.ts +0 -19
  66. package/src/hooks/navigator/navigator.module.ts +0 -21
  67. package/src/hooks/route/route.module.ts +0 -51
  68. package/src/lazy/lazy-routing.module.ts +0 -21
  69. package/src/lazy/lazy.hooks.ts +0 -24
  70. package/src/lazy-widget/lazy-widget.module.ts +0 -30
  71. package/src/list/lists.module.ts +0 -17
  72. package/src/redirect-to-last-route/redirect-to-last-route.module.ts +0 -20
  73. package/src/translations/translations.module.ts +0 -18
  74. package/src/user-menu/user-menu.module.ts +0 -13
  75. package/src/user-menu/user-menu.ts +0 -26
  76. package/src/widget/demo-widget.module.ts +0 -55
  77. package/src/widget-resolvers/widget-resolvers.module.ts +0 -52
@@ -1,5 +1,10 @@
1
1
  import { Component } from '@angular/core';
2
- import { WizardComponent } from '@c8y/ngx-components';
2
+ import {
3
+ WizardComponent,
4
+ WizardHeaderComponent,
5
+ WizardBodyComponent,
6
+ WizardFooterComponent
7
+ } from '@c8y/ngx-components';
3
8
 
4
9
  @Component({
5
10
  selector: 'multiple-entries-one-component',
@@ -10,7 +15,9 @@ import { WizardComponent } from '@c8y/ngx-components';
10
15
  <button class="btn btn-default" title="{{ 'Back' }}" (click)="back()">Back</button>
11
16
  <button class="btn btn-default" title="{{ 'Cancel' }}" (click)="cancel()">Cancel</button>
12
17
  </c8y-wizard-footer>
13
- `
18
+ `,
19
+ standalone: true,
20
+ imports: [WizardHeaderComponent, WizardBodyComponent, WizardFooterComponent]
14
21
  })
15
22
  export class MultipleEntriesOne {
16
23
  constructor(private wizardComponent: WizardComponent) {}
@@ -1,5 +1,10 @@
1
1
  import { Component } from '@angular/core';
2
- import { WizardComponent } from '@c8y/ngx-components';
2
+ import {
3
+ WizardComponent,
4
+ WizardHeaderComponent,
5
+ WizardBodyComponent,
6
+ WizardFooterComponent
7
+ } from '@c8y/ngx-components';
3
8
 
4
9
  @Component({
5
10
  selector: 'multiple-entries-two-component',
@@ -10,7 +15,9 @@ import { WizardComponent } from '@c8y/ngx-components';
10
15
  <button class="btn btn-default" title="{{ 'Back' }}" (click)="back()">Back</button>
11
16
  <button class="btn btn-default" title="{{ 'Cancel' }}" (click)="cancel()">Cancel</button>
12
17
  </c8y-wizard-footer>
13
- `
18
+ `,
19
+ standalone: true,
20
+ imports: [WizardHeaderComponent, WizardBodyComponent, WizardFooterComponent]
14
21
  })
15
22
  export class MultipleEntriesTwo {
16
23
  constructor(private wizardComponent: WizardComponent) {}
@@ -21,8 +21,15 @@ const routes: Routes = [
21
21
  ];
22
22
 
23
23
  @NgModule({
24
- declarations: [MinimalSetupComponent, MultipleEntriesOne, MultipleEntriesTwo],
25
- imports: [RouterModule.forChild(routes), CoreModule, FormsModule, ReactiveFormsModule],
24
+ imports: [
25
+ RouterModule.forChild(routes),
26
+ CoreModule,
27
+ FormsModule,
28
+ ReactiveFormsModule,
29
+ MinimalSetupComponent,
30
+ MultipleEntriesOne,
31
+ MultipleEntriesTwo
32
+ ],
26
33
  /**
27
34
  * Adding the hooks to the providers:
28
35
  */
@@ -1 +1,13 @@
1
- export * from './hooks.module';
1
+ import { hookNavigator, NavigatorNode } from '@c8y/ngx-components';
2
+
3
+ export function provideHooksSample() {
4
+ return [
5
+ hookNavigator(
6
+ new NavigatorNode({
7
+ priority: 90,
8
+ icon: 'u-turn',
9
+ label: 'Hooks'
10
+ })
11
+ )
12
+ ];
13
+ }
@@ -1 +1,12 @@
1
- export * from './navigator.module';
1
+ import { hookNavigator } from '@c8y/ngx-components';
2
+ import { ExampleNavigationFactory } from './navigator';
3
+
4
+ export function provideHooksNavigatorSample() {
5
+ /**
6
+ * Use our predefined InjectionTokens and provide your own classes to extend behavior
7
+ * and functionality of existing ones. Implement your own NavigationNodes, Tabs, Actions and Breadcrumbs.
8
+ * Note: Hooks should always be implemented in the module where they are used, so that
9
+ * a module can act standalone and has no dependencies on other modules.
10
+ */
11
+ return [hookNavigator(ExampleNavigationFactory)];
12
+ }
@@ -1 +1,42 @@
1
- export * from './route.module';
1
+ import { hookRoute, ViewContext } from '@c8y/ngx-components';
2
+ import { RandomGuard } from './random.guard';
3
+
4
+ export function provideRouteSample() {
5
+ return [
6
+ /**
7
+ * Route hooks allow you to use routes as child routes on a ViewContext. If used with a context
8
+ * the particular data is resolved automatically and the page is extended by a tab. Contexts
9
+ * are currently Application, Device, Group, Tenant and User. Note: All components used here
10
+ * needs to be used as EntryComponent!
11
+ * This example will add a device tab with all the context information as well as a randomly
12
+ * guarded context tab.
13
+ *
14
+ */
15
+ hookRoute([
16
+ {
17
+ path: 'context',
18
+ context: ViewContext.Device,
19
+ loadComponent: () =>
20
+ import('./device/device-tab-context.component').then(m => m.DeviceTabContextComponent),
21
+ label: 'Context',
22
+ priority: 1000,
23
+ icon: 'bell'
24
+ },
25
+ {
26
+ path: 'info',
27
+ context: ViewContext.Device,
28
+ loadComponent: () =>
29
+ import('./device/device-info.component').then(m => m.DeviceInfoComponent),
30
+ label: 'Info',
31
+ priority: 0,
32
+ icon: 'info',
33
+ /**
34
+ * An example of an route guard which randomly activates
35
+ * the child route. See Guards documentation from Angular
36
+ * for more details.
37
+ */
38
+ canActivate: [RandomGuard]
39
+ }
40
+ ])
41
+ ];
42
+ }
@@ -1,6 +1,13 @@
1
1
  import { Component, OnInit } from '@angular/core';
2
- import { SetupStep, StepperService, Steppers } from '@c8y/ngx-components';
2
+ import {
3
+ SetupStep,
4
+ StepperService,
5
+ Steppers,
6
+ TitleComponent,
7
+ StepperOutletComponent
8
+ } from '@c8y/ngx-components';
3
9
  import { firstValueFrom } from 'rxjs';
10
+ import { NgIf } from '@angular/common';
4
11
 
5
12
  /**
6
13
  * This is a standard angular component.
@@ -21,7 +28,9 @@ import { firstValueFrom } from 'rxjs';
21
28
  </div>
22
29
  </div>
23
30
  </div>
24
- `
31
+ `,
32
+ standalone: true,
33
+ imports: [TitleComponent, NgIf, StepperOutletComponent]
25
34
  })
26
35
  export class BasicViewComponent implements OnInit {
27
36
  readonly stepperId = Steppers.SETUP;
@@ -13,8 +13,13 @@ const routes: Routes = [
13
13
  ];
14
14
 
15
15
  @NgModule({
16
- declarations: [BasicViewComponent, Step1Component, Step2Component],
17
- imports: [RouterModule.forChild(routes), CoreModule],
16
+ imports: [
17
+ RouterModule.forChild(routes),
18
+ CoreModule,
19
+ BasicViewComponent,
20
+ Step1Component,
21
+ Step2Component
22
+ ],
18
23
  /**
19
24
  * Adding the hooks to the providers:
20
25
  */
@@ -1,7 +1,20 @@
1
1
  import { CdkStep } from '@angular/cdk/stepper';
2
2
  import { Component, OnInit } from '@angular/core';
3
- import { FormBuilder, FormGroup, Validators } from '@angular/forms';
4
- import { C8yStepper } from '@c8y/ngx-components';
3
+ import {
4
+ FormBuilder,
5
+ FormGroup,
6
+ Validators,
7
+ FormsModule,
8
+ ReactiveFormsModule
9
+ } from '@angular/forms';
10
+ import {
11
+ C8yStepper,
12
+ FormGroupComponent,
13
+ RequiredInputPlaceholderDirective,
14
+ MessagesComponent,
15
+ MessageDirective,
16
+ C8yStepperButtons
17
+ } from '@c8y/ngx-components';
5
18
 
6
19
  @Component({
7
20
  selector: 'tut-step-1-device',
@@ -22,7 +35,17 @@ import { C8yStepper } from '@c8y/ngx-components';
22
35
  (onNext)="goToNextStep($event)"
23
36
  ></c8y-stepper-buttons>
24
37
  </div>
25
- `
38
+ `,
39
+ standalone: true,
40
+ imports: [
41
+ FormGroupComponent,
42
+ FormsModule,
43
+ ReactiveFormsModule,
44
+ RequiredInputPlaceholderDirective,
45
+ MessagesComponent,
46
+ MessageDirective,
47
+ C8yStepperButtons
48
+ ]
26
49
  })
27
50
  export class Step1Component implements OnInit {
28
51
  formGroupStepOne: FormGroup;
@@ -1,4 +1,5 @@
1
1
  import { Component } from '@angular/core';
2
+ import { C8yStepperButtons } from '@c8y/ngx-components';
2
3
 
3
4
  @Component({
4
5
  selector: 'tut-step-2-device',
@@ -10,7 +11,9 @@ import { Component } from '@angular/core';
10
11
  [showButtons]="{ next: false, cancel: false, back: true, custom: false }"
11
12
  [labels]="{ back: 'Got it!' }"
12
13
  ></c8y-stepper-buttons>
13
- `
14
+ `,
15
+ standalone: true,
16
+ imports: [C8yStepperButtons]
14
17
  })
15
18
  export class Step2Component {
16
19
  close() {
@@ -0,0 +1,16 @@
1
+ import { Component } from '@angular/core';
2
+ import { CoreModule } from '@c8y/ngx-components';
3
+
4
+ /**
5
+ * This is a standard angular component.
6
+ * Obviously it does not do anything.
7
+ */
8
+ @Component({
9
+ selector: 'tut-additional-config-component',
10
+ template: 'Any additional configuration can be done here.',
11
+ standalone: true,
12
+ imports: [CoreModule]
13
+ })
14
+ export class AdditionalConfigComponent {
15
+ editComponent = false;
16
+ }
@@ -0,0 +1,18 @@
1
+ <div class="card">
2
+ <div class="card-block">
3
+ <c8y-widget-config-section
4
+ *ngFor="let section of widgetConfigService.currentSections$ | async; let i = index"
5
+ [section]="section"
6
+ ></c8y-widget-config-section>
7
+ </div>
8
+
9
+ <div class="card-block">
10
+ <label>The configuration is:</label>
11
+ <code>
12
+ <pre>
13
+ {{ widgetConfigService.currentConfig$ | async | json }}
14
+ </pre
15
+ >
16
+ </code>
17
+ </div>
18
+ </div>
@@ -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
+ }