From c827892a8618045fef34210ac472f546a30da4ee Mon Sep 17 00:00:00 2001 From: snoop Date: Wed, 26 Jul 2017 11:55:05 +0900 Subject: [PATCH] added leftmenu sensors --- .../@overflow/app/views/layout/LeftMenu.tsx | 2 +- .../meta/react/components/SensorItemTree.tsx | 34 +++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/ts/@overflow/app/views/layout/LeftMenu.tsx b/src/ts/@overflow/app/views/layout/LeftMenu.tsx index 8c0dfd3..f106601 100644 --- a/src/ts/@overflow/app/views/layout/LeftMenu.tsx +++ b/src/ts/@overflow/app/views/layout/LeftMenu.tsx @@ -60,7 +60,7 @@ class LeftMenu extends React.Component { this.props.onChangeUrl('/probe_setup')} style={{ 'marginLeft': '30px' }}> Probe Setup - + this.props.onChangeUrl('/sensors')} style={{ 'marginLeft': '30px' }}> Sensors diff --git a/src/ts/@overflow/meta/react/components/SensorItemTree.tsx b/src/ts/@overflow/meta/react/components/SensorItemTree.tsx index 3dd2c0d..1dcc339 100644 --- a/src/ts/@overflow/meta/react/components/SensorItemTree.tsx +++ b/src/ts/@overflow/meta/react/components/SensorItemTree.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import * as _ from 'lodash'; // import update from 'immutability-helper'; import { Checkbox, Container, Label, Accordion, Icon, List, ListItemProps } from 'semantic-ui-react'; @@ -24,7 +25,8 @@ export type SensorItemTreeProps = SensorItemTreeStateProps & SensorItemTreeDispa export interface SensorItemTreeState { - portState: Map; + categoryState: Map; + itemState: Map; } interface TreeItem { @@ -42,7 +44,8 @@ export class SensorItemTree extends React.Component - { + { - let newPortState: Map = new Map(this.state.portState); - newPortState[key] = true; - this.setState({ portState: newPortState }); + {/*let newPortState: Map = new Map(this.state.portState);*/ } + let newCategoryState: Map = _.cloneDeep(this.state.categoryState); + newCategoryState[key] = !newCategoryState[key]; + this.setState({ categoryState: newCategoryState }); }} /> Category - {this.state.portState[key] ? this.ViewSensorItem(data.metaSensorItemList) : ''} + {this.state.categoryState[key] ? this.ViewSensorItem(data.metaSensorItemList, key) : ''} , ); @@ -91,15 +95,23 @@ export class SensorItemTree extends React.Component { + let checkList: boolean[] = this.state.itemState[parentKey]; elems.push( - - + { + + {/*let newPortState: Map = new Map(this.state.portState);*/ } + let newItemState: Map = _.cloneDeep(this.state.itemState[parentKey]); + newItemState[idx] = !newItemState[idx]; + this.setState({ itemState: newItemState }); + + }}> + - + Sensor Item