https://github.com/intercloud/mozaik-ext-datadog
https://github.com/intercloud/mozaik-ext-datadog
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/intercloud/mozaik-ext-datadog
- Owner: intercloud
- Created: 2018-12-28T10:41:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-04T22:34:17.000Z (over 5 years ago)
- Last Synced: 2025-06-20T17:43:48.394Z (11 months ago)
- Language: JavaScript
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mozaïk JSON widget
This widget display data from JSON file in your [Mozaik](http://mozaik.rocks/) dashboard.
This JSON file may be either a static hosted file or a JSON object fetched from a REST API.

## Installation
To install mozaik-ext-json from npm, run:
```bash
npm install --save mozaik-ext-json
```
## Configuration
### Static hosted file
Let's say you want to display two set of data from a file you host on your Dropbox public directory.
#### JSON file
```javascript
{
type: 'json.data',
title: '${obj2.name}',
value: '${obj2.value}',
unit: null,
columns: 1, rows: 1,
x: 1, y: 1
},
{
type: 'json.data',
title: 'WIDGET TITLE',
value: '${obj1.value}',
unit: '${obj1.unit}',
columns: 1, rows: 1,
x: 2, y: 1
},
```
#### api
In your Mozaik dashboard's config.js file, add the JSON file url in the api section. The url key shall contains the full URL where your JSON file is hosted:
```javascript
// clients configs
api: {
json: {
url: 'https://dl.dropboxusercontent.com/u/21352749/mozaik.json'
}
}
```
### JSON data fetched from REST API
In your Mozaik dashboard's config.js file, add the webservice url in the api section. The url key shall contains the full URL where your webservice is hosted. An optionnal headers key can be added (to add authentication information for example):
```javascript
// clients configs
api: {
json: {
url: 'http://mywebservice/rest/api/2/resource/id',
headers: [{name: 'Authorization', value: 'Basic aKjs6LK8ijkSfT'}, {name: 'Content-type', value: 'applicatin/json'}]
}
}
```
### parameters
title, value and unit parameters can be either a String or a property path to be retrieve in the JSON data.
key | required | description
----------|----------|-------------------------------------------------------------------
`type` | yes | *Always equal to 'json.data'*
`title` | yes | *The title to be displayed in the header.*
`value` | yes | *The value to be displayed in the widget body.*
`unit` | yes | *Unit to be displayed after the data. Set to null if not needed.*
### usage
```javascript
{
type: 'json.data',
title: 'THIS IS A TITLE',
value: '${obj1.value}',
unit: '${obj1.unit}',
columns: 1, rows: 1,
x: 1, y: 1
},
{
type: 'json.data',
title: '${obj2.name}',
value: '${obj2.value}',
unit: null,
columns: 1, rows: 1,
x: 2, y: 1
}
```