-
-
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.
Add Air Conditioning device category (#1718)
- Loading branch information
Showing
9 changed files
with
179 additions
and
6 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
79 changes: 79 additions & 0 deletions
79
...t/src/components/boxs/device-in-room/device-features/AirConditioningModeDeviceFeature.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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import get from 'get-value'; | ||
import { Text } from 'preact-i18n'; | ||
import cx from 'classnames'; | ||
|
||
import { getDeviceName } from '../../../../utils/device'; | ||
import { DeviceFeatureCategoriesIcon } from '../../../../utils/consts'; | ||
import { AC_MODE } from '../../../../../../server/utils/constants'; | ||
|
||
const AirConditioningModeDeviceFeature = ({ children, ...props }) => { | ||
const { device, deviceFeature } = props; | ||
const { category, type, last_value: lastValue } = deviceFeature; | ||
|
||
function updateValue(value) { | ||
props.updateValueWithDebounce( | ||
props.x, | ||
props.y, | ||
device, | ||
deviceFeature, | ||
props.deviceIndex, | ||
props.deviceFeatureIndex, | ||
value, | ||
lastValue | ||
); | ||
} | ||
|
||
function auto() { | ||
updateValue(AC_MODE.AUTO); | ||
} | ||
|
||
function cooling() { | ||
updateValue(AC_MODE.COOLING); | ||
} | ||
|
||
function heating() { | ||
updateValue(AC_MODE.HEATING); | ||
} | ||
|
||
return ( | ||
<tr> | ||
<td> | ||
<i class={`fe fe-${get(DeviceFeatureCategoriesIcon, `${category}.${type}`, { default: 'sliders' })}`} /> | ||
</td> | ||
<td>{getDeviceName(device, deviceFeature)}</td> | ||
|
||
<td class="py-0"> | ||
<div class="d-flex justify-content-end"> | ||
<div class="btn-group" role="group"> | ||
<button | ||
class={cx('btn btn-sm btn-secondary', { | ||
active: lastValue === AC_MODE.AUTO | ||
})} | ||
onClick={auto} | ||
> | ||
<Text id={`deviceFeatureAction.category.${category}.${type}.auto`} plural={AC_MODE.HEATING} /> | ||
</button> | ||
<button | ||
class={cx('btn btn-sm btn-secondary', { | ||
active: lastValue === AC_MODE.COOLING | ||
})} | ||
onClick={cooling} | ||
> | ||
<Text id={`deviceFeatureAction.category.${category}.${type}.cooling`} plural={AC_MODE.HEATING} /> | ||
</button> | ||
<button | ||
class={cx('btn btn-sm', 'btn-secondary', { | ||
active: lastValue === AC_MODE.HEATING | ||
})} | ||
onClick={heating} | ||
> | ||
<Text id={`deviceFeatureAction.category.${category}.${type}.heating`} plural={AC_MODE.HEATING} /> | ||
</button> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
); | ||
}; | ||
|
||
export default AirConditioningModeDeviceFeature; |
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