This commit is contained in:
Eugene Pankov 2020-03-01 15:12:24 +01:00
parent df2f4d4a6c
commit e1cc1d56ea
9 changed files with 71 additions and 56 deletions

View File

@ -1,7 +1,7 @@
.mb-4 .mb-4
.terminus-logo .terminus-logo
h1.terminus-title Terminus h1.terminus-title Terminus
sup α sup α
.container .container
.text-center.mb-5 Thank you for downloading Terminus! .text-center.mb-5 Thank you for downloading Terminus!
@ -10,10 +10,20 @@
.header .header
.title Enable analytics .title Enable analytics
.description Help us track the number of Terminus installs across the world! .description Help us track the number of Terminus installs across the world!
toggle( toggle([(ngModel)]='config.store.enableAnalytics')
[(ngModel)]='config.store.enableAnalytics',
(ngModelChange)='config.save(); config.requestRestart()', .form-line
) .header
.title Enable SSH plugin
.description Adds an SSH connection manager UI to Terminus
toggle([(ngModel)]='enableSSH')
.form-line
.header
.title Enable Serial plugin
.description Allows attaching Terminus to serial ports
toggle([(ngModel)]='enableSerial')
.text-center.mt-5 .text-center.mt-5
button.btn.btn-primary((click)='closeAndDisable()') Close and never show again button.btn.btn-primary((click)='closeAndDisable()') Close and never show again

View File

@ -1,7 +1,7 @@
import { Component } from '@angular/core' import { Component } from '@angular/core'
import { BaseTabComponent } from './baseTab.component' import { BaseTabComponent } from './baseTab.component'
import { ConfigService } from '../services/config.service' import { ConfigService } from '../services/config.service'
import { AppService } from '../services/app.service' import { HostAppService } from '../services/hostApp.service'
/** @hidden */ /** @hidden */
@Component({ @Component({
@ -10,17 +10,29 @@ import { AppService } from '../services/app.service'
styles: [require('./welcomeTab.component.scss')], styles: [require('./welcomeTab.component.scss')],
}) })
export class WelcomeTabComponent extends BaseTabComponent { export class WelcomeTabComponent extends BaseTabComponent {
enableSSH = false
enableSerial = false
constructor ( constructor (
private app: AppService, private hostApp: HostAppService,
public config: ConfigService, public config: ConfigService,
) { ) {
super() super()
this.setTitle('Welcome') this.setTitle('Welcome')
this.enableSSH = !config.store.pluginBlacklist.includes('ssh')
this.enableSerial = !config.store.pluginBlacklist.includes('serial')
} }
closeAndDisable () { closeAndDisable () {
this.config.store.enableWelcomeTab = false this.config.store.enableWelcomeTab = false
this.config.store.pluginBlacklist = []
if (!this.enableSSH) {
this.config.store.pluginBlacklist.push('ssh')
}
if (!this.enableSerial) {
this.config.store.pluginBlacklist.push('serial')
}
this.config.save() this.config.save()
this.app.closeTab(this) this.hostApp.getWindow().reload()
} }
} }

View File

@ -191,8 +191,8 @@ export class ConfigService {
const ngModule = window['rootModule'].ɵinj const ngModule = window['rootModule'].ɵinj
for (const imp of ngModule.imports) { for (const imp of ngModule.imports) {
const module = imp['ngModule'] || imp const module = imp['ngModule'] || imp
if (module.ngInjectorDef && module.ngInjectorDef.providers) { if (module.ɵinj?.providers) {
this.servicesCache[module['pluginName']] = module.ngInjectorDef.providers.map(provider => { this.servicesCache[module['pluginName']] = module.ɵinj.providers.map(provider => {
return provider['useClass'] || provider return provider['useClass'] || provider
}) })
} }

View File

@ -1,6 +1,6 @@
import { BehaviorSubject, Observable } from 'rxjs' import { BehaviorSubject, Observable } from 'rxjs'
import { debounceTime, distinctUntilChanged, first, tap, flatMap, map } from 'rxjs/operators' import { debounceTime, distinctUntilChanged, first, tap, flatMap, map } from 'rxjs/operators'
import * as semver from 'semver' import semverGt from 'semver/functions/gt'
import { Component, Input } from '@angular/core' import { Component, Input } from '@angular/core'
import { ConfigService, ElectronService } from 'terminus-core' import { ConfigService, ElectronService } from 'terminus-core'
@ -48,7 +48,7 @@ export class PluginsSettingsTabComponent {
return plugins return plugins
})).subscribe(available => { })).subscribe(available => {
for (const plugin of this.pluginManager.installedPlugins) { for (const plugin of this.pluginManager.installedPlugins) {
this.knownUpgrades[plugin.name] = available.find(x => x.name === plugin.name && semver.gt(x.version, plugin.version)) || null this.knownUpgrades[plugin.name] = available.find(x => x.name === plugin.name && semverGt(x.version, plugin.version)) || null
} }
}) })
} }

