added sensor setup

This commit is contained in:
snoop 2017-07-21 14:41:44 +09:00
parent 7e2d9eee39
commit 3bb4708a0e
8 changed files with 112 additions and 7 deletions

View File

@ -9,7 +9,7 @@ export function int2ip(ipInt: number): string {
export function ip2int(ip: string): number { export function ip2int(ip: string): number {
// tslint:disable-next-line:no-bitwise // tslint:disable-next-line:no-bitwise
return ip.split('.').reduce<number>(function (ipInt: number, octet: string) { return (ipInt << 8) + parseInt(octet, 10); }, 0) >>> 0; return ip.split('.').reduce<number>(function (ipInt, octet) { return (ipInt << 8) + parseInt(octet, 10); }, 0) >>> 0;
} }
export function sec2date(ms: number): string { export function sec2date(ms: number): string {

View File

@ -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<CrawlerReadAllByTargetPayload>;
export type requestSuccess = (metaCrawlerList: MetaCrawler[]) => Action<MetaCrawler[]>;
export type requestFailure = (error: Error) => Action;
export const request: request = (target: Target): Action<CrawlerReadAllByTargetPayload> => {
return {
type: REQUEST,
payload: {
target: target,
},
};
};
export const requestSuccess: requestSuccess = (metaCrawlerList: MetaCrawler[]): Action<MetaCrawler[]> => {
return {
type: REQUEST_SUCCESS,
payload: metaCrawlerList,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<SensorItemReadAllPayload>;
export type requestSuccess = (metaSensorItemList: MetaSensorItem[]) => Action<MetaSensorItem[]>;
export type requestFailure = (error: Error) => Action;
export const request: request = (): Action<SensorItemReadAllPayload> => {
return {
type: REQUEST,
payload: {
},
};
};
export const requestSuccess: requestSuccess = (metaSensorItemList: MetaSensorItem[]): Action<MetaSensorItem[]> => {
return {
type: REQUEST_SUCCESS,
payload: metaSensorItemList,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,7 @@
import Target from '@overflow/target/api/model/Target';
interface CrawlerReadAllByTargetPayload {
target: Target;
}
export default CrawlerReadAllByTargetPayload;

View File

@ -0,0 +1,7 @@
interface SensorItemReadAllPayload {
}
export default SensorItemReadAllPayload;

View File

@ -10,7 +10,10 @@ import Target from '@overflow/target/api/model/Target';
import Sensor from '@overflow/sensor/api/model/Sensor'; import Sensor from '@overflow/sensor/api/model/Sensor';
import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem'; 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::.... // FIXME::....
export function mapStateToProps(state: any): SensorConfigurationStateProps { export function mapStateToProps(state: any): SensorConfigurationStateProps {
@ -20,18 +23,18 @@ export function mapStateToProps(state: any): SensorConfigurationStateProps {
export function mapDispatchToProps(dispatch: Dispatch<any>): SensorConfigurationDispatchProps { export function mapDispatchToProps(dispatch: Dispatch<any>): SensorConfigurationDispatchProps {
return { return {
onReadAllByCrawler: (target: Target) => { onCrawlerReadAllByTarget: (target: Target) => {
// dispatch(ReadActions.request(id)); dispatch(CrawlerReadAllByTargetActions.request(target));
}, },
onCheckCrawlerAuth: (authInfo: string) => { onCheckCrawlerAuth: (authInfo: string) => {
// dispatch(ReadActions.request(id)); // dispatch(ReadActions.request(id));
}, },
// FIXME::how to sensor item? // FIXME::how to sensor item?
onReadSensorItem: () => { onReadMetaSensorItem: () => {
// dispatch(ReadActions.request(id)); dispatch(SensorItemReadAllActions.request());
}, },
onSaveSensor: (sensor: Sensor) => { onSaveSensor: (sensor: Sensor) => {
// dispatch(ReadActions.request(id)); dispatch(RegistActions.request(sensor));
}, },
}; };
} }