@c8y/tutorial 1023.63.1 → 1023.64.1

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.63.1",
3
+ "version": "1023.64.1",
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.63.1",
7
- "@c8y/ngx-components": "1023.63.1",
8
- "@c8y/client": "1023.63.1",
9
- "@c8y/bootstrap": "1023.63.1",
6
+ "@c8y/style": "1023.64.1",
7
+ "@c8y/ngx-components": "1023.64.1",
8
+ "@c8y/client": "1023.64.1",
9
+ "@c8y/bootstrap": "1023.64.1",
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.63.1",
18
- "@c8y/devkit": "1023.63.1"
17
+ "@c8y/options": "1023.64.1",
18
+ "@c8y/devkit": "1023.64.1"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "@angular/common": ">=20 <21"
@@ -1,12 +1,16 @@
1
1
  import { CommonModule } from '@angular/common';
2
2
  import { Component } from '@angular/core';
3
- import { CoreModule } from '@c8y/ngx-components';
3
+ import { FormsModule } from '@angular/forms';
4
+ import { AGGREGATION_VALUES, CoreModule } from '@c8y/ngx-components';
4
5
  import { DatapointSelectorModule, KPIDetails } from '@c8y/ngx-components/datapoint-selector';
5
6
  import {
6
7
  DatapointDetails,
7
8
  DatapointsExportSelectorComponent,
8
- ExportConfig
9
+ ExportColumnConfig,
10
+ ExportConfig,
11
+ ExportType
9
12
  } from '@c8y/ngx-components/datapoints-export-selector';
13
+ import { TooltipModule } from 'ngx-bootstrap/tooltip';
10
14
 
11
15
  @Component({
12
16
  selector: 'tut-datapoints-export-selector-example',
@@ -14,6 +18,30 @@ import {
14
18
  <c8y-title>Data points export selector</c8y-title>
15
19
  <div class="container-fluid">
16
20
  <div class="p-16 m-b-16 separator-bottom">
21
+ <div class="alert alert-info m-b-16">
22
+ <strong>Tutorial toggle:</strong> Switch between export types to see the differences. The
23
+ toggle is for demonstration purposes only.
24
+ </div>
25
+ <div class="d-flex gap-8 align-items-center m-b-16">
26
+ <label
27
+ class="c8y-switch"
28
+ [tooltip]="
29
+ isListExport
30
+ ? 'Latest measurement with datapoint details: current, target, diff, and diff% values'
31
+ : 'Timeline of measurements with Data Scope options (Compact/Full modes)'
32
+ "
33
+ placement="right"
34
+ [delay]="500"
35
+ >
36
+ <input
37
+ type="checkbox"
38
+ [(ngModel)]="isListExport"
39
+ (ngModelChange)="updateExportConfig()"
40
+ />
41
+ <span></span>
42
+ <span>{{ isListExport ? 'Latest with details' : 'Time series' }}</span>
43
+ </label>
44
+ </div>
17
45
  <c8y-datapoints-export-selector [exportConfig]="config"></c8y-datapoints-export-selector>
18
46
  </div>
19
47
  <div class="card">
@@ -30,39 +58,79 @@ import {
30
58
  </div>
31
59
  `,
32
60
  standalone: true,
33
- imports: [CommonModule, CoreModule, DatapointsExportSelectorComponent, DatapointSelectorModule]
61
+ imports: [
62
+ CommonModule,
63
+ CoreModule,
64
+ FormsModule,
65
+ TooltipModule,
66
+ DatapointsExportSelectorComponent,
67
+ DatapointSelectorModule
68
+ ]
34
69
  })
35
70
  export class DatapointsExportSelectorExampleComponent {
36
- config: ExportConfig;
37
- datapoint: DatapointDetails;
38
- datapointDetails: DatapointDetails[];
71
+ config: ExportConfig | null = null;
72
+ datapointDetails: DatapointDetails[] = [];
39
73
  datapoints: KPIDetails[] = [];
74
+ isListExport = false;
75
+
76
+ /**
77
+ * Default columns for latestWithDetails export type
78
+ */
79
+ private readonly listColumns: ExportColumnConfig[] = [
80
+ { id: 'kpi', label: 'Label', visible: true, order: 0 },
81
+ { id: 'target', label: 'Target', visible: true, order: 1 },
82
+ { id: 'current', label: 'Current', visible: true, order: 2 },
83
+ { id: 'diff', label: 'Diff', visible: true, order: 3 },
84
+ { id: 'diffPercentage', label: 'Diff %', visible: true, order: 4 },
85
+ { id: 'asset', label: 'Asset', visible: true, order: 5 }
86
+ ];
40
87
 
41
88
  updateExportConfig(): void {
42
89
  if (this.datapoints.length === 0) {
43
90
  return;
44
91
  }
45
92
 
46
- this.datapointDetails = this.datapoints.map(datapoint => ({
47
- deviceName: datapoint.__target.name,
48
- source: datapoint.__target.id,
49
- valueFragmentSeries: datapoint.series,
50
- valueFragmentType: datapoint.fragment
51
- }));
93
+ this.datapointDetails = this.datapoints.map((datapoint, index) => {
94
+ // Mock target value for demonstration purposes
95
+ const mockTarget = 100 + index * 10;
96
+
97
+ return {
98
+ deviceName: datapoint.__target.name,
99
+ source: datapoint.__target.id,
100
+ valueFragmentSeries: datapoint.series,
101
+ valueFragmentType: datapoint.fragment,
102
+ target: mockTarget,
103
+ label: datapoint.label ?? `${datapoint.fragment}.${datapoint.series}`
104
+ };
105
+ });
52
106
 
53
107
  const { dateFrom, dateTo } = this.getDateRange();
54
108
 
109
+ const exportType: ExportType = this.isListExport ? 'latestWithDetails' : 'timeSeries';
110
+
111
+ // Base config
55
112
  this.config = {
113
+ exportType,
56
114
  datapointDetails: this.datapointDetails,
57
115
  dateFrom,
58
116
  dateTo
59
117
  };
118
+
119
+ // Add type-specific configuration
120
+ if (this.isListExport) {
121
+ // Latest with details export: includes column configuration
122
+ this.config.columns = this.listColumns;
123
+ } else {
124
+ // Time series export: includes aggregation option
125
+ this.config.aggregation = AGGREGATION_VALUES.minutely;
126
+ }
60
127
  }
61
128
 
62
129
  private getDateRange(): { dateFrom: string; dateTo: string } {
63
- const baseDate = Date.now();
64
- const dateFrom = new Date(baseDate).toISOString();
65
- const dateTo = new Date(baseDate + 1).toISOString();
130
+ const now = Date.now();
131
+ const oneDayInMs = 24 * 60 * 60 * 1000;
132
+ const dateFrom = new Date(now - oneDayInMs).toISOString();
133
+ const dateTo = new Date(now).toISOString();
66
134
 
67
135
  return { dateFrom, dateTo };
68
136
  }