Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Actions

Table of Contents
maxLevel5
stylecircle
minLevel2

Requirements

The examples in this page use the Prototype library, which is included by default inside a portal. However, the same concepts may be applied using other implementations.

Description

These set of actions can retrieve a list of available Sample projects, and import a specific sample into the workspace.
Samples are contributed to the Studio via extensions, or via the scripting mechanism (Rubles).

Invocation

This command is executed immediately in a synchronous way.

List the available Samples

To get the JSON list of samples, dispatch this call:

...

key

description

category

The sample's category

name

The name of the sample

id

A unique sample identifier which should also be used when importing a sample

description

A description of the sample

image

(currently empty for all samples) Will hold an image URL for the sample

Import a Sample

When importing a sample, the dispatch call should use a sample id that was retrieved via the getSamples action.
Here is a dispatch example:

Code Block
dispatch($H({
	controller: 'portal.samples',
	action: "importSample", 
	args: [sampleID].toJSON()
}).toJSON());

Listening to Sample Changes

It is possible that some of the samples are loaded or removed after the portal is opened. In this case, the Studio fires events that indicate a Sample addition or removal.
Here is a sample of a way you can listen to such events (based on the studio3-sdk sample):

...