forked from GladysAssistant/Gladys
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
168 additions
and
2 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
84 changes: 84 additions & 0 deletions
84
front/src/components/boxs/device-in-room/device-features/PilotWireModeDeviceFeature.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,84 @@ | ||
import get from 'get-value'; | ||
import { Text } from 'preact-i18n'; | ||
import cx from 'classnames'; | ||
|
||
import { DeviceFeatureCategoriesIcon } from '../../../../utils/consts'; | ||
import { PILOT_WIRE_MODE } from '../../../../../../server/utils/constants'; | ||
|
||
const PilotWireModeDeviceFeature = ({ children, ...props }) => { | ||
const { deviceFeature } = props; | ||
const { category, type, last_value: lastValue } = deviceFeature; | ||
|
||
function updateValue(value) { | ||
props.updateValueWithDebounce(deviceFeature, value); | ||
} | ||
|
||
function comfort() { | ||
updateValue(PILOT_WIRE_MODE.COMFORT); | ||
} | ||
|
||
function eco() { | ||
updateValue(PILOT_WIRE_MODE.ECO); | ||
} | ||
|
||
function frost_protection() { | ||
updateValue(PILOT_WIRE_MODE.FROST_PROTECTION); | ||
} | ||
|
||
function off() { | ||
updateValue(PILOT_WIRE_MODE.OFF); | ||
} | ||
|
||
return ( | ||
<tr> | ||
<td> | ||
<i class={`fe fe-${get(DeviceFeatureCategoriesIcon, `${category}.${type}`, { default: 'sliders' })}`} /> | ||
</td> | ||
<td>{props.rowName}</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 === PILOT_WIRE_MODE.COMFORT | ||
})} | ||
onClick={comfort} | ||
> | ||
<Text id={`deviceFeatureAction.category.${category}.${type}.comfort`} plural={PILOT_WIRE_MODE.COMFORT} /> | ||
</button> | ||
<button | ||
class={cx('btn btn-sm btn-secondary', { | ||
active: lastValue === PILOT_WIRE_MODE.ECO | ||
})} | ||
onClick={eco} | ||
> | ||
<Text id={`deviceFeatureAction.category.${category}.${type}.eco`} plural={PILOT_WIRE_MODE.ECO} /> | ||
</button> | ||
<button | ||
class={cx('btn btn-sm btn-secondary', { | ||
active: lastValue === PILOT_WIRE_MODE.FROST_PROTECTION | ||
})} | ||
onClick={frost_protection} | ||
> | ||
<Text | ||
id={`deviceFeatureAction.category.${category}.${type}.frost_protection`} | ||
plural={PILOT_WIRE_MODE.FROST_PROTECTION} | ||
/> | ||
</button> | ||
<button | ||
class={cx('btn btn-sm', 'btn-secondary', { | ||
active: lastValue === PILOT_WIRE_MODE.OFF | ||
})} | ||
onClick={off} | ||
> | ||
<Text id={`deviceFeatureAction.category.${category}.${type}.off`} plural={PILOT_WIRE_MODE.OFF} /> | ||
</button> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
); | ||
}; | ||
|
||
export default PilotWireModeDeviceFeature; |
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