From e98a5df85879d92cdad42235669c6bc6b9563254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 14 Jun 2021 11:01:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Special=20metadata=20output=20fo?= =?UTF-8?q?r=20empty=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of zero dimensions and bounding box we now just say "Model contains no extrusion." That should hopefully make it clear. Works for new analysis results with `_empty` flag as well as analysis results with all 0 dimensions. See also #4162 --- .../static/js/app/viewmodels/files.js | 101 ++++++++++-------- 1 file changed, 56 insertions(+), 45 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/files.js b/src/octoprint/static/js/app/viewmodels/files.js index 953816b4a..d22a3cb19 100644 --- a/src/octoprint/static/js/app/viewmodels/files.js +++ b/src/octoprint/static/js/app/viewmodels/files.js @@ -944,60 +944,71 @@ $(function () { self.getAdditionalData = function (data) { var output = ""; if (data["gcodeAnalysis"]) { - if (data["gcodeAnalysis"]["dimensions"]) { - var dimensions = data["gcodeAnalysis"]["dimensions"]; - output += - gettext("Model size") + - ": " + - _.sprintf( - "%(width).2fmm × %(depth).2fmm × %(height).2fmm", - dimensions - ); - output += "
"; - } if ( - data["gcodeAnalysis"]["filament"] && - typeof data["gcodeAnalysis"]["filament"] === "object" + data["gcodeAnalysis"]["_empty"] || + (data["gcodeAnalysis"]["dimensions"]["width"] === 0 && + data["gcodeAnalysis"]["dimensions"]["depth"] === 0 && + data["gcodeAnalysis"]["dimensions"]["height"] === 0) ) { - var filament = data["gcodeAnalysis"]["filament"]; - if (_.keys(filament).length === 1) { + output += gettext("Model contains no extrusion.
"); + } else { + if (data["gcodeAnalysis"]["dimensions"]) { + var dimensions = data["gcodeAnalysis"]["dimensions"]; output += - gettext("Filament") + + gettext("Model size") + ": " + - formatFilament( - data["gcodeAnalysis"]["filament"]["tool" + 0] - ) + - "
"; - } else if (_.keys(filament).length > 1) { - _.each(filament, function (f, k) { - if ( - !_.startsWith(k, "tool") || - !f || - !f.hasOwnProperty("length") || - f["length"] <= 0 - ) - return; + _.sprintf( + "%(width).2fmm × %(depth).2fmm × %(height).2fmm", + dimensions + ); + output += "
"; + } + if ( + data["gcodeAnalysis"]["filament"] && + typeof data["gcodeAnalysis"]["filament"] === "object" + ) { + var filament = data["gcodeAnalysis"]["filament"]; + if (_.keys(filament).length === 1) { output += gettext("Filament") + - " (" + - gettext("Tool") + - " " + - k.substr("tool".length) + - "): " + - formatFilament(f) + + ": " + + formatFilament( + data["gcodeAnalysis"]["filament"]["tool" + 0] + ) + "
"; - }); + } else if (_.keys(filament).length > 1) { + _.each(filament, function (f, k) { + if ( + !_.startsWith(k, "tool") || + !f || + !f.hasOwnProperty("length") || + f["length"] <= 0 + ) + return; + output += + gettext("Filament") + + " (" + + gettext("Tool") + + " " + + k.substr("tool".length) + + "): " + + formatFilament(f) + + "
"; + }); + } } + output += + gettext("Estimated print time") + + ": " + + (self.settingsViewModel.appearance_fuzzyTimes() + ? formatFuzzyPrintTime( + data["gcodeAnalysis"]["estimatedPrintTime"] + ) + : formatDuration( + data["gcodeAnalysis"]["estimatedPrintTime"] + )) + + "
"; } - output += - gettext("Estimated print time") + - ": " + - (self.settingsViewModel.appearance_fuzzyTimes() - ? formatFuzzyPrintTime( - data["gcodeAnalysis"]["estimatedPrintTime"] - ) - : formatDuration(data["gcodeAnalysis"]["estimatedPrintTime"])) + - "
"; } if (data["prints"] && data["prints"]["last"]) { output +=