diff --git a/src/ts/@overflow/sensor/react/components/SensorConfigTargetSelect.tsx b/src/ts/@overflow/sensor/react/components/SensorConfigTargetSelect.tsx index 14939b7..15b0473 100644 --- a/src/ts/@overflow/sensor/react/components/SensorConfigTargetSelect.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorConfigTargetSelect.tsx @@ -33,6 +33,7 @@ import SensorRegistInfo from '../../api/model/SensorRegistInfo'; import PageParams from '@overflow/commons/api/model/PageParams'; +import * as Utils from '@overflow/commons/util/Utils'; export interface StateProps { infraList?: Page; @@ -52,7 +53,7 @@ export interface DispatchProps { export type Props = StateProps & DispatchProps; export interface State { - + selected: Infra; } @@ -64,6 +65,7 @@ export class SensorConfigTargetSelect extends React.Component { constructor(props: Props, context: State) { super(props, context); this.state = { + selected: null, }; } @@ -81,20 +83,46 @@ export class SensorConfigTargetSelect extends React.Component { } } - public convertInfraList(): void { + public handleSelect(infra: Infra): void { + this.setState({ + selected: infra, + }); + + let sd = this.props.getSensor(); + sd.infra = infra; + this.props.setSensor(sd); + } + + public handleRowActive(infra: Infra): boolean { + if (this.state.selected === infra) { + return true; + } + return false; + } + + public convertInfraList(): JSX.Element[] { if (this.props.infraList === undefined) { return null; } - let selectionOptions: Array = new Array; + let elems: Array = new Array(); - for (let infra of this.props.infraList.content) { - - selectionOptions.push(this.createOption(infra)); + for (let index: number = 0; index < this.props.infraList.content.length; ++index) { + let infra: Infra = this.props.infraList.content[index]; + elems.push( + + {index + 1} + {infra.infraType.name} + {infra.target.displayName} + TODO + {Utils.date2date(infra.target.createDate)} + , + ); } - this.selectOptions = selectionOptions; + + return elems; } public convertInfra(): void { @@ -141,24 +169,41 @@ export class SensorConfigTargetSelect extends React.Component { this.props.setSensor(sd); } - public renderInfra(): JSX.Element { + public renderInfra(): JSX.Element[] { if (this.props.infraId === undefined) { - this.convertInfraList(); + return this.convertInfraList(); } else { this.convertInfra(); } - return (); + return null; + + // return (); } public render(): JSX.Element { return ( - {this.renderInfra()} + {/* */} + + + + No. + Type + Name + Sensor Count + Created at + + + + + {this.renderInfra()} + +
); }