Eugene Pankov 7 лет назад
Родитель
Сommit
c285b89b6c

+ 5 - 1
terminus-ssh/src/components/editConnectionModal.component.pug

@@ -41,7 +41,11 @@
                         type='text', 
                         [(ngModel)]='connection.user', 
                     )
-
+                    
+                .alert.alert-info.d-flex.bg-transparent.text-white.align-items-center(*ngIf='hasSavedPassword')
+                    .mr-auto There is a saved password for this connection
+                    button.btn.btn-danger.ml-4((click)='clearSavedPassword()') Forget
+                    
                 .form-group
                     label Private key 
                     .input-group

+ 12 - 0
terminus-ssh/src/components/editConnectionModal.component.ts

@@ -1,6 +1,7 @@
 import { Component } from '@angular/core'
 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
 import { ElectronService, HostAppService } from 'terminus-core'
+import { PasswordStorageService } from '../services/passwordStorage.service'
 import { SSHConnection, LoginScript } from '../api'
 
 @Component({
@@ -9,15 +10,26 @@ import { SSHConnection, LoginScript } from '../api'
 export class EditConnectionModalComponent {
     connection: SSHConnection
     newScript: LoginScript
+    hasSavedPassword: boolean
 
     constructor (
         private modalInstance: NgbActiveModal,
         private electron: ElectronService,
         private hostApp: HostAppService,
+        private passwordStorage: PasswordStorageService,
     ) {
         this.newScript = { expect: '', send: '' }
     }
 
+    async ngOnInit () {
+        this.hasSavedPassword = !!(await this.passwordStorage.loadPassword(this.connection))
+    }
+
+    clearSavedPassword () {
+        this.hasSavedPassword = false
+        this.passwordStorage.deletePassword(this.connection)
+    }
+
     selectPrivateKey () {
         let path = this.electron.dialog.showOpenDialog(
             this.hostApp.getWindow(),