@c8y/tutorial 1023.48.2 → 1023.48.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 +7 -0
- package/package.json +7 -7
- package/src/bottom-drawer-stacked/bottom-drawer-content-example.component.html +39 -0
- package/src/bottom-drawer-stacked/bottom-drawer-content-example.component.ts +78 -0
- package/src/bottom-drawer-stacked/bottom-drawer-content-top-example.component.html +33 -0
- package/src/bottom-drawer-stacked/bottom-drawer-content-top-example.component.ts +48 -0
- package/src/bottom-drawer-stacked/bottom-drawer-stacked-example.component.html +7 -0
- package/src/bottom-drawer-stacked/bottom-drawer-stacked-example.component.ts +35 -0
- package/src/bottom-drawer-stacked/bottom-drawer-stacked.providers.ts +19 -0
package/cumulocity.config.ts
CHANGED
|
@@ -899,6 +899,13 @@ export default {
|
|
|
899
899
|
description: 'This is an example for the bottom drawer service.',
|
|
900
900
|
scope: 'self'
|
|
901
901
|
},
|
|
902
|
+
{
|
|
903
|
+
name: 'Bottom drawer stacked',
|
|
904
|
+
module: 'bottomDrawerStackedExampleModuleProviders',
|
|
905
|
+
path: './src/bottom-drawer-stacked/bottom-drawer-stacked.providers.ts',
|
|
906
|
+
description: 'This is an example for multiple bottom drawers.',
|
|
907
|
+
scope: 'self'
|
|
908
|
+
},
|
|
902
909
|
{
|
|
903
910
|
name: 'Widget Config Hook',
|
|
904
911
|
module: 'widgetConfigHookProviders',
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c8y/tutorial",
|
|
3
|
-
"version": "1023.48.
|
|
3
|
+
"version": "1023.48.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/style": "1023.48.
|
|
7
|
-
"@c8y/ngx-components": "1023.48.
|
|
8
|
-
"@c8y/client": "1023.48.
|
|
9
|
-
"@c8y/bootstrap": "1023.48.
|
|
6
|
+
"@c8y/style": "1023.48.3",
|
|
7
|
+
"@c8y/ngx-components": "1023.48.3",
|
|
8
|
+
"@c8y/client": "1023.48.3",
|
|
9
|
+
"@c8y/bootstrap": "1023.48.3",
|
|
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.48.
|
|
18
|
-
"@c8y/devkit": "1023.48.
|
|
17
|
+
"@c8y/options": "1023.48.3",
|
|
18
|
+
"@c8y/devkit": "1023.48.3"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"@angular/common": ">=20 <21"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<div class="card-header separator">
|
|
2
|
+
<span
|
|
3
|
+
class="h4 card-title"
|
|
4
|
+
id="drawerTitle"
|
|
5
|
+
>
|
|
6
|
+
{{ title }}
|
|
7
|
+
</span>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="inner-scroll flex-grow">
|
|
10
|
+
<div class="card-block">
|
|
11
|
+
<p>Bottom drawer content</p>
|
|
12
|
+
<button
|
|
13
|
+
class="btn btn-primary"
|
|
14
|
+
(click)="openTopDrawer()"
|
|
15
|
+
>
|
|
16
|
+
Open bottom drawer via service
|
|
17
|
+
</button>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="card-footer text-center p-24 separator flex-no-shrink">
|
|
21
|
+
<button
|
|
22
|
+
class="btn btn-default"
|
|
23
|
+
[disabled]="isDisabled"
|
|
24
|
+
>
|
|
25
|
+
This button is disabled, as the inital state defines it.
|
|
26
|
+
</button>
|
|
27
|
+
<button
|
|
28
|
+
class="btn btn-default"
|
|
29
|
+
(click)="cancel()"
|
|
30
|
+
>
|
|
31
|
+
Cancel
|
|
32
|
+
</button>
|
|
33
|
+
<button
|
|
34
|
+
class="btn btn-primary"
|
|
35
|
+
(click)="save()"
|
|
36
|
+
>
|
|
37
|
+
Save
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Component, inject, OnInit, OnDestroy, HostListener } from '@angular/core';
|
|
2
|
+
import { BottomDrawerRef, BottomDrawerService } from '@c8y/ngx-components';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { takeUntil } from 'rxjs/operators';
|
|
5
|
+
import { BottomDrawerContentTopExampleComponent } from './bottom-drawer-content-top-example.component';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'tut-bottom-drawer-content-example',
|
|
9
|
+
templateUrl: './bottom-drawer-content-example.component.html',
|
|
10
|
+
standalone: true,
|
|
11
|
+
host: {
|
|
12
|
+
class: 'd-contents'
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
export class BottomDrawerContentExampleComponent implements OnInit, OnDestroy {
|
|
16
|
+
bottomDrawerRef = inject(BottomDrawerRef);
|
|
17
|
+
isDisabled = false;
|
|
18
|
+
title = 'First bottom drawer title';
|
|
19
|
+
destroy$: Subject<boolean> = new Subject<boolean>();
|
|
20
|
+
|
|
21
|
+
result: Promise<string> = new Promise((resolve, reject) => {
|
|
22
|
+
this._save = resolve;
|
|
23
|
+
this._cancel = reject;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
private _save: (value: string) => void;
|
|
27
|
+
private _cancel: (reason?: any) => void;
|
|
28
|
+
bottomDrawerService = inject(BottomDrawerService);
|
|
29
|
+
|
|
30
|
+
@HostListener('document:keydown.escape', ['$event'])
|
|
31
|
+
async onEscapePress(event: Event) {
|
|
32
|
+
if (this.bottomDrawerService.isTop(this.bottomDrawerRef)) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
await this.bottomDrawerRef.close();
|
|
35
|
+
console.log(
|
|
36
|
+
'Escape pressed- first bottom drawer closed, handled by BottomDrawerContentExampleComponent'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ngOnInit() {
|
|
42
|
+
this.bottomDrawerRef.onClosed$.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
|
43
|
+
this._cancel('Drawer closed');
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async openTopDrawer() {
|
|
48
|
+
const drawer = this.bottomDrawerService.openDrawer(BottomDrawerContentTopExampleComponent, {
|
|
49
|
+
initialState: {
|
|
50
|
+
// place here any content you want to pass to the component
|
|
51
|
+
isDisabled: true
|
|
52
|
+
},
|
|
53
|
+
disableClickOutside: true
|
|
54
|
+
// closeOnEscape is true by default
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const _resultOf = await drawer.instance.result;
|
|
59
|
+
} catch (ex) {
|
|
60
|
+
//
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ngOnDestroy() {
|
|
65
|
+
this.destroy$.next(true);
|
|
66
|
+
this.destroy$.complete();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
cancel() {
|
|
70
|
+
this._cancel('User canceled');
|
|
71
|
+
this.bottomDrawerRef.close();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
save() {
|
|
75
|
+
this._save('Value to pass back.');
|
|
76
|
+
this.bottomDrawerRef.close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<div class="card-header separator">
|
|
2
|
+
<span
|
|
3
|
+
class="h4 card-title"
|
|
4
|
+
id="drawerTitle"
|
|
5
|
+
>
|
|
6
|
+
{{ title }}
|
|
7
|
+
</span>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="inner-scroll flex-grow">
|
|
10
|
+
<div class="card-block">
|
|
11
|
+
<p>Bottom drawer content</p>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="card-footer text-center p-24 separator flex-no-shrink">
|
|
15
|
+
<button
|
|
16
|
+
class="btn btn-default"
|
|
17
|
+
[disabled]="isDisabled"
|
|
18
|
+
>
|
|
19
|
+
This button is disabled, as the inital state defines it.
|
|
20
|
+
</button>
|
|
21
|
+
<button
|
|
22
|
+
class="btn btn-default"
|
|
23
|
+
(click)="cancel()"
|
|
24
|
+
>
|
|
25
|
+
Cancel
|
|
26
|
+
</button>
|
|
27
|
+
<button
|
|
28
|
+
class="btn btn-primary"
|
|
29
|
+
(click)="save()"
|
|
30
|
+
>
|
|
31
|
+
Save
|
|
32
|
+
</button>
|
|
33
|
+
</div>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Component, inject, OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
import { BottomDrawerRef } from '@c8y/ngx-components';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { takeUntil } from 'rxjs/operators';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'tut-bottom-drawer-content-top-example',
|
|
8
|
+
templateUrl: './bottom-drawer-content-top-example.component.html',
|
|
9
|
+
standalone: true,
|
|
10
|
+
host: {
|
|
11
|
+
class: 'd-contents'
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
export class BottomDrawerContentTopExampleComponent implements OnInit, OnDestroy {
|
|
15
|
+
bottomDrawerRef = inject(BottomDrawerRef);
|
|
16
|
+
isDisabled = false;
|
|
17
|
+
title = 'Second bottom drawer title';
|
|
18
|
+
destroy$: Subject<boolean> = new Subject<boolean>();
|
|
19
|
+
|
|
20
|
+
result: Promise<string> = new Promise((resolve, reject) => {
|
|
21
|
+
this._save = resolve;
|
|
22
|
+
this._cancel = reject;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
private _save: (value: string) => void;
|
|
26
|
+
private _cancel: (reason?: any) => void;
|
|
27
|
+
|
|
28
|
+
ngOnInit() {
|
|
29
|
+
this.bottomDrawerRef.onClosed$.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
|
30
|
+
this._cancel('Top drawer closed');
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ngOnDestroy() {
|
|
35
|
+
this.destroy$.next(true);
|
|
36
|
+
this.destroy$.unsubscribe();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
cancel() {
|
|
40
|
+
this._cancel('User canceled');
|
|
41
|
+
this.bottomDrawerRef.close();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
save() {
|
|
45
|
+
this._save('Value to pass back.');
|
|
46
|
+
this.bottomDrawerRef.close();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Component, inject } from '@angular/core';
|
|
2
|
+
import { AlertService, BottomDrawerService, CoreModule } from '@c8y/ngx-components';
|
|
3
|
+
import { BottomDrawerContentExampleComponent } from './bottom-drawer-content-example.component';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'tut-bottom-drawer-stacked-example',
|
|
7
|
+
templateUrl: './bottom-drawer-stacked-example.component.html',
|
|
8
|
+
standalone: true,
|
|
9
|
+
imports: [CoreModule]
|
|
10
|
+
})
|
|
11
|
+
export class BottomDrawerStackedExampleComponent {
|
|
12
|
+
bottomDrawerService = inject(BottomDrawerService);
|
|
13
|
+
alertService = inject(AlertService);
|
|
14
|
+
isOpen = false;
|
|
15
|
+
|
|
16
|
+
async openDrawer() {
|
|
17
|
+
this.isOpen = true;
|
|
18
|
+
const drawer = this.bottomDrawerService.openDrawer(BottomDrawerContentExampleComponent, {
|
|
19
|
+
initialState: {
|
|
20
|
+
// place here any content you want to pass to the component
|
|
21
|
+
isDisabled: true
|
|
22
|
+
},
|
|
23
|
+
disableClickOutside: true,
|
|
24
|
+
closeOnEscape: false // BottomDrawerContentExampleComponent will handle Escape key on its own
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const resultOf = await drawer.instance.result;
|
|
29
|
+
this.alertService.success(resultOf);
|
|
30
|
+
} catch (ex) {
|
|
31
|
+
this.alertService.danger('Canceled as of: ' + ex);
|
|
32
|
+
}
|
|
33
|
+
this.isOpen = false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
|
|
2
|
+
|
|
3
|
+
export const bottomDrawerStackedExampleModuleProviders = [
|
|
4
|
+
hookRoute({
|
|
5
|
+
path: 'bottom-drawer-stacked',
|
|
6
|
+
loadComponent: () =>
|
|
7
|
+
import('./bottom-drawer-stacked-example.component').then(
|
|
8
|
+
m => m.BottomDrawerStackedExampleComponent
|
|
9
|
+
)
|
|
10
|
+
}),
|
|
11
|
+
hookNavigator(
|
|
12
|
+
new NavigatorNode({
|
|
13
|
+
label: 'Bottom drawer stacked',
|
|
14
|
+
path: '/bottom-drawer-stacked',
|
|
15
|
+
icon: 'th-list',
|
|
16
|
+
priority: 0
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
];
|