Merge branch 'master' of https://git.loafle.net/overflow/overflow-webapp
This commit is contained in:
commit
0c9ef4fb76
10
src/packages/commons/commons.module.ts
Normal file
10
src/packages/commons/commons.module.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
declarations: []
|
||||
})
|
||||
export class CommonsModule { }
|
121
src/packages/commons/rx/websocket/rx-websocket-subject.ts
Normal file
121
src/packages/commons/rx/websocket/rx-websocket-subject.ts
Normal file
|
@ -0,0 +1,121 @@
|
|||
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));
|
||||
}
|
||||
}
|
5
src/packages/discovery/component/index.ts
Normal file
5
src/packages/discovery/component/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { SettingComponent } from './setting/setting.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
SettingComponent,
|
||||
];
|
|
@ -1,19 +1,19 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { SettingComponent } from './component/setting/setting.component';
|
||||
import { COMPONENTS } from './component';
|
||||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||
|
||||
export const COMPONENTS = [
|
||||
SettingComponent,
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
MaterialModule
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
})
|
||||
export class DiscoveryModule { }
|
||||
|
|
5
src/packages/infra/component/index.ts
Normal file
5
src/packages/infra/component/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { MapComponent } from './map/map.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
MapComponent,
|
||||
];
|
|
@ -3,18 +3,18 @@ import { CommonModule } from '@angular/common';
|
|||
|
||||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||
|
||||
import { MapComponent } from './component/map/map.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
MapComponent,
|
||||
];
|
||||
import { COMPONENTS } from './component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
MaterialModule
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
})
|
||||
export class InfraModule { }
|
||||
|
|
11
src/packages/member/component/index.ts
Normal file
11
src/packages/member/component/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { ModifyComponent } from './modify/modify.component';
|
||||
import { SigninComponent } from './signin/signin.component';
|
||||
import { SignupComponent } from './signup/signup.component';
|
||||
import { ResetPasswordComponent } from './reset-password/reset-password.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ModifyComponent,
|
||||
SigninComponent,
|
||||
SignupComponent,
|
||||
ResetPasswordComponent,
|
||||
];
|
|
@ -8,15 +8,16 @@ import {
|
|||
import { EffectsModule } from '@ngrx/effects';
|
||||
import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
|
||||
|
||||
import { State as MemberState } from './store/state';
|
||||
import { reducers as memberReducers } from './store/reducer';
|
||||
import { EFFECTS } from './store/effect';
|
||||
import {
|
||||
REDUCERS,
|
||||
EFFECTS,
|
||||
} from './store';
|
||||
|
||||
import { MODULE } from './member.constant';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
StoreModule.forFeature(MODULE.name, memberReducers),
|
||||
StoreModule.forFeature(MODULE.name, REDUCERS),
|
||||
EffectsModule.forFeature(EFFECTS),
|
||||
],
|
||||
})
|
||||
|
|
|
@ -5,21 +5,12 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|||
|
||||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||
|
||||
import { ModifyComponent } from './component/modify/modify.component';
|
||||
import { SigninComponent } from './component/signin/signin.component';
|
||||
import { SignupComponent } from './component/signup/signup.component';
|
||||
import { ResetPasswordComponent } from './component/reset-password/reset-password.component';
|
||||
import { MemberService } from './service/member.service';
|
||||
import { AuthGuard } from './guard/auth.guard';
|
||||
|
||||
import { MemberStoreModule } from './member-store.module';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ModifyComponent,
|
||||
SigninComponent,
|
||||
SignupComponent,
|
||||
ResetPasswordComponent,
|
||||
];
|
||||
import { COMPONENTS } from './component';
|
||||
import { SERVICES } from './service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -30,11 +21,14 @@ export const COMPONENTS = [
|
|||
MaterialModule,
|
||||
MemberStoreModule,
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
providers: [
|
||||
AuthGuard,
|
||||
MemberService,
|
||||
SERVICES,
|
||||
],
|
||||
})
|
||||
export class MemberModule { }
|
||||
|
|
5
src/packages/member/service/index.ts
Normal file
5
src/packages/member/service/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { MemberService } from './member.service';
|
||||
|
||||
export const SERVICES = [
|
||||
MemberService,
|
||||
];
|
|
@ -1,7 +0,0 @@
|
|||
import * as AuthStore from './auth';
|
||||
import * as SignupStore from './signup';
|
||||
|
||||
export const EFFECTS = [
|
||||
AuthStore.Effects,
|
||||
SignupStore.Effects,
|
||||
];
|
|
@ -6,3 +6,12 @@ export interface State {
|
|||
signup: SignupStore.Signup;
|
||||
}
|
||||
|
||||
export const REDUCERS = {
|
||||
auth: AuthStore.reducer,
|
||||
signup: SignupStore.reducer,
|
||||
};
|
||||
|
||||
export const EFFECTS = [
|
||||
AuthStore.Effects,
|
||||
SignupStore.Effects,
|
||||
];
|
|
@ -1,7 +0,0 @@
|
|||
import * as AuthStore from './auth';
|
||||
import * as SignupStore from './signup';
|
||||
|
||||
export const reducers = {
|
||||
auth: AuthStore.reducer,
|
||||
signup: SignupStore.reducer,
|
||||
};
|
5
src/packages/noauth/component/index.ts
Normal file
5
src/packages/noauth/component/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { ListComponent } from './list/list.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ListComponent,
|
||||
];
|
|
@ -1,17 +1,17 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { ListComponent } from './component/list/list.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ListComponent,
|
||||
];
|
||||
import { COMPONENTS } from './component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
})
|
||||
export class NoauthModule { }
|
||||
|
|
5
src/packages/notification/component/index.ts
Normal file
5
src/packages/notification/component/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { NotificationComponent } from './notification/notification.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
NotificationComponent,
|
||||
];
|
|
@ -6,12 +6,7 @@ import {
|
|||
|
||||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||
|
||||
import { NotificationComponent } from './component/notification/notification.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
NotificationComponent,
|
||||
];
|
||||
|
||||
import { COMPONENTS } from './component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -19,7 +14,11 @@ export const COMPONENTS = [
|
|||
PerfectScrollbarModule,
|
||||
MaterialModule,
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
})
|
||||
export class NotificationModule { }
|
||||
|
|
9
src/packages/probe/component/index.ts
Normal file
9
src/packages/probe/component/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { DetailComponent } from './detail/detail.component';
|
||||
import { ListComponent } from './list/list.component';
|
||||
import { DownloadComponent } from './download/download.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ListComponent,
|
||||
DetailComponent,
|
||||
DownloadComponent,
|
||||
];
|
|
@ -3,15 +3,7 @@ import { CommonModule } from '@angular/common';
|
|||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||
import { InfoTableModule } from 'app/commons/component/info-table/info-table.module';
|
||||
|
||||
import { DetailComponent } from './component/detail/detail.component';
|
||||
import { ListComponent } from './component/list/list.component';
|
||||
import { DownloadComponent } from './component/download/download.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ListComponent,
|
||||
DetailComponent,
|
||||
DownloadComponent,
|
||||
];
|
||||
import { COMPONENTS } from './component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -19,7 +11,11 @@ export const COMPONENTS = [
|
|||
MaterialModule,
|
||||
InfoTableModule,
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
})
|
||||
export class ProbeModule { }
|
||||
|
|
5
src/packages/sensor-item/component/index.ts
Normal file
5
src/packages/sensor-item/component/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { ListComponent } from './list/list.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ListComponent,
|
||||
];
|
|
@ -1,11 +1,7 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||
import { ListComponent } from './component/list/list.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ListComponent,
|
||||
];
|
||||
import { COMPONENTS } from './component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
@ -13,7 +9,11 @@ export const COMPONENTS = [
|
|||
CommonModule,
|
||||
MaterialModule,
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
})
|
||||
export class SensorItemModule { }
|
||||
|
|
7
src/packages/sensor/component/index.ts
Normal file
7
src/packages/sensor/component/index.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { DiscoverySettingComponent } from './setting/setting.component';
|
||||
import { SettingResultComponent } from './setting-result/setting-result.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
DiscoverySettingComponent,
|
||||
SettingResultComponent,
|
||||
];
|
|
@ -4,13 +4,7 @@ import {FormsModule} from '@angular/forms';
|
|||
|
||||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||
|
||||
import { DiscoverySettingComponent } from './component/setting/setting.component';
|
||||
import { SettingResultComponent } from './component/setting-result/setting-result.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
DiscoverySettingComponent,
|
||||
SettingResultComponent,
|
||||
];
|
||||
import { COMPONENTS } from './component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -18,7 +12,11 @@ export const COMPONENTS = [
|
|||
MaterialModule,
|
||||
FormsModule
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
})
|
||||
export class SensorModule { }
|
||||
|
|
7
src/packages/target/component/index.ts
Normal file
7
src/packages/target/component/index.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { DetailComponent } from './detail/detail.component';
|
||||
import { ListComponent } from './list/list.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ListComponent,
|
||||
DetailComponent,
|
||||
];
|
|
@ -3,13 +3,7 @@ import { CommonModule } from '@angular/common';
|
|||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||
import { InfoTableModule } from 'app/commons/component/info-table/info-table.module';
|
||||
|
||||
import { DetailComponent } from './component/detail/detail.component';
|
||||
import { ListComponent } from './component/list/list.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
ListComponent,
|
||||
DetailComponent,
|
||||
];
|
||||
import { COMPONENTS } from './component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -17,7 +11,11 @@ export const COMPONENTS = [
|
|||
MaterialModule,
|
||||
InfoTableModule
|
||||
],
|
||||
declarations: COMPONENTS,
|
||||
exports: COMPONENTS,
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
],
|
||||
exports: [
|
||||
COMPONENTS,
|
||||
],
|
||||
})
|
||||
export class TargetModule { }
|
||||
|
|
Loading…
Reference in New Issue
Block a user