This commit is contained in:
crusader 2018-03-11 20:54:56 +09:00
parent 41beac9712
commit 3293add02f
67 changed files with 801 additions and 300 deletions

View File

@ -9,10 +9,10 @@ import {
import { EffectsModule } from '@ngrx/effects'; import { EffectsModule } from '@ngrx/effects';
import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store'; import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
import { SimpleRouterStateSerializer } from 'packages/commons/util/router/state/serializer/simple-router-state-serializer';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
import { EFFECTS } from './commons/store';
import { SimpleRouterStateSerializer } from 'packages/commons/util/router/state/serializer/simple-router-state-serializer';
export interface AppState { export interface AppState {
} }
@ -51,7 +51,7 @@ export const reducers: ActionReducerMap<AppState> = {
maxAge: 50, maxAge: 50,
logOnly: environment.production, logOnly: environment.production,
}), }),
EffectsModule.forRoot([]), EffectsModule.forRoot(EFFECTS),
], ],
providers: [ providers: [
/** /**

View File

@ -5,6 +5,16 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import { RPCClientCodec } from 'packages/core/rpc/protocol/RPCClientCodec';
import { RPCClientJSONCodec } from 'packages/core/rpc/protocol/json/RPCClientJSONCodec';
import { RPCClientRWC } from 'packages/core/rpc/client/rwc/RPCClientRWC';
import { RPCClientWebsocketRWC } from 'packages/core/rpc/client/rwc/websocket/RPCClientWebsocketRWC';
import { RxWebsocketSubjectConfig } from 'packages/core/websocket/RxWebsocketSubject';
import { RESTClient } from 'packages/core/rest/client/RESTClient';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { AppStoreModule } from './app-store.module'; import { AppStoreModule } from './app-store.module';
import { AppL10NModule } from './app-l10n.module'; import { AppL10NModule } from './app-l10n.module';
@ -15,8 +25,9 @@ import { CovalentModule } from './commons/ui/covalent/covalent.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
import { RESTService } from 'packages/commons/service/rest.service'; import { RPCService } from './commons/service/rpc.service';
import { RPCService } from 'packages/commons/service/rpc.service'; import { RESTService } from './commons/service/rest.service';
@NgModule({ @NgModule({
imports: [ imports: [
@ -31,8 +42,20 @@ import { RPCService } from 'packages/commons/service/rpc.service';
], ],
providers: [ providers: [
{provide: 'REST_BASE_URL', useValue: environment.restBaseURL}, {provide: 'REST_BASE_URL', useValue: environment.restBaseURL},
{provide: 'RPC_BASE_URL', useValue: environment.rpcBaseURL}, {provide: 'WEBAPP_RPC_CONFIG', useValue: environment.webappRPCConfig},
RESTService, RPCService,
{provide: RPCClientCodec, useFactory: () => new RPCClientJSONCodec()},
{
provide: RPCClientRWC,
useFactory: (config: RxWebsocketSubjectConfig) => new RPCClientWebsocketRWC(config),
deps: ['WEBAPP_RPC_CONFIG']
},
{
provide: RESTClient, useClass: RESTService
},
{
provide: RPCClient, useClass: RPCService
},
], ],
declarations: [ declarations: [
AppComponent, AppComponent,

View File

@ -0,0 +1,26 @@
import { Injectable, Inject } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { Location } from '@angular/common';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/timeout';
import 'rxjs/add/observable/throw';
import { RESTClient } from 'packages/core/rest/client/RESTClient';
@Injectable()
export class RESTService extends RESTClient {
constructor(
@Inject('REST_BASE_URL') _baseURL: string,
@Inject(HttpClient) _httpClient: HttpClient,
) {
super(_baseURL, _httpClient);
}
}

View File

@ -0,0 +1,19 @@
import { Injectable, Inject } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import { RPCClientCodec } from 'packages/core/rpc/protocol/RPCClientCodec';
import { RPCClientRWC } from 'packages/core/rpc/client/rwc/RPCClientRWC';
@Injectable()
export class RPCService extends RPCClient {
constructor(
private _rpcClientCodec: RPCClientCodec,
private _rpcClientRWC: RPCClientRWC,
) {
super(_rpcClientCodec, _rpcClientRWC);
}
}

View File

@ -0,0 +1,5 @@
import * as SigninInitStore from './signin-init';
export const EFFECTS = [
SigninInitStore.Effects,
];

View File

@ -0,0 +1 @@
export * from './signin-init.effect';

View File

@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';
import { Effects } from './signin-init.effect';
describe('SigninInit.Effects', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [Effects]
});
});
it('should be created', inject([Effects], (effects: Effects) => {
expect(effects).toBeTruthy();
}));
});

View File

@ -0,0 +1,43 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/exhaustMap';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take';
import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import {
Signin,
SigninSuccess,
SigninFailure,
ActionType,
} from 'packages/member/store/auth';
@Injectable()
export class Effects {
constructor(
private actions$: Actions,
private rpcClient: RPCClient,
) { }
@Effect({ dispatch: false })
signinSuccess$ = this.actions$
.ofType(ActionType.SigninSuccess)
.do(
() => {
this.rpcClient.connect();
}
);
}

View File

@ -17,10 +17,10 @@ export interface Codec {
} }
export const defaultCodec: Codec = { export const defaultCodec: Codec = {
encode: (e: MessageEvent) => { decode: (e: MessageEvent) => {
return JSON.parse(e.data); return JSON.parse(e.data);
}, },
decode: (data: any): string => { encode: (data: any): string => {
return JSON.stringify(data); return JSON.stringify(data);
} }
}; };
@ -59,7 +59,7 @@ export class RxWebsocketSubject<T> extends Subject<T> {
this.connectionObserver.next(true); this.connectionObserver.next(true);
} }
}, },
resultSelector: this.codec.decode, // resultSelector: this.codec.decode,
}; };
this._connectionStatus.subscribe((isConnected: boolean) => { this._connectionStatus.subscribe((isConnected: boolean) => {
@ -116,6 +116,7 @@ export class RxWebsocketSubject<T> extends Subject<T> {
} }
public send(data: any): void { public send(data: any): void {
const s = this.codec.encode(data);
this.socket.next(this.codec.encode(data)); this.socket.next(this.codec.encode(data));
} }
} }

View File

@ -6,8 +6,13 @@
export const environment = { export const environment = {
production: false, production: false,
restBaseURL: 'http://192.168.1.101:19080', restBaseURL: 'http://192.168.1.101:19080',
rpcBaseURL: 'ws://192.168.1.101/webapp', webappRPCConfig: {
url: 'ws://192.168.1.101:19090/webapp',
reconnectInterval: 5000,
reconnectRetry: 10,
},
}; };
export const palete = { export const palete = {
primary: '#D32F2F', primary: '#D32F2F',
accent: '#E65100', accent: '#E65100',

View File

@ -1,32 +0,0 @@
import { HttpErrorResponse } from '@angular/common/http';
export class ErrorResponse {
private constructor(
private _code: number,
private _exception: string,
private _message: string,
) {
}
public get code(): number {
return this._code;
}
public get exception(): string {
return this._exception;
}
public get message(): string {
return this._message;
}
public static restError(errorResponse: HttpErrorResponse): ErrorResponse {
const aryMsg = errorResponse.error.message.split('|');
const resError: ErrorResponse = new ErrorResponse(
errorResponse.error.code,
aryMsg[0],
aryMsg[1] === 'null' ? '' : aryMsg[1],
);
return resError;
}
}

View File

@ -1,58 +0,0 @@
import { Injectable, Inject } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { Location } from '@angular/common';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/timeout';
import 'rxjs/add/observable/throw';
import { ErrorResponse } from './error-response';
@Injectable()
export class RESTService {
private readonly httpHeaders: HttpHeaders;
constructor(
@Inject('REST_BASE_URL') private _baseURL: string,
@Inject(HttpClient) private _httpClient: HttpClient,
) {
this.httpHeaders = new HttpHeaders()
.set('Content-Type', 'application/json');
}
public get httpClient(): HttpClient {
return this._httpClient;
}
public get<T>(entry: string, params?: {[param: string]: string | string[]}): Observable<T> {
const headers: HttpHeaders = this.httpHeaders;
return this._httpClient
.get(Location.joinWithSlash(this._baseURL, entry), {
headers: headers,
params: params,
responseType: 'json',
})
.map((response: string) => <T>JSON.parse(response))
.catch((error: HttpErrorResponse) => Observable.throw(ErrorResponse.restError(error)));
}
public post<T>(entry: string, body: any | null, params?: {[param: string]: string | string[]}): Observable<T> {
const headers: HttpHeaders = this.httpHeaders;
return this._httpClient
.post(Location.joinWithSlash(this._baseURL, entry), body, {
headers: headers,
params: params,
responseType: 'json',
})
.map((response: string) => <T>JSON.parse(response))
.catch((error: HttpErrorResponse) => Observable.throw(ErrorResponse.restError(error)));
}
}

View File

@ -1,68 +0,0 @@
import { Injectable, Inject } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { RxWebsocketSubject } from 'app/core/rx/websocket/rx-websocket-subject';
import { RPCRegistry } from 'app/core/rpc/registry/rpc-registry';
@Injectable()
export class RPCService {
private wsSocketSubject: RxWebsocketSubject<Object>;
private rpcRegistry: RPCRegistry;
constructor(
@Inject('RPC_BASE_URL') private _baseURL: string,
) {
this.wsSocketSubject = new RxWebsocketSubject<Object>(this._baseURL);
}
public connect(): void {
this.wsSocketSubject.connect();
this.wsSocketSubject.subscribe(
(value: Object) => {
this.onMessage(value);
},
(error: any) => {
this.onError(error);
},
() => {
this.onDisconnected();
}
);
}
public call<T>(method: string, ...args: any[]): Observable<T> {
return undefined;
}
public callTimeout<T>(method: string, ...args: any[]): Observable<T> {
return undefined;
}
public send(method: string, ...args: any[]): void {
}
private sendInternal(data: Object): void {
this.wsSocketSubject.next(data);
}
public getConnectionStatus(): Observable<boolean> {
return this.wsSocketSubject.connectionStatus;
}
private onMessage(message: Object): void {
//
console.log(message);
}
private onError(error: any): void {
//
console.log(error);
}
private onDisconnected(): void {
//
console.log('disconnected');
}
}

View File

@ -0,0 +1,57 @@
import { Injectable, Inject } from '@angular/core';
import { Location } from '@angular/common';
import { HttpClient, HttpHeaders, HttpParams, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/timeout';
import 'rxjs/add/observable/throw';
import { RESTError } from '../error';
export class RESTClient {
private readonly httpHeaders: HttpHeaders;
constructor(
private _baseURL: string,
private _httpClient: HttpClient,
) {
this.httpHeaders = new HttpHeaders()
.set('Content-Type', 'application/json');
}
public get httpClient(): HttpClient {
return this._httpClient;
}
public request<T>(method: string, entry: string, options?: {
body?: any;
headers?: HttpHeaders | {
[header: string]: string | string[];
};
observe?: 'body';
params?: HttpParams | {
[param: string]: string | string[];
};
responseType?: 'json';
reportProgress?: boolean;
withCredentials?: boolean;
}): Observable<T> {
const headers: HttpHeaders = this.httpHeaders;
return this._httpClient
.request(method, Location.joinWithSlash(this._baseURL, entry), options)
.map((response: string) => <T>JSON.parse(response))
.catch((error: HttpErrorResponse) => {
const aryMsg = error.error.message.split('|');
const resError: RESTError = {
code: error.error.code,
message: aryMsg[0],
data: aryMsg[1] === 'null' ? '' : aryMsg[1],
};
return Observable.throw(resError);
});
}
}

View File

@ -0,0 +1,5 @@
export interface RESTError {
code: number;
message: string;
data?: any;
}

View File

@ -0,0 +1,113 @@
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { RPCClientRWC } from './rwc/RPCClientRWC';
import { RPCRegistry } from './../registry/RPCRegistry';
import { RPCClientCodec, RPCClientResponseCodec } from '../protocol/RPCClientCodec';
export class RPCClient {
private _requestID: number;
private _pendingRequestsCount: number;
private _pendingRequests: Map<number, Subject<any>>;
public constructor(
private _codec: RPCClientCodec,
private _rwc: RPCClientRWC,
) {
this._requestID = 0;
this._pendingRequestsCount = 0;
this._pendingRequests = new Map();
}
private getRequestID(): number {
return ++this._requestID;
}
/**
* connect
*/
public connect(): void {
this._rwc.connect();
this._rwc.readResponse().subscribe(
(value: Object) => {
this.onMessage(value);
},
(error: any) => {
},
() => {
}
);
}
/**
* close
*/
public disconnect() {
this._rwc.disconnect();
}
/**
* notify
*/
public notify(method: string, ...args: any[]): void {
this.send(false, method, args);
}
/**
* call
*/
public call<T>(method: string, ...args: any[]): Observable<T> {
return this.send<T>(true, method, args);
}
/**
* callTimeout
*/
public callTimeout<T>(ms: number, method: string, ...args: any[]): Observable<T> {
return undefined;
}
private send<T>(hasResponse: boolean, method: string, args?: any[]): Observable<T> | undefined {
let id: number;
let resSubject: Subject<T>;
if (hasResponse) {
id = this.getRequestID();
resSubject = new Subject<T>();
this._pendingRequests.set(id, resSubject);
this._pendingRequestsCount++;
}
const req = this._codec.request(method, args, id);
this._rwc.writeRequest(req);
if (undefined !== resSubject) {
return resSubject.asObservable();
}
}
private onMessage(message: Object): void {
const resCodec = this._codec.response(message);
if (undefined !== resCodec.id()) {
this.onResponse(resCodec);
}
}
protected onResponse(resCodec: RPCClientResponseCodec): void {
const id = resCodec.id();
const result = resCodec.result();
const error = resCodec.error();
const resSubject: Subject<any> = this._pendingRequests.get(id);
this._pendingRequests.delete(id);
this._pendingRequestsCount--;
if (undefined !== result) {
resSubject.next(result);
} else if (undefined !== error) {
resSubject.error(error);
}
}
}

View File

@ -0,0 +1,11 @@
import { InjectionToken } from '@angular/core';
import { Observable } from 'rxjs/Observable';
export abstract class RPCClientRWC {
public abstract connect(): void;
public abstract readResponse(): Observable<Object>;
public abstract writeRequest(data: any): void;
public abstract disconnect(): void;
public abstract connectionStatus(): Observable<boolean>;
}

View File

@ -0,0 +1,59 @@
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { map } from 'rxjs/operator/map';
import {
RxWebsocketSubject,
RxWebsocketSubjectConfig,
} from 'packages/core/websocket/RxWebsocketSubject';
import { RPCClientRWC } from '../RPCClientRWC';
export class RPCClientWebsocketRWC extends RPCClientRWC {
private _wsSocketSubject: RxWebsocketSubject<Object>;
private _responseSubject: Subject<Object>;
public constructor(
private _config: RxWebsocketSubjectConfig,
) {
super();
this._wsSocketSubject = new RxWebsocketSubject<Object>(this._config);
}
public connect(): void {
this._wsSocketSubject.connect();
this._wsSocketSubject.subscribe(
(value: Object) => {
if (undefined !== this._responseSubject) {
this._responseSubject.next(value);
}
},
(error: any) => {
if (undefined !== this._responseSubject) {
this._responseSubject.error(error);
}
},
() => {
}
);
}
public disconnect(): void {
this._wsSocketSubject.disconnect();
}
public connectionStatus(): Observable<boolean> {
return this._wsSocketSubject.connectionStatus;
}
public readResponse(): Observable<Object> {
if (undefined === this._responseSubject) {
this._responseSubject = new Subject<Object>();
}
return this._responseSubject.asObservable();
}
public writeRequest(data: any): void {
this._wsSocketSubject.write(data);
}
}

View File

@ -0,0 +1,33 @@
/**
* Error object representation when a method invocation fails.
*/
export interface RPCError {
/** Indicates the error type that occurred. */
code: ErrorCode;
/** A short description of the error. */
message: string;
/** Additional information about the error */
data?: any;
}/*
/** Error codes are same as xml-rpc codes. See http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php */
export const enum ErrorCode {
/** Parse error Invalid JSON was received by the Server. */
ParseError = -32700,
/** Invalid Request The JSON sent is not a valid Request object. */
InvalidRequest = -32600,
/** The method does not exist / is not available. */
MethodNotFound = -32601,
/** Invalid method parameter(s). */
InvalidParams = - -32602,
/** Internal JSON-RPC error. */
InternalError = -32603
/** -32000 to -32099: Reserved for implementation-defined Server errors. */
}

View File

@ -0,0 +1,12 @@
import { RPCError } from '../error';
export abstract class RPCClientCodec {
abstract request(method: string, args: any[], id: number): any;
abstract response(res: any): RPCClientResponseCodec;
}
export abstract class RPCClientResponseCodec {
abstract id(): number | undefined;
abstract error(): RPCError | undefined;
abstract result(): any | undefined;
}

View File

@ -0,0 +1,59 @@
import {
RPCClientCodec,
RPCClientResponseCodec,
} from '../RPCClientCodec';
import {
RPCError,
} from '../../error';
export interface ClientRequest {
jsonrpc: string;
method: string;
params?: any[];
id?: number;
}
export interface ClientResponse {
jsonrpc: string;
result?: any;
error?: RPCError;
id?: number;
}
export class RPCClientJSONCodec extends RPCClientCodec {
public request(method: string, args: any[], id?: number): any {
const req: ClientRequest = {
jsonrpc: '2.0',
method: method,
params: args,
id: id,
};
return JSON.stringify(req);
}
public response(res: any): RPCClientResponseCodec {
const _res: ClientResponse = {
id: res.id,
jsonrpc: res.jsonrpc,
result: undefined !== res.result ? JSON.parse(res.result) : undefined,
error: undefined !== res.error ? JSON.parse(res.error) : undefined,
};
return new RPCClientJSONResponseCodec(_res);
}
}
export class RPCClientJSONResponseCodec extends RPCClientResponseCodec {
public constructor(private _res: ClientResponse) {
super();
}
public id(): number | undefined {
return this._res.id;
}
public error(): RPCError | undefined {
return this._res.error;
}
public result(): any | undefined {
return this._res.result;
}
}

View File

@ -0,0 +1,17 @@
export class RPCInvoker {
/**
* hasMethod
*/
public hasMethod(method: string): boolean {
return false;
}
/**
* invoke
*/
public invoke() {
}
}

View File

@ -0,0 +1,18 @@
import { RPCInvoker } from './RPCInvoker';
export class RPCRegistry extends RPCInvoker {
/**
* registerService
*/
public registerService<T>(receiver: T, name: string) {
}
/**
* getService
*/
public getService<T>(name: string): T {
return undefined;
}
}

View File

@ -0,0 +1,103 @@
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 RxWebsocketSubjectConfig {
url: string;
protocol?: string | Array<string>;
reconnectInterval?: 5000;
reconnectRetry?: 10;
}
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>;
public constructor(private _config: RxWebsocketSubjectConfig) {
super();
this._connectionStatus = new Observable<boolean>((observer) => {
this._connectionObserver = observer;
}).share().distinctUntilChanged();
this._wsSubjectConfig = {
url: _config.url,
protocol: _config.protocol,
closeObserver: {
next: (e: CloseEvent) => {
this._socket = null;
this._connectionObserver.next(false);
}
},
openObserver: {
next: (e: Event) => {
this._connectionObserver.next(true);
}
},
};
this._connectionStatus.subscribe((isConnected: boolean) => {
if (!this._reconnectionObservable && typeof(isConnected) === 'boolean' && !isConnected) {
this.reconnect();
}
});
}
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();
}
}
);
}
public disconnect(): void {
this._socket.complete();
}
private reconnect(): void {
this._reconnectionObservable = Observable.interval(this._config.reconnectInterval)
.takeWhile((v, index) => {
return index < this._config.reconnectRetry && !this._socket;
});
this._reconnectionObservable.subscribe(
() => {
this.connect();
},
null,
() => {
this._reconnectionObservable = null;
if (!this._socket) {
this.complete();
this._connectionObserver.complete();
}
}
);
}
public write(data: any): void {
this._socket.next(data);
}
}

