ing
This commit is contained in:
parent
07b2d08483
commit
9e571f6fed
|
@ -17,36 +17,36 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- target 별 sensor list -->
|
|
||||||
<div fxFlex="80%" class="example-container mat-elevation-z8">
|
<div fxFlex="80%" class="example-container mat-elevation-z8">
|
||||||
<div fxLayout="row" >
|
<div fxLayout="row">
|
||||||
<div fxFlex="20">aaaaaaaaaaaaaaaaaaa</div>
|
|
||||||
|
|
||||||
<div fxFlex="80">
|
|
||||||
<mat-table #table [dataSource]="dataSource" matSort>
|
<mat-table #table [dataSource]="dataSource" matSort>
|
||||||
|
|
||||||
<ng-container matColumnDef="status">
|
<ng-container matColumnDef="target">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Status </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> Target </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let element"> ? </mat-cell>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="type">
|
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Type </mat-header-cell>
|
|
||||||
<mat-cell *matCellDef="let element"> {{element.infraType.name}} </mat-cell>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="name">
|
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Name </mat-header-cell>
|
|
||||||
<mat-cell *matCellDef="let element"> {{element.target.displayName}} </mat-cell>
|
<mat-cell *matCellDef="let element"> {{element.target.displayName}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="sensors">
|
<ng-container matColumnDef="crawler">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Sensors </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> Crawler </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let element"> ? </mat-cell>
|
<mat-cell *matCellDef="let element"> {{element.crawler.name}} </mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="itemCount">
|
||||||
|
<mat-header-cell *matHeaderCellDef mat-sort-header> Items </mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let element"> {{element.itemCount}} </mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="status">
|
||||||
|
<mat-header-cell *matHeaderCellDef mat-sort-header> Status </mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let element"> {{element.status.name}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<mat-row *matRowDef="let row; columns: displayedColumns;" (click)="handleRowClick(row)"></mat-row>
|
<mat-row *matRowDef="let row; columns: displayedColumns;" (click)="handleRowClick(row)"></mat-row>
|
||||||
</mat-table>
|
</mat-table>
|
||||||
|
|
||||||
|
<mat-paginator #paginator [length]="totalLength" [pageIndex]="0" [pageSize]="PAGE_SIZE" (page)="handlePaging($event)">
|
||||||
|
</mat-paginator>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,12 @@ import { Store, select } from '@ngrx/store';
|
||||||
import * as SensorStore from '../../store';
|
import * as SensorStore from '../../store';
|
||||||
|
|
||||||
import { RPCError } from 'packages/core/rpc/error';
|
import { RPCError } from 'packages/core/rpc/error';
|
||||||
import * as ReadAllByDomainStore from '../../store/readallbydomain';
|
import * as ListStore from '../../store/list';
|
||||||
import { ReadAllByMemberSelector } from '../../store';
|
import { sensorListSelector } from '../../store';
|
||||||
import { Domain } from '../../../domain/model';
|
import { Domain } from '../../../domain/model';
|
||||||
import { SettingComponent } from '../setting/setting.component';
|
import { SettingComponent } from '../setting/setting.component';
|
||||||
|
import { AuthSelector } from 'packages/member/store';
|
||||||
|
import { Page, PageParams } from 'app/commons/model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-sensor-list',
|
selector: 'of-sensor-list',
|
||||||
|
@ -21,75 +23,58 @@ import { SettingComponent } from '../setting/setting.component';
|
||||||
})
|
})
|
||||||
export class ListComponent implements OnInit, AfterContentInit {
|
export class ListComponent implements OnInit, AfterContentInit {
|
||||||
|
|
||||||
sensorList$ = this.store.pipe(select(ReadAllByMemberSelector.select('sensorList')));
|
sensorList$ = this.store.pipe(select(sensorListSelector.select('page')));
|
||||||
|
|
||||||
displayedColumns = ['crawler', 'type', 'name', 'sensors'];
|
displayedColumns = ['target', 'crawler', 'itemCount', 'status'];
|
||||||
dataSource: MatTableDataSource<Sensor>;
|
dataSource: MatTableDataSource<Sensor>;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
PAGE_SIZE = '10';
|
||||||
|
totalLength = 0;
|
||||||
|
|
||||||
/**
|
constructor(private router: Router,
|
||||||
* Set the sort after the view init since this component will
|
private store: Store<ListStore.State>,
|
||||||
* be able to query its view for the initialized sort.
|
private dialog: MatDialog,
|
||||||
*/
|
) { }
|
||||||
ngAfterContentInit() {
|
|
||||||
// temporary data
|
|
||||||
// const data: Sensor[] = new Array();
|
|
||||||
// for (let i = 0; i < 3; i++) {
|
|
||||||
// const t: Sensor = {
|
|
||||||
// id: i,
|
|
||||||
// target: {
|
|
||||||
// id: 1,
|
|
||||||
// displayName: '192.168.1.1',
|
|
||||||
// },
|
|
||||||
// crawler: {
|
|
||||||
// id: 1,
|
|
||||||
// name: 'WMI'
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// data.push(t);
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.store.select(ReadAllByMemberSelector.select('domain')).subscribe(
|
|
||||||
(domain: Domain) => {
|
|
||||||
this.store.dispatch(new ReadAllByDomainStore.ReadAllByDomain(domain));
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// const domain: Domain = {
|
|
||||||
// id: 1
|
|
||||||
// };
|
|
||||||
|
|
||||||
// this.store.dispatch(new ReadAllByDomainStore.ReadAllByDomain(domain));
|
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
this.sensorList$.subscribe(
|
this.sensorList$.subscribe(
|
||||||
(probes: Sensor[]) => {
|
(page: Page) => {
|
||||||
console.log(probes);
|
if (page != null) {
|
||||||
this.dataSource = new MatTableDataSource(probes);
|
this.totalLength = page.totalElements;
|
||||||
this.dataSource.sort = this.sort;
|
this.dataSource = new MatTableDataSource(page.content);
|
||||||
|
this.dataSource.sort = this.sort;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(error: RPCError) => {
|
(error: RPCError) => {
|
||||||
console.log(error.response.message);
|
console.log(error.response.message);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// this.dataSource = new MatTableDataSource(data);
|
|
||||||
// this.dataSource.sort = this.sort;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private router: Router,
|
ngAfterContentInit() {
|
||||||
private store: Store<ReadAllByDomainStore.State>,
|
this.getSensors(0);
|
||||||
private dialog: MatDialog,
|
}
|
||||||
) { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
getSensors(pageIndex: number) {
|
||||||
|
this.store.select(AuthSelector.select('domain')).subscribe(
|
||||||
|
(domain: Domain) => {
|
||||||
|
const pageParams: PageParams = {
|
||||||
|
pageNo: pageIndex + '',
|
||||||
|
countPerPage: this.PAGE_SIZE,
|
||||||
|
sortCol: 'id',
|
||||||
|
sortDirection: 'descending'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.store.dispatch(new ListStore.ReadAllByDomain({ domain, pageParams }));
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRowClick(obj: Sensor) {
|
handleRowClick(obj: Sensor) {
|
||||||
this.router.navigate(['target', obj.id]);
|
// this.router.navigate(['target', obj.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSensor() {
|
addSensor() {
|
||||||
|
|
|
@ -5,8 +5,8 @@ import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
import { RPCClient } from 'packages/core/rpc/client/RPCClient';
|
import { RPCClient } from 'packages/core/rpc/client/RPCClient';
|
||||||
|
|
||||||
import { Sensor } from '../model';
|
|
||||||
import { Domain } from '../../domain/model';
|
import { Domain } from '../../domain/model';
|
||||||
|
import { PageParams, Page } from 'app/commons/model';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -18,8 +18,8 @@ export class SensorService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readAllByDomain(domain: Domain): Observable<Sensor[]> {
|
public readAllByDomain(domain: Domain, pageParams: PageParams): Observable<Page> {
|
||||||
return this.rpcClient.call('SensorService.readAllByDomain', domain);
|
return this.rpcClient.call('SensorService.readAllByDomain', domain, pageParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,23 +8,23 @@ import {
|
||||||
|
|
||||||
import { MODULE } from '../sensor.constant';
|
import { MODULE } from '../sensor.constant';
|
||||||
|
|
||||||
import * as ReadAllByDomainStore from './readallbydomain';
|
import * as ReadAllByDomainStore from './list';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
readallbydomain: ReadAllByDomainStore.State;
|
list: ReadAllByDomainStore.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const REDUCERS = {
|
export const REDUCERS = {
|
||||||
readallbymember: ReadAllByDomainStore.reducer,
|
list: ReadAllByDomainStore.reducer,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EFFECTS = [
|
export const EFFECTS = [
|
||||||
ReadAllByDomainStore.Effects,
|
ReadAllByDomainStore.Effects,
|
||||||
];
|
];
|
||||||
|
|
||||||
export const selectNotificationState = createFeatureSelector<State>(MODULE.name);
|
export const selectState = createFeatureSelector<State>(MODULE.name);
|
||||||
|
|
||||||
export const ReadAllByMemberSelector = new StateSelector<ReadAllByDomainStore.State>(createSelector(
|
export const sensorListSelector = new StateSelector<ReadAllByDomainStore.State>(createSelector(
|
||||||
selectNotificationState,
|
selectState,
|
||||||
(state: State) => state.readallbydomain
|
(state: State) => state.list
|
||||||
));
|
));
|
||||||
|
|
4
src/packages/sensor/store/list/index.ts
Normal file
4
src/packages/sensor/store/list/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export * from './list.action';
|
||||||
|
export * from './list.effect';
|
||||||
|
export * from './list.reducer';
|
||||||
|
export * from './list.state';
|
|
@ -2,8 +2,8 @@ import { Action } from '@ngrx/store';
|
||||||
|
|
||||||
import { RPCError } from 'packages/core/rpc/error';
|
import { RPCError } from 'packages/core/rpc/error';
|
||||||
|
|
||||||
import { Sensor } from '../../model';
|
import { Domain } from 'packages/domain/model';
|
||||||
import { Domain } from '../../../domain/model';
|
import { PageParams, Page } from 'app/commons/model';
|
||||||
|
|
||||||
export enum ActionType {
|
export enum ActionType {
|
||||||
ReadAllByDomain = '[Sensor.ReadAllByDomain] ReadAllByDomain',
|
ReadAllByDomain = '[Sensor.ReadAllByDomain] ReadAllByDomain',
|
||||||
|
@ -14,13 +14,13 @@ export enum ActionType {
|
||||||
export class ReadAllByDomain implements Action {
|
export class ReadAllByDomain implements Action {
|
||||||
readonly type = ActionType.ReadAllByDomain;
|
readonly type = ActionType.ReadAllByDomain;
|
||||||
|
|
||||||
constructor(public payload: Domain) {}
|
constructor(public payload: { domain: Domain, pageParams: PageParams}) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ReadAllByDomainSuccess implements Action {
|
export class ReadAllByDomainSuccess implements Action {
|
||||||
readonly type = ActionType.ReadAllByDomainSuccess;
|
readonly type = ActionType.ReadAllByDomainSuccess;
|
||||||
|
|
||||||
constructor(public payload: Sensor[]) {}
|
constructor(public payload: Page) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ReadAllByDomainFailure implements Action {
|
export class ReadAllByDomainFailure implements Action {
|
|
@ -1,6 +1,6 @@
|
||||||
import { TestBed, inject } from '@angular/core/testing';
|
import { TestBed, inject } from '@angular/core/testing';
|
||||||
|
|
||||||
import { Effects } from './readallbydomain.effect';
|
import { Effects } from './list.effect';
|
||||||
|
|
||||||
describe('ReadAllByDomain.Effects', () => {
|
describe('ReadAllByDomain.Effects', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
|
@ -23,26 +23,27 @@ import {
|
||||||
ReadAllByDomainSuccess,
|
ReadAllByDomainSuccess,
|
||||||
ReadAllByDomainFailure,
|
ReadAllByDomainFailure,
|
||||||
ActionType,
|
ActionType,
|
||||||
} from './readallbydomain.action';
|
} from './list.action';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Effects {
|
export class Effects {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
private sensorService: SensorService,
|
private service: SensorService,
|
||||||
private router: Router
|
private router: Router
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@Effect()
|
@Effect()
|
||||||
readAllByMember$: Observable<Action> = this.actions$
|
readAllByDomain$: Observable<Action> = this.actions$
|
||||||
.ofType(ActionType.ReadAllByDomain)
|
.ofType(ActionType.ReadAllByDomain)
|
||||||
.map((action: ReadAllByDomain) => action.payload)
|
.map((action: ReadAllByDomain) => action.payload)
|
||||||
.exhaustMap(domain =>
|
.switchMap(payload => this.service.readAllByDomain(payload.domain, payload.pageParams))
|
||||||
this.sensorService
|
.map(list => {
|
||||||
.readAllByDomain(domain)
|
return new ReadAllByDomainSuccess(list);
|
||||||
.map(sensorList => new ReadAllByDomainSuccess(sensorList))
|
})
|
||||||
.catch(error => of(new ReadAllByDomainFailure(error)))
|
.catch((error: RPCError) => {
|
||||||
);
|
return of(new ReadAllByDomainFailure(error));
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
import {
|
import {
|
||||||
Actions,
|
Actions,
|
||||||
ActionType,
|
ActionType,
|
||||||
} from './readallbydomain.action';
|
} from './list.action';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
State,
|
State,
|
||||||
initialState,
|
initialState,
|
||||||
} from './readallbydomain.state';
|
} from './list.state';
|
||||||
|
|
||||||
import { Sensor } from '../../model';
|
import { Sensor } from '../../model';
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import {
|
||||||
...state,
|
...state,
|
||||||
error: null,
|
error: null,
|
||||||
pending: false,
|
pending: false,
|
||||||
sensorList: action.payload
|
page: action.payload
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import {
|
||||||
...state,
|
...state,
|
||||||
error: action.payload,
|
error: action.payload,
|
||||||
pending: false,
|
pending: false,
|
||||||
sensorList: null,
|
page: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { RPCError } from 'packages/core/rpc/error';
|
import { RPCError } from 'packages/core/rpc/error';
|
||||||
|
|
||||||
import { Sensor } from '../../model';
|
import { Page } from 'app/commons/model';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
error: RPCError | null;
|
error: RPCError | null;
|
||||||
pending: boolean;
|
pending: boolean;
|
||||||
sensorList: Sensor[] | null;
|
page: Page | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialState: State = {
|
export const initialState: State = {
|
||||||
error: null,
|
error: null,
|
||||||
pending: false,
|
pending: false,
|
||||||
sensorList: null,
|
page: null,
|
||||||
};
|
};
|
|
@ -1,4 +0,0 @@
|
||||||
export * from './readallbydomain.action';
|
|
||||||
export * from './readallbydomain.effect';
|
|
||||||
export * from './readallbydomain.reducer';
|
|
||||||
export * from './readallbydomain.state';
|
|
Loading…
Reference in New Issue
Block a user