diff --git a/src/octoprint/server/api/slicing.py b/src/octoprint/server/api/slicing.py index 824faf02..3427bb3b 100644 --- a/src/octoprint/server/api/slicing.py +++ b/src/octoprint/server/api/slicing.py @@ -43,6 +43,8 @@ def _etag(configured, lm=None): else: hash.update(repr(sorted(slicingManager.registered_slicers))) + hash.update("v2") # increment version if we change the API format + return hash.hexdigest() diff --git a/src/octoprint/static/js/app/viewmodels/slicing.js b/src/octoprint/static/js/app/viewmodels/slicing.js index ae98bed7..d2d47098 100644 --- a/src/octoprint/static/js/app/viewmodels/slicing.js +++ b/src/octoprint/static/js/app/viewmodels/slicing.js @@ -4,6 +4,7 @@ $(function() { self.loginState = parameters[0]; self.printerProfiles = parameters[1]; + self.printerState = parameters[2]; self.file = ko.observable(undefined); self.target = undefined; @@ -23,6 +24,8 @@ $(function() { self.profiles = ko.observableArray(); self.printerProfile = ko.observable(); + self.slicerSameDevice = ko.observable(); + self.allViewModels = undefined; self.slicersForFile = function(file) { @@ -73,6 +76,19 @@ $(function() { self.profile(undefined); }; + self.metadataForSlicer = function(key) { + if (key == undefined || !self.data.hasOwnProperty(key)) { + return; + } + + var slicer = self.data[key]; + self.slicerSameDevice(slicer.sameDevice); + }; + + self.resetMetadata = function() { + self.slicerSameDevice(true); + }; + self.configuredSlicers = ko.pureComputed(function() { return _.filter(self.slicers(), function(slicer) { return slicer.configured; @@ -136,8 +152,10 @@ $(function() { self.slicer.subscribe(function(newValue) { if (newValue === undefined) { self.resetProfiles(); + self.resetMetadata(); } else { self.profilesForSlicer(newValue); + self.metadataForSlicer(newValue); } }); @@ -153,7 +171,20 @@ $(function() { return self.destinationFilename() != undefined && self.destinationFilename().trim() != "" && self.slicer() != undefined - && self.profile() != undefined; + && self.profile() != undefined + && (!(self.printerState.isPrinting() || self.printerState.isPaused()) || !self.slicerSameDevice()); + }); + + self.sliceButtonTooltip = ko.pureComputed(function() { + if (!self.enableSliceButton()) { + if ((self.printerState.isPrinting() || self.printerState.isPaused()) && self.slicerSameDevice()) { + return gettext("Cannot slice on the same device while printing"); + } else { + return gettext("Cannot slice, not all parameters specified"); + } + } else { + return gettext("Start the slicing process"); + } }); self.requestData = function() { @@ -218,6 +249,10 @@ $(function() { }; self.slice = function() { + if (!self.enableSliceButton()) { + return; + } + var destinationFilename = self._sanitize(self.destinationFilename()); var destinationExtensions = self.data[self.slicer()] && self.data[self.slicer()].extensions && self.data[self.slicer()].extensions.destination @@ -275,7 +310,7 @@ $(function() { OCTOPRINT_VIEWMODELS.push([ SlicingViewModel, - ["loginStateViewModel", "printerProfilesViewModel"], + ["loginStateViewModel", "printerProfilesViewModel", "printerStateViewModel"], "#slicing_configuration_dialog" ]); }); diff --git a/src/octoprint/templates/dialogs/slicing.jinja2 b/src/octoprint/templates/dialogs/slicing.jinja2 index 51021027..2d1f9ec6 100644 --- a/src/octoprint/templates/dialogs/slicing.jinja2 +++ b/src/octoprint/templates/dialogs/slicing.jinja2 @@ -16,6 +16,13 @@ +
+ +
+ + {{ _('For performance reasons locally run slicers are disabled while printing') }} +
+
@@ -48,6 +55,6 @@