From 553c6e3759bb603dd2ddb1573ab37ff03852a9f7 Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 4 Jun 2018 21:15:15 +0900 Subject: [PATCH] ing --- .../component/sensor-detail.component.html | 2 +- .../component/sensor-detail.component.ts | 9 ++-- .../sensor/component/sensor-list.component.ts | 2 +- .../sensors/sensor-tab-page-routing.module.ts | 7 +-- .../pages/sensors/sensor-tab-page.module.ts | 5 +++ .../sensor/sensor-detail-page.component.html | 1 + .../sensor/sensor-detail-page.component.ts | 37 ++++++++++++++++ .../sensor/sensor-list-page.component.html | 1 + .../sensor/sensor-list-page.component.ts | 43 +++++++++++++++++++ 9 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 src/app/pages/sensors/sensor/sensor-detail-page.component.html create mode 100644 src/app/pages/sensors/sensor/sensor-detail-page.component.ts create mode 100644 src/app/pages/sensors/sensor/sensor-list-page.component.html create mode 100644 src/app/pages/sensors/sensor/sensor-list-page.component.ts diff --git a/@overflow/sensor/component/sensor-detail.component.html b/@overflow/sensor/component/sensor-detail.component.html index 19fbce1..addf489 100644 --- a/@overflow/sensor/component/sensor-detail.component.html +++ b/@overflow/sensor/component/sensor-detail.component.html @@ -38,7 +38,7 @@ SENSOR_DETAIL_COMPONENT
- + diff --git a/@overflow/sensor/component/sensor-detail.component.ts b/@overflow/sensor/component/sensor-detail.component.ts index c88a642..c627fcf 100644 --- a/@overflow/sensor/component/sensor-detail.component.ts +++ b/@overflow/sensor/component/sensor-detail.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Inject, AfterContentInit, OnDestroy, Input } from '@angular/core'; +import { Component, OnInit, Inject, AfterContentInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core'; import { Store, select } from '@ngrx/store'; @@ -11,6 +11,7 @@ import { RPCClientError } from '@loafer/ng-rpc'; import { Sensor } from '@overflow/commons-typescript/model/sensor'; import { SensorService } from '../service/sensor.service'; +import { Target } from '@overflow/commons-typescript/model/target'; @Component({ selector: 'of-sensor-detail', @@ -19,6 +20,7 @@ import { SensorService } from '../service/sensor.service'; }) export class SensorDetailComponent implements OnInit, OnDestroy { @Input() sensorID: number; + @Output() selectTarget = new EventEmitter(); sensor: Sensor; sensorSettingDisplay: boolean; @@ -75,10 +77,5 @@ export class SensorDetailComponent implements OnInit, OnDestroy { } }); } - - onTargetClick(target) { - // this.router.navigate(['sensors'], { queryParams: { target: target.id } }); - // this.router.navigate(['target', target.id, 'info']); - } } diff --git a/@overflow/sensor/component/sensor-list.component.ts b/@overflow/sensor/component/sensor-list.component.ts index 6475453..6136edf 100644 --- a/@overflow/sensor/component/sensor-list.component.ts +++ b/@overflow/sensor/component/sensor-list.component.ts @@ -18,10 +18,10 @@ import { PageParams } from '@overflow/commons-typescript/model/commons/PageParam templateUrl: './sensor-list.component.html', }) export class SensorListComponent implements OnInit, OnChanges { + @Input() pageNo: number; @Output() select = new EventEmitter(); @Output() addSensor = new EventEmitter(); - pageNo = 1; page: Page; pending$: Observable; error$: Observable; diff --git a/src/app/pages/sensors/sensor-tab-page-routing.module.ts b/src/app/pages/sensors/sensor-tab-page-routing.module.ts index 84446b7..5d3c797 100644 --- a/src/app/pages/sensors/sensor-tab-page-routing.module.ts +++ b/src/app/pages/sensors/sensor-tab-page-routing.module.ts @@ -1,15 +1,16 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { SensorTabPageComponent } from './sensor-tab-page.component'; +import { SensorListPageComponent } from '@app/pages/sensors/sensor/sensor-list-page.component'; +import { SensorDetailPageComponent } from '@app/pages/sensors/sensor/sensor-detail-page.component'; const routes: Routes = [ { path: '', component: SensorTabPageComponent, children: [ - { path: 'list', loadChildren: './sensor/sensor-page.module#SensorPageModule' }, - { path: 'setting', loadChildren: './sensor/sensor-page.module#SensorPageModule' }, - { path: ':id/info', loadChildren: './sensor/sensor-page.module#SensorPageModule' }, + { path: 'list', component: SensorListPageComponent }, + { path: ':id/info', component: SensorDetailPageComponent }, { path: ':id/history', component: null }, ] }, diff --git a/src/app/pages/sensors/sensor-tab-page.module.ts b/src/app/pages/sensors/sensor-tab-page.module.ts index de92ae3..219904f 100644 --- a/src/app/pages/sensors/sensor-tab-page.module.ts +++ b/src/app/pages/sensors/sensor-tab-page.module.ts @@ -5,6 +5,9 @@ import { UIModule } from '@overflow/shared/ui/ui.module'; import { SensorModule } from '@overflow/sensor/sensor.module'; import { SensorTabPageComponent } from './sensor-tab-page.component'; +import { SensorListPageComponent } from '@app/pages/sensors/sensor/sensor-list-page.component'; +import { SensorDetailPageComponent } from '@app/pages/sensors/sensor/sensor-detail-page.component'; + import { SensorTabPageRoutingModule } from './sensor-tab-page-routing.module'; import { TabbarModule } from '../../commons/component/layout/tabbar/app.tabbar.module'; @@ -18,6 +21,8 @@ import { TabbarModule } from '../../commons/component/layout/tabbar/app.tabbar.m ], declarations: [ SensorTabPageComponent, + SensorListPageComponent, + SensorDetailPageComponent, ] }) export class SensorTabPageModule { } diff --git a/src/app/pages/sensors/sensor/sensor-detail-page.component.html b/src/app/pages/sensors/sensor/sensor-detail-page.component.html new file mode 100644 index 0000000..39a720d --- /dev/null +++ b/src/app/pages/sensors/sensor/sensor-detail-page.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/pages/sensors/sensor/sensor-detail-page.component.ts b/src/app/pages/sensors/sensor/sensor-detail-page.component.ts new file mode 100644 index 0000000..8e40f96 --- /dev/null +++ b/src/app/pages/sensors/sensor/sensor-detail-page.component.ts @@ -0,0 +1,37 @@ +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Router, ActivatedRoute, NavigationEnd } from '@angular/router'; +import { Subscription } from 'rxjs'; +import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; +import { Target } from '@overflow/commons-typescript/model/target'; +import { BreadcrumbService } from '@app/commons/service/breadcrumb.service'; + +@Component({ + selector: 'of-pages-sensor-detail', + templateUrl: './sensor-detail-page.component.html', +}) +export class SensorDetailPageComponent implements OnInit { + + isDetail: boolean; + sensorID: string; + + constructor( + private router: Router, + private route: ActivatedRoute, + private breadcrumbService: BreadcrumbService + ) { + } + + ngOnInit(): void { + this.route.params.subscribe(params => { + this.sensorID = params['id']; + }); + } + + onTargetSelect(target: Target) { + this.router.navigate(['target', target.id, 'info']); + } + + onDiscovery(probeHostID: number) { + this.router.navigate(['discovery', probeHostID]); + } +} diff --git a/src/app/pages/sensors/sensor/sensor-list-page.component.html b/src/app/pages/sensors/sensor/sensor-list-page.component.html new file mode 100644 index 0000000..d313fd0 --- /dev/null +++ b/src/app/pages/sensors/sensor/sensor-list-page.component.html @@ -0,0 +1 @@ + diff --git a/src/app/pages/sensors/sensor/sensor-list-page.component.ts b/src/app/pages/sensors/sensor/sensor-list-page.component.ts new file mode 100644 index 0000000..9379f7b --- /dev/null +++ b/src/app/pages/sensors/sensor/sensor-list-page.component.ts @@ -0,0 +1,43 @@ +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Router, ActivatedRoute, NavigationEnd } from '@angular/router'; +import { Subscription } from 'rxjs'; +import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; +import { Target } from '@overflow/commons-typescript/model/target'; +import { BreadcrumbService } from '@app/commons/service/breadcrumb.service'; +import { Sensor } from '@overflow/commons-typescript/model/sensor'; + +@Component({ + selector: 'of-pages-sensor-list', + templateUrl: './sensor-list-page.component.html', +}) +export class SensorListPageComponent implements OnInit { + pageNo: number; + + constructor( + private router: Router, + private route: ActivatedRoute, + private breadcrumbService: BreadcrumbService + ) { + this.breadcrumbService.setItems([ + { label: 'Sensor', routerLink: ['/sensor/list'], } + ]); + } + + ngOnInit() { + this.route.queryParams.subscribe(queryParams => { + this.pageNo = queryParams['page'] || 1; + }); + } + + onSensorSelect(sensor: Sensor) { + this.router.navigate(['sensor', sensor.id, 'info']); + } + + onAddSensor() { + this.router.navigate(['sensor', 0, 'info']); + } + + onPageChange(pageNo: number) { + this.router.navigate(['/notification'], { queryParams: { page: pageNo } }); + } +}