mirror of
https://github.com/Eugeny/tabby
synced 2024-11-15 09:27:24 +00:00
added an option to add password from the connection properties (fixes #637)
This commit is contained in:
parent
77058c0472
commit
db3b8cc718
6 changed files with 59 additions and 29 deletions
|
@ -1,8 +1,7 @@
|
|||
.modal-body
|
||||
ngb-tabset(type='pills', [activeId]='basic')
|
||||
ngb-tab(id='basic')
|
||||
ng-template(ngbTabTitle)
|
||||
| Basic Setting
|
||||
ng-template(ngbTabTitle) General
|
||||
ng-template(ngbTabContent)
|
||||
.form-group
|
||||
label Name
|
||||
|
@ -42,12 +41,22 @@
|
|||
[(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-line
|
||||
.header
|
||||
.title Password
|
||||
.description(*ngIf='!hasSavedPassword') Save a password in the keychain
|
||||
.description(*ngIf='hasSavedPassword') There is a saved password for this connection
|
||||
button.btn.btn-outline-success.ml-4(*ngIf='!hasSavedPassword', (click)='setPassword()')
|
||||
i.fas.fa-key
|
||||
span Set password
|
||||
button.btn.btn-danger.ml-4(*ngIf='hasSavedPassword', (click)='clearSavedPassword()')
|
||||
i.fas.fa-trash-alt
|
||||
span Forget
|
||||
|
||||
.form-group
|
||||
label Private key
|
||||
.form-line
|
||||
.header
|
||||
.title Private key
|
||||
.description Path to the private key file
|
||||
.input-group
|
||||
input.form-control(
|
||||
type='text',
|
||||
|
@ -59,8 +68,7 @@
|
|||
i.fas.fa-folder-open
|
||||
|
||||
ngb-tab(id='advanced')
|
||||
ng-template(ngbTabTitle)
|
||||
| Advanced Setting
|
||||
ng-template(ngbTabTitle) Advanced
|
||||
ng-template(ngbTabContent)
|
||||
.form-group
|
||||
label Keep Alive Interval (Milliseconds)
|
||||
|
@ -108,8 +116,7 @@
|
|||
|
||||
|
||||
ngb-tab(id='scripts')
|
||||
ng-template(ngbTabTitle)
|
||||
| Login Scripts
|
||||
ng-template(ngbTabTitle) Login scripts
|
||||
ng-template(ngbTabContent)
|
||||
table
|
||||
tr
|
||||
|
@ -130,11 +137,11 @@
|
|||
[(ngModel)]='script.send'
|
||||
)
|
||||
td
|
||||
toggle(
|
||||
checkbox(
|
||||
[(ngModel)]='script.isRegex',
|
||||
)
|
||||
td
|
||||
toggle(
|
||||
checkbox(
|
||||
[(ngModel)]='script.optional',
|
||||
)
|
||||
td
|
||||
|
@ -159,19 +166,17 @@
|
|||
[(ngModel)]='newScript.send'
|
||||
)
|
||||
td
|
||||
toggle(
|
||||
checkbox(
|
||||
[(ngModel)]='newScript.isRegex',
|
||||
)
|
||||
td
|
||||
toggle(
|
||||
checkbox(
|
||||
[(ngModel)]='newScript.optional',
|
||||
)
|
||||
td
|
||||
.input-group.flex-nowrap
|
||||
button.btn.btn-outline-info.ml-0((click)='addScript()')
|
||||
i.fas.fa-check
|
||||
button.btn.btn-outline-danger.ml-0((click)='clearScript()')
|
||||
i.fas.fa-trash
|
||||
|
||||
.modal-footer
|
||||
button.btn.btn-outline-primary((click)='save()') Save
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Component } from '@angular/core'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ElectronService, HostAppService } from 'terminus-core'
|
||||
import { PasswordStorageService } from '../services/passwordStorage.service'
|
||||
import { SSHConnection, LoginScript, SSHAlgorithmType } from '../api'
|
||||
import { PromptModalComponent } from './promptModal.component'
|
||||
import { ALGORITHMS } from 'ssh2-streams/lib/constants'
|
||||
|
||||
/** @hidden */
|
||||
|
@ -23,6 +24,7 @@ export class EditConnectionModalComponent {
|
|||
private electron: ElectronService,
|
||||
private hostApp: HostAppService,
|
||||
private passwordStorage: PasswordStorageService,
|
||||
private ngbModal: NgbModal,
|
||||
) {
|
||||
this.newScript = { expect: '', send: '' }
|
||||
|
||||
|
@ -59,6 +61,19 @@ export class EditConnectionModalComponent {
|
|||
}
|
||||
}
|
||||
|
||||
async setPassword () {
|
||||
const modal = this.ngbModal.open(PromptModalComponent)
|
||||
modal.componentInstance.prompt = `Password for ${this.connection.user}@${this.connection.host}`
|
||||
modal.componentInstance.password = true
|
||||
try {
|
||||
const result = await modal.result
|
||||
if (result && result.value) {
|
||||
this.passwordStorage.savePassword(this.connection, result.value)
|
||||
this.hasSavedPassword = true
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
clearSavedPassword () {
|
||||
this.hasSavedPassword = false
|
||||
this.passwordStorage.deletePassword(this.connection)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
.d-flex.align-items-start.mt-2
|
||||
checkbox(
|
||||
*ngIf='showRememberCheckbox',
|
||||
[(model)]='remember',
|
||||
[(ngModel)]='remember',
|
||||
text='Remember'
|
||||
)
|
||||
button.btn.btn-primary.ml-auto(
|
||||
|
|
|
@ -23,10 +23,13 @@ export class PromptModalComponent {
|
|||
}
|
||||
|
||||
ok () {
|
||||
this.modalInstance.close(this.value)
|
||||
this.modalInstance.close({
|
||||
value: this.value,
|
||||
remember: this.remember,
|
||||
})
|
||||
}
|
||||
|
||||
cancel () {
|
||||
this.modalInstance.close('')
|
||||
this.modalInstance.close(null)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ export class SSHSettingsTabComponent {
|
|||
}
|
||||
|
||||
editConnection (connection: SSHConnection) {
|
||||
const modal = this.ngbModal.open(EditConnectionModalComponent)
|
||||
const modal = this.ngbModal.open(EditConnectionModalComponent, { size: 'lg' })
|
||||
modal.componentInstance.connection = Object.assign({}, connection)
|
||||
modal.result.then(result => {
|
||||
Object.assign(connection, result)
|
||||
|
@ -77,7 +77,7 @@ export class SSHSettingsTabComponent {
|
|||
modal.result.then(result => {
|
||||
if (result) {
|
||||
for (const connection of this.connections.filter(x => x.group === group.name)) {
|
||||
connection.group = result
|
||||
connection.group = result.value
|
||||
}
|
||||
this.config.store.ssh.connections = this.connections
|
||||
this.config.save()
|
||||
|
|
|
@ -82,7 +82,10 @@ export class SSHService {
|
|||
modal.componentInstance.prompt = 'Private key passphrase'
|
||||
modal.componentInstance.password = true
|
||||
try {
|
||||
privateKeyPassphrase = await modal.result
|
||||
const result = await modal.result
|
||||
if (result) {
|
||||
privateKeyPassphrase = result.value
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +122,8 @@ export class SSHService {
|
|||
const modal = this.ngbModal.open(PromptModalComponent)
|
||||
modal.componentInstance.prompt = prompt.prompt
|
||||
modal.componentInstance.password = !prompt.echo
|
||||
results.push(await modal.result)
|
||||
const result = await modal.result
|
||||
results.push(result ? result.value : '')
|
||||
}
|
||||
finish(results)
|
||||
}))
|
||||
|
@ -194,11 +198,14 @@ export class SSHService {
|
|||
modal.componentInstance.password = true
|
||||
modal.componentInstance.showRememberCheckbox = true
|
||||
try {
|
||||
let password = await modal.result
|
||||
if (modal.componentInstance.remember) {
|
||||
savedPassword = password
|
||||
const result = await modal.result
|
||||
if (result) {
|
||||
if (result.remember) {
|
||||
savedPassword = result.value
|
||||
}
|
||||
return result.value
|
||||
}
|
||||
return password
|
||||
return ''
|
||||
} catch (_) {
|
||||
return ''
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue