2015-09-28 15:07:37 +00:00
|
|
|
(function (global, factory) {
|
|
|
|
|
if (typeof define === "function" && define.amd) {
|
2017-01-20 10:34:19 +00:00
|
|
|
define(["OctoPrintClient"], factory);
|
2015-09-28 15:07:37 +00:00
|
|
|
} else {
|
2017-01-20 10:34:19 +00:00
|
|
|
factory(global.OctoPrintClient);
|
2015-09-28 15:07:37 +00:00
|
|
|
}
|
2017-01-20 10:34:19 +00:00
|
|
|
})(this, function(OctoPrintClient) {
|
|
|
|
|
var OctoPrintSoftwareUpdateClient = function(base) {
|
|
|
|
|
this.base = base;
|
2015-09-28 15:07:37 +00:00
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
var url = this.base.getBlueprintUrl("softwareupdate");
|
|
|
|
|
this.checkUrl = url + "check";
|
|
|
|
|
this.updateUrl = url + "update";
|
|
|
|
|
};
|
2015-09-28 15:07:37 +00:00
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
OctoPrintSoftwareUpdateClient.prototype.checkEntries = function(entries, force, opts) {
|
2016-08-30 16:03:50 +00:00
|
|
|
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
|
|
|
|
var params = arguments[0];
|
|
|
|
|
entries = params.entries;
|
|
|
|
|
force = params.force;
|
|
|
|
|
opts = params.opts;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-30 13:45:13 +00:00
|
|
|
entries = entries || [];
|
|
|
|
|
if (typeof entries == "string") {
|
|
|
|
|
entries = [entries];
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-30 16:03:50 +00:00
|
|
|
var data = {};
|
|
|
|
|
if (!!force) {
|
|
|
|
|
data.force = true;
|
|
|
|
|
}
|
2016-03-30 13:45:13 +00:00
|
|
|
if (entries && entries.length) {
|
2016-08-30 16:03:50 +00:00
|
|
|
data.check = entries.join(",");
|
2016-03-30 13:45:13 +00:00
|
|
|
}
|
2017-01-20 10:34:19 +00:00
|
|
|
return this.base.getWithQuery(this.checkUrl, data, opts);
|
2016-03-30 13:45:13 +00:00
|
|
|
};
|
|
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
OctoPrintSoftwareUpdateClient.prototype.check = function(force, opts) {
|
2016-08-30 16:03:50 +00:00
|
|
|
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
|
|
|
|
var params = arguments[0];
|
|
|
|
|
force = params.force;
|
|
|
|
|
opts = params.opts;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
return this.checkEntries({entries: [], force: force, opts: opts});
|
2015-09-28 15:07:37 +00:00
|
|
|
};
|
|
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
OctoPrintSoftwareUpdateClient.prototype.update = function(entries, force, opts) {
|
2016-08-30 16:03:50 +00:00
|
|
|
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
|
|
|
|
var params = arguments[0];
|
|
|
|
|
entries = params.entries;
|
|
|
|
|
force = params.force;
|
|
|
|
|
opts = params.opts;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 15:07:37 +00:00
|
|
|
entries = entries || [];
|
|
|
|
|
if (typeof entries == "string") {
|
|
|
|
|
entries = [entries];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
|
entries: entries,
|
|
|
|
|
force: !!force
|
2015-09-25 11:53:42 +00:00
|
|
|
};
|
2017-01-20 10:34:19 +00:00
|
|
|
return this.base.postJson(this.updateUrl, data, opts);
|
2015-09-28 15:07:37 +00:00
|
|
|
};
|
2015-09-25 11:53:42 +00:00
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
OctoPrintSoftwareUpdateClient.prototype.updateAll = function(force, opts) {
|
2016-08-30 16:03:50 +00:00
|
|
|
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
|
|
|
|
var params = arguments[0];
|
|
|
|
|
force = params.force;
|
|
|
|
|
opts = params.opts;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 15:07:37 +00:00
|
|
|
var data = {
|
|
|
|
|
force: !!force
|
2015-09-25 11:53:42 +00:00
|
|
|
};
|
2017-01-20 10:34:19 +00:00
|
|
|
return this.base.postJson(this.updateUrl, data, opts);
|
2015-09-28 15:07:37 +00:00
|
|
|
};
|
2015-09-25 11:53:42 +00:00
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
OctoPrintClient.registerPluginComponent("softwareupdate", OctoPrintSoftwareUpdateClient);
|
|
|
|
|
return OctoPrintSoftwareUpdateClient;
|
2015-09-28 15:07:37 +00:00
|
|
|
});
|
2015-09-25 11:53:42 +00:00
|
|
|
|
2015-09-28 15:07:37 +00:00
|
|
|
$(function() {
|
2015-06-09 11:35:03 +00:00
|
|
|
function SoftwareUpdateViewModel(parameters) {
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
self.loginState = parameters[0];
|
|
|
|
|
self.printerState = parameters[1];
|
|
|
|
|
self.settings = parameters[2];
|
|
|
|
|
self.popup = undefined;
|
|
|
|
|
|
2015-12-10 13:41:46 +00:00
|
|
|
self.forceUpdate = false;
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.updateInProgress = false;
|
|
|
|
|
self.waitingForRestart = false;
|
|
|
|
|
self.restartTimeout = undefined;
|
|
|
|
|
|
|
|
|
|
self.currentlyBeingUpdated = [];
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
self.working = ko.observable(false);
|
|
|
|
|
self.workingTitle = ko.observable();
|
|
|
|
|
self.workingDialog = undefined;
|
|
|
|
|
self.workingOutput = undefined;
|
|
|
|
|
self.loglines = ko.observableArray([]);
|
|
|
|
|
|
2016-11-23 16:52:16 +00:00
|
|
|
self.checking = ko.observable(false);
|
|
|
|
|
|
2017-11-02 10:03:12 +00:00
|
|
|
self.octoprintReleasedVersion = ko.observable();
|
|
|
|
|
|
|
|
|
|
self.octoprintUnconfigured = ko.pureComputed(function() {
|
|
|
|
|
return self.error_checkoutFolder();
|
|
|
|
|
});
|
|
|
|
|
self.octoprintUnreleased = ko.pureComputed(function() {
|
|
|
|
|
return self.settings.settings.plugins.softwareupdate.octoprint_type() === "github_release"
|
|
|
|
|
&& !self.octoprintReleasedVersion();
|
|
|
|
|
});
|
2015-08-26 13:50:57 +00:00
|
|
|
|
2017-05-11 10:44:48 +00:00
|
|
|
self.cacheTimestamp = ko.observable();
|
|
|
|
|
self.cacheTimestampText = ko.pureComputed(function() {
|
|
|
|
|
return formatDate(self.cacheTimestamp());
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.config_cacheTtl = ko.observable();
|
2017-03-29 12:47:49 +00:00
|
|
|
self.config_notifyUsers = ko.observable();
|
2015-08-26 13:50:57 +00:00
|
|
|
self.config_checkoutFolder = ko.observable();
|
|
|
|
|
self.config_checkType = ko.observable();
|
2016-08-24 17:02:39 +00:00
|
|
|
self.config_releaseChannel = ko.observable();
|
2015-06-09 11:35:03 +00:00
|
|
|
|
2017-11-02 10:03:12 +00:00
|
|
|
self.error_checkoutFolder = ko.pureComputed(function() {
|
|
|
|
|
return self.config_checkType() === "git_commit"
|
|
|
|
|
&& (!self.config_checkoutFolder() || self.config_checkoutFolder().trim() === '');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
self.enable_configSave = ko.pureComputed(function() {
|
|
|
|
|
return self.config_checkType() === "github_release"
|
|
|
|
|
|| (self.config_checkType() === "git_commit" && !self.error_checkoutFolder());
|
|
|
|
|
});
|
|
|
|
|
|
2017-05-16 13:54:52 +00:00
|
|
|
self.configurationDialog = undefined;
|
|
|
|
|
self.confirmationDialog = undefined;
|
|
|
|
|
self._updateClicked = false;
|
2015-06-09 11:35:03 +00:00
|
|
|
|
2016-08-25 13:45:25 +00:00
|
|
|
self.config_availableCheckTypes = ko.observableArray([]);
|
2016-08-24 17:02:39 +00:00
|
|
|
self.config_availableReleaseChannels = ko.observableArray([]);
|
2015-08-26 13:50:57 +00:00
|
|
|
|
2015-10-08 15:08:36 +00:00
|
|
|
self.reloadOverlay = $("#reloadui_overlay");
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.versions = new ItemListHelper(
|
|
|
|
|
"plugin.softwareupdate.versions",
|
|
|
|
|
{
|
|
|
|
|
"name": function(a, b) {
|
|
|
|
|
// sorts ascending, puts octoprint first
|
2017-11-02 10:03:12 +00:00
|
|
|
if (a.key.toLocaleLowerCase() === "octoprint") return -1;
|
|
|
|
|
if (b.key.toLocaleLowerCase() === "octoprint") return 1;
|
2015-06-09 11:35:03 +00:00
|
|
|
|
|
|
|
|
if (a.displayName.toLocaleLowerCase() < b.displayName.toLocaleLowerCase()) return -1;
|
|
|
|
|
if (a.displayName.toLocaleLowerCase() > b.displayName.toLocaleLowerCase()) return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{},
|
|
|
|
|
"name",
|
|
|
|
|
[],
|
|
|
|
|
[],
|
|
|
|
|
5
|
|
|
|
|
);
|
|
|
|
|
|
2016-01-27 16:36:39 +00:00
|
|
|
self.availableAndPossible = ko.pureComputed(function() {
|
2015-12-10 13:41:46 +00:00
|
|
|
return _.filter(self.versions.items(), function(info) { return info.updateAvailable && info.updatePossible; });
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.onUserLoggedIn = function() {
|
|
|
|
|
self.performCheck();
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-29 12:47:49 +00:00
|
|
|
self.onUserLoggedOut = function() {
|
2015-06-18 15:08:56 +00:00
|
|
|
self._closePopup();
|
2017-03-29 12:47:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self._showPopup = function(options, eventListeners, singleButtonNotify) {
|
|
|
|
|
singleButtonNotify = singleButtonNotify || false;
|
|
|
|
|
|
|
|
|
|
self._closePopup();
|
|
|
|
|
|
|
|
|
|
if (singleButtonNotify) {
|
|
|
|
|
self.popup = PNotify.singleButtonNotify(options);
|
|
|
|
|
} else {
|
|
|
|
|
self.popup = new PNotify(options);
|
|
|
|
|
}
|
2015-06-09 11:35:03 +00:00
|
|
|
|
|
|
|
|
if (eventListeners) {
|
|
|
|
|
var popupObj = self.popup.get();
|
|
|
|
|
_.each(eventListeners, function(value, key) {
|
|
|
|
|
popupObj.on(key, value);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self._updatePopup = function(options) {
|
|
|
|
|
if (self.popup === undefined) {
|
|
|
|
|
self._showPopup(options);
|
|
|
|
|
} else {
|
|
|
|
|
self.popup.update(options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-18 15:08:56 +00:00
|
|
|
self._closePopup = function() {
|
|
|
|
|
if (self.popup !== undefined) {
|
|
|
|
|
self.popup.remove();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.showPluginSettings = function() {
|
|
|
|
|
self._copyConfig();
|
|
|
|
|
self.configurationDialog.modal();
|
|
|
|
|
};
|
|
|
|
|
|
2015-09-01 15:18:08 +00:00
|
|
|
self.savePluginSettings = function(viewModel, event) {
|
|
|
|
|
var target = $(event.target);
|
2017-05-13 18:18:40 +00:00
|
|
|
target.prepend('<i class="fa fa-spinner fa-spin"></i> ');
|
2015-09-01 15:18:08 +00:00
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
var data = {
|
|
|
|
|
plugins: {
|
|
|
|
|
softwareupdate: {
|
2015-08-26 13:50:57 +00:00
|
|
|
cache_ttl: parseInt(self.config_cacheTtl()),
|
2017-03-29 12:47:49 +00:00
|
|
|
notify_users: self.config_notifyUsers(),
|
2016-08-24 17:02:39 +00:00
|
|
|
octoprint_type: self.config_checkType(),
|
2017-11-02 10:03:12 +00:00
|
|
|
octoprint_release_channel: self.config_releaseChannel(),
|
|
|
|
|
octoprint_checkout_folder: self.config_checkoutFolder()
|
2015-06-09 11:35:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2015-09-01 15:18:08 +00:00
|
|
|
self.settings.saveData(data, {
|
|
|
|
|
success: function() {
|
|
|
|
|
self.configurationDialog.modal("hide");
|
|
|
|
|
self._copyConfig();
|
|
|
|
|
self.performCheck();
|
|
|
|
|
},
|
|
|
|
|
complete: function() {
|
2017-05-13 18:18:40 +00:00
|
|
|
$("i.fa-spinner", target).remove();
|
2015-09-01 15:18:08 +00:00
|
|
|
},
|
|
|
|
|
sending: true
|
2015-08-26 13:50:57 +00:00
|
|
|
});
|
2015-06-09 11:35:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self._copyConfig = function() {
|
2017-11-02 10:03:12 +00:00
|
|
|
var availableCheckTypes = [{"key": "github_release", "name": gettext("Release")},
|
2016-08-25 13:45:25 +00:00
|
|
|
{"key": "git_commit", "name": gettext("Commit")}];
|
|
|
|
|
self.config_availableCheckTypes(availableCheckTypes);
|
|
|
|
|
|
2016-08-25 11:32:18 +00:00
|
|
|
var availableReleaseChannels = [];
|
|
|
|
|
_.each(self.settings.settings.plugins.softwareupdate.octoprint_branch_mappings(), function(mapping) {
|
|
|
|
|
availableReleaseChannels.push({"key": mapping.branch(), "name": gettext(mapping.name() || mapping.branch())});
|
|
|
|
|
});
|
|
|
|
|
self.config_availableReleaseChannels(availableReleaseChannels);
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.config_cacheTtl(self.settings.settings.plugins.softwareupdate.cache_ttl());
|
2017-03-29 12:47:49 +00:00
|
|
|
self.config_notifyUsers(self.settings.settings.plugins.softwareupdate.notify_users());
|
2017-11-02 10:03:12 +00:00
|
|
|
|
2015-08-26 13:50:57 +00:00
|
|
|
self.config_checkType(self.settings.settings.plugins.softwareupdate.octoprint_type());
|
2016-08-24 17:02:39 +00:00
|
|
|
self.config_releaseChannel(self.settings.settings.plugins.softwareupdate.octoprint_release_channel());
|
2017-11-02 10:03:12 +00:00
|
|
|
self.config_checkoutFolder(self.settings.settings.plugins.softwareupdate.octoprint_checkout_folder());
|
2015-06-09 11:35:03 +00:00
|
|
|
};
|
|
|
|
|
|
2016-03-30 09:26:58 +00:00
|
|
|
self._copyConfigBack = function() {
|
|
|
|
|
self.settings.settings.plugins.softwareupdate.octoprint_checkout_folder(self.config_checkoutFolder());
|
|
|
|
|
self.settings.settings.plugins.softwareupdate.octoprint_type(self.config_checkType());
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-18 15:08:56 +00:00
|
|
|
self.fromCheckResponse = function(data, ignoreSeen, showIfNothingNew) {
|
2017-05-11 10:44:48 +00:00
|
|
|
self.cacheTimestamp(data.timestamp);
|
|
|
|
|
|
2015-06-18 15:08:56 +00:00
|
|
|
var versions = [];
|
|
|
|
|
_.each(data.information, function(value, key) {
|
|
|
|
|
value["key"] = key;
|
|
|
|
|
|
2017-11-02 10:03:12 +00:00
|
|
|
if (!value.hasOwnProperty("displayName") || value.displayName === "") {
|
2015-06-18 15:08:56 +00:00
|
|
|
value.displayName = value.key;
|
|
|
|
|
}
|
2017-11-02 10:03:12 +00:00
|
|
|
if (!value.hasOwnProperty("displayVersion") || value.displayVersion === "") {
|
2015-06-18 15:08:56 +00:00
|
|
|
value.displayVersion = value.information.local.name;
|
|
|
|
|
}
|
2017-11-02 10:03:12 +00:00
|
|
|
if (!value.hasOwnProperty("releaseNotes") || value.releaseNotes === "") {
|
2015-12-10 13:41:46 +00:00
|
|
|
value.releaseNotes = undefined;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-10 16:12:02 +00:00
|
|
|
var fullNameTemplate = gettext("%(name)s: %(version)s");
|
|
|
|
|
value.fullNameLocal = _.sprintf(fullNameTemplate, {name: value.displayName, version: value.displayVersion});
|
|
|
|
|
|
|
|
|
|
var fullNameRemoteVars = {name: value.displayName, version: gettext("unknown")};
|
|
|
|
|
if (value.hasOwnProperty("information") && value.information.hasOwnProperty("remote") && value.information.remote.hasOwnProperty("name")) {
|
|
|
|
|
fullNameRemoteVars.version = value.information.remote.name;
|
|
|
|
|
}
|
|
|
|
|
value.fullNameRemote = _.sprintf(fullNameTemplate, fullNameRemoteVars);
|
2015-06-18 15:08:56 +00:00
|
|
|
|
|
|
|
|
versions.push(value);
|
|
|
|
|
});
|
|
|
|
|
self.versions.updateItems(versions);
|
|
|
|
|
|
2015-08-26 13:50:57 +00:00
|
|
|
var octoprint = data.information["octoprint"];
|
2017-11-02 10:03:12 +00:00
|
|
|
self.octoprintReleasedVersion(!octoprint || octoprint.released_version);
|
2015-08-26 13:50:57 +00:00
|
|
|
|
2017-03-29 12:47:49 +00:00
|
|
|
if (!self.loginState.isAdmin() && !self.settings.settings.plugins.softwareupdate.notify_users()) return;
|
|
|
|
|
|
2017-11-02 10:03:12 +00:00
|
|
|
if (data.status === "updateAvailable" || data.status === "updatePossible") {
|
2015-12-10 13:41:46 +00:00
|
|
|
var text = "<div class='softwareupdate_notification'>" + gettext("There are updates available for the following components:");
|
2015-06-18 15:08:56 +00:00
|
|
|
|
2017-05-29 10:37:50 +00:00
|
|
|
text += "<ul class='fa-ul'>";
|
2015-06-18 15:08:56 +00:00
|
|
|
_.each(self.versions.items(), function(update_info) {
|
|
|
|
|
if (update_info.updateAvailable) {
|
2015-12-10 13:41:46 +00:00
|
|
|
text += "<li>"
|
2017-05-29 10:37:50 +00:00
|
|
|
+ "<i class='fa fa-li " + (update_info.updatePossible ? "fa-check" : "fa-remove")+ "'></i>"
|
2015-12-10 16:12:02 +00:00
|
|
|
+ "<span class='name' title='" + update_info.fullNameRemote + "'>" + update_info.fullNameRemote + "</span>"
|
2015-12-10 13:41:46 +00:00
|
|
|
+ (update_info.releaseNotes ? "<a href=\"" + update_info.releaseNotes + "\" target=\"_blank\">" + gettext("Release Notes") + "</a>" : "")
|
|
|
|
|
+ "</li>";
|
2015-06-18 15:08:56 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
text += "</ul>";
|
|
|
|
|
|
2017-05-29 10:37:50 +00:00
|
|
|
text += "<p><small>" + gettext("Those components marked with <i class=\"fa fa-check\"></i> can be updated directly.") + "</small></p>";
|
2017-03-29 12:47:49 +00:00
|
|
|
|
|
|
|
|
if (!self.loginState.isAdmin()) {
|
|
|
|
|
text += "<p><small>" + gettext("To have updates applied, get in touch with an administrator of this OctoPrint instance.") + "</small></p>";
|
|
|
|
|
}
|
2015-06-18 15:08:56 +00:00
|
|
|
|
2015-12-10 13:41:46 +00:00
|
|
|
text += "</div>";
|
|
|
|
|
|
2015-06-18 15:08:56 +00:00
|
|
|
var options = {
|
|
|
|
|
title: gettext("Update Available"),
|
|
|
|
|
text: text,
|
|
|
|
|
hide: false
|
|
|
|
|
};
|
|
|
|
|
var eventListeners = {};
|
|
|
|
|
|
2017-03-29 12:47:49 +00:00
|
|
|
var singleButtonNotify = false;
|
2017-11-02 10:03:12 +00:00
|
|
|
if (data.status === "updatePossible" && self.loginState.isAdmin()) {
|
2017-03-29 12:47:49 +00:00
|
|
|
// if update is possible and user is admin, add action buttons for ignore and update
|
2015-06-18 15:08:56 +00:00
|
|
|
options["confirm"] = {
|
|
|
|
|
confirm: true,
|
|
|
|
|
buttons: [{
|
|
|
|
|
text: gettext("Ignore"),
|
|
|
|
|
click: function() {
|
|
|
|
|
self._markNotificationAsSeen(data.information);
|
|
|
|
|
self._showPopup({
|
2015-07-07 16:26:06 +00:00
|
|
|
text: gettext("You can make this message display again via \"Settings\" > \"Software Update\" > \"Check for update now\"")
|
2015-06-18 15:08:56 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
text: gettext("Update now"),
|
|
|
|
|
addClass: "btn-primary",
|
2017-05-16 13:54:52 +00:00
|
|
|
click: function() {
|
|
|
|
|
if (self._updateClicked) return;
|
|
|
|
|
self._updateClicked = true;
|
|
|
|
|
self.update();
|
|
|
|
|
}
|
2015-06-18 15:08:56 +00:00
|
|
|
}]
|
|
|
|
|
};
|
|
|
|
|
options["buttons"] = {
|
|
|
|
|
closer: false,
|
|
|
|
|
sticker: false
|
|
|
|
|
};
|
2017-03-29 12:47:49 +00:00
|
|
|
} else {
|
|
|
|
|
// if update is not possible or user is not admin, only add ignore button
|
|
|
|
|
options["confirm"] = {
|
|
|
|
|
confirm: true,
|
|
|
|
|
buttons: [{
|
|
|
|
|
text: gettext("Ignore"),
|
|
|
|
|
click: function(notice) {
|
|
|
|
|
notice.remove();
|
|
|
|
|
self._markNotificationAsSeen(data.information);
|
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
};
|
|
|
|
|
options["buttons"] = {
|
|
|
|
|
closer: false,
|
|
|
|
|
sticker: false
|
|
|
|
|
};
|
|
|
|
|
singleButtonNotify = true;
|
2015-06-18 15:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-24 10:28:45 +00:00
|
|
|
if ((ignoreSeen || !self._hasNotificationBeenSeen(data.information)) && !OctoPrint.coreui.wizardOpen) {
|
2017-03-29 12:47:49 +00:00
|
|
|
self._showPopup(options, eventListeners, singleButtonNotify);
|
2015-06-18 15:08:56 +00:00
|
|
|
}
|
2017-11-02 10:03:12 +00:00
|
|
|
} else if (data.status === "current") {
|
2015-06-18 15:08:56 +00:00
|
|
|
if (showIfNothingNew) {
|
|
|
|
|
self._showPopup({
|
|
|
|
|
title: gettext("Everything is up-to-date"),
|
|
|
|
|
type: "success"
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
self._closePopup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.performCheck = function(showIfNothingNew, force, ignoreSeen) {
|
2017-03-29 12:47:49 +00:00
|
|
|
if (!self.loginState.isAdmin() && !self.settings.settings.plugins.softwareupdate.notify_users()) return;
|
|
|
|
|
|
2016-11-23 16:52:16 +00:00
|
|
|
self.checking(true);
|
2015-09-25 11:53:42 +00:00
|
|
|
OctoPrint.plugins.softwareupdate.check(force)
|
|
|
|
|
.done(function(data) {
|
2015-06-18 15:08:56 +00:00
|
|
|
self.fromCheckResponse(data, ignoreSeen, showIfNothingNew);
|
2016-11-23 16:52:16 +00:00
|
|
|
})
|
|
|
|
|
.always(function() {
|
|
|
|
|
self.checking(false);
|
2015-09-25 11:53:42 +00:00
|
|
|
});
|
2015-06-09 11:35:03 +00:00
|
|
|
};
|
|
|
|
|
|
2017-07-19 15:19:36 +00:00
|
|
|
self.iconTitleForEntry = function(data) {
|
|
|
|
|
if (data.updatePossible) {
|
|
|
|
|
return "";
|
|
|
|
|
} else if (!data.online && data.information && data.information.needs_online) {
|
|
|
|
|
return gettext("No internet connection");
|
|
|
|
|
} else if (data.error) {
|
|
|
|
|
return self.errorTextForEntry(data);
|
|
|
|
|
} else {
|
|
|
|
|
return gettext("Update not possible");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.errorTextForEntry = function(data) {
|
|
|
|
|
if (!data.error) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (data.error) {
|
|
|
|
|
case "unknown_check": {
|
|
|
|
|
return gettext("Unknown update check, configuration ok?");
|
|
|
|
|
}
|
|
|
|
|
case "needs_online": {
|
|
|
|
|
return gettext("Cannot check for update, need online connection");
|
|
|
|
|
}
|
|
|
|
|
case "network": {
|
|
|
|
|
return gettext("Network error while checking for update");
|
|
|
|
|
}
|
|
|
|
|
case "unknown": {
|
|
|
|
|
return gettext("Unknown error while checking for update, please check the logs");
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self._markNotificationAsSeen = function(data) {
|
|
|
|
|
if (!Modernizr.localstorage)
|
|
|
|
|
return false;
|
2017-03-29 12:47:49 +00:00
|
|
|
if (!self.loginState.isUser())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
var currentString = localStorage["plugin.softwareupdate.seen_information"];
|
|
|
|
|
var current;
|
|
|
|
|
if (currentString === undefined) {
|
|
|
|
|
current = {};
|
|
|
|
|
} else {
|
|
|
|
|
current = JSON.parse(currentString);
|
|
|
|
|
}
|
|
|
|
|
current[self.loginState.username()] = self._informationToRemoteVersions(data);
|
|
|
|
|
localStorage["plugin.softwareupdate.seen_information"] = JSON.stringify(current);
|
2015-06-09 11:35:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self._hasNotificationBeenSeen = function(data) {
|
|
|
|
|
if (!Modernizr.localstorage)
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-11-02 10:03:12 +00:00
|
|
|
if (localStorage["plugin.softwareupdate.seen_information"] === undefined)
|
2015-06-09 11:35:03 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
var knownData = JSON.parse(localStorage["plugin.softwareupdate.seen_information"]);
|
2017-03-29 12:47:49 +00:00
|
|
|
|
|
|
|
|
if (!self.loginState.isUser())
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
var userData = knownData[self.loginState.username()];
|
|
|
|
|
if (userData === undefined)
|
|
|
|
|
return false;
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
var freshData = self._informationToRemoteVersions(data);
|
|
|
|
|
|
|
|
|
|
var hasBeenSeen = true;
|
|
|
|
|
_.each(freshData, function(value, key) {
|
2017-11-02 10:03:12 +00:00
|
|
|
if (!_.has(userData, key) || userData[key] !== freshData[key]) {
|
2015-06-09 11:35:03 +00:00
|
|
|
hasBeenSeen = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return hasBeenSeen;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self._informationToRemoteVersions = function(data) {
|
|
|
|
|
var result = {};
|
|
|
|
|
_.each(data, function(value, key) {
|
|
|
|
|
result[key] = value.information.remote.value;
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-10 13:41:46 +00:00
|
|
|
self.performUpdate = function(force, items) {
|
2017-03-29 12:47:49 +00:00
|
|
|
if (!self.loginState.isAdmin()) return;
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.updateInProgress = true;
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
title: gettext("Updating..."),
|
|
|
|
|
text: gettext("Now updating, please wait."),
|
2017-05-13 18:18:40 +00:00
|
|
|
icon: "fa fa-cog fa-spin",
|
2015-06-09 11:35:03 +00:00
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
closer: false,
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
self._showPopup(options);
|
|
|
|
|
|
2015-12-10 13:45:16 +00:00
|
|
|
OctoPrint.plugins.softwareupdate.updateAll(force, items)
|
2015-09-25 11:53:42 +00:00
|
|
|
.done(function(data) {
|
|
|
|
|
self.currentlyBeingUpdated = data.checks;
|
|
|
|
|
self._markWorking(gettext("Updating..."), gettext("Updating, please wait."));
|
|
|
|
|
})
|
|
|
|
|
.fail(function() {
|
2015-06-09 11:35:03 +00:00
|
|
|
self.updateInProgress = false;
|
|
|
|
|
self._showPopup({
|
|
|
|
|
title: gettext("Update not started!"),
|
|
|
|
|
text: gettext("The update could not be started. Is it already active? Please consult the log for details."),
|
|
|
|
|
type: "error",
|
|
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-09-25 11:53:42 +00:00
|
|
|
});
|
2015-06-09 11:35:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.update = function(force) {
|
2017-05-16 13:54:52 +00:00
|
|
|
if (self.updateInProgress) {
|
|
|
|
|
self._updateClicked = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!self.loginState.isAdmin()) {
|
|
|
|
|
self._updateClicked = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-06-09 11:35:03 +00:00
|
|
|
|
|
|
|
|
if (self.printerState.isPrinting()) {
|
|
|
|
|
self._showPopup({
|
|
|
|
|
title: gettext("Can't update while printing"),
|
|
|
|
|
text: gettext("A print job is currently in progress. Updating will be prevented until it is done."),
|
|
|
|
|
type: "error"
|
|
|
|
|
});
|
2017-05-16 13:54:52 +00:00
|
|
|
self._updateClicked = false;
|
2015-06-09 11:35:03 +00:00
|
|
|
} else {
|
2015-12-10 13:41:46 +00:00
|
|
|
self.forceUpdate = (force == true);
|
|
|
|
|
self.confirmationDialog.modal("show");
|
2015-06-09 11:35:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-10 13:41:46 +00:00
|
|
|
self.confirmUpdate = function() {
|
|
|
|
|
self.performUpdate(self.forceUpdate,
|
2015-12-10 13:45:16 +00:00
|
|
|
_.map(self.availableAndPossible(), function(info) { return info.key }));
|
2017-05-16 13:54:52 +00:00
|
|
|
self.confirmationDialog.modal("hide");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.confirmationHidden = function() {
|
|
|
|
|
self._updateClicked = false;
|
2015-12-10 13:45:16 +00:00
|
|
|
};
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
self._showWorkingDialog = function(title) {
|
|
|
|
|
if (!self.loginState.isAdmin()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.working(true);
|
|
|
|
|
self.workingTitle(title);
|
2016-11-23 14:11:35 +00:00
|
|
|
self.workingDialog.modal({keyboard: false, backdrop: "static", show: true});
|
2015-07-03 11:59:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self._markWorking = function(title, line, stream) {
|
|
|
|
|
if (stream === undefined) {
|
|
|
|
|
stream = "message";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.loglines.removeAll();
|
|
|
|
|
self.loglines.push({line: line, stream: stream});
|
|
|
|
|
self._showWorkingDialog(title);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self._markDone = function(line, stream) {
|
|
|
|
|
if (stream === undefined) {
|
|
|
|
|
stream = "message";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.working(false);
|
|
|
|
|
self.loglines.push({line: "", stream: stream});
|
|
|
|
|
self.loglines.push({line: line, stream: stream});
|
|
|
|
|
self._scrollWorkingOutputToEnd();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self._scrollWorkingOutputToEnd = function() {
|
2017-05-10 07:25:53 +00:00
|
|
|
self.workingOutput.scrollTop(self.workingOutput[0].scrollHeight - self.workingOutput.height());
|
2015-07-03 11:59:22 +00:00
|
|
|
};
|
|
|
|
|
|
2016-11-24 10:56:37 +00:00
|
|
|
self.onBeforeWizardTabChange = function(next, current) {
|
2017-11-02 10:03:12 +00:00
|
|
|
if (next && next === "#wizard_plugin_softwareupdate") {
|
2016-03-30 09:26:58 +00:00
|
|
|
// switching to the plugin wizard tab
|
|
|
|
|
self._copyConfig();
|
2017-11-02 10:03:12 +00:00
|
|
|
} else if (current && current === "#wizard_plugin_softwareupdate") {
|
2016-03-30 09:26:58 +00:00
|
|
|
// switching away from the plugin wizard tab
|
|
|
|
|
self._copyConfigBack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-30 13:45:13 +00:00
|
|
|
self.onAfterWizardFinish = function() {
|
|
|
|
|
// we might have changed our config, so we need to refresh our check data from the server
|
|
|
|
|
self.performCheck();
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
self.onStartup = function() {
|
|
|
|
|
self.workingDialog = $("#settings_plugin_softwareupdate_workingdialog");
|
|
|
|
|
self.workingOutput = $("#settings_plugin_softwareupdate_workingdialog_output");
|
2017-05-16 13:54:52 +00:00
|
|
|
self.configurationDialog = $("#settings_plugin_softwareupdate_configurationdialog");
|
|
|
|
|
self.confirmationDialog = $("#softwareupdate_confirmation_dialog");
|
|
|
|
|
|
|
|
|
|
self.confirmationDialog.on("hidden", self.confirmationHidden);
|
2015-07-03 11:59:22 +00:00
|
|
|
};
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.onServerDisconnect = function() {
|
|
|
|
|
if (self.restartTimeout !== undefined) {
|
|
|
|
|
clearTimeout(self.restartTimeout);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-19 16:39:23 +00:00
|
|
|
self.onEventConnectivityChanged = function(payload) {
|
|
|
|
|
if (!payload || !payload.new) return;
|
|
|
|
|
self.performCheck();
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.onDataUpdaterReconnect = function() {
|
|
|
|
|
if (self.waitingForRestart) {
|
|
|
|
|
self.waitingForRestart = false;
|
|
|
|
|
self.updateInProgress = false;
|
2015-10-08 15:08:36 +00:00
|
|
|
if (!self.reloadOverlay.is(":visible")) {
|
|
|
|
|
self.reloadOverlay.show();
|
|
|
|
|
}
|
2015-06-09 11:35:03 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.onDataUpdaterPluginMessage = function(plugin, data) {
|
2017-11-02 10:03:12 +00:00
|
|
|
if (plugin !== "softwareupdate") {
|
2015-06-09 11:35:03 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var messageType = data.type;
|
|
|
|
|
var messageData = data.data;
|
|
|
|
|
|
|
|
|
|
var options = undefined;
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
var restartType = undefined;
|
|
|
|
|
var title = undefined;
|
|
|
|
|
var text = undefined;
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
switch (messageType) {
|
2015-07-03 11:59:22 +00:00
|
|
|
case "loglines": {
|
|
|
|
|
if (self.working()) {
|
|
|
|
|
_.each(messageData.loglines, function(line) {
|
2016-11-23 13:28:50 +00:00
|
|
|
self.loglines.push(self._preprocessLine(line));
|
2015-07-03 11:59:22 +00:00
|
|
|
});
|
|
|
|
|
self._scrollWorkingOutputToEnd();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-06-09 11:35:03 +00:00
|
|
|
case "updating": {
|
|
|
|
|
console.log(JSON.stringify(messageData));
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
if (!self.working()) {
|
|
|
|
|
self._markWorking(gettext("Updating..."), gettext("Updating, please wait."));
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-03 13:25:36 +00:00
|
|
|
text = _.sprintf(gettext("Now updating %(name)s to %(version)s"), {name: messageData.name, version: messageData.version});
|
2015-07-03 11:59:22 +00:00
|
|
|
self.loglines.push({line: "", stream: "separator"});
|
|
|
|
|
self.loglines.push({line: _.repeat("+", text.length), stream: "separator"});
|
|
|
|
|
self.loglines.push({line: text, stream: "message"});
|
|
|
|
|
self.loglines.push({line: _.repeat("+", text.length), stream: "separator"});
|
2016-11-23 13:28:50 +00:00
|
|
|
self._scrollWorkingOutputToEnd();
|
2015-06-09 11:35:03 +00:00
|
|
|
self._updatePopup({
|
2015-07-03 11:53:59 +00:00
|
|
|
text: text,
|
|
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
2015-06-09 11:35:03 +00:00
|
|
|
});
|
2015-07-03 11:59:22 +00:00
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "restarting": {
|
|
|
|
|
console.log(JSON.stringify(messageData));
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
title = gettext("Update successful, restarting!");
|
|
|
|
|
text = gettext("The update finished successfully and the server will now be restarted.");
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
options = {
|
2015-07-03 11:59:22 +00:00
|
|
|
title: title,
|
|
|
|
|
text: text,
|
2015-06-09 11:35:03 +00:00
|
|
|
type: "success",
|
|
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
self.loglines.push({line: text, stream: "message"});
|
2016-11-23 13:28:50 +00:00
|
|
|
self._scrollWorkingOutputToEnd();
|
2015-07-03 11:59:22 +00:00
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self.waitingForRestart = true;
|
|
|
|
|
self.restartTimeout = setTimeout(function() {
|
2015-07-03 11:59:22 +00:00
|
|
|
title = gettext("Restart failed");
|
|
|
|
|
text = gettext("The server apparently did not restart by itself, you'll have to do it manually. Please consult the log file on what went wrong.");
|
|
|
|
|
|
2015-06-09 11:35:03 +00:00
|
|
|
self._showPopup({
|
2015-07-03 11:59:22 +00:00
|
|
|
title: title,
|
|
|
|
|
text: text,
|
2015-06-09 11:35:03 +00:00
|
|
|
type: "error",
|
|
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
self.waitingForRestart = false;
|
2015-07-03 11:59:22 +00:00
|
|
|
|
|
|
|
|
self._markDone(text, "message_error");
|
2015-09-02 09:34:32 +00:00
|
|
|
}, 60000);
|
2015-06-09 11:35:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "restart_manually": {
|
|
|
|
|
console.log(JSON.stringify(messageData));
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
restartType = messageData.restart_type;
|
|
|
|
|
text = gettext("The update finished successfully, please restart OctoPrint now.");
|
2017-11-02 10:03:12 +00:00
|
|
|
if (restartType === "environment") {
|
2015-06-09 11:35:03 +00:00
|
|
|
text = gettext("The update finished successfully, please reboot the server now.");
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
title = gettext("Update successful, restart required!");
|
2015-06-09 11:35:03 +00:00
|
|
|
options = {
|
2015-07-03 11:59:22 +00:00
|
|
|
title: title,
|
2015-06-09 11:35:03 +00:00
|
|
|
text: text,
|
|
|
|
|
type: "success",
|
|
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
self.updateInProgress = false;
|
2015-07-03 11:59:22 +00:00
|
|
|
self._markDone(text);
|
2015-06-09 11:35:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "restart_failed": {
|
2015-07-03 11:59:22 +00:00
|
|
|
restartType = messageData.restart_type;
|
|
|
|
|
text = gettext("Restarting OctoPrint failed, please restart it manually. You might also want to consult the log file on what went wrong here.");
|
2017-11-02 10:03:12 +00:00
|
|
|
if (restartType === "environment") {
|
2015-06-09 11:35:03 +00:00
|
|
|
text = gettext("Rebooting the server failed, please reboot it manually. You might also want to consult the log file on what went wrong here.");
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-03 11:59:22 +00:00
|
|
|
title = gettext("Restart failed");
|
2015-06-09 11:35:03 +00:00
|
|
|
options = {
|
2015-07-03 11:59:22 +00:00
|
|
|
title: title,
|
|
|
|
|
test: text,
|
2015-06-09 11:35:03 +00:00
|
|
|
type: "error",
|
|
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
self.waitingForRestart = false;
|
|
|
|
|
self.updateInProgress = false;
|
2015-07-03 11:59:22 +00:00
|
|
|
self._markDone(text, "message_error");
|
2015-06-09 11:35:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "success": {
|
2015-07-03 11:59:22 +00:00
|
|
|
title = gettext("Update successful!");
|
|
|
|
|
text = gettext("The update finished successfully.");
|
2015-06-09 11:35:03 +00:00
|
|
|
options = {
|
2015-07-03 11:59:22 +00:00
|
|
|
title: title,
|
|
|
|
|
text: text,
|
2015-06-09 11:35:03 +00:00
|
|
|
type: "success",
|
|
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
self.updateInProgress = false;
|
2015-07-03 11:59:22 +00:00
|
|
|
self._markDone(text);
|
2015-06-09 11:35:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "error": {
|
2015-07-03 11:59:22 +00:00
|
|
|
title = gettext("Update failed!");
|
|
|
|
|
text = gettext("The update did not finish successfully. Please consult the log for details.");
|
2015-06-09 11:35:03 +00:00
|
|
|
self._showPopup({
|
2015-07-03 11:59:22 +00:00
|
|
|
title: title,
|
|
|
|
|
text: text,
|
2015-06-09 11:35:03 +00:00
|
|
|
type: "error",
|
|
|
|
|
hide: false,
|
|
|
|
|
buttons: {
|
|
|
|
|
sticker: false
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
self.updateInProgress = false;
|
2015-07-03 11:59:22 +00:00
|
|
|
self._markDone(text, "message_error");
|
2015-06-09 11:35:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2015-06-18 15:08:56 +00:00
|
|
|
case "update_versions": {
|
|
|
|
|
self.performCheck();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-06-09 11:35:03 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-02 10:03:12 +00:00
|
|
|
if (options !== undefined) {
|
2015-06-09 11:35:03 +00:00
|
|
|
self._showPopup(options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-10 10:15:52 +00:00
|
|
|
self._forcedStdoutPatterns = ["You are using pip version .*?, however version .*? is available\.",
|
|
|
|
|
"You should consider upgrading via the '.*?' command\.",
|
|
|
|
|
"'.*?' does not exist -- can't clean it"];
|
|
|
|
|
self._forcedStdoutLine = new RegExp(self._forcedStdoutPatterns.join("|"));
|
2016-11-23 13:28:50 +00:00
|
|
|
self._preprocessLine = function(line) {
|
2017-11-02 10:03:12 +00:00
|
|
|
if (line.stream === "stderr" && line.line.match(self._forcedStdoutLine)) {
|
2016-11-23 13:28:50 +00:00
|
|
|
line.stream = "stdout";
|
|
|
|
|
}
|
|
|
|
|
return line;
|
|
|
|
|
}
|
2015-06-09 11:35:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// view model class, parameters for constructor, container to bind to
|
2015-12-10 13:41:46 +00:00
|
|
|
ADDITIONAL_VIEWMODELS.push([
|
|
|
|
|
SoftwareUpdateViewModel,
|
|
|
|
|
["loginStateViewModel", "printerStateViewModel", "settingsViewModel"],
|
2016-03-30 09:26:58 +00:00
|
|
|
["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog", "#wizard_plugin_softwareupdate"]
|
2015-12-10 13:41:46 +00:00
|
|
|
]);
|
2015-06-18 10:05:11 +00:00
|
|
|
});
|