Fixed a bunch of issues with the software update wizard

This commit is contained in:
Gina Häußge 2016-03-30 15:45:13 +02:00
parent aecedfa57f
commit 45a79b1939
4 changed files with 42 additions and 4 deletions

View file

@ -216,15 +216,25 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
))
)
updated_octoprint_check_config = False
if "octoprint_checkout_folder" in data:
self._settings.set(["checks", "octoprint", "checkout_folder"], data["octoprint_checkout_folder"], defaults=defaults, force=True)
if update_folder and data["octoprint_checkout_folder"]:
self._settings.set(["checks", "octoprint", "update_folder"], None, defaults=defaults, force=True)
self._refresh_configured_checks = True
updated_octoprint_check_config = True
if "octoprint_type" in data and data["octoprint_type"] in ("github_release", "git_commit"):
self._settings.set(["checks", "octoprint", "type"], data["octoprint_type"], defaults=defaults, force=True)
updated_octoprint_check_config = True
if updated_octoprint_check_config:
self._refresh_configured_checks = True
try:
del self._version_cache["octoprint"]
except KeyError:
pass
self._version_cache_dirty = True
def get_settings_version(self):
return 4
@ -406,7 +416,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
dict(type="settings", name=gettext("Software Update"))
]
##~~
##~~ WizardPlugin API
def is_wizard_required(self):
checks = self._get_configured_checks()

View file

@ -11,8 +11,23 @@
var checkUrl = url + "check";
var updateUrl = url + "update";
exports.checkEntries = function(entries, force, opts) {
entries = entries || [];
if (typeof entries == "string") {
entries = [entries];
}
var data = {
force: !!force
};
if (entries && entries.length) {
data["check"] = entries.join(",")
}
return OctoPrint.getWithQuery(checkUrl, data, opts);
};
exports.check = function(force, opts) {
return OctoPrint.get(checkUrl + ((!!force) ? "?force=true" : ""), opts);
return exports.checkEntries([], force, opts);
};
exports.update = function(entries, force, opts) {
@ -432,6 +447,11 @@ $(function() {
return true;
};
self.onAfterWizardFinish = function() {
// we might have changed our config, so we need to refresh our check data from the server
self.performCheck();
};
self.onStartup = function() {
self.workingDialog = $("#settings_plugin_softwareupdate_workingdialog");
self.workingOutput = $("#settings_plugin_softwareupdate_workingdialog_output");

View file

@ -84,6 +84,10 @@
return OctoPrint.ajax("GET", url, opts);
};
OctoPrint.getWithQuery = function(url, data, opts) {
return OctoPrint.ajaxWithData("GET", url, data, opts);
};
OctoPrint.post = function(url, data, opts) {
return OctoPrint.ajaxWithData("POST", url, data, noCache(opts));
};

View file

@ -32,6 +32,8 @@ $(function() {
'margin-left': function() { return -($(this).width() /2); }
});
}
callViewModels(self.allViewModels, "onWizardShow");
});
};
@ -96,7 +98,8 @@ $(function() {
if (current != undefined && next != undefined) {
var result = true;
callViewModels(allViewModels, "onWizardTabChange", function(method) {
result = result && (method(current, next) !== false);
// we want to continue evaluating even if result becomes false
result = (method(current, next) !== false) && result;
});
return result;
}
@ -130,6 +133,7 @@ $(function() {
if (reload) {
self.reloadOverlay.show();
}
callViewModels(allViewModels, "onAfterWizardFinish");
});
}
}