#8 Relais ein / ausschalten von Ocotprint aus

- Button Style auf default geändert
- get_api_commands implementiert
This commit is contained in:
David Zingg 2019-11-24 15:29:45 +01:00
parent 4bd7df899c
commit 7a4d53d221
4 changed files with 8 additions and 17 deletions

View File

@ -101,6 +101,13 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
self._logger.info("toggleRelais") self._logger.info("toggleRelais")
self._toggleRelay() self._toggleRelay()
def get_api_commands(self):
return dict(
enableRelais=[],
disableRelais=[],
toggleRelais=[]
)
def on_after_startup(self): def on_after_startup(self):
pass pass

View File

@ -32,20 +32,6 @@
display:none; display:none;
} }
.mystromToggleButton {
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
display: block;
height: 100%;
padding-left: 10px;
padding-right: 10px;
margin-left: 20px;
margin-right: 20px;
font-size: 14px;
font-weight: bold;
color: #fff;
background-color: #eb0000;
}
#touch body #tabs #sidebar_plugin_mystromswitch_wrapper_link a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_mystromswitch_wrapper_link a:before,#touch body #tabs #sidebar_plugin_mystromswitch_wrapper_link2 a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_mystromswitch_wrapper_link2 a:before { #touch body #tabs #sidebar_plugin_mystromswitch_wrapper_link a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_mystromswitch_wrapper_link a:before,#touch body #tabs #sidebar_plugin_mystromswitch_wrapper_link2 a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_mystromswitch_wrapper_link2 a:before {
content: "\f011"; content: "\f011";
} }

View File

@ -9,8 +9,6 @@ $(function() {
self.mystromswitchEnabled = ko.observable(); self.mystromswitchEnabled = ko.observable();
self.mystromswitchPowerValue = document.getElementById("mystromswitchPowerValue") self.mystromswitchPowerValue = document.getElementById("mystromswitchPowerValue")
self.mystromToggleButton = document.getElementById("myStromRelaisToggleButton")
self.onToggleRelayEvent = function(){ self.onToggleRelayEvent = function(){
$.ajax({ $.ajax({
url: API_BASEURL + "plugin/mystromswitch", url: API_BASEURL + "plugin/mystromswitch",
@ -22,7 +20,6 @@ $(function() {
contentType: "application/json; charset=UTF-8" contentType: "application/json; charset=UTF-8"
}) })
} }
self.mystromToggleButton.addEventListener("click",self.onToggleRelayEvent)
self.onmystromswitchEvent = function() { self.onmystromswitchEvent = function() {
if (self.mystromswitchEnabled()) { if (self.mystromswitchEnabled()) {

View File

@ -1,4 +1,5 @@
<div class="sidebar_plugin_mystromswitch"> <div class="sidebar_plugin_mystromswitch">
<label class="control-label" id="mystromswitchPowerValue">Powerconsumption 0.0W</label> <label class="control-label" id="mystromswitchPowerValue">Powerconsumption 0.0W</label>
<span id="myStromRelaisToggleButton" type="button" class="mystromToggleButton">Toggle Relais</span> <span id="myStromRelaisToggleButton" type="button" class="mystromToggleButton">Toggle Relais</span>
<button class="btn btn-primary" data-bind="click: onToggleRelayEvent">{{ _('Go') }}</button>
</div> </div>