From 89bbf5dee92b1e53db29e8113ca307c09f0e879a Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 21 Mar 2018 19:39:40 +0900 Subject: [PATCH] sensor configuration --- .../infra/component/map/map.component.ts | 1 - .../crawler-auth/crawler-auth.component.ts | 3 -- .../crawler-selector.component.html | 4 +- .../crawler-selector.component.ts | 6 --- .../sensor-item-selector.component.html | 3 +- .../sensor-item-selector.component.ts | 42 ++++++++----------- .../component/setting/setting.component.html | 2 +- .../component/setting/setting.component.ts | 32 ++++++++++---- 8 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/packages/infra/component/map/map.component.ts b/src/packages/infra/component/map/map.component.ts index bcb0025..b030c5f 100644 --- a/src/packages/infra/component/map/map.component.ts +++ b/src/packages/infra/component/map/map.component.ts @@ -62,7 +62,6 @@ export class MapComponent implements OnInit, AfterContentInit { addSensor(infra: Infra) { const targetId = infra.target.id; - console.log(targetId); const dialogRef = this.dialog.open(SettingComponent, { width: '80%', diff --git a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts index 0c7c858..c5ee744 100644 --- a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts +++ b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts @@ -29,9 +29,6 @@ export class CrawlerAuthComponent implements OnInit, OnChanges { this.inputItems$.subscribe( (list: MetaCrawlerInputItem[]) => { if (list !== null) { - console.log('###Auth Inputs###'); - console.log(list); - console.log('###################'); this.inputItems = list; this.generateAuthComponent(); } diff --git a/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.html b/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.html index f836d19..89857f1 100644 --- a/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.html +++ b/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.html @@ -9,11 +9,11 @@ - + {{crawler.name}} - + diff --git a/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.ts b/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.ts index 4ddc1ca..8031553 100644 --- a/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.ts +++ b/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.ts @@ -17,13 +17,10 @@ import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler'; export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContentInit { crawlers$ = this.listStore.pipe(select(ReadAllCrawlerSelector.select('metaCrawlerList'))); - @Input() selectedTarget: Target; crawlers: MetaCrawler[]; - @Output() crawlerSelectEvent = new EventEmitter(); - constructor( private router: Router, private listStore: Store, @@ -47,9 +44,6 @@ export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContent } ngOnChanges() { - // if (this.selectedTarget) { - // console.log('Getting valid crawlers for ' + this.selectedTarget.displayName); - // } } crawlerSelected(crawler: MetaCrawler) { diff --git a/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.html b/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.html index 48fbdc0..de90f1c 100644 --- a/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.html +++ b/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.html @@ -12,12 +12,13 @@
- +
+ Recommend! {{ node.data.title }} {{node.data.key}}
diff --git a/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.ts b/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.ts index fb3cb20..ee060ca 100644 --- a/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.ts +++ b/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, OnChanges, Input, Output, EventEmitter, ViewChild, AfterViewInit } from '@angular/core'; +import { Component, OnInit, OnChanges, Input, Output, EventEmitter, ViewChild, AfterViewInit, OnDestroy } from '@angular/core'; import { Router } from '@angular/router'; import { Store, select } from '@ngrx/store'; import { RPCError } from 'packages/core/rpc/error'; @@ -14,14 +14,13 @@ import { ITreeOptions } from 'angular-tree-component'; templateUrl: './sensor-item-selector.component.html', styleUrls: ['./sensor-item-selector.component.scss'] }) -export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnChanges { +export class SensorItemSelectorComponent implements OnInit, OnChanges { @Input() selectedCrawler: MetaCrawler; - @Output() selectedItems = new EventEmitter(); + @Output() itemSelectEvent = new EventEmitter>(); items$ = this.listStore.pipe(select(ReadAllSensorDisplayItemByCrawlerSelector.select('list'))); - sensorDisplayItems: MetaSensorDisplayItem[]; - @ViewChild('tree') tree; nodes; + checkedSet: Set; constructor( private router: Router, @@ -29,13 +28,10 @@ export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnCha ) { } ngOnInit() { + this.checkedSet = new Set(); this.items$.subscribe( (list: MetaSensorDisplayItem[]) => { if (list !== null) { - console.log('###Display Items###'); - console.log(list); - console.log('###################'); - this.sensorDisplayItems = list; this.generateTreeNode(list); } }, @@ -45,9 +41,6 @@ export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnCha ); } - ngAfterViewInit() { - } - ngOnChanges() { this.listStore.dispatch(new ListStore.ReadAllByCrawler(this.selectedCrawler)); } @@ -62,20 +55,21 @@ export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnCha const node = { title: item.itemType.name, children: childrenNode, - isExpanded: true }; this.nodes.push(node); } else { categoryNode.children.push(this.getChildNode(item)); } } + this.itemSelectEvent.emit(this.checkedSet); } getChildNode(item) { const childNode = { title: item.displayName, key: ' - ' + item.key, - default: item.default + default: item.default, + displayItem: item }; return childNode; } @@ -92,16 +86,16 @@ export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnCha checkItem(node) { node.toggleActivated(true); - console.log(node); - // if (node.isActive) { - // if (this.checkedSet.has(node.data) === false) { - // this.checkedSet.add(node.data); - // } - // } else { - // if (this.checkedSet.has(node.data)) { - // this.checkedSet.delete(node.data); - // } - // } + if (node.isActive) { + if (this.checkedSet.has(node.data.displayItem) === false) { + this.checkedSet.add(node.data.displayItem); + } + } else { + if (this.checkedSet.has(node.data.displayItem)) { + this.checkedSet.delete(node.data.displayItem); + } + } + this.itemSelectEvent.emit(this.checkedSet); } onTreeDataLoad(tree) { diff --git a/src/packages/sensor/component/setting/setting.component.html b/src/packages/sensor/component/setting/setting.component.html index 4bfbe80..b1d39cd 100644 --- a/src/packages/sensor/component/setting/setting.component.html +++ b/src/packages/sensor/component/setting/setting.component.html @@ -1,5 +1,5 @@
-
+
diff --git a/src/packages/sensor/component/setting/setting.component.ts b/src/packages/sensor/component/setting/setting.component.ts index 768943f..a878037 100644 --- a/src/packages/sensor/component/setting/setting.component.ts +++ b/src/packages/sensor/component/setting/setting.component.ts @@ -1,9 +1,9 @@ import { Component, OnInit, Input, Inject } from '@angular/core'; -import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks'; import { Target } from '../../../target/model'; import { MAT_DIALOG_DATA } from '@angular/material'; import { Infra } from '../../../infra/model'; import { MetaCrawler } from '../../../meta/crawler/model/MetaCrawler'; +import { MetaSensorDisplayItem } from '../../../meta/sensor-display-item/model/MetaSensorDisplayItem'; @Component({ @@ -11,10 +11,11 @@ import { MetaCrawler } from '../../../meta/crawler/model/MetaCrawler'; templateUrl: './setting.component.html', styleUrls: ['./setting.component.scss'] }) -export class SettingComponent implements OnInit, AfterContentInit { +export class SettingComponent implements OnInit { selectedTarget: Target = null; selectedCrawler: MetaCrawler = null; + selectedSensorDisplayItems: Set = null; step = 1; constructor( @@ -25,16 +26,30 @@ export class SettingComponent implements OnInit, AfterContentInit { } } - ngOnInit() { } - ngAfterContentInit() { - + onNext() { + const valid = this.validateSelection(); + if (valid !== null) { + alert(valid); + return; + } + this.step += 1; } - onNext() { - this.step += 1; + validateSelection() { + let message = null; + if (this.selectedTarget === null) { + message = 'Target is not selected.'; + } + if (this.selectedCrawler === null) { + message = 'Crawler is not selected.'; + } + if (this.selectedSensorDisplayItems === null || this.selectedSensorDisplayItems.size === 0) { + message = 'SensorItem is not selected.'; + } + return message; } onPrev() { @@ -51,4 +66,7 @@ export class SettingComponent implements OnInit, AfterContentInit { handleCrawlerSelection(c: MetaCrawler) { this.selectedCrawler = c; } + handleItemSelection(itemSet: Set) { + this.selectedSensorDisplayItems = itemSet; + } }