-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/caldav-disable-sync
- Loading branch information
Showing
35 changed files
with
703 additions
and
216 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
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,75 +1,32 @@ | ||
import { createElement } from 'preact'; | ||
import { DEVICE_FEATURE_TYPES } from '../../../../../server/utils/constants'; | ||
|
||
import BinaryDeviceFeature from './device-features/BinaryDeviceFeature'; | ||
import ColorDeviceFeature from './device-features/ColorDeviceFeature'; | ||
import SensorDeviceFeature from './device-features/SensorDeviceFeature'; | ||
import MultilevelDeviceFeature from './device-features/MultiLevelDeviceFeature'; | ||
import BrightnessDeviceFeature from './device-features/BrightnessDeviceFeature'; | ||
import MultiLevelDeviceFeature from './device-features/MultiLevelDeviceFeature'; | ||
|
||
const ROW_TYPE_BY_FEATURE_TYPE = { | ||
[DEVICE_FEATURE_TYPES.LIGHT.BINARY]: BinaryDeviceFeature, | ||
[DEVICE_FEATURE_TYPES.LIGHT.COLOR]: ColorDeviceFeature, | ||
[DEVICE_FEATURE_TYPES.SWITCH.DIMMER]: MultiLevelDeviceFeature, | ||
[DEVICE_FEATURE_TYPES.LIGHT.BRIGHTNESS]: MultiLevelDeviceFeature | ||
}; | ||
|
||
const DeviceRow = ({ children, ...props }) => { | ||
// if device is a sensor, we display the sensor deviceFeature | ||
if (props.deviceFeature.read_only) { | ||
return <SensorDeviceFeature user={props.user} deviceFeature={props.deviceFeature} />; | ||
} | ||
|
||
// else, it's not a sensor | ||
// if it's a binary | ||
if (props.deviceFeature.type === 'binary') { | ||
return ( | ||
<BinaryDeviceFeature | ||
x={props.x} | ||
y={props.y} | ||
device={props.device} | ||
deviceFeature={props.deviceFeature} | ||
roomIndex={props.roomIndex} | ||
deviceIndex={props.deviceIndex} | ||
deviceFeatureIndex={props.deviceFeatureIndex} | ||
updateValue={props.updateValue} | ||
/> | ||
); | ||
} | ||
if (props.deviceFeature.type === 'color') { | ||
return ( | ||
<ColorDeviceFeature | ||
x={props.x} | ||
y={props.y} | ||
device={props.device} | ||
deviceFeature={props.deviceFeature} | ||
roomIndex={props.roomIndex} | ||
deviceIndex={props.deviceIndex} | ||
deviceFeatureIndex={props.deviceFeatureIndex} | ||
updateValue={props.updateValue} | ||
/> | ||
); | ||
} | ||
if (props.deviceFeature.type === 'dimmer') { | ||
return ( | ||
<MultilevelDeviceFeature | ||
x={props.x} | ||
y={props.y} | ||
device={props.device} | ||
deviceFeature={props.deviceFeature} | ||
roomIndex={props.roomIndex} | ||
deviceIndex={props.deviceIndex} | ||
deviceFeatureIndex={props.deviceFeatureIndex} | ||
updateValue={props.updateValue} | ||
/> | ||
); | ||
} | ||
if (props.deviceFeature.type === 'brightness') { | ||
return ( | ||
<BrightnessDeviceFeature | ||
x={props.x} | ||
y={props.y} | ||
device={props.device} | ||
deviceFeature={props.deviceFeature} | ||
roomIndex={props.roomIndex} | ||
deviceIndex={props.deviceIndex} | ||
deviceFeatureIndex={props.deviceFeatureIndex} | ||
updateValue={props.updateValue} | ||
/> | ||
); | ||
const elementType = ROW_TYPE_BY_FEATURE_TYPE[props.deviceFeature.type]; | ||
|
||
if (!elementType) { | ||
// if no related components, we return nothing | ||
return null; | ||
} | ||
// if not, we return nothing | ||
return null; | ||
|
||
return createElement(elementType, props); | ||
}; | ||
|
||
export default DeviceRow; |
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
43 changes: 0 additions & 43 deletions
43
front/src/components/boxs/device-in-room/device-features/BrightnessDeviceFeature.jsx
This file was deleted.
Oops, something went wrong.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.