Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,39 @@
</div>

<div class="col-12 gateway-form-group">
<web-client-enabled-encodings-control [parentForm]="form"
[inputFormData]="inputFormData"></web-client-enabled-encodings-control>
<web-client-enabled-encoding-control
[parentForm]="form"
[inputFormData]="inputFormData"
(controlReady)="subscribeToSelectedEncodingChanges()"></web-client-enabled-encoding-control>
</div>

<div class="col-12 gateway-form-group">
<web-client-color-format-control [parentForm]="form"
[inputFormData]="inputFormData"></web-client-color-format-control>
@if (showTightOptions) {
<div class="col-12 gateway-form-group">
<web-client-tight-png-enabled-control [parentForm]="form"
[inputFormData]="inputFormData"
(controlReady)="subscribeToPngEnabledChanges()"></web-client-tight-png-enabled-control>
</div>

<div class="col-12 gateway-form-group">
<web-client-jpeg-quality-level-control [parentForm]="form"
[inputFormData]="inputFormData"></web-client-jpeg-quality-level-control>
</div>
[inputFormData]="inputFormData"
(controlReady)="subscribeToJpegEnabledChanges()"></web-client-jpeg-quality-level-control>
</div>
}

@if (showPixelFormatSelector) {
<div class="col-12 gateway-form-group">
<web-client-color-format-control [parentForm]="form"
[inputFormData]="inputFormData"
[disabled]="pixelFormatSelectorDisabled"
disabledTooltip="Tight JPEG and Tight PNG do not support custom pixel formats."
></web-client-color-format-control>
</div>
}

<div class="col-12 gateway-form-group">
<web-client-enable-cursor-control [parentForm]="form"
[inputFormData]="inputFormData"></web-client-enable-cursor-control>
[inputFormData]="inputFormData"></web-client-enable-cursor-control>
</div>

<div *ngIf="showExtendedClipboardCheckbox" class="col-12 gateway-form-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';

import { BaseComponent } from '@shared/bases/base.component';
import { Encoding } from '@shared/enums/encoding.enum';
import { VncAuthMode } from '@shared/enums/web-client-auth-mode.enum';
import { WebFormService } from '@shared/services/web-form.service';
import { SelectItem } from 'primeng/api';
Expand All @@ -14,6 +15,11 @@ interface FormInputVisibility {
showPasswordInput?: boolean;
}

interface TightOptions {
jpeg: boolean;
png: boolean;
}

