sensor in progress
This commit is contained in:
parent
1df1e0bb55
commit
2cce12ea37
|
@ -78,9 +78,9 @@
|
|||
<p-contextMenu #cmService [model]="contextMenuService"></p-contextMenu>
|
||||
<p-contextMenu #cmSensor [model]="contextMenuSensor"></p-contextMenu>
|
||||
|
||||
<p-dialog [modal]="true" [width]="800" [(visible)]="sensorSettingDisplay" [showHeader]="true" [closeOnEscape]="false">
|
||||
<!-- <p-dialog [modal]="true" [width]="800" [(visible)]="sensorSettingDisplay" [showHeader]="true" [closeOnEscape]="false">
|
||||
<of-sensor-setting [visible]="sensorSettingDisplay" [preTarget]="target" (close)="onSensorSettingClose()"></of-sensor-setting>
|
||||
</p-dialog>
|
||||
</p-dialog> -->
|
||||
|
||||
|
||||
<p-dialog header="Rename Probe" [(visible)]="renameProbeVisible" [modal]="true" [responsive]="true" [width]="350" [minWidth]="200"
|
||||
|
|
|
@ -13,7 +13,7 @@ import { Subscription } from 'rxjs/Subscription';
|
|||
templateUrl: './detail.component.html',
|
||||
providers: [ConfirmationService]
|
||||
})
|
||||
export class DetailComponent {
|
||||
export class SensorDetailComponent {
|
||||
|
||||
// sensorSubscription$: Subscription;
|
||||
// sensor$ = this.detailStore.pipe(select(sensorSelector.select('sensor')));
|
||||
|
|
|
@ -1,22 +1,7 @@
|
|||
import { SensorListComponent } from './list/list.component';
|
||||
|
||||
import { TargetSelectorComponent } from './setting/target-selector/target-selector.component';
|
||||
import { CrawlerSelectorComponent } from './setting/crawler-selector/crawler-selector.component';
|
||||
import { CrawlerAuthComponent } from './setting/crawler-auth/crawler-auth.component';
|
||||
import { SensorItemSelectorComponent } from './setting/sensor-item-selector/sensor-item-selector.component';
|
||||
import { SettingETCComponent } from './setting/setting-etc/setting-etc.component';
|
||||
import { DetailComponent } from './detail/detail.component';
|
||||
// import { FilterComponent } from './list/filter/filter.component';
|
||||
// import { TargetSelectorComponent } from './setting/target-selector/target-selector.component';
|
||||
import { SensorDetailComponent } from './detail/detail.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
TargetSelectorComponent,
|
||||
CrawlerSelectorComponent,
|
||||
CrawlerAuthComponent,
|
||||
SensorItemSelectorComponent,
|
||||
SettingETCComponent,
|
||||
SensorListComponent,
|
||||
DetailComponent,
|
||||
// FilterComponent,
|
||||
// SettingETCComponent,
|
||||
SensorDetailComponent,
|
||||
];
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</div>
|
||||
|
||||
<div class="ui-g-12 ui-md-9">
|
||||
<p-dataList [value]="targetSensor" [paginator]="true" styleClass="ui-sensors-datalist" [rows]="10">
|
||||
<p-dataList [value]="targetSensors" [paginator]="true" styleClass="ui-sensors-datalist" [rows]="10">
|
||||
<!-- <p-header>
|
||||
List of Cars
|
||||
</p-header> -->
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
||||
import { Page } from '@overflow/commons-typescript/model/commons/Page';
|
||||
import { Target } from '@overflow/commons-typescript/model/target';
|
||||
|
||||
@Component({
|
||||
selector: 'of-sensor-list',
|
||||
|
@ -10,8 +11,8 @@ export class SensorListComponent implements OnChanges {
|
|||
|
||||
@Input() page: Page<Sensor>;
|
||||
|
||||
totalLength;
|
||||
targetSensor;
|
||||
totalLength: number;
|
||||
targetSensors: Object;
|
||||
|
||||
constructor(
|
||||
) { }
|
||||
|
@ -41,7 +42,7 @@ export class SensorListComponent implements OnChanges {
|
|||
}
|
||||
}
|
||||
this.totalLength = tempList.length;
|
||||
this.targetSensor = tempList;
|
||||
this.targetSensors = tempList;
|
||||
}
|
||||
|
||||
existTarget(sensor: Sensor, tempList) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1>Add Sensor</h1>
|
||||
<!-- <h1>Add Sensor</h1>
|
||||
<div *ngIf="page === 1; else etc">
|
||||
<p-accordion [multiple]="false" [activeIndex]="step" (onOpen)="onTabOpen($event)">
|
||||
<p-accordionTab header="{{getTitle(0)}}" [disabled]="preTarget" class="ui-nopad">
|
||||
|
@ -26,35 +26,6 @@
|
|||
|
||||
<button pButton *ngIf="page === 1" class="ui-button-danger ui-button-width-fit" type="button" label="Cancel" icon="ui-icon-close" (click)="onCancel()"></button>
|
||||
<button pButton *ngIf="page === 2" class="ui-button-danger ui-button-width-fit" type="button" label="Prev" icon="ui-icon-close" (click)="onPrev()"></button>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
|
||||
<!-- <div [hidden]="step !== 1">
|
||||
<div class="ui-g">
|
||||
<div class="ui-g-6">
|
||||
<of-target-selector [preTarget]="preTarget" (targetSelected)="onTargetSelect($event)"></of-target-selector>
|
||||
</div>
|
||||
<div class="ui-g-6">
|
||||
<of-crawler-auth [crawler]="selectedCrawler" (credentialPassed)="onCredentialPass($event)"></of-crawler-auth>
|
||||
</div>
|
||||
<div class="ui-g-6">
|
||||
<of-crawler-selector [target]="selectedTarget" (crawlerSelected)="onCrawlerSelect($event)"></of-crawler-selector>
|
||||
</div>
|
||||
<div class="ui-g-6">
|
||||
<of-sensor-item-selector [target]="selectedTarget" [crawler]="selectedCrawler" (sensorItemsSelected)="onItemsSelect($event)"></of-sensor-item-selector>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="step === 2">
|
||||
<of-sensor-setting-etc [selectedTarget]="selectedTarget" [selectedCrawler]="selectedCrawler" [selectedItems]="selectedSensorDisplayItems"></of-sensor-setting-etc>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button pButton *ngIf="step === 1" class="ui-button-danger" type="button" label="Cancel" icon="ui-icon-close" (click)="onCancel()"></button>
|
||||
<button pButton *ngIf="step === 2" class="ui-button-danger" type="button" label="Prev" icon="ui-icon-close" (click)="onPrev()"></button>
|
||||
|
||||
<button pButton *ngIf="step === 1" [disabled]="!nextable" type="button" label="Next" icon="fa-check" (click)="onNext()"></button>
|
||||
<button pButton *ngIf="step === 2" type="button" label="Done" icon="fa-check" (click)="onDone()"></button>
|
||||
</div> -->
|
||||
<div>SENSOR_SETTING_COMPONENT</div>
|
|
@ -1,161 +1,13 @@
|
|||
import { Component, OnInit, Input, Inject, DoCheck, ViewEncapsulation, Output, EventEmitter, OnChanges } from '@angular/core';
|
||||
import { Target } from '@overflow/commons-typescript/model/target';
|
||||
import { Infra } from '@overflow/commons-typescript/model/infra';
|
||||
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
|
||||
import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta';
|
||||
|
||||
import { Store, select, StateObservable } from '@ngrx/store';
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
import * as SensorItemKeyListStore from '@overflow/sensor-item/store/key-list';
|
||||
import { ReadSensorItemKeySelector } from '@overflow/sensor-item/store';
|
||||
import { MetaSensorItemKey } from '@overflow/commons-typescript/model/meta';
|
||||
import { TreeNode } from 'primeng/primeng';
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'of-sensor-setting',
|
||||
templateUrl: './setting.component.html',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SettingComponent implements OnInit, DoCheck, OnChanges {
|
||||
|
||||
@Input() preTarget: Target;
|
||||
@Output() close = new EventEmitter();
|
||||
@Input() visible: boolean;
|
||||
@Input() editMode: boolean;
|
||||
|
||||
nextable = false;
|
||||
selectedTarget: Target;
|
||||
selectedCrawler: MetaCrawler;
|
||||
credentialPassed: boolean;
|
||||
selectedSensorDisplayItems: MetaSensorDisplayItem[];
|
||||
itemNodes: TreeNode[];
|
||||
step = 0;
|
||||
page = 1;
|
||||
|
||||
sensorItemKeys$: StateObservable;
|
||||
export class SettingComponent {
|
||||
|
||||
|
||||
constructor(
|
||||
private keyListStore: Store<SensorItemKeyListStore.State>
|
||||
) {
|
||||
keyListStore.pipe(select(ReadSensorItemKeySelector.select('list')));
|
||||
this.editMode = true;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.step = this.preTarget ? 1 : 0;
|
||||
// this.sensorItemKeys$.subscribe(
|
||||
// (list: MetaSensorItemKey[]) => {
|
||||
// if (list !== null) {
|
||||
// console.log(list);
|
||||
// }
|
||||
// },
|
||||
// (error: RPCClientError) => {
|
||||
// console.log(error.response.message);
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
ngOnChanges(changes) {
|
||||
this.step = this.preTarget ? 1 : 0;
|
||||
}
|
||||
|
||||
ngDoCheck() {
|
||||
try {
|
||||
if (
|
||||
this.selectedTarget === null ||
|
||||
this.selectedCrawler === null ||
|
||||
this.itemNodes === null ||
|
||||
this.itemNodes.length === 0 ||
|
||||
!this.credentialPassed
|
||||
) {
|
||||
this.nextable = false;
|
||||
} else {
|
||||
this.nextable = true;
|
||||
}
|
||||
} catch (exception) {
|
||||
this.nextable = false;
|
||||
}
|
||||
}
|
||||
|
||||
onCancel() {
|
||||
this.page = 1;
|
||||
this.step = 0;
|
||||
this.visible = false;
|
||||
this.nextable = false;
|
||||
this.selectedTarget = null;
|
||||
this.selectedCrawler = null;
|
||||
this.credentialPassed = false;
|
||||
this.selectedSensorDisplayItems = null;
|
||||
this.close.emit();
|
||||
}
|
||||
|
||||
onNext() {
|
||||
this.page += 1;
|
||||
}
|
||||
|
||||
onPrev() {
|
||||
this.page -= 1;
|
||||
}
|
||||
|
||||
onDone() {
|
||||
this.selectedSensorDisplayItems = [];
|
||||
for (const node of this.itemNodes) {
|
||||
if (node.data && node.data !== undefined) {
|
||||
this.selectedSensorDisplayItems.push(node.data);
|
||||
}
|
||||
}
|
||||
console.log(this.selectedSensorDisplayItems);
|
||||
}
|
||||
|
||||
onTargetSelect(t: Target) {
|
||||
this.selectedTarget = t;
|
||||
this.step = 1;
|
||||
}
|
||||
onCrawlerSelect(c: MetaCrawler) {
|
||||
this.selectedCrawler = c;
|
||||
this.step = 2;
|
||||
}
|
||||
onCredentialPass(b: boolean) {
|
||||
if (!b) {
|
||||
return;
|
||||
}
|
||||
this.credentialPassed = b;
|
||||
this.step = 3;
|
||||
}
|
||||
onItemsSelect(nodes: TreeNode[]) {
|
||||
this.itemNodes = nodes;
|
||||
}
|
||||
|
||||
onTabOpen(event) {
|
||||
this.step = event.index;
|
||||
}
|
||||
|
||||
getTitle(index) {
|
||||
if (index === 0 && this.preTarget) {
|
||||
return this.preTarget.displayName;
|
||||
}
|
||||
let title = '';
|
||||
switch (index) {
|
||||
case 0:
|
||||
title = this.selectedTarget && this.step !== index ?
|
||||
this.selectedTarget.displayName :
|
||||
'Choose a Target to monitor.';
|
||||
break;
|
||||
case 1:
|
||||
title = this.selectedCrawler && this.step !== index ?
|
||||
this.selectedCrawler.name :
|
||||
'Choose a Crawler.';
|
||||
break;
|
||||
case 2:
|
||||
title = this.credentialPassed && this.step !== index ?
|
||||
'Credentials test succeed.' :
|
||||
'Credentials';
|
||||
break;
|
||||
case 3:
|
||||
title = 'Choose Sensor Items.';
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { SensorListContainerComponent } from './sensor-list-container.component';
|
||||
import { SensorDetailContainerComponent } from './sensor-detail-container.component';
|
||||
import { SensorSettingContainerComponent } from './sensor-setting-container.component';
|
||||
|
||||
export const CONTAINER_COMPONENTS = [
|
||||
SensorListContainerComponent,
|
||||
SensorDetailContainerComponent
|
||||
SensorDetailContainerComponent,
|
||||
SensorSettingContainerComponent
|
||||
];
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<div>SENSOR_ADD_CONTAINER</div>
|
|
@ -0,0 +1,17 @@
|
|||
import { Component, EventEmitter, Output, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Store, select } from '@ngrx/store';
|
||||
import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
||||
import * as SensorEntityStore from '../store/entity/sensor';
|
||||
import { SensorEntitySelector } from '../store';
|
||||
|
||||
@Component({
|
||||
selector: 'of-sensor-setting-container',
|
||||
templateUrl: './sensor-setting-container.component.html',
|
||||
})
|
||||
export class SensorSettingContainerComponent {
|
||||
|
||||
constructor(private store: Store<SensorEntityStore.State>) {
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { SensorPageComponent } from './sensor-page.component';
|
||||
import { DetailComponent } from '@overflow/sensor/component/detail/detail.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: SensorPageComponent,
|
||||
children: [
|
||||
{ path: ':id/info', component: DetailComponent },
|
||||
{ path: ':id/history', component: null },
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class SensorPageRoutingModule { }
|
|
@ -1,12 +0,0 @@
|
|||
<div class="ui-fluid">
|
||||
<div class="ui-g">
|
||||
<div class="ui-g-12">
|
||||
<div class="card no-margin">
|
||||
<of-tabbar [tabs]="tabs"></of-tabbar>
|
||||
</div>
|
||||
<div class="card no-margin">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,25 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SensorPageComponent } from './sensor-page.component';
|
||||
|
||||
describe('SensorPageComponent', () => {
|
||||
let component: SensorPageComponent;
|
||||
let fixture: ComponentFixture<SensorPageComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SensorPageComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SensorPageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'of-pages-sensor',
|
||||
templateUrl: './sensor-page.component.html',
|
||||
})
|
||||
export class SensorPageComponent implements OnInit {
|
||||
|
||||
tabs = undefined;
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
const id = this.router.url.split('sensor/')[1].split('/')[0];
|
||||
|
||||
this.tabs = [
|
||||
{ label: 'INFO', routerLink: ['/sensor/' + id, 'info'] },
|
||||
{ label: 'HISTORY', path: ['/sensor/' + id, 'history'], disabled: true },
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { SensorModule } from '@overflow/sensor/sensor.module';
|
||||
import { SensorPageRoutingModule } from './sensor-page-routing.module';
|
||||
import { SensorPageComponent } from './sensor-page.component';
|
||||
import { TabbarModule } from '../../commons/component/layout/tabbar/app.tabbar.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
SensorPageRoutingModule,
|
||||
SensorModule,
|
||||
TabbarModule
|
||||
],
|
||||
declarations: [
|
||||
SensorPageComponent,
|
||||
]
|
||||
})
|
||||
export class SensorPageModule { }
|
|
@ -8,6 +8,7 @@ const routes: Routes = [
|
|||
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: ':id/history', component: null },
|
||||
]
|
||||
|
|
|
@ -22,6 +22,8 @@ export class SensorPageComponent {
|
|||
if (params['id']) {
|
||||
this.onDetailContainer(params['id']);
|
||||
} else {
|
||||
console.log('?');
|
||||
console.log(params);
|
||||
this.onListContainer();
|
||||
}
|
||||
});
|
||||
|
@ -34,8 +36,8 @@ export class SensorPageComponent {
|
|||
this.isDetail = false;
|
||||
}
|
||||
|
||||
onDetailContainer(sensorHostID: string) {
|
||||
this.sensorID = sensorHostID;
|
||||
onDetailContainer(sensorID: string) {
|
||||
this.sensorID = sensorID;
|
||||
this.breadcrumbService.setItems([
|
||||
{ label: 'Sensor', routerLink: ['/sensor/list'] },
|
||||
{ label: this.sensorID }
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { SensorsPageComponent } from './sensors-page.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: SensorsPageComponent,
|
||||
children: [
|
||||
// { path: '', component: SensorListComponent },
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class SensorsPageRoutingModule { }
|
|
@ -1,9 +0,0 @@
|
|||
<div class="ui-fluid">
|
||||
<div class="ui-g">
|
||||
<div class="ui-g-12">
|
||||
<div class="card no-margin">
|
||||
<of-sensor-list></of-sensor-list>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,25 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SensorsPageComponent } from './sensors-page.component';
|
||||
|
||||
describe('SensorsComponent', () => {
|
||||
let component: SensorsPageComponent;
|
||||
let fixture: ComponentFixture<SensorsPageComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SensorsPageComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SensorsPageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'of-pages-sensors',
|
||||
templateUrl: './sensors-page.component.html',
|
||||
})
|
||||
export class SensorsPageComponent implements OnInit {
|
||||
|
||||
tabs = [
|
||||
{ label: 'Overview', path: '/sensors' },
|
||||
{ label: 'History', path: '/sensors/history' },
|
||||
];
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SensorModule } from '@overflow/sensor/sensor.module';
|
||||
import { SensorsPageComponent } from './sensors-page.component';
|
||||
import { SensorsPageRoutingModule } from './sensors-page-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
SensorsPageRoutingModule,
|
||||
SensorModule
|
||||
],
|
||||
declarations: [
|
||||
SensorsPageComponent
|
||||
]
|
||||
})
|
||||
export class SensorsPageModule { }
|
Loading…
Reference in New Issue
Block a user