fixed problem in scene state
This commit is contained in:
parent
d231ce7e84
commit
2d9bdf63fb
2 changed files with 60 additions and 46 deletions
|
@ -127,52 +127,59 @@ class Device extends React.Component {
|
|||
tab={this.props.tab}
|
||||
/>
|
||||
);
|
||||
case "":
|
||||
return "";
|
||||
default:
|
||||
throw new Error("Device type unknown");
|
||||
//throw new Error("Device type unknown");
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Segment>
|
||||
<Grid columns={2}>
|
||||
<Grid.Column>{this.renderDeviceComponent()}</Grid.Column>
|
||||
{this.props.tab === "Devices" ? (
|
||||
<Grid.Column textAlign="center">
|
||||
<Header as="h3">{this.props.stateOrDevice.name}</Header>
|
||||
<Button
|
||||
color="blue"
|
||||
icon
|
||||
onClick={this.edit}
|
||||
labelPosition="left"
|
||||
>
|
||||
<Icon name="pencil" />
|
||||
Edit
|
||||
</Button>
|
||||
{this.props.stateOrDevice.kind === "smartPlug" ? (
|
||||
<Button
|
||||
color="orange"
|
||||
icon
|
||||
onClick={this.resetSmartPlug}
|
||||
labelPosition="left"
|
||||
>
|
||||
<Icon name="undo" />
|
||||
Reset
|
||||
</Button>
|
||||
) : null}
|
||||
</Grid.Column>
|
||||
) : (
|
||||
<Grid.Column textAlign="center">
|
||||
<Header as="h3">
|
||||
{this.props.stateOrDevice ? this.props.stateOrDevice.name : ""}
|
||||
</Header>
|
||||
</Grid.Column>
|
||||
)}
|
||||
</Grid>
|
||||
</Segment>
|
||||
);
|
||||
{
|
||||
if (this.props.type !== "") {
|
||||
return (
|
||||
<Segment>
|
||||
<Grid columns={2}>
|
||||
<Grid.Column>{this.renderDeviceComponent()}</Grid.Column>
|
||||
{this.props.tab === "Devices" ? (
|
||||
<Grid.Column textAlign="center">
|
||||
<Header as="h3">{this.props.stateOrDevice.name}</Header>
|
||||
<Button
|
||||
color="blue"
|
||||
icon
|
||||
onClick={this.edit}
|
||||
labelPosition="left"
|
||||
>
|
||||
<Icon name="pencil" />
|
||||
Edit
|
||||
</Button>
|
||||
{this.props.stateOrDevice.kind === "smartPlug" ? (
|
||||
<Button
|
||||
color="orange"
|
||||
icon
|
||||
onClick={this.resetSmartPlug}
|
||||
labelPosition="left"
|
||||
>
|
||||
<Icon name="undo" />
|
||||
Reset
|
||||
</Button>
|
||||
) : null}
|
||||
</Grid.Column>
|
||||
) : (
|
||||
<Grid.Column textAlign="center">
|
||||
<Header as="h3">
|
||||
{this.props.stateOrDevice
|
||||
? this.props.stateOrDevice.name
|
||||
: ""}
|
||||
</Header>
|
||||
</Grid.Column>
|
||||
)}
|
||||
</Grid>
|
||||
</Segment>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@ -211,9 +218,14 @@ const mapStateToProps = (state, ownProps) => ({
|
|||
},
|
||||
get type() {
|
||||
if (state.active.activeTab === "Scenes") {
|
||||
const id = state.sceneStates[ownProps.id].deviceId;
|
||||
console.log(id, state.devices[id].kind);
|
||||
return state.devices[id].kind;
|
||||
if (state.sceneStates[ownProps.id]) {
|
||||
console.log(state.sceneStates[ownProps.id], ownProps.id);
|
||||
const id = state.sceneStates[ownProps.id].deviceId;
|
||||
console.log(id, state.devices[id].kind);
|
||||
return state.devices[id].kind;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,9 @@ function reducer(previousState, action) {
|
|||
|
||||
const updateSceneStateProps = (state) => {
|
||||
change.sceneStates[state.id] = {};
|
||||
change.sceneStates[state.id] = { $set: state.id };
|
||||
for (const key in state) {
|
||||
change.sceneStates[state.id][key] = { $set: state[key] };
|
||||
}
|
||||
};
|
||||
|
||||
switch (action.type) {
|
||||
|
@ -104,7 +106,7 @@ function reducer(previousState, action) {
|
|||
}
|
||||
break;
|
||||
case "STATE_UPDATE":
|
||||
console.log(action.sceneStates);
|
||||
//console.log(action.sceneStates);
|
||||
newState = previousState;
|
||||
change = null;
|
||||
|
||||
|
|
Loading…
Reference in a new issue