started separating terminus-electron and terminus-web

This commit is contained in:
Eugene Pankov
2021-05-24 17:48:12 +02:00
parent c19e131d8c
commit 012986dc7e
94 changed files with 1899 additions and 972 deletions

View File

@@ -61,7 +61,7 @@ h3.mt-5 Options
(ngModelChange)='config.save()',
)
.form-line
.form-line(*ngIf='hostApp.platform === Platform.Windows')
.header
.title WinSCP path
.descriptions When WinSCP is detected, you can launch an SCP session from the context menu.

View File

@@ -2,7 +2,7 @@
import deepClone from 'clone-deep'
import { Component } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { ConfigService, ElectronService, HostAppService } from 'terminus-core'
import { ConfigService, ElectronService, HostAppService, Platform } from 'terminus-core'
import { PasswordStorageService } from '../services/passwordStorage.service'
import { SSHConnection } from '../api'
import { EditConnectionModalComponent } from './editConnectionModal.component'
@@ -23,11 +23,12 @@ export class SSHSettingsTabComponent {
childGroups: SSHConnectionGroup[]
groupCollapsed: Record<string, boolean> = {}
filter = ''
Platform = Platform
constructor (
public config: ConfigService,
public hostApp: HostAppService,
private electron: ElectronService,
private hostApp: HostAppService,
private ngbModal: NgbModal,
private passwordStorage: PasswordStorageService,
) {

View File

@@ -10,7 +10,7 @@ import { exec } from 'child_process'
import * as path from 'path'
import * as sshpk from 'sshpk'
import { Subject, Observable } from 'rxjs'
import { HostAppService, Platform, Logger, LogService, AppService, SelectorOption, ConfigService, NotificationsService } from 'terminus-core'
import { HostAppService, Platform, Logger, LogService, AppService, SelectorOption, ConfigService, NotificationsService, PlatformService } from 'terminus-core'
import { SettingsTabComponent } from 'terminus-settings'
import { ALGORITHM_BLACKLIST, ForwardedPort, SSHConnection, SSHSession } from '../api'
import { PromptModalComponent } from '../components/promptModal.component'
@@ -20,15 +20,6 @@ import { ChildProcess } from 'node:child_process'
const WINDOWS_OPENSSH_AGENT_PIPE = '\\\\.\\pipe\\openssh-ssh-agent'
try {
var windowsProcessTreeNative = require('windows-process-tree/build/Release/windows_process_tree.node') // eslint-disable-line @typescript-eslint/no-var-requires, no-var
} catch { }
// eslint-disable-next-line @typescript-eslint/no-type-alias
export type SSHLogCallback = (message: string) => void
@Injectable({ providedIn: 'root' })
export class SSHService {
private logger: Logger
@@ -42,6 +33,7 @@ export class SSHService {
private notifications: NotificationsService,
private app: AppService,
private config: ConfigService,
private platform: PlatformService,
) {
this.logger = log.create('ssh')
}
@@ -197,13 +189,7 @@ export class SSHService {
if (await fs.exists(WINDOWS_OPENSSH_AGENT_PIPE)) {
agent = WINDOWS_OPENSSH_AGENT_PIPE
} else {
// eslint-disable-next-line @typescript-eslint/no-shadow
const pageantRunning = await new Promise<boolean>(resolve => {
windowsProcessTreeNative.getProcessList(list => { // eslint-disable-line block-scoped-var
resolve(list.some(x => x.name === 'pageant.exe'))
}, 0)
})
if (pageantRunning) {
if (await this.platform.isProcessRunning('pageant.exe')) {
agent = 'pageant'
}
}

View File

@@ -1,27 +1,20 @@
import type { MenuItemConstructorOptions } from 'electron'
import { execFile } from 'child_process'
import { Injectable } from '@angular/core'
import { ConfigService, BaseTabComponent, TabContextMenuItemProvider, TabHeaderComponent, HostAppService, Platform } from 'terminus-core'
import { ConfigService, BaseTabComponent, TabContextMenuItemProvider, TabHeaderComponent, HostAppService, Platform, PlatformService, MenuItemOptions } from 'terminus-core'
import { SSHTabComponent } from './components/sshTab.component'
import { PasswordStorageService } from './services/passwordStorage.service'
import { SSHConnection } from './api'
/* eslint-disable block-scoped-var */
try {
var wnr = require('windows-native-registry') // eslint-disable-line @typescript-eslint/no-var-requires, no-var
} catch { }
/** @hidden */
@Injectable()
export class WinSCPContextMenu extends TabContextMenuItemProvider {
weight = 10
private detectedPath?: string
private detectedPath: string | null
constructor (
private hostApp: HostAppService,
private config: ConfigService,
private platform: PlatformService,
private passwordStorage: PasswordStorageService,
) {
super()
@@ -30,14 +23,10 @@ export class WinSCPContextMenu extends TabContextMenuItemProvider {
return
}
const key = wnr.getRegistryKey(wnr.HK.CR, 'WinSCP.Url\\DefaultIcon')
if (key?.['']) {
this.detectedPath = key[''].value?.split(',')[0]
this.detectedPath = this.detectedPath?.substring(1, this.detectedPath.length - 1)
}
this.detectedPath = platform.getWinSCPPath()
}
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemConstructorOptions[]> {
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemOptions[]> {
if (this.hostApp.platform !== Platform.Windows || tabHeader) {
return []
}
@@ -81,6 +70,6 @@ export class WinSCPContextMenu extends TabContextMenuItemProvider {
args.push('/privatekey')
args.push(connection.privateKey)
}
execFile(path, args)
this.platform.exec(path, args)
}
}