mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-08 05:20:01 +00:00
ref ef6b8a4eaa1ce4cf0311649d009d1a8a3e66a71c
This commit is contained in:
parent
a9c63b5305
commit
7687972e65
@ -16,7 +16,7 @@ export { BootstrapData, PluginInfo, BOOTSTRAP_DATA } from './mainProcess'
|
|||||||
export { HostWindowService } from './hostWindow'
|
export { HostWindowService } from './hostWindow'
|
||||||
export { HostAppService, Platform } from './hostApp'
|
export { HostAppService, Platform } from './hostApp'
|
||||||
export { FileProvider } from './fileProvider'
|
export { FileProvider } from './fileProvider'
|
||||||
export { ProfileProvider, ConnectableProfileProvider, Profile, ConnectableProfile, PartialProfile, ProfileSettingsComponent, ProfileGroup, PartialProfileGroup } from './profileProvider'
|
export { ProfileProvider, ConnectableProfileProvider, QuickConnectProfileProvider, Profile, ConnectableProfile, PartialProfile, ProfileSettingsComponent, ProfileGroup, PartialProfileGroup } from './profileProvider'
|
||||||
export { PromptModalComponent } from '../components/promptModal.component'
|
export { PromptModalComponent } from '../components/promptModal.component'
|
||||||
export * from './commands'
|
export * from './commands'
|
||||||
|
|
||||||
|
@ -74,14 +74,12 @@ export abstract class ProfileProvider<P extends Profile> {
|
|||||||
deleteProfile (profile: P): void { }
|
deleteProfile (profile: P): void { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class ConnectableProfileProvider<P extends ConnectableProfile> extends ProfileProvider<P> {
|
export abstract class ConnectableProfileProvider<P extends ConnectableProfile> extends ProfileProvider<P> {}
|
||||||
|
|
||||||
quickConnect (query: string): PartialProfile<P>|null {
|
export abstract class QuickConnectProfileProvider<P extends ConnectableProfile> extends ConnectableProfileProvider<P> {
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
intoQuickConnectString (profile: P): string|null {
|
abstract quickConnect (query: string): PartialProfile<P>|null
|
||||||
return null
|
|
||||||
}
|
abstract intoQuickConnectString (profile: P): string|null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ import { FastHtmlBindDirective } from './directives/fastHtmlBind.directive'
|
|||||||
import { DropZoneDirective } from './directives/dropZone.directive'
|
import { DropZoneDirective } from './directives/dropZone.directive'
|
||||||
import { CdkAutoDropGroup } from './directives/cdkAutoDropGroup.directive'
|
import { CdkAutoDropGroup } from './directives/cdkAutoDropGroup.directive'
|
||||||
|
|
||||||
import { Theme, CLIHandler, TabContextMenuItemProvider, TabRecoveryProvider, HotkeyProvider, ConfigProvider, PlatformService, FileProvider, ProfilesService, ProfileProvider, ConnectableProfileProvider, SelectorOption, Profile, SelectorService, CommandProvider } from './api'
|
import { Theme, CLIHandler, TabContextMenuItemProvider, TabRecoveryProvider, HotkeyProvider, ConfigProvider, PlatformService, FileProvider, ProfilesService, ProfileProvider, QuickConnectProfileProvider, SelectorOption, Profile, SelectorService, CommandProvider } from './api'
|
||||||
|
|
||||||
import { AppService } from './services/app.service'
|
import { AppService } from './services/app.service'
|
||||||
import { ConfigService } from './services/config.service'
|
import { ConfigService } from './services/config.service'
|
||||||
@ -214,7 +214,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
|
|||||||
callback: () => this.profilesService.openNewTabForProfile(p),
|
callback: () => this.profilesService.openNewTabForProfile(p),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if (provider instanceof ConnectableProfileProvider) {
|
if (provider instanceof QuickConnectProfileProvider) {
|
||||||
options.push({
|
options.push({
|
||||||
name: this.translate.instant('Quick connect'),
|
name: this.translate.instant('Quick connect'),
|
||||||
freeInputPattern: this.translate.instant('Connect to "%s"...'),
|
freeInputPattern: this.translate.instant('Connect to "%s"...'),
|
||||||
|
@ -2,7 +2,7 @@ import { Injectable, Inject } from '@angular/core'
|
|||||||
import { TranslateService } from '@ngx-translate/core'
|
import { TranslateService } from '@ngx-translate/core'
|
||||||
import { NewTabParameters } from './tabs.service'
|
import { NewTabParameters } from './tabs.service'
|
||||||
import { BaseTabComponent } from '../components/baseTab.component'
|
import { BaseTabComponent } from '../components/baseTab.component'
|
||||||
import { ConnectableProfileProvider, PartialProfile, PartialProfileGroup, Profile, ProfileGroup, ProfileProvider } from '../api/profileProvider'
|
import { QuickConnectProfileProvider, PartialProfile, PartialProfileGroup, Profile, ProfileGroup, ProfileProvider } from '../api/profileProvider'
|
||||||
import { SelectorOption } from '../api/selector'
|
import { SelectorOption } from '../api/selector'
|
||||||
import { AppService } from './app.service'
|
import { AppService } from './app.service'
|
||||||
import { configMerge, ConfigProxy, ConfigService } from './config.service'
|
import { configMerge, ConfigProxy, ConfigService } from './config.service'
|
||||||
@ -230,7 +230,7 @@ export class ProfilesService {
|
|||||||
selectorOptionForProfile <P extends Profile, T> (profile: PartialProfile<P>): SelectorOption<T> {
|
selectorOptionForProfile <P extends Profile, T> (profile: PartialProfile<P>): SelectorOption<T> {
|
||||||
const fullProfile = this.getConfigProxyForProfile(profile)
|
const fullProfile = this.getConfigProxyForProfile(profile)
|
||||||
const provider = this.providerForProfile(fullProfile)
|
const provider = this.providerForProfile(fullProfile)
|
||||||
const freeInputEquivalent = provider instanceof ConnectableProfileProvider ? provider.intoQuickConnectString(fullProfile) ?? undefined : undefined
|
const freeInputEquivalent = provider instanceof QuickConnectProfileProvider ? provider.intoQuickConnectString(fullProfile) ?? undefined : undefined
|
||||||
return {
|
return {
|
||||||
...profile,
|
...profile,
|
||||||
group: this.resolveProfileGroupName(profile.group ?? ''),
|
group: this.resolveProfileGroupName(profile.group ?? ''),
|
||||||
@ -308,7 +308,7 @@ export class ProfilesService {
|
|||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
this.getProviders().forEach(provider => {
|
this.getProviders().forEach(provider => {
|
||||||
if (provider instanceof ConnectableProfileProvider) {
|
if (provider instanceof QuickConnectProfileProvider) {
|
||||||
options.push({
|
options.push({
|
||||||
name: this.translate.instant('Quick connect'),
|
name: this.translate.instant('Quick connect'),
|
||||||
freeInputPattern: this.translate.instant('Connect to "%s"...'),
|
freeInputPattern: this.translate.instant('Connect to "%s"...'),
|
||||||
@ -338,7 +338,7 @@ export class ProfilesService {
|
|||||||
|
|
||||||
async quickConnect (query: string): Promise<PartialProfile<Profile>|null> {
|
async quickConnect (query: string): Promise<PartialProfile<Profile>|null> {
|
||||||
for (const provider of this.getProviders()) {
|
for (const provider of this.getProviders()) {
|
||||||
if (provider instanceof ConnectableProfileProvider) {
|
if (provider instanceof QuickConnectProfileProvider) {
|
||||||
const profile = provider.quickConnect(query)
|
const profile = provider.quickConnect(query)
|
||||||
if (profile) {
|
if (profile) {
|
||||||
return profile
|
return profile
|
||||||
|
@ -2,7 +2,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
|
|||||||
import deepClone from 'clone-deep'
|
import deepClone from 'clone-deep'
|
||||||
import { Component, Inject } from '@angular/core'
|
import { Component, Inject } from '@angular/core'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { ConfigService, HostAppService, Profile, SelectorService, ProfilesService, PromptModalComponent, PlatformService, BaseComponent, PartialProfile, ProfileProvider, TranslateService, Platform, ProfileGroup, PartialProfileGroup, ConnectableProfileProvider } from 'tabby-core'
|
import { ConfigService, HostAppService, Profile, SelectorService, ProfilesService, PromptModalComponent, PlatformService, BaseComponent, PartialProfile, ProfileProvider, TranslateService, Platform, ProfileGroup, PartialProfileGroup, QuickConnectProfileProvider } from 'tabby-core'
|
||||||
import { EditProfileModalComponent } from './editProfileModal.component'
|
import { EditProfileModalComponent } from './editProfileModal.component'
|
||||||
import { EditProfileGroupModalComponent, EditProfileGroupModalComponentResult } from './editProfileGroupModal.component'
|
import { EditProfileGroupModalComponent, EditProfileGroupModalComponentResult } from './editProfileGroupModal.component'
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getQuickConnectProviders (): ProfileProvider<Profile>[] {
|
getQuickConnectProviders (): ProfileProvider<Profile>[] {
|
||||||
return this.profileProviders.filter(x => x instanceof ConnectableProfileProvider)
|
return this.profileProviders.filter(x => x instanceof QuickConnectProfileProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Injectable, InjectFlags, Injector } from '@angular/core'
|
import { Injectable, InjectFlags, Injector } from '@angular/core'
|
||||||
import { NewTabParameters, PartialProfile, TranslateService, ConnectableProfileProvider } from 'tabby-core'
|
import { NewTabParameters, PartialProfile, TranslateService, QuickConnectProfileProvider } from 'tabby-core'
|
||||||
import * as ALGORITHMS from 'ssh2/lib/protocol/constants'
|
import * as ALGORITHMS from 'ssh2/lib/protocol/constants'
|
||||||
import { SSHProfileSettingsComponent } from './components/sshProfileSettings.component'
|
import { SSHProfileSettingsComponent } from './components/sshProfileSettings.component'
|
||||||
import { SSHTabComponent } from './components/sshTab.component'
|
import { SSHTabComponent } from './components/sshTab.component'
|
||||||
@ -8,7 +8,7 @@ import { ALGORITHM_BLACKLIST, SSHAlgorithmType, SSHProfile } from './api'
|
|||||||
import { SSHProfileImporter } from './api/importer'
|
import { SSHProfileImporter } from './api/importer'
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class SSHProfilesService extends ConnectableProfileProvider<SSHProfile> {
|
export class SSHProfilesService extends QuickConnectProfileProvider<SSHProfile> {
|
||||||
id = 'ssh'
|
id = 'ssh'
|
||||||
name = 'SSH'
|
name = 'SSH'
|
||||||
settingsComponent = SSHProfileSettingsComponent
|
settingsComponent = SSHProfileSettingsComponent
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { NewTabParameters, PartialProfile, TranslateService, ConnectableProfileProvider } from 'tabby-core'
|
import { NewTabParameters, PartialProfile, TranslateService, QuickConnectProfileProvider } from 'tabby-core'
|
||||||
import { TelnetProfileSettingsComponent } from './components/telnetProfileSettings.component'
|
import { TelnetProfileSettingsComponent } from './components/telnetProfileSettings.component'
|
||||||
import { TelnetTabComponent } from './components/telnetTab.component'
|
import { TelnetTabComponent } from './components/telnetTab.component'
|
||||||
import { TelnetProfile } from './session'
|
import { TelnetProfile } from './session'
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class TelnetProfilesService extends ConnectableProfileProvider<TelnetProfile> {
|
export class TelnetProfilesService extends QuickConnectProfileProvider<TelnetProfile> {
|
||||||
id = 'telnet'
|
id = 'telnet'
|
||||||
name = 'Telnet'
|
name = 'Telnet'
|
||||||
supportsQuickConnect = true
|
supportsQuickConnect = true
|
||||||
@ -96,4 +96,12 @@ export class TelnetProfilesService extends ConnectableProfileProvider<TelnetProf
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
intoQuickConnectString (profile: TelnetProfile): string | null {
|
||||||
|
let s = profile.options.host
|
||||||
|
if (profile.options.port !== 23) {
|
||||||
|
s = `${s}:${profile.options.port}`
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user