@c8y/tutorial 1021.55.2 → 1021.56.4
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/cumulocity.config.ts +7 -0
- package/package.json +7 -7
- package/src/generate-json-schema/generate-json-schema.component.ts +44 -0
- package/src/generate-json-schema/generate-json-schema.module.ts +20 -0
- package/src/generate-json-schema/schema-example.model.ts +16 -0
- package/src/lazy-widget/lazy-widget-config/lazy-widget-config.component.ts +5 -2
- package/src/lazy-widget/lazy-widget-view/lazy-widget-view.component.ts +5 -2
- package/src/lazy-widget/lazy-widget.module.ts +4 -1
- package/src/lazy-widget/widget-config.model.ts +3 -0
- package/src/widget/demo-widget-config.component.ts +3 -7
- package/src/widget/demo-widget.component.ts +2 -1
- package/src/widget/demo-widget.module.ts +1 -0
- package/src/widget/widget-config.model.ts +3 -0
- package/src/widget-resolvers/widget-config.model.ts +3 -0
- package/src/widget-resolvers/widget-resolvers.component.ts +2 -1
- package/src/widget-resolvers/widget-resolvers.module.ts +1 -0
package/cumulocity.config.ts
CHANGED
|
@@ -506,6 +506,13 @@ export default {
|
|
|
506
506
|
description: 'An example for For of directive.',
|
|
507
507
|
scope: 'self'
|
|
508
508
|
},
|
|
509
|
+
{
|
|
510
|
+
name: 'Generate JSON Schema example',
|
|
511
|
+
module: 'GenerateJsonSchemaModule',
|
|
512
|
+
path: './src/generate-json-schema/generate-json-schema.module.ts',
|
|
513
|
+
description: 'An example for generate JSON schema from interface.',
|
|
514
|
+
scope: 'self'
|
|
515
|
+
},
|
|
509
516
|
{
|
|
510
517
|
name: 'Example of ngx modal',
|
|
511
518
|
module: 'NgxModalExampleModule',
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c8y/tutorial",
|
|
3
|
-
"version": "1021.
|
|
3
|
+
"version": "1021.56.4",
|
|
4
4
|
"description": "This package is used to scaffold a tutorial for Cumulocity IoT Web SDK which explains a lot of concepts.",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@c8y/style": "1021.
|
|
7
|
-
"@c8y/ngx-components": "1021.
|
|
8
|
-
"@c8y/client": "1021.
|
|
9
|
-
"@c8y/bootstrap": "1021.
|
|
6
|
+
"@c8y/style": "1021.56.4",
|
|
7
|
+
"@c8y/ngx-components": "1021.56.4",
|
|
8
|
+
"@c8y/client": "1021.56.4",
|
|
9
|
+
"@c8y/bootstrap": "1021.56.4",
|
|
10
10
|
"@angular/cdk": "^18.2.14",
|
|
11
11
|
"ngx-bootstrap": "18.0.0",
|
|
12
12
|
"leaflet": "1.9.4",
|
|
13
13
|
"rxjs": "^7.8.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@c8y/options": "1021.
|
|
17
|
-
"@c8y/devkit": "1021.
|
|
16
|
+
"@c8y/options": "1021.56.4",
|
|
17
|
+
"@c8y/devkit": "1021.56.4"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@angular/common": ">=18 <19"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Component, OnInit } from '@angular/core';
|
|
2
|
+
import { CoreModule } from '@c8y/ngx-components';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'c8y-generate-json-schema',
|
|
6
|
+
template: `
|
|
7
|
+
<h3>Base interface</h3>
|
|
8
|
+
<pre>{{ baseInterface }}</pre>
|
|
9
|
+
<pre>{{ referencedInterfaces }}</pre>
|
|
10
|
+
<h3>JSON Schema generated from ExampleInterface</h3>
|
|
11
|
+
<pre>{{ schemaString }}</pre>
|
|
12
|
+
`,
|
|
13
|
+
standalone: true,
|
|
14
|
+
imports: [CoreModule]
|
|
15
|
+
})
|
|
16
|
+
export class GenerateJsonSchemaComponent implements OnInit {
|
|
17
|
+
schemaString: unknown;
|
|
18
|
+
baseInterface = `
|
|
19
|
+
export type ExampleInterface = {
|
|
20
|
+
name: string;
|
|
21
|
+
id: number;
|
|
22
|
+
location: Address;
|
|
23
|
+
children?: Children[] | null;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
referencedInterfaces = `
|
|
27
|
+
export type Address ={
|
|
28
|
+
street: string;
|
|
29
|
+
city: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type Children = {
|
|
33
|
+
name: string;
|
|
34
|
+
id: number;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
async ngOnInit() {
|
|
39
|
+
const { schema } = await import(
|
|
40
|
+
'c8y-schema-loader?interfaceName=ExampleInterface!./schema-example.model'
|
|
41
|
+
);
|
|
42
|
+
this.schemaString = JSON.stringify(schema, null, 2);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { hookNavigator, hookRoute, NavigatorNode } from '@c8y/ngx-components';
|
|
3
|
+
|
|
4
|
+
@NgModule({
|
|
5
|
+
providers: [
|
|
6
|
+
hookRoute({
|
|
7
|
+
path: 'generate-json-schema',
|
|
8
|
+
loadComponent: () =>
|
|
9
|
+
import('./generate-json-schema.component').then(m => m.GenerateJsonSchemaComponent)
|
|
10
|
+
}),
|
|
11
|
+
hookNavigator(
|
|
12
|
+
new NavigatorNode({
|
|
13
|
+
label: 'JSON schema',
|
|
14
|
+
path: 'generate-json-schema',
|
|
15
|
+
icon: 'code1'
|
|
16
|
+
})
|
|
17
|
+
)
|
|
18
|
+
]
|
|
19
|
+
})
|
|
20
|
+
export class GenerateJsonSchemaModule {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type ExampleInterface = {
|
|
2
|
+
name: string;
|
|
3
|
+
id: number;
|
|
4
|
+
location: Address;
|
|
5
|
+
children?: Children[] | null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type Address = {
|
|
9
|
+
street: string;
|
|
10
|
+
city: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type Children = {
|
|
14
|
+
name: string;
|
|
15
|
+
id: number;
|
|
16
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { WidgetConfig } from '../widget-config.model';
|
|
3
4
|
|
|
4
5
|
@Component({
|
|
5
6
|
selector: 'tutorial-lazy-widget-config',
|
|
@@ -7,4 +8,6 @@ import { CommonModule } from '@angular/common';
|
|
|
7
8
|
standalone: true,
|
|
8
9
|
imports: [CommonModule]
|
|
9
10
|
})
|
|
10
|
-
export class LazyWidgetConfigComponent {
|
|
11
|
+
export class LazyWidgetConfigComponent {
|
|
12
|
+
@Input() config: WidgetConfig;
|
|
13
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { WidgetConfig } from '../widget-config.model';
|
|
3
4
|
|
|
4
5
|
@Component({
|
|
5
6
|
selector: 'tutorial-lazy-widget-view',
|
|
@@ -7,4 +8,6 @@ import { CommonModule } from '@angular/common';
|
|
|
7
8
|
standalone: true,
|
|
8
9
|
imports: [CommonModule]
|
|
9
10
|
})
|
|
10
|
-
export class LazyWidgetViewComponent {
|
|
11
|
+
export class LazyWidgetViewComponent {
|
|
12
|
+
@Input() config: WidgetConfig;
|
|
13
|
+
}
|
|
@@ -20,7 +20,10 @@ async function loadConfigComponent() {
|
|
|
20
20
|
label: 'Lazy Loaded Widget',
|
|
21
21
|
description: 'Lazy Loaded Widget',
|
|
22
22
|
loadComponent: loadViewComponent,
|
|
23
|
-
loadConfigComponent: loadConfigComponent
|
|
23
|
+
loadConfigComponent: loadConfigComponent,
|
|
24
|
+
data: {
|
|
25
|
+
schema: () => import('c8y-schema-loader?interfaceName=WidgetConfig!./widget-config.model')
|
|
26
|
+
}
|
|
24
27
|
})
|
|
25
28
|
]
|
|
26
29
|
})
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { Component, Input } from '@angular/core';
|
|
2
2
|
import { ControlContainer, NgForm } from '@angular/forms';
|
|
3
|
-
import {
|
|
4
|
-
DynamicComponent,
|
|
5
|
-
OnBeforeSave,
|
|
6
|
-
AlertService,
|
|
7
|
-
GlobalTimeContextWidgetConfig
|
|
8
|
-
} from '@c8y/ngx-components';
|
|
3
|
+
import { DynamicComponent, OnBeforeSave, AlertService } from '@c8y/ngx-components';
|
|
9
4
|
import { omit } from 'lodash';
|
|
5
|
+
import { WidgetConfig } from './widget-config.model';
|
|
10
6
|
|
|
11
7
|
@Component({
|
|
12
8
|
selector: 'c8y-widget-config-demo',
|
|
@@ -45,7 +41,7 @@ export class WidgetConfigDemo implements DynamicComponent, OnBeforeSave {
|
|
|
45
41
|
*
|
|
46
42
|
* Note: The dashboard itself adds certain properties. As such, some properties are not allowed (e.g. device or settings)
|
|
47
43
|
*/
|
|
48
|
-
@Input() config:
|
|
44
|
+
@Input() config: WidgetConfig = {};
|
|
49
45
|
|
|
50
46
|
/**
|
|
51
47
|
* An internal component property used to hide/show settings.
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
DynamicComponentAlertAggregator,
|
|
6
6
|
gettext
|
|
7
7
|
} from '@c8y/ngx-components';
|
|
8
|
+
import { WidgetConfig } from './widget-config.model';
|
|
8
9
|
|
|
9
10
|
@Component({
|
|
10
11
|
selector: 'c8y-widget-demo',
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
]
|
|
34
35
|
})
|
|
35
36
|
export class WidgetDemo implements OnChanges {
|
|
36
|
-
@Input() config;
|
|
37
|
+
@Input() config: WidgetConfig;
|
|
37
38
|
alerts: DynamicComponentAlertAggregator;
|
|
38
39
|
|
|
39
40
|
ngOnInit() {
|
|
@@ -33,6 +33,7 @@ import { WidgetDemo } from './demo-widget.component';
|
|
|
33
33
|
|
|
34
34
|
/** new Angular-Dashboard definition */
|
|
35
35
|
data: {
|
|
36
|
+
schema: () => import('c8y-schema-loader?interfaceName=WidgetConfig!./widget-config.model'),
|
|
36
37
|
// The settings object can be used to configure the configComponent
|
|
37
38
|
settings: {
|
|
38
39
|
noNewWidgets: false, // Set this to true, to don't allow adding new widgets.
|
|
@@ -1,13 +1,14 @@
|
|
|
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 { WidgetConfig } from './widget-config.model';
|
|
4
5
|
|
|
5
6
|
@Component({
|
|
6
7
|
selector: 'app-widget-resolvers',
|
|
7
8
|
templateUrl: './widget-resolvers.component.html'
|
|
8
9
|
})
|
|
9
10
|
export class WidgetResolversComponent implements OnInit, DynamicComponent {
|
|
10
|
-
@Input() config:
|
|
11
|
+
@Input() config: WidgetConfig;
|
|
11
12
|
label: string;
|
|
12
13
|
value: string;
|
|
13
14
|
alerts: DynamicComponentAlertAggregator;
|
|
@@ -31,6 +31,7 @@ import { ContextWidgetConfig } from '@c8y/ngx-components/context-dashboard';
|
|
|
31
31
|
},
|
|
32
32
|
errorStrategy: DynamicComponentErrorStrategy.OVERLAY_ERROR,
|
|
33
33
|
data: {
|
|
34
|
+
schema: () => import('c8y-schema-loader?interfaceName=WidgetConfig!./widget-config.model'),
|
|
34
35
|
settings: {
|
|
35
36
|
noNewWidgets: false,
|
|
36
37
|
widgetDefaults: {
|