fixed auth_crawler by select_type

This commit is contained in:
snoop 2017-09-12 17:34:46 +09:00
parent 2b21d74d63
commit 4d1eb970ce

View File

@ -47,8 +47,8 @@ export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, C
}
public componentWillReceiveProps?(nextProps: Readonly<CrawlerAuthInputsProps>, nextContext: any): void {
if(nextProps.metaCrawlerInputItemList !== this.props.metaCrawlerInputItemList) {
this.setState({authJson: {}});
if (nextProps.metaCrawlerInputItemList !== this.props.metaCrawlerInputItemList) {
this.setState({ authJson: {} });
}
}
@ -96,8 +96,8 @@ export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, C
this.props.onVerifyCrawler(sd.infra.id, sd.crawler, sd.crawlerAuth);
let authCrawler: AuthCrawler = {
crawler: {id:sd.crawler.id},
target: {id:sd.infra.target.id},
crawler: { id: sd.crawler.id },
target: { id: sd.infra.target.id },
authJson: JSON.stringify(sd.crawlerAuth),
};
@ -108,6 +108,8 @@ export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, C
let newJson: any = _.clone(this.state.authJson);
newJson[key] = data;
this.setState({ authJson: newJson });
console.log(newJson);
}
public renderRow(item: MetaCrawlerInputItem, index: number): JSX.Element {
@ -122,15 +124,24 @@ export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, C
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
this.onChangeAuth(item.name, data.value);
}} />);
} else if (item.inputType.name === 'Radio') {
} else if (item.inputType.name === 'SELECT_TYPE') {
let itemValues = item.keyValue.split('|');
let idx = 0;
elem.push(<Label pointing='below'>{item.name}</Label>);
if(this.state.authJson[item.name] === undefined) {
this.onChangeAuth(item.name, item.defaultValue);
}
for (let itemValue of itemValues) {
elem.push(<Form.Radio
elem.push(
<Form.Radio
key={idx++}
label={itemValue}
name='radioGroup'
name={'radioGroup' + String(item.id)}
value={itemValue}
checked={this.state.authJson[item.name] ? this.state.authJson[item.name] === itemValue : itemValue === item.defaultValue}
defaultChecked={itemValue === item.defaultValue ? true : false}
onChange={
(event: React.FormEvent<HTMLInputElement>, data: CheckboxProps) => {
this.onChangeAuth(item.name, itemValue);