@@ -10,6 +10,7 @@ import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
1010import { TooltipModule } from 'ngx-bootstrap/tooltip' ;
1111
1212import { QueryErrorComponent } from '@keira/shared/base-editor-components' ;
13+ import { ElectronService } from '@keira/shared/common-services' ;
1314import { KeiraConnectionOptions , MysqlService } from '@keira/shared/db-layer' ;
1415import { LoginConfigService } from '@keira/shared/login-config' ;
1516import { SwitchLanguageComponent } from '@keira/shared/switch-language' ;
@@ -34,6 +35,7 @@ export class ConnectionWindowComponent extends SubscriptionHandler implements On
3435 private readonly mysqlService = inject ( MysqlService ) ;
3536 private readonly loginConfigService = inject ( LoginConfigService ) ;
3637 private readonly changeDetectorRef = inject ( ChangeDetectorRef ) ;
38+ private readonly electronService = inject ( ElectronService ) ;
3739
3840 private readonly IMAGES_COUNT = 11 ;
3941 readonly RANDOM_IMAGE = Math . floor ( Math . random ( ) * this . IMAGES_COUNT ) + 1 ;
@@ -56,14 +58,20 @@ export class ConnectionWindowComponent extends SubscriptionHandler implements On
5658 password : new FormControl < string > ( 'root' ) as FormControl < string > ,
5759 database : new FormControl < string > ( 'acore_world' ) as FormControl < string > ,
5860 sslEnabled : new FormControl < boolean > ( false ) as FormControl < boolean > ,
61+ sshEnabled : new FormControl < boolean > ( false ) as FormControl < boolean > ,
62+ sshHost : new FormControl < string > ( '' ) as FormControl < string > ,
63+ sshPort : new FormControl < number > ( 22 ) as FormControl < number > ,
64+ sshUser : new FormControl < string > ( '' ) as FormControl < string > ,
65+ sshPassword : new FormControl < string > ( '' ) as FormControl < string > ,
66+ sshPrivateKey : new FormControl < string > ( '' ) as FormControl < string > ,
5967 } ) ;
6068
6169 this . configs = this . loginConfigService . getConfigs ( ) ;
6270
6371 if ( this . configs ?. length > 0 ) {
6472 // get last saved config
6573 const lastConfig = this . configs [ this . configs . length - 1 ] ;
66- this . form . setValue ( lastConfig ) ;
74+ this . form . patchValue ( lastConfig ) ;
6775
6876 if ( ! this . form . getRawValue ( ) . password ) {
6977 this . savePassword = false ;
@@ -76,7 +84,7 @@ export class ConnectionWindowComponent extends SubscriptionHandler implements On
7684 }
7785
7886 loadConfig ( config : Partial < KeiraConnectionOptions > ) : void {
79- this . form . setValue ( config ) ;
87+ this . form . patchValue ( config ) ;
8088 }
8189
8290 removeAllConfigs ( ) : void {
@@ -85,6 +93,15 @@ export class ConnectionWindowComponent extends SubscriptionHandler implements On
8593 this . form . reset ( ) ;
8694 }
8795
96+ onPrivateKeyFileSelected ( event : Event ) : void {
97+ const input = event . target as HTMLInputElement ;
98+ const file = input . files ?. [ 0 ] ;
99+ if ( file ) {
100+ const keyContent = this . electronService . fs . readFileSync ( ( file as any ) . path , 'utf8' ) ;
101+ this . form . get ( 'sshPrivateKey' ) ?. setValue ( keyContent ) ;
102+ }
103+ }
104+
88105 onConnect ( ) : void {
89106 const connectionConfig = this . form . getRawValue ( ) ;
90107
0 commit comments