From 43681525e107caec0ce433c85521e7b2084da1d9 Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 8 Nov 2017 18:23:12 +0900 Subject: [PATCH] sensor.... --- src/ts/@overflow/app/config/index.ts | 13 +- .../meta/api/model/MetaSensorDisplayItem.ts | 17 +++ .../meta/api/model/MetaSensorItemUnit.ts | 8 ++ .../@overflow/meta/react/SensorItemTree.tsx | 37 ++--- .../meta/react/components/SensorItemTree.tsx | 128 +++++++----------- ...sensor_display_item_read_all_by_crawler.ts | 9 ++ ...sensor_display_item_read_all_by_crawler.ts | 29 ++++ .../SensorDisplayItemReadAllByCrawler.ts | 13 ++ .../@overflow/sensor/api/model/SensorItem.ts | 4 +- .../sensor/api/model/SensorRegistInfo.ts | 4 +- .../react/components/SensorConfigStepper.tsx | 17 +-- .../react/components/SensorConfiguration.tsx | 9 +- 12 files changed, 159 insertions(+), 129 deletions(-) create mode 100644 src/ts/@overflow/meta/api/model/MetaSensorDisplayItem.ts create mode 100644 src/ts/@overflow/meta/api/model/MetaSensorItemUnit.ts create mode 100644 src/ts/@overflow/meta/redux/action/sensor_display_item_read_all_by_crawler.ts create mode 100644 src/ts/@overflow/meta/redux/reducer/sensor_display_item_read_all_by_crawler.ts create mode 100644 src/ts/@overflow/meta/redux/state/SensorDisplayItemReadAllByCrawler.ts diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index 57ade35..f9cda14 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -35,35 +35,27 @@ import readHostReducer from '@overflow/infra/redux/reducer/host_read'; import readOSReducer from '@overflow/infra/redux/reducer/os_read'; import readServiceReducer from '@overflow/infra/redux/reducer/service_read'; import InfraReadServiceReducer from '@overflow/infra/redux/reducer/read'; - import CrawlerReadAllByTargetReducer from '@overflow/meta/redux/reducer/crawler_read_all_by_target'; import CrawlerAuthInputsReducer from '@overflow/meta/redux/reducer/crawler_auth_inputs'; - import MetaSensorItemReadAllReducer from '@overflow/meta/redux/reducer/sensor_item_read_all'; import MetaSensorItemTypeReadAllReducer from '@overflow/meta/redux/reducer/sensor_item_type_read_all'; - import DiscoveryInfraTargetRegistAllReducer from '@overflow/discovery/redux/reducer/infra_target_regist_all'; import DiscoveryIngReducer from '@overflow/discovery/redux/reducer/ing'; - import HistoryReadAllByProbeReducer from '@overflow/history/redux/reducer/read_all_by_probe'; import HistoryReadAllByProbeAndTypeReducer from '@overflow/history/redux/reducer/read_all_by_probe_and_type'; import HistoryTypeReadAllReducer from '@overflow/meta/redux/reducer/history_type_read_all'; import NotificationReadAllUnconfirmedReducer from '@overflow/notification/redux/reducer/read_all_unconfirmed'; import NotificationReadAllReducer from '@overflow/notification/redux/reducer/read_all'; import NotificationReadCountReducer from '@overflow/notification/redux/reducer/read_unconfirmed_count'; - import SensorItemKeyReadAllByCrawlerReducer from '@overflow/meta/redux/reducer/sensor_item_key_read_all_by_crawler'; - import ForgotPassword from '@overflow/member/redux/reducer/forgotPassword'; - import AuthCrawlerRegistReducer from '@overflow/auth/redux/reducer/regist'; - import AsyncRequest from '@overflow/app/redux/saga/AsyncRequest'; import AsyncNotify from '@overflow/app/redux/saga/AsyncNotify'; import AsyncRestRequest from '@overflow/app/redux/saga/AsyncRestRequest'; - import DiscoveryService from '@overflow/discovery/api/service/DiscoveryService'; import NoAuthProbeService from '@overflow/noauthprobe/api/service/NoAuthProbeService'; +import MetaSensorDisplayItemReducer from '@overflow/meta/redux/reducer/sensor_display_item_read_all_by_crawler'; // Container Configuration export interface ContainerConfig { @@ -78,7 +70,7 @@ export interface RPCConfig { url: string; } const rpcConfig: RPCConfig = { - url: 'ws://192.168.1.209:19090/web', + url: 'ws://127.0.0.1:19090/web', }; // REST Server Configuration @@ -146,6 +138,7 @@ const reduxConfig: ReduxConfig = { AuthCrawlerRegistReducer, ForgotPassword, SensorItemKeyReadAllByCrawlerReducer, + MetaSensorDisplayItemReducer, ], sagaWatchers: [ AsyncRequest, diff --git a/src/ts/@overflow/meta/api/model/MetaSensorDisplayItem.ts b/src/ts/@overflow/meta/api/model/MetaSensorDisplayItem.ts new file mode 100644 index 0000000..f2c7cee --- /dev/null +++ b/src/ts/@overflow/meta/api/model/MetaSensorDisplayItem.ts @@ -0,0 +1,17 @@ +import MetaCrawler from './MetaCrawler'; +import MetaSensorItemUnit from './MetaSensorItemUnit'; +import MetaSensorItemType from './MetaSensorItemType'; + +export interface MetaSensorDisplayItem { + id?: number; + key?: string; + displayName?: string; + description?: string; + crawler?: MetaCrawler; + unit?: MetaSensorItemUnit; + createDate?: Date; + default?: boolean; + itemType?: MetaSensorItemType; +} + +export default MetaSensorDisplayItem; diff --git a/src/ts/@overflow/meta/api/model/MetaSensorItemUnit.ts b/src/ts/@overflow/meta/api/model/MetaSensorItemUnit.ts new file mode 100644 index 0000000..9c711ad --- /dev/null +++ b/src/ts/@overflow/meta/api/model/MetaSensorItemUnit.ts @@ -0,0 +1,8 @@ +export interface MetaSensorItemUnit { + id: number; + unit: string; + createDate: Date; + mark: string; +} + +export default MetaSensorItemUnit; diff --git a/src/ts/@overflow/meta/react/SensorItemTree.tsx b/src/ts/@overflow/meta/react/SensorItemTree.tsx index a2591d4..4a666a4 100644 --- a/src/ts/@overflow/meta/react/SensorItemTree.tsx +++ b/src/ts/@overflow/meta/react/SensorItemTree.tsx @@ -6,10 +6,7 @@ import { } from './components/SensorItemTree'; import State from '../redux/state/SensorItemReadAll'; -import * as SensorItemReadAllByActions from '../redux/action/sensor_item_read_all'; -import * as SensorItemReadAllBySensorActions from '../redux/action/sensor_item_read_all_by_sensor'; -import * as SensorItemTypeReadAllActions from '../redux/action/sensor_item_type_read_all'; -import * as SensorItemKeyReadAllByCrawlerActions from '../redux/action/sensor_item_key_read_all_by_crawler'; +import * as SensorDisplayItemReadAllByCrawlerActions from '../redux/action/sensor_display_item_read_all_by_crawler'; import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; import Sensor from '@overflow/sensor/api/model/Sensor'; @@ -22,25 +19,29 @@ export function mapStateToProps(state: any, props: any): SensorItemTreeStateProp // metaSensorItemTypeList: state.MetaSensorItemTypeList, // sensorItemList: state.SensorItemList, // metaSensorItemList: state.MetaSensorItemList, - metaSensorItemKeyList: state.MetaSensorItemKeyList, + sensorDisplayItems: state.sensorDisplayItems, }; } export function mapDispatchToProps(dispatch: Dispatch): SensorItemTreeDispatchProps { return { - onReadAll: () => { - dispatch(asyncRequestActions.request('MetaSensorItemService', 'readAll', SensorItemReadAllByActions.REQUEST)); - }, - onReadAllBySensor: (sensor: Sensor) => { - dispatch(asyncRequestActions.request('SensorItemService', 'readAllBySensor', - SensorItemReadAllBySensorActions.REQUEST, JSON.stringify(sensor))); - }, - onSensorItemTypeReadAll: () => { - dispatch(asyncRequestActions.request('MetaSensorItemTypeService', 'readAll', SensorItemTypeReadAllActions.REQUEST)); - }, - onReadAllSensorItemKeyByCrawler: (metaCrawler: MetaCrawler) => { - dispatch(asyncRequestActions.request('MetaSensorItemKeyService', 'readAllByCrawler', - SensorItemKeyReadAllByCrawlerActions.REQUEST, JSON.stringify(metaCrawler))); + // onReadAll: () => { + // dispatch(asyncRequestActions.request('MetaSensorItemService', 'readAll', SensorItemReadAllByActions.REQUEST)); + // }, + // onReadAllBySensor: (sensor: Sensor) => { + // dispatch(asyncRequestActions.request('SensorItemService', 'readAllBySensor', + // SensorItemReadAllBySensorActions.REQUEST, JSON.stringify(sensor))); + // }, + // onSensorItemTypeReadAll: () => { + // dispatch(asyncRequestActions.request('MetaSensorItemTypeService', 'readAll', SensorItemTypeReadAllActions.REQUEST)); + // }, + // onReadAllSensorItemKeyByCrawler: (metaCrawler: MetaCrawler) => { + // dispatch(asyncRequestActions.request('MetaSensorItemKeyService', 'readAllByCrawler', + // SensorItemKeyReadAllByCrawlerActions.REQUEST, JSON.stringify(metaCrawler))); + // }, + onReadAllDisplayItemByCrawler: (metaCrawler: MetaCrawler) => { + dispatch(asyncRequestActions.request('MetaSensorDisplayItemService', 'readAllByCrawler', + SensorDisplayItemReadAllByCrawlerActions.REQUEST, JSON.stringify(metaCrawler))); }, }; } diff --git a/src/ts/@overflow/meta/react/components/SensorItemTree.tsx b/src/ts/@overflow/meta/react/components/SensorItemTree.tsx index fde23b9..d360381 100644 --- a/src/ts/@overflow/meta/react/components/SensorItemTree.tsx +++ b/src/ts/@overflow/meta/react/components/SensorItemTree.tsx @@ -16,7 +16,7 @@ import { import MetaSensorItemType from '../../api/model/MetaSensorItemType'; import MetaSensorItem from '../../api/model/MetaSensorItem'; -import MetaSensorItemKey from '../../api/model/MetaSensorItemKey'; +import MetaSensorDisplayItem from '../../api/model/MetaSensorDisplayItem'; import MetaCrawler from '../../api/model/MetaCrawler'; import Sensor from '@overflow/sensor/api/model/Sensor'; @@ -27,19 +27,24 @@ import SensorRegistInfo from '@overflow/sensor/api/model/SensorRegistInfo'; export interface SensorItemTreeStateProps { crawlerId?: number; - sensorItemList?: SensorItem[]; - metaSensorItemTypeList?: MetaSensorItemType[]; - metaSensorItemList?: MetaSensorItem[]; - metaSensorItemKeyList?: MetaSensorItemKey[]; + + // sensorItemList?: SensorItem[]; + // metaSensorItemTypeList?: MetaSensorItemType[]; + // metaSensorItemList?: MetaSensorItem[]; + // metaSensorItemKeyList?: MetaSensorItemKey[]; + + sensorDisplayItems?: MetaSensorDisplayItem[]; setSensor?(data: SensorRegistInfo): void; getSensor?(): SensorRegistInfo; } export interface SensorItemTreeDispatchProps { - onReadAllBySensor?(sensor: Sensor): void; - onSensorItemTypeReadAll?(): void; - onReadAll?(): void; - onReadAllSensorItemKeyByCrawler?(metaCrawler: MetaCrawler): void; + // onReadAllBySensor?(sensor: Sensor): void; + // onSensorItemTypeReadAll?(): void; + // onReadAll?(): void; + // onReadAllSensorItemKeyByCrawler?(metaCrawler: MetaCrawler): void; + + onReadAllDisplayItemByCrawler?(metaCrawler: MetaCrawler): void; } @@ -54,7 +59,7 @@ export interface SensorItemTreeState { } interface TreeItem { - metaSensorItemList: Array; + metaSensorDisplayItems: Array; metaSensorItemType: MetaSensorItemType; } @@ -75,25 +80,13 @@ export class SensorItemTree extends React.Component { - // this.state.itemState[key] = new Array(data.metaSensorItemList.length).fill(false); elems.push( - Category - {this.state.categoryState[key] ? this.ViewSensorItem(data.metaSensorItemList, key) : ''} + + {this.state.categoryState[key] ? this.ViewSensorItem(data.metaSensorDisplayItems, key) : ''} , ); @@ -126,24 +118,26 @@ export class SensorItemTree extends React.Component { + metaSensorDisplayItemList.map((item: MetaSensorDisplayItem, idx: number) => { elems.push( - , checkProps: CheckboxProps) => { - this.onItemCheckCBox(parentKey, checkProps, item); - }} /> - Sensor Item + + , checkProps: CheckboxProps) => { + this.onItemCheckCBox(parentKey, checkProps, item); + }} /> + + {this.getItemDesc(item)} , @@ -153,50 +147,39 @@ export class SensorItemTree extends React.Component {this.ViewSensorItemType()} - {/*

