added authcrawler
This commit is contained in:
parent
1eae013724
commit
9319ddfa8e
14
src/ts/@overflow/auth/api/model/AuthCrawler.ts
Normal file
14
src/ts/@overflow/auth/api/model/AuthCrawler.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
|
||||
import MetaCrawler from '@overflow/meta/api/model/MetaCrawler';
|
||||
import Target from '@overflow/target/api/model/Target';
|
||||
|
||||
interface AuthCrawler {
|
||||
id?: number;
|
||||
crawler?: MetaCrawler;
|
||||
target?: Target;
|
||||
authJson?: string;
|
||||
createDate?: Date;
|
||||
}
|
||||
|
||||
export default AuthCrawler;
|
7
src/ts/@overflow/auth/redux/action/check_auth_crawler.ts
Normal file
7
src/ts/@overflow/auth/redux/action/check_auth_crawler.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export type REQUEST = '@overflow/auth/check_auth_crawler/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/auth/check_auth_crawler/REQUEST/SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/auth/check_auth_crawler/REQUEST/FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/auth/check_auth_crawler/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/auth/check_auth_crawler/REQUEST/SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/auth/check_auth_crawler/REQUEST/FAILURE';
|
7
src/ts/@overflow/auth/redux/action/regist.ts
Normal file
7
src/ts/@overflow/auth/redux/action/regist.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export type REQUEST = '@overflow/auth/regist/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/auth/regist/REQUEST/SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/auth/regist/REQUEST/FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/auth/regist/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/auth/regist/REQUEST/SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/auth/regist/REQUEST/FAILURE';
|
25
src/ts/@overflow/auth/redux/reducer/check_auth_crawler.ts
Normal file
25
src/ts/@overflow/auth/redux/reducer/check_auth_crawler.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import Action from '@overflow/commons/redux/Action';
|
||||
import { ReducersMapObject } from 'redux';
|
||||
|
||||
|
||||
import * as CheckAuthCrawlerActionTypes from '../action/check_auth_crawler';
|
||||
import CheckAuthCrawlerState, { defaultState as CheckAuthCrawlerDefaultState } from '../state/CheckAuthCrawler';
|
||||
|
||||
const reducer: ReducersMapObject = {
|
||||
[CheckAuthCrawlerActionTypes.REQUEST_SUCCESS]: (state: CheckAuthCrawlerState = CheckAuthCrawlerDefaultState,
|
||||
action: Action<boolean>): CheckAuthCrawlerState => {
|
||||
return {
|
||||
...state,
|
||||
isSuccessCheckAuthCrawler: action.payload,
|
||||
};
|
||||
},
|
||||
[CheckAuthCrawlerActionTypes.REQUEST_FAILURE]: (state: CheckAuthCrawlerState = CheckAuthCrawlerDefaultState,
|
||||
action: Action<Error>): CheckAuthCrawlerState => {
|
||||
return {
|
||||
...state,
|
||||
error: action.error,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default reducer;
|
27
src/ts/@overflow/auth/redux/reducer/regist.ts
Normal file
27
src/ts/@overflow/auth/redux/reducer/regist.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import Action from '@overflow/commons/redux/Action';
|
||||
import { ReducersMapObject } from 'redux';
|
||||
|
||||
|
||||
import * as RegistActionTypes from '../action/regist';
|
||||
import RegistState, { defaultState as RegistDefaultState } from '../state/Regist';
|
||||
|
||||
import AuthCrawler from '../../api/model/AuthCrawler';
|
||||
|
||||
const reducer: ReducersMapObject = {
|
||||
[RegistActionTypes.REQUEST_SUCCESS]: (state: RegistState = RegistDefaultState,
|
||||
action: Action<AuthCrawler>): RegistState => {
|
||||
return {
|
||||
...state,
|
||||
authCrawler: action.payload,
|
||||
};
|
||||
},
|
||||
[RegistActionTypes.REQUEST_FAILURE]: (state: RegistState = RegistDefaultState,
|
||||
action: Action<AuthCrawler>): RegistState => {
|
||||
return {
|
||||
...state,
|
||||
error: action.error,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default reducer;
|
12
src/ts/@overflow/auth/redux/state/CheckAuthCrawler.ts
Normal file
12
src/ts/@overflow/auth/redux/state/CheckAuthCrawler.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
export interface State {
|
||||
readonly isSuccessCheckAuthCrawler: boolean;
|
||||
readonly error?: Error;
|
||||
}
|
||||
|
||||
export const defaultState: State = {
|
||||
isSuccessCheckAuthCrawler: undefined,
|
||||
error: undefined,
|
||||
};
|
||||
|
||||
export default State;
|
14
src/ts/@overflow/auth/redux/state/Regist.ts
Normal file
14
src/ts/@overflow/auth/redux/state/Regist.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
import AuthCrawler from '../../api/model/AuthCrawler';
|
||||
|
||||
export interface State {
|
||||
readonly authCrawler: AuthCrawler;
|
||||
readonly error?: Error;
|
||||
}
|
||||
|
||||
export const defaultState: State = {
|
||||
authCrawler: undefined,
|
||||
error: undefined,
|
||||
};
|
||||
|
||||
export default State;
|
|
@ -6,11 +6,12 @@ import {
|
|||
} from './components/CrawlerAuthInputs';
|
||||
// import State from '../redux/state/ReadAllByTarget';
|
||||
|
||||
import Crawler from '@overflow/meta/api/model/MetaCrawler';
|
||||
// import Sensor from '@overflow/sensor/api/model/Sensor';
|
||||
// import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem';
|
||||
import MetaCrawler from '@overflow/meta/api/model/MetaCrawler';
|
||||
import Infra from '@overflow/infra/api/model/Infra';
|
||||
import AuthCrawler from '@overflow/auth/api/model/AuthCrawler';
|
||||
|
||||
import * as CrawlerAuthInputsActions from '@overflow/meta/redux/action/crawler_auth_inputs';
|
||||
import * as CheckAuthCrawlerActions from '@overflow/auth/redux/action/check_auth_crawler';
|
||||
import * as RegistActions from '@overflow/auth/redux/action/regist';
|
||||
// import * as SensorItemReadAllActions from '@overflow/meta/redux/action/sensor_item_read_all';
|
||||
// import * as CrawlerReadAllByTargetActions from '../redux/action/crawler_read_all_by_target';
|
||||
|
||||
|
@ -27,6 +28,14 @@ export function mapStateToProps(state: any, props: any): CrawlerAuthInputsStateP
|
|||
|
||||
export function mapDispatchToProps(dispatch: Dispatch<any>): CrawlerAuthInputsDispatchProps {
|
||||
return {
|
||||
onVerifyCrawler: (infraId: number, crawler: MetaCrawler, authJson: String) => {
|
||||
dispatch(asyncRequestActions.request('AuthCrawlerService', 'checkAuthCrawler', CheckAuthCrawlerActions.REQUEST,
|
||||
JSON.stringify(infraId), JSON.stringify(crawler), authJson));
|
||||
},
|
||||
onRegistAuthCrawler: (authCrawler: AuthCrawler) => {
|
||||
dispatch(asyncRequestActions.request('AuthCrawlerService', 'regist', RegistActions.REQUEST,
|
||||
JSON.stringify(authCrawler)));
|
||||
},
|
||||
// onCrawlerReadAllByMetaCrawler: (crawler: Crawler) => {
|
||||
// dispatch(asyncRequestActions.request('MetaCrawlerInputItemService',
|
||||
// 'readAllByMetaCrawler', CrawlerAuthInputsActions.REQUEST, JSON.stringify(crawler)));
|
||||
|
|
|
@ -1,20 +1,28 @@
|
|||
|
||||
import * as React from 'react';
|
||||
import * as _ from 'lodash';
|
||||
import { Icon, Step, Button, Table, Radio, Form, Container, Checkbox } from 'semantic-ui-react';
|
||||
import { Grid, Image, Label, Segment, Dropdown, Input, List, Accordion, Loader } from 'semantic-ui-react';
|
||||
import { Grid, Image, Label, Segment, Dropdown, Input, List, Accordion, Loader, InputOnChangeData, CheckboxProps } from 'semantic-ui-react';
|
||||
|
||||
import MetaCrawler from '@overflow/meta/api/model/MetaCrawler';
|
||||
import MetaCrawlerInputItem from '@overflow/meta/api/model/MetaCrawlerInputItem';
|
||||
|
||||
import SensorItemTree from '@overflow/meta/react/SensorItemTree';
|
||||
import SensorRegistInfo from '@overflow/sensor/api/model/SensorRegistInfo';
|
||||
import Infra from '@overflow/infra/api/model/Infra';
|
||||
import AuthCrawler from '@overflow/auth/api/model/AuthCrawler';
|
||||
|
||||
export interface CrawlerAuthInputsStateProps {
|
||||
crawlerId?: number;
|
||||
crawler?: MetaCrawler;
|
||||
metaCrawlerInputItemList?: MetaCrawlerInputItem[];
|
||||
setSensor?(data: SensorRegistInfo): void;
|
||||
getSensor?(): SensorRegistInfo;
|
||||
}
|
||||
|
||||
export interface CrawlerAuthInputsDispatchProps {
|
||||
onVerifyCrawler?(infraId: number, crawler: MetaCrawler, authJson: String): void;
|
||||
onRegistAuthCrawler?(authCrawler: AuthCrawler): void;
|
||||
}
|
||||
|
||||
export type CrawlerAuthInputsProps = CrawlerAuthInputsStateProps & CrawlerAuthInputsDispatchProps;
|
||||
|
@ -23,6 +31,7 @@ export type CrawlerAuthInputsProps = CrawlerAuthInputsStateProps & CrawlerAuthIn
|
|||
|
||||
export interface CrawlerAuthInputsState {
|
||||
isVerifying: boolean;
|
||||
authJson: any;
|
||||
}
|
||||
|
||||
export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, CrawlerAuthInputsState> {
|
||||
|
@ -32,6 +41,7 @@ export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, C
|
|||
super(props, context);
|
||||
this.state = {
|
||||
isVerifying: false,
|
||||
authJson: {},
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -71,14 +81,39 @@ export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, C
|
|||
this.setState({
|
||||
isVerifying: true,
|
||||
});
|
||||
let sd = this.props.getSensor();
|
||||
sd.crawlerAuth = this.state.authJson;
|
||||
this.props.setSensor(sd);
|
||||
|
||||
this.props.onVerifyCrawler(sd.infra.id, sd.crawler, sd.crawlerAuth);
|
||||
|
||||
let authCrawler: AuthCrawler = {
|
||||
crawler: {id:sd.crawler.id},
|
||||
target: {id:sd.infra.target.id},
|
||||
authJson: JSON.stringify(sd.crawlerAuth),
|
||||
};
|
||||
|
||||
this.props.onRegistAuthCrawler(authCrawler);
|
||||
}
|
||||
|
||||
public onChangeAuth = (key: string, data: string) => {
|
||||
let newJson: any = _.clone(this.state.authJson);
|
||||
newJson[key] = data;
|
||||
this.setState({ authJson: newJson });
|
||||
}
|
||||
|
||||
public renderRow(item: MetaCrawlerInputItem, index: number): JSX.Element {
|
||||
let elem = new Array();
|
||||
if (item.inputType.name === 'TEXT_TYPE') {
|
||||
elem.push(<Input placeholder={item.defaultValue} key={0} />);
|
||||
elem.push(<Input label={item.name} placeholder={item.defaultValue} key={0} onChange={
|
||||
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
|
||||
this.onChangeAuth(item.name, data.value);
|
||||
}} />);
|
||||
} else if (item.inputType.name === 'PASSWORD_TYPE') {
|
||||
elem.push(<Input type='password' placeholder={item.defaultValue} key={0} />);
|
||||
elem.push(<Input label={item.name} type='password' placeholder={item.defaultValue} key={0} onChange={
|
||||
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
|
||||
this.onChangeAuth(item.name, data.value);
|
||||
}} />);
|
||||
} else if (item.inputType.name === 'Radio') {
|
||||
let itemValues = item.keyValue.split('|');
|
||||
let idx = 0;
|
||||
|
@ -88,6 +123,11 @@ export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, C
|
|||
label={itemValue}
|
||||
name='radioGroup'
|
||||
value={itemValue}
|
||||
onChange={
|
||||
(event: React.FormEvent<HTMLInputElement>, data: CheckboxProps) => {
|
||||
this.onChangeAuth(item.name, itemValue);
|
||||
}
|
||||
}
|
||||
/>);
|
||||
}
|
||||
}
|
||||
|
@ -145,6 +185,7 @@ export class CrawlerAuthInputs extends React.Component<CrawlerAuthInputsProps, C
|
|||
<Table.Footer>
|
||||
<Table.Row>
|
||||
<Table.HeaderCell colSpan='2'>
|
||||
{/*loading={this.state.isVerifying}*/}
|
||||
<Button primary floated={'right'} onClick={this.handleVerify.bind(this)} loading={this.state.isVerifying}>Verify</Button>
|
||||
</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
|
|
|
@ -128,7 +128,8 @@ export class CrawlerSelector extends React.Component<CrawlerSelectorProps, Crawl
|
|||
<br />
|
||||
</Grid.Column>
|
||||
<Grid.Column>
|
||||
<CrawlerAuthInputsContainer metaCrawlerInputItemList={this.props.metaCrawlerInputItemList} />
|
||||
<CrawlerAuthInputsContainer metaCrawlerInputItemList={this.props.metaCrawlerInputItemList}
|
||||
getSensor={this.props.getSensor} setSensor={this.props.setSensor}/>
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
);
|
||||
|
|
|
@ -10,6 +10,7 @@ interface SensorRegistInfo {
|
|||
interval: number;
|
||||
// type: string;
|
||||
infra: Infra;
|
||||
crawlerAuth: string;
|
||||
}
|
||||
|
||||
export default SensorRegistInfo;
|
||||
|
|
|
@ -29,9 +29,10 @@ export function mapStateToProps(state: any, props: any): SensorConfigStepperStat
|
|||
|
||||
export function mapDispatchToProps(dispatch: Dispatch<any>): SensorConfigStepperDispatchProps {
|
||||
return {
|
||||
onRegistSensorConfig: (sensor: Sensor, sensorItemList: SensorItem[]) => {
|
||||
onRegistSensorConfig: (sensor: Sensor, sensorItemList: SensorItem[], etc: any) => {
|
||||
dispatch(asyncRequestActions.request('SensorService', 'registSensorConfig', RegistSensorConfigActions.REQUEST,
|
||||
JSON.stringify(sensor), JSON.stringify(sensorItemList)));
|
||||
JSON.stringify(sensor), JSON.stringify(sensorItemList),
|
||||
JSON.stringify(etc)));
|
||||
},
|
||||
onMoveSensors: () => {
|
||||
dispatch(routerPush('/sensors'));
|
||||
|
|
|
@ -47,7 +47,7 @@ export interface SensorConfigStepperStateProps {
|
|||
}
|
||||
|
||||
export interface SensorConfigStepperDispatchProps {
|
||||
onRegistSensorConfig?(sensor: Sensor, sensorItemList: SensorItem[]): void;
|
||||
onRegistSensorConfig?(sensor: Sensor, sensorItemList: SensorItem[], etc: any): void;
|
||||
onMoveSensors?(): void;
|
||||
onMoveTargetSensors?(targetId: number): void;
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ export class SensorConfigStepper extends React.Component<SensorConfigStepperProp
|
|||
|
||||
public registSensor(): void {
|
||||
let sensorData = this.props.getSensor();
|
||||
console.log(sensorData);
|
||||
let sensor: Sensor = {};
|
||||
|
||||
sensor.crawler = { id: sensorData.crawler.id };
|
||||
|
@ -202,7 +203,9 @@ export class SensorConfigStepper extends React.Component<SensorConfigStepperProp
|
|||
console.log(sensor);
|
||||
console.log(siList);
|
||||
|
||||
this.props.onRegistSensorConfig(sensor, siList);
|
||||
let etc: any = {interval: sensorData.interval};
|
||||
|
||||
this.props.onRegistSensorConfig(sensor, siList, etc);
|
||||
}
|
||||
|
||||
public showContent(): any {
|
||||
|
|
Loading…
Reference in New Issue
Block a user