From 9319ddfa8e2da855c6ee6d9800fab9bdb14df07d Mon Sep 17 00:00:00 2001 From: snoop Date: Wed, 30 Aug 2017 19:53:10 +0900 Subject: [PATCH] added authcrawler --- .../@overflow/auth/api/model/AuthCrawler.ts | 14 ++++++ .../auth/redux/action/check_auth_crawler.ts | 7 +++ src/ts/@overflow/auth/redux/action/regist.ts | 7 +++ .../auth/redux/reducer/check_auth_crawler.ts | 25 ++++++++++ src/ts/@overflow/auth/redux/reducer/regist.ts | 27 +++++++++++ .../auth/redux/state/CheckAuthCrawler.ts | 12 +++++ src/ts/@overflow/auth/redux/state/Regist.ts | 14 ++++++ .../meta/react/CrawlerAuthInputs.tsx | 19 ++++++-- .../react/components/CrawlerAuthInputs.tsx | 47 +++++++++++++++++-- .../meta/react/components/CrawlerSelector.tsx | 3 +- .../sensor/api/model/SensorRegistInfo.ts | 1 + .../sensor/react/SensorConfigStepper.tsx | 5 +- .../react/components/SensorConfigStepper.tsx | 7 ++- 13 files changed, 175 insertions(+), 13 deletions(-) create mode 100644 src/ts/@overflow/auth/api/model/AuthCrawler.ts create mode 100644 src/ts/@overflow/auth/redux/action/check_auth_crawler.ts create mode 100644 src/ts/@overflow/auth/redux/action/regist.ts create mode 100644 src/ts/@overflow/auth/redux/reducer/check_auth_crawler.ts create mode 100644 src/ts/@overflow/auth/redux/reducer/regist.ts create mode 100644 src/ts/@overflow/auth/redux/state/CheckAuthCrawler.ts create mode 100644 src/ts/@overflow/auth/redux/state/Regist.ts diff --git a/src/ts/@overflow/auth/api/model/AuthCrawler.ts b/src/ts/@overflow/auth/api/model/AuthCrawler.ts new file mode 100644 index 0000000..10b3616 --- /dev/null +++ b/src/ts/@overflow/auth/api/model/AuthCrawler.ts @@ -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; diff --git a/src/ts/@overflow/auth/redux/action/check_auth_crawler.ts b/src/ts/@overflow/auth/redux/action/check_auth_crawler.ts new file mode 100644 index 0000000..a7f95f4 --- /dev/null +++ b/src/ts/@overflow/auth/redux/action/check_auth_crawler.ts @@ -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'; diff --git a/src/ts/@overflow/auth/redux/action/regist.ts b/src/ts/@overflow/auth/redux/action/regist.ts new file mode 100644 index 0000000..1942dbf --- /dev/null +++ b/src/ts/@overflow/auth/redux/action/regist.ts @@ -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'; diff --git a/src/ts/@overflow/auth/redux/reducer/check_auth_crawler.ts b/src/ts/@overflow/auth/redux/reducer/check_auth_crawler.ts new file mode 100644 index 0000000..9840f03 --- /dev/null +++ b/src/ts/@overflow/auth/redux/reducer/check_auth_crawler.ts @@ -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): CheckAuthCrawlerState => { + return { + ...state, + isSuccessCheckAuthCrawler: action.payload, + }; + }, + [CheckAuthCrawlerActionTypes.REQUEST_FAILURE]: (state: CheckAuthCrawlerState = CheckAuthCrawlerDefaultState, + action: Action): CheckAuthCrawlerState => { + return { + ...state, + error: action.error, + }; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/auth/redux/reducer/regist.ts b/src/ts/@overflow/auth/redux/reducer/regist.ts new file mode 100644 index 0000000..418d1be --- /dev/null +++ b/src/ts/@overflow/auth/redux/reducer/regist.ts @@ -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): RegistState => { + return { + ...state, + authCrawler: action.payload, + }; + }, + [RegistActionTypes.REQUEST_FAILURE]: (state: RegistState = RegistDefaultState, + action: Action): RegistState => { + return { + ...state, + error: action.error, + }; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/auth/redux/state/CheckAuthCrawler.ts b/src/ts/@overflow/auth/redux/state/CheckAuthCrawler.ts new file mode 100644 index 0000000..71240ee --- /dev/null +++ b/src/ts/@overflow/auth/redux/state/CheckAuthCrawler.ts @@ -0,0 +1,12 @@ + +export interface State { + readonly isSuccessCheckAuthCrawler: boolean; + readonly error?: Error; +} + +export const defaultState: State = { + isSuccessCheckAuthCrawler: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/auth/redux/state/Regist.ts b/src/ts/@overflow/auth/redux/state/Regist.ts new file mode 100644 index 0000000..5835fe3 --- /dev/null +++ b/src/ts/@overflow/auth/redux/state/Regist.ts @@ -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; diff --git a/src/ts/@overflow/meta/react/CrawlerAuthInputs.tsx b/src/ts/@overflow/meta/react/CrawlerAuthInputs.tsx index e8f0390..2b27d60 100644 --- a/src/ts/@overflow/meta/react/CrawlerAuthInputs.tsx +++ b/src/ts/@overflow/meta/react/CrawlerAuthInputs.tsx @@ -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'; @@ -21,12 +22,20 @@ import * as asyncRequestActions from '@overflow/commons/redux/action/asyncReques export function mapStateToProps(state: any, props: any): CrawlerAuthInputsStateProps { return { // crawler: props.crawler, - metaCrawlerInputItemList:props.metaCrawlerInputItemList, + metaCrawlerInputItemList: props.metaCrawlerInputItemList, }; } export function mapDispatchToProps(dispatch: Dispatch): 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))); diff --git a/src/ts/@overflow/meta/react/components/CrawlerAuthInputs.tsx b/src/ts/@overflow/meta/react/components/CrawlerAuthInputs.tsx index 9a69eb7..db93833 100644 --- a/src/ts/@overflow/meta/react/components/CrawlerAuthInputs.tsx +++ b/src/ts/@overflow/meta/react/components/CrawlerAuthInputs.tsx @@ -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 { @@ -32,6 +41,7 @@ export class CrawlerAuthInputs extends React.Component { + 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(); + elem.push(, data: InputOnChangeData) => { + this.onChangeAuth(item.name, data.value); + }} />); } else if (item.inputType.name === 'PASSWORD_TYPE') { - elem.push(); + elem.push(, 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, data: CheckboxProps) => { + this.onChangeAuth(item.name, itemValue); + } + } />); } } @@ -145,6 +185,7 @@ export class CrawlerAuthInputs extends React.Component + {/*loading={this.state.isVerifying}*/} diff --git a/src/ts/@overflow/meta/react/components/CrawlerSelector.tsx b/src/ts/@overflow/meta/react/components/CrawlerSelector.tsx index 3e389ac..a49bff4 100644 --- a/src/ts/@overflow/meta/react/components/CrawlerSelector.tsx +++ b/src/ts/@overflow/meta/react/components/CrawlerSelector.tsx @@ -128,7 +128,8 @@ export class CrawlerSelector extends React.Component - + ); diff --git a/src/ts/@overflow/sensor/api/model/SensorRegistInfo.ts b/src/ts/@overflow/sensor/api/model/SensorRegistInfo.ts index 6f0da5a..e3edf75 100644 --- a/src/ts/@overflow/sensor/api/model/SensorRegistInfo.ts +++ b/src/ts/@overflow/sensor/api/model/SensorRegistInfo.ts @@ -10,6 +10,7 @@ interface SensorRegistInfo { interval: number; // type: string; infra: Infra; + crawlerAuth: string; } export default SensorRegistInfo; diff --git a/src/ts/@overflow/sensor/react/SensorConfigStepper.tsx b/src/ts/@overflow/sensor/react/SensorConfigStepper.tsx index bd8aa10..c1ad6aa 100644 --- a/src/ts/@overflow/sensor/react/SensorConfigStepper.tsx +++ b/src/ts/@overflow/sensor/react/SensorConfigStepper.tsx @@ -29,9 +29,10 @@ export function mapStateToProps(state: any, props: any): SensorConfigStepperStat export function mapDispatchToProps(dispatch: Dispatch): 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')); diff --git a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx index 5add4bd..5ebda94 100644 --- a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx @@ -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