From 3bb4708a0e72efde41e2112239f8e93d00072389 Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 21 Jul 2017 14:41:44 +0900 Subject: [PATCH] added sensor setup --- src/ts/@overflow/commons/utils/Utils.tsx | 2 +- src/ts/@overflow/meta/redux/action/_ | 0 .../action/crawler_read_all_by_target.ts | 44 +++++++++++++++++++ .../meta/redux/action/sensor_item_read_all.ts | 44 +++++++++++++++++++ .../payload/CrawlerReadAllByTargetPayload.ts | 7 +++ .../redux/payload/SensorItemReadAllPayload.ts | 7 +++ src/ts/@overflow/meta/redux/payload/_ | 0 .../sensor/react/SensorConfiguration.tsx | 15 ++++--- 8 files changed, 112 insertions(+), 7 deletions(-) delete mode 100644 src/ts/@overflow/meta/redux/action/_ create mode 100644 src/ts/@overflow/meta/redux/action/crawler_read_all_by_target.ts create mode 100644 src/ts/@overflow/meta/redux/action/sensor_item_read_all.ts create mode 100644 src/ts/@overflow/meta/redux/payload/CrawlerReadAllByTargetPayload.ts create mode 100644 src/ts/@overflow/meta/redux/payload/SensorItemReadAllPayload.ts delete mode 100644 src/ts/@overflow/meta/redux/payload/_ diff --git a/src/ts/@overflow/commons/utils/Utils.tsx b/src/ts/@overflow/commons/utils/Utils.tsx index 5a76c24..0e8c758 100644 --- a/src/ts/@overflow/commons/utils/Utils.tsx +++ b/src/ts/@overflow/commons/utils/Utils.tsx @@ -9,7 +9,7 @@ export function int2ip(ipInt: number): string { export function ip2int(ip: string): number { // tslint:disable-next-line:no-bitwise - return ip.split('.').reduce(function (ipInt: number, octet: string) { return (ipInt << 8) + parseInt(octet, 10); }, 0) >>> 0; + return ip.split('.').reduce(function (ipInt, octet) { return (ipInt << 8) + parseInt(octet, 10); }, 0) >>> 0; } export function sec2date(ms: number): string { diff --git a/src/ts/@overflow/meta/redux/action/_ b/src/ts/@overflow/meta/redux/action/_ deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/meta/redux/action/crawler_read_all_by_target.ts b/src/ts/@overflow/meta/redux/action/crawler_read_all_by_target.ts new file mode 100644 index 0000000..d558d9c --- /dev/null +++ b/src/ts/@overflow/meta/redux/action/crawler_read_all_by_target.ts @@ -0,0 +1,44 @@ +import Action from '@overflow/commons/redux/Action'; +import MetaCrawler from '../../api/model//MetaCrawler'; +import Target from '@overflow/target/api/model/Target'; + +import CrawlerReadAllByTargetPayload from '../payload/CrawlerReadAllByTargetPayload'; + +// Action Type +export type REQUEST = '@overflow/meta_crawler/crawler_read_all_by_target/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/meta_crawler/crawler_read_all_by_target/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/meta_crawler/crawler_read_all_by_target/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/meta_crawler/crawler_read_all_by_target/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/meta_crawler/crawler_read_all_by_target/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/meta_crawler/crawler_read_all_by_target/REQUEST_FAILURE'; + +// Action Creater +export type request = (target: Target) => Action; +export type requestSuccess = (metaCrawlerList: MetaCrawler[]) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (target: Target): Action => { + return { + type: REQUEST, + payload: { + target: target, + }, + }; +}; + +export const requestSuccess: requestSuccess = (metaCrawlerList: MetaCrawler[]): Action => { + return { + type: REQUEST_SUCCESS, + payload: metaCrawlerList, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/meta/redux/action/sensor_item_read_all.ts b/src/ts/@overflow/meta/redux/action/sensor_item_read_all.ts new file mode 100644 index 0000000..d57564a --- /dev/null +++ b/src/ts/@overflow/meta/redux/action/sensor_item_read_all.ts @@ -0,0 +1,44 @@ +import Action from '@overflow/commons/redux/Action'; +import MetaSensorItem from '../../api/model//MetaSensorItem'; + + +import SensorItemReadAllPayload from '../payload/SensorItemReadAllPayload'; + +// Action Type +export type REQUEST = '@overflow/meta_sensor_item/sensor_item_read_all/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/meta_sensor_item/sensor_item_read_all/REQUEST_SUCCESS'; +export type REQUEST_FAILURE = '@overflow/meta_sensor_item/sensor_item_read_all/REQUEST_FAILURE'; + +export const REQUEST: REQUEST = '@overflow/meta_sensor_item/sensor_item_read_all/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/meta_sensor_item/sensor_item_read_all/REQUEST_SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/meta_sensor_item/sensor_item_read_all/REQUEST_FAILURE'; + +// Action Creater +export type request = () => Action; +export type requestSuccess = (metaSensorItemList: MetaSensorItem[]) => Action; +export type requestFailure = (error: Error) => Action; + + + +export const request: request = (): Action => { + return { + type: REQUEST, + payload: { + + }, + }; +}; + +export const requestSuccess: requestSuccess = (metaSensorItemList: MetaSensorItem[]): Action => { + return { + type: REQUEST_SUCCESS, + payload: metaSensorItemList, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/meta/redux/payload/CrawlerReadAllByTargetPayload.ts b/src/ts/@overflow/meta/redux/payload/CrawlerReadAllByTargetPayload.ts new file mode 100644 index 0000000..cbc4342 --- /dev/null +++ b/src/ts/@overflow/meta/redux/payload/CrawlerReadAllByTargetPayload.ts @@ -0,0 +1,7 @@ +import Target from '@overflow/target/api/model/Target'; + +interface CrawlerReadAllByTargetPayload { + target: Target; +} + +export default CrawlerReadAllByTargetPayload; diff --git a/src/ts/@overflow/meta/redux/payload/SensorItemReadAllPayload.ts b/src/ts/@overflow/meta/redux/payload/SensorItemReadAllPayload.ts new file mode 100644 index 0000000..74a5801 --- /dev/null +++ b/src/ts/@overflow/meta/redux/payload/SensorItemReadAllPayload.ts @@ -0,0 +1,7 @@ + + +interface SensorItemReadAllPayload { + +} + +export default SensorItemReadAllPayload; diff --git a/src/ts/@overflow/meta/redux/payload/_ b/src/ts/@overflow/meta/redux/payload/_ deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/sensor/react/SensorConfiguration.tsx b/src/ts/@overflow/sensor/react/SensorConfiguration.tsx index d58e9b0..7bf62af 100644 --- a/src/ts/@overflow/sensor/react/SensorConfiguration.tsx +++ b/src/ts/@overflow/sensor/react/SensorConfiguration.tsx @@ -10,7 +10,10 @@ import Target from '@overflow/target/api/model/Target'; import Sensor from '@overflow/sensor/api/model/Sensor'; import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem'; -// import * as ReadAllByTargetActions from '../redux/action/read_all_by_target'; +import * as CrawlerReadAllByTargetActions from '@overflow/meta/redux/action/crawler_read_all_by_target'; +import * as SensorItemReadAllActions from '@overflow/meta/redux/action/sensor_item_read_all'; +import * as RegistActions from '../redux/action/regist'; + // FIXME::.... export function mapStateToProps(state: any): SensorConfigurationStateProps { @@ -20,18 +23,18 @@ export function mapStateToProps(state: any): SensorConfigurationStateProps { export function mapDispatchToProps(dispatch: Dispatch): SensorConfigurationDispatchProps { return { - onReadAllByCrawler: (target: Target) => { - // dispatch(ReadActions.request(id)); + onCrawlerReadAllByTarget: (target: Target) => { + dispatch(CrawlerReadAllByTargetActions.request(target)); }, onCheckCrawlerAuth: (authInfo: string) => { // dispatch(ReadActions.request(id)); }, // FIXME::how to sensor item? - onReadSensorItem: () => { - // dispatch(ReadActions.request(id)); + onReadMetaSensorItem: () => { + dispatch(SensorItemReadAllActions.request()); }, onSaveSensor: (sensor: Sensor) => { - // dispatch(ReadActions.request(id)); + dispatch(RegistActions.request(sensor)); }, }; }