ing
This commit is contained in:
parent
a506bdc587
commit
fbb4957bd0
|
@ -35,11 +35,13 @@
|
||||||
"@ngrx/store": "^5.2.0",
|
"@ngrx/store": "^5.2.0",
|
||||||
"@ngrx/store-devtools": "^5.2.0",
|
"@ngrx/store-devtools": "^5.2.0",
|
||||||
"@swimlane/ngx-charts": "^7.1.1",
|
"@swimlane/ngx-charts": "^7.1.1",
|
||||||
|
"angular-tree-component": "^7.0.1",
|
||||||
"core-js": "^2.5.3",
|
"core-js": "^2.5.3",
|
||||||
"d3": "^4.13.0",
|
"d3": "^4.13.0",
|
||||||
"hammerjs": "^2.0.8",
|
"hammerjs": "^2.0.8",
|
||||||
"ng2-odometer": "^1.1.3",
|
"ng2-odometer": "^1.1.3",
|
||||||
"ngx-cookie-service": "^1.0.10",
|
"ngx-cookie-service": "^1.0.10",
|
||||||
|
"ng2-nvd3": "^2.0.0",
|
||||||
"ngx-perfect-scrollbar": "^5.3.1",
|
"ngx-perfect-scrollbar": "^5.3.1",
|
||||||
"rxjs": "^5.5.6",
|
"rxjs": "^5.5.6",
|
||||||
"zone.js": "^0.8.20",
|
"zone.js": "^0.8.20",
|
||||||
|
|
|
@ -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<T> extends Subject<T> {
|
|
||||||
private reconnectionObservable: Observable<number>;
|
|
||||||
private wsSubjectConfig: WebSocketSubjectConfig;
|
|
||||||
private socket: WebSocketSubject<any>;
|
|
||||||
private connectionObserver: Observer<boolean>;
|
|
||||||
private _connectionStatus: Observable<boolean>;
|
|
||||||
|
|
||||||
private _reconnectInterval = 5000;
|
|
||||||
private _reconnectAttempts = 10;
|
|
||||||
|
|
||||||
public constructor(private url: string, private codec?: Codec) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this._connectionStatus = new Observable<boolean>((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<boolean> {
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
ActionReducerMap,
|
ActionReducerMap,
|
||||||
} from '@ngrx/store';
|
} from '@ngrx/store';
|
||||||
|
|
||||||
import { StateSelector } from 'packages/commons/util/ngrx/store';
|
import { StateSelector } from 'packages/core/ngrx/store';
|
||||||
|
|
||||||
import { MODULE } from '../member.constant';
|
import { MODULE } from '../member.constant';
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
ActionReducerMap,
|
ActionReducerMap,
|
||||||
} from '@ngrx/store';
|
} from '@ngrx/store';
|
||||||
|
|
||||||
import { StateSelector } from 'packages/commons/util/ngrx/store';
|
import { StateSelector } from 'packages/core/ngrx/store';
|
||||||
|
|
||||||
import { MODULE } from '../meta.constant';
|
import { MODULE } from '../meta.constant';
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {
|
||||||
createFeatureSelector,
|
createFeatureSelector,
|
||||||
} from '@ngrx/store';
|
} from '@ngrx/store';
|
||||||
|
|
||||||
import { StateSelector } from 'packages/commons/util/ngrx/store';
|
import { StateSelector } from 'packages/core/ngrx/store';
|
||||||
|
|
||||||
import { MODULE } from '../noauth-probe.constant';
|
import { MODULE } from '../noauth-probe.constant';
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
ActionReducerMap,
|
ActionReducerMap,
|
||||||
} from '@ngrx/store';
|
} from '@ngrx/store';
|
||||||
|
|
||||||
import { StateSelector } from 'packages/commons/util/ngrx/store';
|
import { StateSelector } from 'packages/core/ngrx/store';
|
||||||
|
|
||||||
import { MODULE } from '../notification.constant';
|
import { MODULE } from '../notification.constant';
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
ActionReducerMap,
|
ActionReducerMap,
|
||||||
} from '@ngrx/store';
|
} from '@ngrx/store';
|
||||||
|
|
||||||
import { StateSelector } from 'packages/commons/util/ngrx/store';
|
import { StateSelector } from 'packages/core/ngrx/store';
|
||||||
|
|
||||||
import { MODULE } from '../probe.constant';
|
import { MODULE } from '../probe.constant';
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
ActionReducerMap,
|
ActionReducerMap,
|
||||||
} from '@ngrx/store';
|
} from '@ngrx/store';
|
||||||
|
|
||||||
import { StateSelector } from 'packages/commons/util/ngrx/store';
|
import { StateSelector } from 'packages/core/ngrx/store';
|
||||||
|
|
||||||
import { MODULE } from '../sensor.constant';
|
import { MODULE } from '../sensor.constant';
|
||||||
|
|
||||||
|
|
45
yarn.lock
45
yarn.lock
|
@ -409,6 +409,14 @@ angular-l10n@^4.1.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib "^1.7.1"
|
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:
|
angularx-qrcode@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/angularx-qrcode/-/angularx-qrcode-1.0.1.tgz#9b10423995cd7448ef38843e241407ce7337daad"
|
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-selection "1"
|
||||||
d3-transition "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:
|
d3@^4.13.0:
|
||||||
version "4.13.0"
|
version "4.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/d3/-/d3-4.13.0.tgz#ab236ff8cf0cfc27a81e69bf2fb7518bc9b4f33d"
|
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"
|
version "4.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
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"
|
version "4.17.4"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
|
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:
|
dependencies:
|
||||||
minimist "0.0.8"
|
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:
|
module-deps@^4.0.8:
|
||||||
version "4.1.1"
|
version "4.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-4.1.1.tgz#23215833f1da13fd606ccb8087b44852dcb821fd"
|
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"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35"
|
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:
|
ng2-odometer@^1.1.3:
|
||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/ng2-odometer/-/ng2-odometer-1.1.3.tgz#27209e7ed225790120635aba2281b8a9318b6f47"
|
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"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
|
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:
|
oauth-sign@~0.8.1:
|
||||||
version "0.8.2"
|
version "0.8.2"
|
||||||
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"
|
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:
|
dependencies:
|
||||||
balanced-match "^0.4.2"
|
balanced-match "^0.4.2"
|
||||||
|
|
||||||
reflect-metadata@^0.1.2:
|
reflect-metadata@^0.1.10, reflect-metadata@^0.1.2:
|
||||||
version "0.1.12"
|
version "0.1.12"
|
||||||
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.12.tgz#311bf0c6b63cd782f228a81abe146a2bfa9c56f2"
|
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.12.tgz#311bf0c6b63cd782f228a81abe146a2bfa9c56f2"
|
||||||
|
|
||||||
|
@ -6189,6 +6222,12 @@ rw@1:
|
||||||
version "1.3.3"
|
version "1.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4"
|
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:
|
rxjs@^5.5.2, rxjs@^5.5.6:
|
||||||
version "5.5.6"
|
version "5.5.6"
|
||||||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.6.tgz#e31fb96d6fd2ff1fd84bcea8ae9c02d007179c02"
|
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.6.tgz#e31fb96d6fd2ff1fd84bcea8ae9c02d007179c02"
|
||||||
|
@ -6913,7 +6952,7 @@ svgo@^0.7.0:
|
||||||
sax "~1.2.1"
|
sax "~1.2.1"
|
||||||
whet.extend "~0.9.9"
|
whet.extend "~0.9.9"
|
||||||
|
|
||||||
symbol-observable@1.0.1:
|
symbol-observable@1.0.1, symbol-observable@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4"
|
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user