Enforce update of updateable software after plugin changes

When any plugins are enabled/disabled, the client now gets a trigger to fetch a fresh list of update information from the server. This should take care of any old popups still hinting at now uninstalled plugins.
This commit is contained in:
Gina Häußge 2015-06-18 17:08:56 +02:00
parent 6e90c9d730
commit a26b203205
2 changed files with 98 additions and 80 deletions

View file

@ -43,6 +43,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
def refresh_checks(name, plugin):
self._refresh_configured_checks = True
self._send_client_message("update_versions")
self._plugin_lifecycle_manager.add_callback("enabled", refresh_checks)
self._plugin_lifecycle_manager.add_callback("disabled", refresh_checks)
@ -92,6 +94,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
#~~ BluePrint API
@octoprint.plugin.BlueprintPlugin.route("/check", methods=["GET"])
@restricted_access
def check_for_update(self):
if "check" in flask.request.values:
check_targets = map(str.strip, flask.request.values["check"].split(","))
@ -101,7 +104,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
if "force" in flask.request.values and flask.request.values["force"] in octoprint.settings.valid_boolean_trues:
force = True
else:
force=False
force = False
try:
information, update_available, update_possible = self.get_current_versions(check_targets=check_targets, force=force)
@ -128,9 +131,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
else:
check_targets = None
if "force" in json_data:
from octoprint.settings import valid_boolean_trues
force = (json_data["force"] in valid_boolean_trues)
if "force" in json_data and json_data["force"] in octoprint.settings.valid_boolean_trues:
force = True
else:
force = False

View file

@ -44,9 +44,7 @@ $(function() {
};
self._showPopup = function(options, eventListeners) {
if (self.popup !== undefined) {
self.popup.remove();
}
self._closePopup();
self.popup = new PNotify(options);
if (eventListeners) {
@ -65,6 +63,12 @@ $(function() {
}
};
self._closePopup = function() {
if (self.popup !== undefined) {
self.popup.remove();
}
};
self.showPluginSettings = function() {
self._copyConfig();
self.configurationDialog.modal();
@ -89,19 +93,7 @@ $(function() {
self.config_cacheTtl(self.settings.settings.plugins.softwareupdate.cache_ttl());
};
self.performCheck = function(showIfNothingNew, force, ignoreSeen) {
if (!self.loginState.isUser()) return;
var url = PLUGIN_BASEURL + "softwareupdate/check";
if (force) {
url += "?force=true";
}
$.ajax({
url: url,
type: "GET",
dataType: "json",
success: function(data) {
self.fromCheckResponse = function(data, ignoreSeen, showIfNothingNew) {
var versions = [];
_.each(data.information, function(value, key) {
value["key"] = key;
@ -168,14 +160,34 @@ $(function() {
if (ignoreSeen || !self._hasNotificationBeenSeen(data.information)) {
self._showPopup(options, eventListeners);
}
} else if (data.status == "current" && showIfNothingNew) {
} else if (data.status == "current") {
if (showIfNothingNew) {
self._showPopup({
title: gettext("Everything is up-to-date"),
hide: false,
type: "success"
});
} else {
self._closePopup();
}
}
};
self.performCheck = function(showIfNothingNew, force, ignoreSeen) {
if (!self.loginState.isUser()) return;
var url = PLUGIN_BASEURL + "softwareupdate/check";
if (force) {
url += "?force=true";
}
$.ajax({
url: url,
type: "GET",
dataType: "json",
success: function(data) {
self.fromCheckResponse(data, ignoreSeen, showIfNothingNew);
}
});
};
@ -421,6 +433,10 @@ $(function() {
self.updateInProgress = false;
break;
}
case "update_versions": {
self.performCheck();
break;
}
}
if (options != undefined) {