sensor....
This commit is contained in:
parent
9233f75f6f
commit
43681525e1
|
@ -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,
|
||||
|
|
17
src/ts/@overflow/meta/api/model/MetaSensorDisplayItem.ts
Normal file
17
src/ts/@overflow/meta/api/model/MetaSensorDisplayItem.ts
Normal file
|
@ -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;
|
8
src/ts/@overflow/meta/api/model/MetaSensorItemUnit.ts
Normal file
8
src/ts/@overflow/meta/api/model/MetaSensorItemUnit.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export interface MetaSensorItemUnit {
|
||||
id: number;
|
||||
unit: string;
|
||||
createDate: Date;
|
||||
mark: string;
|
||||
}
|
||||
|
||||
export default MetaSensorItemUnit;
|
|
@ -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<any>): 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)));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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<MetaSensorItem>;
|
||||
metaSensorDisplayItems: Array<MetaSensorDisplayItem>;
|
||||
metaSensorItemType: MetaSensorItemType;
|
||||
}
|
||||
|
||||
|
@ -75,25 +80,13 @@ export class SensorItemTree extends React.Component<SensorItemTreeProps, SensorI
|
|||
itemState: new Map(),
|
||||
};
|
||||
|
||||
|
||||
// this.props.onReadAll();
|
||||
// this.props.onSensorItemTypeReadAll();
|
||||
// fs.readFile('../../../../../dh.json', this.handlJSONFile);
|
||||
|
||||
this.props.onReadAllSensorItemKeyByCrawler({id: this.props.crawlerId});
|
||||
this.props.onReadAllDisplayItemByCrawler({ id: this.props.crawlerId });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ViewSensorItemType(): JSX.Element[] {
|
||||
|
||||
// if(this.props.metaSensorItemTypeList === undefined
|
||||
// || this.props.metaSensorItemList === undefined) {
|
||||
// return null;
|
||||
// }
|
||||
if(this.props.metaSensorItemKeyList === undefined) {
|
||||
if (this.props.sensorDisplayItems === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -102,7 +95,6 @@ export class SensorItemTree extends React.Component<SensorItemTreeProps, SensorI
|
|||
let elems: JSX.Element[] = new Array();
|
||||
|
||||
this.itemMap.forEach((data: TreeItem, key: number) => {
|
||||
// this.state.itemState[key] = new Array(data.metaSensorItemList.length).fill(false);
|
||||
elems.push(
|
||||
<List.Item key={key} >
|
||||
<List.Icon name={this.state.categoryState[key] ? 'chevron up' : 'chevron down'}
|
||||
|
@ -114,8 +106,8 @@ export class SensorItemTree extends React.Component<SensorItemTreeProps, SensorI
|
|||
this.onTypeCheckCBox(key, checkProps, data);
|
||||
}} />
|
||||
</List.Header>
|
||||
<List.Description style={{ marginLeft: '26px' }}>Category</List.Description>
|
||||
{this.state.categoryState[key] ? this.ViewSensorItem(data.metaSensorItemList, key) : ''}
|
||||
<List.Description style={{ marginLeft: '26px' }}></List.Description>
|
||||
{this.state.categoryState[key] ? this.ViewSensorItem(data.metaSensorDisplayItems, key) : ''}
|
||||
</List.Content>
|
||||
</List.Item>,
|
||||
);
|
||||
|
@ -126,24 +118,26 @@ export class SensorItemTree extends React.Component<SensorItemTreeProps, SensorI
|
|||
|
||||
|
||||
|
||||
public ViewSensorItem(metaSensorItemList: MetaSensorItem[], parentKey: number): JSX.Element[] {
|
||||
public ViewSensorItem(metaSensorDisplayItemList: MetaSensorDisplayItem[], parentKey: number): JSX.Element[] {
|
||||
let elems: JSX.Element[] = new Array();
|
||||
|
||||
if (this.state.itemState[parentKey] === undefined) {
|
||||
this.state.itemState[parentKey] = new Array(metaSensorItemList.length).fill(false);
|
||||
this.state.itemState[parentKey] = new Array(metaSensorDisplayItemList.length).fill(false);
|
||||
}
|
||||
|
||||
metaSensorItemList.map((item: MetaSensorItem, idx: number) => {
|
||||
metaSensorDisplayItemList.map((item: MetaSensorDisplayItem, idx: number) => {
|
||||
elems.push(
|
||||
<List.List key={String(parentKey) + String(idx)} onClick={this.onItemClick.bind(this, parentKey, idx)}>
|
||||
<List.Item >
|
||||
<List.Icon name='file' />
|
||||
<List.Content>
|
||||
<List.Header> <Checkbox label={item.name} checked={this.state.itemState[parentKey][idx]} onChange={
|
||||
(event: React.FormEvent<HTMLInputElement>, checkProps: CheckboxProps) => {
|
||||
this.onItemCheckCBox(parentKey, checkProps, item);
|
||||
}} /></List.Header>
|
||||
<List.Description style={{ marginLeft: '26px' }}>Sensor Item</List.Description>
|
||||
<List.Header>
|
||||
<Checkbox label={item.displayName} checked={this.state.itemState[parentKey][idx]} onChange={
|
||||
(event: React.FormEvent<HTMLInputElement>, checkProps: CheckboxProps) => {
|
||||
this.onItemCheckCBox(parentKey, checkProps, item);
|
||||
}} />
|
||||
</List.Header>
|
||||
<List.Description style={{ marginLeft: '26px' }}>{this.getItemDesc(item)}</List.Description>
|
||||
</List.Content>
|
||||
</List.Item>
|
||||
</List.List>,
|
||||
|
@ -153,50 +147,39 @@ export class SensorItemTree extends React.Component<SensorItemTreeProps, SensorI
|
|||
return elems;
|
||||
}
|
||||
|
||||
private getItemDesc(item: MetaSensorDisplayItem): string {
|
||||
if(item.default) {
|
||||
return '(Recommend) ' + item.key;
|
||||
}
|
||||
return item.key;
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<Container fluid>
|
||||
<List selection>
|
||||
{this.ViewSensorItemType()}
|
||||
</List>
|
||||
{/*<Button primary floated='right' onClick={() => {
|
||||
console.log(this.selectedItemMap);
|
||||
}}>Test</Button><br /><br />*/}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
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<SensorItemTreeProps, SensorI
|
|||
this.state.categoryCheckState[key] = checkProps.checked;
|
||||
let newItemState: Map<number, Array<boolean>> = _.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<SensorItemTreeProps, SensorI
|
|||
return false;
|
||||
}
|
||||
|
||||
private GetMetaSensorItemType(id: number): MetaSensorItemType {
|
||||
|
||||
for(let sit of this.props.metaSensorItemTypeList) {
|
||||
if(sit.id === id) {
|
||||
return sit;
|
||||
}
|
||||
}
|
||||
|
||||
// for (let i: number = 0; i < SensorTypeJsonData.length; ++i) {
|
||||
// let msit: MetaSensorItemType = SensorTypeJsonData[i];
|
||||
// if (msit.id === id) {
|
||||
// return msit;
|
||||
// }
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default SensorItemTree;
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
// Action Type
|
||||
export type REQUEST = '@overflow/meta_sensor_display_item/read_all_by_crawler/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/meta_sensor_display_item/read_all_by_crawler/REQUEST/SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/meta_sensor_display_item/read_all_by_crawler/REQUEST/FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/meta_sensor_display_item/read_all_by_crawler/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/meta_sensor_display_item/read_all_by_crawler/REQUEST/SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/meta_sensor_display_item/read_all_by_crawler/REQUEST/FAILURE';
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
import Action from '@overflow/commons/redux/Action';
|
||||
import { ReducersMapObject } from 'redux';
|
||||
|
||||
|
||||
import * as SensorDisplayItemReadAllByCrawlerActions from '../action/sensor_display_item_read_all_by_crawler';
|
||||
import SensorDisplayItemReadAllByCrawlerState,
|
||||
{ defaultState as SensorDisplayItemReadAllByCrawlerDefaultState }
|
||||
from '../state/SensorDisplayItemReadAllByCrawler';
|
||||
|
||||
import MetaSensorDisplayItem from '../../api/model/MetaSensorDisplayItem';
|
||||
|
||||
const reducer: ReducersMapObject = {
|
||||
[SensorDisplayItemReadAllByCrawlerActions.REQUEST_SUCCESS]:
|
||||
(state: SensorDisplayItemReadAllByCrawlerState = SensorDisplayItemReadAllByCrawlerDefaultState, action: Action<MetaSensorItemKey[]>):
|
||||
SensorDisplayItemReadAllByCrawlerState => {
|
||||
return {
|
||||
...state,
|
||||
sensorDisplayItems: <MetaSensorDisplayItem[]>action.payload,
|
||||
};
|
||||
},
|
||||
[SensorDisplayItemReadAllByCrawlerActions.REQUEST_FAILURE]:
|
||||
(state: SensorDisplayItemReadAllByCrawlerState = SensorDisplayItemReadAllByCrawlerDefaultState, action: Action<Error>):
|
||||
SensorDisplayItemReadAllByCrawlerState => {
|
||||
return state;
|
||||
},
|
||||
};
|
||||
|
||||
export default reducer;
|
|
@ -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;
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<number, Array<MetaSensorItem>>;
|
||||
sensorItemMap: Map<number, Array<MetaSensorDisplayItem>>;
|
||||
crawler: Crawler;
|
||||
// targetId: number;
|
||||
interval: number;
|
||||
|
|
|
@ -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<SensorConfigStepperProp
|
|||
currentStep: step,
|
||||
});
|
||||
if (step === this.props.steps.length + 1) {
|
||||
console.log('Done');
|
||||
console.log(this.props.getSensor());
|
||||
this.registSensor();
|
||||
if (this.props.infraId === undefined) {
|
||||
this.props.onMoveSensors();
|
||||
|
@ -172,7 +171,7 @@ export class SensorConfigStepper extends React.Component<SensorConfigStepperProp
|
|||
|
||||
let result: boolean = false;
|
||||
|
||||
this.props.getSensor().sensorItemMap.forEach((value: MetaSensorItem[], key: number) => {
|
||||
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<SensorConfigStepperProp
|
|||
sensor.crawler = { id: sensorData.crawler.id };
|
||||
sensor.target = { id: sensorData.infra.target.id };
|
||||
sensor.status = { id: MetaSensorStatus_ID.RUNNING };
|
||||
|
||||
sensor.description = sensorData.infra.infraType.name + '-' + sensorData.crawler.name;
|
||||
|
||||
let siList: Array<SensorItem> = 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<SensorConfigStepperProp
|
|||
}
|
||||
});
|
||||
|
||||
console.log(sensor);
|
||||
console.log(siList);
|
||||
|
||||
let etc: any = { interval: sensorData.interval };
|
||||
|
||||
this.props.onRegistSensorConfig(sensor, siList, etc);
|
||||
|
@ -267,8 +264,8 @@ export class SensorConfigStepper extends React.Component<SensorConfigStepperProp
|
|||
<Button content='Prev' icon='left arrow' labelPosition='left'
|
||||
onClick={this.handlePrev.bind(this)} disabled={this.checkPrevDisabled()} />
|
||||
<Button.Or />
|
||||
<Button content={this.state.currentStep === 3 ? 'Finish' : 'Next'}
|
||||
icon={this.state.currentStep === 3 ? 'send' : 'right arrow'} labelPosition='right' positive
|
||||
<Button content={this.state.currentStep === 4 ? 'Finish' : 'Next'}
|
||||
icon={this.state.currentStep === 4 ? 'send' : 'right arrow'} labelPosition='right' positive
|
||||
onClick={this.handleNext.bind(this)} disabled={this.checkNextDisabled()} />
|
||||
</Button.Group>
|
||||
</Container>
|
||||
|
|
|
@ -81,14 +81,14 @@ export class SensorConfiguration extends React.Component<SensorConfigurationProp
|
|||
}
|
||||
|
||||
public stepNext = () => {
|
||||
this.setState({isTarget:true});
|
||||
this.setState({ isTarget: true });
|
||||
}
|
||||
|
||||
|
||||
public render(): JSX.Element {
|
||||
let steps = [
|
||||
<SensorConfigTargetSelectContainer setSensor={this.setSensor.bind(this)} getSensor={this.getSensor.bind(this)}
|
||||
infraId={this.props.infraId} stepNext={this.stepNext.bind(this)} />,
|
||||
infraId={this.props.infraId} stepNext={this.stepNext.bind(this)} />,
|
||||
<CrawlerSelectorContainer onSelectCrawlerId={this.onSelectCrawlerId.bind(this)}
|
||||
setSensor={this.setSensor.bind(this)} getSensor={this.getSensor.bind(this)} />,
|
||||
<Segment vertical>
|
||||
|
@ -105,9 +105,6 @@ export class SensorConfiguration extends React.Component<SensorConfigurationProp
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export interface ETCSelectorProps {
|
||||
setSensor?(data: SensorRegistInfo): void;
|
||||
getSensor?(): SensorRegistInfo;
|
||||
|
@ -128,7 +125,7 @@ export class ETCSelector extends React.Component<ETCSelectorProps, ETCSelectorSt
|
|||
sd.interval = 5;
|
||||
this.props.setSensor(sd);
|
||||
}
|
||||
public handleIntervalChange = (e: any, { value }: any) => {
|
||||
private handleIntervalChange = (e: any, { value }: any) => {
|
||||
this.setState({ interval: value });
|
||||
|
||||
let sd = this.props.getSensor();
|
||||
|
|
Loading…
Reference in New Issue
Block a user