Add first run wizard dialog for default printer profile

This commit is contained in:
Gina Häußge 2016-08-19 11:42:06 +02:00
parent d2f8b957bc
commit 98b57650d9
3 changed files with 51 additions and 0 deletions

View file

@ -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):

View file

@ -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"
]);
});

View file

@ -0,0 +1,12 @@
<h3>{{ _('Set up your printer profile') }}</h3>
<p>{% 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 %}</p>
<div data-bind="visible: editorLoaded" style="display: none">
<!-- ko with: editor -->
{% include "_snippets/settings/printerprofiles/profileEditor.jinja2" %}
<!-- /ko -->
</div>
<div data-bind="visible: !editorLoaded()">
Loading...
</div>