View File

@ -3,7 +3,7 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { RESTService } from 'packages/commons/service/rest.service'; import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import { DiscoveryStartInfo } from '../model'; import { DiscoveryStartInfo } from '../model';
@ -11,7 +11,7 @@ import { DiscoveryStartInfo } from '../model';
export class DiscoveryService { export class DiscoveryService {
public constructor( public constructor(
private restService: RESTService, private rpcClient: RPCClient,
) { ) {
} }
@ -22,7 +22,7 @@ export class DiscoveryService {
// signinPw: password, // signinPw: password,
// }; // };
return this.restService.post('/discovery/start', dsInfo); return this.rpcClient.call('DiscoveryService.start', dsInfo);
} }
// public signup(member: DiscoveryStartInfo): Observable<DiscoveryStartInfo> { // public signup(member: DiscoveryStartInfo): Observable<DiscoveryStartInfo> {

View File

@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { DiscoveryStartInfo } from '../../model'; import { DiscoveryStartInfo } from '../../model';
@ -26,7 +26,7 @@ export class SettingSuccess implements Action {
export class SettingFailure implements Action { export class SettingFailure implements Action {
readonly type = ActionType.SettingFailure; readonly type = ActionType.SettingFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RPCError) {}
} }
export class SettingRedirect implements Action { export class SettingRedirect implements Action {

View File

@ -14,7 +14,7 @@ import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take'; import 'rxjs/add/operator/take';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { DiscoveryStartInfo } from '../../model'; import { DiscoveryStartInfo } from '../../model';
import { DiscoveryService } from '../../service/discovery.service'; import { DiscoveryService } from '../../service/discovery.service';
@ -43,7 +43,7 @@ export class Effects {
.map(discoveryStartInfo => { .map(discoveryStartInfo => {
return new SettingSuccess(discoveryStartInfo); return new SettingSuccess(discoveryStartInfo);
}) })
.catch((error: ErrorResponse) => { .catch((error: RPCError) => {
return of(new SettingFailure(error)); return of(new SettingFailure(error));
}); });

View File

@ -1,4 +1,4 @@
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { import {
Actions, Actions,

View File

@ -1,10 +1,10 @@
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { DiscoveryStartInfo } from '../../model'; import { DiscoveryStartInfo } from '../../model';
export interface State { export interface State {
isStart: boolean; isStart: boolean;
error: ErrorResponse | null; error: RPCError | null;
isPending: boolean; isPending: boolean;
discoveryStartInfo: DiscoveryStartInfo | null; discoveryStartInfo: DiscoveryStartInfo | null;
} }

View File

@ -3,7 +3,7 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { RESTService } from 'packages/commons/service/rest.service'; import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import { Infra } from '../model'; import { Infra } from '../model';
import { Page } from '../../../app/commons/model'; import { Page } from '../../../app/commons/model';
@ -14,16 +14,16 @@ import { Probe } from '../../probe/model';
export class InfraService { export class InfraService {
public constructor( public constructor(
private restService: RESTService, private rpcClient: RPCClient,
) { ) {
} }
public readByDomain(domain: Domain): Observable<Page> { public readByDomain(domain: Domain): Observable<Page> {
return this.restService.post<Page>('/account/signin', domain); return this.rpcClient.call<Page>('InfraService.', domain);
} }
public readByProbe(probe: Probe): Observable<Page> { public readByProbe(probe: Probe): Observable<Page> {
return this.restService.post<Page>('/account/signup', probe); return this.rpcClient.call<Page>('InfraService.', probe);
} }
} }

View File

@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Infra } from '../../model'; import { Infra } from '../../model';
import { Page } from '../../../../app/commons/model'; import { Page } from '../../../../app/commons/model';
@ -26,7 +26,7 @@ export class ReadbydomainSuccess implements Action {
export class ReadbydomainFailure implements Action { export class ReadbydomainFailure implements Action {
readonly type = ActionType.ReadbydomainFailure; readonly type = ActionType.ReadbydomainFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RPCError) {}
} }
export type Actions = export type Actions =

View File

@ -13,7 +13,7 @@ import 'rxjs/add/operator/exhaustMap';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take'; import 'rxjs/add/operator/take';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Infra } from '../../model'; import { Infra } from '../../model';
import { InfraService } from '../../service/infra.service'; import { InfraService } from '../../service/infra.service';

View File

@ -3,13 +3,14 @@ import {
MemoizedSelector, MemoizedSelector,
} from '@ngrx/store'; } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Infra } from '../../model'; import { Infra } from '../../model';
import { Page } from '../../../../app/commons/model'; import { Page } from '../../../../app/commons/model';
export interface State { export interface State {
isSignin: boolean; isSignin: boolean;
error: ErrorResponse | null; error: RPCError | null;
isPending: boolean; isPending: boolean;
infraList: Page | null; infraList: Page | null;
} }

View File

@ -3,8 +3,6 @@ import { Router } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response';
import * as AuthStore from '../../store/auth'; import * as AuthStore from '../../store/auth';
import { AuthSelector } from '../../store'; import { AuthSelector } from '../../store';
@ -55,14 +53,14 @@ export class SigninComponent implements OnInit {
initForm() { initForm() {
this.signinForm = this.formBuilder.group({ this.signinForm = this.formBuilder.group({
'email': [ 'email': [
'', 'overflow@loafle.com',
[ [
Validators.required, Validators.required,
Validators.email Validators.email
] ]
], ],
'password': [ 'password': [
'', '!@#$qwer1234',
[ [
Validators.pattern('^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$'), Validators.pattern('^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$'),
Validators.minLength(6), Validators.minLength(6),

View File

@ -3,7 +3,7 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { RESTService } from 'packages/commons/service/rest.service'; import { RESTClient } from 'packages/core/rest/client/RESTClient';
import { DomainMember } from 'packages/domain/model'; import { DomainMember } from 'packages/domain/model';
import { Member } from '../model'; import { Member } from '../model';
@ -12,7 +12,7 @@ import { Member } from '../model';
export class MemberService { export class MemberService {
public constructor( public constructor(
private restService: RESTService, private restClient: RESTClient,
) { ) {
} }
@ -23,10 +23,14 @@ export class MemberService {
signinPw: password, signinPw: password,
}; };
return this.restService.post<DomainMember>('/account/signin', body); return this.restClient.request<DomainMember>('post', '/account/signin', {
body: body,
});
} }
public signup(member: Member): Observable<Member> { public signup(member: Member): Observable<Member> {
return this.restService.post<Member>('/account/signup', member); return this.restClient.request<Member>('post', '/account/signup', {
body: member,
});
} }
} }

View File

@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RESTError } from 'packages/core/rest/error';
import { DomainMember } from 'packages/domain/model'; import { DomainMember } from 'packages/domain/model';
import { Member } from '../../model'; import { Member } from '../../model';
@ -30,7 +30,7 @@ export class SigninSuccess implements Action {
export class SigninFailure implements Action { export class SigninFailure implements Action {
readonly type = ActionType.SigninFailure; readonly type = ActionType.SigninFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RESTError) {}
} }
export class SigninRedirect implements Action { export class SigninRedirect implements Action {
@ -48,7 +48,7 @@ export class SignoutSuccess implements Action {
export class SignoutFailure implements Action { export class SignoutFailure implements Action {
readonly type = ActionType.SignoutFailure; readonly type = ActionType.SignoutFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RESTError) {}
} }
export type Actions = export type Actions =

View File

@ -14,7 +14,7 @@ import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take'; import 'rxjs/add/operator/take';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RESTError } from 'packages/core/rest/error';
import { DomainMember } from 'packages/domain/model'; import { DomainMember } from 'packages/domain/model';
@ -45,7 +45,7 @@ export class Effects {
.map((domainMember: DomainMember) => { .map((domainMember: DomainMember) => {
return new SigninSuccess(domainMember); return new SigninSuccess(domainMember);
}) })
.catch((error: ErrorResponse) => { .catch((error: RESTError) => {
return of(new SigninFailure(error)); return of(new SigninFailure(error));
}); });

View File

@ -1,5 +1,3 @@
import { ErrorResponse } from 'packages/commons/service/error-response';
import { import {
Actions, Actions,
ActionType, ActionType,

View File

@ -1,10 +1,10 @@
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RESTError } from 'packages/core/rest/error';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
import { Member } from '../../model'; import { Member } from '../../model';
export interface State { export interface State {
signined: boolean; signined: boolean;
error: ErrorResponse | null; error: RESTError | null;
pending: boolean; pending: boolean;
member: Member | null; member: Member | null;
domain: Domain | null; domain: Domain | null;

View File

@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RESTError } from 'packages/core/rest/error';
import { Member } from '../../model'; import { Member } from '../../model';
@ -25,7 +25,7 @@ export class SignupSuccess implements Action {
export class SignupFailure implements Action { export class SignupFailure implements Action {
readonly type = ActionType.SignupFailure; readonly type = ActionType.SignupFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RESTError) {}
} }
export type Actions = export type Actions =

View File

@ -13,7 +13,7 @@ import 'rxjs/add/operator/exhaustMap';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take'; import 'rxjs/add/operator/take';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RESTError } from 'packages/core/rest/error';
import { Member } from '../../model'; import { Member } from '../../model';
import { MemberService } from '../../service/member.service'; import { MemberService } from '../../service/member.service';

View File

@ -1,9 +1,9 @@
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RESTError } from 'packages/core/rest/error';
import { Member } from '../../model'; import { Member } from '../../model';
export interface State { export interface State {
error: ErrorResponse | null; error: RESTError | null;
pending: boolean; pending: boolean;
member: Member | null; member: Member | null;
} }

View File

@ -3,8 +3,7 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { RESTService } from 'packages/commons/service/rest.service'; import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import { MetaCrawler } from '../model'; import { MetaCrawler } from '../model';
@ -12,7 +11,7 @@ import { MetaCrawler } from '../model';
export class CrawlerService { export class CrawlerService {
public constructor( public constructor(
private restService: RESTService, private rpcClient: RPCClient,
) { ) {
} }
@ -23,10 +22,10 @@ export class CrawlerService {
signinPw: password, signinPw: password,
}; };
return this.restService.post<MetaCrawler>('/account/signin', body); return this.rpcClient.call<MetaCrawler>('CrawlerService.', body);
} }
public readAll(): Observable<MetaCrawler[]> { public readAll(): Observable<MetaCrawler[]> {
return this.restService.post<MetaCrawler[]>('/account/signup', null); return this.rpcClient.call<MetaCrawler[]>('CrawlerService.');
} }
} }

View File

@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { MetaCrawler } from '../../model'; import { MetaCrawler } from '../../model';
@ -26,7 +26,7 @@ export class ReadAllSuccess implements Action {
export class ReadAllFailure implements Action { export class ReadAllFailure implements Action {
readonly type = ActionType.ReadAllFailure; readonly type = ActionType.ReadAllFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RPCError) {}
} }
export type Actions = export type Actions =

View File

@ -14,7 +14,7 @@ import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take'; import 'rxjs/add/operator/take';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { DomainMember } from 'packages/domain/model'; import { DomainMember } from 'packages/domain/model';
@ -45,7 +45,7 @@ export class Effects {
.map((metaCrawlerList: MetaCrawler[]) => { .map((metaCrawlerList: MetaCrawler[]) => {
return new ReadAllSuccess(metaCrawlerList); return new ReadAllSuccess(metaCrawlerList);
}) })
.catch((error: ErrorResponse) => { .catch((error: RPCError) => {
return of(new ReadAllFailure(error)); return of(new ReadAllFailure(error));
}); });

View File

@ -1,5 +1,3 @@
import { ErrorResponse } from 'packages/commons/service/error-response';
import { import {
Actions, Actions,
ActionType, ActionType,

View File

@ -1,9 +1,9 @@
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { MetaCrawler } from '../../model'; import { MetaCrawler } from '../../model';
export interface State { export interface State {
error: ErrorResponse | null; error: RPCError | null;
pending: boolean; pending: boolean;
metaCrawlerList: MetaCrawler[] | null; metaCrawlerList: MetaCrawler[] | null;
} }

View File

@ -2,9 +2,14 @@ import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatSort } from '@angular/material'; import { MatTableDataSource, MatSort } from '@angular/material';
import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks'; import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Store } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { AuthSelector } from 'packages/member/store';
import { RPCError } from 'packages/core/rpc/error';
import { Domain } from 'packages/domain/model';
import * as ListStore from '../../store/noauth-probe'; import * as ListStore from '../../store/noauth-probe';
import { Domain } from '../../../domain/model'; import { NoAuthProbeSelector } from '../../store';
import { NoAuthProbe } from '../../model'; import { NoAuthProbe } from '../../model';
@Component({ @Component({
@ -13,6 +18,7 @@ import { NoAuthProbe } from '../../model';
styleUrls: ['./list.component.scss'] styleUrls: ['./list.component.scss']
}) })
export class ListComponent implements OnInit, AfterContentInit { export class ListComponent implements OnInit, AfterContentInit {
noAuthProbes$ = this.store.pipe(select(NoAuthProbeSelector.select('noAuthProbes')));
selected: NoAuthProbe = null; selected: NoAuthProbe = null;
@ -23,27 +29,39 @@ export class ListComponent implements OnInit, AfterContentInit {
constructor( constructor(
private router: Router, private router: Router,
private store: Store<ListStore.State> private store: Store<ListStore.State>
) { } ) {
}
ngAfterContentInit() { ngAfterContentInit() {
// const domain: Domain = { this.store.select(AuthSelector.select('domain')).subscribe(
// id: 1, (domain: Domain) => {
// }; this.store.dispatch(new ListStore.ReadAllByDomain(domain));
// this.store.dispatch(new ListStore.ReadAllByDomain(domain)); }
);
// temporary data // temporary data
const data: NoAuthProbe[] = new Array(); // const data: NoAuthProbe[] = new Array();
for (let i = 0; i < 5; i++) { // for (let i = 0; i < 5; i++) {
const p: NoAuthProbe = { // const p: NoAuthProbe = {
id: i, // id: i,
description: String('desc' + i), // description: String('desc' + i),
createDate: new Date() // createDate: new Date()
}; // };
data.push(p); // data.push(p);
} // }
this.dataSource = new MatTableDataSource(data); this.noAuthProbes$.subscribe(
this.dataSource.sort = this.sort; (noAuthProbes: NoAuthProbe[]) => {
this.dataSource = new MatTableDataSource(noAuthProbes);
this.dataSource.sort = this.sort;
},
(error: RPCError) => {
console.log(error.message);
}
);
// this.dataSource = new MatTableDataSource(data);
// this.dataSource.sort = this.sort;
} }
ngOnInit() { ngOnInit() {

View File

@ -3,7 +3,7 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { RPCService } from 'packages/commons/service/rpc.service'; import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
@ -14,20 +14,20 @@ import { NoAuthProbe } from '../model';
export class NoAuthProbeService { export class NoAuthProbeService {
public constructor( public constructor(
private rpcService: RPCService, private rpcClient: RPCClient,
) { ) {
} }
public readAllByDomain(domain: Domain): Observable<NoAuthProbe[]> { public readAllByDomain(domain: Domain): Observable<NoAuthProbe[]> {
return this.rpcService.call<NoAuthProbe[]>('NoAuthProbeService.readAllByDomain', domain); return this.rpcClient.call<NoAuthProbe[]>('NoAuthProbeService.readAllByDomain', domain);
} }
public acceptNoAuthProbe(noAuthProbe: NoAuthProbe): Observable<NoAuthProbe[]> { public acceptNoAuthProbe(noAuthProbe: NoAuthProbe): Observable<NoAuthProbe[]> {
return this.rpcService.call<NoAuthProbe[]>('NoAuthProbeService.acceptNoAuthProbe', noAuthProbe); return this.rpcClient.call<NoAuthProbe[]>('NoAuthProbeService.acceptNoAuthProbe', noAuthProbe);
} }
public denyNoauthProbe(noAuthProbe: NoAuthProbe): Observable<NoAuthProbe[]> { public denyNoauthProbe(noAuthProbe: NoAuthProbe): Observable<NoAuthProbe[]> {
return this.rpcService.call<NoAuthProbe[]>('NoAuthProbeService.denyNoauthProbe', noAuthProbe); return this.rpcClient.call<NoAuthProbe[]>('NoAuthProbeService.denyNoauthProbe', noAuthProbe);
} }
} }

View File

@ -1,3 +1,12 @@
import {
createSelector,
createFeatureSelector,
} from '@ngrx/store';
import { StateSelector } from 'packages/commons/util/ngrx/store';
import { MODULE } from '../noauth-probe.constant';
import * as NoAuthProbeStore from './noauth-probe'; import * as NoAuthProbeStore from './noauth-probe';
export interface State { export interface State {
@ -11,3 +20,10 @@ export const REDUCERS = {
export const EFFECTS = [ export const EFFECTS = [
NoAuthProbeStore.Effects, NoAuthProbeStore.Effects,
]; ];
export const selectNoAuthProbeState = createFeatureSelector<State>(MODULE.name);
export const NoAuthProbeSelector = new StateSelector<NoAuthProbeStore.State>(createSelector(
selectNoAuthProbeState,
(state: State) => state.noAuthProbe
));

View File

@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
@ -35,7 +35,7 @@ export class ReadAllByDomainSuccess implements Action {
export class ReadAllByDomainFailure implements Action { export class ReadAllByDomainFailure implements Action {
readonly type = ActionType.ReadAllByDomainFailure; readonly type = ActionType.ReadAllByDomainFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RPCError) {}
} }
export class Accept implements Action { export class Accept implements Action {
@ -53,7 +53,7 @@ export class AcceptSuccess implements Action {
export class AcceptFailure implements Action { export class AcceptFailure implements Action {
readonly type = ActionType.AcceptFailure; readonly type = ActionType.AcceptFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RPCError) {}
} }
export class Deny implements Action { export class Deny implements Action {
@ -71,7 +71,7 @@ export class DenySuccess implements Action {
export class DenyFailure implements Action { export class DenyFailure implements Action {
readonly type = ActionType.DenyFailure; readonly type = ActionType.DenyFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RPCError) {}
} }

View File

@ -14,7 +14,7 @@ import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take'; import 'rxjs/add/operator/take';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
@ -51,7 +51,7 @@ export class Effects {
.map(noAuthProbes => { .map(noAuthProbes => {
return new ReadAllByDomainSuccess(noAuthProbes); return new ReadAllByDomainSuccess(noAuthProbes);
}) })
.catch((error: ErrorResponse) => { .catch((error: RPCError) => {
return of(new ReadAllByDomainFailure(error)); return of(new ReadAllByDomainFailure(error));
}); });
@ -63,7 +63,7 @@ export class Effects {
.map(noAuthProbes => { .map(noAuthProbes => {
return new AcceptSuccess(noAuthProbes); return new AcceptSuccess(noAuthProbes);
}) })
.catch((error: ErrorResponse) => { .catch((error: RPCError) => {
return of(new AcceptFailure(error)); return of(new AcceptFailure(error));
}); });
@ -75,7 +75,7 @@ export class Effects {
.map(noAuthProbes => { .map(noAuthProbes => {
return new DenySuccess(noAuthProbes); return new DenySuccess(noAuthProbes);
}) })
.catch((error: ErrorResponse) => { .catch((error: RPCError) => {
return of(new DenyFailure(error)); return of(new DenyFailure(error));
}); });

View File

@ -1,5 +1,3 @@
import { ErrorResponse } from 'packages/commons/service/error-response';
import { import {
ReadAllByDomain, ReadAllByDomain,
ReadAllByDomainFailure, ReadAllByDomainFailure,
@ -27,7 +25,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: null, error: null,
isPending: true, pending: true,
}; };
} }
@ -35,7 +33,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: null, error: null,
isPending: false, pending: false,
noAuthProbes: action.payload, noAuthProbes: action.payload,
}; };
} }
@ -44,7 +42,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: action.payload, error: action.payload,
isPending: false, pending: false,
noAuthProbes: null, noAuthProbes: null,
}; };
} }
@ -53,7 +51,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: null, error: null,
isPending: true, pending: true,
}; };
} }
@ -61,7 +59,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: null, error: null,
isPending: false, pending: false,
noAuthProbes: action.payload, noAuthProbes: action.payload,
}; };
} }
@ -70,7 +68,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: action.payload, error: action.payload,
isPending: false, pending: false,
}; };
} }
@ -78,7 +76,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: null, error: null,
isPending: true, pending: true,
}; };
} }
@ -86,7 +84,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: null, error: null,
isPending: false, pending: false,
noAuthProbes: action.payload, noAuthProbes: action.payload,
}; };
} }
@ -95,7 +93,7 @@ export function reducer(state = initialState, action: Actions): State {
return { return {
...state, ...state,
error: action.payload, error: action.payload,
isPending: false, pending: false,
}; };
} }

