Skip to content

Commit

Permalink
fix GladysAssistant#657 - no page on get device
Browse files Browse the repository at this point in the history
  • Loading branch information
atrovato committed Mar 15, 2020
1 parent d7070bd commit 0a68e7f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 32 deletions.
20 changes: 5 additions & 15 deletions front/src/routes/integration/all/mqtt/device-page/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,19 @@ function createActions(store) {
const houseActions = createActionsHouse(store);
const integrationActions = createActionsIntegration(store);
const actions = {
async getMqttDevices(state, take, skip) {
async getMqttDevices(state) {
store.setState({
getMqttDevicesStatus: RequestStatus.Getting
});
try {
const options = {
service: 'mqtt',
order_dir: state.getMqttDeviceOrderDir || 'asc',
take,
skip
order_dir: state.getMqttDeviceOrderDir || 'asc'
};
if (state.mqttDeviceSearch && state.mqttDeviceSearch.length) {
options.search = state.mqttDeviceSearch;
}
const mqttDevicesReceived = await state.httpClient.get('/api/v1/service/mqtt/device', options);
let mqttDevices;
if (skip === 0) {
mqttDevices = mqttDevicesReceived;
} else {
mqttDevices = update(state.mqttDevices, {
$push: mqttDevicesReceived
});
}
const mqttDevices = await state.httpClient.get('/api/v1/service/mqtt/device', options);
store.setState({
mqttDevices,
getMqttDevicesStatus: RequestStatus.Success
Expand Down Expand Up @@ -77,13 +67,13 @@ function createActions(store) {
store.setState({
mqttDeviceSearch: e.target.value
});
await actions.getMqttDevices(store.getState(), 20, 0);
await actions.getMqttDevices(store.getState());
},
async changeOrderDir(state, e) {
store.setState({
getMqttDeviceOrderDir: e.target.value
});
await actions.getMqttDevices(store.getState(), 20, 0);
await actions.getMqttDevices(store.getState());
},
addDeviceFeature(state, index, category, type) {
const uniqueId = uuid.v4();
Expand Down
2 changes: 1 addition & 1 deletion front/src/routes/integration/all/mqtt/device-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DeviceTab from './DeviceTab';
@connect('session,user,mqttDevices,houses,getMqttDevicesStatus', actions)
class MqttDevicePage extends Component {
componentWillMount() {
this.props.getMqttDevices(20, 0);
this.props.getMqttDevices();
this.props.getHouses();
this.props.getIntegrationByName('mqtt');
}
Expand Down
20 changes: 5 additions & 15 deletions front/src/routes/integration/all/zwave/node-page/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,19 @@ import debounce from 'debounce';
function createActions(store) {
const houseActions = createActionsHouse(store);
const actions = {
async getZWaveDevices(state, take, skip) {
async getZWaveDevices(state) {
store.setState({
getZwaveDevicesStatus: RequestStatus.Getting
});
try {
const options = {
service: 'zwave',
order_dir: state.getZwaveDeviceOrderDir || 'asc',
take,
skip
order_dir: state.getZwaveDeviceOrderDir || 'asc'
};
if (state.zwaveDeviceSearch && state.zwaveDeviceSearch.length) {
options.search = state.zwaveDeviceSearch;
}
const zwaveDevicesReceived = await state.httpClient.get('/api/v1/service/zwave/device', options);
let zwaveDevices;
if (skip === 0) {
zwaveDevices = zwaveDevicesReceived;
} else {
zwaveDevices = update(state.zwaveDevices, {
$push: zwaveDevicesReceived
});
}
const zwaveDevices = await state.httpClient.get('/api/v1/service/zwave/device', options);
store.setState({
zwaveDevices,
getZwaveDevicesStatus: RequestStatus.Success
Expand Down Expand Up @@ -67,13 +57,13 @@ function createActions(store) {
store.setState({
zwaveDeviceSearch: e.target.value
});
await actions.getZWaveDevices(store.getState(), 20, 0);
await actions.getZWaveDevices(store.getState());
},
async changeOrderDir(state, e) {
store.setState({
getZwaveDeviceOrderDir: e.target.value
});
await actions.getZWaveDevices(store.getState(), 20, 0);
await actions.getZWaveDevices(store.getState());
}
};
actions.debouncedSearch = debounce(actions.search, 200);
Expand Down
2 changes: 1 addition & 1 deletion front/src/routes/integration/all/zwave/node-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import integrationConfig from '../../../../../config/integrations';
@connect('session,user,zwaveDevices,houses,getZwaveDevicesStatus', actions)
class ZwaveNodePage extends Component {
componentWillMount() {
this.props.getZWaveDevices(20, 0);
this.props.getZWaveDevices();
this.props.getHouses();
}

Expand Down

0 comments on commit 0a68e7f

Please sign in to comment.