diff --git a/terminus-core/src/components/welcomeTab.component.pug b/terminus-core/src/components/welcomeTab.component.pug index 45186247..9e51e2d0 100644 --- a/terminus-core/src/components/welcomeTab.component.pug +++ b/terminus-core/src/components/welcomeTab.component.pug @@ -1,7 +1,7 @@ .mb-4 .terminus-logo h1.terminus-title Terminus - sup α + sup α .container .text-center.mb-5 Thank you for downloading Terminus! @@ -10,10 +10,20 @@ .header .title Enable analytics .description Help us track the number of Terminus installs across the world! - toggle( - [(ngModel)]='config.store.enableAnalytics', - (ngModelChange)='config.save(); config.requestRestart()', - ) + toggle([(ngModel)]='config.store.enableAnalytics') + + .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 button.btn.btn-primary((click)='closeAndDisable()') Close and never show again diff --git a/terminus-core/src/components/welcomeTab.component.ts b/terminus-core/src/components/welcomeTab.component.ts index f2b8a9f4..c5186952 100644 --- a/terminus-core/src/components/welcomeTab.component.ts +++ b/terminus-core/src/components/welcomeTab.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core' import { BaseTabComponent } from './baseTab.component' import { ConfigService } from '../services/config.service' -import { AppService } from '../services/app.service' +import { HostAppService } from '../services/hostApp.service' /** @hidden */ @Component({ @@ -10,17 +10,29 @@ import { AppService } from '../services/app.service' styles: [require('./welcomeTab.component.scss')], }) export class WelcomeTabComponent extends BaseTabComponent { + enableSSH = false + enableSerial = false + constructor ( - private app: AppService, + private hostApp: HostAppService, public config: ConfigService, ) { super() this.setTitle('Welcome') + this.enableSSH = !config.store.pluginBlacklist.includes('ssh') + this.enableSerial = !config.store.pluginBlacklist.includes('serial') } closeAndDisable () { 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.app.closeTab(this) + this.hostApp.getWindow().reload() } } diff --git a/terminus-core/src/services/config.service.ts b/terminus-core/src/services/config.service.ts index 22af6879..7a9c7a70 100644 --- a/terminus-core/src/services/config.service.ts +++ b/terminus-core/src/services/config.service.ts @@ -191,8 +191,8 @@ export class ConfigService { const ngModule = window['rootModule'].ɵinj for (const imp of ngModule.imports) { const module = imp['ngModule'] || imp - if (module.ngInjectorDef && module.ngInjectorDef.providers) { - this.servicesCache[module['pluginName']] = module.ngInjectorDef.providers.map(provider => { + if (module.ɵinj?.providers) { + this.servicesCache[module['pluginName']] = module.ɵinj.providers.map(provider => { return provider['useClass'] || provider }) } diff --git a/terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts b/terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts index 041544eb..d3680ba7 100644 --- a/terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts +++ b/terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts @@ -1,6 +1,6 @@ import { BehaviorSubject, Observable } from 'rxjs' 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 { ConfigService, ElectronService } from 'terminus-core' @@ -48,7 +48,7 @@ export class PluginsSettingsTabComponent { return plugins })).subscribe(available => { 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 } }) } diff --git a/terminus-serial/src/components/serialModal.component.ts b/terminus-serial/src/components/serialModal.component.ts index 21e49b06..97dfb297 100644 --- a/terminus-serial/src/components/serialModal.component.ts +++ b/terminus-serial/src/components/serialModal.component.ts @@ -1,10 +1,11 @@ -import { Component } from '@angular/core' +import { Component, NgZone } from '@angular/core' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { ToastrService } from 'ngx-toastr' import { ConfigService, AppService } from 'terminus-core' import { SettingsTabComponent } from 'terminus-settings' import { SerialService } from '../services/serial.service' import { SerialConnection, SerialPortInfo, BAUD_RATES } from '../api' +import { SerialTabComponent } from './serialTab.component' /** @hidden */ @Component({ @@ -22,6 +23,7 @@ export class SerialModalComponent { private config: ConfigService, private serial: SerialService, private app: AppService, + private zone: NgZone, private toastr: ToastrService, ) { } @@ -61,15 +63,23 @@ export class SerialModalComponent { this.lastConnection = null } - connect (connection: SerialConnection) { + async connect (connection: SerialConnection) { this.close() - this.serial.openTab(connection).catch(error => { - this.toastr.error(`Could not connect: ${error}`) - }).then(() => { + + try { + const tab = this.zone.run(() => this.app.openNewTab( + SerialTabComponent, + { connection } + ) as SerialTabComponent) + if (connection.color) { + (this.app.getParentTab(tab) || tab).color = connection.color + } setTimeout(() => { this.app.activeTab.emitFocused() }) - }) + } catch (error) { + this.toastr.error(`Could not connect: ${error}`) + } } manageConnections () { diff --git a/terminus-serial/src/services/serial.service.ts b/terminus-serial/src/services/serial.service.ts index 26ecde88..1a22258f 100644 --- a/terminus-serial/src/services/serial.service.ts +++ b/terminus-serial/src/services/serial.service.ts @@ -1,15 +1,13 @@ import { Injectable, NgZone } from '@angular/core' import SerialPort from 'serialport' import { ToastrService } from 'ngx-toastr' -import { AppService, LogService } from 'terminus-core' +import { LogService } from 'terminus-core' import { SerialConnection, SerialSession, SerialPortInfo } from '../api' -import { SerialTabComponent } from '../components/serialTab.component' @Injectable({ providedIn: 'root' }) export class SerialService { private constructor ( private log: LogService, - private app: AppService, private zone: NgZone, private toastr: ToastrService, ) { } @@ -21,17 +19,6 @@ export class SerialService { })) } - async openTab (connection: SerialConnection): Promise { - 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 { const session = new SerialSession(connection) session.logger = this.log.create(`serial-${connection.port}`) diff --git a/terminus-ssh/src/components/sshModal.component.ts b/terminus-ssh/src/components/sshModal.component.ts index b7ac42ba..d519ce71 100644 --- a/terminus-ssh/src/components/sshModal.component.ts +++ b/terminus-ssh/src/components/sshModal.component.ts @@ -1,10 +1,10 @@ -import { Component } from '@angular/core' +import { Component, NgZone } from '@angular/core' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { ToastrService } from 'ngx-toastr' import { ConfigService, AppService } from 'terminus-core' import { SettingsTabComponent } from 'terminus-settings' -import { SSHService } from '../services/ssh.service' import { SSHConnection, SSHConnectionGroup } from '../api' +import { SSHTabComponent } from './sshTab.component' /** @hidden */ @Component({ @@ -22,9 +22,9 @@ export class SSHModalComponent { constructor ( public modalInstance: NgbActiveModal, private config: ConfigService, - private ssh: SSHService, private app: AppService, private toastr: ToastrService, + private zone: NgZone, ) { } ngOnInit () { @@ -63,15 +63,24 @@ export class SSHModalComponent { this.lastConnection = null } - connect (connection: SSHConnection) { + async connect (connection: SSHConnection) { this.close() - this.ssh.openTab(connection).catch(error => { - this.toastr.error(`Could not connect: ${error}`) - }).then(() => { + + try { + const tab = this.zone.run(() => this.app.openNewTab( + SSHTabComponent, + { connection } + ) as SSHTabComponent) + if (connection.color) { + (this.app.getParentTab(tab) || tab).color = connection.color + } + setTimeout(() => { - this.app.activeTab.emitFocused() + this.app.activeTab?.emitFocused() }) - }) + } catch (error) { + this.toastr.error(`Could not connect: ${error}`) + } } manageConnections () { diff --git a/terminus-ssh/src/services/ssh.service.ts b/terminus-ssh/src/services/ssh.service.ts index a22514bb..35e5fb58 100644 --- a/terminus-ssh/src/services/ssh.service.ts +++ b/terminus-ssh/src/services/ssh.service.ts @@ -8,10 +8,9 @@ import { execFile } from 'mz/child_process' import * as path from 'path' import * as sshpk from 'sshpk' 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 { PromptModalComponent } from '../components/promptModal.component' -import { SSHTabComponent } from '../components/sshTab.component' import { PasswordStorageService } from './passwordStorage.service' import { SSH2Stream } from 'ssh2-streams' @@ -25,7 +24,6 @@ export class SSHService { private constructor ( private log: LogService, - private app: AppService, private electron: ElectronService, private zone: NgZone, private ngbModal: NgbModal, @@ -36,17 +34,6 @@ export class SSHService { this.logger = log.create('ssh') } - async openTab (connection: SSHConnection): Promise { - 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 { const session = new SSHSession(connection) session.logger = this.log.create(`ssh-${connection.host}-${connection.port}`) diff --git a/tsconfig.json b/tsconfig.json index 92bce4f8..24b87f1c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "es2015", - "target": "es2016", + "target": "es2017", "moduleResolution": "node", "noImplicitAny": false, "removeComments": false,