diff --git a/src/octoprint/plugins/eventmanager/__init__.py b/src/octoprint/plugins/eventmanager/__init__.py index 667c783b3..f631d6ecc 100644 --- a/src/octoprint/plugins/eventmanager/__init__.py +++ b/src/octoprint/plugins/eventmanager/__init__.py @@ -17,7 +17,9 @@ class EventManagerPlugin( } events = self._settings.global_get(["events"]) if events: - my_settings["subscriptions"] = events.get("subscriptions", []) + my_settings["subscriptions"] = sorted( + events.get("subscriptions", []), key=(lambda x: x["event"]) + ) return my_settings def on_settings_save(self, data): diff --git a/src/octoprint/plugins/eventmanager/static/js/events.js b/src/octoprint/plugins/eventmanager/static/js/events.js index f30e4972f..9a51ff31d 100644 --- a/src/octoprint/plugins/eventmanager/static/js/events.js +++ b/src/octoprint/plugins/eventmanager/static/js/events.js @@ -16,6 +16,7 @@ $(function () { return { event: ko.observable(""), command: ko.observable(""), + name: ko.observable(""), type: ko.observable(""), enabled: ko.observable(true), debug: ko.observable(false) diff --git a/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 b/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 index 27408c35d..c0d41b6bd 100644 --- a/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 +++ b/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 @@ -4,7 +4,7 @@
{{ _('Event') }}
-
{{ _('Command') }}
+
{{ _('Name') }}
@@ -12,7 +12,7 @@
-
+
@@ -32,6 +32,13 @@
+ +
+ +
+ +
+
diff --git a/src/octoprint/schema/config/events.py b/src/octoprint/schema/config/events.py index ae8652a5d..249476e9e 100644 --- a/src/octoprint/schema/config/events.py +++ b/src/octoprint/schema/config/events.py @@ -2,7 +2,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License" from enum import Enum -from typing import List +from typing import List, Optional from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs @@ -18,6 +18,9 @@ class EventSubscription(BaseModel): event: str """The event to subscribe to.""" + name: Optional[str] = None + """The event name to show on the UI""" + command: str """The command to execute when the event is triggered, either a GCODE or a system command."""