WIP: More work on the documentation of the js client lib

This commit is contained in:
Gina Häußge committed 2016-06-30 12:06:08 +02:00
1 parent b8405becb3
commit cec2f7d917
14 files changed
+533 -38

No files matched your search

+3 -3
View File
@@ -83,13 +83,13 @@
return issueFileCommand(location, filename, "move", { destination: destination }, opts);
},
createFolder: function (location, name, path) {
createFolder: function (location, name, path, opts) {
var data = "foldername=" + name;
if (path != undefined && path != "") {
data = "foldername:" + path + "/" + name;
data = "foldername=" + path + "/" + name;
}
return OctoPrint.post(resourceForLocation(location), data);
return OctoPrint.post(resourceForLocation(location), data, opts);
},
+14 -3
View File
@@ -7,8 +7,13 @@
})(window || this, function(OctoPrint) {
var url = "api/job";
var issueCommand = function(command, opts) {
return OctoPrint.issueCommand(url, command, {}, opts);
var issueCommand = function(command, payload, opts) {
if (arguments.length == 2) {
opts = payload;
payload = {};
}
return OctoPrint.issueCommand(url, command, payload, opts);
};
OctoPrint.job = {
@@ -22,7 +27,13 @@
return issueCommand("restart", opts);
},
pause: function(opts) {
return issueCommand("pause", opts);
return issueCommand("pause", {"action": "pause"}, opts);
},
resume: function(opts) {
return issueCommand("pause", {"action": "resume"}, opts)
},
togglePause: function(opts) {
return issueCommand("pause", {"action": "toggle"}, opts);
},
cancel: function(opts) {
return issueCommand("cancel", opts);
+21 -21
View File
@@ -28,12 +28,12 @@
};
OctoPrint.printer = {
getFullState: function (data, opts) {
data = data || {};
getFullState: function (flags, opts) {
flags = flags || {};
var history = data.history || undefined;
var limit = data.limit || undefined;
var exclude = data.exclude || undefined;
var history = flags.history || undefined;
var limit = flags.limit || undefined;
var exclude = flags.exclude || undefined;
var getUrl = url;
if (history || exclude) {
@@ -53,11 +53,11 @@
return OctoPrint.get(getUrl, opts);
},
getToolState: function (data, opts) {
data = data || {};
getToolState: function (flags, opts) {
flags = flags || {};
var history = data.history || undefined;
var limit = data.limit || undefined;
var history = flags.history || undefined;
var limit = flags.limit || undefined;
var getUrl = toolUrl;
if (history) {
@@ -70,11 +70,11 @@
return OctoPrint.get(getUrl, opts);
},
getBedState: function (data, opts) {
data = data || {};
getBedState: function (flags, opts) {
flags = flags || {};
var history = data.history || undefined;
var limit = data.limit || undefined;
var history = flags.history || undefined;
var limit = flags.limit || undefined;
var getUrl = bedUrl;
if (history) {
@@ -91,13 +91,13 @@
return OctoPrint.get(sdUrl, opts);
},
jog: function (data, opts) {
data = data || {};
jog: function (amounts, opts) {
amounts = amounts || {};
var payload = {};
if (data.x) payload.x = data.x;
if (data.y) payload.y = data.y;
if (data.z) payload.z = data.z;
if (amounts.x) payload.x = amounts.x;
if (amounts.y) payload.y = amounts.y;
if (amounts.z) payload.z = amounts.z;
return issuePrintheadCommand("jog", payload, opts);
},
@@ -172,11 +172,11 @@
return issueToolCommand("flowrate", payload, opts);
},
setBedTargetTemperature: function (temperature, opts) {
temperature = temperature || 0;
setBedTargetTemperature: function (target, opts) {
target = target || 0;
var payload = {
target: temperature
target: target
};
return issueBedCommand("target", payload, opts);
@@ -221,7 +221,7 @@ $(function() {
};
self.pause = function() {
OctoPrint.job.pause();
OctoPrint.job.togglePause();
};
self.cancel = function() {