Merge branch 'master' of https://git.loafle.net/overflow/overflow-webapp
This commit is contained in:
commit
3cdee810bb
|
@ -37,12 +37,18 @@ export class Effects {
|
|||
@Effect({ dispatch: false })
|
||||
signinSuccess$ = this.actions$
|
||||
.ofType(ActionType.SigninSuccess)
|
||||
.map((action: SigninSuccess) => action.payload)
|
||||
.do(
|
||||
() => {
|
||||
let queryString: string;
|
||||
if (this.cookieService.check('AuthToken')) {
|
||||
queryString = `AuthToken=${this.cookieService.get('AuthToken')}`;
|
||||
}
|
||||
(result: Map<string, any>) => {
|
||||
const authToken = result['authToken'];
|
||||
// console.log(`authToken: ${authToken}`);
|
||||
|
||||
const expires = new Date();
|
||||
expires.setDate(expires.getDate() + 1);
|
||||
this.cookieService.set('authToken', authToken, expires, '/');
|
||||
|
||||
const queryString = `authToken=${authToken}`;
|
||||
|
||||
this.rpcClient.connect(queryString);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -12,14 +12,10 @@ 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 {
|
||||
|
@ -39,11 +35,15 @@ export class RESTClient {
|
|||
reportProgress?: boolean;
|
||||
withCredentials?: boolean;
|
||||
}): Observable<T> {
|
||||
const headers: HttpHeaders = this.httpHeaders;
|
||||
// options.withCredentials = true;
|
||||
|
||||
return this._httpClient
|
||||
.request(method, Location.joinWithSlash(this._baseURL, entry), options)
|
||||
.map((response: string) => <T>JSON.parse(response))
|
||||
.request<T>(method, Location.joinWithSlash(this._baseURL, entry), options)
|
||||
.map(
|
||||
(response: T) => {
|
||||
return response;
|
||||
}
|
||||
)
|
||||
.catch((error: HttpErrorResponse) => {
|
||||
const aryMsg = error.error.message.split('|');
|
||||
const resError: RESTError = {
|
||||
|
|
|
@ -17,13 +17,13 @@ export class MemberService {
|
|||
|
||||
}
|
||||
|
||||
public signin(email: string, password: string): Observable<DomainMember> {
|
||||
public signin(email: string, password: string): Observable<any> {
|
||||
const body = {
|
||||
signinId: email,
|
||||
signinPw: password,
|
||||
};
|
||||
|
||||
return this.restClient.request<DomainMember>('post', '/account/signin', {
|
||||
return this.restClient.request<any>('post', '/account/signin', {
|
||||
body: body,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export class Signin implements Action {
|
|||
export class SigninSuccess implements Action {
|
||||
readonly type = ActionType.SigninSuccess;
|
||||
|
||||
constructor(public payload: DomainMember) {}
|
||||
constructor(public payload: any) {}
|
||||
}
|
||||
|
||||
export class SigninFailure implements Action {
|
||||
|
|
|
@ -47,8 +47,8 @@ export class Effects {
|
|||
this._options = payload.options;
|
||||
return this.memberService.signin(payload.email, payload.password);
|
||||
})
|
||||
.map((domainMember: DomainMember) => {
|
||||
return new SigninSuccess(domainMember);
|
||||
.map((result: any) => {
|
||||
return new SigninSuccess(result);
|
||||
})
|
||||
.catch((error: RESTError) => {
|
||||
return of(new SigninFailure(error));
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from './auth.state';
|
||||
|
||||
import { Member } from '../../model';
|
||||
import { DomainMember } from '../../../domain/model';
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
|
@ -22,13 +23,14 @@ export function reducer(state = initialState, action: Actions): State {
|
|||
}
|
||||
|
||||
case ActionType.SigninSuccess: {
|
||||
const domainMember = action.payload['domainMember'];
|
||||
return {
|
||||
...state,
|
||||
signined: true,
|
||||
error: null,
|
||||
pending: false,
|
||||
member: action.payload.member,
|
||||
domain: action.payload.domain,
|
||||
member: domainMember.member,
|
||||
domain: domainMember.domain,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ export class ListComponent implements OnInit, AfterContentInit {
|
|||
ngAfterContentInit() {
|
||||
this.store.select(AuthSelector.select('domain')).subscribe(
|
||||
(domain: Domain) => {
|
||||
console.log(domain);
|
||||
this.store.dispatch(new ListStore.ReadAllByDomain(domain));
|
||||
}
|
||||
);
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
<ng-container matColumnDef="ip">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> IP </mat-header-cell>
|
||||
<mat-cell *matCellDef="let element"> {{element.host.ip}} </mat-cell>
|
||||
<mat-cell *matCellDef="let element"> </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="os">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> OS </mat-header-cell>
|
||||
<mat-cell *matCellDef="let element"> {{element.host.os.meta}} </mat-cell>
|
||||
<mat-cell *matCellDef="let element"> </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="cidr">
|
||||
|
|
|
@ -19,8 +19,8 @@ import { ListSelector } from '../../store';
|
|||
})
|
||||
export class ListComponent implements OnInit, AfterContentInit {
|
||||
probes$ = this.store.pipe(select(ListSelector.select('probes')));
|
||||
pageSize = '25';
|
||||
length = '100';
|
||||
// pageSize = '25';
|
||||
// length = '100';
|
||||
|
||||
displayedColumns = ['name', 'ip', 'os', 'cidr', 'targetCnt', 'date', 'authBy'];
|
||||
dataSource: MatTableDataSource<Probe>;
|
||||
|
@ -33,15 +33,6 @@ export class ListComponent implements OnInit, AfterContentInit {
|
|||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
this.probes$.subscribe(
|
||||
(probes: Probe[]) => {
|
||||
this.dataSource = new MatTableDataSource(probes);
|
||||
this.dataSource.sort = this.sort;
|
||||
},
|
||||
(error: RPCError) => {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
|
||||
this.store.select(AuthSelector.select('domain')).subscribe(
|
||||
(domain: Domain) => {
|
||||
|
@ -52,34 +43,45 @@ export class ListComponent implements OnInit, AfterContentInit {
|
|||
}
|
||||
);
|
||||
|
||||
// temporary data
|
||||
const data: Probe[] = new Array();
|
||||
for (let i = 0; i < 100; i++) {
|
||||
const p: Probe = {
|
||||
id: i,
|
||||
displayName: String('displayName' + i),
|
||||
host: {
|
||||
ip: i,
|
||||
os: {
|
||||
meta: 'blahblahblah'
|
||||
},
|
||||
},
|
||||
cidr: String('cidr' + i),
|
||||
targets: [
|
||||
{
|
||||
id: i,
|
||||
},
|
||||
],
|
||||
authorizeDate: new Date(),
|
||||
authorizeMember: {
|
||||
'name': String('insanity')
|
||||
},
|
||||
};
|
||||
data.push(p);
|
||||
}
|
||||
this.probes$.subscribe(
|
||||
(probes: Probe[]) => {
|
||||
console.log(probes);
|
||||
this.dataSource = new MatTableDataSource(probes);
|
||||
this.dataSource.sort = this.sort;
|
||||
},
|
||||
(error: RPCError) => {
|
||||
console.log(error.message);
|
||||
}
|
||||
);
|
||||
|
||||
this.dataSource = new MatTableDataSource(data);
|
||||
this.dataSource.sort = this.sort;
|
||||
// // temporary data
|
||||
// const data: Probe[] = new Array();
|
||||
// for (let i = 0; i < 100; i++) {
|
||||
// const p: Probe = {
|
||||
// id: i,
|
||||
// displayName: String('displayName' + i),
|
||||
// host: {
|
||||
// ip: i,
|
||||
// os: {
|
||||
// meta: 'blahblahblah'
|
||||
// },
|
||||
// },
|
||||
// cidr: String('cidr' + i),
|
||||
// targets: [
|
||||
// {
|
||||
// id: i,
|
||||
// },
|
||||
// ],
|
||||
// authorizeDate: new Date(),
|
||||
// authorizeMember: {
|
||||
// 'name': String('insanity')
|
||||
// },
|
||||
// };
|
||||
// data.push(p);
|
||||
// }
|
||||
|
||||
// this.dataSource = new MatTableDataSource(data);
|
||||
// this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
|
|
@ -16,6 +16,6 @@ export interface Probe {
|
|||
cidr?: string;
|
||||
authorizeDate?: Date;
|
||||
authorizeMember?: Member;
|
||||
host?: InfraHost;
|
||||
// host?: InfraHost;
|
||||
targets?: Target[];
|
||||
}
|
||||
|
|
|
@ -9,10 +9,12 @@ import {
|
|||
import {
|
||||
State,
|
||||
initialState,
|
||||
adapter,
|
||||
} from './detail.state';
|
||||
|
||||
import { Probe } from '../../model';
|
||||
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.Read: {
|
||||
|
|
|
@ -2,18 +2,39 @@ import { RPCError } from 'packages/core/rpc/error';
|
|||
|
||||
import { Probe } from '../../model';
|
||||
|
||||
export interface State {
|
||||
// export interface State {
|
||||
// error: RPCError | null;
|
||||
// isPending: boolean;
|
||||
// probe: Probe | null;
|
||||
// }
|
||||
|
||||
// export const initialState: State = {
|
||||
// error: null,
|
||||
// isPending: false,
|
||||
// probe: null,
|
||||
// };
|
||||
|
||||
// export const getProbe = (state: State) => state.probe;
|
||||
// export const getError = (state: State) => state.error;
|
||||
// export const isPending = (state: State) => state.isPending;
|
||||
|
||||
import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity';
|
||||
|
||||
export interface State extends EntityState<Probe> {
|
||||
error: RPCError | null;
|
||||
isPending: boolean;
|
||||
probe: Probe | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
export const adapter: EntityAdapter<Probe> = createEntityAdapter<Probe>();
|
||||
export const initialState: State = adapter.getInitialState({
|
||||
error: null,
|
||||
isPending: false,
|
||||
probe: null,
|
||||
};
|
||||
});
|
||||
|
||||
export const getProbe = (state: State) => state.probe;
|
||||
export const getError = (state: State) => state.error;
|
||||
export const isPending = (state: State) => state.isPending;
|
||||
// export const {
|
||||
// selectIds,
|
||||
// selectEntities,
|
||||
// selectAll,
|
||||
// selectTotal,
|
||||
// } = adapter.getSelectors();
|
||||
|
|
|
@ -32,3 +32,7 @@ export const ListSelector = new StateSelector<ProbeListStore.State>(createSelect
|
|||
selectProbeState,
|
||||
(state: State) => state.list
|
||||
));
|
||||
export const DetailSelector = new StateSelector<ProbeDetailStore.State>(createSelector(
|
||||
selectProbeState,
|
||||
(state: State) => state.detail
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue
Block a user