diff --git a/terminus-serial/src/components/serialTab.component.ts b/terminus-serial/src/components/serialTab.component.ts index d0c2f414..cea6e1bc 100644 --- a/terminus-serial/src/components/serialTab.component.ts +++ b/terminus-serial/src/components/serialTab.component.ts @@ -1,6 +1,6 @@ import colors from 'ansi-colors' import { Spinner } from 'cli-spinner' -import { Component } from '@angular/core' +import { Component, Injector } from '@angular/core' import { first } from 'rxjs/operators' import { BaseTerminalTabComponent } from 'terminus-terminal' import { SerialService } from '../services/serial.service' @@ -16,14 +16,19 @@ import { Subscription } from 'rxjs' }) export class SerialTabComponent extends BaseTerminalTabComponent { connection: SerialConnection - serial: SerialService session: SerialSession serialPort: any private homeEndSubscription: Subscription + constructor ( + injector: Injector, + private serial: SerialService, + ) { + super(injector) + } + ngOnInit () { this.logger = this.log.create('terminalTab') - this.serial = this.injector.get(SerialService) this.homeEndSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => { if (!this.hasFocus) { diff --git a/terminus-ssh/src/components/sshTab.component.ts b/terminus-ssh/src/components/sshTab.component.ts index 0ca53f54..2429e162 100644 --- a/terminus-ssh/src/components/sshTab.component.ts +++ b/terminus-ssh/src/components/sshTab.component.ts @@ -1,6 +1,6 @@ import colors from 'ansi-colors' import { Spinner } from 'cli-spinner' -import { Component } from '@angular/core' +import { Component, Injector } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { first } from 'rxjs/operators' import { BaseTerminalTabComponent } from 'terminus-terminal' @@ -18,16 +18,19 @@ import { Subscription } from 'rxjs' }) export class SSHTabComponent extends BaseTerminalTabComponent { connection: SSHConnection - ssh: SSHService session: SSHSession - private ngbModal: NgbModal private homeEndSubscription: Subscription - ngOnInit () { - this.ngbModal = this.injector.get(NgbModal) + constructor ( + injector: Injector, + public ssh: SSHService, + private ngbModal: NgbModal, + ) { + super(injector) + } + ngOnInit () { this.logger = this.log.create('terminalTab') - this.ssh = this.injector.get(SSHService) this.homeEndSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => { if (!this.hasFocus) { diff --git a/terminus-terminal/src/api/baseTerminalTab.component.ts b/terminus-terminal/src/api/baseTerminalTab.component.ts index d7dc1280..a566073b 100644 --- a/terminus-terminal/src/api/baseTerminalTab.component.ts +++ b/terminus-terminal/src/api/baseTerminalTab.component.ts @@ -2,7 +2,7 @@ import { Observable, Subject, Subscription } from 'rxjs' import { first } from 'rxjs/operators' import { ToastrService } from 'ngx-toastr' import colors from 'ansi-colors' -import { NgZone, OnInit, OnDestroy, Inject, Injector, Optional, ViewChild, HostBinding, Input, ElementRef } from '@angular/core' +import { NgZone, OnInit, OnDestroy, Injector, ViewChild, HostBinding, Input, ElementRef, InjectFlags } from '@angular/core' import { trigger, transition, style, animate, AnimationTriggerMetadata } from '@angular/animations' import { AppService, ConfigService, BaseTabComponent, ElectronService, HostAppService, HotkeysService, Platform, LogService, Logger, TabContextMenuItemProvider } from 'terminus-core' @@ -63,6 +63,22 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit */ enablePassthrough = true + // Deps start + config: ConfigService + element: ElementRef + protected zone: NgZone + protected app: AppService + protected hostApp: HostAppService + protected hotkeys: HotkeysService + protected sessions: SessionsService + protected electron: ElectronService + protected terminalContainersService: TerminalFrontendService + protected toastr: ToastrServiceProxy + protected log: LogService + protected decorators: TerminalDecorator[] + protected contextMenuProviders: TabContextMenuItemProvider[] + // Deps end + protected logger: Logger protected output = new Subject() private sessionCloseSubscription: Subscription @@ -76,24 +92,24 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit get alternateScreenActive$ (): Observable { return this.frontend.alternateScreenActive$ } get frontendReady$ (): Observable { return this.frontendReady } - constructor ( - public config: ConfigService, - public element: ElementRef, - protected injector: Injector, - protected zone: NgZone, - protected app: AppService, - protected hostApp: HostAppService, - protected hotkeys: HotkeysService, - protected sessions: SessionsService, - protected electron: ElectronService, - protected terminalContainersService: TerminalFrontendService, - @Inject(ToastrService) protected toastr: ToastrServiceProxy, - protected log: LogService, - @Optional() @Inject(TerminalDecorator) protected decorators: TerminalDecorator[], - @Optional() @Inject(TabContextMenuItemProvider) protected contextMenuProviders: TabContextMenuItemProvider[], - ) { + constructor (protected injector: Injector) { super() - this.logger = log.create('baseTerminalTab') + + this.config = injector.get(ConfigService) + this.element = injector.get(ElementRef) + this.zone = injector.get(NgZone) + this.app = injector.get(AppService) + this.hostApp = injector.get(HostAppService) + this.hotkeys = injector.get(HotkeysService) + this.sessions = injector.get(SessionsService) + this.electron = injector.get(ElectronService) + this.terminalContainersService = injector.get(TerminalFrontendService) + this.toastr = injector.get(ToastrService) + this.log = injector.get(LogService) + this.decorators = injector.get(TerminalDecorator, null, InjectFlags.Optional) as TerminalDecorator[] + this.contextMenuProviders = injector.get(TabContextMenuItemProvider, null, InjectFlags.Optional) as TabContextMenuItemProvider[] + + this.logger = this.log.create('baseTerminalTab') this.decorators = this.decorators || [] this.setTitle('Terminal') diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 2b51c94a..6a3bc300 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core' +import { Component, Input, Injector } from '@angular/core' import { Subscription } from 'rxjs' import { first } from 'rxjs/operators' import { BaseTabProcess, WIN_BUILD_CONPTY_SUPPORTED, isWindowsBuild } from 'terminus-core' @@ -17,6 +17,13 @@ export class TerminalTabComponent extends BaseTerminalTabComponent { @Input() sessionOptions: SessionOptions private homeEndSubscription: Subscription + // eslint-disable-next-line @typescript-eslint/no-useless-constructor + constructor ( + injector: Injector, + ) { + super(injector) + } + ngOnInit () { this.logger = this.log.create('terminalTab') this.session = new Session(this.config)