@luzmo/embed 5.0.3 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +216 -0
- package/index.js +78 -1195
- package/index.mjs +63 -1196
- package/index.umd.js +79 -1197
- package/lib/dashboard-component/dashboard-component.d.ts +1 -1
- package/lib/models/filters.model.d.ts +6 -0
- package/luzmo-embed.min.js +79 -1197
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Web Component for Luzmo dashboard
|
|
2
|
+
|
|
3
|
+
A modern [Web Component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) for [Luzmo](https://luzmo.com) dashboards in your web application.
|
|
4
|
+
|
|
5
|
+
## Table of contents
|
|
6
|
+
|
|
7
|
+
1. [Installation instructions](#installation-instructions)
|
|
8
|
+
2. [Usage](#usage)
|
|
9
|
+
3. [Events](#events)
|
|
10
|
+
4. [Public Methods](#public-methods)
|
|
11
|
+
5. [Examples](#examples)
|
|
12
|
+
6. [Changelog](#changelog)
|
|
13
|
+
7. [Migration](#migration)
|
|
14
|
+
8. [Quick links](#quick-links)
|
|
15
|
+
|
|
16
|
+
## Installation instructions
|
|
17
|
+
|
|
18
|
+
### 1. Install the component from npm
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm i @luzmo/embed
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Import the component
|
|
25
|
+
|
|
26
|
+
In a JavaScript module:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
import '@luzmo/embed';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
OR In an HTML page:
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<script type="module">
|
|
36
|
+
import './node_modules/@luzmo/embed/index.umd.js';
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
OR
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<script type="module" src="./node_modules/@luzmo/embed/index.umd.js"></script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
Use the dashboard components as if they were native HTML tags. Use the id of the dashboard you wish to embed.
|
|
49
|
+
**In your HTML template.**
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<luzmo-dashboard dashboardId="55cfb99c-d602-492b-b192-6c15277fdb9a" language="en"> </luzmo-dashboard>
|
|
53
|
+
|
|
54
|
+
OR
|
|
55
|
+
|
|
56
|
+
<!-- Embed a item by passing the item id as well -->
|
|
57
|
+
<luzmo-dashboard dashboardId="55cfb99c-d602-492b-b192-6c15277fdb9a" itemId="59fe5bd7-5070-42f5-98f4-da7f931e316c"> </luzmo-dashboard>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Properties:**
|
|
61
|
+
|
|
62
|
+
Below a list of available properties on the dashboard web component
|
|
63
|
+
|
|
64
|
+
| Property | Type | Description |
|
|
65
|
+
| -------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `dashboardId` | string | The id of the Luzmo dashboard you wish to embed |
|
|
67
|
+
| `dashboardSlug` | string | The slug of the Luzmo dashboard you wish to embed (if a dashboardId is supplied that one will be used) |
|
|
68
|
+
| `itemId` | string | The id of the Luzmo item you wish to embed |
|
|
69
|
+
| `itemDimensions` | { width: number/string; height: number/string; } | width and height of item only applies when itemId is provided. Accepts a JSON string. |
|
|
70
|
+
| `authKey` | string | Authorization key generated via Luzmo API |
|
|
71
|
+
| `authToken` | string | Authorization token generated via Luzmo API |
|
|
72
|
+
| `language` | string | The language of the dashboard: eg. 'en' (Default: 'auto') |
|
|
73
|
+
| `screenMode` | string | The screen mode of your dashboard: 'mobile', 'tablet', 'desktop', 'largeScreen', 'fixed' or 'auto' (Default: 'auto') |
|
|
74
|
+
| `switchScreenModeOnResize` | boolean | true: the embedded dashboard can switch screenModes on resize of the container , false: Dashboard will keep the same screenMode (Default: true) |
|
|
75
|
+
| `loaderBackground` | string | Background color of the loader element (Default: '#f9f9f9') |
|
|
76
|
+
| `loaderFontColor` | string | Font color of the text of the loaders (Default: '#5a5a5a') |
|
|
77
|
+
| `loaderSpinnerColor` | string | Spinner color of the loader (Default: 'rgba(255, 165, 0, 0.7)') |
|
|
78
|
+
| `loaderSpinnerBackground` | string | Background color of the spinner (Default: 'rgba(169, 169, 169, 0.14)') |
|
|
79
|
+
| `appServer` | string | Tenancy of luzmo.com to connect to (Default: 'https://app.luzmo.com/' for US set appServer to 'https://app.us.luzmo.com/') |
|
|
80
|
+
| `timezoneId` | string | The timezone you you wish to use in your dashboard. This timezone id needs to be a valid id that is available in the [IANA timezone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List), for example: Europe/Brussels or America/New_York. |
|
|
81
|
+
| `apiHost` | string | API server to connect to (Default: 'https://api.luzmo.com/' , for US set apiHost to 'https://api.us.luzmo.com/') |
|
|
82
|
+
| `editMode` | string | Specifies if the embedded dashboard should be editable or not. Accepted values: "view" , "editLimited" , "editFull" . Use "view" if you don't want the embedded dashboard to be editable. (Default: "view" ) |
|
|
83
|
+
| `mainColor` | string | Optional override of the main color used in the whitelabeling of the embedded dashboard editor. If not provided, the main color of the whitelabeling colors set on the organization will be used. Should be specified as a string of rgb values (i.e. "rgb(50,50,50)"). |
|
|
84
|
+
| `accentColor` | string | Optional override of the accent color used in the whitelabeling of the embedded dashboard editor. If not provided, the accent color of the whitelabeling colors set on the organization will be used. Should be specified as a string of rgb values (i.e. "rgb(50,50,50)"). |
|
|
85
|
+
|
|
86
|
+
<br/><br/>
|
|
87
|
+
|
|
88
|
+
## Events
|
|
89
|
+
|
|
90
|
+
| Name | Description | Event Arguments |
|
|
91
|
+
| -------------- | -------------------------------------- | --------------------- |
|
|
92
|
+
| changedFilters | Emitted when filters are changed | `ChangedFiltersEvent` |
|
|
93
|
+
| customEvent | Emitted when a custom event is fired | `CustomEvent` |
|
|
94
|
+
| exported | Emitted when export completes or fails | `ExportedEvent` |
|
|
95
|
+
| itemsRendered | Emitted when all items are rendered | `ItemsRenderedEvent` |
|
|
96
|
+
| load | Emitted when dashboard is loaded | `LoadEvent` |
|
|
97
|
+
|
|
98
|
+
<br/>
|
|
99
|
+
|
|
100
|
+
## Public methods
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
getDashboards(): Promise<LuzmoDashboard[]>
|
|
104
|
+
// Returns an instantly resolved promise with an array of all the visible dashboards on a page with their information.
|
|
105
|
+
|
|
106
|
+
getData(itemId: string): Promise<ItemData>
|
|
107
|
+
// Returns an array the data of a chart of a certain dashboard by adding the dashboardId or the container of the iframe.
|
|
108
|
+
|
|
109
|
+
getFilters(): Promise<FilterGroup[]>
|
|
110
|
+
// Returns an array of active filters.
|
|
111
|
+
|
|
112
|
+
setAuthorization(key: string, token: string): Promise<void>
|
|
113
|
+
// Changes the authorization of all or one dashboard. To fetch data based on new authorization parameters, reloadDashboard() or refreshData() needs to be called.
|
|
114
|
+
|
|
115
|
+
refreshData(itemId?: string): Promise<void>
|
|
116
|
+
// Refreshes the data of a specific chart when the id of that item is supplied. Without a itemId this refreshes the data in all items.
|
|
117
|
+
|
|
118
|
+
reloadDashboard(): Promise<void>
|
|
119
|
+
// Reload the dashboard. (useful when the authorization is changed, and dashboard needs to be reloaded without reloading the iFrame)
|
|
120
|
+
|
|
121
|
+
exportDashboard(type?: ExportType): Promise<ExportDashboard>
|
|
122
|
+
// Exports the current dashboard as either pdf or png. A container class needs to be passed as an argument and an optional type parameter.
|
|
123
|
+
|
|
124
|
+
getAccessibleDashboards(): Promise<AccessibleDashboard[]>
|
|
125
|
+
// Get accessible dashboards in a integration, make sure 'apiHost', 'authKey', 'authToken' are set correctly on the instance.
|
|
126
|
+
|
|
127
|
+
setEditMode(editMode: DashboardEditMode): Promise<SetEditMode>
|
|
128
|
+
// Sets the editMode of the current dashboard. Accepted parameters: "view" , "editLimited" , "editFull".
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
<br/>
|
|
132
|
+
|
|
133
|
+
## Examples
|
|
134
|
+
|
|
135
|
+
A dashboard with a gray loader background
|
|
136
|
+
|
|
137
|
+
```html
|
|
138
|
+
<luzmo-dashboard dashboardId="035c0304-0bfe-4b7c-8c10-a4acb8eb9d76" loaderBackground="rgb(238,243,246)"> </luzmo-dashboard>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
A secured dashboard using an [authorization key & token](https://developer.luzmo.com/#quickstart)
|
|
142
|
+
|
|
143
|
+
```html
|
|
144
|
+
<luzmo-dashboard dashboardId="035c0304-0bfe-4b7c-8c10-a4acb8eb9d76" authKey="<!-- your generated authKey-->" authToken="<!-- your generated authToken -->"> </luzmo-dashboard>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
A dashboard with a purple spinner color of the loader with screenMode="mobile" and switchScreenModeOnResize=false, so that the dashboard will stay in mobile mode
|
|
148
|
+
|
|
149
|
+
```html
|
|
150
|
+
<luzmo-dashboard id="dashboard" dashboardId="55cfb99c-d602-492b-b192-6c15277fdb9a" loaderSpinnerColor="purple" screenMode="mobile" switchScreenModeOnResize="false"> </luzmo-dashboard>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Add an event listener when all items are rendered
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// get the component, here we query the component that has an id 'dashboard'
|
|
157
|
+
const dashboardComponent = document.getElementById('dashboard');
|
|
158
|
+
dashboardComponent.addEventListener('itemsRendered', (event) => {
|
|
159
|
+
// do something after all items are rendered
|
|
160
|
+
console.log(event);
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Get data from an item
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
dashboardComponent.getData('59fe5bd7-5070-42f5-98f4-da7f931e316c').then((data) => {
|
|
168
|
+
// do something with the item data
|
|
169
|
+
console.log('Item data', data);
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Get filters used in the dashboard
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
dashboardComponent.getFilters().then((data) => {
|
|
177
|
+
// do something with the item data
|
|
178
|
+
console.log('Item data', data);
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Export the dashboard
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
dashboardComponent.exportDashboard('png').then((data) => {
|
|
186
|
+
// do something with the item data
|
|
187
|
+
console.log('Item data', data);
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Get accessible dashboards of an integration
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
dashboardComponent.getAccessibleDashboards().then((dashboards) => {
|
|
195
|
+
// do something with the dashboards
|
|
196
|
+
console.log('Accessible dashboards', dashboards);
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Changelog
|
|
201
|
+
|
|
202
|
+
- [Changelog](https://embed-libs.luzmo.com/changelogs/embed/)
|
|
203
|
+
|
|
204
|
+
## Migration
|
|
205
|
+
|
|
206
|
+
### Migrating from cumul.io to luzmo.
|
|
207
|
+
|
|
208
|
+
* Change `import '@cumul.io/cumulio-dashboard` to `import @luzmo/embed`.
|
|
209
|
+
* Replace all references of `cumulio-dashboard` to `luzmo-dashboard`
|
|
210
|
+
|
|
211
|
+
## Quick links
|
|
212
|
+
|
|
213
|
+
[Luzmo](https://luzmo.com) |
|
|
214
|
+
[Demo - Sample Integration](https://sample-integration.luzmo.com/) |
|
|
215
|
+
[Changelog](https://embed-libs.luzmo.com/changelogs/embed/) |
|
|
216
|
+
[Migrations](https://embed-libs.luzmo.com/migrations/embed/)
|