mirror of
https://github.com/eugeny/tabby
synced 2025-12-12 18:55:47 +00:00
added SSH connection manager (fixes #220)
This commit is contained in:
52
terminus-ssh/src/components/sshSettingsTab.component.ts
Normal file
52
terminus-ssh/src/components/sshSettingsTab.component.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ConfigService } from 'terminus-core'
|
||||
import { SSHConnection } from '../api'
|
||||
import { EditConnectionModalComponent } from './editConnectionModal.component'
|
||||
|
||||
@Component({
|
||||
template: require('./sshSettingsTab.component.pug'),
|
||||
})
|
||||
export class SSHSettingsTabComponent {
|
||||
connections: SSHConnection[]
|
||||
|
||||
constructor (
|
||||
public config: ConfigService,
|
||||
private ngbModal: NgbModal,
|
||||
) {
|
||||
this.connections = this.config.store.ssh.connections
|
||||
}
|
||||
|
||||
async ngOnInit () {
|
||||
}
|
||||
|
||||
createConnection () {
|
||||
let connection: SSHConnection = {
|
||||
name: '',
|
||||
host: '',
|
||||
user: 'root',
|
||||
}
|
||||
let modal = this.ngbModal.open(EditConnectionModalComponent)
|
||||
modal.componentInstance.connection = connection
|
||||
modal.result.then(result => {
|
||||
this.connections.push(result)
|
||||
this.config.store.ssh.connections = this.connections
|
||||
})
|
||||
}
|
||||
|
||||
editConnection (connection: SSHConnection) {
|
||||
let modal = this.ngbModal.open(EditConnectionModalComponent)
|
||||
modal.componentInstance.connection = Object.assign({}, connection)
|
||||
modal.result.then(result => {
|
||||
Object.assign(connection, result)
|
||||
this.config.save()
|
||||
})
|
||||
}
|
||||
|
||||
deleteConnection (connection: SSHConnection) {
|
||||
if (confirm(`Delete "${connection.name}"?`)) {
|
||||
this.connections = this.connections.filter(x => x !== connection)
|
||||
this.config.store.ssh.connections = this.connections
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user