@Component({
selector: 'vnc-form',
templateUrl: 'vnc-form.component.html',
Expand All @@ -31,9 +37,16 @@ export class VncFormComponent extends BaseComponent implements OnInit {
};

showMoreSettings = false;
showPixelFormatSelector = false;
showTightOptions = false;
showExtendedClipboardCheckbox = false;
showAutoClipboardCheckbox = false;

pixelFormatSelectorDisabled = false;

selectedEncoding = Encoding.Default;
tightOptions: TightOptions = { jpeg: true, png: true };

constructor(
private formService: WebFormService,
private cdr: ChangeDetectorRef,
Expand Down Expand Up @@ -97,6 +110,75 @@ export class VncFormComponent extends BaseComponent implements OnInit {
this.showAutoClipboardCheckbox = new UAParser().getEngine().name === 'Blink' && window.isSecureContext;
}

subscribeToSelectedEncodingChanges(): void {
this.form
.get('enabledEncoding')
.valueChanges.pipe(
takeUntil(this.destroyed$),
startWith(this.form.get('enabledEncoding').value as Encoding),
switchMap((encoding: Encoding) => {
this.showPixelFormatSelector = encoding !== Encoding.Default;
this.showTightOptions = encoding === Encoding.Tight;
this.selectedEncoding = encoding;

return of(undefined);
}),
)
.subscribe({
error: (error) => console.error('Failed to subscribe to selected encoding changes', error),
});
}

subscribeToJpegEnabledChanges(): void {
this.form
.get('jpegEnabled')
.valueChanges.pipe(
takeUntil(this.destroyed$),
startWith(this.form.get('jpegEnabled').value as boolean),
switchMap((jpegEnabled: boolean) => {
this.tightOptions.jpeg = jpegEnabled;
this.updatePixelFormatOptionState();
this.cdr.detectChanges();

return of(undefined);
}),
)
.subscribe({
error: (error) => console.error('Failed to subscribe to jpeg enabled changes', error),
});
}

subscribeToPngEnabledChanges(): void {
this.form
.get('pngEnabled')
.valueChanges.pipe(
takeUntil(this.destroyed$),
startWith(this.form.get('pngEnabled').value as boolean),
switchMap((pngEnabled: boolean) => {
this.tightOptions.png = pngEnabled;
this.updatePixelFormatOptionState();
this.cdr.detectChanges();

return of(undefined);
}),
)
.subscribe({
error: (error) => console.error('Failed to subscribe to jpeg enabled changes', error),
});
}

private updatePixelFormatOptionState(): void {
const { jpeg, png } = this.tightOptions;

// Disable PixelFormat option for Tight JPEG and Tight PNG.
if (this.selectedEncoding === Encoding.Tight && (jpeg || png)) {
this.pixelFormatSelectorDisabled = true;
return;
}

this.pixelFormatSelectorDisabled = false;
}

private subscribeToAuthModeChanges(): void {
this.form
.get('authMode')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { BaseComponent } from '@shared/bases/base.component';
import { ColorFormat } from '@shared/enums/color-format.enum';
Expand All @@ -10,9 +10,11 @@ import { WebFormService } from '@shared/services/web-form.service';
templateUrl: 'color-format-control.component.html',
styleUrls: ['color-format-control.component.scss'],
})
export class ColorFormatControlComponent extends BaseComponent implements OnInit {
export class ColorFormatControlComponent extends BaseComponent implements OnInit, OnDestroy, OnChanges {
@Input() parentForm: FormGroup;
@Input() inputFormData;
@Input() disabled: boolean;
@Input() disabledTooltip: string;

colorFormatOptions: SelectItemWithTooltip[];

Expand All @@ -22,16 +24,51 @@ export class ColorFormatControlComponent extends BaseComponent implements OnInit

ngOnInit(): void {
this.colorFormatOptions = this.formService.getColorFormatOptions();
this.formService.addControlToForm({
formGroup: this.parentForm,
controlName: 'colorFormat',
inputFormData: this.inputFormData,
isRequired: false,
defaultValue: ColorFormat.Default,
});

if (!this.parentForm.contains('colorFormat')) {
this.formService.addControlToForm({
formGroup: this.parentForm,
controlName: 'colorFormat',
inputFormData: this.inputFormData,
isRequired: false,
defaultValue: ColorFormat.Default,
});
} else {
this.parentForm.get('colorFormat').enable();
}

if (this.disabled) {
this.parentForm.get('colorFormat').disable();
}
}

ngOnChanges(changes: SimpleChanges): void {
const disabled = changes.disabled;
if (disabled) {
// First `ngOnChanges` runs before `ngOnInit`.
if (disabled.firstChange) {
return;
}

if (disabled.currentValue) {
this.parentForm.get('colorFormat').disable();
} else {
this.parentForm.get('colorFormat').enable();
}
}
}

ngOnDestroy() {
super.ngOnDestroy();
// Disable the control to ignore it when reading the form. At the same time, the value is preserved.
this.parentForm.get('colorFormat').disable();
}

getSelectedTooltip(): string {
if (this.disabled) {
return this.disabledTooltip;
}

const selectedOptionValue = this.parentForm.get('colorFormat')?.value;
return this.colorFormatOptions.find((item) => item.value === selectedOptionValue)?.tooltipText || '';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div [formGroup]="parentForm">
<label for="enabledEncoding">Enabled Encoding</label>
<div class="gateway-form-input">
<p-dropdown id="enabledEncoding"
styleClass="full-with-dropdown"
appendTo="body"
formControlName="enabledEncoding"
[options]="supportedEncodings"/>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Encoding } from '@gateway/shared/enums/encoding.enum';
import { BaseComponent } from '@shared/bases/base.component';
import { WebFormService } from '@shared/services/web-form.service';
import { SelectItem } from 'primeng/api';

@Component({
selector: 'web-client-enabled-encodings-control',
templateUrl: 'enabled-encodings-control.component.html',
styleUrls: ['enabled-encodings-control.component.scss'],
selector: 'web-client-enabled-encoding-control',
templateUrl: 'enabled-encoding-control.component.html',
styleUrls: ['enabled-encoding-control.component.scss'],
})
export class EnabledEncodingsControlComponent extends BaseComponent implements OnInit {
export class EnabledEncodingControlComponent extends BaseComponent implements OnInit {
@Input() parentForm: FormGroup;
@Input() inputFormData;

@Output() controlReady = new EventEmitter<void>();

supportedEncodings: SelectItem[];

constructor(private formService: WebFormService) {
Expand All @@ -24,10 +26,12 @@ export class EnabledEncodingsControlComponent extends BaseComponent implements O
this.supportedEncodings = this.formService.getSupportedEncodings();
this.formService.addControlToForm({
formGroup: this.parentForm,
controlName: 'enabledEncodings',
controlName: 'enabledEncoding',
inputFormData: this.inputFormData,
isRequired: false,
defaultValue: Encoding.getAllEncodings(),
defaultValue: Encoding.Default,
});

this.controlReady.emit();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { FormGroup } from '@angular/forms';

import { BaseComponent } from '@shared/bases/base.component';
Expand All @@ -9,10 +9,12 @@ import { WebFormService } from '@shared/services/web-form.service';
templateUrl: 'jpeg-quality-level-control.component.html',
styleUrls: ['jpeg-quality-level-control.component.scss'],
})
export class JpegQualityLevelControlComponent extends BaseComponent implements OnInit {
export class JpegQualityLevelControlComponent extends BaseComponent implements OnInit, OnDestroy {
@Input() parentForm: FormGroup;
@Input() inputFormData;

@Output() controlReady = new EventEmitter<void>();

jpegEnabled = true;

constructor(private formService: WebFormService) {
Expand All @@ -24,20 +26,34 @@ export class JpegQualityLevelControlComponent extends BaseComponent implements O
}

ngOnInit(): void {
this.formService.addControlToForm({
formGroup: this.parentForm,
controlName: 'jpegEnabled',
inputFormData: this.inputFormData,
isRequired: false,
defaultValue: true,
});

this.formService.addControlToForm({
formGroup: this.parentForm,
controlName: 'jpegQualityLevel',
inputFormData: this.inputFormData,
isRequired: false,
defaultValue: 9,
});
if (!this.parentForm.contains('jpegEnabled')) {
this.formService.addControlToForm({
formGroup: this.parentForm,
controlName: 'jpegEnabled',
inputFormData: this.inputFormData,
isRequired: false,
defaultValue: true,
});

this.formService.addControlToForm({
formGroup: this.parentForm,
controlName: 'jpegQualityLevel',
inputFormData: this.inputFormData,
isRequired: false,
defaultValue: 9,
});

this.controlReady.emit();
} else {
this.parentForm.get('jpegEnabled').enable();
}

this.jpegEnabled = this.parentForm.get('jpegEnabled').value;
}

ngOnDestroy() {
super.ngOnDestroy();
// Disable the control to ignore it when reading the form. At the same time, the value is preserved.
this.parentForm.get('jpegEnabled').disable();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div [formGroup]="parentForm">
<div class="gateway-form-input">
<p-checkbox formControlName="pngEnabled"
label="Use Tight PNG"
binary="true"></p-checkbox>
</div>
</div>
Loading
Loading