GCode file list now automatically switches to page with newly uploaded file as soon as upload request comes back from backend as finished. Progress bar also gets emptied again then. Careful: might take a bit after the upload progress reaches 100% since the file still has to be written to disk in the backend (have to look into how to get this done in a streaming way), metadata analysis gets triggered after returning a response.

Different sorting options are still on my mental todo list ;)

Closes #34.
master
Gina Häußge 2013-02-04 22:24:32 +01:00
parent 3de0d1b1e5
commit 5f55ebd90a
3 changed files with 26 additions and 3 deletions

View File

@ -119,7 +119,7 @@ class GcodeManager:
if absolutePath is not None:
file.save(absolutePath)
self._metadataAnalyzer.addFileToQueue(os.path.basename(absolutePath))
return absolutePath
return self._getBasicFilename(absolutePath)
return None
def removeFile(self, filename):

View File

@ -238,10 +238,11 @@ def readGcodeFile(filename):
@app.route(BASEURL + "gcodefiles/upload", methods=["POST"])
def uploadGcodeFile():
filename = None
if "gcode_file" in request.files.keys():
file = request.files["gcode_file"]
gcodeManager.addFile(file)
return readGcodeFiles()
filename = gcodeManager.addFile(file)
return jsonify(files=gcodeManager.getAllFileData(), filename=filename)
@app.route(BASEURL + "gcodefiles/load", methods=["POST"])
def loadGcodeFile():

View File

@ -658,6 +658,11 @@ function GcodeFilesViewModel() {
});
self.files(sortedFiles);
if (response.filename) {
// got a file to scroll to
self.switchToFile(response.filename);
}
}
self.loadFile = function(filename) {
@ -679,6 +684,22 @@ function GcodeFilesViewModel() {
})
}
self.switchToFile = function(filename) {
var pos = -1;
var filelist = self.files();
for (var i = 0; i < filelist.length; i++) {
if (filelist[i].name == filename) {
pos = i;
break;
}
}
if (pos > -1) {
var page = Math.floor(pos / self.pageSize());
self.changePage(page);
}
}
self.changePage = function(newPage) {
if (newPage < 0 || newPage > self.lastPage())
return;
@ -1057,6 +1078,7 @@ $(function() {
dataType: "json",
done: function (e, data) {
gcodeFilesViewModel.fromResponse(data.result);
$("#gcode_upload_progress .bar").css("width", "0%");
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);