Disable "Slice" button when printing and local slicer is selected
Solves #1631
This commit is contained in:
parent
3a984d41ff
commit
aab98a7c9f
3 changed files with 47 additions and 3 deletions
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,6 +16,13 @@
|
|||
<select data-bind="options: matchingSlicers, optionsText: 'name', optionsValue: 'key', optionsCaption: '{{ _('Select a slicer...') }}', value: slicer, valueAllowUnset: true"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Runs locally') }}</label>
|
||||
<div class="controls">
|
||||
<strong data-bind="text: slicerSameDevice() ? gettext('Yes') : gettext('No')"></strong>
|
||||
<span class="help-block"><small>{{ _('For performance reasons locally run slicers are disabled while printing') }}</small></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Slicing Profile') }}</label>
|
||||
<div class="controls">
|
||||
|
|
@ -48,6 +55,6 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Cancel') }}</a>
|
||||
<a href="#" class="btn btn-primary" data-bind="click: function() { if ($root.enableSliceButton()) { $root.slice() } }, enabled: enableSliceButton, css: {disabled: !$root.enableSliceButton()}">{{ _('Slice') }}</a>
|
||||
<a href="#" class="btn btn-primary" data-bind="click: function() { if ($root.enableSliceButton()) { $root.slice() } }, enabled: enableSliceButton, css: {disabled: !$root.enableSliceButton()}, attr: {title: $root.sliceButtonTooltip}">{{ _('Slice') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue