Skip to content

Commit

Permalink
chore(webapp):Update web-ssh-gui version to use Rust stack
Browse files Browse the repository at this point in the history
  • Loading branch information
irvingoujAtDevolution committed Oct 7, 2024
1 parent 01fb589 commit f2db1b5
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 38 deletions.
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 @@ -28,7 +28,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);
},
}),
).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

0 comments on commit f2db1b5

Please sign in to comment.