Types
Types of field values and metrics. All types are exported by @modbros/dashboard-core, except where noted, and should be
imported as types:
import type {ChannelValue, ValueMetricConfig} from '@modbros/dashboard-core'
The field value types are also used by the JSON schemas of the configuration files, e.g. for defaultValues.
Field Values
ValueColor
The value of a color field.
| Property | Type | Description |
|---|---|---|
| hex | string | The color as hex value, e.g. #ff0000. |
| alpha | number | The opacity between 0 and 1. |
All properties are optional.
ValueFile
A file of a file field. Also exported
by @modbros/dashboard-sdk.
| Property | Type | Description |
|---|---|---|
| filename | string | The name of the file. |
| src | string | The URL of the file, relative to MoBro. Use it to display the file. |
| localSrc | string | The absolute URL of the file on the PC running MoBro. |
All properties are optional.
ValueOptions
The options of a select
or radio field: an array of objects with the following
properties.
| Property | Type | Restrictions | Description |
|---|---|---|---|
| label | string | Required | The label shown to users. |
| value | string | Required | The value returned when it's selected. |
ValueMetricConfig
The value of a metric field: the selected metric.
| Property | Type | Description |
|---|---|---|
| id | string | The id of the metric. |
| plugin | string | The name of the plugin providing the metric. |
| categories | string[] | The ids of the categories the user navigated through to select the metric. |
| options | ValueMetricOptions | The unit conversion and value source selected by the user. |
All properties are optional.
ValueMetricOptions
| Property | Type | Restrictions | Description |
|---|---|---|---|
| conversionUnit | string | Required | The abbreviation of the unit to convert the value to. |
| source | string | - | The value the widget receives: value (default), min, max or avg. |
ValueActionConfig
The value of an action field: the selected action.
| Property | Type | Description |
|---|---|---|
| id | string | The id of the action. |
| plugin | string | The name of the plugin providing the action. |
| categories | string[] | The ids of the categories the user navigated through to select the action. |
| settings | Record<string, unknown> | The settings passed to the plugin when executing the action. |
All properties are optional.
FilterMetricConfig
The filters of a metric field.
| Property | Type | Description |
|---|---|---|
| valueTypes | string[] | Only metrics whose type has one of these value types. |
| types | string[] | Only metrics of these metric types, by id. |
| groups | string[] | Only metrics in these groups, by id. |
| static | boolean | Only static metrics (true), or only non-static metrics (false). |
| hasValue | boolean | Only metrics that currently have a value. |
FilterActionConfig
The filters of an action field.
| Property | Type | Description |
|---|---|---|
| groups | string[] | Only actions in these groups, by id. |
Metrics
ChannelValue
The value of a metric as received by a widget, e.g. from useMetricField.
It combines the metric's value with the metric, its type and its unit. See In-depth: Metrics.
| Property | Type | Description |
|---|---|---|
| metric | Metric | The metric. |
| type | MetricType | The type of the metric. |
| unit | MetricUnit | The unit the value is provided in, after the conversion selected by the user. |
| value | MetricValue | The value of the metric. |
The actual value is accessed as channelValue.value.value.
MetricValue
The value of a metric, as provided by a plugin. See Plugins: MetricValue.
| Property | Type | Description |
|---|---|---|
| id | string | The id of the metric. |
| value | MetricValueType | The value. |
| valueUpdated | string | null | When the value was last updated, as ISO date. |
| valueChanged | string | null | When the value last changed, as ISO date. |
| statistics | MetricStatistics | Statistics about the values of the metric. |
| timeseries | MetricTimeseries | Previous values of the metric. Optional, may not be present. |
MetricValueType
type MetricValueType = number | string | null
MetricStatistics
Statistics MoBro collects about the values of a metric.
| Property | Type | Description |
|---|---|---|
| min | number | null | The smallest value. |
| max | number | null | The largest value. |
| avg | number | null | The average value. |
| count | number | The number of values. |
| started | string | When MoBro started collecting, as ISO date. |
| lastUpdated | string | When the statistics were last updated, as ISO date. |
MetricTimeseries
| Property | Type | Description |
|---|---|---|
| count | number | The number of values. |
| timestamps | string[] | The ISO dates of the values. |
| values | (number | null)[] | The values, in the same order as the timestamps. |
Metric
| Property | Type | Description |
|---|---|---|
| id | string | The id of the metric. |
| label | string | null | The label of the metric. |
| description | string | null | The description of the metric. |
| plugin | Relation | null | The plugin providing the metric. |
| type | Relation | The type of the metric. |
| category | Relation | null | The category of the metric. |
| group | Relation | null | The group of the metric. |
| isStatic | boolean | Whether the value of the metric never changes. |
The metric also contains the properties value, valueUpdated, valueChanged, statistics and timeseries. Use the
ones of the MetricValue instead, which are always up to date.
MetricType
| Property | Type | Description |
|---|---|---|
| id | string | The id of the metric type. |
| label | string | The label of the metric type. |
| description | string | null | The description of the metric type. |
| plugin | Relation | null | The plugin providing the metric type, if any. |
| icon | Relation | null | The icon of the metric type. |
| valueType | MetricTypeValueType | The value type of all metrics of this type. |
| baseUnit | MetricUnit | The unit plugins provide values in. |
| units | MetricUnit[] | All units values can be converted to. |
MetricTypeValueType
type MetricTypeValueType =
| 'Custom'
| 'String'
| 'Numeric'
| 'Duration'
| 'DateTime'
| 'DateOnly'
| 'TimeOnly'
| 'Resource'
| 'Currency'
| 'Boolean'
MetricUnit
| Property | Type | Description |
|---|---|---|
| label | string | The label of the unit. |
| abbreviation | string | The abbreviation of the unit, e.g. °C. |
| description | string | null | The description of the unit. |
| fromBaseFormula | string | The formula to convert a value from the base unit to this unit. |
| toBaseFormula | string | The formula to convert a value from this unit to the base unit. |
Relation
A reference to another item, like a plugin or a category.
| Property | Type | Description |
|---|---|---|
| id | string | The id of the referenced item. |
| href | string | The API path of the item. |
Widget
The following types are exported by @modbros/dashboard-sdk.
ItemPosition
The position of a widget on the dashboard.
| Property | Type | Description |
|---|---|---|
| x | number | The horizontal position in pixels. |
| y | number | The vertical position in pixels. |
ItemSize
The size of a widget on the dashboard.
| Property | Type | Description |
|---|---|---|
| width | number | The width in pixels. |
| height | number | The height in pixels. |
Settings
The settings selected in MoBro, as returned by useSettings. This type is not exported.
| Property | Type | Description |
|---|---|---|
| language | string | The selected language, e.g. en. |
| timezone | string | The selected timezone, e.g. Europe/Vienna. |
| theme | string | The selected theme of the app. |