Code Monkey home page Code Monkey logo

thingsboard-extensions's Introduction

Extension ThingsBoard Platform

ThingsBoard Dependencies

To add some of ThingsBoard dependencies imports to your "extension" Angular component, please use this import structure:

import { <dependency> } from '<TB-module>/public-api';

"TB-module" - any of the following modules:

@app/*
@core/*
@shared/*
@modules/*
@home/*

"dependency" - name of dependency/type located in "TB-module". Refer to modules-map to see what you can use.

Example:

import { WidgetConfig } from '@shared/public-api';

External Dependencies

In case you want to use your own dependencies package from the npm registry (unless you have specified another one in your package.json), you can easily add them to yarn packet manager running the next command:

yarn add <package-name>

Example:

yarn add lodash

If it's not the npm/yarn registry, and you want to add it in another way, please refer to yarn docs.

Run project in development mode

cd ${TB_EXTENSION_WORK_DIR}/widgets
mvn clean install -P yarn-start

In widgets library create a new widget and in the resources tab of the widget editor add this file path:

http://localhost:5000/static/widgets/thingsboard-extension-widgets.js

You must also check "Is module"

Build project

cd ${TB_EXTENSION_WORK_DIR}
mvn clean install -DskipTests

Deploy project to customer server

cd ${TB_EXTENSION_WORK_DIR}
scp widgets/target/thingsboard-extension-widgets-1.0.0-SNAPSHOT.jar ubuntu@${CUSTOMER}:~/.
ssh ${CUSTOMER}

sudo cp thingsboard-extension-widgets-1.0.0-SNAPSHOT.jar /usr/share/thingsboard/extensions/
sudo chown thingsboard:thingsboard /usr/share/thingsboard/extensions/thingsboard-extension-widgets-1.0.0-SNAPSHOT.jar
sudo service thingsboard restart

Run project in production mode

In widgets library create a new widget. In the resources tab of the widget editor add this file path:

static/widgets/thingsboard-extension-widgets.js

You must also check "Is module"

Build docker image with custom extension

Before building the docker image you have to choose the proper TB version, by default it has been set to 3.5.0 ThingsBoard CE.
An example of setting version:
CE:

thingsboard/tb-node:3.5.0

PE:

store/thingsboard/tb-pe-node:3.5.0PE

To build a docker image with a custom extension inside, you need to specify the repository name, the image name and ThingsBoard version by executing following command:

mvn license:format clean install -Ddockerfile.skip=false -Ddocker.repo=thingsboard -Ddocker.name=thingsboard-extension-docker -Dtb.edition=thingsboard/tb-node:3.5.0

where

-Ddocker.repo= - the repository name in your dockerhub
-Ddocker.name= - the name of your image
-Dtb.edition=  - your ThingsBoard edititon (CE/PE) chosen from the example above

To run the built image, please follow our official guides.
CE:

https://thingsboard.io/docs/user-guide/install/cluster/docker-compose-setup/

NOTE: Don't forget to do git checkout v3.5.0
Otherwise, you will hit the error messages related to the unreleased features

PE:

https://thingsboard.io/docs/user-guide/install/pe/cluster/docker-compose-setup/

Once the guides successfully passed, please do the following.
In case you use CE you have to change the used image within docker-compose.yml to your local one.
Open the docker-compose.yml:

nano docker-compose.yml

Under tb-core1 & tb-core2 you will see:

image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"

change it to

image: "thingsboard/thingsboard-extension-docker:1.0.0-SNAPSHOT"

where <YOUR_VERSION> by default is 1.0.0-SNAPSHOT.
It can be configured within parent pom.xml file in tag version.

In case you use PE you have to perform the same steps as for CE, but to change the docker image within docker-compose.yml that is located within your installation type folder.
E.g. if you choose basic/monolith installation type then the proper docker-compose.yml will be located at your_docker_directory/monolith/docker-compose.yml under tb-monolith property.
For advanced installation type is the same as for CE and located under tb-core1 & tb-core2.

Once the docker-compose.yml file has been updated, please restart ThingsBoard regard to our official guides.

thingsboard-extensions's People

Contributors

cadaver123 avatar chantsovaekaterina avatar dmitriymush avatar ikulikov avatar nickyadvokaat avatar vvlladd28 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.