Giter VIP home page Giter VIP logo

bot-web-interface's Introduction

bot-web-interface

This is a small project for displaying data of multiple sources on one webpage that gets automatically updated.

Basic Usage

bot-web-interface is a small tool to create a live-dashboard from data within node. It accomplishes this by running an express app in a http server, utilizing socket.io to send updates as they occur.

Startup

In order to start bot-web-interface you must first require it and initialize it.

const bwi = require("bot-web-interface");
//start up bwi
const bwi_instance = new bwi({
  //what port the http server should run on
  port: 2080,
  //what password the interface should have
  //null means no password is needed
  password: null
});

Data Schemas

bot-web-interface presents data through tiles, which are referred to as interfaces. Each Interface belongs to one block of data. In order to know how to render an interface you must specify a schema for it. A Schema is an array, specifying for each piece of data a name, a type, a label, as well as some optional options. A list of some possible types is given in this example:

bwi_instance.publisher.setDefaultStructure([
  {name: "greeting", type: "text", label: "Greeting"},
  {name: "balance", type: "progressBar", label: "Balance", options: {color: "green"}},
  {name: "imbalance", type: "progressBar", label: "Imbalance"},
  {name: "rating", type: "labelProgressBar", label: "Rating"}
]);

It is not necessary to specify a default structure if you specify the structure of each interface individually.

Interfaces

In order to display data you need to create interfaces. Interfaces are bound to the schema they use, as well as a data source, which supplies the data to be displayed.

//an interface using the default structure
const interface1 = bwi_instance.publisher.createInterface();
//specify a static data source
interface1.setDataSource(() => ({
  greeting:"Hello",
  //Take note that the progress needs to be supplied in %
  //and not as a range from 0 to 1
  balance:50,
  imbalance:31.4,
  rating:[60,"6/10"]
}));
//an interface using a custom structure
const interface2 = bwi_instance.publisher.createInterface([
  {name: "speech", type: "text", label: "See also"}
]);
//specify a dynamic data source
interface2.setDataSource(() => ({
  speech:"Hello "+["Cat","Dog","Cow","Monkey"][Math.floor(Math.random()*4)]
}));

bot-web-interface's People

Contributors

nexusnull avatar numbereself avatar marvin-bitterlich avatar dependabot[bot] avatar

Watchers

 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.