From 131f58a3cedf33d62749ce388e81ffbac18488e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 25 Feb 2022 16:24:52 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20GCV:=20Add=20more=20progress=20i?= =?UTF-8?q?nfo=20for=20loading=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a "downloading" and a "splitting lines" step so it's clear that something IS happening, even though the progress bar isn't yet showing a percentage. --- .../gcodeviewer/static/js/gcodeviewer.js | 20 +++++++++++++++---- .../gcodeviewer/static/js/viewer/ui.js | 2 +- .../templates/gcodeviewer_tab.jinja2 | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js index 9a05741f3..e5197cd02 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js @@ -9,14 +9,23 @@ $(function () { self.sizeThresholdStr = undefined; self.mobileSizeThresholdStr = undefined; + self.ui_progress_busy = ko.observable(false); self.ui_progress_percentage = ko.observable(); self.ui_progress_type = ko.observable(); self.ui_progress_text = ko.pureComputed(function () { var text = ""; switch (self.ui_progress_type()) { - case "loading": { + case "downloading": { + text = gettext("Downloading..."); + break; + } + case "splitting": { + text = gettext("Splitting lines..."); + break; + } + case "parsing": { text = - gettext("Loading...") + + gettext("Parsing...") + " (" + self.ui_progress_percentage().toFixed(0) + "%)"; @@ -31,7 +40,7 @@ $(function () { break; } case "done": { - text = gettext("Analyzed"); + text = gettext("Ready!"); break; } } @@ -489,6 +498,7 @@ $(function () { self.needsLoad = false; if (self.status === "idle" && self.errorCount < 3) { self.status = "request"; + self._onProgress("downloading"); OctoPrint.files .download("local", path) .done(function (response, rstatus) { @@ -528,6 +538,7 @@ $(function () { } }; GCODE.renderer.clear(); + self._onProgress("splitting"); GCODE.gCodeReader.loadFile(par); if (self.layerSlider !== undefined) { @@ -651,7 +662,8 @@ $(function () { self._onProgress = function (type, percentage) { self.ui_progress_type(type); - self.ui_progress_percentage(percentage); + self.ui_progress_percentage(percentage === undefined ? 100 : percentage); + self.ui_progress_busy(percentage === undefined); }; self._onModelLoaded = function (model) { diff --git a/src/octoprint/plugins/gcodeviewer/static/js/viewer/ui.js b/src/octoprint/plugins/gcodeviewer/static/js/viewer/ui.js index fd103c565..3e9672f22 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/viewer/ui.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/viewer/ui.js @@ -79,7 +79,7 @@ GCODE.ui = (function () { case "returnLayers": GCODE.gCodeReader.processLayersFromWorker(data.msg); - setProgress("loading", data.msg.progress / 2); + setProgress("parsing", data.msg.progress / 2); break; case "analyzeProgress": diff --git a/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_tab.jinja2 b/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_tab.jinja2 index 4e9302952..3f0705686 100644 --- a/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_tab.jinja2 +++ b/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_tab.jinja2 @@ -16,7 +16,7 @@ -
+