* adds an update queue to allow starting updates while printing, #3320, #3589, #3585 * change to 202 status code instead of abort for queued installs * remove commented code * fix formatting * UI improvements proper list merging, without duplicates * add countdown timer on print completion prior to update don't automatically update on print fail add ability to cancel queued updates * UI tweaks and fixes * minor bugfix * if logic adjustment to prevent sending messages to front end when no updates queued * add timer abort on print start in case he update is in process * added wait for timelapse completion to avoid interrupting that process due to resstart at the end of updates. * ♻️ Get rid of some data duplication ...and a TODO * API adjustments as requested, removed PNotify hack for singleButtonNotify change (broken) * added print_cancelled flag to deal with changes related to waiting for timelapse switched PNotify back from singleButtonNotify and added class hidden to button instead to avoid Pnotify.update issue * 💄 minify CSS Implements #3320 Implements #3585 Implements #3589 Implements #4431 Co-authored-by: Gina Häußge <gina@octoprint.org>
134 lines
3.9 KiB
JavaScript
134 lines
3.9 KiB
JavaScript
(function (global, factory) {
|
|
if (typeof define === "function" && define.amd) {
|
|
define(["OctoPrintClient"], factory);
|
|
} else {
|
|
factory(global.OctoPrintClient);
|
|
}
|
|
})(this, function (OctoPrintClient) {
|
|
var OctoPrintSoftwareUpdateClient = function (base) {
|
|
this.base = base;
|
|
|
|
var url = this.base.getBlueprintUrl("softwareupdate");
|
|
this.checkUrl = url + "check";
|
|
this.updateUrl = url + "update";
|
|
this.configureUrl = url + "configure";
|
|
this.updatelogUrl = url + "updatelog";
|
|
this.queuedURL = this.updateUrl + "/queued";
|
|
};
|
|
|
|
OctoPrintSoftwareUpdateClient.prototype.checkEntries = function (
|
|
entries,
|
|
force,
|
|
opts
|
|
) {
|
|
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
|
var params = arguments[0];
|
|
entries = params.entries;
|
|
force = params.force;
|
|
opts = params.opts;
|
|
}
|
|
|
|
entries = entries || [];
|
|
if (typeof entries == "string") {
|
|
entries = [entries];
|
|
}
|
|
|
|
var data = {};
|
|
if (!!force) {
|
|
data.force = true;
|
|
}
|
|
if (entries && entries.length) {
|
|
data.targets = entries.join(",");
|
|
}
|
|
return this.base.getWithQuery(this.checkUrl, data, opts);
|
|
};
|
|
|
|
OctoPrintSoftwareUpdateClient.prototype.check = function (force, opts) {
|
|
if (arguments.length === 1 && _.isObject(arguments[0])) {
|
|
var params = arguments[0];
|
|
force = params.force;
|
|
opts = params.opts;
|
|
}
|
|
|
|
return this.checkEntries({entries: [], force: force, opts: opts});
|
|
};
|
|
|
|
OctoPrintSoftwareUpdateClient.prototype.update = function (targets, force, opts) {
|
|
if (arguments.length === 1 && _.isObject(arguments[0])) {
|
|
var params = arguments[0];
|
|
targets = params.targets;
|
|
force = params.force;
|
|
opts = params.opts;
|
|
}
|
|
|
|
targets = targets || [];
|
|
if (typeof targets === "string") {
|
|
targets = [targets];
|
|
}
|
|
|
|
var data = {
|
|
targets: targets,
|
|
force: !!force
|
|
};
|
|
return this.base.postJson(this.updateUrl, data, opts);
|
|
};
|
|
|
|
OctoPrintSoftwareUpdateClient.prototype.cancelQueued = function (targets, opts) {
|
|
if (arguments.length === 1 && _.isObject(arguments[0])) {
|
|
var params = arguments[0];
|
|
targets = params.targets;
|
|
}
|
|
|
|
targets = targets || [];
|
|
if (typeof targets === "string") {
|
|
targets = [targets];
|
|
}
|
|
|
|
var data = {
|
|
command: "cancel",
|
|
targets: targets
|
|
};
|
|
return this.base.postJson(this.queuedURL, data, opts);
|
|
};
|
|
|
|
OctoPrintSoftwareUpdateClient.prototype.cancelAllQueued = function (opts) {
|
|
if (arguments.length === 1 && _.isObject(arguments[0])) {
|
|
var params = arguments[0];
|
|
opts = params.opts;
|
|
}
|
|
|
|
var data = {
|
|
command: "cancel"
|
|
};
|
|
|
|
return this.base.postJson(this.queuedURL, data, opts);
|
|
};
|
|
|
|
OctoPrintSoftwareUpdateClient.prototype.updateAll = function (force, opts) {
|
|
if (arguments.length === 1 && _.isObject(arguments[0])) {
|
|
var params = arguments[0];
|
|
force = params.force;
|
|
opts = params.opts;
|
|
}
|
|
|
|
var data = {
|
|
force: !!force
|
|
};
|
|
return this.base.postJson(this.updateUrl, data, opts);
|
|
};
|
|
|
|
OctoPrintSoftwareUpdateClient.prototype.configure = function (data, opts) {
|
|
return this.base.postJson(this.configureUrl, data, opts);
|
|
};
|
|
|
|
OctoPrintSoftwareUpdateClient.prototype.getUpdatelog = function (opts) {
|
|
return this.base.get(this.updatelogUrl, opts);
|
|
};
|
|
|
|
OctoPrintClient.registerPluginComponent(
|
|
"softwareupdate",
|
|
OctoPrintSoftwareUpdateClient
|
|
);
|
|
return OctoPrintSoftwareUpdateClient;
|
|
});
|