View File

@ -1,10 +1,11 @@
import { Component } from '@angular/core' import { Component, NgZone } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { ToastrService } from 'ngx-toastr' import { ToastrService } from 'ngx-toastr'
import { ConfigService, AppService } from 'terminus-core' import { ConfigService, AppService } from 'terminus-core'
import { SettingsTabComponent } from 'terminus-settings' import { SettingsTabComponent } from 'terminus-settings'
import { SerialService } from '../services/serial.service' import { SerialService } from '../services/serial.service'
import { SerialConnection, SerialPortInfo, BAUD_RATES } from '../api' import { SerialConnection, SerialPortInfo, BAUD_RATES } from '../api'
import { SerialTabComponent } from './serialTab.component'
/** @hidden */ /** @hidden */
@Component({ @Component({
@ -22,6 +23,7 @@ export class SerialModalComponent {
private config: ConfigService, private config: ConfigService,
private serial: SerialService, private serial: SerialService,
private app: AppService, private app: AppService,
private zone: NgZone,
private toastr: ToastrService, private toastr: ToastrService,
) { } ) { }
@ -61,15 +63,23 @@ export class SerialModalComponent {
this.lastConnection = null this.lastConnection = null
} }
connect (connection: SerialConnection) { async connect (connection: SerialConnection) {
this.close() this.close()
this.serial.openTab(connection).catch(error => {
this.toastr.error(`Could not connect: ${error}`) try {
}).then(() => { const tab = this.zone.run(() => this.app.openNewTab(
SerialTabComponent,
{ connection }
) as SerialTabComponent)
if (connection.color) {
(this.app.getParentTab(tab) || tab).color = connection.color
}
setTimeout(() => { setTimeout(() => {
this.app.activeTab.emitFocused() this.app.activeTab.emitFocused()
}) })
}) } catch (error) {
this.toastr.error(`Could not connect: ${error}`)
}
} }
manageConnections () { manageConnections () {

View File

@ -1,15 +1,13 @@
import { Injectable, NgZone } from '@angular/core' import { Injectable, NgZone } from '@angular/core'
import SerialPort from 'serialport' import SerialPort from 'serialport'
import { ToastrService } from 'ngx-toastr' import { ToastrService } from 'ngx-toastr'
import { AppService, LogService } from 'terminus-core' import { LogService } from 'terminus-core'
import { SerialConnection, SerialSession, SerialPortInfo } from '../api' import { SerialConnection, SerialSession, SerialPortInfo } from '../api'
import { SerialTabComponent } from '../components/serialTab.component'
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class SerialService { export class SerialService {
private constructor ( private constructor (
private log: LogService, private log: LogService,
private app: AppService,
private zone: NgZone, private zone: NgZone,
private toastr: ToastrService, private toastr: ToastrService,
) { } ) { }
@ -21,17 +19,6 @@ export class SerialService {
})) }))
} }
async openTab (connection: SerialConnection): Promise<SerialTabComponent> {
const tab = this.zone.run(() => this.app.openNewTab(
SerialTabComponent,
{ connection }
) as SerialTabComponent)
if (connection.color) {
(this.app.getParentTab(tab) || tab).color = connection.color
}
return tab
}
createSession (connection: SerialConnection): SerialSession { createSession (connection: SerialConnection): SerialSession {
const session = new SerialSession(connection) const session = new SerialSession(connection)
session.logger = this.log.create(`serial-${connection.port}`) session.logger = this.log.create(`serial-${connection.port}`)

View File

@ -1,10 +1,10 @@
import { Component } from '@angular/core' import { Component, NgZone } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { ToastrService } from 'ngx-toastr' import { ToastrService } from 'ngx-toastr'
import { ConfigService, AppService } from 'terminus-core' import { ConfigService, AppService } from 'terminus-core'
import { SettingsTabComponent } from 'terminus-settings' import { SettingsTabComponent } from 'terminus-settings'
import { SSHService } from '../services/ssh.service'
import { SSHConnection, SSHConnectionGroup } from '../api' import { SSHConnection, SSHConnectionGroup } from '../api'
import { SSHTabComponent } from './sshTab.component'
/** @hidden */ /** @hidden */
@Component({ @Component({
@ -22,9 +22,9 @@ export class SSHModalComponent {
constructor ( constructor (
public modalInstance: NgbActiveModal, public modalInstance: NgbActiveModal,
private config: ConfigService, private config: ConfigService,
private ssh: SSHService,
private app: AppService, private app: AppService,
private toastr: ToastrService, private toastr: ToastrService,
private zone: NgZone,
) { } ) { }
ngOnInit () { ngOnInit () {
@ -63,15 +63,24 @@ export class SSHModalComponent {
this.lastConnection = null this.lastConnection = null
} }
connect (connection: SSHConnection) { async connect (connection: SSHConnection) {
this.close() this.close()
this.ssh.openTab(connection).catch(error => {
this.toastr.error(`Could not connect: ${error}`) try {
}).then(() => { const tab = this.zone.run(() => this.app.openNewTab(
SSHTabComponent,
{ connection }
) as SSHTabComponent)
if (connection.color) {
(this.app.getParentTab(tab) || tab).color = connection.color
}
setTimeout(() => { setTimeout(() => {
this.app.activeTab.emitFocused() this.app.activeTab?.emitFocused()
}) })
}) } catch (error) {
this.toastr.error(`Could not connect: ${error}`)
}
} }
manageConnections () { manageConnections () {

View File

@ -8,10 +8,9 @@ import { execFile } from 'mz/child_process'
import * as path from 'path' import * as path from 'path'
import * as sshpk from 'sshpk' import * as sshpk from 'sshpk'
import { ToastrService } from 'ngx-toastr' import { ToastrService } from 'ngx-toastr'
import { AppService, HostAppService, Platform, Logger, LogService, ElectronService } from 'terminus-core' import { HostAppService, Platform, Logger, LogService, ElectronService } from 'terminus-core'
import { SSHConnection, SSHSession } from '../api' import { SSHConnection, SSHSession } from '../api'
import { PromptModalComponent } from '../components/promptModal.component' import { PromptModalComponent } from '../components/promptModal.component'
import { SSHTabComponent } from '../components/sshTab.component'
import { PasswordStorageService } from './passwordStorage.service' import { PasswordStorageService } from './passwordStorage.service'
import { SSH2Stream } from 'ssh2-streams' import { SSH2Stream } from 'ssh2-streams'
@ -25,7 +24,6 @@ export class SSHService {
private constructor ( private constructor (
private log: LogService, private log: LogService,
private app: AppService,
private electron: ElectronService, private electron: ElectronService,
private zone: NgZone, private zone: NgZone,
private ngbModal: NgbModal, private ngbModal: NgbModal,
@ -36,17 +34,6 @@ export class SSHService {
this.logger = log.create('ssh') this.logger = log.create('ssh')
} }
async openTab (connection: SSHConnection): Promise<SSHTabComponent> {
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 { createSession (connection: SSHConnection): SSHSession {
const session = new SSHSession(connection) const session = new SSHSession(connection)
session.logger = this.log.create(`ssh-${connection.host}-${connection.port}`) session.logger = this.log.create(`ssh-${connection.host}-${connection.port}`)

View File

@ -1,7 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "es2015", "module": "es2015",
"target": "es2016", "target": "es2017",
"moduleResolution": "node", "moduleResolution": "node",
"noImplicitAny": false, "noImplicitAny": false,
"removeComments": false, "removeComments": false,