view.xml
This page lists all of the available tags within the view.xml file and how to access them from within the plugin
As described before, this file allows the developer to create a form so that it can be displayed as a GUI at the moment of creating the plugin. The contents of this file are Ubidots-mapped XML-like tags to React elements, so it actually differs from the traditional XML supported tags.
Form
This tag is the most important since it wraps the whole form. It is mapped to an XML form
element. It has the following attributes:
name: Document-unique text that identifies the form.
Example:
Group
This tag is mapped in the DOM as a div
. It serves as a container, thus allowing grouping elements. Its attributes are:
name: Document-unique text that identifies the group.
Example:
This div element represented by utilizes certain CSS flexbox technique so it is properly rendering on the front-end.
Label
This tag is mapped in the DOM as a label
tag. Generally used as the title associated to an input element, yet not constrained to it solely. Its properties are:
name: Document-unique text that identifies the label.
help (optional): A help text displayed as a question mark icon next to the label. Clicking the icon reveals the text, which can also contain external links using markdown.
Example:
Input
This tag is mapped onto the DOM as a text input element. This field can be of password, switch or text type. Its properties are:
name: Document-unique text that identifies the input.
type: This is the input type of the element. Its allowed values are
password
,checkbox
andtext
placeholder (optional): Help-like text that will be displayed within the input field
value (optional): Default value for the input
The text
and password
inputs are sent to the plugin as plain text. On the other hand, the checkbox is sent as a boolean as:
Paragraph
This tag is mapped into the DOM as a p
element. It allows including text blocks within the form. Its properties are:
name: Document-unique text that identifies the paragraph.
Example:
As shown above, this tag allows including external link using markdown syntaxis, however it should include the HTTP protocol (either HTTP or HTTPS)
Map
This tag represents a map in the web browser. It works as any other entry in he form, that allows selecting a location through a google map. Its properties are:
name: Document-unique text that identifies the map within the form.
lat (optional): If allowed by the user, their position will be retrieved and
lat
will be the user's position latitude. Else, it will be set to37.428458
by default.lng (optional): If allowed by the user, their position will be retrieved and
lng
will be the user's position longitude. Else, it will be set to-122.160901
by default.zoom (optional): Zoom initial value. Its defaulted to 12.
type (optional): Map type. The accepted values are
roadmap
,satellite
andhybrid
, the later being the default value.
Example:
They lat and lng values are sent to the plugin in an object as follows:
This is how the map looks like:
Select
This element is rendered in the browser as a dropdown, allowing users to select one or multiple items from a list. Its properties are:
name: A unique identifier for the dropdown within the form.
type: Determines if the dropdown allows single or multiple selections. Accepted values are
single
andmultiple
.search (optional): Enables a search feature within the dropdown. Accepted values are
enabled
anddisabled
.placeholder: A default message displayed in the dropdown before any selection.
value (optional): Default value for the dropdown.
Note: For multiple
type dropdown, the default value should be a comma-separated string without spaces.
Correspondingly, for each case, the following is interpreted by the plugin:
Option
Represents individual items within a dropdown. They can only be used as sub-elements of a dropdown and cannot exist independently. Its properties are:
value: The associated value of the item.
Example:
Token
A dropdown that lists all user tokens and allows one to be selected for plugin configuration. Its properties are:
name: A unique identifier for the token within the form.
placeholder: A default message displayed in the dropdown before any selection.
Example:
This is sent to the plugin as:
Frequency
A text field accompanied by a label, both arranged on a single line. The text field is positioned within the label based on a specified keyword. Its properties are:
label: Descriptive text for the interval input field. The label can contain the
{field}
keyword, which represents the position of the text field. If not specified, the field is placed at the end of the label.
Example:
Connected Account Field
A list of all accounts connected to Ubidots, filtered based on the provider
attribute. This field also allows connecting new accounts from the same provider. Its attributes are:
label (optional): Descriptive text for the field.
provider: Refers to various external services that can be connected. Currently, the only accepted value is
AWS_IAM
. This attribute is case-sensitive.
Example:
Note: Information related to this field can only be accessed from the control script using environment variables. Variables referencing this field have the AUTH_CREDENTIALS_
prefix.
Accessing view.xml elements from within the plugin
Any of the elements in view.xml file can be accessed from the plugin's scripts, namely control
and function
. For example, suppose that your plugin is implementing the following view.xml file:
So in order to access these data on the aforementioned scripts, you should read the _parameters
key from the incoming JSON (the function's arguments).
For this particular case, this is how said JSON would look like:
Said so, if you want to get the value of input-text
field, you need to do something like the following snippet on your script:
Conversely, the input-password
, input-checkbox
and age-range data can be read as:
Last updated
Was this helpful?