diff --git a/app/src/app.module.ts b/app/src/app.module.ts index 53c10bfb..c3be988d 100644 --- a/app/src/app.module.ts +++ b/app/src/app.module.ts @@ -14,19 +14,18 @@ import { ModalService } from 'services/modal' import { NotifyService } from 'services/notify' import { PluginDispatcherService } from 'services/pluginDispatcher' import { QuitterService } from 'services/quitter' -import { SessionsService } from 'services/sessions' import { DockingService } from 'services/docking' import { AppComponent } from 'components/app' import { CheckboxComponent } from 'components/checkbox' import { TabBodyComponent } from 'components/tabBody' import { TabHeaderComponent } from 'components/tabHeader' -import { TerminalTabComponent } from 'components/terminalTab' import { TitleBarComponent } from 'components/titleBar' let plugins = [ require('./settings').default, + require('./terminal').default, ] @NgModule({ @@ -48,17 +47,14 @@ let plugins = [ NotifyService, PluginDispatcherService, QuitterService, - SessionsService, ], entryComponents: [ - TerminalTabComponent, ], declarations: [ AppComponent, CheckboxComponent, TabBodyComponent, TabHeaderComponent, - TerminalTabComponent, TitleBarComponent, ], bootstrap: [ diff --git a/app/src/components/app.ts b/app/src/components/app.ts index c16d1c6d..03c55a22 100644 --- a/app/src/components/app.ts +++ b/app/src/components/app.ts @@ -8,10 +8,10 @@ import { LogService } from 'services/log' import { QuitterService } from 'services/quitter' import { ConfigService } from 'services/config' import { DockingService } from 'services/docking' -import { SessionsService } from 'services/sessions' +// import { SessionsService } from 'services/sessions' import { PluginDispatcherService } from 'services/pluginDispatcher' -import { Tab, TerminalTab } from 'models/tab' +import { Tab } from 'models/tab' import 'angular2-toaster/lib/toaster.css' import 'global.less' @@ -48,7 +48,7 @@ export class AppComponent { lastTabIndex = 0 constructor( - private sessions: SessionsService, +// private sessions: SessionsService, private docking: DockingService, private electron: ElectronService, public hostApp: HostAppService, @@ -146,11 +146,7 @@ export class AppComponent { } newTab () { - this.addTerminalTab(this.sessions.createNewSession({command: 'zsh'})) - } - - addTerminalTab (session) { - let tab = new TerminalTab(session) + const tab = this.pluginDispatcher.temp2('zsh') this.tabs.push(tab) this.selectTab(tab) } @@ -192,9 +188,9 @@ export class AppComponent { closeTab (tab) { tab.destroy() - if (tab.session) { + /* if (tab.session) { this.sessions.destroySession(tab.session) - } + } */ let newIndex = Math.max(0, this.tabs.indexOf(tab) - 1) this.tabs = this.tabs.filter((x) => x != tab) if (tab == this.activeTab) { @@ -203,6 +199,7 @@ export class AppComponent { } ngOnInit () { + /* this.sessions.recoverAll().then((recoveredSessions) => { if (recoveredSessions.length > 0) { recoveredSessions.forEach((session) => { @@ -213,6 +210,7 @@ export class AppComponent { this.showSettings(); } }) + */ } showSettings() { diff --git a/app/src/models/tab.ts b/app/src/models/tab.ts index a60b03bf..fa20e374 100644 --- a/app/src/models/tab.ts +++ b/app/src/models/tab.ts @@ -1,6 +1,5 @@ import { EventEmitter } from '@angular/core' import { BaseTabComponent } from 'components/baseTab' -import { Session } from 'services/sessions' export declare type ComponentType = new (...args: any[]) => BaseTabComponent @@ -25,16 +24,3 @@ export class Tab { return null } } - - -import { TerminalTabComponent } from 'components/terminalTab' - -export class TerminalTab extends Tab { - constructor (public session: Session) { - super() - } - - getComponentType (): ComponentType { - return TerminalTabComponent - } -} diff --git a/app/src/services/pluginDispatcher.ts b/app/src/services/pluginDispatcher.ts index cb2b6826..ccc884de 100644 --- a/app/src/services/pluginDispatcher.ts +++ b/app/src/services/pluginDispatcher.ts @@ -7,7 +7,8 @@ import { ElectronService } from 'services/electron' export class PluginDispatcherService { plugins = [] temp: any - + temp2: any + constructor ( private config: ConfigService, private electron: ElectronService, diff --git a/app/src/components/terminal.userCSS.scss b/app/src/terminal/components/terminal.userCSS.scss similarity index 100% rename from app/src/components/terminal.userCSS.scss rename to app/src/terminal/components/terminal.userCSS.scss diff --git a/app/src/components/terminalTab.scss b/app/src/terminal/components/terminalTab.scss similarity index 100% rename from app/src/components/terminalTab.scss rename to app/src/terminal/components/terminalTab.scss diff --git a/app/src/components/terminalTab.ts b/app/src/terminal/components/terminalTab.ts similarity index 97% rename from app/src/components/terminalTab.ts rename to app/src/terminal/components/terminalTab.ts index 5825b524..d721715c 100644 --- a/app/src/components/terminalTab.ts +++ b/app/src/terminal/components/terminalTab.ts @@ -5,9 +5,9 @@ import { ConfigService } from 'services/config' import { PluginDispatcherService } from 'services/pluginDispatcher' import { BaseTabComponent } from 'components/baseTab' -import { TerminalTab } from 'models/tab' +import { TerminalTab } from '../tab' -import { hterm, preferenceManager } from 'hterm' +import { hterm, preferenceManager } from '../hterm' @Component({ diff --git a/app/src/hterm.ts b/app/src/terminal/hterm.ts similarity index 100% rename from app/src/hterm.ts rename to app/src/terminal/hterm.ts diff --git a/app/src/terminal/index.ts b/app/src/terminal/index.ts new file mode 100644 index 00000000..e1af23dd --- /dev/null +++ b/app/src/terminal/index.ts @@ -0,0 +1,37 @@ +import { BrowserModule } from '@angular/platform-browser' +import { NgModule } from '@angular/core' +import { FormsModule } from '@angular/forms' + +import { TerminalTabComponent } from './components/terminalTab' +import { SessionsService } from './services/sessions' +import { TerminalTab } from './tab' + +import { PluginDispatcherService } from 'services/pluginDispatcher' + + +@NgModule({ + imports: [ + BrowserModule, + FormsModule, + ], + providers: [ + SessionsService, + ], + entryComponents: [ + TerminalTabComponent, + ], + declarations: [ + TerminalTabComponent, + ], +}) +class TerminalModule { + constructor (pluginDispatcher: PluginDispatcherService, sessions: SessionsService) { + pluginDispatcher.temp2 = (command) => { + let session = sessions.createNewSession({ command })) + return new TerminalTab(session) + } + } +} + + +export default TerminalModule diff --git a/app/src/services/sessions.ts b/app/src/terminal/services/sessions.ts similarity index 100% rename from app/src/services/sessions.ts rename to app/src/terminal/services/sessions.ts diff --git a/app/src/terminal/tab.ts b/app/src/terminal/tab.ts new file mode 100644 index 00000000..a51a7e32 --- /dev/null +++ b/app/src/terminal/tab.ts @@ -0,0 +1,14 @@ +import { Tab, ComponentType } from '../models/tab' +import { TerminalTabComponent } from './components/terminalTab' +import { Session } from './services/sessions' + + +export class TerminalTab extends Tab { + constructor (public session: Session) { + super() + } + + getComponentType (): ComponentType { + return TerminalTabComponent + } +} diff --git a/package.json b/package.json index 0bcfd31c..080d1577 100644 --- a/package.json +++ b/package.json @@ -25,11 +25,13 @@ "sass-loader": "^6.0.3", "style-loader": "^0.13.1", "to-string-loader": "^1.1.5", - "tslint": "4.2.0", + "tslint": "4.5.0", + "tslint-eslint-rules": "^3.5.1", "typescript": "2.2.1", "url-loader": "^0.5.7", "val-loader": "^0.5.0", - "webpack": "2.2.0-rc.4", + "vrsource-tslint-rules": "^4.0.1", + "webpack": "2.2.0", "yaml-loader": "^0.4.0" }, "build": { diff --git a/tslint.json b/tslint.json index 27b277b5..217c8c7c 100644 --- a/tslint.json +++ b/tslint.json @@ -1,21 +1,35 @@ { + "rulesDirectory": [ + "node_modules/vrsource-tslint-rules/rules", + "node_modules/tslint-eslint-rules/dist/rules" + ], "rules": { - "indent": [true, "spaces"], - "quotemark": [true, "single"], - "semicolon": false, - "no-inferrable-types": [true, "ignore-params"], - "curly": true, + "no-console": [ + true, + "log" + ], + "no-duplicate-imports": true, "no-duplicate-variable": true, - "no-empty": true, + "no-jasmine-focus": true, + "no-var-keyword": true, "no-eval": true, - "no-invalid-this": true, "no-shadowed-variable": true, "no-undef": true, "no-unused-expression": true, "no-unused-new": true, "no-unused-variable": true, "no-use-before-declare": true, - "no-var-keyword": true, - "new-parens": true + "require-internal-with-underscore": true, + "semicolon": [ + false + ], + "variable-name": [ + true, + "ban-keywords" + ], + "no-inner-declarations": [ + true, + "function" + ] } }