ing
This commit is contained in:
parent
c7dd7d04dc
commit
33b3340a8f
|
@ -13,7 +13,13 @@ describe('APIService', () => {
|
||||||
expect(service).toBeTruthy();
|
expect(service).toBeTruthy();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should be created', inject([APIService], (service: APIService) => {
|
it('apiService connect to server', inject([APIService], (service: APIService) => {
|
||||||
|
service.connect();
|
||||||
|
service.getConnectionStatus().subscribe(
|
||||||
|
(isConnected: boolean) => {
|
||||||
|
console.log('isConnected:' + isConnected);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
expect(service).toBeTruthy();
|
expect(service).toBeTruthy();
|
||||||
}));
|
}));
|
|
@ -1,15 +1,17 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { RxWebsocketSubject } from 'app/commons/core/rx/websocket/rx-websocket-subject';
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
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()
|
@Injectable()
|
||||||
export class APIService {
|
export class APIService {
|
||||||
private wsSocketSubject: RxWebsocketSubject<Object>;
|
private wsSocketSubject: RxWebsocketSubject<Object>;
|
||||||
|
private rpcRegistry: RPCRegistry;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.wsSocketSubject = new RxWebsocketSubject<Object>('');
|
this.wsSocketSubject = new RxWebsocketSubject<Object>('ws://127.0.0.1:19090/webapp');
|
||||||
}
|
}
|
||||||
|
|
||||||
public connect(): void {
|
public connect(): void {
|
||||||
|
@ -22,24 +24,35 @@ export class APIService {
|
||||||
this.onError(error);
|
this.onError(error);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
|
this.onDisconnected();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public call<T>(method: string, ...args: any[]): Observable<T> {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
public send(method: string, ...args: any[]): void {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public getConnectionStatus(): Observable<boolean> {
|
public getConnectionStatus(): Observable<boolean> {
|
||||||
return this.wsSocketSubject.connectionStatus;
|
return this.wsSocketSubject.connectionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onMessage(message: Object): void {
|
private onMessage(message: Object): void {
|
||||||
//
|
//
|
||||||
|
console.log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onError(error: any): void {
|
private onError(error: any): void {
|
||||||
//
|
//
|
||||||
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onDisconnected(): void {
|
private onDisconnected(): void {
|
||||||
//
|
//
|
||||||
|
console.log('disconnected');
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@ import {
|
||||||
} from 'rxjs/observable/dom/WebSocketSubject';
|
} from 'rxjs/observable/dom/WebSocketSubject';
|
||||||
|
|
||||||
import 'rxjs/add/operator/distinctUntilChanged';
|
import 'rxjs/add/operator/distinctUntilChanged';
|
||||||
import 'rxjs/add/operator/interval';
|
|
||||||
import 'rxjs/add/operator/share';
|
import 'rxjs/add/operator/share';
|
||||||
import 'rxjs/add/operator/takeWhile';
|
import 'rxjs/add/operator/takeWhile';
|
||||||
import 'rxjs/add/observable/interval';
|
import 'rxjs/add/observable/interval';
|
||||||
|
@ -112,7 +111,8 @@ export class RxWebsocketSubject<T> extends Subject<T> {
|
||||||
this.complete();
|
this.complete();
|
||||||
this.connectionObserver.complete();
|
this.connectionObserver.complete();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public send(data: any): void {
|
public send(data: any): void {
|
|
@ -1,37 +0,0 @@
|
||||||
$gray-lighter: #eceeef !default;
|
|
||||||
$image_path: "/assets/images/" !default;
|
|
||||||
|
|
||||||
$prefix: 'sigin';
|
|
||||||
|
|
||||||
.#{$prefix} {
|
|
||||||
|
|
||||||
&-conainer {
|
|
||||||
min-height: 100%;
|
|
||||||
background-size: cover;
|
|
||||||
padding: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-main {
|
|
||||||
position: relative;
|
|
||||||
margin: 0 auto;
|
|
||||||
width: 500px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.full-width {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.help {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.is-danger {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.redirect {
|
|
||||||
font-size: 14px;
|
|
||||||
margin-left: 10px;
|
|
||||||
color: #00AAAA;
|
|
||||||
}
|
|
|
@ -1,11 +1,23 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { APIService } from 'app/commons/service/api.service';
|
||||||
|
|
||||||
|
import { Member } from '../model/member';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MemberService {
|
export class MemberService {
|
||||||
|
|
||||||
constructor() { }
|
public constructor(
|
||||||
|
private apiService: APIService,
|
||||||
|
) { }
|
||||||
|
|
||||||
signin(email: string, password: string) {
|
public signin(email: string, password: string) {
|
||||||
|
this.apiService.call<Member>('MemberService.signin', email, password).subscribe(
|
||||||
|
(member: Member) => {
|
||||||
|
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user