This commit is contained in:
Eugene Pankov
2020-03-01 16:10:45 +01:00
parent fda4d2dcef
commit 04a0a0cc64
81 changed files with 284 additions and 295 deletions

View File

@@ -60,11 +60,11 @@ export class ForwardedPort {
})
}
stopLocalListener () {
stopLocalListener (): void {
this.listener.close()
}
toString () {
toString (): string {
if (this.type === PortForwardType.Local) {
return `(local) ${this.host}:${this.port} → (remote) ${this.targetAddress}:${this.targetPort}`
} else {
@@ -88,7 +88,7 @@ export class SSHSession extends BaseSession {
this.scripts = connection.scripts || []
}
async start () {
async start (): Promise<void> {
this.open = true
try {
@@ -217,12 +217,12 @@ export class SSHSession extends BaseSession {
this.executeUnconditionalScripts()
}
emitServiceMessage (msg: string) {
emitServiceMessage (msg: string): void {
this.serviceMessage.next(msg)
this.logger.info(msg)
}
async addPortForward (fw: ForwardedPort) {
async addPortForward (fw: ForwardedPort): Promise<void> {
if (fw.type === PortForwardType.Local) {
await fw.startLocalListener((socket: Socket) => {
this.logger.info(`New connection on ${fw}`)
@@ -270,7 +270,7 @@ export class SSHSession extends BaseSession {
}
}
async removePortForward (fw: ForwardedPort) {
async removePortForward (fw: ForwardedPort): Promise<void> {
if (fw.type === PortForwardType.Local) {
fw.stopLocalListener()
this.forwardedPorts = this.forwardedPorts.filter(x => x !== fw)
@@ -282,19 +282,19 @@ export class SSHSession extends BaseSession {
this.emitServiceMessage(`Stopped forwarding ${fw}`)
}
resize (columns, rows) {
resize (columns: number, rows: number): void {
if (this.shell) {
this.shell.setWindow(rows, columns, rows, columns)
}
}
write (data) {
write (data: string): void {
if (this.shell) {
this.shell.write(data)
}
}
kill (signal?: string) {
kill (signal?: string): void {
if (this.shell) {
this.shell.signal(signal || 'TERM')
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Injectable } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { HotkeysService, ToolbarButtonProvider, ToolbarButton } from 'terminus-core'

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component } from '@angular/core'
import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { ElectronService, HostAppService } from 'terminus-core'

View File

@@ -16,20 +16,20 @@ export class PromptModalComponent {
private modalInstance: NgbActiveModal,
) { }
ngOnInit () {
ngOnInit (): void {
setTimeout(() => {
this.input.nativeElement.focus()
})
}
ok () {
ok (): void {
this.modalInstance.close({
value: this.value,
remember: this.remember,
})
}
cancel () {
cancel (): void {
this.modalInstance.close(null)
}
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component, NgZone } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { ToastrService } from 'ngx-toastr'

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component, Input } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { ForwardedPort, PortForwardType, SSHSession } from '../api'

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { ConfigService, ElectronService, HostAppService } from 'terminus-core'

View File

@@ -3,6 +3,7 @@ import { Spinner } from 'cli-spinner'
import { Component, Injector } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { first } from 'rxjs/operators'
import { RecoveryToken } from 'terminus-core'
import { BaseTerminalTabComponent } from 'terminus-terminal'
import { SSHService } from '../services/ssh.service'
import { SSHConnection, SSHSession } from '../api'
@@ -29,7 +30,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
super(injector)
}
ngOnInit () {
ngOnInit (): void {
this.logger = this.log.create('terminalTab')
this.homeEndSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => {
@@ -57,7 +58,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
})
}
async initializeSession () {
async initializeSession (): void {
if (!this.connection) {
this.logger.error('No SSH connection info supplied')
return
@@ -96,7 +97,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
this.session.resize(this.size.columns, this.size.rows)
}
async getRecoveryToken (): Promise<any> {
async getRecoveryToken (): Promise<RecoveryToken> {
return {
type: 'app:ssh-tab',
connection: this.connection,
@@ -104,16 +105,16 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
}
}
showPortForwarding () {
showPortForwarding (): void {
const modal = this.ngbModal.open(SSHPortForwardingModalComponent).componentInstance as SSHPortForwardingModalComponent
modal.session = this.session
}
reconnect () {
reconnect (): void {
this.initializeSession()
}
ngOnDestroy () {
ngOnDestroy (): void {
this.homeEndSubscription.unsubscribe()
super.ngOnDestroy()
}

View File

@@ -1,18 +1,18 @@
import { Injectable } from '@angular/core'
import { TabRecoveryProvider, RecoveredTab } from 'terminus-core'
import { TabRecoveryProvider, RecoveredTab, RecoveryToken } from 'terminus-core'
import { SSHTabComponent } from './components/sshTab.component'
/** @hidden */
@Injectable()
export class RecoveryProvider extends TabRecoveryProvider {
async recover (recoveryToken: any): Promise<RecoveredTab|null> {
if (recoveryToken && recoveryToken.type === 'app:ssh-tab') {
async recover (recoveryToken: RecoveryToken): Promise<RecoveredTab|null> {
if (recoveryToken?.type === 'app:ssh-tab') {
return {
type: SSHTabComponent,
options: {
connection: recoveryToken.connection,
savedState: recoveryToken.savedState,
connection: recoveryToken['connection'],
savedState: recoveryToken['savedState'],
},
}
}