ing
This commit is contained in:
parent
378c65c514
commit
0fe54aaa86
|
@ -1,5 +1,5 @@
|
|||
SENSOR_DETAIL_COMPONENT
|
||||
<!-- <div *ngIf="sensor">
|
||||
<div *ngIf="sensor">
|
||||
<h1>{{sensor.crawler.name}}</h1>
|
||||
|
||||
<div class="ui-g">
|
||||
|
@ -53,4 +53,4 @@ SENSOR_DETAIL_COMPONENT
|
|||
</div>
|
||||
<p-confirmDialog header="Confirmation" icon="fa ui-icon-warning" width="425"></p-confirmDialog>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
|
|
@ -1,82 +1,83 @@
|
|||
import { Component, OnInit, Inject, AfterContentInit, OnDestroy } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ConfirmationService } from 'primeng/primeng';
|
||||
import { Component, OnInit, Inject, AfterContentInit, OnDestroy, Input } from '@angular/core';
|
||||
|
||||
import { Store, select } from '@ngrx/store';
|
||||
|
||||
import { Observable, of, Subscription } from 'rxjs';
|
||||
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
||||
|
||||
import { ConfirmationService } from 'primeng/primeng';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
// import { sensorSelector } from '../../store';
|
||||
|
||||
import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { SensorService } from '../service/sensor.service';
|
||||
|
||||
@Component({
|
||||
selector: 'of-sensor-detail',
|
||||
templateUrl: './sensor-detail.component.html',
|
||||
providers: [ConfirmationService]
|
||||
})
|
||||
export class SensorDetailComponent {
|
||||
export class SensorDetailComponent implements OnInit, OnDestroy {
|
||||
@Input() sensorID: number;
|
||||
|
||||
// sensorSubscription$: Subscription;
|
||||
// sensor$ = this.detailStore.pipe(select(sensorSelector.select('sensor')));
|
||||
// sensor: Sensor;
|
||||
// sensorSettingDisplay: boolean;
|
||||
sensor: Sensor;
|
||||
sensorSettingDisplay: boolean;
|
||||
|
||||
// constructor(
|
||||
// private route: ActivatedRoute,
|
||||
// private router: Router,
|
||||
// private confirmationService: ConfirmationService,
|
||||
// private detailStore: Store<DetailStore.State>,
|
||||
// ) {
|
||||
// this.sensorSettingDisplay = false;
|
||||
// }
|
||||
pending$: Observable<boolean>;
|
||||
error$: Observable<any>;
|
||||
|
||||
// ngOnInit() {
|
||||
// this.sensorSubscription$ = this.sensor$.subscribe(
|
||||
// (sensor: Sensor) => {
|
||||
// console.log(sensor);
|
||||
// this.sensor = sensor;
|
||||
// },
|
||||
// (error: RPCClientError) => {
|
||||
// console.log(error.response.message);
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
constructor(
|
||||
private confirmationService: ConfirmationService,
|
||||
private store: Store<any>,
|
||||
private sensorService: SensorService,
|
||||
) {
|
||||
this.sensorSettingDisplay = false;
|
||||
}
|
||||
|
||||
// ngAfterContentInit() {
|
||||
// const sensorId = this.route.snapshot.paramMap.get('id');
|
||||
// this.detailStore.dispatch(
|
||||
// new DetailStore.Read(
|
||||
// { id: sensorId }
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
ngOnInit() {
|
||||
this.sensorService.read(this.sensorID)
|
||||
.pipe(
|
||||
tap(() => {
|
||||
this.pending$ = of(true);
|
||||
}),
|
||||
map((sensor: Sensor) => {
|
||||
this.sensor = sensor;
|
||||
}),
|
||||
catchError(error => {
|
||||
this.error$ = of(error);
|
||||
return of();
|
||||
}),
|
||||
tap(() => {
|
||||
this.pending$ = of(false);
|
||||
}),
|
||||
).take(1).subscribe();
|
||||
}
|
||||
|
||||
// ngOnDestroy() {
|
||||
// if (this.sensorSubscription$) {
|
||||
// this.sensorSubscription$.unsubscribe();
|
||||
// }
|
||||
// }
|
||||
ngOnDestroy() {
|
||||
}
|
||||
|
||||
// onStartOrStop() { }
|
||||
onStartOrStop() { }
|
||||
|
||||
// onEdit() {
|
||||
// this.sensorSettingDisplay = true;
|
||||
// }
|
||||
onEdit() {
|
||||
this.sensorSettingDisplay = true;
|
||||
}
|
||||
|
||||
// onRemove() {
|
||||
// this.confirmationService.confirm({
|
||||
// header: 'Are you sure to remove this Sensor?',
|
||||
// icon: 'fa fa-trash',
|
||||
// message: 'All the related data will be deleted. ',
|
||||
// accept: () => {
|
||||
// alert('으앙 안돼 지우지마ㅠㅠ');
|
||||
// },
|
||||
// reject: () => {
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
onRemove() {
|
||||
this.confirmationService.confirm({
|
||||
header: 'Are you sure to remove this Sensor?',
|
||||
icon: 'fa fa-trash',
|
||||
message: 'All the related data will be deleted. ',
|
||||
accept: () => {
|
||||
alert('으앙 안돼 지우지마ㅠㅠ');
|
||||
},
|
||||
reject: () => {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// onTargetClick(target) {
|
||||
// // this.router.navigate(['sensors'], { queryParams: { target: target.id } });
|
||||
// this.router.navigate(['target', target.id, 'info']);
|
||||
// }
|
||||
onTargetClick(target) {
|
||||
// this.router.navigate(['sensors'], { queryParams: { target: target.id } });
|
||||
// this.router.navigate(['target', target.id, 'info']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ export class SensorService {
|
|||
// return this.rpcService.call('SensorService.readAllByTarget', target, pageParams);
|
||||
// }
|
||||
|
||||
public read(id: string): Observable<Sensor> {
|
||||
public read(id: number): Observable<Sensor> {
|
||||
return this.rpcService.call<Sensor>('SensorService.read', id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<of-sensor-list *ngIf="containerType === 1" (select)="onSensorSelect($event)" (addSensor)="onAddSensor($event)">
|
||||
</of-sensor-list>
|
||||
<of-sensor-detail *ngIf="containerType === 2"></of-sensor-detail>
|
||||
<of-sensor-detail *ngIf="containerType === 2" [sensorID]="sensorID"></of-sensor-detail>
|
||||
<of-sensor-setting *ngIf="containerType === 3"></of-sensor-setting>
|
Loading…
Reference in New Issue
Block a user