Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(webapp): update web-ssh-gui (new Rust stack) #1047

Merged
merged 1 commit into from
Oct 8, 2024
Merged
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
187 changes: 183 additions & 4 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@devolutions/icons": "4.0.8",
"@devolutions/iron-remote-gui": "^0.11.6",
"@devolutions/iron-remote-gui-vnc": "^0.2.2",
"@devolutions/web-ssh-gui": "^0.2.18",
"@devolutions/web-ssh-gui": "^0.3.1",
"@devolutions/web-telnet-gui": "^0.2.15",
"primeflex": "3.3.1",
"primeicons": "7.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
</div>

<div class="col-12 gateway-form-group" [hidden]="!formInputVisibility.showPrivateKeyInput">
<web-client-password-control [parentForm]="form"
[inputFormData]="inputFormData"
[label]="'Passphrase'"
[formKey]="'passphrase'"
<web-client-password-control [parentForm]="form"
[inputFormData]="inputFormData"
[label]="'Passphrase'"
[formKey]="'passphrase'"
[isRequired]="false"
[isEnabled]="formInputVisibility.showPrivateKeyInput">
</web-client-password-control>
</web-client-password-control>
</div>

<div [hidden]="!formInputVisibility.showPrivateKeyInput">
<app-file-control privateKeyFileForm [disabled] ="formInputVisibility.showPrivateKeyInput" ></app-file-control>
</div>


</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit, SimpleChanges } from '@angular/core';
import { AbstractControl, FormGroup } from '@angular/forms';
import { AbstractControl, FormGroup, Validators } from '@angular/forms';

import { BaseComponent } from '@shared/bases/base.component';
import { WebFormService } from '@shared/services/web-form.service';
Expand All @@ -15,6 +15,7 @@ export class PasswordControlComponent extends BaseComponent implements OnInit {
@Input() isEnabled = true;
@Input() label = 'Password';
@Input() formKey = 'password';
@Input() isRequired = true;

showPasswordToggle = false;

Expand All @@ -23,7 +24,8 @@ export class PasswordControlComponent extends BaseComponent implements OnInit {
}

ngOnInit(): void {
this.formService.addControlToForm(this.parentForm, this.formKey, this.inputFormData);
console.log('this is required', this.isRequired);
this.formService.addControlToForm(this.parentForm, this.formKey, this.inputFormData, this.isRequired);
this.toggleControl();
}

Expand All @@ -42,5 +44,18 @@ export class PasswordControlComponent extends BaseComponent implements OnInit {
if (control) {
this.isEnabled ? control.enable() : control.disable();
}
this.updateValidators();
}

private updateValidators(): void {
const control = this.parentForm.get(this.formKey);
if (control) {
if (this.isRequired) {
control.setValidators([Validators.required]);
} else {
control.clearValidators(); // Remove the 'required' validator
}
control.updateValueAndValidity(); // Ensure the form reflects new validation state
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class WebClientSshComponent extends WebClientBaseComponent implements OnI
return;
}

this.remoteTerminal.status.subscribe((v) => {
this.remoteTerminal.onStatusChange((v) => {
if (v === TerminalConnectionStatus.connected) {
// connected only indicates connection to Gateway is successful
this.remoteTerminal.writeToTerminal('connecting... \r\n');
Expand All @@ -180,15 +180,18 @@ export class WebClientSshComponent extends WebClientBaseComponent implements OnI

private callConnect(connectionParameters: SshConnectionParameters) {
return from(
this.remoteTerminal.connect(
connectionParameters.host,
connectionParameters.port,
connectionParameters.username,
connectionParameters.gatewayAddress + `?token=${connectionParameters.token}`,
connectionParameters.password,
connectionParameters.privateKey,
connectionParameters.privateKeyPassphrase,
),
this.remoteTerminal.connect({
hostname: connectionParameters.host,
port: connectionParameters.port,
username: connectionParameters.username,
proxyUrl: connectionParameters.gatewayAddress + `?token=${connectionParameters.token}`,
passpharse: connectionParameters.privateKeyPassphrase ?? '',
privateKey: connectionParameters.privateKey ?? '',
password: connectionParameters.password ?? '',
onHostKeyReceived: (serverName, fingerprint) => {
return Promise.resolve(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be completed in separate PR

},
}),
).pipe(catchError((error) => throwError(error)));
}

Expand Down Expand Up @@ -228,21 +231,18 @@ export class WebClientSshComponent extends WebClientBaseComponent implements OnI
return;
}

this.remoteTerminal.status.subscribe({
next: (status): void => {
switch (status) {
case TerminalConnectionStatus.connected:
this.handleSessionStarted();
break;
case TerminalConnectionStatus.failed:
case TerminalConnectionStatus.closed:
this.handleSessionEndedOrError(status);
break;
default:
break;
}
},
error: (err) => this.handleSubscriptionError(err),
this.remoteTerminal.onStatusChange((status) => {
switch (status) {
case TerminalConnectionStatus.connected:
this.handleSessionStarted();
break;
case TerminalConnectionStatus.failed:
case TerminalConnectionStatus.closed:
this.handleSessionEndedOrError(status);
break;
default:
break;
}
});
}

Expand Down
Loading