diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index b3a0b7f3..e35356fa 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -213,6 +213,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, "check_providers": {}, "cache_ttl": 24 * 60, + + "notify_users": True } def on_settings_load(self): @@ -260,7 +262,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, def on_settings_save(self, data): for key in self.get_settings_defaults(): - if key in ("checks", "cache_ttl", "octoprint_checkout_folder", "octoprint_type", "octoprint_release_channel"): + if key in ("checks", "cache_ttl", "notify_user", "octoprint_checkout_folder", "octoprint_type", "octoprint_release_channel"): continue if key in data: self._settings.set([key], data[key]) @@ -269,6 +271,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, self._settings.set_int(["cache_ttl"], data["cache_ttl"]) self._version_cache_ttl = self._settings.get_int(["cache_ttl"]) * 60 + if "notify_users" in data: + self._settings.set_boolean(["notify_users"], data["notify_users"]) + checks = self._get_configured_checks() if "octoprint" in checks: check = checks["octoprint"] diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 019b4240..62bd0003 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -112,6 +112,7 @@ $(function() { self.octoprintUnreleased = ko.observable(); self.config_cacheTtl = ko.observable(); + self.config_notifyUsers = ko.observable(); self.config_checkoutFolder = ko.observable(); self.config_checkType = ko.observable(); self.config_updateMethod = ko.observable(); @@ -153,9 +154,20 @@ $(function() { self.performCheck(); }; - self._showPopup = function(options, eventListeners) { + self.onUserLoggedOut = function() { self._closePopup(); - self.popup = new PNotify(options); + }; + + self._showPopup = function(options, eventListeners, singleButtonNotify) { + singleButtonNotify = singleButtonNotify || false; + + self._closePopup(); + + if (singleButtonNotify) { + self.popup = PNotify.singleButtonNotify(options); + } else { + self.popup = new PNotify(options); + } if (eventListeners) { var popupObj = self.popup.get(); @@ -192,6 +204,7 @@ $(function() { plugins: { softwareupdate: { cache_ttl: parseInt(self.config_cacheTtl()), + notify_users: self.config_notifyUsers(), octoprint_checkout_folder: self.config_checkoutFolder(), octoprint_type: self.config_checkType(), octoprint_release_channel: self.config_releaseChannel() @@ -231,6 +244,7 @@ $(function() { self.config_updateMethod(updateMethod); self.config_cacheTtl(self.settings.settings.plugins.softwareupdate.cache_ttl()); + self.config_notifyUsers(self.settings.settings.plugins.softwareupdate.notify_users()); self.config_checkoutFolder(self.settings.settings.plugins.softwareupdate.octoprint_checkout_folder()); self.config_checkType(self.settings.settings.plugins.softwareupdate.octoprint_type()); self.config_releaseChannel(self.settings.settings.plugins.softwareupdate.octoprint_release_channel()); @@ -288,6 +302,8 @@ $(function() { } } + if (!self.loginState.isAdmin() && !self.settings.settings.plugins.softwareupdate.notify_users()) return; + if (data.status == "updateAvailable" || data.status == "updatePossible") { var text = "
" + gettext("Those components marked with can be updated directly.") + "
"; + + if (!self.loginState.isAdmin()) { + text += "" + gettext("To have updates applied, get in touch with an administrator of this OctoPrint instance.") + "
"; + } text += "