This commit is contained in:
crusader 2018-06-04 21:15:15 +09:00
parent c47bb4fad5
commit 553c6e3759
9 changed files with 96 additions and 11 deletions

View File

@ -38,7 +38,7 @@ SENSOR_DETAIL_COMPONENT
<p-panel [showHeader]="false">
<div class="ui-g form-group ui-key-value">
<of-key-value [key]="'ID'" [value]="sensor.id"></of-key-value>
<of-key-value [key]="'Location'" [value]="sensor.target.displayName" [clickable]="true" (click)="onTargetClick(sensor.target)"></of-key-value>
<of-key-value [key]="'Location'" [value]="sensor.target.displayName" [clickable]="true" (click)="selectTarget.emit(sensor.target)"></of-key-value>
<of-key-value [key]="'Description'" [value]="sensor.description"></of-key-value>
<of-key-value [key]="'Crawler Type'" [value]="sensor.crawler.name"></of-key-value>
<of-key-value [key]="'Sensor Items'" [value]="sensor.itemCount"></of-key-value>

View File

@ -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<Target>();
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']);
}
}

View File

@ -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<Sensor>();
@Output() addSensor = new EventEmitter();
pageNo = 1;
page: Page<Sensor>;
pending$: Observable<boolean>;
error$: Observable<any>;

View File

@ -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 },
]
},

View File

@ -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 { }

View File

@ -0,0 +1 @@
<of-sensor-detail [sensorID]="sensorID" (discovery)="onDiscovery($event)"></of-sensor-detail>

View File

@ -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]);
}
}

View File

@ -0,0 +1 @@
<of-sensor-list [pageNo]="pageNo" (select)="onSensorSelect($event)" (addSensor)="onAddSensor($event)"></of-sensor-list>

View File

@ -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 } });
}
}