Skip to content

Commit 607a9c1

Browse files
Mikersdmike
authored andcommitted
feat: allow KVM fullscreen
1 parent 6b6db0e commit 607a9c1

File tree

5 files changed

+53
-19
lines changed

5 files changed

+53
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
# [9.0.0](https://github.com/open-amt-cloud-toolkit/ui-toolkit-angular/compare/v8.0.5...v9.0.0) (2025-01-07)
22

3-
43
### chore
54

6-
* update build tasks, package.json and changelog ([#1668](https://github.com/open-amt-cloud-toolkit/ui-toolkit-angular/issues/1668)) ([17294a2](https://github.com/open-amt-cloud-toolkit/ui-toolkit-angular/commit/17294a28b6e5eff874dfef7cc9c7edf67fc3195a))
7-
8-
9-
* chore!: address incorrectly released breaking change ([b3a5414](https://github.com/open-amt-cloud-toolkit/ui-toolkit-angular/commit/b3a541477b4c71795ff0754f501df3f59b61a4a1))
5+
- update build tasks, package.json and changelog ([#1668](https://github.com/open-amt-cloud-toolkit/ui-toolkit-angular/issues/1668)) ([17294a2](https://github.com/open-amt-cloud-toolkit/ui-toolkit-angular/commit/17294a28b6e5eff874dfef7cc9c7edf67fc3195a))
106

7+
- chore!: address incorrectly released breaking change ([b3a5414](https://github.com/open-amt-cloud-toolkit/ui-toolkit-angular/commit/b3a541477b4c71795ff0754f501df3f59b61a4a1))
118

129
### BREAKING CHANGES
1310

14-
* move to angular 19
15-
* - build(deps): bump angular 18 to 19
11+
- move to angular 19
12+
- - build(deps): bump angular 18 to 19
1613

1714
## [8.0.6](https://github.com/open-amt-cloud-toolkit/ui-toolkit-angular/compare/v8.0.5...v8.0.6) (2025-01-07)
1815

kvm/src/kvm.component.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
max-height: 80%;
33
max-width: 100%;
44
}
5+
6+
canvas.fullscreen {
7+
height: 100vh !important;
8+
}

kvm/src/kvm.component.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import {
1111
viewChild,
1212
input,
1313
output,
14-
EventEmitter
14+
EventEmitter,
15+
inject,
16+
Renderer2,
17+
computed,
18+
model,
19+
effect
1520
} from '@angular/core'
1621
import {
1722
AMTDesktop,
@@ -32,9 +37,11 @@ import { throttleTime } from 'rxjs/operators'
3237
styleUrls: ['./kvm.component.css']
3338
})
3439
export class KVMComponent implements OnInit, AfterViewInit, OnDestroy {
40+
renderer = inject(Renderer2)
3541
readonly canvas = viewChild<ElementRef>('canvas')
3642
readonly device = viewChild.required<string>('device')
3743
public context!: CanvasRenderingContext2D
44+
public isFullscreen = input(false)
3845

3946
//setting a width and height for the canvas
4047

@@ -45,8 +52,9 @@ export class KVMComponent implements OnInit, AfterViewInit, OnDestroy {
4552
public deviceId = input('')
4653

4754
readonly deviceStatus = output<number>()
48-
readonly deviceConnection = input<EventEmitter<boolean>>(new EventEmitter<boolean>())
49-
readonly selectedEncoding = input<EventEmitter<number>>(new EventEmitter<number>())
55+
readonly deviceConnection = input(new EventEmitter<boolean>())
56+
readonly selectedEncoding = input(new EventEmitter<number>())
57+
5058
module: AMTDesktop | null
5159
redirector: AMTKvmDataRedirector | null
5260
dataProcessor!: IDataProcessor | null
@@ -61,6 +69,11 @@ export class KVMComponent implements OnInit, AfterViewInit, OnDestroy {
6169
{ value: 2, viewValue: 'RLE 16' }
6270
]
6371

72+
constructor() {
73+
effect(() => {
74+
this.toggleFullscreen()
75+
})
76+
}
6477
ngOnInit(): void {
6578
this.deviceConnection().subscribe((data: boolean) => {
6679
if (data) {
@@ -79,6 +92,26 @@ export class KVMComponent implements OnInit, AfterViewInit, OnDestroy {
7992
this.init()
8093
}
8194

95+
toggleFullscreen(): void {
96+
const canvasElement = this.canvas()?.nativeElement
97+
if (!canvasElement) return
98+
99+
if (this.isFullscreen()) {
100+
if (canvasElement.requestFullscreen) {
101+
canvasElement.requestFullscreen()
102+
}
103+
this.renderer.addClass(canvasElement, 'fullscreen')
104+
} else {
105+
if (document.exitFullscreen && document.fullscreenElement != null) {
106+
document.exitFullscreen()
107+
}
108+
this.renderer.removeClass(canvasElement, 'fullscreen')
109+
}
110+
if (this.mouseHelper != null) {
111+
this.mouseHelper.resetOffsets()
112+
}
113+
}
114+
82115
instantiate(): void {
83116
const canvas = this.canvas()
84117
this.context = canvas?.nativeElement.getContext('2d')

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"e2e": "ng e2e"
1919
},
2020
"peerDependencies": {
21-
"@open-amt-cloud-toolkit/ui-toolkit": "~3.2.9",
21+
"@open-amt-cloud-toolkit/ui-toolkit": "^3.3.0",
2222
"@xterm/xterm": "^5.5.0"
2323
},
2424
"devDependencies": {
@@ -29,9 +29,9 @@
2929
"@angular/cdk": "^19.0.4",
3030
"@angular/cli": "^19.0.6",
3131
"@angular/common": "^19.0.5",
32-
"@angular/core": "^19.0.5",
3332
"@angular/compiler": "^19.0.5",
3433
"@angular/compiler-cli": "^19.0.5",
34+
"@angular/core": "^19.0.5",
3535
"@angular/platform-browser": "^19.0.5",
3636
"@angular/platform-browser-dynamic": "^19.0.5",
3737
"@types/jasmine": "~5.1.5",
@@ -47,14 +47,14 @@
4747
"karma-jasmine": "~5.1.0",
4848
"karma-jasmine-html-reporter": "^2.1.0",
4949
"karma-junit-reporter": "^2.0.1",
50+
"ng-packagr": "^19.0.1",
5051
"prettier-config-standard": "^7.0.0",
5152
"prettier-plugin-multiline-arrays": "^3.0.6",
5253
"rxjs": "~7.8.1",
5354
"ts-node": "~10.9.2",
5455
"tslib": "^2.8.1",
55-
"ng-packagr": "^19.0.1",
56-
"zone.js": "~0.15.0",
5756
"typescript": "^5.5.4",
58-
"typescript-eslint": "^8.15.0"
57+
"typescript-eslint": "^8.15.0",
58+
"zone.js": "~0.15.0"
5959
}
6060
}

0 commit comments

Comments
 (0)