member_webapp/@overflow/target/component/list/list.component.ts

87 lines
2.3 KiB
TypeScript
Raw Normal View History

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 06:24:55 +00:00
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
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({
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
}