Skip to main content

UIConfig.json

BetaThe plugin SDK and these pages are new. They change with each release, as developers use them and tell us what works.View as Markdown

UIConfig.json describes a plugin's settings page: a page with sections, and fields inside each section. getUIConfig in index.js translates it and fills in the saved values, and the Volumio web UI renders it. Add a settings page shows how the pieces fit together.

Example​

UIConfig.json
{
"page": { "label": "TRANSLATE.PLUGIN_NAME" },
"sections": [
{
"id": "account",
"element": "section",
"label": "TRANSLATE.ACCOUNT",
"icon": "fa-user",
"onSave": { "type": "controller", "endpoint": "music_service/my_service", "method": "saveAccount" },
"saveButton": { "label": "TRANSLATE.SAVE", "data": ["username", "password", "high_quality"] },
"content": [
{ "id": "username", "element": "input", "type": "text", "label": "TRANSLATE.USERNAME", "value": "" },
{ "id": "password", "element": "input", "type": "password", "label": "TRANSLATE.PASSWORD", "value": "" },
{ "id": "high_quality", "element": "switch", "label": "TRANSLATE.HIGH_QUALITY", "value": true }
]
}
]
}

When the user selects Save, Volumio calls saveAccount with { "username": "...", "password": "...", "high_quality": true }.

Page​

PropertyTypeValue
page.labelstringThe page title
page.descriptionstringOptional. A line under the title.
sectionsarrayThe sections, in order

Section​

PropertyTypeValue
idstringThe section's id
elementstringsection
labelstringThe section title
descriptionstringOptional. A line under the title.
iconstringOptional. A Font Awesome class, such as fa-cog
hiddenbooleanOptional. true hides the section.
contentarrayThe fields. See Fields.
onSaveobjectWhat Save calls: { "type": "controller", "endpoint": "<type>/<id>", "method": "<method>" }
onSave.askForConfirmobjectOptional. { "title": "...", "message": "..." } asks the user to confirm before saving.
saveButton.labelstringThe text of the Save button
saveButton.dataarrayThe ids of the fields whose values Save sends. A field missing here is not sent.
saveButton.hiddenbooleanOptional. true hides the button.

Fields​

Every field has these properties:

PropertyTypeValue
idstringThe field's id, used in saveButton.data and in visibleIf
elementstringinput, switch, select, button or equalizer
labelstringThe field's label
docstringOptional. Help text, shown behind an info icon
descriptionstringOptional. A line under the field
valueanyThe current value. getUIConfig sets it from the saved settings.
visibleIfobjectOptional. { "field": "<id>", "value": <value> } shows the field only while the field <id> of the same section has that value.
hiddenbooleanOptional. true hides the field.

input​

A text box. type is an HTML input type: text, password, number and the like.

{ "id": "player_name", "element": "input", "type": "text", "label": "TRANSLATE.PLAYER_NAME", "value": "Volumio", "attributes": [{ "placeholder": "Living room" }, { "maxlength": 20 }] }
PropertyTypeValue
typestringThe HTML input type
attributesarrayOptional. HTML attributes, one object each, such as { "maxlength": 20 }
readonlybooleanOptional. true shows the value without letting the user change it.

Sends: the text the user typed.

switch​

An on and off switch.

{ "id": "high_quality", "element": "switch", "label": "TRANSLATE.HIGH_QUALITY", "value": true }

Sends: true or false.

select​

A list of options.

{
"id": "bitrate",
"element": "select",
"label": "TRANSLATE.BITRATE",
"value": { "value": 320, "label": "320 kbit/s" },
"options": [
{ "value": 160, "label": "160 kbit/s" },
{ "value": 320, "label": "320 kbit/s" }
]
}
PropertyTypeValue
optionsarrayThe options, each { "value": ..., "label": "..." }
valueobjectThe selected option, in the same shape

Sends: the selected option, { "value": 320, "label": "320 kbit/s" }.

button​

A button that acts at once, without Save.

{
"id": "clear_cache",
"element": "button",
"label": "TRANSLATE.CLEAR_CACHE",
"onClick": { "type": "controller", "endpoint": "music_service/my_service", "method": "clearCache", "data": {} }
}
PropertyTypeValue
onClickobjectWhat the button does. See the table below.
onClick.askForConfirmobjectOptional. { "title": "...", "message": "..." } asks the user to confirm first.
button_labelstringOptional. The text on the button. Default: label.
attributesarrayOptional. HTML attributes, as for input
onClick.typeDoesOther properties
controllerCalls a method of a plugin with dataendpoint (<type>/<id>), method, data
emitSends a socket.io message to Volumiomessage, data
openUrlOpens a web page in a new taburl

Sends: nothing. The button does not take part in Save.

equalizer​

One or more sliders.

{
"id": "eq",
"element": "equalizer",
"label": "TRANSLATE.EQUALIZER",
"config": {
"orientation": "vertical",
"bars": [
{ "min": -12, "max": 12, "step": 1, "value": 0, "tooltip": "always" },
{ "min": -12, "max": 12, "step": 1, "value": 3, "tooltip": "always" }
]
}
}
PropertyTypeValue
config.orientationstringvertical or horizontal
config.barsarrayOne object per slider
bars[].min, bars[].max, bars[].stepnumberThe range and the step
bars[].valuenumber or arrayThe position. With range: true, two numbers.
bars[].rangebooleanOptional. true makes the slider select a range.
bars[].ticks, bars[].ticksLabels, bars[].ticksPositionsarrayOptional. Fixed positions, their labels, and where they sit, from 0 to 100
bars[].tickSnapBoundsnumberOptional. How close the slider snaps to a tick
bars[].tooltipstringalways, show or hide

Sends: an array with the value of each bar.

Text and translations​

Every text property can be a TRANSLATE. key, such as "label": "TRANSLATE.GREETING". i18nJson replaces it with the value of GREETING in i18n/strings_<language>.json, or in i18n/strings_en.json when the user's language has no such key. Keys can be nested one level deep: TRANSLATE.ACCOUNT.USERNAME reads { "ACCOUNT": { "USERNAME": "Username" } }.

Was this page helpful?