ing
This commit is contained in:
parent
0c9ef4fb76
commit
8c93055ba1
|
@ -34,12 +34,14 @@
|
|||
"@ngrx/store": "^5.0.0",
|
||||
"@ngrx/store-devtools": "^5.0.1",
|
||||
"@swimlane/ngx-charts": "^7.1.1",
|
||||
"@types/url-join": "^0.8.2",
|
||||
"core-js": "^2.5.3",
|
||||
"d3": "^4.13.0",
|
||||
"hammerjs": "^2.0.8",
|
||||
"ng2-odometer": "^1.1.3",
|
||||
"ngx-perfect-scrollbar": "^5.3.1",
|
||||
"rxjs": "^5.5.6",
|
||||
"url-join": "^4.0.0",
|
||||
"zone.js": "^0.8.20"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -12,7 +12,7 @@ import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@
|
|||
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
import { SimpleRouterStateSerializer } from './commons/router/state/serializer/simple-router-state-serializer';
|
||||
import { SimpleRouterStateSerializer } from 'packages/commons/util/router/state/serializer/simple-router-state-serializer';
|
||||
|
||||
export interface AppState {
|
||||
}
|
||||
|
|
|
@ -12,8 +12,9 @@ import { CovalentModule } from './commons/ui/covalent/covalent.module';
|
|||
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
import { RESTService } from './commons/service/rest.service';
|
||||
import { RPCService } from './commons/service/rpc.service';
|
||||
import { environment } from '../environments/environment';
|
||||
import { RESTService } from 'packages/commons/service/rest.service';
|
||||
import { RPCService } from 'packages/commons/service/rpc.service';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -29,6 +30,8 @@ import { RPCService } from './commons/service/rpc.service';
|
|||
HttpClientModule,
|
||||
],
|
||||
providers: [
|
||||
{provide: 'REST_BASE_URL', useValue: environment.restBaseURL},
|
||||
{provide: 'RPC_BASE_URL', useValue: environment.rpcBaseURL},
|
||||
RESTService, RPCService,
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
export const environment = {
|
||||
production: true
|
||||
production: true,
|
||||
restBaseURL: 'http://127.0.0.1:19080',
|
||||
rpcBaseURL: 'ws://127.0.0.1:19090/webapp',
|
||||
|
||||
};
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false
|
||||
production: false,
|
||||
restBaseURL: 'http://127.0.0.1:19080',
|
||||
rpcBaseURL: 'ws://127.0.0.1:19090/webapp',
|
||||
};
|
||||
export const palete = {
|
||||
primary: '#D32F2F',
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
declarations: []
|
||||
})
|
||||
export class CommonsModule { }
|
|
@ -1,20 +1,22 @@
|
|||
import { Injectable, Inject } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
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/timeout';
|
||||
import 'rxjs/add/observable/throw';
|
||||
|
||||
@Injectable()
|
||||
export class RESTService {
|
||||
private baseURL: string;
|
||||
private readonly httpHeaders: HttpHeaders;
|
||||
|
||||
constructor(
|
||||
@Inject('REST_BASE_URL') private _baseURL: string,
|
||||
@Inject(HttpClient) private _httpClient: HttpClient,
|
||||
) {
|
||||
this.baseURL = 'http://192.168.1.103:19090/webapp';
|
||||
this.httpHeaders = new HttpHeaders()
|
||||
.set('Accept', 'application/json')
|
||||
.set('Content-Type', 'application/json');
|
||||
|
@ -28,22 +30,26 @@ export class RESTService {
|
|||
const headers: HttpHeaders = this.httpHeaders;
|
||||
|
||||
return this._httpClient
|
||||
.get<T>(`${this.baseURL}${entry}`, {
|
||||
.get<T>(Location.joinWithSlash(this._baseURL, entry), {
|
||||
headers: headers,
|
||||
params: params,
|
||||
responseType: 'json',
|
||||
});
|
||||
})
|
||||
.map(response => response)
|
||||
.catch((error: HttpErrorResponse) => Observable.throw(error.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<T>(`${this.baseURL}${entry}`, body, {
|
||||
.post<T>(Location.joinWithSlash(this._baseURL, entry), body, {
|
||||
headers: headers,
|
||||
params: params,
|
||||
responseType: 'json',
|
||||
});
|
||||
})
|
||||
.map(response => response)
|
||||
.catch((error: HttpErrorResponse) => Observable.throw(error.error));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { RxWebsocketSubject } from 'app/core/rx/websocket/rx-websocket-subject';
|
||||
|
@ -10,8 +10,10 @@ export class RPCService {
|
|||
private wsSocketSubject: RxWebsocketSubject<Object>;
|
||||
private rpcRegistry: RPCRegistry;
|
||||
|
||||
constructor() {
|
||||
this.wsSocketSubject = new RxWebsocketSubject<Object>('ws://127.0.0.1:19090/webapp');
|
||||
constructor(
|
||||
@Inject('RPC_BASE_URL') private _baseURL: string,
|
||||
) {
|
||||
this.wsSocketSubject = new RxWebsocketSubject<Object>(this._baseURL);
|
||||
}
|
||||
|
||||
public connect(): void {
|
|
@ -3,7 +3,7 @@ import { Observable } from 'rxjs/Observable';
|
|||
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import { RESTService } from 'app/commons/service/rest.service';
|
||||
import { RESTService } from 'packages/commons/service/rest.service';
|
||||
|
||||
import { Member } from '../model/member';
|
||||
|
||||
|
@ -17,10 +17,15 @@ export class MemberService {
|
|||
}
|
||||
|
||||
public signin(email: string, password: string): Observable<Member> {
|
||||
return this.restService.post('/member/signin', '').map((member: Member) => member);
|
||||
const body = {
|
||||
signinId: email,
|
||||
signinPw: password,
|
||||
};
|
||||
|
||||
return this.restService.post('/account/signin', body);
|
||||
}
|
||||
|
||||
public signup(member: Member): Observable<Member> {
|
||||
return this.restService.post('/member/signup', '').map((_member: Member) => _member);
|
||||
return this.restService.post('/account/signup', '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ 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';
|
||||
|
||||
|
@ -36,12 +37,25 @@ export class Effects {
|
|||
signin$: Observable<Action> = this.actions$
|
||||
.ofType(ActionType.Signin)
|
||||
.map((action: Signin) => action.payload)
|
||||
.exhaustMap(payload =>
|
||||
this.memberService
|
||||
.signin(payload.email, payload.password)
|
||||
.map(member => new SigninSuccess(member))
|
||||
.catch(error => of(new SigninFailure(error)))
|
||||
);
|
||||
.switchMap(payload => this.memberService.signin(payload.email, payload.password))
|
||||
.map(member => {
|
||||
return new SigninSuccess(member);
|
||||
})
|
||||
.catch((error) => {
|
||||
return of(new SigninFailure(error));
|
||||
});
|
||||
|
||||
// .map((action: Signin) => action.payload)
|
||||
// .exhaustMap(payload =>
|
||||
// this.memberService
|
||||
// .signin(payload.email, payload.password)
|
||||
// .map(member => {
|
||||
// return new SigninSuccess(member);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// return of(new SigninFailure(error.message));
|
||||
// })
|
||||
// );
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
signinSuccess$ = this.actions$
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
Actions,
|
||||
ActionType,
|
||||
Signin,
|
||||
} from './auth.action';
|
||||
|
||||
import {
|
||||
|
|
|
@ -291,6 +291,10 @@
|
|||
version "0.0.30"
|
||||
resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1"
|
||||
|
||||
"@types/url-join@^0.8.2":
|
||||
version "0.8.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/url-join/-/url-join-0.8.2.tgz#1181ecbe1d97b7034e0ea1e35e62e86cc26b422d"
|
||||
|
||||
JSONStream@^1.0.3:
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea"
|
||||
|
@ -7273,6 +7277,10 @@ urix@^0.1.0:
|
|||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
|
||||
|
||||
url-join@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.0.tgz#4d3340e807d3773bda9991f8305acdcc2a665d2a"
|
||||
|
||||
url-loader@^0.6.2:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-0.6.2.tgz#a007a7109620e9d988d14bce677a1decb9a993f7"
|
||||
|
|
Loading…
Reference in New Issue
Block a user