Migrated existing javascript application files to use client lib
TODO: Testing & Debugging
This commit is contained in:
1 parent
1678951d84
commit
bbd728c51b
28 files changed
+779
-1119
No files matched your search
@@ -1,4 +1,38 @@
|
||||
$(function() {
|
||||
OctoPrint.plugins.softwareupdate = (function($, _) {
|
||||
var exports = {};
|
||||
|
||||
var url = OctoPrint.getBlueprintUrl("softwareupdate");
|
||||
var checkUrl = url + "check";
|
||||
var updateUrl = url + "update";
|
||||
|
||||
exports.check = function(force, opts) {
|
||||
return OctoPrint.get(checkUrl + ((!!force) ? "?force=true" : ""), opts);
|
||||
};
|
||||
|
||||
exports.update = function(entries, force, opts) {
|
||||
entries = entries || [];
|
||||
if (typeof entries == "string") {
|
||||
entries = [entries];
|
||||
}
|
||||
|
||||
var data = {
|
||||
entries: entries,
|
||||
force: !!force
|
||||
};
|
||||
return OctoPrint.postJson(updateUrl, data, opts);
|
||||
};
|
||||
|
||||
exports.updateAll = function(force, opts) {
|
||||
var data = {
|
||||
force: !!force
|
||||
};
|
||||
return OctoPrint.postJson(updateUrl, data, opts);
|
||||
};
|
||||
|
||||
return exports;
|
||||
})($, _);
|
||||
|
||||
function SoftwareUpdateViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
@@ -221,20 +255,10 @@ $(function() {
|
||||
|
||||
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) {
|
||||
OctoPrint.plugins.softwareupdate.check(force)
|
||||
.done(function(data) {
|
||||
self.fromCheckResponse(data, ignoreSeen, showIfNothingNew);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
self._markNotificationAsSeen = function(data) {
|
||||
@@ -285,13 +309,12 @@ $(function() {
|
||||
};
|
||||
self._showPopup(options);
|
||||
|
||||
$.ajax({
|
||||
url: PLUGIN_BASEURL + "softwareupdate/update",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({force: (force == true)}),
|
||||
error: function() {
|
||||
OctoPrint.plugins.softwareupdate.updateAll(force)
|
||||
.done(function(data) {
|
||||
self.currentlyBeingUpdated = data.checks;
|
||||
self._markWorking(gettext("Updating..."), gettext("Updating, please wait."));
|
||||
})
|
||||
.fail(function() {
|
||||
self.updateInProgress = false;
|
||||
self._showPopup({
|
||||
title: gettext("Update not started!"),
|
||||
@@ -302,12 +325,7 @@ $(function() {
|
||||
sticker: false
|
||||
}
|
||||
});
|
||||
},
|
||||
success: function(data) {
|
||||
self.currentlyBeingUpdated = data.checks;
|
||||
self._markWorking(gettext("Updating..."), gettext("Updating, please wait."));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
self.update = function(force) {
|
||||
|
||||
Reference in new issue
Block a user