From 7cc5082a505040e798589a7fa8960adf6af388ab Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 25 Aug 2017 13:02:59 +0900 Subject: [PATCH] sensor setup ing --- .../meta/api/model/MetaSensorItem.ts | 8 +- .../meta/api/model/MetaSensorStatus.ts | 2 +- .../meta/react/components/CrawlerSelector.tsx | 11 +- .../meta/react/components/SensorItemTree.tsx | 103 ++---------------- .../sensor/api/model/SensorRegistInfo.ts | 8 +- .../react/components/SensorConfigStepper.tsx | 50 ++++++++- .../react/components/SensorConfiguration.tsx | 10 +- 7 files changed, 79 insertions(+), 113 deletions(-) diff --git a/src/ts/@overflow/meta/api/model/MetaSensorItem.ts b/src/ts/@overflow/meta/api/model/MetaSensorItem.ts index 2b9895f..38712fc 100644 --- a/src/ts/@overflow/meta/api/model/MetaSensorItem.ts +++ b/src/ts/@overflow/meta/api/model/MetaSensorItem.ts @@ -4,10 +4,10 @@ import MetaSensorItemType from './MetaSensorItemType'; interface MetaSensorItem { id?: number; - itemType: MetaSensorItemType; - key: string; - name: string; - createDate: Date; + itemType?: MetaSensorItemType; + key?: string; + name?: string; + createDate?: Date; } export default MetaSensorItem; diff --git a/src/ts/@overflow/meta/api/model/MetaSensorStatus.ts b/src/ts/@overflow/meta/api/model/MetaSensorStatus.ts index 322e559..afd9850 100644 --- a/src/ts/@overflow/meta/api/model/MetaSensorStatus.ts +++ b/src/ts/@overflow/meta/api/model/MetaSensorStatus.ts @@ -1,7 +1,7 @@ interface MetaSensorStatus { id?: number; - name: string; + name?: string; } export enum MetaSensorStatus_ID { diff --git a/src/ts/@overflow/meta/react/components/CrawlerSelector.tsx b/src/ts/@overflow/meta/react/components/CrawlerSelector.tsx index 10c1fb9..14d8884 100644 --- a/src/ts/@overflow/meta/react/components/CrawlerSelector.tsx +++ b/src/ts/@overflow/meta/react/components/CrawlerSelector.tsx @@ -69,7 +69,7 @@ export class CrawlerSelector extends React.Component { - // let sensorItem: MetaSensorItem = data; - - // if (this.itemMap.has(sensorItem.itemType.id)) { - // this.itemMap.get(sensorItem.itemType.id).metaSensorItemList.push(sensorItem); - // } else { - // let item: TreeItem = { metaSensorItemList: null, metaSensorItemType: null }; - // item.metaSensorItemList = []; - // item.metaSensorItemList.push(sensorItem); - // item.metaSensorItemType = this.GetMetaSensorItemType(sensorItem.itemType.id); - // this.itemMap.set(sensorItem.itemType.id, item); - // } - // }); } private onItemClick = (parentKey: number, idx: number) => { @@ -199,17 +186,17 @@ export class SensorItemTree extends React.Component { - if (this.selectedItemMap[parentKey] === undefined) { - this.selectedItemMap[parentKey] = []; + if (this.selectedItemMap.get(parentKey) === undefined) { + this.selectedItemMap.set(parentKey, []); } if (checkProps.checked) { - this.selectedItemMap[parentKey].push(item); + this.selectedItemMap.get(parentKey).push(item); } else { - let index: number = this.selectedItemMap[parentKey].indexOf(item); + let index: number = this.selectedItemMap.get(parentKey).indexOf(item); if (index >= 0) { - this.selectedItemMap[parentKey].splice(index, 1); + this.selectedItemMap.get(parentKey).splice(index, 1); } - if (this.selectedItemMap[parentKey].length <= 0) { + if (this.selectedItemMap.get(parentKey).length <= 0) { let newCheckState: Map = _.clone(this.state.categoryCheckState); newCheckState[parentKey] = false; this.setState({ categoryCheckState: newCheckState }); @@ -234,11 +221,15 @@ export class SensorItemTree extends React.Component): boolean { @@ -267,74 +258,4 @@ export class SensorItemTree extends React.Component>; - crawlerId: number; - targetId: number; + crawler: Crawler; + // targetId: number; interval: number; + // type: string; + infra: Infra; } export default SensorRegistInfo; diff --git a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx index cc2039c..e8a9d4d 100644 --- a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx @@ -28,11 +28,13 @@ import Domain from '@overflow/domain/api/model/Domain'; import Page from '@overflow/commons/api/model/Page'; import SensorRegistInfo from '../../api/model/SensorRegistInfo'; - +import Sensor from '../../api/model/Sensor'; +import SensorItem from '../../api/model/SensorItem'; +import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem'; import SensorItemTree from '@overflow/meta/react/SensorItemTree'; import CrawlerSelectorContainer from '@overflow/meta/react/CrawlerSelector'; - +import { MetaSensorStatus_ID } from '@overflow/meta/api/model/MetaSensorStatus'; export interface SensorConfigStepperStateProps { @@ -105,9 +107,40 @@ export class SensorConfigStepper extends React.Component = new Array; + + // let msiArray: MetaSensorItem[]; + // let msi: MetaSensorItem; + // for (let key of Array.from(sensorData.sensorItemMap.keys())) { + // msiArray = sensorData.sensorItemMap[key]; + // for (let msi of msiArray) { + // msiList.push(msi); + // } + // } + + sensorData.sensorItemMap.forEach( (value: MetaSensorItem[], key: number) => { + for(let msi of value) { + msiList.push(msi); + } + }); + + console.log(sensor); + console.log(msiList); + } + public showContent(): any { return this.props.steps[this.state.currentStep - 1]; } @@ -154,7 +187,9 @@ export class SensorConfigStepper extends React.Component, data: DropdownProps): void { let sd = this.props.getSensor(); - - sd.targetId = Number(data.value); + // let infra: Infra = JSON.parse(String(data.value)); + // sd.targetId = infra.target.id; + // sd.type = infra.infraType.name; + sd.infra = JSON.parse(String(data.value)); this.props.setSensor(sd); } diff --git a/src/ts/@overflow/sensor/react/components/SensorConfiguration.tsx b/src/ts/@overflow/sensor/react/components/SensorConfiguration.tsx index eca19ba..1999866 100644 --- a/src/ts/@overflow/sensor/react/components/SensorConfiguration.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorConfiguration.tsx @@ -113,14 +113,14 @@ export interface ETCSelectorProps { } export interface ETCSelectorState { - interval: number; + interval: string; } export class ETCSelector extends React.Component { constructor(props: any, context: any) { super(props, context); this.state = { - interval: 5, + interval: '5', }; } public handleIntervalChange = (e: any, { value }: any) => { @@ -145,21 +145,21 @@ export class ETCSelector extends React.Component