mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-05 14:34:54 +00:00
@typescript-eslint linter
This commit is contained in:
@@ -141,7 +141,7 @@ export class SSHSession extends BaseSession {
|
||||
}
|
||||
}
|
||||
|
||||
export interface ISSHConnectionGroup {
|
||||
export interface SSHConnectionGroup {
|
||||
name: string
|
||||
connections: SSHConnection[]
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { DomSanitizer } from '@angular/platform-browser'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { HotkeysService, ToolbarButtonProvider, IToolbarButton } from 'terminus-core'
|
||||
import { HotkeysService, ToolbarButtonProvider, ToolbarButton } from 'terminus-core'
|
||||
import { SSHModalComponent } from './components/sshModal.component'
|
||||
|
||||
/** @hidden */
|
||||
@@ -13,7 +13,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
hotkeys: HotkeysService,
|
||||
) {
|
||||
super()
|
||||
hotkeys.matchedHotkey.subscribe(async (hotkey) => {
|
||||
hotkeys.matchedHotkey.subscribe(async (hotkey: string) => {
|
||||
if (hotkey === 'ssh') {
|
||||
this.activate()
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
this.ngbModal.open(SSHModalComponent)
|
||||
}
|
||||
|
||||
provide (): IToolbarButton[] {
|
||||
provide (): ToolbarButton[] {
|
||||
return [{
|
||||
icon: this.domSanitizer.bypassSecurityTrustHtml(require('./icons/globe.svg')),
|
||||
weight: 5,
|
||||
@@ -32,7 +32,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
touchBarNSImage: 'NSTouchBarOpenInBrowserTemplate',
|
||||
click: async () => {
|
||||
this.activate()
|
||||
}
|
||||
},
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
@@ -27,23 +27,25 @@ export class EditConnectionModalComponent {
|
||||
this.newScript = { expect: '', send: '' }
|
||||
|
||||
for (const k of Object.values(SSHAlgorithmType)) {
|
||||
this.supportedAlgorithms[k] = ALGORITHMS[{
|
||||
const supportedAlg = {
|
||||
[SSHAlgorithmType.KEX]: 'SUPPORTED_KEX',
|
||||
[SSHAlgorithmType.HOSTKEY]: 'SUPPORTED_SERVER_HOST_KEY',
|
||||
[SSHAlgorithmType.CIPHER]: 'SUPPORTED_CIPHER',
|
||||
[SSHAlgorithmType.HMAC]: 'SUPPORTED_HMAC',
|
||||
}[k]]
|
||||
this.defaultAlgorithms[k] = ALGORITHMS[{
|
||||
}[k]
|
||||
const defaultAlg = {
|
||||
[SSHAlgorithmType.KEX]: 'KEX',
|
||||
[SSHAlgorithmType.HOSTKEY]: 'SERVER_HOST_KEY',
|
||||
[SSHAlgorithmType.CIPHER]: 'CIPHER',
|
||||
[SSHAlgorithmType.HMAC]: 'HMAC',
|
||||
}[k]]
|
||||
}[k]
|
||||
this.supportedAlgorithms[k] = ALGORITHMS[supportedAlg]
|
||||
this.defaultAlgorithms[k] = ALGORITHMS[defaultAlg]
|
||||
}
|
||||
}
|
||||
|
||||
async ngOnInit () {
|
||||
this.hasSavedPassword = !!(await this.passwordStorage.loadPassword(this.connection))
|
||||
this.hasSavedPassword = !!await this.passwordStorage.loadPassword(this.connection)
|
||||
this.connection.algorithms = this.connection.algorithms || {}
|
||||
for (const k of Object.values(SSHAlgorithmType)) {
|
||||
if (!this.connection.algorithms[k]) {
|
||||
@@ -77,8 +79,8 @@ export class EditConnectionModalComponent {
|
||||
save () {
|
||||
for (const k of Object.values(SSHAlgorithmType)) {
|
||||
this.connection.algorithms[k] = Object.entries(this.algorithms[k])
|
||||
.filter(([k, v]) => !!v)
|
||||
.map(([k, v]) => k)
|
||||
.filter(([_k, v]) => !!v)
|
||||
.map(([k, _v]) => k)
|
||||
}
|
||||
this.modalInstance.close(this.connection)
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import { ToastrService } from 'ngx-toastr'
|
||||
import { ConfigService, AppService } from 'terminus-core'
|
||||
import { SettingsTabComponent } from 'terminus-settings'
|
||||
import { SSHService } from '../services/ssh.service'
|
||||
import { SSHConnection, ISSHConnectionGroup } from '../api'
|
||||
import { SSHConnection, SSHConnectionGroup } from '../api'
|
||||
|
||||
/** @hidden */
|
||||
@Component({
|
||||
@@ -13,10 +13,10 @@ import { SSHConnection, ISSHConnectionGroup } from '../api'
|
||||
})
|
||||
export class SSHModalComponent {
|
||||
connections: SSHConnection[]
|
||||
childFolders: ISSHConnectionGroup[]
|
||||
childFolders: SSHConnectionGroup[]
|
||||
quickTarget: string
|
||||
lastConnection: SSHConnection
|
||||
childGroups: ISSHConnectionGroup[]
|
||||
childGroups: SSHConnectionGroup[]
|
||||
groupCollapsed: {[id: string]: boolean} = {}
|
||||
|
||||
constructor (
|
||||
@@ -49,7 +49,9 @@ export class SSHModalComponent {
|
||||
|
||||
const connection: SSHConnection = {
|
||||
name: this.quickTarget,
|
||||
host, user, port
|
||||
host,
|
||||
user,
|
||||
port,
|
||||
}
|
||||
window.localStorage.lastConnection = JSON.stringify(connection)
|
||||
this.connect(connection)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ConfigService, ElectronService, HostAppService } from 'terminus-core'
|
||||
import { SSHConnection, ISSHConnectionGroup } from '../api'
|
||||
import { SSHConnection, SSHConnectionGroup } from '../api'
|
||||
import { EditConnectionModalComponent } from './editConnectionModal.component'
|
||||
import { PromptModalComponent } from './promptModal.component'
|
||||
|
||||
@@ -11,7 +11,7 @@ import { PromptModalComponent } from './promptModal.component'
|
||||
})
|
||||
export class SSHSettingsTabComponent {
|
||||
connections: SSHConnection[]
|
||||
childGroups: ISSHConnectionGroup[]
|
||||
childGroups: SSHConnectionGroup[]
|
||||
groupCollapsed: {[id: string]: boolean} = {}
|
||||
|
||||
constructor (
|
||||
@@ -70,7 +70,7 @@ export class SSHSettingsTabComponent {
|
||||
}
|
||||
}
|
||||
|
||||
editGroup (group: ISSHConnectionGroup) {
|
||||
editGroup (group: SSHConnectionGroup) {
|
||||
const modal = this.ngbModal.open(PromptModalComponent)
|
||||
modal.componentInstance.prompt = 'New group name'
|
||||
modal.componentInstance.value = group.name
|
||||
@@ -86,7 +86,7 @@ export class SSHSettingsTabComponent {
|
||||
})
|
||||
}
|
||||
|
||||
async deleteGroup (group: ISSHConnectionGroup) {
|
||||
async deleteGroup (group: SSHConnectionGroup) {
|
||||
if ((await this.electron.showMessageBox(
|
||||
this.hostApp.getWindow(),
|
||||
{
|
||||
|
@@ -6,10 +6,10 @@ export class SSHConfigProvider extends ConfigProvider {
|
||||
ssh: {
|
||||
connections: [],
|
||||
options: {
|
||||
}
|
||||
},
|
||||
},
|
||||
hotkeys: {
|
||||
'ssh': [
|
||||
ssh: [
|
||||
'Alt-S',
|
||||
],
|
||||
},
|
||||
|
@@ -47,4 +47,4 @@ import { RecoveryProvider } from './recoveryProvider'
|
||||
SSHTabComponent,
|
||||
],
|
||||
})
|
||||
export default class SSHModule { }
|
||||
export default class SSHModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class
|
||||
|
@@ -9,13 +9,12 @@ import { SSHConnection, SSHSession } from '../api'
|
||||
import { PromptModalComponent } from '../components/promptModal.component'
|
||||
import { SSHTabComponent } from '../components/sshTab.component'
|
||||
import { PasswordStorageService } from './passwordStorage.service'
|
||||
const { SSH2Stream } = require('ssh2-streams')
|
||||
import { SSH2Stream } from 'ssh2-streams'
|
||||
|
||||
let windowsProcessTree
|
||||
/* eslint-disable block-scoped-var */
|
||||
try {
|
||||
windowsProcessTree = require('windows-process-tree/build/Release/windows_process_tree.node')
|
||||
} catch (e) {
|
||||
} // tslint:disable-line
|
||||
var windowsProcessTree = require('windows-process-tree/build/Release/windows_process_tree.node') // eslint-disable-line @typescript-eslint/no-var-requires
|
||||
} catch (_) { }
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class SSHService {
|
||||
@@ -46,10 +45,10 @@ export class SSHService {
|
||||
let privateKeyPath = session.connection.privateKey
|
||||
|
||||
if (!logCallback) {
|
||||
logCallback = (s) => null
|
||||
logCallback = () => null
|
||||
}
|
||||
|
||||
const log = s => {
|
||||
const log = (s: any) => {
|
||||
logCallback(s)
|
||||
this.logger.info(s)
|
||||
}
|
||||
@@ -84,7 +83,7 @@ export class SSHService {
|
||||
modal.componentInstance.password = true
|
||||
try {
|
||||
privateKeyPassphrase = await modal.result
|
||||
} catch (_err) { } // tslint:disable-line
|
||||
} catch (e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,11 +213,11 @@ export class SSHService {
|
||||
session.shell = shell
|
||||
|
||||
shell.on('greeting', greeting => {
|
||||
log('Shell Greeting: ' + greeting)
|
||||
log(`Shell Greeting: ${greeting}`)
|
||||
})
|
||||
|
||||
shell.on('banner', banner => {
|
||||
log('Shell Banner: ' + banner)
|
||||
log(`Shell Banner: ${banner}`)
|
||||
})
|
||||
} catch (error) {
|
||||
this.toastr.error(error.message)
|
||||
@@ -227,7 +226,8 @@ export class SSHService {
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable */
|
||||
const _authPassword = SSH2Stream.prototype.authPassword
|
||||
SSH2Stream.prototype.authPassword = async function (username, passwordFn) {
|
||||
SSH2Stream.prototype.authPassword = async function (username, passwordFn: any) {
|
||||
_authPassword.bind(this)(username, await passwordFn())
|
||||
}
|
||||
} as any
|
||||
|
Reference in New Issue
Block a user