*/} ); } private sortItemMap(): void { - if(this.itemMap.size > 0) { + if (this.itemMap.size > 0) { return; } - // for(let si of this.props.metaSensorItemList) { - // let sensorItem: MetaSensorItem = si; + for (let displayItem of this.props.sensorDisplayItems) { - // if (this.itemMap.has(sensorItem.itemType.id)) { - // this.itemMap.get(sensorItem.itemType.id).metaSensorItemList.push(sensorItem); - // } else { - // let item: TreeItem = { metaSensorItemList: null, metaSensorItemType: null }; - // item.metaSensorItemList = []; - // item.metaSensorItemList.push(sensorItem); - // item.metaSensorItemType = this.GetMetaSensorItemType(sensorItem.itemType.id); - // this.itemMap.set(sensorItem.itemType.id, item); - // } - // } - - for(let si of this.props.metaSensorItemKeyList) { - let sensorItem: MetaSensorItem = si.item; - - if (this.itemMap.has(sensorItem.itemType.id)) { - this.itemMap.get(sensorItem.itemType.id).metaSensorItemList.push(sensorItem); + if (this.itemMap.has(displayItem.itemType.id)) { + this.itemMap.get(displayItem.itemType.id).metaSensorDisplayItems.push(displayItem); } else { - let item: TreeItem = { metaSensorItemList: null, metaSensorItemType: null }; - item.metaSensorItemList = []; - item.metaSensorItemList.push(sensorItem); - item.metaSensorItemType = sensorItem.itemType; - this.itemMap.set(sensorItem.itemType.id, item); + let item: TreeItem = { metaSensorDisplayItems: null, metaSensorItemType: null }; + item.metaSensorDisplayItems = []; + item.metaSensorDisplayItems.push(displayItem); + item.metaSensorItemType = displayItem.itemType; + this.itemMap.set(displayItem.itemType.id, item); } } @@ -240,11 +223,11 @@ export class SensorItemTree extends React.Component> = _.clone(this.state.itemState); if (newItemState[key] === undefined) { - newItemState[key] = new Array(data.metaSensorItemList.length).fill(false); + newItemState[key] = new Array(data.metaSensorDisplayItems.length).fill(false); } newItemState[key].fill(checkProps.checked); if (checkProps.checked) { - this.selectedItemMap.set(key, _.clone(data.metaSensorItemList)); + this.selectedItemMap.set(key, _.clone(data.metaSensorDisplayItems)); } else { this.selectedItemMap.get(key).length = 0; } @@ -262,23 +245,6 @@ export class SensorItemTree extends React.Component): + SensorDisplayItemReadAllByCrawlerState => { + return { + ...state, + sensorDisplayItems: action.payload, + }; + }, + [SensorDisplayItemReadAllByCrawlerActions.REQUEST_FAILURE]: + (state: SensorDisplayItemReadAllByCrawlerState = SensorDisplayItemReadAllByCrawlerDefaultState, action: Action): + SensorDisplayItemReadAllByCrawlerState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/meta/redux/state/SensorDisplayItemReadAllByCrawler.ts b/src/ts/@overflow/meta/redux/state/SensorDisplayItemReadAllByCrawler.ts new file mode 100644 index 0000000..85cd842 --- /dev/null +++ b/src/ts/@overflow/meta/redux/state/SensorDisplayItemReadAllByCrawler.ts @@ -0,0 +1,13 @@ +import MetaSensorDisplayItem from '../../api/model/MetaSensorDisplayItem'; + +export interface State { + readonly sensorDisplayItems: MetaSensorDisplayItem[]; + readonly error?: Error; +} + +export const defaultState: State = { + sensorDisplayItems: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/sensor/api/model/SensorItem.ts b/src/ts/@overflow/sensor/api/model/SensorItem.ts index f581c40..e25dc66 100644 --- a/src/ts/@overflow/sensor/api/model/SensorItem.ts +++ b/src/ts/@overflow/sensor/api/model/SensorItem.ts @@ -1,10 +1,10 @@ import Sensor from './Sensor'; -import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem'; +import MetaSensorDisplayItem from '@overflow/meta/api/model/MetaSensorDisplayItem'; interface SensorItem { id?: number; sensor?: Sensor; - item?: MetaSensorItem; + item?: MetaSensorDisplayItem; createDate?: Date; } diff --git a/src/ts/@overflow/sensor/api/model/SensorRegistInfo.ts b/src/ts/@overflow/sensor/api/model/SensorRegistInfo.ts index e3edf75..4081642 100644 --- a/src/ts/@overflow/sensor/api/model/SensorRegistInfo.ts +++ b/src/ts/@overflow/sensor/api/model/SensorRegistInfo.ts @@ -1,10 +1,10 @@ -import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem'; +import MetaSensorDisplayItem from '@overflow/meta/api/model/MetaSensorDisplayItem'; import Infra from '@overflow/infra/api/model/Infra'; import Crawler from '@overflow/meta/api/model/MetaCrawler'; interface SensorRegistInfo { - sensorItemMap: Map>; + sensorItemMap: Map>; crawler: Crawler; // targetId: number; interval: number; diff --git a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx index 4ced862..4199a95 100644 --- a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx @@ -30,7 +30,7 @@ import Page from '@overflow/commons/api/model/Page'; import SensorRegistInfo from '../../api/model/SensorRegistInfo'; import Sensor from '../../api/model/Sensor'; import SensorItem from '../../api/model/SensorItem'; -import MetaSensorItem from '@overflow/meta/api/model/MetaSensorItem'; +import MetaSensorDisplayItem from '@overflow/meta/api/model/MetaSensorDisplayItem'; import SensorItemTree from '@overflow/meta/react/SensorItemTree'; import CrawlerSelectorContainer from '@overflow/meta/react/CrawlerSelector'; @@ -51,6 +51,7 @@ export interface SensorConfigStepperDispatchProps { onMoveTargetSensors?(targetId: number): void; } + export type SensorConfigStepperProps = SensorConfigStepperStateProps & SensorConfigStepperDispatchProps; export interface SensorConfigStepperState { @@ -111,8 +112,6 @@ export class SensorConfigStepper extends React.Component { + this.props.getSensor().sensorItemMap.forEach((value: MetaSensorDisplayItem[], key: number) => { if (value.length > 0) { result = true; } @@ -189,11 +188,12 @@ export class SensorConfigStepper extends React.Component = new Array; - sensorData.sensorItemMap.forEach((value: MetaSensorItem[], key: number) => { + sensorData.sensorItemMap.forEach((value: MetaSensorDisplayItem[], key: number) => { for (let msi of value) { siList.push({ item: { id: msi.id }, @@ -201,9 +201,6 @@ export class SensorConfigStepper extends React.Component -