View File

@ -1,19 +1,15 @@
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { NoAuthProbe } from '../../model'; import { NoAuthProbe } from '../../model';
export interface State { export interface State {
error: ErrorResponse | null; error: RPCError | null;
isPending: boolean; pending: boolean;
noAuthProbes: NoAuthProbe[] | null; noAuthProbes: NoAuthProbe[] | null;
} }
export const initialState: State = { export const initialState: State = {
error: null, error: null,
isPending: false, pending: false,
noAuthProbes: null, noAuthProbes: null,
}; };
export const getNoAuthProbes = (state: State) => state.noAuthProbes;
export const getError = (state: State) => state.error;
export const isPending = (state: State) => state.isPending;

View File

@ -1,13 +1,15 @@
import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core'; import { Component, OnInit, AfterViewInit, AfterContentInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatSort } from '@angular/material'; import { MatTableDataSource, MatSort } from '@angular/material';
import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Probe } from '../../model';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { RPCError } from 'packages/core/rpc/error';
import { Domain } from 'packages/domain/model';
import { AuthSelector } from 'packages/member/store';
import { Probe } from '../../model';
import * as ListStore from '../../store/list'; import * as ListStore from '../../store/list';
import { Domain } from '../../../domain/model';
import { AuthSelector } from '../../../member/store';
import { ErrorResponse } from '../../../commons/service/error-response';
import { ListSelector } from '../../store'; import { ListSelector } from '../../store';
@Component({ @Component({
@ -36,7 +38,7 @@ export class ListComponent implements OnInit, AfterContentInit {
this.dataSource = new MatTableDataSource(probes); this.dataSource = new MatTableDataSource(probes);
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
}, },
(error: ErrorResponse) => { (error: RPCError) => {
console.log(error); console.log(error);
} }
); );

View File

@ -3,7 +3,7 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { RPCService } from 'packages/commons/service/rpc.service'; import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
@ -14,19 +14,19 @@ import { Probe } from '../model';
export class ProbeService { export class ProbeService {
public constructor( public constructor(
private rpcService: RPCService, private rpcClient: RPCClient,
) { ) {
} }
public readAllByDomain(domain: Domain): Observable<Probe[]> { public readAllByDomain(domain: Domain): Observable<Probe[]> {
return this.rpcService.call<Probe[]>('ProbeService.readAllByDomain', domain); return this.rpcClient.call<Probe[]>('ProbeService.readAllByDomain', domain);
} }
public read(id: string): Observable<Probe> { public read(id: string): Observable<Probe> {
const param = { const param = {
id: id, id: id,
}; };
return this.rpcService.call<Probe>('ProbeService.read', param); return this.rpcClient.call<Probe>('ProbeService.read', param);
} }
} }

View File

@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Probe } from '../../model'; import { Probe } from '../../model';
@ -26,7 +26,7 @@ export class ReadSuccess implements Action {
export class ReadFailure implements Action { export class ReadFailure implements Action {
readonly type = ActionType.ReadFailure; readonly type = ActionType.ReadFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RPCError) {}
} }

