mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-04 14:04:56 +00:00
ssh - show connection log while connecting
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Observable, Subject, Subscription } from 'rxjs'
|
||||
import { first } from 'rxjs/operators'
|
||||
import { ToastrService } from 'ngx-toastr'
|
||||
import { NgZone, OnInit, OnDestroy, Inject, Optional, ViewChild, HostBinding, Input } from '@angular/core'
|
||||
import { NgZone, OnInit, OnDestroy, Inject, Injector, Optional, ViewChild, HostBinding, Input } from '@angular/core'
|
||||
import { AppService, ConfigService, BaseTabComponent, ElectronService, HostAppService, HotkeysService, Platform, LogService, Logger } from 'terminus-core'
|
||||
|
||||
import { Session, SessionsService } from '../services/sessions.service'
|
||||
import { BaseSession, SessionsService } from '../services/sessions.service'
|
||||
import { TerminalFrontendService } from '../services/terminalFrontend.service'
|
||||
|
||||
import { TerminalDecorator, ResizeEvent, TerminalContextMenuItemProvider } from '../api'
|
||||
@@ -20,7 +20,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
`
|
||||
static styles = [require('./terminalTab.component.scss')]
|
||||
|
||||
session: Session
|
||||
session: BaseSession
|
||||
@Input() zoom = 0
|
||||
@ViewChild('content') content
|
||||
@HostBinding('style.background-color') backgroundColor: string
|
||||
@@ -43,6 +43,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
|
||||
constructor (
|
||||
public config: ConfigService,
|
||||
protected injector: Injector,
|
||||
protected zone: NgZone,
|
||||
protected app: AppService,
|
||||
protected hostApp: HostAppService,
|
||||
@@ -60,8 +61,6 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
this.decorators = this.decorators || []
|
||||
this.setTitle('Terminal')
|
||||
|
||||
this.session = new Session(this.config)
|
||||
|
||||
this.hotkeysSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => {
|
||||
if (!this.hasFocus) {
|
||||
return
|
||||
@@ -241,7 +240,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
this.logger.info(`Resizing to ${columns}x${rows}`)
|
||||
this.size = { columns, rows }
|
||||
this.zone.run(() => {
|
||||
if (this.session.open) {
|
||||
if (this.session && this.session.open) {
|
||||
this.session.resize(columns, rows)
|
||||
}
|
||||
})
|
||||
@@ -333,4 +332,19 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
await this.session.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
protected attachSessionHandlers () {
|
||||
// this.session.output$.bufferTime(10).subscribe((datas) => {
|
||||
this.session.output$.subscribe(data => {
|
||||
this.zone.run(() => {
|
||||
this.output.next(data)
|
||||
this.write(data)
|
||||
})
|
||||
})
|
||||
|
||||
this.sessionCloseSubscription = this.session.closed$.subscribe(() => {
|
||||
this.frontend.destroy()
|
||||
this.app.closeTab(this)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ import { first } from 'rxjs/operators'
|
||||
import { BaseTabProcess } from 'terminus-core'
|
||||
import { BaseTerminalTabComponent } from './baseTerminalTab.component'
|
||||
import { SessionOptions } from '../api'
|
||||
import { Session } from '../services/sessions.service'
|
||||
|
||||
@Component({
|
||||
selector: 'terminalTab',
|
||||
@@ -14,6 +15,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
|
||||
|
||||
ngOnInit () {
|
||||
this.logger = this.log.create('terminalTab')
|
||||
this.session = new Session(this.config)
|
||||
|
||||
this.frontendReady$.pipe(first()).subscribe(() => {
|
||||
this.initializeSession(this.size.columns, this.size.rows)
|
||||
@@ -31,18 +33,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
|
||||
})
|
||||
)
|
||||
|
||||
// this.session.output$.bufferTime(10).subscribe((datas) => {
|
||||
this.session.output$.subscribe(data => {
|
||||
this.zone.run(() => {
|
||||
this.output.next(data)
|
||||
this.write(data)
|
||||
})
|
||||
})
|
||||
|
||||
this.sessionCloseSubscription = this.session.closed$.subscribe(() => {
|
||||
this.frontend.destroy()
|
||||
this.app.closeTab(this)
|
||||
})
|
||||
this.attachSessionHandlers()
|
||||
}
|
||||
|
||||
async getRecoveryToken (): Promise<any> {
|
||||
|
@@ -11,13 +11,16 @@ export class TerminalFrontendService {
|
||||
|
||||
constructor (private config: ConfigService) { }
|
||||
|
||||
getFrontend (session: BaseSession): Frontend {
|
||||
getFrontend (session?: BaseSession): Frontend {
|
||||
if (!session) {
|
||||
return (this.config.store.terminal.frontend === 'xterm')
|
||||
? new XTermFrontend()
|
||||
: new HTermFrontend()
|
||||
}
|
||||
if (!this.containers.has(session)) {
|
||||
this.containers.set(
|
||||
session,
|
||||
(this.config.store.terminal.frontend === 'xterm')
|
||||
? new XTermFrontend()
|
||||
: new HTermFrontend()
|
||||
this.getFrontend(),
|
||||
)
|
||||
}
|
||||
return this.containers.get(session)
|
||||
|
Reference in New Issue
Block a user