fixed router
This commit is contained in:
parent
3a44072e53
commit
4af1a7ace1
|
@ -1,4 +1,6 @@
|
|||
import { connect, Dispatch } from 'react-redux';
|
||||
import { push as routerPush } from 'react-router-redux';
|
||||
|
||||
import {
|
||||
SensorList,
|
||||
StateProps as SensorListStateProps,
|
||||
|
@ -6,6 +8,7 @@ import {
|
|||
} from './components/SensorList';
|
||||
import State from '../redux/state/ReadAllByTarget';
|
||||
|
||||
|
||||
import * as ReadAllByTargetActions from '../redux/action/read_all_by_target';
|
||||
import * as ReadAllByProbeActions from '../redux/action/read_all_by_probe';
|
||||
import * as ReadAllByDomainActions from '../redux/action/read_all_by_domain';
|
||||
|
@ -30,6 +33,9 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): SensorListDispatchP
|
|||
onReadAllByDomain: (domain: Domain) => {
|
||||
dispatch(ReadAllByDomainActions.request(domain));
|
||||
},
|
||||
onSensorSelect: (id: number) => {
|
||||
dispatch(routerPush('/sensor/' + String(id)));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@ export interface DispatchProps {
|
|||
onReadAllByTarget?(target: Target): void;
|
||||
onReadAllByProbe?(probe: Probe): void;
|
||||
onReadAllByDomain?(domain: Domain): void;
|
||||
onSensorSelect?(id: number): void;
|
||||
}
|
||||
|
||||
export type SensorListProps = StateProps & DispatchProps;
|
||||
|
||||
export interface SensorListState {
|
||||
isDetail: boolean;
|
||||
selected: Sensor;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ export class SensorList extends React.Component<SensorListProps, SensorListState
|
|||
super(props, context);
|
||||
this.state = {
|
||||
selected: null,
|
||||
isDetail: false, // temp
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -92,8 +91,9 @@ export class SensorList extends React.Component<SensorListProps, SensorListState
|
|||
public handleSelect(selectedSensor: Sensor): void {
|
||||
this.setState({
|
||||
selected: selectedSensor,
|
||||
isDetail: true,
|
||||
});
|
||||
|
||||
this.props.onSensorSelect(selectedSensor.id);
|
||||
}
|
||||
|
||||
public checkCellStatus(status: any): boolean {
|
||||
|
@ -119,10 +119,6 @@ export class SensorList extends React.Component<SensorListProps, SensorListState
|
|||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
if (this.state.isDetail) {
|
||||
// return (<SensorDetailContainer sensor={this.state.selected} />);
|
||||
return (<SensorDetailContainer />);
|
||||
}
|
||||
return (
|
||||
<Container fluid>
|
||||
<Header as='h3' dividing>Sensors</Header>
|
||||
|
|
Loading…
Reference in New Issue
Block a user