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.
Dashboard: Add push button feature (GladysAssistant#2165)
- Loading branch information
1 parent
2540927
commit 68cdb6c
Showing
10 changed files
with
76 additions
and
9 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
44 changes: 44 additions & 0 deletions
44
front/src/components/boxs/device-in-room/device-features/PushDeviceFeature.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,44 @@ | ||
import { Component } from 'preact'; | ||
import cx from 'classnames'; | ||
import { Text } from 'preact-i18n'; | ||
import style from './style.css'; | ||
|
||
class PushDeviceComponent extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
loading: false | ||
}; | ||
} | ||
push = async () => { | ||
await this.setState({ loading: true }); | ||
this.props.updateValue(this.props.deviceFeature, 1); | ||
setTimeout(() => { | ||
this.setState({ loading: false }); | ||
}, 350); | ||
}; | ||
|
||
render(props, { loading }) { | ||
return ( | ||
<tr> | ||
<td> | ||
<i class="fe fe-circle" /> | ||
</td> | ||
<td>{props.rowName}</td> | ||
<td class="text-right"> | ||
<button | ||
onClick={this.push} | ||
type="button" | ||
class={cx('btn', 'btn-outline-success', 'btn-sm', style.btnLoading, { | ||
'btn-loading': loading | ||
})} | ||
> | ||
<i class="fe fe-circle" /> <Text id="dashboard.boxes.devicesInRoom.pushButton" /> | ||
</button> | ||
</td> | ||
</tr> | ||
); | ||
} | ||
} | ||
|
||
export default PushDeviceComponent; |
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