diff --git a/src/ts/@overflow/sensor/react/SensorConfigTargetSelect.tsx b/src/ts/@overflow/sensor/react/SensorConfigTargetSelect.tsx new file mode 100644 index 0000000..53cdd18 --- /dev/null +++ b/src/ts/@overflow/sensor/react/SensorConfigTargetSelect.tsx @@ -0,0 +1,40 @@ +import { connect, Dispatch } from 'react-redux'; +import { + SensorConfigTargetSelect, + Props as SensorConfigTargetSelectStateProps, + State as SensorConfigTargetSelectDispatchProps, +} from './components/SensorConfigTargetSelect'; +// import State from '../redux/state/ReadAllByTarget'; +import { push as routerPush } from 'react-router-redux'; + +// import Target from '@overflow/target/api/model/Target'; +// import Sensor from '@overflow/sensor/api/model/Sensor'; +// import SensorItem from '@overflow/sensor/api/model/SensorItem'; +import Domain from '@overflow/domain/api/model/Domain'; +import PageParams from '@overflow/commons/api/model/PageParams'; + +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; +import * as targetListActions from '@overflow/target/redux/action/read_all_by_probe'; +import * as readActionType from '@overflow/infra/redux/action/read'; + +export function mapStateToProps(state: any, props: any): SensorConfigTargetSelectStateProps { + return { + infraList: state.infraList, + infra: state.infra, + }; +} + +export function mapDispatchToProps(dispatch: Dispatch): SensorConfigTargetSelectDispatchProps { + return { + onReadAllTargetByDomain: (domain: Domain, pageParams: PageParams) => { + dispatch(asyncRequestActions.request('InfraService', 'readAllByDomain', targetListActions.REQUEST, + JSON.stringify(domain), JSON.stringify(pageParams))); + }, + onReadInfra: (infraId: number) => { + dispatch(asyncRequestActions.request('InfraService', 'read', readActionType.REQUEST, infraId)); + }, + }; +} + + +export default connect(mapStateToProps, mapDispatchToProps)(SensorConfigTargetSelect); diff --git a/src/ts/@overflow/sensor/react/SensorConfiguration.tsx b/src/ts/@overflow/sensor/react/SensorConfiguration.tsx index 94ac459..e3be18d 100644 --- a/src/ts/@overflow/sensor/react/SensorConfiguration.tsx +++ b/src/ts/@overflow/sensor/react/SensorConfiguration.tsx @@ -16,30 +16,19 @@ import * as SensorItemReadAllActions from '@overflow/meta/redux/action/sensor_it import * as RegistActions from '../redux/action/regist'; import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; -import * as targetListActions from '@overflow/target/redux/action/read_all_by_probe'; -import * as readActionType from '@overflow/infra/redux/action/read'; -import PageParams from '@overflow/commons/api/model/PageParams'; + + // FIXME::.... export function mapStateToProps(state: any, props: any): SensorConfigurationStateProps { return { - infraList: state.infraList, infraId: props.params.id, - infra: state.infra, }; } export function mapDispatchToProps(dispatch: Dispatch): SensorConfigurationDispatchProps { return { - onReadAllTargetByDomain: (domain: Domain, pageParams: PageParams) => { - // dispatch(asyncRequestActions.request('InfraService', 'readAllByDomain', - // targetListActions.REQUEST, JSON.stringify(domain), '0', '10')); - dispatch(asyncRequestActions.request('InfraService', 'readAllByDomain', targetListActions.REQUEST, - JSON.stringify(domain), JSON.stringify(pageParams))); - }, - onReadInfra: (infraId: number) => { - dispatch(asyncRequestActions.request('InfraService', 'read', readActionType.REQUEST, infraId)); - }, + // onCheckCrawlerAuth: (authInfo: string) => { // // dispatch(ReadActions.request(id)); // }, diff --git a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx index 5ebda94..15db7d0 100644 --- a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx @@ -39,8 +39,6 @@ import { MetaSensorStatus_ID } from '@overflow/meta/api/model/MetaSensorStatus'; export interface SensorConfigStepperStateProps { steps?: Array; - infraList?: Page; - infra?: Infra; infraId?: number; setSensor?(data: SensorRegistInfo): void; getSensor?(): SensorRegistInfo; @@ -60,8 +58,6 @@ export interface SensorConfigStepperState { export class SensorConfigStepper extends React.Component { - private selectOptions: Array; - constructor(props: SensorConfigStepperProps, context: SensorConfigStepperState) { super(props, context); this.state = { @@ -136,19 +132,23 @@ export class SensorConfigStepper extends React.Component = new Array; - - for (let infra of this.props.infraList.content) { - - selectionOptions.push(this.createOption(infra)); - - } - this.selectOptions = selectionOptions; - } - - public convertInfra(): void { - if (this.props.infra === undefined) { - return; - } - let selectionOptions: Array = new Array; - - selectionOptions.push(this.createOption(this.props.infra)); - this.selectOptions = selectionOptions; - - let sd = this.props.getSensor(); - // sd.targetId = this.props.infra.target.id; - // sd.type = this.props.infra.infraType.name; - sd.infra = this.props.infra; - this.props.setSensor(sd); - } - - public createOption(infra: Infra): DropdownItemProps { - let option = { - key: infra.id, - text: infra.infraType.name + '-' + infra.target.displayName, - // value: infra.target.id, - value: JSON.stringify(infra), - // icon: 'check', // or close? - }; - return option; - } - - public defaultValue(): any { - if (this.selectOptions !== undefined && this.selectOptions.length > 0) { - return this.selectOptions[0].value; - } - return null; - } - - public onChangeTarget(event: React.SyntheticEvent, data: DropdownProps): void { - let sd = this.props.getSensor(); - // 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); - } - - public renderInfra(): JSX.Element { - - if (this.props.infraId === undefined) { - this.convertInfraList(); - } else { - this.convertInfra(); - } - - return (); - } public render(): JSX.Element { @@ -307,20 +236,24 @@ export class SensorConfigStepper extends React.Component - + - + - + + + + + + - {this.renderInfra()} {this.showContent()}
{/* floated 사용시 레이아웃 깨지는 현상 */} diff --git a/src/ts/@overflow/sensor/react/components/SensorConfigTargetSelect.tsx b/src/ts/@overflow/sensor/react/components/SensorConfigTargetSelect.tsx new file mode 100644 index 0000000..3cfabf7 --- /dev/null +++ b/src/ts/@overflow/sensor/react/components/SensorConfigTargetSelect.tsx @@ -0,0 +1,162 @@ +import * as React from 'react'; + +import { + Icon, + Step, + Button, + Table, + Radio, + Form, + Container, + Checkbox, +} from 'semantic-ui-react'; +import { + Grid, + Image, + Label, + Segment, + Dropdown, + Input, + List, + Accordion, + Loader, + DropdownItemProps, DropdownProps, +} from 'semantic-ui-react'; + + +import MetaCrawler from '@overflow/meta/api/model/MetaCrawler'; +import Infra from '@overflow/infra/api/model/Infra'; +import Domain from '@overflow/domain/api/model/Domain'; + +import Page from '@overflow/commons/api/model/Page'; +import SensorRegistInfo from '../../api/model/SensorRegistInfo'; + +import PageParams from '@overflow/commons/api/model/PageParams'; + + +export interface StateProps { + infraList?: Page; + infra?: Infra; + infraId?: number; + setSensor?(data: SensorRegistInfo): void; + getSensor?(): SensorRegistInfo; +} + +export interface DispatchProps { + + onReadAllTargetByDomain?(domain: Domain, pageParams: PageParams): void; + onReadInfra?(infraId: number): void; +} + +export type Props = StateProps & DispatchProps; + +export interface State { + +} + + + +export class SensorConfigTargetSelect extends React.Component { + + private selectOptions: Array; + + constructor(props: Props, context: State) { + super(props, context); + this.state = { + }; + } + + public componentWillMount(): void { + if (this.props.infraId === undefined) { + const pageParams: PageParams = { + pageNo: '0', + countPerPage: '999', + sortCol: 'id', + sortDirection: 'descending', + }; + this.props.onReadAllTargetByDomain({ id: 1 }, pageParams); + } else { + this.props.onReadInfra(this.props.infraId); + } + } + + public convertInfraList(): void { + + if (this.props.infraList === undefined) { + return null; + } + + let selectionOptions: Array = new Array; + + for (let infra of this.props.infraList.content) { + + selectionOptions.push(this.createOption(infra)); + + } + this.selectOptions = selectionOptions; + } + + public convertInfra(): void { + if (this.props.infra === undefined) { + return; + } + let selectionOptions: Array = new Array; + + selectionOptions.push(this.createOption(this.props.infra)); + this.selectOptions = selectionOptions; + + let sd = this.props.getSensor(); + // sd.targetId = this.props.infra.target.id; + // sd.type = this.props.infra.infraType.name; + sd.infra = this.props.infra; + this.props.setSensor(sd); + } + + public createOption(infra: Infra): DropdownItemProps { + let option = { + key: infra.id, + text: infra.infraType.name + '-' + infra.target.displayName, + // value: infra.target.id, + value: JSON.stringify(infra), + // icon: 'check', // or close? + }; + return option; + } + + public defaultValue(): any { + if (this.selectOptions !== undefined && this.selectOptions.length > 0) { + return this.selectOptions[0].value; + } + return null; + } + + public onChangeTarget(event: React.SyntheticEvent, data: DropdownProps): void { + let sd = this.props.getSensor(); + // 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); + } + + public renderInfra(): JSX.Element { + + if (this.props.infraId === undefined) { + this.convertInfraList(); + } else { + this.convertInfra(); + } + + return (); + } + + public render(): JSX.Element { + return ( + + {this.renderInfra()} + + ); + } +} diff --git a/src/ts/@overflow/sensor/react/components/SensorConfiguration.tsx b/src/ts/@overflow/sensor/react/components/SensorConfiguration.tsx index f881b1f..ee22286 100644 --- a/src/ts/@overflow/sensor/react/components/SensorConfiguration.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorConfiguration.tsx @@ -33,17 +33,15 @@ import SensorItemTree from '@overflow/meta/react/SensorItemTree'; import CrawlerSelectorContainer from '@overflow/meta/react/CrawlerSelector'; import SensorConfigStepperContainer from '../SensorConfigStepper'; -import PageParams from '@overflow/commons/api/model/PageParams'; +import SensorConfigTargetSelectContainer from '../SensorConfigTargetSelect'; + export interface SensorConfigurationStateProps { infraId?: number; - infraList?: Page; - infra?: Infra; } export interface SensorConfigurationDispatchProps { - onReadAllTargetByDomain?(domain: Domain, pageParams: PageParams): void; - onReadInfra?(infraId: number): void; + } export interface SensorConfigurationState { @@ -64,19 +62,7 @@ export class SensorConfiguration extends React.Component { this.setState({ @@ -95,6 +81,8 @@ export class SensorConfiguration extends React.Component, , @@ -104,7 +92,7 @@ export class SensorConfiguration extends React.Component]; return ( - ); }