From fbb4957bd03295677b2c59ac8ef1610fd54c0366 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 14 Mar 2018 15:35:53 +0900 Subject: [PATCH] ing --- package.json | 2 + .../util/websocket/rx-websocket-subject.ts | 121 ------------------ .../util => core}/ngrx/store/index.ts | 0 .../util => core}/ngrx/store/selectors.ts | 0 src/packages/member/store/index.ts | 2 +- src/packages/meta/store/index.ts | 2 +- src/packages/noauth/store/index.ts | 2 +- src/packages/notification/store/index.ts | 2 +- src/packages/probe/store/index.ts | 2 +- src/packages/sensor/store/index.ts | 2 +- yarn.lock | 45 ++++++- 11 files changed, 50 insertions(+), 130 deletions(-) delete mode 100644 src/packages/commons/util/websocket/rx-websocket-subject.ts rename src/packages/{commons/util => core}/ngrx/store/index.ts (100%) rename src/packages/{commons/util => core}/ngrx/store/selectors.ts (100%) diff --git a/package.json b/package.json index 35bc6a5..dfab23e 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,13 @@ "@ngrx/store": "^5.2.0", "@ngrx/store-devtools": "^5.2.0", "@swimlane/ngx-charts": "^7.1.1", + "angular-tree-component": "^7.0.1", "core-js": "^2.5.3", "d3": "^4.13.0", "hammerjs": "^2.0.8", "ng2-odometer": "^1.1.3", "ngx-cookie-service": "^1.0.10", + "ng2-nvd3": "^2.0.0", "ngx-perfect-scrollbar": "^5.3.1", "rxjs": "^5.5.6", "zone.js": "^0.8.20", diff --git a/src/packages/commons/util/websocket/rx-websocket-subject.ts b/src/packages/commons/util/websocket/rx-websocket-subject.ts deleted file mode 100644 index 0ee3bfb..0000000 --- a/src/packages/commons/util/websocket/rx-websocket-subject.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { Observable } from 'rxjs/Observable'; -import { Observer } from 'rxjs/Observer'; -import { Subject } from 'rxjs/Subject'; -import { - WebSocketSubject, - WebSocketSubjectConfig -} from 'rxjs/observable/dom/WebSocketSubject'; - -import 'rxjs/add/operator/distinctUntilChanged'; -import 'rxjs/add/operator/share'; -import 'rxjs/add/operator/takeWhile'; -import 'rxjs/add/observable/interval'; - -export interface Codec { - decode(e: MessageEvent): any; - encode(data: any): string; -} - -export const defaultCodec: Codec = { - encode: (e: MessageEvent) => { - return JSON.parse(e.data); - }, - decode: (data: any): string => { - return JSON.stringify(data); - } -}; - -export class RxWebsocketSubject extends Subject { - private reconnectionObservable: Observable; - private wsSubjectConfig: WebSocketSubjectConfig; - private socket: WebSocketSubject; - private connectionObserver: Observer; - private _connectionStatus: Observable; - - private _reconnectInterval = 5000; - private _reconnectAttempts = 10; - - public constructor(private url: string, private codec?: Codec) { - super(); - - this._connectionStatus = new Observable((observer) => { - this.connectionObserver = observer; - }).share().distinctUntilChanged(); - - if (undefined === codec) { - this.codec = defaultCodec; - } - - this.wsSubjectConfig = { - url: url, - closeObserver: { - next: (e: CloseEvent) => { - this.socket = null; - this.connectionObserver.next(false); - } - }, - openObserver: { - next: (e: Event) => { - this.connectionObserver.next(true); - } - }, - resultSelector: this.codec.decode, - }; - - this._connectionStatus.subscribe((isConnected: boolean) => { - if (!this.reconnectionObservable && typeof(isConnected) === 'boolean' && !isConnected) { - this.reconnect(); - } - }); - } - - public set reconnectInterval(reconnectInterval: number) { - this._reconnectInterval = reconnectInterval; - } - - public set reconnectAttempts(reconnectAttempts: number) { - this._reconnectAttempts = reconnectAttempts; - } - - public get connectionStatus(): Observable { - return this._connectionStatus; - } - - public connect(): void { - this.socket = new WebSocketSubject(this.wsSubjectConfig); - this.socket.subscribe( - (m) => { - this.next(m); - }, - (error: Event) => { - if (!this.socket) { - this.reconnect(); - } - } - ); - } - - private reconnect(): void { - this.reconnectionObservable = Observable.interval(this._reconnectInterval) - .takeWhile((v, index) => { - return index < this._reconnectAttempts && !this.socket; - }); - this.reconnectionObservable.subscribe( - () => { - this.connect(); - }, - null, - () => { - this.reconnectionObservable = null; - if (!this.socket) { - this.complete(); - this.connectionObserver.complete(); - } - } - ); - } - - public send(data: any): void { - this.socket.next(this.codec.encode(data)); - } -} diff --git a/src/packages/commons/util/ngrx/store/index.ts b/src/packages/core/ngrx/store/index.ts similarity index 100% rename from src/packages/commons/util/ngrx/store/index.ts rename to src/packages/core/ngrx/store/index.ts diff --git a/src/packages/commons/util/ngrx/store/selectors.ts b/src/packages/core/ngrx/store/selectors.ts similarity index 100% rename from src/packages/commons/util/ngrx/store/selectors.ts rename to src/packages/core/ngrx/store/selectors.ts diff --git a/src/packages/member/store/index.ts b/src/packages/member/store/index.ts index 774a5d5..ae97d0d 100644 --- a/src/packages/member/store/index.ts +++ b/src/packages/member/store/index.ts @@ -4,7 +4,7 @@ import { ActionReducerMap, } from '@ngrx/store'; -import { StateSelector } from 'packages/commons/util/ngrx/store'; +import { StateSelector } from 'packages/core/ngrx/store'; import { MODULE } from '../member.constant'; diff --git a/src/packages/meta/store/index.ts b/src/packages/meta/store/index.ts index 26c26ff..bfb7db3 100644 --- a/src/packages/meta/store/index.ts +++ b/src/packages/meta/store/index.ts @@ -4,7 +4,7 @@ import { ActionReducerMap, } from '@ngrx/store'; - import { StateSelector } from 'packages/commons/util/ngrx/store'; + import { StateSelector } from 'packages/core/ngrx/store'; import { MODULE } from '../meta.constant'; diff --git a/src/packages/noauth/store/index.ts b/src/packages/noauth/store/index.ts index 56e7112..44d3653 100644 --- a/src/packages/noauth/store/index.ts +++ b/src/packages/noauth/store/index.ts @@ -3,7 +3,7 @@ import { createFeatureSelector, } from '@ngrx/store'; -import { StateSelector } from 'packages/commons/util/ngrx/store'; +import { StateSelector } from 'packages/core/ngrx/store'; import { MODULE } from '../noauth-probe.constant'; diff --git a/src/packages/notification/store/index.ts b/src/packages/notification/store/index.ts index 252b180..b22f27e 100644 --- a/src/packages/notification/store/index.ts +++ b/src/packages/notification/store/index.ts @@ -4,7 +4,7 @@ import { ActionReducerMap, } from '@ngrx/store'; - import { StateSelector } from 'packages/commons/util/ngrx/store'; + import { StateSelector } from 'packages/core/ngrx/store'; import { MODULE } from '../notification.constant'; diff --git a/src/packages/probe/store/index.ts b/src/packages/probe/store/index.ts index 60ac10c..ec1ad7e 100644 --- a/src/packages/probe/store/index.ts +++ b/src/packages/probe/store/index.ts @@ -4,7 +4,7 @@ import { ActionReducerMap, } from '@ngrx/store'; -import { StateSelector } from 'packages/commons/util/ngrx/store'; +import { StateSelector } from 'packages/core/ngrx/store'; import { MODULE } from '../probe.constant'; diff --git a/src/packages/sensor/store/index.ts b/src/packages/sensor/store/index.ts index 31c02fc..f75b207 100644 --- a/src/packages/sensor/store/index.ts +++ b/src/packages/sensor/store/index.ts @@ -4,7 +4,7 @@ import { ActionReducerMap, } from '@ngrx/store'; - import { StateSelector } from 'packages/commons/util/ngrx/store'; + import { StateSelector } from 'packages/core/ngrx/store'; import { MODULE } from '../sensor.constant'; diff --git a/yarn.lock b/yarn.lock index 3581a59..ec7efbc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -409,6 +409,14 @@ angular-l10n@^4.1.5: dependencies: tslib "^1.7.1" +angular-tree-component@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/angular-tree-component/-/angular-tree-component-7.0.1.tgz#fc8d0e72d8c34b87131a3ba2bd32ad20945689ac" + dependencies: + lodash "4.17.4" + mobx ">=3" + mobx-angular ">=1" + angularx-qrcode@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/angularx-qrcode/-/angularx-qrcode-1.0.1.tgz#9b10423995cd7448ef38843e241407ce7337daad" @@ -1964,6 +1972,10 @@ d3-zoom@1.7.1: d3-selection "1" d3-transition "1" +d3@^3.5.15: + version "3.5.17" + resolved "https://registry.yarnpkg.com/d3/-/d3-3.5.17.tgz#bc46748004378b21a360c9fc7cf5231790762fb8" + d3@^4.13.0: version "4.13.0" resolved "https://registry.yarnpkg.com/d3/-/d3-4.13.0.tgz#ab236ff8cf0cfc27a81e69bf2fb7518bc9b4f33d" @@ -4295,7 +4307,7 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash@^4.0.0, lodash@^4.11.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.0, lodash@~4.17.4: +lodash@4.17.4, lodash@^4.0.0, lodash@^4.11.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.0, lodash@~4.17.4: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -4598,6 +4610,14 @@ mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkd dependencies: minimist "0.0.8" +mobx-angular@>=1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/mobx-angular/-/mobx-angular-3.0.1.tgz#881379acea563c0767550d1f7801ab3434449bb1" + +mobx@>=3: + version "4.0.1" + resolved "https://registry.yarnpkg.com/mobx/-/mobx-4.0.1.tgz#321945580f7d3bf7b1f60ddaa1d623835683b5a2" + module-deps@^4.0.8: version "4.1.1" resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-4.1.1.tgz#23215833f1da13fd606ccb8087b44852dcb821fd" @@ -4682,6 +4702,15 @@ netmask@~1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35" +ng2-nvd3@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ng2-nvd3/-/ng2-nvd3-2.0.0.tgz#70db3652ba03bc874c4187b30964a26aae23f52a" + dependencies: + d3 "^3.5.15" + nvd3 "^1.8.5" + reflect-metadata "^0.1.10" + rxjs "5.2.0" + ng2-odometer@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/ng2-odometer/-/ng2-odometer-1.1.3.tgz#27209e7ed225790120635aba2281b8a9318b6f47" @@ -4926,6 +4955,10 @@ number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" +nvd3@^1.8.5: + version "1.8.6" + resolved "https://registry.yarnpkg.com/nvd3/-/nvd3-1.8.6.tgz#2d3eba74bf33363b5101ebf1d093c59a53ae73c4" + oauth-sign@~0.8.1: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" @@ -5951,7 +5984,7 @@ reduce-function-call@^1.0.1: dependencies: balanced-match "^0.4.2" -reflect-metadata@^0.1.2: +reflect-metadata@^0.1.10, reflect-metadata@^0.1.2: version "0.1.12" resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.12.tgz#311bf0c6b63cd782f228a81abe146a2bfa9c56f2" @@ -6189,6 +6222,12 @@ rw@1: version "1.3.3" resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" +rxjs@5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.2.0.tgz#db537de8767c05fa73721587a29e0085307d318b" + dependencies: + symbol-observable "^1.0.1" + rxjs@^5.5.2, rxjs@^5.5.6: version "5.5.6" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.6.tgz#e31fb96d6fd2ff1fd84bcea8ae9c02d007179c02" @@ -6913,7 +6952,7 @@ svgo@^0.7.0: sax "~1.2.1" whet.extend "~0.9.9" -symbol-observable@1.0.1: +symbol-observable@1.0.1, symbol-observable@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4"