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-07 06:24:55 +00:00
|
|
|
import { Observable, of, Subscription } from 'rxjs';
|
2018-06-05 11:31:29 +00:00
|
|
|
import { Store, select } from '@ngrx/store';
|
2018-06-07 06:24:55 +00:00
|
|
|
import { catchError, map, tap, take } from 'rxjs/operators';
|
|
|
|
|
2018-06-06 10:36:51 +00:00
|
|
|
import { TargetService } from '../../service/target.service';
|
|
|
|
import { InfraService } from '@overflow/infra/service/infra.service';
|
2018-06-07 07:28:27 +00:00
|
|
|
import { Page, PageParams } from '@overflow/commons-typescript/core/model';
|
2018-04-16 10:45:10 +00:00
|
|
|
|
2018-04-16 08:28:39 +00:00
|
|
|
@Component({
|
2018-06-07 06:24:55 +00:00
|
|
|
selector: 'of-target-list',
|
|
|
|
templateUrl: './list.component.html',
|
2018-04-16 08:28:39 +00:00
|
|
|
})
|
2018-06-07 06:30:15 +00:00
|
|
|
export class ListComponent implements OnInit {
|
2018-04-16 08:28:39 +00:00
|
|
|
|
2018-06-07 06:24:55 +00:00
|
|
|
page: Page<Target>;
|
|
|
|
pending$: Observable<boolean>;
|
|
|
|
error$: Observable<any>;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private store: Store<any>,
|
|
|
|
private targetService: TargetService,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
const pageParams: PageParams = {
|
|
|
|
pageNo: 0,
|
2018-06-07 06:30:15 +00:00
|
|
|
countPerPage: 5,
|
2018-06-07 06:24:55 +00:00
|
|
|
sortCol: 'id',
|
|
|
|
sortDirection: 'descending',
|
|
|
|
};
|
|
|
|
|
|
|
|
this.targetService.readAllByProbeID(1, pageParams)
|
|
|
|
.pipe(
|
|
|
|
tap(() => {
|
|
|
|
this.pending$ = of(true);
|
|
|
|
}),
|
|
|
|
map((page: Page<Target>) => {
|
|
|
|
this.page = page;
|
|
|
|
}),
|
|
|
|
catchError(err => {
|
|
|
|
console.log(err);
|
|
|
|
return err;
|
|
|
|
}),
|
|
|
|
tap(() => {
|
|
|
|
this.pending$ = of(false);
|
|
|
|
}),
|
|
|
|
take(1),
|
|
|
|
).subscribe();
|
|
|
|
}
|
|
|
|
|
|
|
|
getInfras(pageNo) {
|
|
|
|
// const pageParams: PageParams = {
|
|
|
|
// pageNo: pageNo + '',
|
|
|
|
// countPerPage: this.pageSize,
|
|
|
|
// sortCol: 'id',
|
|
|
|
// sortDirection: 'descending'
|
|
|
|
// };
|
|
|
|
// this.infraListStore.dispatch(
|
|
|
|
// new InfraListStore.ReadAllByProbe(
|
|
|
|
// { probe: this.probe, pageParams: pageParams }
|
|
|
|
// )
|
|
|
|
// );
|
|
|
|
}
|
|
|
|
|
|
|
|
onRowSelect(event) {
|
|
|
|
// this.router.navigate(['target'], { queryParams: { target: event.data.id } });
|
|
|
|
// this.router.navigate(['target', event.data.id, 'info']);
|
|
|
|
}
|
|
|
|
|
|
|
|
onAddSensor(target: Target) {
|
|
|
|
// this.target = target;
|
|
|
|
// this.sensorSettingDisplay = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
onPaginate(event) {
|
|
|
|
|
|
|
|
}
|
2018-04-16 08:28:39 +00:00
|
|
|
}
|