JS Client docs for OctoPrint.connection

This commit is contained in:
Gina Häußge 2016-06-29 09:28:55 +02:00
parent 5611f87339
commit ca8bbe2de4
3 changed files with 38 additions and 4 deletions

View file

@ -81,7 +81,7 @@
:param string method: The HTTP method to use for the request (optional)
:param string url: The URL to perform the request against (optional)
:param object opts: Additional options to use for the request, see above for details (optional)
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response's response
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrint.ajaxWithData(method, url, data, opts)

View file

@ -9,11 +9,20 @@
``password`` as credentials. If ``remember`` is set to ``true``, the session
will also persist across browser restarts.
**Example:**
.. code-block:: javascript
OctoPrint.browser.login("myusername", "mypassword", true)
.done(function(response) {
// do something with the response
});
:param string username: Username to log in with
:param string password: Password to log in with
:param bool remember: "Remember me"
:param object opts: Additional request options
:returns Promise: A promise for the performed login request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrint.browser.passiveLogin(opts)
@ -21,11 +30,11 @@
stored in the browser's cookies.
:param object opts: Additional request options
:returns Promise: A promise for the performed login request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrint.browser.logout(opts)
Logs the browser out of OctoPrint.
:param object opts: Additional request options
:returns Promise: A promise for the performed logout request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response

View file

@ -5,8 +5,33 @@
.. js:function:: OctoPrint.connection.getSettings(opts)
Retrieves the available connection options for connection to a printer.
See :ref:`Get connection settings <sec-api-connection-current>` for the response format.
.. js:function:: OctoPrint.connection.connect(data, opts)
Connects to the printer, optionally using the provided connection ``data`` as parameters.
If ``data`` is provided it's expected to be an object specifying one or more of
* ``port``
* ``baudrate``
* ``printerProfile``
* ``save``
* ``autoconnect``
See :ref:`Issue a connection command <sec-api-connection-command>` for more details.
.. js:function:: OctoPrint.connection.disconnect(opts)
Disconnects from the printer.
See :ref:`Issue a connection command <sec-api-connection-command>` for more details.
.. js:function:: OctoPrint.connection.fakeAck(opts)
Triggers a fake acknowledgement (``ok``) on the printer.
See :ref:`Issue a connection command <sec-api-connection-command>` for more details.