1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-24 06:04:04 +03:00

use providedIn

This commit is contained in:
Eugene Pankov 2018-12-21 21:21:33 +01:00
parent 91bba042b5
commit c204f6d5a4
24 changed files with 25 additions and 58 deletions

View File

@ -6,19 +6,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { PerfectScrollbarModule, PERFECT_SCROLLBAR_CONFIG } from 'ngx-perfect-scrollbar'
import { DndModule } from 'ng2-dnd'
import { AppService } from './services/app.service'
import { ConfigService } from './services/config.service'
import { ElectronService } from './services/electron.service'
import { HostAppService } from './services/hostApp.service'
import { LogService } from './services/log.service'
import { HomeBaseService } from './services/homeBase.service'
import { HotkeysService, AppHotkeyProvider } from './services/hotkeys.service'
import { DockingService } from './services/docking.service'
import { ShellIntegrationService } from './services/shellIntegration.service'
import { TabRecoveryService } from './services/tabRecovery.service'
import { ThemesService } from './services/themes.service'
import { TouchbarService } from './services/touchbar.service'
import { UpdaterService } from './services/updater.service'
import { AppHotkeyProvider } from './services/hotkeys.service'
import { AppRootComponent } from './components/appRoot.component'
import { CheckboxComponent } from './components/checkbox.component'
@ -44,19 +32,6 @@ import 'perfect-scrollbar/css/perfect-scrollbar.css'
import 'ng2-dnd/bundles/style.css'
const PROVIDERS = [
AppService,
ConfigService,
DockingService,
ElectronService,
HomeBaseService,
HostAppService,
HotkeysService,
LogService,
ShellIntegrationService,
TabRecoveryService,
ThemesService,
TouchbarService,
UpdaterService,
{ provide: HotkeyProvider, useClass: AppHotkeyProvider, multi: true },
{ provide: Theme, useClass: StandardTheme, multi: true },
{ provide: Theme, useClass: StandardCompactTheme, multi: true },

View File

@ -35,7 +35,7 @@ class CompletionObserver {
}
}
@Injectable()
@Injectable({ providedIn: 'root' })
export class AppService {
tabs: BaseTabComponent[] = []
activeTab: BaseTabComponent

View File

@ -74,7 +74,7 @@ export class ConfigProxy {
setValue (key: string, value: any) { } // tslint:disable-line
}
@Injectable()
@Injectable({ providedIn: 'root' })
export class ConfigService {
store: any
restartRequested: boolean

View File

@ -8,7 +8,7 @@ export interface IScreen {
name: string
}
@Injectable()
@Injectable({ providedIn: 'root' })
export class DockingService {
constructor (
private electron: ElectronService,

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'
import { TouchBar, BrowserWindow, Menu, MenuItem } from 'electron'
@Injectable()
@Injectable({ providedIn: 'root' })
export class ElectronService {
app: any
ipcRenderer: any

View File

@ -5,7 +5,7 @@ import { ConfigService } from './config.service'
import ua = require('universal-analytics')
import uuidv4 = require('uuid/v4')
@Injectable()
@Injectable({ providedIn: 'root' })
export class HomeBaseService {
appVersion: string

View File

@ -16,7 +16,7 @@ export interface Bounds {
height: number
}
@Injectable()
@Injectable({ providedIn: 'root' })
export class HostAppService {
platform: Platform
nodePlatform: string

View File

@ -17,7 +17,7 @@ interface EventBufferEntry {
time: number,
}
@Injectable()
@Injectable({ providedIn: 'root' })
export class HotkeysService {
key = new EventEmitter<NativeKeyEvent>()
matchedHotkey = new EventEmitter<string>()

View File

@ -53,7 +53,7 @@ export class Logger {
log (...args: any[]) { this.doLog('log', ...args) }
}
@Injectable()
@Injectable({ providedIn: 'root' })
export class LogService {
private log: any

View File

@ -6,7 +6,7 @@ import { Injectable } from '@angular/core'
import { ElectronService } from './electron.service'
import { HostAppService, Platform } from './hostApp.service'
@Injectable()
@Injectable({ providedIn: 'root' })
export class ShellIntegrationService {
private automatorWorkflows = ['Open Terminus here.workflow', 'Paste path into Terminus.workflow']
private automatorWorkflowsLocation: string

View File

@ -5,7 +5,7 @@ import { Logger, LogService } from '../services/log.service'
import { AppService } from '../services/app.service'
import { ConfigService } from '../services/config.service'
@Injectable()
@Injectable({ providedIn: 'root' })
export class TabRecoveryService {
logger: Logger

View File

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core'
import { ConfigService } from '../services/config.service'
import { Theme } from '../api/theme'
@Injectable()
@Injectable({ providedIn: 'root' })
export class ThemesService {
private styleElement: HTMLElement = null

View File

@ -6,7 +6,7 @@ import { ElectronService } from './electron.service'
import { HostAppService } from './hostApp.service'
import { IToolbarButton, ToolbarButtonProvider } from '../api'
@Injectable()
@Injectable({ providedIn: 'root' })
export class TouchbarService {
private tabsSegmentedControl: TouchBarSegmentedControl
private tabSegments: SegmentedControlSegment[] = []

View File

@ -6,7 +6,7 @@ import { ElectronService } from './electron.service'
const UPDATES_URL = 'https://api.github.com/repos/eugeny/terminus/releases/latest'
@Injectable()
@Injectable({ providedIn: 'root' })
export class UpdaterService {
private logger: Logger
private downloaded: Promise<boolean>

View File

@ -22,7 +22,6 @@ import { PluginsSettingsTabProvider } from './settings'
providers: [
{ provide: SettingsTabProvider, useClass: PluginsSettingsTabProvider, multi: true },
{ provide: ConfigProvider, useClass: PluginsConfigProvider, multi: true },
PluginManagerService,
],
entryComponents: [
PluginsSettingsTabComponent,

View File

@ -23,7 +23,7 @@ export interface IPluginInfo {
path?: string
}
@Injectable()
@Injectable({ providedIn: 'root' })
export class PluginManagerService {
logger: Logger
builtinPluginsPath: string = (window as any).builtinPluginsPath

View File

@ -11,8 +11,6 @@ import { EditConnectionModalComponent } from './components/editConnectionModal.c
import { SSHModalComponent } from './components/sshModal.component'
import { PromptModalComponent } from './components/promptModal.component'
import { SSHSettingsTabComponent } from './components/sshSettingsTab.component'
import { SSHService } from './services/ssh.service'
import { PasswordStorageService } from './services/passwordStorage.service'
import { ButtonProvider } from './buttonProvider'
import { SSHConfigProvider } from './config'
@ -27,8 +25,6 @@ import { SSHSettingsTabProvider } from './settings'
TerminusCoreModule,
],
providers: [
PasswordStorageService,
SSHService,
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
{ provide: ConfigProvider, useClass: SSHConfigProvider, multi: true },
{ provide: SettingsTabProvider, useClass: SSHSettingsTabProvider, multi: true },

View File

@ -1,5 +1,6 @@
import { Injectable, NgZone } from '@angular/core'
import { SSHConnection } from '../api'
import SSHModule from '..'
let xkeychain
let wincredmgr
@ -13,7 +14,7 @@ try {
}
}
@Injectable()
@Injectable({ providedIn: SSHModule })
export class PasswordStorageService {
constructor (
private zone: NgZone,

View File

@ -9,6 +9,7 @@ import { TerminalTabComponent } from 'terminus-terminal'
import { SSHConnection, SSHSession } from '../api'
import { PromptModalComponent } from '../components/promptModal.component'
import { PasswordStorageService } from './passwordStorage.service'
import SSHModule from '..'
const { SSH2Stream } = require('ssh2-streams')
let windowsProcessTree
@ -17,7 +18,7 @@ try {
} catch (e) {
} // tslint:disable-line
@Injectable()
@Injectable({ providedIn: SSHModule })
export class SSHService {
private logger: Logger

View File

@ -19,7 +19,7 @@ import { ColorPickerComponent } from './components/colorPicker.component'
import { EditProfileModalComponent } from './components/editProfileModal.component'
import { EnvironmentEditorComponent } from './components/environmentEditor.component'
import { SessionsService, BaseSession } from './services/sessions.service'
import { BaseSession } from './services/sessions.service'
import { TerminalFrontendService } from './services/terminalFrontend.service'
import { TerminalService } from './services/terminal.service'
import { DockMenuService } from './services/dockMenu.service'
@ -57,11 +57,6 @@ import { hterm } from './hterm'
TerminusCorePlugin,
],
providers: [
SessionsService,
TerminalFrontendService,
TerminalService,
DockMenuService,
{ provide: SettingsTabProvider, useClass: AppearanceSettingsTabProvider, multi: true },
{ provide: SettingsTabProvider, useClass: ShellSettingsTabProvider, multi: true },
{ provide: SettingsTabProvider, useClass: TerminalSettingsTabProvider, multi: true },

View File

@ -2,7 +2,7 @@ import { NgZone, Injectable } from '@angular/core'
import { ElectronService, ConfigService, HostAppService, Platform } from 'terminus-core'
import { TerminalService } from './terminal.service'
@Injectable()
@Injectable({ providedIn: 'root' })
export class DockMenuService {
appVersion: string

View File

@ -6,7 +6,7 @@ import { first } from 'rxjs/operators'
import { Injectable } from '@angular/core'
import { Logger, LogService, ConfigService } from 'terminus-core'
import { exec } from 'mz/child_process'
import TerminalModule from '..'
import { SessionOptions } from '../api'
let macOSNativeProcessList
@ -248,7 +248,7 @@ export class Session extends BaseSession {
}
}
@Injectable()
@Injectable({ providedIn: TerminalModule })
export class SessionsService {
sessions: {[id: string]: BaseSession} = {}
logger: Logger

View File

@ -4,7 +4,7 @@ import { AppService, Logger, LogService, ConfigService } from 'terminus-core'
import { IShell, ShellProvider, SessionOptions } from '../api'
import { TerminalTabComponent } from '../components/terminalTab.component'
@Injectable()
@Injectable({ providedIn: 'root' })
export class TerminalService {
private shells = new AsyncSubject<IShell[]>()
private logger: Logger

View File

@ -5,7 +5,7 @@ import { HTermFrontend } from '../frontends/htermFrontend'
import { XTermFrontend } from '../frontends/xtermFrontend'
import { BaseSession } from '../services/sessions.service'
@Injectable()
@Injectable({ providedIn: 'root' })
export class TerminalFrontendService {
private containers = new WeakMap<BaseSession, Frontend>()