Git Product home page Git Product logo

mozaik-ext-version-control's Introduction

Mozaïk JSON widget

This widget display data from JSON file in your Mozaik dashboard. This JSON file may be either a static hosted file or a JSON object fetched from a REST API.

json

Installation

To install mozaik-ext-json from npm, run:

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

  {
      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:

    // 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):

    // 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

  {
      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
  }

mozaik-ext-version-control's People

Contributors

jtbonhomme avatar sciotta avatar trinitronx avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.