Removed a couple of redundancies for loadAndPrint button, actions are now disabled if they don't make sense
parent
52bd2bee49
commit
f70649b0d2
|
@ -158,7 +158,7 @@ class Printer():
|
|||
|
||||
self._comm.setFeedrateModifier(self._feedrateModifierMapping[structure], percentage / 100.0)
|
||||
|
||||
def loadGcode(self, file):
|
||||
def loadGcode(self, file, printAfterLoading=False):
|
||||
"""
|
||||
Loads the gcode from the given file as the new print job.
|
||||
Aborts if the printer is currently printing or another gcode file is currently being loaded.
|
||||
|
@ -168,27 +168,15 @@ class Printer():
|
|||
|
||||
self._setJobData(None, None)
|
||||
|
||||
self._gcodeLoader = GcodeLoader(file, self._onGcodeLoadingProgress, self._onGcodeLoaded)
|
||||
onGcodeLoadedCallback = self._onGcodeLoaded
|
||||
if printAfterLoading:
|
||||
onGcodeLoadedCallback = self._onGcodeLoadedToPrint
|
||||
|
||||
self._gcodeLoader = GcodeLoader(file, self._onGcodeLoadingProgress, onGcodeLoadedCallback)
|
||||
self._gcodeLoader.start()
|
||||
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def loadAndPrintGcode(self, file):
|
||||
"""
|
||||
Loads the gcode from the given file as the new print job and starts the print.
|
||||
Aborts if the printer is currently printing or another gcode file is currently being loaded, or if loading the gcode file fails.
|
||||
"""
|
||||
if (self._comm is not None and self._comm.isPrinting()) or (self._gcodeLoader is not None):
|
||||
return
|
||||
|
||||
self._setJobData(None, None)
|
||||
|
||||
self._gcodeLoader = GcodeLoader(file, self._onGcodeLoadingProgress, self._onGcodeLoadedToPrint)
|
||||
self._gcodeLoader.start()
|
||||
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
|
||||
def startPrint(self):
|
||||
"""
|
||||
Starts the currently loaded print job.
|
||||
|
@ -433,15 +421,8 @@ class Printer():
|
|||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def _onGcodeLoadedToPrint(self, filename, gcodeList):
|
||||
self._setJobData(filename, gcodeList)
|
||||
self._setCurrentZ(None)
|
||||
self._setProgressData(None, None, None)
|
||||
self._gcodeLoader = None
|
||||
|
||||
self._stateMonitor.setGcodeData({"filename": None, "progress": None})
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
self.startPrint();
|
||||
self._onGcodeLoaded(filename, gcodeList)
|
||||
self.startPrint()
|
||||
|
||||
#~~ state reports
|
||||
|
||||
|
|
|
@ -261,17 +261,12 @@ def uploadGcodeFile():
|
|||
@app.route(BASEURL + "gcodefiles/load", methods=["POST"])
|
||||
def loadGcodeFile():
|
||||
if "filename" in request.values.keys():
|
||||
printAfterLoading = False
|
||||
if "print" in request.values.keys() and request.values["print"]:
|
||||
printAfterLoading = True
|
||||
filename = gcodeManager.getAbsolutePath(request.values["filename"])
|
||||
if filename is not None:
|
||||
printer.loadGcode(filename)
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
@app.route(BASEURL + "gcodefiles/loadandprint", methods=["POST"])
|
||||
def loadAndPrintGcodeFile():
|
||||
if "filename" in request.values.keys():
|
||||
filename = gcodeManager.getAbsolutePath(request.values["filename"])
|
||||
if filename is not None:
|
||||
printer.loadAndPrintGcode(filename)
|
||||
printer.loadGcode(filename, printAfterLoading)
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
@app.route(BASEURL + "gcodefiles/delete", methods=["POST"])
|
||||
|
|
|
@ -65,6 +65,10 @@ body {
|
|||
@base: #7728FF;
|
||||
.navbar-inner-color(@base);
|
||||
}
|
||||
|
||||
.brand img {
|
||||
vertical-align: bottom;
|
||||
}
|
||||
}
|
||||
|
||||
/** OctoPrint application tabs */
|
||||
|
@ -115,6 +119,11 @@ body {
|
|||
a.accordion-toggle {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
[class^="icon-"],
|
||||
[class*=" icon-"] {
|
||||
color: #000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,6 +155,16 @@ table {
|
|||
&.gcode_files_action {
|
||||
text-align: center;
|
||||
width: 70px;
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
|
||||
&.disabled {
|
||||
color: #ccc;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// timelapse files
|
||||
|
|
|
@ -657,6 +657,14 @@ function TerminalViewModel() {
|
|||
function GcodeFilesViewModel() {
|
||||
var self = this;
|
||||
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
self.isPrinting = ko.observable(undefined);
|
||||
self.isPaused = ko.observable(undefined);
|
||||
self.isError = ko.observable(undefined);
|
||||
self.isReady = ko.observable(undefined);
|
||||
self.isLoading = ko.observable(undefined);
|
||||
|
||||
// initialize list helper
|
||||
self.listHelper = new ItemListHelper(
|
||||
"gcodeFiles",
|
||||
|
@ -688,7 +696,33 @@ function GcodeFilesViewModel() {
|
|||
"name",
|
||||
[],
|
||||
CONFIG_GCODEFILESPERPAGE
|
||||
)
|
||||
);
|
||||
|
||||
self.isLoadActionPossible = ko.computed(function() {
|
||||
return !self.isPrinting() && !self.isPaused() && !self.isLoading();
|
||||
});
|
||||
|
||||
self.isLoadAndPrintActionPossible = ko.computed(function() {
|
||||
return self.isOperational() && self.isLoadActionPossible();
|
||||
});
|
||||
|
||||
self.fromCurrentData = function(data) {
|
||||
self._processStateData(data.state);
|
||||
}
|
||||
|
||||
self.fromHistoryData = function(data) {
|
||||
self._processStateData(data.state);
|
||||
}
|
||||
|
||||
self._processStateData = function(data) {
|
||||
self.isErrorOrClosed(data.flags.closedOrError);
|
||||
self.isOperational(data.flags.operational);
|
||||
self.isPaused(data.flags.paused);
|
||||
self.isPrinting(data.flags.printing);
|
||||
self.isError(data.flags.error);
|
||||
self.isReady(data.flags.ready);
|
||||
self.isLoading(data.flags.loading);
|
||||
}
|
||||
|
||||
self.requestData = function() {
|
||||
$.ajax({
|
||||
|
@ -710,21 +744,12 @@ function GcodeFilesViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
self.loadFile = function(filename) {
|
||||
self.loadFile = function(filename, printAfterLoad) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "gcodefiles/load",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {filename: filename}
|
||||
})
|
||||
}
|
||||
|
||||
self.loadAndPrintFile = function(filename) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "gcodefiles/loadandprint",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {filename: filename}
|
||||
data: {filename: filename, print: printAfterLoad}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1149,6 +1174,7 @@ function DataUpdater(connectionViewModel, printerStateViewModel, temperatureView
|
|||
self.terminalViewModel.fromHistoryData(data);
|
||||
self.webcamViewModel.fromHistoryData(data);
|
||||
self.gcodeViewModel.fromHistoryData(data);
|
||||
self.gcodeFilesViewModel.fromCurrentData(data);
|
||||
})
|
||||
self._socket.on("current", function(data) {
|
||||
self.connectionViewModel.fromCurrentData(data);
|
||||
|
@ -1158,6 +1184,7 @@ function DataUpdater(connectionViewModel, printerStateViewModel, temperatureView
|
|||
self.terminalViewModel.fromCurrentData(data);
|
||||
self.webcamViewModel.fromCurrentData(data);
|
||||
self.gcodeViewModel.fromCurrentData(data);
|
||||
self.gcodeFilesViewModel.fromCurrentData(data);
|
||||
})
|
||||
self._socket.on("updateTrigger", function(type) {
|
||||
if (type == "gcodeFiles") {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<link rel="apple-touch-icon" sizes="144x144" href="{{ url_for('static', filename='img/apple-touch-icon-144x144.png') }}">
|
||||
|
||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet" media="screen">
|
||||
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet" media="screen">
|
||||
<link href="{{ url_for('static', filename='css/jquery.fileupload-ui.css') }}" rel="stylesheet" media="screen">
|
||||
<link href="{{ url_for('static', filename='css/jquery.pnotify.default.css') }}" rel="stylesheet" media="screen">
|
||||
<link href="{{ url_for('static', filename='css/octoprint.less') }}" rel="stylesheet/less" type="text/css" media="screen">
|
||||
|
@ -127,7 +128,9 @@
|
|||
<tr data-bind="css: $root.getSuccessClass($data), popover: { title: name, animation: true, html: true, placement: 'right', trigger: 'hover', delay: 0, content: $root.getPopoverContent($data), html: true }">
|
||||
<td class="gcode_files_name" data-bind="text: name"></td>
|
||||
<td class="gcode_files_size" data-bind="text: size"></td>
|
||||
<td class="gcode_files_action"><a href="#" class="icon-trash" title="Remove" data-bind="click: function() { $root.removeFile($data.name); }"></a> | <a href="#" class="icon-folder-open" title="Load" data-bind="click: function() { $root.loadFile($data.name); }"></a> | <a href="#" class="icon-print" title="Load and Print" data-bind="click: function() { $root.loadAndPrintFile($data.name); }"></a></td>
|
||||
<td class="gcode_files_action">
|
||||
<a href="#" class="icon-trash" title="Remove" data-bind="click: function() { $root.removeFile($data.name); }"></a> | <a href="#" class="icon-folder-open" title="Load" data-bind="click: function() { if ($root.isLoadActionPossible()) { $root.loadFile($data.name, false); } else { return; } }, css: {disabled: !$root.isLoadActionPossible()}"></a> | <a href="#" class="icon-print" title="Load and Print" data-bind="click: function() { if ($root.isLoadAndPrintActionPossible()) { $root.loadFile($data.name, true); } else { return; } }, css: {disabled: !$root.isLoadAndPrintActionPossible()}"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue