Merge branch 'fix/scrollToUpload' into devel
Conflicts: src/octoprint/static/css/octoprint.css src/octoprint/static/js/app/viewmodels/files.js
This commit is contained in:
commit
1e561e7b4a
3 changed files with 70 additions and 15 deletions
File diff suppressed because one or more lines are too long
|
|
@ -59,6 +59,8 @@ $(function() {
|
|||
self.localTarget = undefined;
|
||||
self.sdTarget = undefined;
|
||||
|
||||
self._uploadInProgress = false;
|
||||
|
||||
self.addFolderDialog = undefined;
|
||||
self.addFolderName = ko.observable(undefined);
|
||||
self.enableAddFolder = ko.computed(function() {
|
||||
|
|
@ -193,17 +195,27 @@ $(function() {
|
|||
self.isSdReady(data.flags.sdReady);
|
||||
};
|
||||
|
||||
self._otherRequestInProgress = false;
|
||||
self._otherRequestInProgress = undefined;
|
||||
self._filenameToFocus = undefined;
|
||||
self._locationToFocus = undefined;
|
||||
self._switchToPath = undefined;
|
||||
self.requestData = function(filenameToFocus, locationToFocus, switchToPath) {
|
||||
if (self._otherRequestInProgress) return;
|
||||
self._filenameToFocus = self._filenameToFocus || filenameToFocus;
|
||||
self._locationToFocus = self._locationToFocus || locationToFocus;
|
||||
self._switchToPath = self._switchToPath || switchToPath;
|
||||
if (self._otherRequestInProgress !== undefined) {
|
||||
return self._otherRequestInProgress
|
||||
}
|
||||
|
||||
self._otherRequestInProgress = true;
|
||||
OctoPrint.files.list(true)
|
||||
return self._otherRequestInProgress = OctoPrint.files.list(true)
|
||||
.done(function(response) {
|
||||
self.fromResponse(response, filenameToFocus, locationToFocus, switchToPath);
|
||||
self.fromResponse(response, self._filenameToFocus, self._locationToFocus, self._switchToPath);
|
||||
})
|
||||
.always(function() {
|
||||
self._otherRequestInProgress = false;
|
||||
self._otherRequestInProgress = undefined;
|
||||
self._filenameToFocus = undefined;
|
||||
self._locationToFocus = undefined;
|
||||
self._switchToPath = undefined;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -226,8 +238,19 @@ $(function() {
|
|||
}
|
||||
var entryElement = self.getEntryElement({name: filenameToFocus, origin: locationToFocus});
|
||||
if (entryElement) {
|
||||
// scroll to uploaded element
|
||||
var entryOffset = entryElement.offsetTop;
|
||||
$(".gcode_files").slimScroll({ scrollTo: entryOffset + "px" });
|
||||
$(".gcode_files").slimScroll({
|
||||
scrollTo: entryOffset + "px"
|
||||
});
|
||||
|
||||
// highlight uploaded element
|
||||
var element = $(entryElement);
|
||||
element.on("webkitAnimationEnd oanimationend msAnimationEnd animationend", function(e) {
|
||||
// remove highlight class again
|
||||
element.removeClass("highlight");
|
||||
});
|
||||
element.addClass("highlight");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -653,9 +676,15 @@ $(function() {
|
|||
};
|
||||
|
||||
self.onEventUpdatedFiles = function(payload) {
|
||||
if (payload.type == "gcode") {
|
||||
self.requestData(undefined, undefined, self.currentPath());
|
||||
if (self._uploadInProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.type !== "gcode") {
|
||||
return;
|
||||
}
|
||||
|
||||
self.requestData(undefined, undefined, self.currentPath());
|
||||
};
|
||||
|
||||
self.onEventSlicingDone = function(payload) {
|
||||
|
|
@ -698,8 +727,10 @@ $(function() {
|
|||
drop: function(e, data) {
|
||||
|
||||
},
|
||||
submit: self._handleUploadStart,
|
||||
done: self._handleUploadDone,
|
||||
fail: self._handleUploadFail,
|
||||
always: self._handleUploadAlways,
|
||||
progressall: self._handleUploadProgress
|
||||
}).bind('fileuploadsubmit', function(e, data) {
|
||||
if (self.currentPath() != "")
|
||||
|
|
@ -731,6 +762,11 @@ $(function() {
|
|||
}
|
||||
};
|
||||
|
||||
self._handleUploadStart = function(e, data) {
|
||||
self._uploadInProgress = true;
|
||||
return true;
|
||||
};
|
||||
|
||||
self._handleUploadDone = function(e, data) {
|
||||
var filename = undefined;
|
||||
var location = undefined;
|
||||
|
|
@ -741,15 +777,16 @@ $(function() {
|
|||
filename = data.result.files.local.name;
|
||||
location = "local";
|
||||
}
|
||||
self.requestData(filename, location, self.currentPath());
|
||||
self.requestData(filename, location, self.currentPath())
|
||||
.done(function() {
|
||||
if (data.result.done) {
|
||||
self._setProgressBar(0, "", false);
|
||||
}
|
||||
});
|
||||
|
||||
if (_.endsWith(filename.toLowerCase(), ".stl")) {
|
||||
self.slicing.show(location, filename);
|
||||
}
|
||||
|
||||
if (data.result.done) {
|
||||
self._setProgressBar(0, "", false);
|
||||
}
|
||||
};
|
||||
|
||||
self._handleUploadFail = function(e, data) {
|
||||
|
|
@ -764,6 +801,10 @@ $(function() {
|
|||
self._setProgressBar(0, "", false);
|
||||
};
|
||||
|
||||
self._handleUploadAlways = function(e, data) {
|
||||
self._uploadInProgress = false;
|
||||
};
|
||||
|
||||
self._handleUploadProgress = function(e, data) {
|
||||
var progress = parseInt(data.loaded / data.total * 100, 10);
|
||||
var uploaded = progress >= 100;
|
||||
|
|
|
|||
|
|
@ -530,6 +530,20 @@ ul.dropdown-menu li a {
|
|||
.additionalInfo {
|
||||
padding-bottom: @line-height + 2px;
|
||||
}
|
||||
|
||||
@highlight-color: yellow;
|
||||
@keyframes highlightframes {
|
||||
0% {
|
||||
background: @highlight-color;
|
||||
}
|
||||
100% {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
&.highlight {
|
||||
animation: highlightframes 2s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue