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