@Vitor Lima
Introduction
We commonly receive questions on how to auto-generate dashboards, apply the access policy and create actions. In this tutorial, you will learn how to do that with a few examples that should give you a starting point.
Required Knowledges
In order to read this guide we expect you to already know how to create devices, dashboards and widgets.
Node.js coding knowledge is good but not required, unless you want to improve the code by yourself.
Step 1: Create your Dashboard Template
First, you need to setup a Dashboard Template. What you do is to simply create a dashboard using the same device for all widgets you put in this dashboard.
- In order to do that create a device using the Custom HTTPs connector: https://admin.tago.io/devices/connectors/5bbd0d144051a50034cd19fb.
- Create your dashboard.
- Create some widgets using this device. You can use the device emulator to enter some data so you can see how the widget will look at end.
- You can also use labels/texts you want to change when creating the dashboard for a customer. For that, try keywords like # to replace later using the Analysis.
- Go to the dashboard configuration > tags. Enter the tag key customer and in the value put in #. The analysis later will change the # with the ID of the user.
- After all done, go to the dashboard configuration > Distribute. Enter any name for the device and press Generate. You need to re-do this step for any change you do in this dashboard template.
Step 3: Create an Access Policy
In the previous step we configured a tag key called customer. This is done so we can create the Access Policy for users to be able to have access to the dashboard.
To create the Access Policy follow these steps:
- Go to Access page and create a new Policy.
- Enter the name “Customer Policy”.
- In the Target select User, Tag Match and customer. (as the screenshot below)
- Do the same for the Permissions.
- Press Save.
Step 2: Create your Analysis
I’ll provide you a starting analysis for this example. Since each application is different from one another, you can later modify it to your own needs.
So what this analysis will do?
- It will be triggered by a form widget in another dashboard, which expects to receive: An email and a device already created in your account.
- Create the User, duplicate the dashboard and substitute the device.
Step 3: Create an Action
Since the script expects to receive an email and a device, you must make sure to trigger the analysis with that information. You can do that in many ways: By action or a widget trigger. In this case, we will be using the widget trigger.
The following dashboard has an input form widget for you to enter both fields. Install in your account and select any device to store these fields. You can just create a Custom HTTPs device for it if you don’t already have one.
- Install the template http://admin.tago.io/template/5dd2df6c16174c001c9ac627.
- Edit the widget.
- Go to the User Control tab.
- Change the Run Analysis When… to your previous created analysis.
Comments
This is all you need to do. Just invite a user and see everything working.
If it didn’t work you can reply to this topic. Be sure to send the console messages from your analysis.
Since this is just a starting point, you may need to change the analysis for your needs. Here are some changes you may want to do:
- Automatically create devices.
- Generate specific widgets based on the device type.
- Choose different templates based on the device or user access level.