This commit is contained in:
geek 2018-06-11 16:33:34 +09:00
parent c844548d68
commit a3c866bb75
7 changed files with 22 additions and 22 deletions

View File

@ -36,6 +36,7 @@ export class ListComponent implements OnInit, OnChanges {
@Input() probeID;
@Input() pageIdx;
@Output() pageChange = new EventEmitter<number>();
@Output() targetSelect = new EventEmitter<Target>();
@ViewChild('paginator') paginator: Paginator;
@ -54,19 +55,15 @@ export class ListComponent implements OnInit, OnChanges {
}
ngOnChanges(changes: SimpleChanges): void {
console.log(changes);
// console.log(changes);
if (changes['pageIdx'] && this.paginator) {
console.log(this.pageIdx);
// console.log(this.pageIdx);
this.getTargetList();
this.paginator.changePage(this.pageIdx);
}
}
private getTargetList() {
// console.log('----------------------------------------------------------------');
// console.log(this.pageIdx);
// console.log('----------------------------------------------------------------');
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) {
this.pageIdx = 0;
}
@ -97,8 +94,7 @@ export class ListComponent implements OnInit, OnChanges {
}
onRowSelect(event) {
// this.router.navigate(['target'], { queryParams: { target: event.data.id } });
// this.router.navigate(['target', event.data.id, 'info']);
this.targetSelect.emit(event.data);
}
onAddSensor(target: Target) {

View File

@ -13,6 +13,7 @@ const routes: Routes = [
{ path: 'discovery', loadChildren: './discovery/discovery-page.module#DiscoveryPageModule' },
{ path: 'map', loadChildren: './infra/infra-page.module#InfraPageModule' },
{ path: 'sensor', loadChildren: './sensors/sensor-tab-page.module#SensorTabPageModule' },
{ path: 'target/:id/info', loadChildren: './targets/target-page.module#TargetPageModule' },
// { path: 'target', loadChildren: './target/target-page.module#TargetPageModule' },
// { path: 'overview', loadChildren: './overview/overview-page.module#OverviewPageModule' },
// { path: 'dashboard', loadChildren: './dashboard/dashboard-page.module#DashboardPageModule' },

View File

@ -3,7 +3,7 @@
<div class="ui-g-12">
<div class="card no-margin">
<!--<of-discovery [probeHostID]="probeHostID"></of-discovery>-->
sdfsdf
sdfsdfasdasdasd
</div>
</div>
</div>

View File

@ -2,7 +2,7 @@
<div class="ui-g">
<div class="ui-g-12">
<div class="card no-margin">
<of-target-list [probeID]="probeID" [pageIdx]="pageIdx" (pageChange)="onPageChange($event)"></of-target-list>
<of-target-list [probeID]="probeID" [pageIdx]="pageIdx" (pageChange)="onPageChange($event)" (targetSelect)="onTargetSelect($event)" ></of-target-list>
</div>
</div>
</div>

View File

@ -1,5 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Target } from '@overflow/commons-typescript';
@Component({
selector: 'of-pages-target-list',
@ -19,20 +20,21 @@ export class TargetListPageComponent implements OnInit {
this.activatedRoute.queryParams.subscribe(queryParams => {
this.pageIdx = Number(queryParams['page']);
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null) {
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) {
this.pageIdx = 0;
}
// console.log('*****************************************************');
// console.log(this.pageIdx);
// console.log('*****************************************************');
});
// this.pageIdx = this.activatedRoute.snapshot.queryParams['page'] || 1;
}
onPageChange(pageNo: number) {
// console.log('**********************pageNo*******************************');
// console.log(pageNo);
// console.log('**********************pageNo*******************************');
this.router.navigate(['/probe', this.probeID, 'target'], { queryParams: { page: pageNo } });
}
onTargetSelect(target: Target) {
// console.log(target);
// this.router.navigate(['target'], { queryParams: { target: event.data.id } });
// this.router.navigate(['target', event.data.id, 'info']);
this.router.navigate(['/target', target.id, 'info']);
}
}

View File

@ -10,8 +10,8 @@ const routes: Routes = [
path: '',
component: TargetPageComponent,
children: [
{ path: 'list', component: TargetListPageComponent },
{ path: 'detail', component: TargetDetailPageComponent }
// { path: ':id/target', component: TargetListPageComponent },
{ path: ':id/info', component: TargetDetailPageComponent }
]
}
];

View File

@ -5,6 +5,7 @@
<!--<ng-template #complete>-->
<of-pages-target-list [probeID]="probeID" ></of-pages-target-list>
<!--</ng-template>-->
<!--<router-outlet></router-outlet>-->
</div>
</div>
</div>