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';
|
2018-04-16 08:28:39 +00:00
|
|
|
import { Store, select } from '@ngrx/store';
|
2018-05-24 06:44:13 +00:00
|
|
|
import { ListSelector } from '@overflow/infra/store';
|
|
|
|
import * as InfraListStore from '@overflow/infra/store/list';
|
|
|
|
// import { Page, PageParams } from 'app/commons/model';
|
|
|
|
import { RPCClientError } from '@loafer/ng-rpc';
|
2018-05-02 08:25:38 +00:00
|
|
|
import { Probe } from '@overflow/commons-typescript/model/probe';
|
2018-04-16 08:28:39 +00:00
|
|
|
|
2018-05-02 08:25:38 +00:00
|
|
|
import { Target } from '@overflow/commons-typescript/model/target';
|
2018-04-29 11:56:46 +00:00
|
|
|
import { Subscription } from 'rxjs/Subscription';
|
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-04-29 11:56:46 +00:00
|
|
|
infrasSubscription$: Subscription;
|
2018-04-16 10:45:10 +00:00
|
|
|
infras$ = this.infraListStore.pipe(select(ListSelector.select('page')));
|
2018-04-16 08:28:39 +00:00
|
|
|
infras: Infra[];
|
|
|
|
probe: Probe;
|
2018-04-16 10:45:10 +00:00
|
|
|
target: Target = null;
|
|
|
|
sensorSettingDisplay = false;
|
2018-04-16 08:28:39 +00:00
|
|
|
|
2018-04-30 08:12:31 +00:00
|
|
|
pageSize = '10';
|
|
|
|
totalLength = 0;
|
|
|
|
currPage = 0;
|
|
|
|
|
2018-04-16 08:28:39 +00:00
|
|
|
constructor(
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private router: Router,
|
2018-04-16 10:45:10 +00:00
|
|
|
private infraListStore: Store<InfraListStore.State>,
|
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-04-16 10:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterContentInit() {
|
2018-04-19 12:56:24 +00:00
|
|
|
this.route.params.subscribe((params: any) => {
|
2018-04-30 08:12:31 +00:00
|
|
|
this.probe = {
|
2018-04-19 12:56:24 +00:00
|
|
|
id: params['id'],
|
|
|
|
};
|
2018-04-30 08:12:31 +00:00
|
|
|
this.getInfras(0);
|
2018-04-19 12:56:24 +00:00
|
|
|
});
|
2018-04-16 10:45:10 +00:00
|
|
|
}
|
|
|
|
|
2018-04-29 11:56:46 +00:00
|
|
|
ngOnDestroy() {
|
|
|
|
if (this.infrasSubscription$) {
|
|
|
|
this.infrasSubscription$.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 } });
|
|
|
|
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) {
|
|
|
|
this.target = target;
|
|
|
|
this.sensorSettingDisplay = true;
|
|
|
|
}
|
2018-04-16 08:28:39 +00:00
|
|
|
|
2018-04-16 10:45:10 +00:00
|
|
|
onSensorSettingClose() {
|
|
|
|
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) {
|
|
|
|
this.getInfras(e.page);
|
|
|
|
}
|
|
|
|
|
2018-04-16 08:28:39 +00:00
|
|
|
}
|