fixed sensor regist
This commit is contained in:
		
							parent
							
								
									f4bbbdec3c
								
							
						
					
					
						commit
						03ba9a1e7b
					
				| @ -30,6 +30,7 @@ import readMachineReducer from '@overflow/infra/redux/reducer/machine_read'; | |||||||
| import readHostReducer from '@overflow/infra/redux/reducer/host_read'; | import readHostReducer from '@overflow/infra/redux/reducer/host_read'; | ||||||
| import readOSReducer from '@overflow/infra/redux/reducer/os_read'; | import readOSReducer from '@overflow/infra/redux/reducer/os_read'; | ||||||
| import readServiceReducer from '@overflow/infra/redux/reducer/service_read'; | import readServiceReducer from '@overflow/infra/redux/reducer/service_read'; | ||||||
|  | import InfraReadServiceReducer from '@overflow/infra/redux/reducer/read'; | ||||||
| 
 | 
 | ||||||
| import CrawlerReadAllByTargetReducer from '@overflow/meta/redux/reducer/crawler_read_all_by_target'; | import CrawlerReadAllByTargetReducer from '@overflow/meta/redux/reducer/crawler_read_all_by_target'; | ||||||
| import CrawlerAuthInputsReducer from '@overflow/meta/redux/reducer/crawler_auth_inputs'; | import CrawlerAuthInputsReducer from '@overflow/meta/redux/reducer/crawler_auth_inputs'; | ||||||
| @ -106,6 +107,7 @@ const reduxConfig: ReduxConfig = { | |||||||
|     HistoryReadAllByProbeReducer, |     HistoryReadAllByProbeReducer, | ||||||
|     HistoryReadAllByProbeAndTypeReducer, |     HistoryReadAllByProbeAndTypeReducer, | ||||||
|     readAllTargetByInfraReducer, |     readAllTargetByInfraReducer, | ||||||
|  |     InfraReadServiceReducer, | ||||||
|   ], |   ], | ||||||
|   sagaWatchers: [ |   sagaWatchers: [ | ||||||
|     AsyncRequest, |     AsyncRequest, | ||||||
|  | |||||||
| @ -0,0 +1,24 @@ | |||||||
|  | import Action from '@overflow/commons/redux/Action'; | ||||||
|  | import { ReducersMapObject } from 'redux'; | ||||||
|  | import Infra from '@overflow/infra/api/model/Infra'; | ||||||
|  | 
 | ||||||
|  | import * as readActionType from '../action/read'; | ||||||
|  | import ReadState, { defaultState as ReadDefaultState } from '../state/Read'; | ||||||
|  | 
 | ||||||
|  | const reducer: ReducersMapObject = { | ||||||
|  |     [readActionType.REQUEST_SUCCESS]: | ||||||
|  |     (state: ReadState = ReadDefaultState, action: Action<Infra>): | ||||||
|  |         ReadState => { | ||||||
|  |         return { | ||||||
|  |             ...state, | ||||||
|  |             infra: <Infra>action.payload, | ||||||
|  |         }; | ||||||
|  |     }, | ||||||
|  |     [readActionType.REQUEST_FAILURE]: | ||||||
|  |     (state: ReadState = ReadDefaultState, action: Action<Error>): | ||||||
|  |         ReadState => { | ||||||
|  |         return state; | ||||||
|  |     }, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | export default reducer; | ||||||
| @ -0,0 +1,13 @@ | |||||||
|  | import Infra from '@overflow/infra/api/model/Infra'; | ||||||
|  | 
 | ||||||
|  | export interface State { | ||||||
|  |   readonly infra?: Infra; | ||||||
|  |   readonly error?: Error; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export const defaultState: State = { | ||||||
|  |   infra: undefined, | ||||||
|  |   error: undefined, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | export default State; | ||||||
| @ -17,6 +17,7 @@ import * as RegistActions from '../redux/action/regist'; | |||||||
| 
 | 
 | ||||||
| import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; | import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; | ||||||
| import * as targetListActions from '@overflow/target/redux/action/read_all_by_probe'; | import * as targetListActions from '@overflow/target/redux/action/read_all_by_probe'; | ||||||
|  | import * as readActionType from '@overflow/infra/redux/action/read'; | ||||||
| 
 | 
 | ||||||
| // FIXME::....
 | // FIXME::....
 | ||||||
| 
 | 
 | ||||||
| @ -24,27 +25,28 @@ export function mapStateToProps(state: any, props: any): SensorConfigurationStat | |||||||
|   return { |   return { | ||||||
|     infraList: state.infraList, |     infraList: state.infraList, | ||||||
|     infraId: props.params.id, |     infraId: props.params.id, | ||||||
|  |     infra: state.infra, | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function mapDispatchToProps(dispatch: Dispatch<any>): SensorConfigurationDispatchProps { | export function mapDispatchToProps(dispatch: Dispatch<any>): SensorConfigurationDispatchProps { | ||||||
|   return { |   return { | ||||||
|     onCrawlerReadAllByTarget: (target: Target) => { |  | ||||||
|       dispatch(asyncRequestActions.request('MetaCrawlerService', 'readAll', CrawlerReadAllByTargetActions.REQUEST)); |  | ||||||
|     }, |  | ||||||
|     onReadAllTargetByDomain: (domain: Domain) => { |     onReadAllTargetByDomain: (domain: Domain) => { | ||||||
|       dispatch(asyncRequestActions.request('InfraService', 'readAllByDomain', targetListActions.REQUEST, JSON.stringify(domain))); |       dispatch(asyncRequestActions.request('InfraService', 'readAllByDomain', targetListActions.REQUEST, JSON.stringify(domain))); | ||||||
|     }, |     }, | ||||||
|     onCheckCrawlerAuth: (authInfo: string) => { |     onReadInfra: (infraId: number) => { | ||||||
|       // dispatch(ReadActions.request(id));
 |       dispatch(asyncRequestActions.request('InfraService', 'read', readActionType.REQUEST, infraId)); | ||||||
|     }, |     }, | ||||||
|  |     // onCheckCrawlerAuth: (authInfo: string) => {
 | ||||||
|  |     //   // dispatch(ReadActions.request(id));
 | ||||||
|  |     // },
 | ||||||
|     // FIXME::how to sensor item?
 |     // FIXME::how to sensor item?
 | ||||||
|     onReadMetaSensorItem: () => { |     // onReadMetaSensorItem: () => {
 | ||||||
|       // dispatch(SensorItemReadAllActions.request());
 |     //   // dispatch(SensorItemReadAllActions.request());
 | ||||||
|     }, |     // },
 | ||||||
|     onSaveSensor: (sensor: Sensor) => { |     // onSaveSensor: (sensor: Sensor) => {
 | ||||||
|       // dispatch(RegistActions.request(sensor));
 |     //   // dispatch(RegistActions.request(sensor));
 | ||||||
|     }, |     // },
 | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -12,10 +12,12 @@ import CrawlerSelectorContainer from '@overflow/meta/react/CrawlerSelector'; | |||||||
| export interface SensorConfigurationStateProps { | export interface SensorConfigurationStateProps { | ||||||
|   infraId?: number; |   infraId?: number; | ||||||
|   infraList?: Infra[]; |   infraList?: Infra[]; | ||||||
|  |   infra?: Infra; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface SensorConfigurationDispatchProps { | export interface SensorConfigurationDispatchProps { | ||||||
|   onReadAllTargetByDomain?(domain: Domain): void; |   onReadAllTargetByDomain?(domain: Domain): void; | ||||||
|  |   onReadInfra?(infraId: number ): void; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface SensorConfigurationState { | export interface SensorConfigurationState { | ||||||
| @ -33,6 +35,14 @@ export class SensorConfiguration extends React.Component<SensorConfigurationProp | |||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   public componentWillMount(): void { | ||||||
|  |     if(this.props.infraId === undefined) { | ||||||
|  |       this.props.onReadAllTargetByDomain({id: 1}); | ||||||
|  |     } else { | ||||||
|  |       this.props.onReadInfra(this.props.infraId); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   public onSelectCrawlerId = (id: number) => { |   public onSelectCrawlerId = (id: number) => { | ||||||
|     this.setState({ |     this.setState({ | ||||||
|       selectedCrawlerId: id, |       selectedCrawlerId: id, | ||||||
| @ -45,7 +55,7 @@ export class SensorConfiguration extends React.Component<SensorConfigurationProp | |||||||
|     <Segment vertical><SensorItemTree crawlerId={this.state.selectedCrawlerId} /></Segment>, <ETCSelector />]; |     <Segment vertical><SensorItemTree crawlerId={this.state.selectedCrawlerId} /></Segment>, <ETCSelector />]; | ||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|       <ConfigStepper steps={steps} /> |       <ConfigStepper steps={steps} infra={this.props.infra} infraList={this.props.infraList}/> | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -53,6 +63,8 @@ export class SensorConfiguration extends React.Component<SensorConfigurationProp | |||||||
| 
 | 
 | ||||||
| export interface ConfigStepperProps { | export interface ConfigStepperProps { | ||||||
|   steps: Array<JSX.Element>; |   steps: Array<JSX.Element>; | ||||||
|  |   infraList?: Infra[]; | ||||||
|  |   infra?: Infra; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface ConfigStepperState { | export interface ConfigStepperState { | ||||||
| @ -128,7 +140,11 @@ export class ConfigStepper extends React.Component<ConfigStepperProps, ConfigSte | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public renderTarget(): JSX.Element[] { |   public renderInfraList(): JSX.Element[] { | ||||||
|  | 
 | ||||||
|  |     if(this.props.infraList === undefined) { | ||||||
|  |       return null; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     let elems: Array<JSX.Element> = new Array; |     let elems: Array<JSX.Element> = new Array; | ||||||
| 
 | 
 | ||||||
| @ -159,7 +175,7 @@ export class ConfigStepper extends React.Component<ConfigStepperProps, ConfigSte | |||||||
|             <Step.Content title='Step 3' description='나머지도 골라 아 빨리' /> |             <Step.Content title='Step 3' description='나머지도 골라 아 빨리' /> | ||||||
|           </Step> |           </Step> | ||||||
|         </Step.Group> |         </Step.Group> | ||||||
| 
 |         {this.renderInfraList()} | ||||||
|         {this.showContent()} |         {this.showContent()} | ||||||
|         <br /> |         <br /> | ||||||
|         <Button.Group floated='right'> {/* floated 사용시 레이아웃 깨지는 현상 */} |         <Button.Group floated='right'> {/* floated 사용시 레이아웃 깨지는 현상 */} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user