View File

@ -14,7 +14,7 @@ import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take'; import 'rxjs/add/operator/take';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Probe } from '../../model'; import { Probe } from '../../model';
import { ProbeService } from '../../service/probe.service'; import { ProbeService } from '../../service/probe.service';
@ -43,7 +43,7 @@ export class Effects {
.map(probe => { .map(probe => {
return new ReadSuccess(probe); return new ReadSuccess(probe);
}) })
.catch((error: ErrorResponse) => { .catch((error: RPCError) => {
return of(new ReadFailure(error)); return of(new ReadFailure(error));
}); });
} }

View File

@ -1,5 +1,3 @@
import { ErrorResponse } from 'packages/commons/service/error-response';
import { import {
Read, Read,
ReadFailure, ReadFailure,

View File

@ -1,9 +1,9 @@
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Probe } from '../../model'; import { Probe } from '../../model';
export interface State { export interface State {
error: ErrorResponse | null; error: RPCError | null;
isPending: boolean; isPending: boolean;
probe: Probe | null; probe: Probe | null;
} }

View File

@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
import { Probe } from '../../model'; import { Probe } from '../../model';
@ -27,7 +27,7 @@ export class ReadAllByDomainSuccess implements Action {
export class ReadAllByDomainFailure implements Action { export class ReadAllByDomainFailure implements Action {
readonly type = ActionType.ReadAllByDomainFailure; readonly type = ActionType.ReadAllByDomainFailure;
constructor(public payload: ErrorResponse) {} constructor(public payload: RPCError) {}
} }

View File

@ -14,7 +14,7 @@ import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take'; import 'rxjs/add/operator/take';
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
@ -45,7 +45,7 @@ export class Effects {
.map(probes => { .map(probes => {
return new ReadAllByDomainSuccess(probes); return new ReadAllByDomainSuccess(probes);
}) })
.catch((error: ErrorResponse) => { .catch((error: RPCError) => {
return of(new ReadAllByDomainFailure(error)); return of(new ReadAllByDomainFailure(error));
}); });
} }

View File

@ -1,5 +1,3 @@
import { ErrorResponse } from 'packages/commons/service/error-response';
import { import {
ReadAllByDomain, ReadAllByDomain,
ReadAllByDomainFailure, ReadAllByDomainFailure,

View File

@ -1,9 +1,9 @@
import { ErrorResponse } from 'packages/commons/service/error-response'; import { RPCError } from 'packages/core/rpc/error';
import { Probe } from '../../model'; import { Probe } from '../../model';
export interface State { export interface State {
error: ErrorResponse | null; error: RPCError | null;
isPending: boolean; isPending: boolean;
probes: Probe[] | null; probes: Probe[] | null;
} }

View File

@ -409,6 +409,12 @@ angular-l10n@^4.1.5:
dependencies: dependencies:
tslib "^1.7.1" tslib "^1.7.1"
angularx-qrcode@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/angularx-qrcode/-/angularx-qrcode-1.0.1.tgz#9b10423995cd7448ef38843e241407ce7337daad"
dependencies:
qrcodejs2 "0.0.2"
ansi-html@0.0.7: ansi-html@0.0.7:
version "0.0.7" version "0.0.7"
resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e" resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
@ -5723,6 +5729,10 @@ qjobs@^1.1.4:
version "1.1.5" version "1.1.5"
resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.1.5.tgz#659de9f2cf8dcc27a1481276f205377272382e73" resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.1.5.tgz#659de9f2cf8dcc27a1481276f205377272382e73"
qrcodejs2@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/qrcodejs2/-/qrcodejs2-0.0.2.tgz#465afe5e39f19facecb932c11f7a186109146ae1"
qs@6.5.1: qs@6.5.1:
version "6.5.1" version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"