-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Philips Hue: Do n-Upnp scan + Upnp scan + manual add of bridge (#1920)
- Loading branch information
Showing
14 changed files
with
252 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
228 changes: 134 additions & 94 deletions
228
front/src/routes/integration/all/philips-hue/setup-page/SetupTab.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,166 @@ | ||
import { MarkupText, Text } from 'preact-i18n'; | ||
import { Component } from 'preact'; | ||
import { MarkupText, Text, Localizer } from 'preact-i18n'; | ||
import cx from 'classnames'; | ||
import { RequestStatus } from '../../../../../utils/consts'; | ||
import style from './style.css'; | ||
|
||
const disconnectBridge = (props, device, index) => () => { | ||
props.deleteDevice(device, index); | ||
}; | ||
class SetupTab extends Component { | ||
disconnectBridge = (props, device, index) => () => { | ||
props.deleteDevice(device, index); | ||
}; | ||
|
||
const connectBridge = (props, device) => () => { | ||
props.connectBridge(device); | ||
}; | ||
connectBridge = (props, device) => () => { | ||
props.connectBridge(device); | ||
}; | ||
|
||
const SetupTab = ({ children, ...props }) => { | ||
return ( | ||
<div> | ||
{props.philipsHueBridgesDevices && props.philipsHueBridgesDevices.length > 0 && ( | ||
setmanualBridgeConfiguration = ipaddress => { | ||
this.setState({ manualBridgeConfiguration: { ipaddress: ipaddress.target.value } }); | ||
}; | ||
|
||
render(props) { | ||
return ( | ||
<div> | ||
{props.philipsHueBridgesDevices && props.philipsHueBridgesDevices.length > 0 && ( | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title"> | ||
<Text id="integration.philipsHue.setup.connectedBridgesTitle" /> | ||
</h3> | ||
</div> | ||
<div class="card-body"> | ||
<div | ||
class={cx('dimmer', { | ||
active: props.philipsHueGetDevicesStatus === RequestStatus.Getting | ||
})} | ||
> | ||
<div class="loader" /> | ||
<div class="dimmer-content"> | ||
{props.philipsHueDeleteDeviceStatus === RequestStatus.Error && ( | ||
<p class="alert alert-danger"> | ||
<MarkupText id="integration.philipsHue.setup.unknownError" /> | ||
</p> | ||
)} | ||
{props.philipsHueGetDevicesStatus === RequestStatus.Getting && <div class={style.emptyDiv} />} | ||
<div class="row"> | ||
{props.philipsHueBridgesDevices && | ||
props.philipsHueBridgesDevices.map((bridge, index) => ( | ||
<div class="col-md-4"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title">{bridge.name}</h3> | ||
</div> | ||
<div class="card-body"> | ||
<button class="btn btn-danger" onClick={this.disconnectBridge(props, bridge, index)}> | ||
<Text id="integration.philipsHue.setup.disconnectButton" /> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title"> | ||
<Text id="integration.philipsHue.setup.connectedBridgesTitle" /> | ||
<Text id="integration.philipsHue.setup.bridgesOnNetwork" /> | ||
</h3> | ||
<div class="page-options d-flex"> | ||
<button | ||
class="btn btn-info" | ||
onClick={props.getBridges} | ||
disabled={props.philipsHueGetBridgesStatus === RequestStatus.Getting} | ||
> | ||
<i class="fe fe-radio" /> <Text id="integration.philipsHue.setup.scanButton" /> | ||
</button> | ||
</div> | ||
</div> | ||
<div class="card-body"> | ||
<div | ||
class={cx('dimmer', { | ||
active: props.philipsHueGetDevicesStatus === RequestStatus.Getting | ||
active: | ||
props.philipsHueGetBridgesStatus === RequestStatus.Getting || | ||
props.philipsHueCreateDeviceStatus === RequestStatus.Getting | ||
})} | ||
> | ||
<div class="loader" /> | ||
<div class="dimmer-content"> | ||
{props.philipsHueDeleteDeviceStatus === RequestStatus.Error && ( | ||
<p class="alert alert-danger"> | ||
<MarkupText id="integration.philipsHue.setup.unknownError" /> | ||
</p> | ||
)} | ||
{props.philipsHueGetDevicesStatus === RequestStatus.Getting && <div class={style.emptyDiv} />} | ||
<div class="row"> | ||
{props.philipsHueBridgesDevices && | ||
props.philipsHueBridgesDevices.map((bridge, index) => ( | ||
<div class="col-md-4"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title">{bridge.name}</h3> | ||
{props.philipsHueGetBridgesStatus === RequestStatus.Getting && <div class={style.emptyDiv} />} | ||
{props.philipsHueBridges && props.philipsHueBridges.length === 0 && ( | ||
<div class="col-md-12"> | ||
<div class="alert alert-info"> | ||
<Text id="integration.philipsHue.setup.noBridgesFound" /> | ||
</div> | ||
<div class="col-md-6"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title"> | ||
<Text id="integration.philipsHue.setup.manualConfiguration.title" /> | ||
</h3> | ||
</div> | ||
<div class="card-body"> | ||
<div class="form-group"> | ||
<Text id="integration.philipsHue.setup.manualConfiguration.text" /> | ||
</div> | ||
<div class="form-group"> | ||
<Localizer> | ||
<input | ||
id="manualConfiguration" | ||
type="text" | ||
class="form-control" | ||
onChange={this.setmanualBridgeConfiguration} | ||
placeholder={<Text id="integration.philipsHue.setup.manualConfiguration.input" />} | ||
/> | ||
</Localizer> | ||
</div> | ||
<div class="card-body"> | ||
<button class="btn btn-danger" onClick={disconnectBridge(props, bridge, index)}> | ||
<Text id="integration.philipsHue.setup.disconnectButton" /> | ||
<div class="form-group"> | ||
<button | ||
class="btn btn-success" | ||
onClick={this.connectBridge(props, this.state.manualBridgeConfiguration)} | ||
> | ||
<Text id="integration.philipsHue.setup.connectButton" /> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title"> | ||
<Text id="integration.philipsHue.setup.bridgesOnNetwork" /> | ||
</h3> | ||
<div class="page-options d-flex"> | ||
<button | ||
class="btn btn-info" | ||
onClick={props.getBridges} | ||
disabled={props.philipsHueGetBridgesStatus === RequestStatus.Getting} | ||
> | ||
<i class="fe fe-radio" /> <Text id="integration.philipsHue.setup.scanButton" /> | ||
</button> | ||
</div> | ||
</div> | ||
<div class="card-body"> | ||
<div | ||
class={cx('dimmer', { | ||
active: | ||
props.philipsHueGetBridgesStatus === RequestStatus.Getting || | ||
props.philipsHueCreateDeviceStatus === RequestStatus.Getting | ||
})} | ||
> | ||
<div class="loader" /> | ||
<div class="dimmer-content"> | ||
{props.philipsHueGetBridgesStatus === RequestStatus.Getting && <div class={style.emptyDiv} />} | ||
{props.philipsHueBridges && props.philipsHueBridges.length === 0 && ( | ||
<div class="col-md-12"> | ||
<div class="alert alert-info"> | ||
<Text id="integration.philipsHue.setup.noBridgesFound" /> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
{props.philipsHueCreateDeviceStatus === RequestStatus.PhilipsHueBridgeButtonNotPressed && ( | ||
<p class="alert alert-danger"> | ||
<Text id="integration.philipsHue.setup.bridgeButtonNotPressed" /> | ||
</p> | ||
)} | ||
{props.philipsHueCreateDeviceStatus === RequestStatus.Error && ( | ||
<p class="alert alert-danger"> | ||
<MarkupText id="integration.philipsHue.setup.unknownError" /> | ||
</p> | ||
)} | ||
{props.philipsHueBridges && | ||
props.philipsHueBridges.map(bridge => ( | ||
<div class="col-md-4"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title">{bridge.name}</h3> | ||
</div> | ||
<div class="card-body"> | ||
<button class="btn btn-success" onClick={connectBridge(props, bridge)}> | ||
<Text id="integration.philipsHue.setup.connectButton" /> | ||
</button> | ||
)} | ||
{props.philipsHueCreateDeviceStatus === RequestStatus.PhilipsHueBridgeButtonNotPressed && ( | ||
<p class="alert alert-danger"> | ||
<Text id="integration.philipsHue.setup.bridgeButtonNotPressed" /> | ||
</p> | ||
)} | ||
{props.philipsHueCreateDeviceStatus === RequestStatus.Error && ( | ||
<p class="alert alert-danger"> | ||
<MarkupText id="integration.philipsHue.setup.unknownError" /> | ||
</p> | ||
)} | ||
{props.philipsHueBridges && | ||
props.philipsHueBridges.map(bridge => ( | ||
<div class="col-md-4"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title">{bridge.name}</h3> | ||
</div> | ||
<div class="card-body"> | ||
<button class="btn btn-success" onClick={this.connectBridge(props, bridge)}> | ||
<Text id="integration.philipsHue.setup.connectButton" /> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
))} | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
); | ||
} | ||
} | ||
|
||
export default SetupTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.