Skip to content

Commit

Permalink
fixed #4 UI refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
OllisGit committed May 24, 2019
1 parent b6d2823 commit 44567af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 11 additions & 0 deletions octoprint_DryRun/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding=utf-8
from __future__ import absolute_import
from octoprint.server import user_permission
from octoprint.events import eventManager, Events

import octoprint.plugin
from flask import make_response
Expand All @@ -10,6 +11,7 @@
class DryrunPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.EventHandlerPlugin,
octoprint.plugin.SimpleApiPlugin):

# var
Expand All @@ -35,6 +37,15 @@ def on_gcode_queuing(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **
# Send the original unaltered command
return None


def on_event(self, event, payload):
if event == Events.CLIENT_OPENED:
# Send initial values to the frontend
self._plugin_manager.send_plugin_message(self._identifier,
dict(dryRunEnabled=self.dryRunEnabled)
)


## Web-UI - Stuff
# list all called commands/parameter that are valid to send from the web-ui
def get_api_commands(self):
Expand Down
8 changes: 2 additions & 6 deletions octoprint_DryRun/static/js/DryRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,18 @@ $(function() {
}) ;
});


// receive data from backend
self.onDataUpdaterPluginMessage = function(plugin, data) {
if (plugin != PLUGIN_ID) {
return;
}
alert("Data from backend!!!" +JSON.stringify(data));
//alert("Data from backend!!!" +JSON.stringify(data));
if (data.dryRunEnabled != undefined){
dryRunCheckBox.attr('checked', data.dryRunEnabled);
dryRunCheckBoxPicker.prop('checked', data.dryRunEnabled);
}
}

});
// TODO not needed any more -> cleanup
//$("#excludeExpressionsTextArea").numberedtextarea();
//$("#excludeExpressions").autogrow({vertical: false, horizontal: false});
}

/* view model class, parameters for constructor, container to bind to
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "DryRun"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.1.0"
plugin_version = "1.1.1"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 44567af

Please sign in to comment.