fix apply scene

This commit is contained in:
britea 2020-05-08 14:55:26 +02:00
parent d1cd93afe5
commit 4688995d12
4 changed files with 15 additions and 5 deletions

View file

@ -53,9 +53,11 @@ class HostsPanel extends Component {
{scene.name} <Icon name={scene.icon} /> {scene.name} <Icon name={scene.icon} />
</Header> </Header>
</Card.Header> </Card.Header>
<Card.Content extras> <Card.Content extras={true}>
<div className="ui two buttons"> <div className="ui two buttons">
<Button onClick={this.applyHostScene(scene.id)}>Apply</Button> <Button onClick={() => this.applyHostScene(scene.id)}>
Apply
</Button>
</div> </div>
</Card.Content> </Card.Content>
</Card> </Card>

View file

@ -70,11 +70,12 @@ class Videocam extends Component {
/> />
</Grid.Column> </Grid.Column>
</Grid.Row> </Grid.Row>
<Grid.Row textAlign="center"> <Grid.Row>
<Grid.Column> <Grid.Column>
<Checkbox <Checkbox
checked={this.props.stateOrDevice.on} checked={this.props.stateOrDevice.on}
toggle toggle
label="Turn on/off"
onChange={(e, val) => this.setOnOff(val.checked)} onChange={(e, val) => this.setOnOff(val.checked)}
/> />
</Grid.Column> </Grid.Column>

View file

@ -557,7 +557,13 @@ export const RemoteService = {
} }
return Endpoint.post(url) return Endpoint.post(url)
.then((res) => dispatch(actions.deviceOperationUpdate(res.data))) .then((res) =>
dispatch(
hostId
? actions.hostDevicesUpdate(hostId, res.data, true)
: actions.deviceOperationUpdate(res.data)
)
)
.catch((err) => { .catch((err) => {
console.warn("scene apply error", err); console.warn("scene apply error", err);
throw new RemoteError(["Network error"]); throw new RemoteError(["Network error"]);

View file

@ -63,9 +63,10 @@ const actions = {
devices, devices,
partial, partial,
}), }),
hostDevicesUpdate: (hostId, devices) => ({ hostDevicesUpdate: (hostId, devices, partial = false) => ({
type: "HOST_DEVICES_UPDATE", type: "HOST_DEVICES_UPDATE",
hostId, hostId,
partial,
devices, devices,
}), }),
stateDelete: (stateId) => ({ stateDelete: (stateId) => ({