Skip to content

Commit

Permalink
Merge pull request #16 from bradcfisher/Issue13
Browse files Browse the repository at this point in the history
0.1.3 release
  • Loading branch information
bradcfisher authored Nov 29, 2018
2 parents 176e12c + 60f514a commit b0aed7a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

## [0.1.3] - 2018-11-28

### Fixed
- Issue with Octoprint 1.3.10rc1 or newer which prevented Gcode viewer event hooks from being registered
Resolves [#15](https://github.com/bradcfisher/OctoPrint-ExcludeRegionPlugin/issues/15)

## [0.1.2] - 2018-08-05

### Fixed
Expand Down
40 changes: 27 additions & 13 deletions octoprint_excluderegion/static/js/excluderegion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$(function() {

// TODO: If isActivePrintJob state changes while editing, the edit should be cancelled (notification to user when this happens?).
// TODO: If isActivePrintJob state changes to printing while editing, the edit should be cancelled (notification to user when this happens?).

var INSIDE = 1;
var TOP = 2;
Expand Down Expand Up @@ -799,14 +799,6 @@ $(function() {
}
}

self.onStartupComplete = function() {
addCanvasOverlays();
retrieveExcludeRegions();
if (self.loginState.loggedIn()) {
addExcludeButtons();
}
}

self.onServerReconnect = function() {
retrieveExcludeRegions();
}
Expand Down Expand Up @@ -952,9 +944,28 @@ $(function() {
return pt.matrixTransform(overlayXform.inverse());
}

var pollFn = function() {
if (!GCODE || !GCODE.renderer || !GCODE.renderer.hijacked_by_exclude_region) {
setTimeout(pollFn, 10);
var startupComplete = false;
var gcodeViewerPollingComplete = false;

self.onStartupComplete = function() {
addCanvasOverlays();
retrieveExcludeRegions();

startupComplete = true;
initializeControlsIfReady();
}

function initializeControlsIfReady() {
if (startupComplete && gcodeViewerPollingComplete) {
if (self.loginState.loggedIn()) {
addExcludeButtons();
}
}
}

var gcodeViewerPollFn = function() {
if (!GCODE || !GCODE.renderer || !GCODE.renderer.getOptions().hasOwnProperty('onViewportChange')) {
setTimeout(gcodeViewerPollFn, 10);
return;
}

Expand Down Expand Up @@ -992,8 +1003,11 @@ $(function() {
console.log("GCODE refresh failed:", e);
}
});

gcodeViewerPollingComplete = true;
initializeControlsIfReady();
};
setTimeout(pollFn, 10);
gcodeViewerPollFn();
}

OCTOPRINT_VIEWMODELS.push({
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 = "OctoPrint-ExcludeRegionPlugin"

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

# 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 b0aed7a

Please sign in to comment.