|
| 1 | +# Dashboard create command |
| 2 | + |
| 3 | +## Review Period |
| 4 | + |
| 5 | +Best before October, 5, 2021. |
| 6 | + |
| 7 | +## Overview |
| 8 | +Arduino Cloud CLI should allow users to create a dashboard starting from a cloud template. |
| 9 | + |
| 10 | +The following User story has been taken from the [RFC](https://arduino.atlassian.net/wiki/spaces/FTWEB/pages/2761064740/Arduino+Cloud+CLI). |
| 11 | +* User is able to launch a simple CLI command to create a Dashboard in Cloud |
| 12 | + * the new Dashboard to create is a logical copy of another existing “template” Dashboard |
| 13 | + * the newly created Dashboard is displaying variables coming from a Thing specified during creation |
| 14 | + |
| 15 | +## Problem |
| 16 | +**An implementation for this command should be chosen.** |
| 17 | + |
| 18 | +The RFC specifies that this command is going to work only for dashboards with a single thing. However, dashboards with multiple things are common and **it would be better to introduce this feature from the beginning.** |
| 19 | + |
| 20 | +The problem in supporting multiple things for a single dashboard lays in mapping the things described in the dashboard template to the actual things. |
| 21 | +Indeed, if a single thing is used, it can be passed as a simple flag into the command. |
| 22 | + |
| 23 | +## Accepted solution |
| 24 | + |
| 25 | +It has been decided to implement the **Multiple things support** solution because it was the most future-proof. |
| 26 | +### Multiple things support |
| 27 | + |
| 28 | +Let's take a dashboard template: |
| 29 | +```YAML |
| 30 | +id: home-security-alarm-dashboard |
| 31 | +name: Home Security Alarm |
| 32 | +widgets: |
| 33 | + - type: Messenger |
| 34 | + name: message_update |
| 35 | + variables: |
| 36 | + - thing_id: home-security-messenger |
| 37 | + variable_id: message_update |
| 38 | + - type: Switch |
| 39 | + name: light_alarm |
| 40 | + variables: |
| 41 | + - thing_id: home-security-alarm |
| 42 | + variable_id: light_alarm |
| 43 | +``` |
| 44 | +Here we are going to use a flag, that could be called `override`, which takes as parameter a map to be defined with the following structure: `<thing-placeholder>=<thing-id>,..` |
| 45 | + |
| 46 | +Following the example, the command will be something like: |
| 47 | + |
| 48 | +```sh |
| 49 | +arduino-cloud-cli dashboard create --name <dashname> --template <yamldashtemplfile> --thing-override home-security-alarm=<mythingid1>,home-security-messenger=<mythingid2> |
| 50 | +``` |
| 51 | + |
| 52 | + |
| 53 | +## Alternative solutions |
| 54 | +### Single thing support |
| 55 | + |
| 56 | +This is the simplest solution but it's very limiting. |
| 57 | + |
| 58 | +Let's take a simple example: |
| 59 | +```YAML |
| 60 | +id: home-security-alarm-dashboard |
| 61 | +name: Home Security Alarm |
| 62 | +widgets: |
| 63 | + - type: Messenger |
| 64 | + name: message_update |
| 65 | + variables: |
| 66 | + - thing_id: home-security-alarm |
| 67 | + variable_id: message_update |
| 68 | +``` |
| 69 | +In this example, the dashboard uses a single thing. So the command could easily be something like: |
| 70 | + |
| 71 | +```sh |
| 72 | +arduino-cloud-cli dashboard create --name <dashname> --template <yamldashtemplfile> --thing-id <mythingid> |
| 73 | +``` |
| 74 | + |
| 75 | +or even: |
| 76 | + |
| 77 | +```sh |
| 78 | +arduino-cloud-cli dashboard create --name <dashname> --template <yamldashtemplfile> --thing-override <home-security-alarm>=<mythingid> |
| 79 | +``` |
0 commit comments