Data Service (opendash/services/data)
The data service allows you to pull data from all registered data adapters at the same time.
Usage
Use the Data Service by injecting opendash/services/data
as an Angular Service. We suggest using $data
as a name for the variable.
Example:
class controller {
static get $inject() { return ['opendash/services/data']; }
constructor($data) {
// ...
}
}
Properties & Methods
$data.list()
Returns all open.DASH data items.
let items = $data.list();
Response
Returns an Array containing all instances of OpenDashDataItem and OpenDashDataContainer.
$data.listByType(type: String)
Returns all open.DASH data items.
let items = $data.listByType('Number');
items.forEach(i => {
let [item, index] = i;
item.value.values[index]; // A numeric value
});
Parameter
- type: One of the following Strings: Number, String, Boolean, Geo, Object
Response
Returns an two dimensional Arrays where the inner Array has two Elements. The first is a instance of OpenDashDataItem, the second one is the index of the requested value type.
The same instance of OpenDashDataItem my be returned multiple times, if the value uses the requested value type multiple times.
$data.query()
Returns a query.
let items = $data.list();
Response
Returns an instances of OpenDashDataQuery.
$data.get(id: String)
Returns a single open.DASH data item.
let item = $data.id('example.id');
if(!item) {
// handle missing item
}
Response
Returns an instance of OpenDashDataItem if there is an item with the given id, if not null
is returned.