diff --git a/src/ts/@overflow/sensor/react/SensorList.tsx b/src/ts/@overflow/sensor/react/SensorList.tsx index f2fa2e0..be83567 100644 --- a/src/ts/@overflow/sensor/react/SensorList.tsx +++ b/src/ts/@overflow/sensor/react/SensorList.tsx @@ -17,21 +17,24 @@ import Sensor from '@overflow/sensor/api/model/Sensor'; import Probe from '@overflow/probe/api/model/Probe'; import Domain from '@overflow/domain/api/model/Domain'; +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; + export function mapStateToProps(state: any): SensorListStateProps { return { + sensorList:state.SensorList, }; } export function mapDispatchToProps(dispatch: Dispatch): SensorListDispatchProps { return { onReadAllByTarget: (target: Target) => { - dispatch(ReadAllByTargetActions.request(target)); + dispatch(asyncRequestActions.request('SensorService', 'readAllByTarget', ReadAllByTargetActions.REQUEST, JSON.stringify(target))); }, onReadAllByProbe: (probe: Probe) => { dispatch(ReadAllByProbeActions.request(probe)); }, onReadAllByDomain: (domain: Domain) => { - dispatch(ReadAllByDomainActions.request(domain)); + dispatch(asyncRequestActions.request('SensorService', 'readAllByDomain', ReadAllByDomainActions.REQUEST, domain)); }, onSelectSensor: (id: number) => { dispatch(routerPush('/sensor/' + String(id))); diff --git a/src/ts/@overflow/sensor/react/components/SensorList.tsx b/src/ts/@overflow/sensor/react/components/SensorList.tsx index 8175739..8c6f8c3 100644 --- a/src/ts/@overflow/sensor/react/components/SensorList.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorList.tsx @@ -10,6 +10,7 @@ import Domain from '@overflow/domain/api/model/Domain'; export interface StateProps { probe?: Probe; target?: Target; + sensorList?: Sensor[]; } export interface DispatchProps { @@ -29,64 +30,71 @@ export interface SensorListState { export class SensorList extends React.Component { - private data: any; + // private data: any; constructor(props: SensorListProps, context: SensorListState) { super(props, context); this.state = { selected: null, }; + + let target: Target = { + id:1, + }; + + this.props.onReadAllByTarget(target); } public componentWillMount(): void { // super.componentWillMount(); - this.data = [ - { - 'id': '111', - 'metaSensorStatus': { - 'name': 'NORMAL', - }, - 'target': { - 'id': '1', - }, - 'metaCrawler': { - 'name': 'WMI', - 'description': 'WMI description', - }, - 'crawlerInputItems': 'json value', - 'description': 'description1111111111', - }, - { - 'id': '222', - 'metaSensorStatus': { - 'name': 'NORMAL', - }, - 'target': { - 'id': '1', - }, - 'metaCrawler': { - 'name': 'SNMP', - 'description': 'SNMP description', - }, - 'crawlerInputItems': 'json value', - 'description': 'description1111111111', - }, - { - 'id': '333', - 'metaSensorStatus': { - 'name': 'NORMAL', - }, - 'target': { - 'id': '1', - }, - 'metaCrawler': { - 'name': 'JMX', - 'description': 'JMX description', - }, - 'crawlerInputItems': 'json value', - 'description': 'description1111111111', - }, - ]; + + // this.data = [ + // { + // 'id': '111', + // 'metaSensorStatus': { + // 'name': 'NORMAL', + // }, + // 'target': { + // 'id': '1', + // }, + // 'metaCrawler': { + // 'name': 'WMI', + // 'description': 'WMI description', + // }, + // 'crawlerInputItems': 'json value', + // 'description': 'description1111111111', + // }, + // { + // 'id': '222', + // 'metaSensorStatus': { + // 'name': 'NORMAL', + // }, + // 'target': { + // 'id': '1', + // }, + // 'metaCrawler': { + // 'name': 'SNMP', + // 'description': 'SNMP description', + // }, + // 'crawlerInputItems': 'json value', + // 'description': 'description1111111111', + // }, + // { + // 'id': '333', + // 'metaSensorStatus': { + // 'name': 'NORMAL', + // }, + // 'target': { + // 'id': '1', + // }, + // 'metaCrawler': { + // 'name': 'JMX', + // 'description': 'JMX description', + // }, + // 'crawlerInputItems': 'json value', + // 'description': 'description1111111111', + // }, + // ]; } public handleSelect(selectedSensor: Sensor): void { @@ -135,18 +143,18 @@ export class SensorList extends React.Component - {this.data.map((sensor: any, index: number) => ( + {this.props.sensorList ? this.props.sensorList.map((sensor: Sensor, index: number) => ( {index + 1} - - {sensor.metaSensorStatus.name} + + {sensor.status.name} -
{sensor.metaCrawler.name}
+
{sensor.crawler.name}
{sensor.description} to do {/* {this.showStartStopBtn(sensor.metaSensorStatus)} */}
- ))} + )) : ''}