✨ Add support for descriptive names to event subscriptions (#4568)
This commit is contained in:
1 parent
a2e2d621ce
commit
bb63eaad03
4 files changed
+17
-4
No files matched your search
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span4">{{ _('Event') }}</div>
|
||||
<div class="span6">{{ _('Command') }}</div>
|
||||
<div class="span6">{{ _('Name') }}</div>
|
||||
<div class="span2 btn-group">
|
||||
<button class="btn btn-mini" data-bind="click: addEvent"><i class="fa fa-plus"></i> {{ _('Add') }}</button>
|
||||
</div>
|
||||
@@ -12,7 +12,7 @@
|
||||
<div data-bind="foreach: settingsViewModel.settings.plugins.eventmanager.subscriptions" class="row-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span4" data-bind="text: event"></div>
|
||||
<div class="span6" data-bind="text: command"></div>
|
||||
<div class="span6" data-bind="attr: {title: command}, text: name() ? name() : command()"></div>
|
||||
<div class="span2 btn-group">
|
||||
<button class="btn btn-mini" data-bind="click: $root.editEvent"><i class="fa fa-pencil"></i></button>
|
||||
<button class="btn btn-mini btn-danger" data-bind="click: $root.removeEvent"><i class="fa fa-trash-alt"></i></button>
|
||||
@@ -32,6 +32,13 @@
|
||||
<select class="input-block-level" data-bind="value: event, options: $root.settingsViewModel.settings.plugins.eventmanager.availableEvents().sort(), optionsCaption: 'Select Event', valueAllowUnset: true"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Name') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Command') }}</label>
|
||||
<div class="controls">
|
||||
|
||||
@@ -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."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user