Added settings to specify server commands.

Added commands for system shutdown and restart and
for server restart.
(cherry picked from commit dab3285)
This commit is contained in:
Nicanor Romero Venier 2015-07-16 16:01:47 +02:00 committed by Gina Häußge
parent 6de7eabca2
commit 1343a4a253
5 changed files with 57 additions and 3 deletions

View file

@ -113,6 +113,13 @@ def getSettings():
"afterPrintResumed": None,
"snippets": dict()
}
},
"server": {
"commands": {
"systemShutdownCommand": s.get(["server", "commands", "systemShutdownCommand"]),
"systemRestartCommand": s.get(["server", "commands", "systemRestartCommand"]),
"serverRestartCommand": s.get(["server", "commands", "serverRestartCommand"])
}
}
}
@ -252,6 +259,12 @@ def setSettings():
continue
s.saveScript("gcode", name, script.replace("\r\n", "\n").replace("\r", "\n"))
if "server" in data:
if "commands" in data["server"]:
if "systemShutdownCommand" in data["server"]["commands"].keys(): s.set(["server", "commands", "systemShutdownCommand"], data["server"]["commands"]["systemShutdownCommand"])
if "systemRestartCommand" in data["server"]["commands"].keys(): s.set(["server", "commands", "systemRestartCommand"], data["server"]["commands"]["systemRestartCommand"])
if "serverRestartCommand" in data["server"]["commands"].keys(): s.set(["server", "commands", "serverRestartCommand"], data["server"]["commands"]["serverRestartCommand"])
if "plugins" in data:
for plugin in octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SettingsPlugin):
plugin_id = plugin._identifier

View file

@ -150,6 +150,7 @@ def index():
folders=(gettext("Folders"), dict(template="dialogs/settings/folders.jinja2", _div="settings_folders", custom_bindings=False)),
appearance=(gettext("Appearance"), dict(template="dialogs/settings/appearance.jinja2", _div="settings_appearance", custom_bindings=False)),
logs=(gettext("Logs"), dict(template="dialogs/settings/logs.jinja2", _div="settings_logs")),
server=(gettext("Server"), dict(template="dialogs/settings/server.jinja2", _div="settings_server", custom_bindings=False)),
)
if enable_accesscontrol:
templates["settings"]["entries"]["accesscontrol"] = (gettext("Access Control"), dict(template="dialogs/settings/accesscontrol.jinja2", _div="settings_users", custom_bindings=False))

View file

@ -104,6 +104,11 @@ default_settings = {
"pathSuffix": "path"
},
"maxSize": 100 * 1024, # 100 KB
"commands": {
"systemShutdownCommand": None,
"systemRestartCommand": None,
"serverRestartCommand": None
}
},
"webcam": {
"stream": None,
@ -190,7 +195,7 @@ default_settings = {
"settings": [
"section_printer", "serial", "printerprofiles", "temperatures", "terminalfilters", "gcodescripts",
"section_features", "features", "webcam", "accesscontrol", "api",
"section_octoprint", "folders", "appearance", "logs", "plugin_pluginmanager", "plugin_softwareupdate"
"section_octoprint", "server", "folders", "appearance", "logs", "plugin_pluginmanager", "plugin_softwareupdate"
],
"usersettings": ["access", "interface"],
"generic": []
@ -324,14 +329,14 @@ class Settings(object):
"/dev/ttyACM0"
``["serial", "timeouts"]`` ::
``["serial", "timeout"]`` ::
communication: 20.0
temperature: 5.0
sdStatus: 1.0
connection: 10.0
``["serial", "timeouts", "temperature"]`` ::
``["serial", "timeout", "temperature"]`` ::
5.0

View file

@ -154,6 +154,10 @@ $(function() {
self.terminalFilters = ko.observableArray([]);
self.server_commands_systemShutdownCommand = ko.observable(undefined);
self.server_commands_systemRestartCommand = ko.observable(undefined);
self.server_commands_serverRestartCommand = ko.observable(undefined);
self.settings = undefined;
self.addTemperatureProfile = function() {
@ -449,6 +453,10 @@ $(function() {
self.system_actions(response.system.actions);
self.terminalFilters(response.terminalFilters);
self.server_commands_systemShutdownCommand(response.server.commands.systemShutdownCommand);
self.server_commands_systemRestartCommand(response.server.commands.systemRestartCommand);
self.server_commands_serverRestartCommand(response.server.commands.serverRestartCommand);
};
self.saveData = function (data, successCallback) {
@ -535,6 +543,13 @@ $(function() {
"beforePrintResumed": self.scripts_gcode_beforePrintResumed(),
"afterPrinterConnected": self.scripts_gcode_afterPrinterConnected()
}
},
"server": {
"commands": {
"systemShutdownCommand": self.server_commands_systemShutdownCommand(),
"systemRestartCommand": self.server_commands_systemRestartCommand(),
"serverRestartCommand": self.server_commands_serverRestartCommand()
}
}
});
}

View file

@ -0,0 +1,20 @@
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="settings-systemShutdownCommand">{{ _('System Shutdown Command') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: server_commands_systemShutdownCommand" id="settings-systemShutdownCommand">
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-systemRestartCommand">{{ _('System Restart Command') }}</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">
<label class="control-label" for="settings-serverRestartCommand">{{ _('Server Restart Command') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: server_commands_serverRestartCommand" id="settings-serverRestartCommand">
</div>
</div>
</form>