More docs & client fixes
This commit is contained in:
parent
4e69b260a1
commit
82ae52e619
6 changed files with 207 additions and 15 deletions
|
|
@ -102,7 +102,7 @@
|
|||
|
||||
Instructs the server to decrease the message rate by 500ms.
|
||||
|
||||
.. sec-jsclient-socket-throttling:
|
||||
.. _sec-jsclient-socket-throttling:
|
||||
|
||||
Communication Throttling
|
||||
========================
|
||||
|
|
|
|||
|
|
@ -3,26 +3,87 @@
|
|||
:mod:`OctoPrint.timelapse`
|
||||
--------------------------
|
||||
|
||||
.. todo::
|
||||
.. js:function:: OctoPrint.timelapse.get(unrendered, opts)
|
||||
|
||||
Needs to be documented
|
||||
Get a list of all timelapses and the current timelapse config.
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.get(opts)
|
||||
If ``unrendered`` is true, also retrieve the list of unrendered
|
||||
timelapses.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.list(opts)
|
||||
|
||||
Get the lists of rendered and unrendered timelapses. The returned promis
|
||||
will be resolved with an object containing the properties ``rendered``
|
||||
which will have the list of rendered timelapses, and ``unrendered`` which
|
||||
will have the list of unrendered timelapses.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.listRendered(opts)
|
||||
|
||||
Get the list of rendered timelapses.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.listUnrendered(opts)
|
||||
|
||||
Get the list of unrendered timelapses.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.download(filename, opts)
|
||||
|
||||
Download the rendered timelapse ``filename``.
|
||||
|
||||
:param string filename: The name of the rendered timelapse to download
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.delete(filename, opts)
|
||||
|
||||
Delete the rendered timelapse ``filename``.
|
||||
|
||||
:param string filename: The name of the rendered timelapse to delete
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.deleteUnrendered(name, opts)
|
||||
|
||||
Delete the unrendered timelapse ``name``.
|
||||
|
||||
:param string name: The name of the unrendered timelapse to delete
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.renderUnrendered(name, opts)
|
||||
|
||||
Render the unrendered timelapse ``name``.
|
||||
|
||||
:param string name: The name of the unrendered timelapse to render
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.getConfig(opts)
|
||||
|
||||
Get the current timelapse configuration.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.saveConfig(config, opts)
|
||||
|
||||
Save the timelapse configuration.
|
||||
|
||||
:param object config: The config to save
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ref:`Timelapse API <sec-api-timelapse>`
|
||||
|
|
|
|||
|
|
@ -3,31 +3,104 @@
|
|||
:mod:`OctoPrint.users`
|
||||
----------------------
|
||||
|
||||
.. todo::
|
||||
.. note::
|
||||
|
||||
Needs to be documented
|
||||
Most methods here require that the used API token or a the existing browser session
|
||||
has admin rights *or* corresponds to the user to be modified. Some methods
|
||||
definitely require admin rights.
|
||||
|
||||
.. js:function:: OctoPrint.users.list(opts)
|
||||
|
||||
Get a list of all registered users.
|
||||
|
||||
Requires admin rights.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.get(name, opts)
|
||||
|
||||
Get information about a specific user.
|
||||
|
||||
:param string name: The user's name
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.add(user, opts)
|
||||
|
||||
Add a new user.
|
||||
|
||||
Requires admin rights.
|
||||
|
||||
:param object user: The new user
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.update(name, active, admin, opts)
|
||||
|
||||
Update an existing user.
|
||||
|
||||
Requires admin rights.
|
||||
|
||||
:param string name: The user's name
|
||||
:param bool active: The new ``active`` state of the user
|
||||
:param bool admin: The new ``admin`` state of the user
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.delete(name, opts)
|
||||
|
||||
Delete an existing user.
|
||||
|
||||
Requires admin rights.
|
||||
|
||||
:param string name: The user's name
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.changePassword(name, password, opts)
|
||||
|
||||
Change the password for a user.
|
||||
|
||||
:param string name: The user's name
|
||||
:param string password: The new password
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.generateApiKey(name, opts)
|
||||
|
||||
Generate a new API key for a user.
|
||||
|
||||
:param string name: The user's name
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.resetApiKey(name, opts)
|
||||
|
||||
Reset the API key for a user to being unset.
|
||||
|
||||
:param string name: The user's name
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.getSettings(name, opts)
|
||||
|
||||
Get the settings for a user.
|
||||
|
||||
:param string name: The user's name
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.saveSettings(name, settings, opts)
|
||||
|
||||
Save the settings for a user.
|
||||
|
||||
:param string name: The user's name
|
||||
:param object settings: The new settings, may be a partial set of settings which will be merged unto the current ones
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ref:`User API <sec-api-users>`
|
||||
:ref:`User API <sec-api-user>`
|
||||
The documentation of the underlying user API.
|
||||
|
|
|
|||
|
|
@ -3,10 +3,27 @@
|
|||
:mod:`OctoPrint.wizard`
|
||||
-----------------------
|
||||
|
||||
.. todo::
|
||||
.. note::
|
||||
|
||||
Needs to be documented
|
||||
All methods here require that the used API token or a the existing browser session
|
||||
has admin rights.
|
||||
|
||||
.. js:function:: OctoPrint.wizard.get(opts)
|
||||
|
||||
Retrieve additional data about registered wizards.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.wizard.finish(handled, opts)
|
||||
|
||||
Inform wizards that the wizard dialog has been finished.
|
||||
|
||||
:param list handled: List of identifiers of handled wizards
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ref:`Wizard API <sec-api-wizard>`
|
||||
The documentation of the underlying wizard API.
|
||||
|
|
|
|||
|
|
@ -7,25 +7,52 @@
|
|||
})(window || this, function(OctoPrint, $) {
|
||||
var url = "api/timelapse";
|
||||
|
||||
var downloadUrl = "downloads/timelapse";
|
||||
|
||||
var timelapseUrl = function(filename) {
|
||||
return url + "/" + filename;
|
||||
};
|
||||
|
||||
var timelapseDownloadUrl = function(filename) {
|
||||
return downloadUrl + "/" + filename;
|
||||
};
|
||||
|
||||
var unrenderedTimelapseUrl = function(name) {
|
||||
return url + "/unrendered/" + name;
|
||||
};
|
||||
|
||||
var getTimelapseData = function (opts) {
|
||||
var getTimelapseData = function (unrendered, opts) {
|
||||
if (unrendered) {
|
||||
opts = opts || {};
|
||||
opts.data = {unrendered: unrendered};
|
||||
}
|
||||
return OctoPrint.get(url, opts);
|
||||
};
|
||||
|
||||
OctoPrint.timelapse = {
|
||||
get: getTimelapseData,
|
||||
|
||||
list: function (opts) {
|
||||
list: function(opts) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
getTimelapseData(opts)
|
||||
getTimelapseData(true, opts)
|
||||
.done(function (response, status, request) {
|
||||
deferred.resolve({
|
||||
rendered: response.files,
|
||||
unrendered: response.unrendered
|
||||
}, status, request);
|
||||
})
|
||||
.fail(function () {
|
||||
deferred.reject.apply(null, arguments);
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
},
|
||||
|
||||
listRendered: function (opts) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
getTimelapseData(false, opts)
|
||||
.done(function (response, status, request) {
|
||||
deferred.resolve(response.files, status, request);
|
||||
})
|
||||
|
|
@ -36,8 +63,22 @@
|
|||
return deferred.promise();
|
||||
},
|
||||
|
||||
listUnrendered: function (opts) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
getTimelapseData(true, opts)
|
||||
.done(function (response, status, request) {
|
||||
deferred.resolve(response.unrendered, status, request);
|
||||
})
|
||||
.fail(function () {
|
||||
deferred.reject.apply(null, arguments);
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
},
|
||||
|
||||
download: function (filename, opts) {
|
||||
return OctoPrint.download(timelapseUrl(filename), opts);
|
||||
return OctoPrint.download(timelapseDownloadUrl(filename), opts);
|
||||
},
|
||||
|
||||
delete: function (filename, opts) {
|
||||
|
|
@ -54,7 +95,7 @@
|
|||
|
||||
getConfig: function (opts) {
|
||||
var deferred = $.Deferred();
|
||||
getTimelapseData(opts)
|
||||
getTimelapseData(false, opts)
|
||||
.done(function (response, status, request) {
|
||||
deferred.resolve(response.config, status, request);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ $(function() {
|
|||
);
|
||||
|
||||
self.requestData = function() {
|
||||
OctoPrint.timelapse.get({ data: { unrendered: true} })
|
||||
OctoPrint.timelapse.get(true)
|
||||
.done(self.fromResponse);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue