MrDraw/docs/jsclientlib/slicing.rst
Gina Häußge eaadf8743b Allow multiple instances of the JS client
We now have a global OctoPrintClient, which is the class from which
all clients are derived, and a global OctoPrint, which is a single
instance already setup and ready to use in case we only need one.

It would be cleaner to have clients create that singular instance
themselves, but we need to maintain backward compatibility for now
with how we established the client to work with the 1.3.0 release.

New clients can be create with

    client = new OctoPrintClient({ /* options */ });

Alternatively the options can be left out and set at a later point:

    client = new OctoPrintClient();
    /* ... */
    client.options = { /* options */ };

Individual client components register themselves with OctoPrintClient
via OctoPrintClient.registerComponent(name, component) from the
component JS files. Just like before their instances are then
available in the individual client instances under "<client>.<name>",
 e.g. "OctoPrint.files".

Plugin components register themselves with OctoPrintClient via
OctoPrintClient.registerPluginComponent(name, component) from the
component JS files. Just like before their instances are then
available in the individual client instances under "<client>.plugins
.<name>", e.g. "OctoPrint.plugins.softwareupdate".

This should make it possible to create dashboard pages utilizing the
JS client that monitor the status of multiple OctoPrint instances,
without workarounds such as having to swap out the options globally
before each request.

See #1681 for the corresponding discussion.
2017-01-26 14:59:56 +01:00

60 lines
2.8 KiB
ReStructuredText

.. _sec-jsclientlib-slicing:
:mod:`OctoPrintClient.slicing`
------------------------------
.. js:function:: OctoPrintClient.slicing.listAllSlicersAndProfiles(opts)
Retrieves a list of all slicers and their available slicing profiles.
: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:: OctoPrintClient.slicing.listProfilesForSlicer(slicer, opts)
Retrieves of all slicing profiles for the specified ``slicer``.
:param string slicer: The identifier of the slicer for which to retrieve the profiles
: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:: OctoPrintClient.slicing.getProfileForSlicer(slicer, profileId, opts)
Retrieves the slicing profile with ``profileId`` for the specified ``slicer``.
:param string slicer: The slicer for which to retrieve the profile
:param string profileId: The identifier of the profile to retrieve
: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:: OctoPrintClient.slicing.addProfileForSlicer(slicer, profileId, profile, opts)
Adds the profile with identifier ``profileId`` to the specified ``slicer``, using the provided ``profile`` data.
:param string slicer: The slicer for which to add the profile
:param string profileId: The identifier for the profile to add
:param object profile: The data of the profile to add
: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:: OctoPrintClient.slicing.updateProfileForSlicer(slicer, profileId, profile, opts)
Updates the profile ``profileId`` for ``slicer`` with the provided ``profile`` data.
:param string slicer: The slicer for which to update the profile
:param string profileId: The identifier for the profile to update
:param object profile: The updated data of the profile
: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:: OctoPrintClient.slicing.deleteProfileForSlicer(slicer, profileId, opts)
Deletes the profile ``profileId`` for ``slicer``.
: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:`Slicing API <sec-api-slicing>`
The documentation of the underlying slicing API.