Skip to content

Commit

Permalink
Remove room list in discover tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Nov 27, 2023
1 parent 22cf58a commit 6a188a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 58 deletions.
52 changes: 27 additions & 25 deletions front/src/routes/integration/all/sonos/SonosDeviceBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,31 +138,33 @@ class SonosDeviceBox extends Component {
</Localizer>
</div>

<div class="form-group">
<label class="form-label" for={`room_${deviceIndex}`}>
<Text id="integration.sonos.roomLabel" />
</label>
<select
id={`room_${deviceIndex}`}
onChange={this.updateRoom}
class="form-control"
disabled={!editable || !validModel}
>
<option value="">
<Text id="global.emptySelectOption" />
</option>
{housesWithRooms &&
housesWithRooms.map(house => (
<optgroup label={house.name}>
{house.rooms.map(room => (
<option selected={room.id === device.room_id} value={room.id}>
{room.name}
</option>
))}
</optgroup>
))}
</select>
</div>
{housesWithRooms && (
<div class="form-group">
<label class="form-label" for={`room_${deviceIndex}`}>
<Text id="integration.sonos.roomLabel" />
</label>
<select
id={`room_${deviceIndex}`}
onChange={this.updateRoom}
class="form-control"
disabled={!editable || !validModel}
>
<option value="">
<Text id="global.emptySelectOption" />
</option>
{housesWithRooms &&
housesWithRooms.map(house => (
<optgroup label={house.name}>
{house.rooms.map(room => (
<option selected={room.id === device.room_id} value={room.id}>
{room.name}
</option>
))}
</optgroup>
))}
</select>
</div>
)}

<div class="form-group">
{device.alreadyExist && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,9 @@ import style from './style.css';
import SonosDeviceBox from '../SonosDeviceBox';
import { connect } from 'unistore/preact';
import { Component } from 'preact';
import { RequestStatus } from '../../../../../utils/consts';

class DiscoverTab extends Component {
async componentWillMount() {
this.getDiscoveredDevices();
this.getHouses();
}

async getHouses() {
this.setState({
housesGetStatus: RequestStatus.Getting
});
try {
const params = {
expand: 'rooms'
};
const housesWithRooms = await this.props.httpClient.get(`/api/v1/house`, params);
this.setState({
housesWithRooms,
housesGetStatus: RequestStatus.Success
});
} catch (e) {
this.setState({
housesGetStatus: RequestStatus.Error
});
}
}

async getDiscoveredDevices() {
getDiscoveredDevices = async () => {
this.setState({
loading: true
});
Expand All @@ -58,6 +32,9 @@ class DiscoverTab extends Component {
errorLoading: true
});
}
};
async componentWillMount() {
this.getDiscoveredDevices();
}

render(props, { loading, errorLoading, discoveredDevices, housesWithRooms }) {

Check failure on line 40 in front/src/routes/integration/all/sonos/discover-page/DiscoverTab.jsx

View workflow job for this annotation

GitHub Actions / Front test

'housesWithRooms' is defined but never used
Expand All @@ -68,11 +45,7 @@ class DiscoverTab extends Component {
<Text id="integration.sonos.discover.title" />
</h1>
<div class="page-options d-flex">
<button
onClick={this.getDiscoveredDevices.bind(this)}
class="btn btn-outline-primary ml-2"
disabled={loading}
>
<button onClick={this.getDiscoveredDevices} class="btn btn-outline-primary ml-2" disabled={loading}>
<Text id="integration.sonos.discover.scan" /> <i class="fe fe-radio" />
</button>
</div>
Expand All @@ -96,7 +69,7 @@ class DiscoverTab extends Component {
<div class="row">
{discoveredDevices &&
discoveredDevices.map((device, index) => (
<SonosDeviceBox saveButton device={device} deviceIndex={index} housesWithRooms={housesWithRooms} />
<SonosDeviceBox saveButton device={device} deviceIndex={index} />
))}
{!discoveredDevices || (discoveredDevices.length === 0 && <EmptyState />)}
</div>
Expand Down

0 comments on commit 6a188a0

Please sign in to comment.