From 98b57650d9f51d35b9eb799d8466090141eab300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 19 Aug 2016 11:42:06 +0200 Subject: [PATCH] Add first run wizard dialog for default printer profile --- src/octoprint/plugins/corewizard/__init__.py | 11 ++++++++ .../corewizard/static/js/corewizard.js | 28 +++++++++++++++++++ .../corewizard_printerprofile_wizard.jinja2 | 12 ++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/octoprint/plugins/corewizard/templates/corewizard_printerprofile_wizard.jinja2 diff --git a/src/octoprint/plugins/corewizard/__init__.py b/src/octoprint/plugins/corewizard/__init__.py index 25fab8e3..1a6b4e03 100644 --- a/src/octoprint/plugins/corewizard/__init__.py +++ b/src/octoprint/plugins/corewizard/__init__.py @@ -139,6 +139,17 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, def _get_servercommands_wizard_name(self): return gettext("Server Commands") + #~~ Printer profile subwizard + + def _is_printerprofile_wizard_required(self): + return self._printer_profile_manager.is_default_unmodified() and self._printer_profile_manager.profile_count == 1 + + def _get_printerprofile_wizard_details(self): + return dict() + + def _get_printerprofile_wizard_name(self): + return gettext("Default Printer Profile") + #~~ helpers def _get_subwizard_attrs(self, start, end, callback=None): diff --git a/src/octoprint/plugins/corewizard/static/js/corewizard.js b/src/octoprint/plugins/corewizard/static/js/corewizard.js index 789fcbff..19a2c32d 100644 --- a/src/octoprint/plugins/corewizard/static/js/corewizard.js +++ b/src/octoprint/plugins/corewizard/static/js/corewizard.js @@ -108,6 +108,30 @@ $(function() { self.settingsViewModel = parameters[0]; } + function CoreWizardPrinterProfileViewModel(parameters) { + var self = this; + + self.printerProfiles = parameters[0]; + + self.editor = self.printerProfiles.createProfileEditor(); + self.editorLoaded = ko.observable(false); + + self.onStartup = function() { + OctoPrint.printerprofiles.get("_default") + .done(function(data) { + self.editor.fromProfileData(data); + self.editorLoaded(true); + }); + }; + + self.onWizardFinish = function() { + OctoPrint.printerprofiles.update("_default", self.editor.toProfileData()) + .done(function() { + self.printerProfiles.requestData(); + }); + }; + } + OCTOPRINT_VIEWMODELS.push([ CoreWizardAclViewModel, ["loginStateViewModel"], @@ -120,5 +144,9 @@ $(function() { CoreWizardServerCommandsViewModel, ["settingsViewModel"], "#wizard_plugin_corewizard_servercommands" + ], [ + CoreWizardPrinterProfileViewModel, + ["printerProfilesViewModel"], + "#wizard_plugin_corewizard_printerprofile" ]); }); diff --git a/src/octoprint/plugins/corewizard/templates/corewizard_printerprofile_wizard.jinja2 b/src/octoprint/plugins/corewizard/templates/corewizard_printerprofile_wizard.jinja2 new file mode 100644 index 00000000..93d870c3 --- /dev/null +++ b/src/octoprint/plugins/corewizard/templates/corewizard_printerprofile_wizard.jinja2 @@ -0,0 +1,12 @@ +

{{ _('Set up your printer profile') }}

+

{% trans %}Please make sure the settings below match your printer. If you plan on connecting more than one printer +to OctoPrint, you can also configure additional printer profiles under Settings > Printer Profiles{% endtrans %}

+ +
+ + {% include "_snippets/settings/printerprofiles/profileEditor.jinja2" %} + +
+
+ Loading... +