@c8y/tutorial 1019.5.6 → 1019.6.3
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 +17 -1
- package/package.json +6 -6
- package/src/application-card/application-card-example.component.html +39 -0
- package/src/application-card/application-card-example.component.ts +57 -0
- package/src/application-card/application-card-example.module.ts +22 -0
- package/src/pagination/pagination-example.component.ts +61 -0
- package/src/pagination/pagination-example.module.ts +21 -0
- package/src/realtime/realtime-tutorial.component.ts +1 -1
package/cumulocity.config.ts
CHANGED
|
@@ -525,11 +525,23 @@ export default {
|
|
|
525
525
|
path: './src/stepper/stepper.module.ts',
|
|
526
526
|
description: 'A simple stepper example.'
|
|
527
527
|
},
|
|
528
|
+
{
|
|
529
|
+
name: 'ApplicationCard',
|
|
530
|
+
module: 'ApplicationCardExampleModule',
|
|
531
|
+
path: './src/application-card/application-card-example.module.ts',
|
|
532
|
+
description: 'Application card example.'
|
|
533
|
+
},
|
|
528
534
|
{
|
|
529
535
|
name: 'Hooking via service',
|
|
530
536
|
module: 'HookStateModule',
|
|
531
537
|
path: './src/hooks/state/hook-state.module.ts',
|
|
532
538
|
description: 'This is an example for an Action added via service or factory.'
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
name: 'Pagination',
|
|
542
|
+
module: 'PaginationExampleModule',
|
|
543
|
+
path: './src/pagination/pagination-example.module.ts',
|
|
544
|
+
description: 'This is an example for pagination.'
|
|
533
545
|
}
|
|
534
546
|
],
|
|
535
547
|
remotes: {
|
|
@@ -614,7 +626,9 @@ export default {
|
|
|
614
626
|
'AssetSelectorTreeDevicesModule',
|
|
615
627
|
'AssetSelectorTreeSearchModule',
|
|
616
628
|
'StepperModule',
|
|
617
|
-
'
|
|
629
|
+
'ApplicationCardExampleModule',
|
|
630
|
+
'HookStateModule',
|
|
631
|
+
'PaginationExampleModule'
|
|
618
632
|
]
|
|
619
633
|
}
|
|
620
634
|
},
|
|
@@ -626,6 +640,8 @@ export default {
|
|
|
626
640
|
})
|
|
627
641
|
]
|
|
628
642
|
},
|
|
643
|
+
// The embedded.css is used by codex for iframe embeddings.
|
|
644
|
+
copy: [{ from: './node_modules/@c8y/style/embedded.css', to: './embedded.css' }],
|
|
629
645
|
entryModule: './src/app/app.module#AppModule',
|
|
630
646
|
brandingEntry: './src/branding/branding.less',
|
|
631
647
|
federation: [
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c8y/tutorial",
|
|
3
|
-
"version": "1019.
|
|
3
|
+
"version": "1019.6.3",
|
|
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/devkit": "1019.
|
|
7
|
-
"@c8y/style": "1019.
|
|
8
|
-
"@c8y/ngx-components": "1019.
|
|
9
|
-
"@c8y/client": "1019.
|
|
10
|
-
"@c8y/bootstrap": "1019.
|
|
6
|
+
"@c8y/devkit": "1019.6.3",
|
|
7
|
+
"@c8y/style": "1019.6.3",
|
|
8
|
+
"@c8y/ngx-components": "1019.6.3",
|
|
9
|
+
"@c8y/client": "1019.6.3",
|
|
10
|
+
"@c8y/bootstrap": "1019.6.3",
|
|
11
11
|
"@angular/cdk": "^16.2.11",
|
|
12
12
|
"ngx-bootstrap": "11.0.2",
|
|
13
13
|
"leaflet": "1.7.1",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<c8y-action-bar-item
|
|
2
|
+
[placement]="'left'"
|
|
3
|
+
itemClass="navbar-form hidden-xs"
|
|
4
|
+
>
|
|
5
|
+
<c8y-list-display-switch
|
|
6
|
+
(onListClassChange)="listClass = $event"
|
|
7
|
+
[listLength]="(apps$ | async)?.length"
|
|
8
|
+
></c8y-list-display-switch>
|
|
9
|
+
</c8y-action-bar-item>
|
|
10
|
+
<div
|
|
11
|
+
class="card-group"
|
|
12
|
+
[ngClass]="listClass"
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
class="page-sticky-header hidden-xs d-flex"
|
|
16
|
+
*ngIf="(apps$ | async)?.length > 0"
|
|
17
|
+
>
|
|
18
|
+
<div class="card-block card-column-40">
|
|
19
|
+
<div class="card-appicon p-l-32 p-r-16 m-r-0 m-l-4"></div>
|
|
20
|
+
{{ 'Application' }}
|
|
21
|
+
</div>
|
|
22
|
+
<div class="card-block p-0 card-column-80 m-r-40">
|
|
23
|
+
<div class="card-block card-column-80">{{ 'Description' }}</div>
|
|
24
|
+
<div class="card-block card-column-20">{{ 'Type' }}</div>
|
|
25
|
+
<div class="card-block card-column-20"></div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<div
|
|
29
|
+
class="col-xs-12 col-sm-4 col-md-3"
|
|
30
|
+
*ngFor="let app of apps$ | async"
|
|
31
|
+
>
|
|
32
|
+
<c8y-application-card
|
|
33
|
+
class="d-contents"
|
|
34
|
+
(onAppDeleted)="appDeleted(app)"
|
|
35
|
+
(onAppCloned)="appCloned(app)"
|
|
36
|
+
[app]="app"
|
|
37
|
+
></c8y-application-card>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { Component } from '@angular/core';
|
|
3
|
+
import { FormsModule } from '@angular/forms';
|
|
4
|
+
import { AppStateService, CoreModule, PackageType } from '@c8y/ngx-components';
|
|
5
|
+
import { SharedEcosystemModule } from '@c8y/ngx-components/ecosystem/shared';
|
|
6
|
+
import { IApplication } from '@c8y/client';
|
|
7
|
+
import { Observable, of } from 'rxjs';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'tut-application-card',
|
|
11
|
+
templateUrl: './application-card-example.component.html',
|
|
12
|
+
standalone: true,
|
|
13
|
+
imports: [CommonModule, FormsModule, CoreModule, SharedEcosystemModule],
|
|
14
|
+
providers: [
|
|
15
|
+
{
|
|
16
|
+
provide: AppStateService,
|
|
17
|
+
useValue: { currentTenant: { value: { name: '' } } }
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
})
|
|
21
|
+
export class ApplicationCardExampleComponent {
|
|
22
|
+
listClass: string;
|
|
23
|
+
apps$: Observable<IApplication[]> = of([
|
|
24
|
+
{
|
|
25
|
+
name: 'cockpit',
|
|
26
|
+
contextPath: 'cockpit',
|
|
27
|
+
key: 'cockpit-application-key',
|
|
28
|
+
label: PackageType.OFFICIAL,
|
|
29
|
+
description: 'This package is used to scaffold a cockpit application for Cumulocity IoT.',
|
|
30
|
+
manifest: { version: '1.0.0', author: 'c8y_dev' }
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'administration',
|
|
34
|
+
contextPath: 'administration',
|
|
35
|
+
key: 'administration-application-key',
|
|
36
|
+
label: PackageType.OFFICIAL,
|
|
37
|
+
description: '',
|
|
38
|
+
manifest: { version: '1.0.0', author: 'c8y_dev' }
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'devicemanagement',
|
|
42
|
+
contextPath: 'devicemanagement',
|
|
43
|
+
key: 'devicemanagement-application-key',
|
|
44
|
+
label: PackageType.OFFICIAL,
|
|
45
|
+
description:
|
|
46
|
+
'This package is used to scaffold a Device management application for Cumulocity IoT.',
|
|
47
|
+
manifest: { version: '1.0.0', author: 'c8y_dev' }
|
|
48
|
+
}
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
appDeleted(app: IApplication[]) {
|
|
52
|
+
console.log('App deleted:', app);
|
|
53
|
+
}
|
|
54
|
+
appCloned(app: IApplication[]) {
|
|
55
|
+
console.log('App cloned:', app);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
|
|
4
|
+
|
|
5
|
+
@NgModule({
|
|
6
|
+
imports: [CommonModule],
|
|
7
|
+
providers: [
|
|
8
|
+
hookRoute({
|
|
9
|
+
path: 'application-card',
|
|
10
|
+
loadComponent: () =>
|
|
11
|
+
import('./application-card-example.component').then(m => m.ApplicationCardExampleComponent)
|
|
12
|
+
}),
|
|
13
|
+
hookNavigator(
|
|
14
|
+
new NavigatorNode({
|
|
15
|
+
path: 'application-card',
|
|
16
|
+
icon: 'inactive-state',
|
|
17
|
+
label: 'Application card'
|
|
18
|
+
})
|
|
19
|
+
)
|
|
20
|
+
]
|
|
21
|
+
})
|
|
22
|
+
export class ApplicationCardExampleModule {}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { CoreModule } from '@c8y/ngx-components';
|
|
3
|
+
import { PageChangedEvent, PaginationModule } from 'ngx-bootstrap/pagination';
|
|
4
|
+
|
|
5
|
+
interface Item {
|
|
6
|
+
id: number;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'tut-pagination-example',
|
|
12
|
+
template: `
|
|
13
|
+
<div class="container-fluid">
|
|
14
|
+
<c8y-title>Pagination</c8y-title>
|
|
15
|
+
<c8y-list-group>
|
|
16
|
+
<c8y-li *ngFor="let item of itemsToShow">
|
|
17
|
+
{{ item.name }}
|
|
18
|
+
</c8y-li>
|
|
19
|
+
<c8y-li class="sticky-bottom">
|
|
20
|
+
<pagination
|
|
21
|
+
[totalItems]="totalItems"
|
|
22
|
+
[(ngModel)]="currentPage"
|
|
23
|
+
[itemsPerPage]="itemsPerPage"
|
|
24
|
+
(pageChanged)="pageChanged($event)"
|
|
25
|
+
previousText="previous"
|
|
26
|
+
nextText="next"
|
|
27
|
+
></pagination>
|
|
28
|
+
</c8y-li>
|
|
29
|
+
</c8y-list-group>
|
|
30
|
+
</div>
|
|
31
|
+
`,
|
|
32
|
+
standalone: true,
|
|
33
|
+
imports: [CoreModule, PaginationModule]
|
|
34
|
+
})
|
|
35
|
+
export class PaginationExampleComponent {
|
|
36
|
+
currentPage = 1;
|
|
37
|
+
itemsPerPage = 10;
|
|
38
|
+
// Items to display on the current page
|
|
39
|
+
itemsToShow: Item[] = [];
|
|
40
|
+
totalItems = 50;
|
|
41
|
+
|
|
42
|
+
// Mock dataset
|
|
43
|
+
private allItems: Item[] = Array.from({ length: this.totalItems }, (_, i) => ({
|
|
44
|
+
id: i + 1,
|
|
45
|
+
name: `Item ${i + 1}`
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
this.updateItemsToShow();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
pageChanged(event: PageChangedEvent): void {
|
|
53
|
+
this.currentPage = event.page;
|
|
54
|
+
this.updateItemsToShow();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private updateItemsToShow(): void {
|
|
58
|
+
const startIndex = (this.currentPage - 1) * this.itemsPerPage;
|
|
59
|
+
this.itemsToShow = this.allItems.slice(startIndex, startIndex + this.itemsPerPage);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
|
|
3
|
+
|
|
4
|
+
@NgModule({
|
|
5
|
+
providers: [
|
|
6
|
+
hookRoute({
|
|
7
|
+
path: 'pagination',
|
|
8
|
+
loadComponent: () =>
|
|
9
|
+
import('./pagination-example.component').then(m => m.PaginationExampleComponent)
|
|
10
|
+
}),
|
|
11
|
+
hookNavigator(
|
|
12
|
+
new NavigatorNode({
|
|
13
|
+
path: '/pagination',
|
|
14
|
+
label: 'Pagination',
|
|
15
|
+
icon: 'realtime',
|
|
16
|
+
priority: 20
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
]
|
|
20
|
+
})
|
|
21
|
+
export class PaginationExampleModule {}
|
|
@@ -14,7 +14,7 @@ import { Observable, merge } from 'rxjs';
|
|
|
14
14
|
import { map, scan } from 'rxjs/operators';
|
|
15
15
|
|
|
16
16
|
@Component({
|
|
17
|
-
selector: '
|
|
17
|
+
selector: 'tut-realtime-button',
|
|
18
18
|
templateUrl: './realtime-tutorial.component.html',
|
|
19
19
|
providers: [
|
|
20
20
|
ManagedObjectRealtimeService,
|