@c8y/tutorial 1023.52.0 → 1023.55.5

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.52.0",
3
+ "version": "1023.55.5",
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.52.0",
7
- "@c8y/ngx-components": "1023.52.0",
8
- "@c8y/client": "1023.52.0",
9
- "@c8y/bootstrap": "1023.52.0",
6
+ "@c8y/style": "1023.55.5",
7
+ "@c8y/ngx-components": "1023.55.5",
8
+ "@c8y/client": "1023.55.5",
9
+ "@c8y/bootstrap": "1023.55.5",
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.52.0",
18
- "@c8y/devkit": "1023.52.0"
17
+ "@c8y/options": "1023.55.5",
18
+ "@c8y/devkit": "1023.55.5"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "@angular/common": ">=20 <21"
@@ -14,6 +14,8 @@ export interface ICounterService {
14
14
  count: () => void;
15
15
  }
16
16
 
17
+ export {};
18
+
17
19
  declare global {
18
20
  /**
19
21
  * The `CumulocityServiceRegistry` namespaces is declared in `@c8y/ngx-components` as part of the global scope.
@@ -17,6 +17,11 @@ import { DeleteModalExampleComponent } from './delete-modal-example.component';
17
17
  Confirm modal using <code>c8y-confirm-modal</code> component
18
18
  </button>
19
19
  </div>
20
+ <div class="p-b-24 text-center">
21
+ <button class="btn btn-default" (click)="deleteTenantWithCodeVerification()">
22
+ Confirm modal with code verification
23
+ </button>
24
+ </div>
20
25
  </div>`,
21
26
  standalone: true,
22
27
  imports: [ModalModule, FormsModule, CoreModule]
@@ -69,4 +74,25 @@ export class ConfirmModalExampleComponent {
69
74
  console.log('Cancel clicked');
70
75
  }
71
76
  }
77
+
78
+ async deleteTenantWithCodeVerification() {
79
+ try {
80
+ await this.modalService.confirm(
81
+ 'Confirm delete?',
82
+ 'You are about to delete the tenant. This action will immediately affect all users.<br><br>For security reasons, enter the following code to continue:',
83
+ Status.DANGER,
84
+ {
85
+ ok: 'Delete'
86
+ },
87
+ {},
88
+ undefined,
89
+ true // requireCodeVerification
90
+ );
91
+ // eslint-disable-next-line no-console
92
+ console.log('Delete confirmed with code verification');
93
+ } catch (e) {
94
+ // eslint-disable-next-line no-console
95
+ console.log('Cancel clicked or code verification failed');
96
+ }
97
+ }
72
98
  }
@@ -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);