diff --git a/src/octoprint/plugins/action_command_notification/__init__.py b/src/octoprint/plugins/action_command_notification/__init__.py index a91c80155..e58007004 100644 --- a/src/octoprint/plugins/action_command_notification/__init__.py +++ b/src/octoprint/plugins/action_command_notification/__init__.py @@ -100,6 +100,7 @@ class ActionCommandNotificationPlugin( "name": gettext("Printer Notifications"), "icon": "bell-o", "styles_wrapper": ["display: none"], + "template_header": "action_command_notification_sidebar_header.jinja2", "data_bind": "visible: loginState.hasPermissionKo(access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW)" " && settings.settings.plugins.action_command_notification.enable()", }, diff --git a/src/octoprint/plugins/action_command_notification/static/js/action_command_notification.js b/src/octoprint/plugins/action_command_notification/static/js/action_command_notification.js index 6410639fd..c9f092d75 100644 --- a/src/octoprint/plugins/action_command_notification/static/js/action_command_notification.js +++ b/src/octoprint/plugins/action_command_notification/static/js/action_command_notification.js @@ -7,6 +7,10 @@ $(function () { self.settings = parameters[2]; self.notifications = ko.observableArray([]); + self.sortDesc = ko.observable(false); + self.sortDesc.subscribe(function () { + self._toLocalStorage(); + }); self.toDateTimeString = function (timestamp) { return formatDate(timestamp); @@ -24,7 +28,11 @@ $(function () { }; self.fromResponse = function (response) { - self.notifications(response.notifications); + var notifications = response.notifications; + if (self.sortDesc()) { + notifications.reverse(); + } + self.notifications(notifications); }; self.clear = function () { @@ -38,6 +46,11 @@ $(function () { OctoPrint.plugins.action_command_notification.clear(); }; + self.toggleSorting = function () { + self.sortDesc(!self.sortDesc()); + self.requestData(); + }; + self.onStartup = self.onUserLoggedIn = self.onUserLoggedOut = function () { self.requestData(); }; @@ -71,6 +84,20 @@ $(function () { }); } }; + + var optionsLocalStorageKey = "core.gcodeviewer.options"; + self._toLocalStorage = function () { + saveToLocalStorage(optionsLocalStorageKey, {sortDesc: self.sortDesc()}); + }; + + self._fromLocalStorage = function () { + var data = loadFromLocalStorage(optionsLocalStorageKey); + if (data["sortDesc"] !== undefined) { + self.sortDesc(!!data["sortDesc"]); + } + }; + + self._fromLocalStorage(); } OCTOPRINT_VIEWMODELS.push({ diff --git a/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar.jinja2 b/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar.jinja2 index 1118af0f3..fb2ed0200 100644 --- a/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar.jinja2 +++ b/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar.jinja2 @@ -5,7 +5,7 @@
- +