From e453201c1af28f1d5e79638dd14d7108e8482f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 4 Jul 2016 13:20:15 +0200 Subject: [PATCH] Better "upload error" message with supported extensions --- src/octoprint/static/js/app/viewmodels/files.js | 9 ++++++++- src/octoprint/templates/initscript.jinja2 | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/octoprint/static/js/app/viewmodels/files.js b/src/octoprint/static/js/app/viewmodels/files.js index 0707ecd5..f4ac09f0 100644 --- a/src/octoprint/static/js/app/viewmodels/files.js +++ b/src/octoprint/static/js/app/viewmodels/files.js @@ -544,7 +544,14 @@ $(function() { }; self._handleUploadFail = function(e, data) { - var error = "

" + gettext("Could not upload the file. Make sure that it is a GCODE file and has the extension \".gcode\" or \".gco\" or that it is an STL file with the extension \".stl\".") + "

"; + var extensions = _.map(SUPPORTED_EXTENSIONS, function(extension) { + return extension.toLowerCase(); + }).sort(); + extensions = extensions.join(", "); + var error = "

" + + _.sprintf(gettext("Could not upload the file. Make sure that it is a valid file with one of these extensions: %(extensions)s"), + {extensions: extensions}) + + "

"; error += pnotifyAdditionalInfo("
" + data.jqXHR.responseText + "
"); new PNotify({ title: "Upload failed", diff --git a/src/octoprint/templates/initscript.jinja2 b/src/octoprint/templates/initscript.jinja2 index 5763a7ee..9ca5b4bd 100644 --- a/src/octoprint/templates/initscript.jinja2 +++ b/src/octoprint/templates/initscript.jinja2 @@ -29,6 +29,7 @@ var BRANCH = "{{ branch|e }}"; var LOCALE = "{{ g.locale|e }}"; var AVAILABLE_LOCALES = {{ locales|tojson }}; + var SUPPORTED_EXTENSIONS = {{ supportedExtensions|tojson }}; var OCTOPRINT_VIEWMODELS = []; var ADDITIONAL_VIEWMODELS = [];