-
Notifications
You must be signed in to change notification settings - Fork 142
RCloud UI Extensions
As of RCloud 1.3, various RCloud UI features and behaviors can be extended using the extension mechanism. Languages can also be added.
Load your code when an RCloud session starts by creating an RCloud add-on, which is an R package which gets loaded automatically. The packages listed under rcloud.alluser.addons
in rcloud.conf will get loaded for all users, and the packages in the RCS key <user>/system/config/addons
will get loaded for that user.
See rcloud.packages/rcloud.viewer
for a simple example of an addon which creates a side panel.
Since these APIs are new, they are in flux, with more features being added. The basic interface of all extension mechanisms has the following methods:
-
init()
- this will be called by the system when the system first starts - you shouldn't need to call it. It calls its ownadd()
method to create the default entries. -
add()
- takes an object (hash) of entries, in most cases a description of the controls to be added to the user interface. The properties of these entries vary, but they always have asort
property, which determines the order the UI elements will be displayed, or processors will be run. -
remove()
- takes the name of an entry to remove.
Beyond that, it is best to look at the existing entries to determine the parameters for each UI extension. Links to the source are below.
Prior to RCloud 1.5, the list of addons for all users was controlled by .allusers/system/config/addons
and populated by rcs.system.config.addons
. This didn't allow multiple RCloud instances using the same RCS with different settings, so now it's just the rcloud.conf key rcloud.alluser.addons
.
E.g. Workspace and Dataframe are implemented as pure extensions.
https://github.com/att/rcloud/blob/develop/htdocs/js/ui/panel_loader.js
The commands that appear when hovering over a notebook.
https://github.com/att/rcloud/blob/develop/htdocs/js/ui/notebook_commands.js
Commands shown in main cell command area at right, left, between cells, and above the prompt.
https://github.com/att/rcloud/blob/develop/htdocs/js/ui/cell_commands.js
Operating on incoming text/html output and on jQuery selections after it has been parsed.
https://github.com/att/rcloud/blob/develop/htdocs/js/notebook/cell_processors.js
The links in the upper right corner of the navbar, including the Advanced Menu. Simple links can be added using rcloud.conf:
rcloud.menu.forum: 2000, edit, link, Forum, https://rcloud.research.att.com/forum
rcloud.menu.about: 3000, edit, link, About, https://rcloud.research.att.com/rcloud_about.html
Where the fields are:
rcloud.menu.name: sort, modes, type, title, link, target
Modes is pipe-separated list of (for now) edit
and view
. Type is (for now) just link
or divider
. Target defaults to _blank
to open in a new tab/window.
Menus need to be added using JavaScript in an extension.
That annoying bucket of clutter at the upper right corner.
https://github.com/att/rcloud/blob/develop/htdocs/js/ui/advanced_menu.js
The options available when clicking on the carat to the right of the Shareable Link button.
https://github.com/att/rcloud/blob/develop/htdocs/js/ui/share_button.js