Added wizard for setup of server commands
This commit is contained in:
parent
bd68bbaa05
commit
c7da95e91a
7 changed files with 72 additions and 22 deletions
|
|
@ -9,6 +9,9 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
|
|||
import octoprint.plugin
|
||||
|
||||
|
||||
from flask.ext.babel import gettext
|
||||
|
||||
|
||||
class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.WizardPlugin,
|
||||
|
|
@ -23,7 +26,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
|||
additional = self._get_subwizard_attrs("_get_", "_additional_wizard_template_data")
|
||||
|
||||
result = list()
|
||||
for key, method in required.iteritems():
|
||||
for key, method in required.items():
|
||||
if not method():
|
||||
continue
|
||||
|
||||
|
|
@ -74,7 +77,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
|||
return dict()
|
||||
|
||||
def _get_acl_wizard_name(self):
|
||||
return "Access Control"
|
||||
return gettext("Access Control")
|
||||
|
||||
def _get_acl_additional_wizard_template_data(self):
|
||||
return dict(mandatory=self._is_acl_wizard_required())
|
||||
|
|
@ -119,7 +122,22 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
|||
return dict()
|
||||
|
||||
def _get_webcam_wizard_name(self):
|
||||
return "Webcam & Timelapse"
|
||||
return gettext("Webcam & Timelapse")
|
||||
|
||||
#~~ Server commands subwizard
|
||||
|
||||
def _is_servercommands_wizard_required(self):
|
||||
system_shutdown_command = self._settings.global_get(["server", "commands", "systemShutdownCommand"])
|
||||
system_restart_command = self._settings.global_get(["server", "commands", "systemRestartCommand"])
|
||||
server_restart_command = self._settings.global_get(["server", "commands", "serverRestartCommand"])
|
||||
|
||||
return not (system_shutdown_command and system_restart_command and server_restart_command)
|
||||
|
||||
def _get_servercommands_wizard_details(self):
|
||||
return dict()
|
||||
|
||||
def _get_servercommands_wizard_name(self):
|
||||
return gettext("Server Commands")
|
||||
|
||||
#~~ helpers
|
||||
|
||||
|
|
@ -143,5 +161,5 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
|||
|
||||
|
||||
__plugin_name__ = "Core Wizard"
|
||||
__plugin_description__ = "Provides wizard dialogs for core components"
|
||||
__plugin_description__ = "Provides wizard dialogs for core components and functionality"
|
||||
__plugin_implementation__ = CoreWizardPlugin()
|
||||
|
|
|
|||
|
|
@ -102,6 +102,12 @@ $(function() {
|
|||
}
|
||||
}
|
||||
|
||||
function CoreWizardServerCommandsViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.settingsViewModel = parameters[0];
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push([
|
||||
CoreWizardAclViewModel,
|
||||
["loginStateViewModel"],
|
||||
|
|
@ -110,5 +116,9 @@ $(function() {
|
|||
CoreWizardWebcamViewModel,
|
||||
["settingsViewModel"],
|
||||
"#wizard_plugin_corewizard_webcam"
|
||||
], [
|
||||
CoreWizardServerCommandsViewModel,
|
||||
["settingsViewModel"],
|
||||
"#wizard_plugin_corewizard_servercommands"
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
<h3>{{ _('Server Commands') }}</h3>
|
||||
|
||||
{% trans %}<p>
|
||||
OctoPrint supports calling external commands in order to restart itself or restarting and/or shutting
|
||||
down the system it is running on. You may configure those here.
|
||||
</p>{% endtrans %}
|
||||
|
||||
<h4>{{ _('OctoPrint related commands') }}</h4>
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel">
|
||||
{% include "_snippets/settings/server/serverCommandServerRestart.jinja2" %}
|
||||
</form>
|
||||
|
||||
<h4>{{ _('System related commands') }}</h4>
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel">
|
||||
{% include "_snippets/settings/server/serverCommandSystemRestart.jinja2" %}
|
||||
{% include "_snippets/settings/server/serverCommandSystemShutdown.jinja2" %}
|
||||
</form>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<div class="control-group" title="{{ _('Command to restart the OctoPrint server') }}">
|
||||
<label class="control-label" for="settings-serverRestartCommand">{{ _('Restart OctoPrint') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: server_commands_serverRestartCommand" id="settings-serverRestartCommand">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<div class="control-group" title="{{ _('Command to restart the system OctoPrint is running on') }}">
|
||||
<label class="control-label" for="settings-systemRestartCommand">{{ _('Restart system') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: server_commands_systemRestartCommand" id="settings-systemRestartCommand">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<div class="control-group" title="{{ _('Command to shut down the system OctoPrint is running on') }}">
|
||||
<label class="control-label" for="settings-systemShutdownCommand">{{ _('Shutdown system') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: server_commands_systemShutdownCommand" id="settings-systemShutdownCommand">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,22 +1,7 @@
|
|||
<form class="form-horizontal">
|
||||
<h3>{{ _('Commands') }}</h3>
|
||||
|
||||
<div class="control-group" title="{{ _('Command to restart the OctoPrint server') }}">
|
||||
<label class="control-label" for="settings-serverRestartCommand">{{ _('Restart OctoPrint') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: server_commands_serverRestartCommand" id="settings-serverRestartCommand">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Command to restart the system OctoPrint is running on') }}">
|
||||
<label class="control-label" for="settings-systemRestartCommand">{{ _('Restart system') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: server_commands_systemRestartCommand" id="settings-systemRestartCommand">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Command to shut down the system OctoPrint is running on') }}">
|
||||
<label class="control-label" for="settings-systemShutdownCommand">{{ _('Shutdown system') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: server_commands_systemShutdownCommand" id="settings-systemShutdownCommand">
|
||||
</div>
|
||||
</div>
|
||||
{% include "_snippets/settings/server/serverCommandServerRestart.jinja2" %}
|
||||
{% include "_snippets/settings/server/serverCommandSystemRestart.jinja2" %}
|
||||
{% include "_snippets/settings/server/serverCommandSystemShutdown.jinja2" %}
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in a new issue