1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-28 04:56:16 +03:00

profile and SSH connection colors (fixes #954)

This commit is contained in:
Eugene Pankov 2020-01-01 01:04:41 +01:00
parent a8d5cf469e
commit 2b5f623b50
7 changed files with 45 additions and 4 deletions

View File

@ -173,6 +173,17 @@ export class AppService {
}
}
getParentTab (tab: BaseTabComponent): SplitTabComponent|null {
for (const topLevelTab of this.tabs) {
if (topLevelTab instanceof SplitTabComponent) {
if (topLevelTab.getAllTabs().includes(tab)) {
return topLevelTab
}
}
}
return null
}
/** Switches between the current tab and the previously active one */
toggleLastTab () {
if (!this.lastTabIndex || this.lastTabIndex >= this.tabs.length) {

View File

@ -30,6 +30,7 @@ export interface SSHConnection {
keepaliveInterval?: number
keepaliveCountMax?: number
readyTimeout?: number
color?: string
algorithms?: {[t: string]: string[]}
}

View File

@ -67,6 +67,17 @@
button.btn.btn-secondary((click)='selectPrivateKey()')
i.fas.fa-folder-open
.form-line
.header
.title Tab color
input.form-control(
type='text',
autofocus,
[(ngModel)]='connection.color',
placeholder='#000000'
)
ngb-tab(id='advanced')
ng-template(ngbTabTitle) Advanced
ng-template(ngbTabContent)

View File

@ -32,10 +32,14 @@ export class SSHService {
}
async openTab (connection: SSHConnection): Promise<SSHTabComponent> {
return this.zone.run(() => this.app.openNewTab(
const tab = this.zone.run(() => this.app.openNewTab(
SSHTabComponent,
{ connection }
) as SSHTabComponent)
if (connection.color) {
(this.app.getParentTab(tab) || tab).color = connection.color
}
return tab
}
createSession (connection: SSHConnection): SSHSession {

View File

@ -16,8 +16,9 @@ export interface SessionOptions {
}
export interface Profile {
name: string,
sessionOptions: SessionOptions,
name: string
color?: string
sessionOptions: SessionOptions
isBuiltin?: boolean
icon?: string
}

View File

@ -53,6 +53,15 @@
[(model)]='profile.sessionOptions.env',
)
.form-group
label Tab color
input.form-control(
type='text',
autofocus,
[(ngModel)]='profile.color',
placeholder='#000000'
)
.modal-footer
button.btn.btn-outline-primary((click)='save()') Save
button.btn.btn-outline-danger((click)='cancel()') Cancel

View File

@ -88,7 +88,11 @@ export class TerminalService {
cwd: cwd || undefined,
}
return this.openTabWithOptions(sessionOptions)
const tab = this.openTabWithOptions(sessionOptions)
if (profile?.color) {
(this.app.getParentTab(tab) || tab).color = profile.color
}
return tab
}
optionsFromShell (shell: Shell): SessionOptions {