2018-05-02 08:25:38 +00:00
|
|
|
import { Component, OnInit, AfterContentInit, OnDestroy } from '@angular/core';
|
2018-04-16 08:28:39 +00:00
|
|
|
import { Router, ActivatedRoute } from '@angular/router';
|
2018-05-02 08:25:38 +00:00
|
|
|
import { Infra } from '@overflow/commons-typescript/model/infra';
|
|
|
|
import { Probe } from '@overflow/commons-typescript/model/probe';
|
|
|
|
import { Target } from '@overflow/commons-typescript/model/target';
|
2018-06-01 10:27:27 +00:00
|
|
|
|
2018-06-05 11:31:29 +00:00
|
|
|
import { Store, select } from '@ngrx/store';
|
2018-06-06 10:36:51 +00:00
|
|
|
import { TargetService } from '../../service/target.service';
|
|
|
|
import { InfraService } from '@overflow/infra/service/infra.service';
|
|
|
|
import {PageParams} from '@overflow/commons-typescript/model/commons/PageParams';
|
|
|
|
import { catchError, map, tap, take } from 'rxjs/operators';
|
|
|
|
import {Page} from '@overflow/commons-typescript/model/commons/Page';
|
2018-04-16 10:45:10 +00:00
|
|
|
|
2018-04-16 08:28:39 +00:00
|
|
|
@Component({
|
|
|
|
selector: 'of-target-list',
|
|
|
|
templateUrl: './list.component.html',
|
|
|
|
})
|
2018-04-29 11:56:46 +00:00
|
|
|
export class ListComponent implements OnInit, AfterContentInit, OnDestroy {
|
2018-04-16 08:28:39 +00:00
|
|
|
|
2018-06-05 11:31:29 +00:00
|
|
|
// infrasSubscription$: Subscription;
|
|
|
|
// infras$: Observable<Infra[]>;
|
|
|
|
// infras: Infra[];
|
|
|
|
// probe: Probe;
|
|
|
|
// target: Target = null;
|
|
|
|
// sensorSettingDisplay = false;
|
2018-04-16 08:28:39 +00:00
|
|
|
|
2018-06-06 10:36:51 +00:00
|
|
|
// pageSize = '10';
|
|
|
|
// totalLength = 0;
|
|
|
|
// currPage = 0;
|
2018-04-30 08:12:31 +00:00
|
|
|
|
2018-04-16 08:28:39 +00:00
|
|
|
constructor(
|
2018-06-06 10:36:51 +00:00
|
|
|
private store: Store<any>,
|
|
|
|
private targetService: TargetService,
|
2018-04-16 08:28:39 +00:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-05-24 06:44:13 +00:00
|
|
|
// this.infrasSubscription$ = this.infras$.subscribe(
|
|
|
|
// (page: Page) => {
|
|
|
|
// if (!page) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// this.totalLength = page.totalElements;
|
|
|
|
// this.infras = page.content;
|
|
|
|
// },
|
|
|
|
// (error: RPCClientError) => {
|
|
|
|
// console.log(error);
|
|
|
|
// }
|
|
|
|
// );
|
2018-06-06 10:36:51 +00:00
|
|
|
const pageParams: PageParams = {
|
|
|
|
pageNo: 0,
|
|
|
|
countPerPage: 10,
|
|
|
|
sortCol: 'id',
|
|
|
|
sortDirection: 'descending',
|
|
|
|
};
|
|
|
|
|
|
|
|
this.targetService.readAllByProbeID(1, pageParams)
|
|
|
|
.pipe(
|
|
|
|
tap(() => {
|
|
|
|
|
|
|
|
}),
|
|
|
|
map((r: Page<Target>) => {
|
|
|
|
console.log(r);
|
|
|
|
}),
|
|
|
|
catchError(err => {
|
|
|
|
console.log(err);
|
|
|
|
return err;
|
|
|
|
}),
|
|
|
|
take(1),
|
|
|
|
).subscribe();
|
2018-04-16 10:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterContentInit() {
|
2018-06-05 11:31:29 +00:00
|
|
|
// this.route.params.subscribe((params: any) => {
|
|
|
|
// this.probe = {
|
|
|
|
// id: params['id'],
|
|
|
|
// };
|
|
|
|
// this.getInfras(0);
|
|
|
|
// });
|
2018-04-16 10:45:10 +00:00
|
|
|
}
|
|
|
|
|
2018-04-29 11:56:46 +00:00
|
|
|
ngOnDestroy() {
|
2018-06-05 11:31:29 +00:00
|
|
|
// if (this.infrasSubscription$) {
|
|
|
|
// this.infrasSubscription$.unsubscribe();
|
|
|
|
// }
|
2018-04-29 11:56:46 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 08:12:31 +00:00
|
|
|
getInfras(pageNo) {
|
2018-05-24 06:44:13 +00:00
|
|
|
// const pageParams: PageParams = {
|
|
|
|
// pageNo: pageNo + '',
|
|
|
|
// countPerPage: this.pageSize,
|
|
|
|
// sortCol: 'id',
|
|
|
|
// sortDirection: 'descending'
|
|
|
|
// };
|
|
|
|
// this.infraListStore.dispatch(
|
|
|
|
// new InfraListStore.ReadAllByProbe(
|
|
|
|
// { probe: this.probe, pageParams: pageParams }
|
|
|
|
// )
|
|
|
|
// );
|
2018-04-16 08:28:39 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 10:45:10 +00:00
|
|
|
onRowSelect(event) {
|
2018-04-30 08:12:31 +00:00
|
|
|
// this.router.navigate(['target'], { queryParams: { target: event.data.id } });
|
2018-06-05 11:31:29 +00:00
|
|
|
// this.router.navigate(['target', event.data.id, 'info']);
|
2018-04-16 08:28:39 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 10:45:10 +00:00
|
|
|
onAddSensor(target: Target) {
|
2018-06-05 11:31:29 +00:00
|
|
|
// this.target = target;
|
|
|
|
// this.sensorSettingDisplay = true;
|
2018-04-16 10:45:10 +00:00
|
|
|
}
|
2018-04-16 08:28:39 +00:00
|
|
|
|
2018-04-16 10:45:10 +00:00
|
|
|
onSensorSettingClose() {
|
2018-06-05 11:31:29 +00:00
|
|
|
// this.sensorSettingDisplay = false;
|
2018-04-16 08:28:39 +00:00
|
|
|
}
|
2018-04-19 10:26:39 +00:00
|
|
|
|
2018-04-30 08:12:31 +00:00
|
|
|
onPaging(e) {
|
2018-06-05 11:31:29 +00:00
|
|
|
// this.getInfras(e.page);
|
2018-04-30 08:12:31 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 08:28:39 +00:00
|
|
|
}
|