-
-
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.
- Loading branch information
Showing
7 changed files
with
219 additions
and
1 deletion.
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
61 changes: 61 additions & 0 deletions
61
front/src/components/boxs/device-in-room/device-features/CoverDeviceFeature.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,61 @@ | ||
import get from 'get-value'; | ||
import { Text } from 'preact-i18n'; | ||
|
||
import { getDeviceName } from './utils'; | ||
import { DeviceFeatureCategoriesIcon } from '../../../../utils/consts'; | ||
import { COVER_STATE } from '../../../../../../server/utils/constants'; | ||
|
||
const UpDownDeviceFeature = ({ 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 open() { | ||
updateValue(COVER_STATE.OPEN); | ||
} | ||
|
||
function close() { | ||
updateValue(COVER_STATE.CLOSE); | ||
} | ||
|
||
function stop() { | ||
updateValue(COVER_STATE.STOP); | ||
} | ||
|
||
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="btn btn-sm btn-secondary" onClick={open}> | ||
<Text id={`deviceFeatureAction.category.${category}.${type}`} plural={COVER_STATE.OPEN} /> | ||
</button> | ||
<button class="btn btn-sm btn-secondary fe fe-pause" onClick={stop} /> | ||
<button class="btn btn-sm btn-secondary" onClick={close}> | ||
<Text id={`deviceFeatureAction.category.${category}.${type}`} plural={COVER_STATE.CLOSE} /> | ||
</button> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
); | ||
}; | ||
|
||
export default UpDownDeviceFeature; |
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