mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-10 14:30:03 +00:00
ref(connectable tab) reconnect context menu & hotkey
This commit is contained in:
parent
901181f681
commit
1e6f6af5ed
@ -2,9 +2,8 @@
|
|||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
|
||||||
import colors from 'ansi-colors'
|
import colors from 'ansi-colors'
|
||||||
import { Component, Injector } from '@angular/core'
|
import { Component, Injector } from '@angular/core'
|
||||||
import { first } from 'rxjs'
|
|
||||||
import { GetRecoveryTokenOptions, Platform, SelectorService } from 'tabby-core'
|
import { GetRecoveryTokenOptions, Platform, SelectorService } from 'tabby-core'
|
||||||
import { BaseTerminalTabComponent, ConnectableTerminalTabComponent, Reconnectable } from 'tabby-terminal'
|
import { BaseTerminalTabComponent, ConnectableTerminalTabComponent } from 'tabby-terminal'
|
||||||
import { SerialSession, BAUD_RATES, SerialProfile } from '../api'
|
import { SerialSession, BAUD_RATES, SerialProfile } from '../api'
|
||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
@ -14,7 +13,7 @@ import { SerialSession, BAUD_RATES, SerialProfile } from '../api'
|
|||||||
styleUrls: ['./serialTab.component.scss', ...BaseTerminalTabComponent.styles],
|
styleUrls: ['./serialTab.component.scss', ...BaseTerminalTabComponent.styles],
|
||||||
animations: BaseTerminalTabComponent.animations,
|
animations: BaseTerminalTabComponent.animations,
|
||||||
})
|
})
|
||||||
export class SerialTabComponent extends ConnectableTerminalTabComponent<SerialProfile> implements Reconnectable {
|
export class SerialTabComponent extends ConnectableTerminalTabComponent<SerialProfile> {
|
||||||
session: SerialSession|null = null
|
session: SerialSession|null = null
|
||||||
Platform = Platform
|
Platform = Platform
|
||||||
|
|
||||||
@ -90,12 +89,7 @@ export class SerialTabComponent extends ConnectableTerminalTabComponent<SerialPr
|
|||||||
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
||||||
this.reconnect()
|
this.reconnect()
|
||||||
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
||||||
this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n')
|
this.offerReconnection()
|
||||||
this.input$.pipe(first()).subscribe(() => {
|
|
||||||
if (!this.session?.open) {
|
|
||||||
this.reconnect()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -2,9 +2,8 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
|
|||||||
import colors from 'ansi-colors'
|
import colors from 'ansi-colors'
|
||||||
import { Component, Injector, HostListener } from '@angular/core'
|
import { Component, Injector, HostListener } from '@angular/core'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { first } from 'rxjs'
|
|
||||||
import { GetRecoveryTokenOptions, Platform, ProfilesService, RecoveryToken } from 'tabby-core'
|
import { GetRecoveryTokenOptions, Platform, ProfilesService, RecoveryToken } from 'tabby-core'
|
||||||
import { BaseTerminalTabComponent, ConnectableTerminalTabComponent, Reconnectable } from 'tabby-terminal'
|
import { BaseTerminalTabComponent, ConnectableTerminalTabComponent } from 'tabby-terminal'
|
||||||
import { SSHService } from '../services/ssh.service'
|
import { SSHService } from '../services/ssh.service'
|
||||||
import { KeyboardInteractivePrompt, SSHSession } from '../session/ssh'
|
import { KeyboardInteractivePrompt, SSHSession } from '../session/ssh'
|
||||||
import { SSHPortForwardingModalComponent } from './sshPortForwardingModal.component'
|
import { SSHPortForwardingModalComponent } from './sshPortForwardingModal.component'
|
||||||
@ -22,7 +21,7 @@ import { SSHMultiplexerService } from '../services/sshMultiplexer.service'
|
|||||||
],
|
],
|
||||||
animations: BaseTerminalTabComponent.animations,
|
animations: BaseTerminalTabComponent.animations,
|
||||||
})
|
})
|
||||||
export class SSHTabComponent extends ConnectableTerminalTabComponent<SSHProfile> implements Reconnectable {
|
export class SSHTabComponent extends ConnectableTerminalTabComponent<SSHProfile> {
|
||||||
Platform = Platform
|
Platform = Platform
|
||||||
sshSession: SSHSession|null = null
|
sshSession: SSHSession|null = null
|
||||||
session: SSHShellSession|null = null
|
session: SSHShellSession|null = null
|
||||||
@ -159,15 +158,7 @@ export class SSHTabComponent extends ConnectableTerminalTabComponent<SSHProfile>
|
|||||||
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
||||||
this.reconnect()
|
this.reconnect()
|
||||||
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
||||||
if (!this.reconnectOffered) {
|
this.offerReconnection()
|
||||||
this.reconnectOffered = true
|
|
||||||
this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n')
|
|
||||||
this.input$.pipe(first()).subscribe(() => {
|
|
||||||
if (!this.session?.open && this.reconnectOffered) {
|
|
||||||
this.reconnect()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -195,7 +186,7 @@ export class SSHTabComponent extends ConnectableTerminalTabComponent<SSHProfile>
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initializeSession (): Promise<void> {
|
async initializeSession (): Promise<void> {
|
||||||
this.reconnectOffered = false
|
await super.initializeSession()
|
||||||
try {
|
try {
|
||||||
await this.initializeSessionMaybeMultiplex(true)
|
await this.initializeSessionMaybeMultiplex(true)
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
|
||||||
import colors from 'ansi-colors'
|
import colors from 'ansi-colors'
|
||||||
import { Component, Injector } from '@angular/core'
|
import { Component, Injector } from '@angular/core'
|
||||||
import { first } from 'rxjs'
|
|
||||||
import { GetRecoveryTokenOptions, Platform, RecoveryToken } from 'tabby-core'
|
import { GetRecoveryTokenOptions, Platform, RecoveryToken } from 'tabby-core'
|
||||||
import { BaseTerminalTabComponent, ConnectableTerminalTabComponent, Reconnectable } from 'tabby-terminal'
|
import { BaseTerminalTabComponent, ConnectableTerminalTabComponent } from 'tabby-terminal'
|
||||||
import { TelnetProfile, TelnetSession } from '../session'
|
import { TelnetProfile, TelnetSession } from '../session'
|
||||||
|
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ import { TelnetProfile, TelnetSession } from '../session'
|
|||||||
styleUrls: ['./telnetTab.component.scss', ...BaseTerminalTabComponent.styles],
|
styleUrls: ['./telnetTab.component.scss', ...BaseTerminalTabComponent.styles],
|
||||||
animations: BaseTerminalTabComponent.animations,
|
animations: BaseTerminalTabComponent.animations,
|
||||||
})
|
})
|
||||||
export class TelnetTabComponent extends ConnectableTerminalTabComponent<TelnetProfile> implements Reconnectable {
|
export class TelnetTabComponent extends ConnectableTerminalTabComponent<TelnetProfile> {
|
||||||
Platform = Platform
|
Platform = Platform
|
||||||
session: TelnetSession|null = null
|
session: TelnetSession|null = null
|
||||||
|
|
||||||
@ -53,15 +52,7 @@ export class TelnetTabComponent extends ConnectableTerminalTabComponent<TelnetPr
|
|||||||
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
||||||
this.reconnect()
|
this.reconnect()
|
||||||
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
||||||
if (!this.reconnectOffered) {
|
this.offerReconnection()
|
||||||
this.reconnectOffered = true
|
|
||||||
this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n')
|
|
||||||
this.input$.pipe(first()).subscribe(() => {
|
|
||||||
if (!this.session?.open && this.reconnectOffered) {
|
|
||||||
this.reconnect()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -69,7 +60,7 @@ export class TelnetTabComponent extends ConnectableTerminalTabComponent<TelnetPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initializeSession (): Promise<void> {
|
async initializeSession (): Promise<void> {
|
||||||
this.reconnectOffered = false
|
await super.initializeSession()
|
||||||
|
|
||||||
const session = new TelnetSession(this.injector, this.profile)
|
const session = new TelnetSession(this.injector, this.profile)
|
||||||
this.setSession(session)
|
this.setSession(session)
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
|
||||||
|
|
||||||
import { Injector, Component } from '@angular/core'
|
import { Injector, Component } from '@angular/core'
|
||||||
|
|
||||||
|
import { first } from 'rxjs'
|
||||||
|
|
||||||
import { BaseTerminalProfile } from './interfaces'
|
import { BaseTerminalProfile } from './interfaces'
|
||||||
import { BaseTerminalTabComponent } from './baseTerminalTab.component'
|
import { BaseTerminalTabComponent } from './baseTerminalTab.component'
|
||||||
|
|
||||||
@ -13,9 +17,37 @@ export abstract class ConnectableTerminalTabComponent<P extends BaseTerminalProf
|
|||||||
|
|
||||||
constructor (protected injector: Injector) {
|
constructor (protected injector: Injector) {
|
||||||
super(injector)
|
super(injector)
|
||||||
|
|
||||||
|
this.subscribeUntilDestroyed(this.hotkeys.hotkey$, hotkey => {
|
||||||
|
if (this.hasFocus && hotkey === 'reconnect-tab') {
|
||||||
|
this.reconnect()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract initializeSession (): Promise<void>
|
/**
|
||||||
|
* Initialize Connectable Session.
|
||||||
|
* Set reconnectOffered to false
|
||||||
|
*/
|
||||||
|
async initializeSession (): Promise<void> {
|
||||||
|
this.reconnectOffered = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offering reconnection to the user if it hasn't been done yet.
|
||||||
|
* Set reconnectOffered to true
|
||||||
|
*/
|
||||||
|
offerReconnection () {
|
||||||
|
if (!this.reconnectOffered) {
|
||||||
|
this.reconnectOffered = true
|
||||||
|
this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n')
|
||||||
|
this.input$.pipe(first()).subscribe(() => {
|
||||||
|
if (!this.session?.open && this.reconnectOffered) {
|
||||||
|
this.reconnect()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async reconnect (): Promise<void> {
|
async reconnect (): Promise<void> {
|
||||||
this.session?.destroy()
|
this.session?.destroy()
|
||||||
|
@ -4,6 +4,7 @@ import { BaseTerminalTabComponent } from './api/baseTerminalTab.component'
|
|||||||
import { isReconnectable } from './api/interfaces'
|
import { isReconnectable } from './api/interfaces'
|
||||||
import { TerminalContextMenuItemProvider } from './api/contextMenuProvider'
|
import { TerminalContextMenuItemProvider } from './api/contextMenuProvider'
|
||||||
import { MultifocusService } from './services/multifocus.service'
|
import { MultifocusService } from './services/multifocus.service'
|
||||||
|
import { ConnectableTerminalTabComponent } from './api/connectableTerminalTab.component'
|
||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -97,7 +98,7 @@ export class ReconnectContextMenu extends TabContextMenuItemProvider {
|
|||||||
) { super() }
|
) { super() }
|
||||||
|
|
||||||
async getItems (tab: BaseTabComponent): Promise<MenuItemOptions[]> {
|
async getItems (tab: BaseTabComponent): Promise<MenuItemOptions[]> {
|
||||||
if (isReconnectable(tab)) {
|
if (isReconnectable(tab) || tab instanceof ConnectableTerminalTabComponent) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: this.translate.instant('Reconnect'),
|
label: this.translate.instant('Reconnect'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user