mirror of
https://github.com/Eugeny/tabby
synced 2024-11-14 17:07:15 +00:00
moved spinner intro baseTerminalTab
This commit is contained in:
parent
025d2d1748
commit
07095f3476
12 changed files with 61 additions and 91 deletions
|
@ -18,8 +18,7 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "14.14.14",
|
||||
"ansi-colors": "^4.1.1",
|
||||
"cli-spinner": "^0.2.10"
|
||||
"ansi-colors": "^4.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/animations": "^9.1.9",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import colors from 'ansi-colors'
|
||||
import { Spinner } from 'cli-spinner'
|
||||
import { Component, Injector } from '@angular/core'
|
||||
import { first } from 'rxjs/operators'
|
||||
import { SelectorService } from 'tabby-core'
|
||||
|
@ -68,21 +67,14 @@ export class SerialTabComponent extends BaseTerminalTabComponent {
|
|||
this.setSession(session)
|
||||
this.write(`Connecting to `)
|
||||
|
||||
const spinner = new Spinner({
|
||||
text: 'Connecting',
|
||||
stream: {
|
||||
write: x => this.write(x),
|
||||
},
|
||||
})
|
||||
spinner.setSpinnerString(6)
|
||||
spinner.start()
|
||||
this.startSpinner('Connecting')
|
||||
|
||||
try {
|
||||
await this.session!.start()
|
||||
spinner.stop(true)
|
||||
this.stopSpinner()
|
||||
session.emitServiceMessage('Port opened')
|
||||
} catch (e) {
|
||||
spinner.stop(true)
|
||||
this.stopSpinner()
|
||||
this.write(colors.black.bgRed(' X ') + ' ' + colors.red(e.message) + '\r\n')
|
||||
return
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
"@types/node": "14.14.31",
|
||||
"@types/ssh2": "^0.5.46",
|
||||
"ansi-colors": "^4.1.1",
|
||||
"cli-spinner": "^0.2.10",
|
||||
"ssh2": "^1.1.0",
|
||||
"sshpk": "Eugeny/node-sshpk#89ed17dfae425a8b629873c8337e77d26838c04f",
|
||||
"strip-ansi": "^7.0.0"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import colors from 'ansi-colors'
|
||||
import { Spinner } from 'cli-spinner'
|
||||
import { Component, Injector, HostListener } from '@angular/core'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { first } from 'rxjs/operators'
|
||||
|
@ -26,13 +25,6 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
|
|||
private sessionStack: SSHSession[] = []
|
||||
private recentInputs = ''
|
||||
private reconnectOffered = false
|
||||
private spinner = new Spinner({
|
||||
text: 'Connecting',
|
||||
stream: {
|
||||
write: x => this.write(x),
|
||||
},
|
||||
})
|
||||
private spinnerActive = false
|
||||
|
||||
constructor (
|
||||
injector: Injector,
|
||||
|
@ -120,13 +112,11 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
|
|||
|
||||
this.write('\r\n' + colors.black.bgWhite(' SSH ') + ` Connecting to ${session.profile.options.host}\r\n`)
|
||||
|
||||
this.startSpinner()
|
||||
this.startSpinner('Connecting')
|
||||
|
||||
this.attachSessionHandler(session.serviceMessage$, msg => {
|
||||
this.pauseSpinner(() => {
|
||||
this.write(`\r${colors.black.bgWhite(' SSH ')} ${msg}\r\n`)
|
||||
session.resize(this.size.columns, this.size.rows)
|
||||
})
|
||||
this.write(`\r${colors.black.bgWhite(' SSH ')} ${msg}\r\n`)
|
||||
session.resize(this.size.columns, this.size.rows)
|
||||
})
|
||||
|
||||
try {
|
||||
|
@ -232,24 +222,4 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
|
|||
onClick (): void {
|
||||
this.sftpPanelVisible = false
|
||||
}
|
||||
|
||||
private startSpinner () {
|
||||
this.spinner.setSpinnerString(6)
|
||||
this.spinner.start()
|
||||
this.spinnerActive = true
|
||||
}
|
||||
|
||||
private stopSpinner () {
|
||||
this.spinner.stop(true)
|
||||
this.spinnerActive = false
|
||||
}
|
||||
|
||||
private pauseSpinner (work: () => void) {
|
||||
const wasActive = this.spinnerActive
|
||||
this.stopSpinner()
|
||||
work()
|
||||
if (wasActive) {
|
||||
this.startSpinner()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import colors from 'ansi-colors'
|
||||
import { Duplex } from 'stream'
|
||||
import { Injectable, Injector, NgZone } from '@angular/core'
|
||||
import { Injectable, NgZone } from '@angular/core'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { Client } from 'ssh2'
|
||||
import { exec } from 'child_process'
|
||||
|
@ -16,8 +16,7 @@ export class SSHService {
|
|||
private detectedWinSCPPath: string | null
|
||||
|
||||
private constructor (
|
||||
private injector: Injector,
|
||||
private log: LogService,
|
||||
log: LogService,
|
||||
private zone: NgZone,
|
||||
private ngbModal: NgbModal,
|
||||
private passwordStorage: PasswordStorageService,
|
||||
|
|
|
@ -74,11 +74,6 @@ brace-expansion@^1.1.7:
|
|||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
cli-spinner@^0.2.10:
|
||||
version "0.2.10"
|
||||
resolved "https://registry.yarnpkg.com/cli-spinner/-/cli-spinner-0.2.10.tgz#f7d617a36f5c47a7bc6353c697fc9338ff782a47"
|
||||
integrity sha512-U0sSQ+JJvSLi1pAYuJykwiA8Dsr15uHEy85iCJ6A+0DjVxivr3d+N2Wjvodeg89uP5K6TswFkKBfAD7B3YSn/Q==
|
||||
|
||||
cli@0.4.x:
|
||||
version "0.4.5"
|
||||
resolved "https://registry.yarnpkg.com/cli/-/cli-0.4.5.tgz#78f9485cd161b566e9a6c72d7170c4270e81db61"
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
"author": "Eugene Pankov",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "14.14.31",
|
||||
"cli-spinner": "^0.2.10"
|
||||
"@types/node": "14.14.31"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/animations": "^9.1.9",
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import colors from 'ansi-colors'
|
||||
import { Spinner } from 'cli-spinner'
|
||||
import { Component, Injector } from '@angular/core'
|
||||
import { first } from 'rxjs/operators'
|
||||
import { Platform, RecoveryToken } from 'tabby-core'
|
||||
|
@ -19,13 +18,6 @@ export class TelnetTabComponent extends BaseTerminalTabComponent {
|
|||
profile?: TelnetProfile
|
||||
session: TelnetSession|null = null
|
||||
private reconnectOffered = false
|
||||
private spinner = new Spinner({
|
||||
text: 'Connecting',
|
||||
stream: {
|
||||
write: x => this.write(x),
|
||||
},
|
||||
})
|
||||
private spinnerActive = false
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
||||
constructor (
|
||||
|
@ -84,13 +76,11 @@ export class TelnetTabComponent extends BaseTerminalTabComponent {
|
|||
this.setSession(session)
|
||||
|
||||
try {
|
||||
this.startSpinner()
|
||||
this.startSpinner('Connecting')
|
||||
|
||||
this.attachSessionHandler(session.serviceMessage$, msg => {
|
||||
this.pauseSpinner(() => {
|
||||
this.write(`\r${colors.black.bgWhite(' Telnet ')} ${msg}\r\n`)
|
||||
session.resize(this.size.columns, this.size.rows)
|
||||
})
|
||||
this.write(`\r${colors.black.bgWhite(' Telnet ')} ${msg}\r\n`)
|
||||
session.resize(this.size.columns, this.size.rows)
|
||||
})
|
||||
|
||||
try {
|
||||
|
@ -133,24 +123,4 @@ export class TelnetTabComponent extends BaseTerminalTabComponent {
|
|||
}
|
||||
)).response === 1
|
||||
}
|
||||
|
||||
private startSpinner () {
|
||||
this.spinner.setSpinnerString(6)
|
||||
this.spinner.start()
|
||||
this.spinnerActive = true
|
||||
}
|
||||
|
||||
private stopSpinner () {
|
||||
this.spinner.stop(true)
|
||||
this.spinnerActive = false
|
||||
}
|
||||
|
||||
private pauseSpinner (work: () => void) {
|
||||
const wasActive = this.spinnerActive
|
||||
this.stopSpinner()
|
||||
work()
|
||||
if (wasActive) {
|
||||
this.startSpinner()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"dataurl": "0.1.0",
|
||||
"deep-equal": "2.0.5",
|
||||
"ps-node": "^0.1.6",
|
||||
"cli-spinner": "^0.2.10",
|
||||
"runes": "^0.4.2",
|
||||
"shell-escape": "^0.2.0",
|
||||
"utils-decorators": "^1.8.1",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Observable, Subject, Subscription } from 'rxjs'
|
||||
import { first } from 'rxjs/operators'
|
||||
import { Spinner } from 'cli-spinner'
|
||||
import colors from 'ansi-colors'
|
||||
import { NgZone, OnInit, OnDestroy, Injector, ViewChild, HostBinding, Input, ElementRef, InjectFlags } from '@angular/core'
|
||||
import { trigger, transition, style, animate, AnimationTriggerMetadata } from '@angular/animations'
|
||||
|
@ -119,6 +120,12 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||
private allFocusModeSubscription: Subscription|null = null
|
||||
private sessionHandlers = new SubscriptionContainer()
|
||||
private sessionSupportsBracketedPaste = false
|
||||
private spinner = new Spinner({
|
||||
stream: {
|
||||
write: x => this.writeRaw(x),
|
||||
},
|
||||
})
|
||||
private spinnerActive = false
|
||||
|
||||
get input$ (): Observable<Buffer> {
|
||||
if (!this.frontend) {
|
||||
|
@ -369,6 +376,12 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||
* Feeds input into the terminal frontend
|
||||
*/
|
||||
write (data: string): void {
|
||||
this.withSpinnerPaused(() => {
|
||||
this.writeRaw(data)
|
||||
})
|
||||
}
|
||||
|
||||
protected writeRaw (data: string): void {
|
||||
if (!this.frontend) {
|
||||
throw new Error('Frontend not ready')
|
||||
}
|
||||
|
@ -666,4 +679,33 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||
protected detachSessionHandlers (): void {
|
||||
this.sessionHandlers.cancelAll()
|
||||
}
|
||||
|
||||
protected startSpinner (text?: string): void {
|
||||
if (this.spinnerActive) {
|
||||
return
|
||||
}
|
||||
if (text) {
|
||||
this.spinner.text = text
|
||||
}
|
||||
this.spinner.setSpinnerString(6)
|
||||
this.spinner.start()
|
||||
this.spinnerActive = true
|
||||
}
|
||||
|
||||
protected stopSpinner (): void {
|
||||
if (!this.spinnerActive) {
|
||||
return
|
||||
}
|
||||
this.spinner.stop(true)
|
||||
this.spinnerActive = false
|
||||
}
|
||||
|
||||
protected withSpinnerPaused (work: () => void): void {
|
||||
const wasActive = this.spinnerActive
|
||||
this.stopSpinner()
|
||||
work()
|
||||
if (wasActive) {
|
||||
this.startSpinner()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Observable, Subject } from 'rxjs'
|
||||
|
||||
|
||||
/**
|
||||
* A session object for a [[BaseTerminalTabComponent]]
|
||||
* Extend this to implement custom I/O and process management for your terminal tab
|
||||
|
|
|
@ -52,6 +52,11 @@ call-bind@^1.0.0, call-bind@^1.0.2:
|
|||
function-bind "^1.1.1"
|
||||
get-intrinsic "^1.0.2"
|
||||
|
||||
cli-spinner@^0.2.10:
|
||||
version "0.2.10"
|
||||
resolved "https://registry.yarnpkg.com/cli-spinner/-/cli-spinner-0.2.10.tgz#f7d617a36f5c47a7bc6353c697fc9338ff782a47"
|
||||
integrity sha512-U0sSQ+JJvSLi1pAYuJykwiA8Dsr15uHEy85iCJ6A+0DjVxivr3d+N2Wjvodeg89uP5K6TswFkKBfAD7B3YSn/Q==
|
||||
|
||||
connected-domain@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/connected-domain/-/connected-domain-1.0.0.tgz#bfe77238c74be453a79f0cb6058deeb4f2358e93"
|
||||
|
|
Loading…
Reference in a new issue