@c8y/tutorial 1023.50.2 → 1023.53.0

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@c8y/tutorial",
3
- "version": "1023.50.2",
3
+ "version": "1023.53.0",
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": "1023.50.2",
7
- "@c8y/ngx-components": "1023.50.2",
8
- "@c8y/client": "1023.50.2",
9
- "@c8y/bootstrap": "1023.50.2",
6
+ "@c8y/style": "1023.53.0",
7
+ "@c8y/ngx-components": "1023.53.0",
8
+ "@c8y/client": "1023.53.0",
9
+ "@c8y/bootstrap": "1023.53.0",
10
10
  "@angular/cdk": "^20.2.14",
11
11
  "monaco-editor": "~0.53.0",
12
12
  "ngx-bootstrap": "20.0.2",
@@ -14,8 +14,8 @@
14
14
  "rxjs": "7.8.2"
15
15
  },
16
16
  "devDependencies": {
17
- "@c8y/options": "1023.50.2",
18
- "@c8y/devkit": "1023.50.2"
17
+ "@c8y/options": "1023.53.0",
18
+ "@c8y/devkit": "1023.53.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "@angular/common": ">=20 <21"
@@ -17,6 +17,27 @@ import { JsonPipe } from '@angular/common';
17
17
  @Component({
18
18
  selector: 'tut-properties-selector-drawer',
19
19
  template: `<c8y-title>Properties selector- drawer</c8y-title>
20
+ <h2>Example of using properties selector with asset selection</h2>
21
+ <div class="d-flex row">
22
+ <div class="col-xs-12 col-md-6">
23
+ <div class="card">
24
+ <div class="card-inner-scroll d-flex d-col bg-component" style="height: 490px"></div>
25
+ <div class="card-header">
26
+ <button class="btn btn-primary" (click)="selectAssetAndProperty()">
27
+ Select asset and property
28
+ </button>
29
+ </div>
30
+ </div>
31
+ </div>
32
+
33
+ <div class="col-xs-12 col-md-6">
34
+ <pre class="inner-scroll m-0" style="height: 554px">{{
35
+ selectorWithAssetSelectionOutput | json
36
+ }}</pre>
37
+ </div>
38
+ </div>
39
+
40
+ <h2>Example of using properties selector without asset selection</h2>
20
41
  <div class="d-flex row">
21
42
  <div class="col-xs-12 col-md-6">
22
43
  <div class="card">
@@ -41,7 +62,7 @@ import { JsonPipe } from '@angular/common';
41
62
  </div>
42
63
 
43
64
  <div class="col-xs-12 col-md-6">
44
- <pre class="inner-scroll m-0" style="height: 554px">{{ output | json }}</pre>
65
+ <pre class="inner-scroll m-0" style="height: 554px">{{ simpleSelectorOutput | json }}</pre>
45
66
  </div>
46
67
  </div>`,
47
68
  imports: [
@@ -57,9 +78,35 @@ export class PropertiesSelectorDrawerExampleComponent {
57
78
  inventoryService = inject(InventoryService);
58
79
  model: IIdentified;
59
80
  selectedAsset: IManagedObject;
60
- output: AssetPropertyType[] = [];
81
+ selectorWithAssetSelectionOutput: AssetPropertyType[] = [];
82
+ simpleSelectorOutput: AssetPropertyType[] = [];
61
83
  bottomDrawerService = inject(BottomDrawerService);
62
84
 
85
+ async selectAssetAndProperty() {
86
+ const drawer = this.bottomDrawerService.openDrawer(AssetPropertySelectorDrawerComponent, {
87
+ disableClickOutside: true,
88
+ initialState: {
89
+ allowChangingContext: true,
90
+ hideSelection: false,
91
+ config: {
92
+ selectMode: 'plus',
93
+ expansionMode: 'collapsedByDefault',
94
+ showValue: true,
95
+ showKey: true,
96
+ selectedProperties: this.selectorWithAssetSelectionOutput,
97
+ allowAddingCustomProperties: true
98
+ }
99
+ }
100
+ });
101
+
102
+ try {
103
+ const resultOf = await drawer.instance.result;
104
+ this.selectorWithAssetSelectionOutput = resultOf;
105
+ } catch (ex) {
106
+ // cancel clicked
107
+ }
108
+ }
109
+
63
110
  selectionChanged(e: AssetSelectionChangeEvent) {
64
111
  this.selectedAsset = e.change.item;
65
112
  }
@@ -68,23 +115,22 @@ export class PropertiesSelectorDrawerExampleComponent {
68
115
  const drawer = this.bottomDrawerService.openDrawer(AssetPropertySelectorDrawerComponent, {
69
116
  disableClickOutside: true,
70
117
  initialState: {
71
- asset: this.selectedAsset,
118
+ contextAsset: this.selectedAsset,
72
119
  config: {
73
120
  selectMode: 'single',
74
121
  expansionMode: 'collapsedByDefault',
75
122
  showValue: true,
76
123
  showKey: true,
77
- emptyStateContent: 'default-properties',
78
- selectedProperties: this.output
124
+ selectedProperties: this.simpleSelectorOutput
79
125
  }
80
126
  }
81
127
  });
82
128
 
83
129
  try {
84
130
  const resultOf = await drawer.instance.result;
85
- this.output = resultOf;
131
+ this.simpleSelectorOutput = resultOf;
86
132
  } catch (ex) {
87
- this.output = [];
133
+ // cancel clicked
88
134
  }
89
135
  }
90
136
  }
@@ -5,6 +5,7 @@ import { C8yTranslatePipe, TitleComponent } from '@c8y/ngx-components';
5
5
  import {
6
6
  AssetPropertyActionDirective,
7
7
  AssetPropertyListComponent,
8
+ AssetPropertySelectorComponent,
8
9
  AssetPropertyType
9
10
  } from '@c8y/ngx-components/asset-properties';
10
11
  import {
@@ -19,6 +20,7 @@ import { PopoverDirective } from 'ngx-bootstrap/popover';
19
20
  @Component({
20
21
  selector: 'tut-properties-selector-inline',
21
22
  template: `<c8y-title>Properties selector- inline</c8y-title>
23
+ <h2>Example of using properties selector with asset selection as separate component</h2>
22
24
  <div class="d-flex-md row">
23
25
  <div class="col-xs-12 col-md-3">
24
26
  <div class="card">
@@ -184,7 +186,27 @@ import { PopoverDirective } from 'ngx-bootstrap/popover';
184
186
  <div class="col-xs-12 col-md-4">
185
187
  <pre class="inner-scroll" style="height: 655px">{{ assetPropertiesOutput | json }}</pre>
186
188
  </div>
187
- </div>`,
189
+ </div>
190
+ <br />
191
+ <h2>Example of using properties selector with asset selection part of selector</h2>
192
+ <div class="d-flex-md row" style="height: 655px">
193
+ <c8y-asset-property-selector
194
+ [config]="{
195
+ selectMode: 'plus',
196
+ expansionMode: 'collapsedByDefault',
197
+ showValue: true,
198
+ showKey: true,
199
+ selectedProperties: this.selectorWithAssetSelectionOutput,
200
+ allowAddingCustomProperties: true
201
+ }"
202
+ [allowChangingContext]="true"
203
+ [allowPropertiesFromMultipleAssets]="true"
204
+ [hideSelection]="false"
205
+ [allowSearch]="true"
206
+ [ngModel]="selectedProperties"
207
+ (ngModelChange)="propertiesSelectionChange($event)"
208
+ ></c8y-asset-property-selector>
209
+ </div> `,
188
210
  standalone: true,
189
211
  imports: [
190
212
  AssetSelectorModule,
@@ -196,7 +218,8 @@ import { PopoverDirective } from 'ngx-bootstrap/popover';
196
218
  C8yTranslatePipe,
197
219
  TooltipModule,
198
220
  JsonPipe,
199
- PopoverDirective
221
+ PopoverDirective,
222
+ AssetPropertySelectorComponent
200
223
  ]
201
224
  })
202
225
  export class PropertiesSelectorInlineExampleComponent {
@@ -233,7 +256,7 @@ export class PropertiesSelectorInlineExampleComponent {
233
256
  model: IIdentified;
234
257
  selectedAsset: IManagedObject;
235
258
  assetPropertiesOutput: AssetPropertyType[] | AssetPropertyType;
236
-
259
+ selectorWithAssetSelectionOutput: AssetPropertyType[] = [];
237
260
  multiSelect: 'single' | 'multi' | 'none' = 'multi';
238
261
  expansionMode: 'expandedByDefault' | 'collapsedByDefault' | 'nonCollapsible' =
239
262
  'expandedByDefault';
@@ -254,6 +277,11 @@ export class PropertiesSelectorInlineExampleComponent {
254
277
  // console.log('Selected properties:', $event);
255
278
  }
256
279
 
280
+ propertiesSelectionChange($event: AssetPropertyType[]) {
281
+ this.selectorWithAssetSelectionOutput = $event;
282
+ // console.log('Selected properties from selector:', $event);
283
+ }
284
+
257
285
  copyProperty(context: AssetPropertyType) {
258
286
  this.assetPropertiesOutput = context;
259
287
  // console.log('Copy property:', context);