diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 31e5235f..91728c1c 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -112,6 +112,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"]) + } } } @@ -250,6 +257,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 diff --git a/src/octoprint/server/views.py b/src/octoprint/server/views.py index 4df458bb..dc278060 100644 --- a/src/octoprint/server/views.py +++ b/src/octoprint/server/views.py @@ -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)) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index f5fd85a2..4d4d58e6 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -104,6 +104,11 @@ default_settings = { "pathSuffix": "path" }, "maxSize": 100 * 1024, # 100 KB + "commands": { + "systemShutdownCommand": None, + "systemRestartCommand": None, + "serverRestartCommand": None + } }, "webcam": { "stream": None, @@ -188,7 +193,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": [] @@ -321,14 +326,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 diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index c860402f..9b33f313 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -149,6 +149,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() { @@ -415,6 +419,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) { @@ -499,6 +507,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() + } } }); } diff --git a/src/octoprint/templates/dialogs/settings/server.jinja2 b/src/octoprint/templates/dialogs/settings/server.jinja2 new file mode 100644 index 00000000..09bee222 --- /dev/null +++ b/src/octoprint/templates/dialogs/settings/server.jinja2 @@ -0,0 +1,20 @@ +