Added possibility to say to select or directly a file right after slicing it finished, both to the API and the UI

This commit is contained in:
Gina Häußge 2014-12-04 18:06:35 +01:00
parent 5784ab82ef
commit aba8a57fa5
3 changed files with 16 additions and 11 deletions

View file

@ -353,7 +353,7 @@ def gcodeFileCommand(filename, target):
select_after_slicing = True
print_after_slicing = False
if "print" in data.keys() and data["select"] in valid_boolean_trues:
if "print" in data.keys() and data["print"] in valid_boolean_trues:
if not printer.isOperational():
return make_response("Printer is not operational, cannot directly start printing", 409)
select_after_slicing = print_after_slicing = True
@ -374,8 +374,6 @@ def gcodeFileCommand(filename, target):
printer.selectFile(filenameToSelect, sd, print_after_slicing)
ok, result = fileManager.slice(slicer, target, filename, target, gcode_name,
printer_after_slicing=print_after_slicing,
select_after_slicing=select_after_slicing,
profile=profile,
printer_profile_id=printerProfile,
position=position,

View file

@ -20,12 +20,20 @@ function SlicingViewModel(loginStateViewModel, printerProfilesViewModel) {
self.profiles = ko.observableArray();
self.printerProfile = ko.observable();
self.afterSlicingOptions = [
{"value": "none", "text": gettext("Do nothing")},
{"value": "select", "text": gettext("Select for printing")},
{"value": "print", "text": gettext("Start printing")}
];
self.afterSlicing = ko.observable("none");
self.show = function(target, file) {
self.target = target;
self.file = file;
self.title(_.sprintf(gettext("Slicing %(filename)s"), {filename: self.file}));
self.gcodeFilename(self.file.substr(0, self.file.lastIndexOf(".")));
self.printerProfile(self.printerProfiles.currentProfile());
self.afterSlicing("none");
$("#slicing_configuration_dialog").modal("show");
};
@ -127,6 +135,12 @@ function SlicingViewModel(loginStateViewModel, printerProfilesViewModel) {
gcode: gcodeFilename
};
if (self.afterSlicing() == "print") {
data["print"] = true;
} else if (self.afterSlicing() == "select") {
data["select"] = true;
}
$.ajax({
url: API_BASEURL + "files/" + self.target + "/" + self.file,
type: "POST",

View file

@ -36,14 +36,7 @@
<div class="control-group">
<label class="control-label">{{ _('After slicing...') }}</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: selectAfterSlicing"> {{ _('Select for printing') }}
</label>
</div>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: printAfterSlicing"> {{ _('Print') }}
</label>
<select data-bind="options: afterSlicingOptions, optionsText: 'text', optionsValue: 'value', value: afterSlicing"></select>
</div>
</div>
</form>