@luzmo/embed 7.5.0 → 8.0.0-es2021
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/CHANGELOG.md +91 -0
- package/README.md +2 -2
- package/index.cjs +1619 -179
- package/index.js +1613 -165
- package/index.rn.cjs +1375 -0
- package/index.rn.js +1305 -0
- package/index.shared.cjs +1486 -0
- package/index.shared.js +1412 -0
- package/luzmo-embed.min.js +227 -132
- package/package.json +29 -3
- package/src/index.common.d.ts +18 -0
- package/src/index.d.ts +3 -3
- package/src/index.rn.d.ts +1 -0
- package/src/index.shared.d.ts +2 -0
- package/src/lib/dashboard/dashboard-base.d.ts +5 -1
- package/src/lib/iq-components/luzmo-iq-answer.d.ts +1 -2
- package/src/lib/iq-components/luzmo-iq-chat.d.ts +1 -1
- package/src/lib/shared/constants/class-constants.d.ts +1 -0
- package/src/lib/shared/helpers/browser-check.d.ts +2 -0
- package/src/lib/shared/helpers/default-parameters.d.ts +2 -0
- package/src/lib/shared/helpers/error.d.ts +5 -0
- package/src/lib/shared/helpers/extents.d.ts +7 -0
- package/src/lib/shared/helpers/get-loader.d.ts +5 -0
- package/src/lib/shared/helpers/iframe-url.d.ts +1 -0
- package/src/lib/shared/helpers/promise-dispatch.d.ts +3 -0
- package/src/lib/shared/helpers/remote-federation.d.ts +56 -0
- package/src/lib/shared/helpers/set-selected-data-utils.d.ts +7 -0
- package/src/lib/shared/helpers/styles.d.ts +8 -0
- package/src/lib/shared/helpers/translations.d.ts +24 -0
- package/src/lib/shared/helpers/update-iframe-url.d.ts +1 -0
- package/src/lib/shared/helpers/utils.d.ts +27 -0
- package/src/lib/shared/methods/export-dashboard.d.ts +5 -0
- package/src/lib/shared/methods/get-accessible-dashboards.d.ts +3 -0
- package/src/lib/shared/methods/get-dashboard-context.d.ts +3 -0
- package/src/lib/shared/methods/get-data.d.ts +3 -0
- package/src/lib/shared/methods/get-filters.d.ts +3 -0
- package/src/lib/shared/methods/get-insights.d.ts +3 -0
- package/src/lib/shared/methods/index.d.ts +13 -0
- package/src/lib/shared/methods/refresh-data.d.ts +2 -0
- package/src/lib/shared/methods/reload-dashboard.d.ts +2 -0
- package/src/lib/shared/methods/send-export-email.d.ts +4 -0
- package/src/lib/shared/methods/set-authorization.d.ts +2 -0
- package/src/lib/shared/methods/set-edit-mode.d.ts +3 -0
- package/src/lib/shared/methods/set-preview.d.ts +3 -0
- package/src/lib/shared/methods/set-selected-data.d.ts +4 -0
- package/src/lib/shared/models/common.model.d.ts +105 -0
- package/src/lib/shared/models/dashboard-context.model.d.ts +50 -0
- package/src/lib/shared/models/dashboard.model.d.ts +59 -0
- package/src/lib/shared/models/embed-error-event.model.d.ts +17 -0
- package/src/lib/shared/models/events.model.d.ts +94 -0
- package/src/lib/shared/models/filter-input.model.d.ts +101 -0
- package/src/lib/shared/models/filter-output.model.d.ts +17 -0
- package/src/lib/shared/models/filters.model.d.ts +26 -0
- package/src/lib/shared/models/index.d.ts +12 -0
- package/src/lib/shared/models/styles.model.d.ts +32 -0
- package/src/lib/shared/models/translation.model.d.ts +2 -0
- package/src/lib/shared/models/viz-item-post-message.model.d.ts +56 -0
- package/src/lib/shared/models/viz-item.model.d.ts +8 -0
- package/src/lib/shared/models/viz-items/areachart.model.d.ts +13 -0
- package/src/lib/shared/models/viz-items/barchart.model.d.ts +24 -0
- package/src/lib/shared/models/viz-items/choroplethmap.model.d.ts +13 -0
- package/src/lib/shared/models/viz-items/circlepack.model.d.ts +2 -0
- package/src/lib/shared/models/viz-items/columnchart.model.d.ts +24 -0
- package/src/lib/shared/models/viz-items/datetime.model.d.ts +13 -0
- package/src/lib/shared/models/viz-items/donutchart.model.d.ts +2 -0
- package/src/lib/shared/models/viz-items/dropdownfilter.model.d.ts +13 -0
- package/src/lib/shared/models/viz-items/index.d.ts +36 -0
- package/src/lib/shared/models/viz-items/linechart.model.d.ts +36 -0
- package/src/lib/shared/models/viz-items/parallelcoordinatesplot.model.d.ts +14 -0
- package/src/lib/shared/models/viz-items/piechart.model.d.ts +24 -0
- package/src/lib/shared/models/viz-items/scatterplot.model.d.ts +13 -0
- package/src/lib/shared/models/viz-items/slicer.model.d.ts +24 -0
- package/src/lib/shared/models/viz-items/slider.model.d.ts +13 -0
- package/src/lib/shared/models/viz-items/stripplot.model.d.ts +15 -0
- package/src/lib/shared/models/viz-items/sunburst.model.d.ts +14 -0
- package/src/lib/shared/models/viz-items/treemap.model.d.ts +24 -0
- package/src/lib/shared/service/calculate-dimensions.d.ts +1 -0
- package/src/lib/shared/service/extend-and-validate.d.ts +2 -0
- package/src/lib/{helper → utils}/embed-error.utils.d.ts +1 -1
- package/src/lib/viz-item/viz-item.base.d.ts +2 -2
- /package/src/lib/{helper → utils}/event-bus-handler.d.ts +0 -0
- /package/src/lib/{helper → utils}/json-schema-utils.d.ts +0 -0
package/index.shared.cjs
ADDED
|
@@ -0,0 +1,1486 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// libs/embed-libs/embed/src/index.shared.ts
|
|
21
|
+
var index_shared_exports = {};
|
|
22
|
+
__export(index_shared_exports, {
|
|
23
|
+
DEFAULT_PARAMETERS: () => DEFAULT_PARAMETERS,
|
|
24
|
+
EXTENTS: () => EXTENTS,
|
|
25
|
+
TRANSLATIONS: () => TRANSLATIONS,
|
|
26
|
+
VERSION: () => VERSION,
|
|
27
|
+
_browserCheck: () => _browserCheck,
|
|
28
|
+
_extendAndValidate: () => _extendAndValidate,
|
|
29
|
+
_handleError: () => _handleError,
|
|
30
|
+
_setCalculatedDimensions: () => _setCalculatedDimensions,
|
|
31
|
+
addTrailingSlash: () => addTrailingSlash,
|
|
32
|
+
calculateIframeStyles: () => calculateIframeStyles,
|
|
33
|
+
cloneDeep: () => cloneDeep,
|
|
34
|
+
containerLoaderStyles: () => containerLoaderStyles,
|
|
35
|
+
containerStyles: () => containerStyles,
|
|
36
|
+
createIframeUrl: () => createIframeUrl,
|
|
37
|
+
defaultsDeep: () => defaultsDeep,
|
|
38
|
+
exportDashboard: () => exportDashboard,
|
|
39
|
+
formatDashboardList: () => formatDashboardList,
|
|
40
|
+
getAccessibleDashboards: () => getAccessibleDashboards,
|
|
41
|
+
getDashboardContext: () => getDashboardContext,
|
|
42
|
+
getData: () => getData,
|
|
43
|
+
getFilters: () => getFilters,
|
|
44
|
+
getInsights: () => getInsights,
|
|
45
|
+
getLoader: () => getLoader,
|
|
46
|
+
lcStyles: () => lcStyles,
|
|
47
|
+
libraryAcceptedParametersList: () => libraryAcceptedParametersList,
|
|
48
|
+
libraryTypeToWebComponentTypeMapping: () => libraryTypeToWebComponentTypeMapping,
|
|
49
|
+
loadLibrary: () => loadLibrary,
|
|
50
|
+
loaderStyles: () => loaderStyles,
|
|
51
|
+
luzmoEmbedContainerClass: () => luzmoEmbedContainerClass,
|
|
52
|
+
plStyles: () => plStyles,
|
|
53
|
+
preloadDashboard: () => preloadDashboard,
|
|
54
|
+
preloadIQ: () => preloadIQ,
|
|
55
|
+
preloadVizItem: () => preloadVizItem,
|
|
56
|
+
refreshData: () => refreshData,
|
|
57
|
+
rejectPromise: () => rejectPromise,
|
|
58
|
+
reloadDashboard: () => reloadDashboard,
|
|
59
|
+
removeTrailingSlash: () => removeTrailingSlash,
|
|
60
|
+
resolvePromise: () => resolvePromise,
|
|
61
|
+
s4: () => s4,
|
|
62
|
+
sanitizeUrl: () => sanitizeUrl,
|
|
63
|
+
selectedDataUtils: () => selectedDataUtils,
|
|
64
|
+
sendExportEmail: () => sendExportEmail,
|
|
65
|
+
setAuthorization: () => setAuthorization,
|
|
66
|
+
setEditMode: () => setEditMode,
|
|
67
|
+
setPreview: () => setPreview,
|
|
68
|
+
setSelectedData: () => setSelectedData,
|
|
69
|
+
updateIframeUrl: () => updateIframeUrl,
|
|
70
|
+
uuidv4: () => uuidv4
|
|
71
|
+
});
|
|
72
|
+
module.exports = __toCommonJS(index_shared_exports);
|
|
73
|
+
|
|
74
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/error.ts
|
|
75
|
+
var _handleError = (errorMessage, parameters) => {
|
|
76
|
+
let message = "The dashboard component encountered an error";
|
|
77
|
+
if (typeof parameters?.dashboardId === "string") {
|
|
78
|
+
message += ` for dashboard with id ${parameters.dashboardId}`;
|
|
79
|
+
}
|
|
80
|
+
if (typeof parameters?.dashboardSlug === "string") {
|
|
81
|
+
message += ` for dashboard with slug ${parameters.dashboardSlug}`;
|
|
82
|
+
}
|
|
83
|
+
if (typeof parameters?.container === "string") {
|
|
84
|
+
message += ` in container ${parameters.container}`;
|
|
85
|
+
}
|
|
86
|
+
if (errorMessage) {
|
|
87
|
+
message += `:
|
|
88
|
+
${errorMessage}`;
|
|
89
|
+
console.warn(message);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/browser-check.ts
|
|
94
|
+
var _browserCheck = (dashboardComponent) => {
|
|
95
|
+
let hasError = false;
|
|
96
|
+
let errorMessage = "";
|
|
97
|
+
const document_ = document.body || document.documentElement;
|
|
98
|
+
const style = document_.style;
|
|
99
|
+
const browserCheck = {
|
|
100
|
+
svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
|
|
101
|
+
flexbox: style.webkitFlexWrap === "" || style.flexWrap === "",
|
|
102
|
+
postMessage: !!window.postMessage
|
|
103
|
+
};
|
|
104
|
+
const browserCheckKeys = ["svg", "flexbox", "postMessage"];
|
|
105
|
+
for (const key of browserCheckKeys) {
|
|
106
|
+
if (!browserCheck[key]) {
|
|
107
|
+
hasError = true;
|
|
108
|
+
dashboardComponent.browserNotSupported = dashboardComponent.browserNotSupported || [];
|
|
109
|
+
dashboardComponent.browserNotSupported.push(key);
|
|
110
|
+
errorMessage += `Your browser does not support: ${key}
|
|
111
|
+
`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const ua = window.navigator.userAgent;
|
|
115
|
+
const msie = ua.includes("MSIE");
|
|
116
|
+
const trident = ua.includes("Trident/");
|
|
117
|
+
if (msie || trident) {
|
|
118
|
+
hasError = true;
|
|
119
|
+
errorMessage = "IE is not supported.";
|
|
120
|
+
}
|
|
121
|
+
if (hasError) {
|
|
122
|
+
_handleError(errorMessage);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/default-parameters.ts
|
|
127
|
+
var DEFAULT_PARAMETERS = {
|
|
128
|
+
appServer: "https://app.luzmo.com/",
|
|
129
|
+
apiHost: "https://api.luzmo.com/",
|
|
130
|
+
dashboardId: null,
|
|
131
|
+
dashboardSlug: null,
|
|
132
|
+
container: null,
|
|
133
|
+
key: null,
|
|
134
|
+
token: null,
|
|
135
|
+
language: "auto",
|
|
136
|
+
editorLanguage: "auto",
|
|
137
|
+
editMode: null,
|
|
138
|
+
screenMode: null,
|
|
139
|
+
switchScreenModeOnResize: true,
|
|
140
|
+
itemId: null,
|
|
141
|
+
theme: "",
|
|
142
|
+
mainColor: "",
|
|
143
|
+
itemDimensions: {
|
|
144
|
+
width: "auto",
|
|
145
|
+
height: "auto"
|
|
146
|
+
},
|
|
147
|
+
loaderBackground: "#f9f9f9",
|
|
148
|
+
loaderFontColor: "#5a5a5a",
|
|
149
|
+
loaderSpinnerColor: "rgb(68, 52, 255)",
|
|
150
|
+
loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
|
|
151
|
+
timezoneId: null,
|
|
152
|
+
contextId: null
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/extents.ts
|
|
156
|
+
var EXTENTS = [
|
|
157
|
+
{ mode: "mobile", width: [150, 767] },
|
|
158
|
+
{ mode: "tablet", width: [768, 1199] },
|
|
159
|
+
{ mode: "desktop", width: [1200, 1599] },
|
|
160
|
+
{ mode: "largeScreen", width: [1600, 9999] },
|
|
161
|
+
{ mode: "fixed", width: [] }
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/translations.ts
|
|
165
|
+
var TRANSLATIONS = {
|
|
166
|
+
initializing: {
|
|
167
|
+
en: "Initializing...",
|
|
168
|
+
nl: "Laden...",
|
|
169
|
+
fr: "Chargement...",
|
|
170
|
+
de: "Initialisiere...",
|
|
171
|
+
es: "Inicializando..."
|
|
172
|
+
},
|
|
173
|
+
errorDashboard: {
|
|
174
|
+
en: "Oops, we could not load this dashboard!",
|
|
175
|
+
nl: "Oeps, we konden het dashboard niet laden.",
|
|
176
|
+
fr: "Le chargement a echou\xE9.",
|
|
177
|
+
de: "Hoppla, wir konnten dieses Dashboard nicht laden!",
|
|
178
|
+
es: "\xA1Ups! No pudimos cargar este tablero."
|
|
179
|
+
},
|
|
180
|
+
errorItem: {
|
|
181
|
+
en: "Oops, we could not load this item!",
|
|
182
|
+
nl: "Oeps, we konden de grafiek niet laden.",
|
|
183
|
+
fr: "Le chargement a echou\xE9.",
|
|
184
|
+
de: "Hoppla, wir konnten dieses Diagramm nicht laden!",
|
|
185
|
+
es: "\xA1Ups! No pudimos cargar este elemento."
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var translations_default = TRANSLATIONS;
|
|
189
|
+
|
|
190
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/utils.ts
|
|
191
|
+
var addTrailingSlash = (serverUrl) => {
|
|
192
|
+
if (!serverUrl) {
|
|
193
|
+
return "";
|
|
194
|
+
}
|
|
195
|
+
return serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
|
|
196
|
+
};
|
|
197
|
+
var removeTrailingSlash = (serverUrl) => {
|
|
198
|
+
if (!serverUrl) {
|
|
199
|
+
return "";
|
|
200
|
+
}
|
|
201
|
+
return serverUrl.endsWith("/") ? serverUrl.slice(0, -1) : serverUrl;
|
|
202
|
+
};
|
|
203
|
+
var formatDashboardList = (dashboards, integrationId, user, dashboardComponent) => {
|
|
204
|
+
const combineRights = (securable, accessUser) => {
|
|
205
|
+
const matchingUser = securable.users.find((u) => u.id === accessUser.id);
|
|
206
|
+
const securableAccessRights = matchingUser && matchingUser.userAccessRight ? {
|
|
207
|
+
flagRead: matchingUser.userAccessRight.flagRead,
|
|
208
|
+
flagUse: matchingUser.userAccessRight.flagUse,
|
|
209
|
+
flagModify: matchingUser.userAccessRight.flagModify,
|
|
210
|
+
flagOwn: matchingUser.userAccessRight.flagOwn
|
|
211
|
+
} : {
|
|
212
|
+
flagRead: false,
|
|
213
|
+
flagUse: false,
|
|
214
|
+
flagModify: false,
|
|
215
|
+
flagOwn: false
|
|
216
|
+
};
|
|
217
|
+
const groups = securable.groups.filter(
|
|
218
|
+
(group) => accessUser.userGroups.includes(group.id) || group.public === true
|
|
219
|
+
);
|
|
220
|
+
const groupsAccess = groups.map((group) => {
|
|
221
|
+
if (group.groupAccessRight) {
|
|
222
|
+
return group.groupAccessRight;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
for (const groupAccess of groupsAccess) {
|
|
226
|
+
if (!securableAccessRights.flagRead && groupAccess.flagRead) {
|
|
227
|
+
securableAccessRights.flagRead = groupAccess.flagRead;
|
|
228
|
+
}
|
|
229
|
+
if (!securableAccessRights.flagUse && groupAccess.flagUse) {
|
|
230
|
+
securableAccessRights.flagUse = groupAccess.flagUse;
|
|
231
|
+
}
|
|
232
|
+
if (!securableAccessRights.flagModify && groupAccess.flagModify) {
|
|
233
|
+
securableAccessRights.flagModify = groupAccess.flagModify;
|
|
234
|
+
}
|
|
235
|
+
if (!securableAccessRights.flagOwn && groupAccess.flagOwn) {
|
|
236
|
+
securableAccessRights.flagOwn = groupAccess.flagOwn;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const integrationsAccess = securable.integrations?.length > 0 ? securable.integrations.map((integration) => {
|
|
240
|
+
if (integration.integrationAccessRight) {
|
|
241
|
+
return integration.integrationAccessRight;
|
|
242
|
+
}
|
|
243
|
+
}) : [];
|
|
244
|
+
for (const integrationAccess of integrationsAccess) {
|
|
245
|
+
if (!securableAccessRights.flagRead && integrationAccess.flagRead) {
|
|
246
|
+
securableAccessRights.flagRead = integrationAccess.flagRead;
|
|
247
|
+
}
|
|
248
|
+
if (!securableAccessRights.flagUse && integrationAccess.flagUse) {
|
|
249
|
+
securableAccessRights.flagUse = integrationAccess.flagUse;
|
|
250
|
+
}
|
|
251
|
+
if (!securableAccessRights.flagModify && integrationAccess.flagModify) {
|
|
252
|
+
securableAccessRights.flagModify = integrationAccess.flagModify;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return securableAccessRights;
|
|
256
|
+
};
|
|
257
|
+
const localize = (item, locale) => {
|
|
258
|
+
if (item === null || item === void 0) {
|
|
259
|
+
return "";
|
|
260
|
+
}
|
|
261
|
+
if (typeof item !== "object" || Object.keys(item).length === 0) {
|
|
262
|
+
if (typeof item === "object" && Object.keys(item).length === 0) {
|
|
263
|
+
return "";
|
|
264
|
+
}
|
|
265
|
+
return item;
|
|
266
|
+
}
|
|
267
|
+
let localizedItem;
|
|
268
|
+
localizedItem = locale && item[locale] ? item[locale] : item[Object.keys(item)[0]];
|
|
269
|
+
if (localizedItem === void 0 || localizedItem === null) {
|
|
270
|
+
localizedItem = "";
|
|
271
|
+
}
|
|
272
|
+
return localizedItem;
|
|
273
|
+
};
|
|
274
|
+
const treatedDashboards = [];
|
|
275
|
+
for (const dashboard of dashboards) {
|
|
276
|
+
const treatedDashboard = {
|
|
277
|
+
accessibleBy: [],
|
|
278
|
+
accessRights: combineRights(dashboard, user),
|
|
279
|
+
id: dashboard.id,
|
|
280
|
+
modifiedAt: dashboard.modified_at,
|
|
281
|
+
name: localize(dashboard.name, dashboardComponent.language),
|
|
282
|
+
slug: null,
|
|
283
|
+
tags: dashboard.tags.map((t) => t.tag).sort((t1, t2) => t1.localeCompare(t2))
|
|
284
|
+
};
|
|
285
|
+
const currentIntegration = dashboard.integrations.find(
|
|
286
|
+
(i) => i.id === integrationId
|
|
287
|
+
);
|
|
288
|
+
if (currentIntegration?.integrationAccessRight?.slug) {
|
|
289
|
+
treatedDashboard.slug = currentIntegration.integrationAccessRight.slug;
|
|
290
|
+
}
|
|
291
|
+
const users = dashboard.users.map((u) => ({
|
|
292
|
+
model: "User",
|
|
293
|
+
id: u.id,
|
|
294
|
+
name: localize(u.name, user.locale_id)
|
|
295
|
+
}));
|
|
296
|
+
const groups = dashboard.groups.map((g) => ({
|
|
297
|
+
model: "Group",
|
|
298
|
+
id: g.id,
|
|
299
|
+
name: localize(g.name, user.locale_id) || {}
|
|
300
|
+
}));
|
|
301
|
+
const integrations = dashboard.integrations.map((i) => ({
|
|
302
|
+
model: "Integration",
|
|
303
|
+
id: i.id,
|
|
304
|
+
name: localize(i.name, user.locale_id) || {}
|
|
305
|
+
}));
|
|
306
|
+
treatedDashboard.accessibleBy = [...users, ...groups, ...integrations];
|
|
307
|
+
treatedDashboards.push(treatedDashboard);
|
|
308
|
+
}
|
|
309
|
+
return treatedDashboards;
|
|
310
|
+
};
|
|
311
|
+
var VERSION = "0.0.0-unknown-luzmo";
|
|
312
|
+
var sanitizeUrl = (url) => {
|
|
313
|
+
const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
|
|
314
|
+
const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
|
|
315
|
+
const urlSchemeRegex = /^([^:]+):/gm;
|
|
316
|
+
const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
|
|
317
|
+
const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
|
|
318
|
+
if (!url) {
|
|
319
|
+
return "about:blank";
|
|
320
|
+
}
|
|
321
|
+
const sanitizedUrl = url.replaceAll(ctrlCharactersRegex, "").trim();
|
|
322
|
+
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
323
|
+
return sanitizedUrl;
|
|
324
|
+
}
|
|
325
|
+
const urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
|
|
326
|
+
if (!urlSchemeParseResults) {
|
|
327
|
+
return sanitizedUrl;
|
|
328
|
+
}
|
|
329
|
+
const urlScheme = urlSchemeParseResults[0];
|
|
330
|
+
if (invalidPrototcolRegex.test(urlScheme)) {
|
|
331
|
+
return "about:blank";
|
|
332
|
+
}
|
|
333
|
+
return sanitizedUrl;
|
|
334
|
+
};
|
|
335
|
+
var cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
|
|
336
|
+
var isObject = (o) => o && typeof o === "object";
|
|
337
|
+
var defaultsDeep = (target, defaults) => {
|
|
338
|
+
Object.entries(defaults).forEach(([k, v]) => {
|
|
339
|
+
if (k in target) {
|
|
340
|
+
if (target[k] === void 0) {
|
|
341
|
+
target[k] = v;
|
|
342
|
+
} else {
|
|
343
|
+
target[k] = isObject(v) ? defaultsDeep(
|
|
344
|
+
target[k],
|
|
345
|
+
v
|
|
346
|
+
) : target[k];
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
target[k] = v;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
return target;
|
|
353
|
+
};
|
|
354
|
+
var s4 = () => Math.floor((1 + Math.random()) * 65536).toString(16).slice(1);
|
|
355
|
+
var uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(c) {
|
|
356
|
+
const r = Math.trunc(Math.random() * 16);
|
|
357
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
358
|
+
return v.toString(16);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/iframe-url.ts
|
|
362
|
+
var createIframeUrl = (dashboardContent) => {
|
|
363
|
+
const searchString = [];
|
|
364
|
+
const {
|
|
365
|
+
appServer,
|
|
366
|
+
language,
|
|
367
|
+
editorLanguage,
|
|
368
|
+
loaderBackground,
|
|
369
|
+
loaderSpinnerColor,
|
|
370
|
+
loaderSpinnerBackground,
|
|
371
|
+
loaderFontColor,
|
|
372
|
+
screenMode,
|
|
373
|
+
key,
|
|
374
|
+
token,
|
|
375
|
+
timezoneId,
|
|
376
|
+
itemEmbedding,
|
|
377
|
+
itemDimensions,
|
|
378
|
+
dashboardId,
|
|
379
|
+
dashboardSlug,
|
|
380
|
+
itemId,
|
|
381
|
+
theme,
|
|
382
|
+
mainColor,
|
|
383
|
+
editMode
|
|
384
|
+
} = dashboardContent.params;
|
|
385
|
+
if (language && language !== "auto") {
|
|
386
|
+
searchString.push(`language=${language}`);
|
|
387
|
+
}
|
|
388
|
+
if (editorLanguage && editorLanguage !== "auto") {
|
|
389
|
+
searchString.push(`editorLanguage=${editorLanguage}`);
|
|
390
|
+
}
|
|
391
|
+
if (loaderBackground) {
|
|
392
|
+
searchString.push(`ldrbg=${loaderBackground}`);
|
|
393
|
+
}
|
|
394
|
+
if (loaderFontColor) {
|
|
395
|
+
searchString.push(`ldrftclr=${loaderFontColor}`);
|
|
396
|
+
}
|
|
397
|
+
if (loaderSpinnerColor) {
|
|
398
|
+
searchString.push(`ldrspclr=${loaderSpinnerColor}`);
|
|
399
|
+
}
|
|
400
|
+
if (loaderSpinnerBackground) {
|
|
401
|
+
searchString.push(`ldrspbg=${loaderSpinnerBackground}`);
|
|
402
|
+
}
|
|
403
|
+
if (theme) {
|
|
404
|
+
searchString.push(`theme=${theme}`);
|
|
405
|
+
}
|
|
406
|
+
if (mainColor) {
|
|
407
|
+
searchString.push(`mainColor=${mainColor}`);
|
|
408
|
+
}
|
|
409
|
+
if (screenMode && screenMode !== "auto") {
|
|
410
|
+
searchString.push(`screenMode=${screenMode}`);
|
|
411
|
+
}
|
|
412
|
+
if (timezoneId) {
|
|
413
|
+
searchString.push("timezoneId=" + timezoneId);
|
|
414
|
+
}
|
|
415
|
+
if (itemEmbedding && itemDimensions && itemDimensions.width) {
|
|
416
|
+
searchString.push("width=" + itemDimensions.width);
|
|
417
|
+
}
|
|
418
|
+
if (itemEmbedding && itemDimensions && itemDimensions.height) {
|
|
419
|
+
searchString.push("height=" + itemDimensions.height);
|
|
420
|
+
}
|
|
421
|
+
if (editMode) {
|
|
422
|
+
searchString.push("editMode=" + editMode);
|
|
423
|
+
}
|
|
424
|
+
const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
|
|
425
|
+
searchString.push("version=" + (dashboardContent.libVersion || VERSION));
|
|
426
|
+
const appServerWithSlash = addTrailingSlash(appServer);
|
|
427
|
+
const iframeUrl = itemEmbedding ? `${appServerWithSlash}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
|
|
428
|
+
searchString.join("&")
|
|
429
|
+
)}${keyTokenUrlAnchor}` : `${appServerWithSlash}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
|
|
430
|
+
searchString.join("&")
|
|
431
|
+
)}${keyTokenUrlAnchor}`;
|
|
432
|
+
return sanitizeUrl(iframeUrl);
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
|
|
436
|
+
var getLoader = (dashboardComponent) => {
|
|
437
|
+
let errorMsg;
|
|
438
|
+
if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
|
|
439
|
+
dashboardComponent.params.error = true;
|
|
440
|
+
if (dashboardComponent.browserNotSupported) {
|
|
441
|
+
errorMsg = "Browser is not supported.";
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
|
|
445
|
+
return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
|
|
449
|
+
function resolvePromise(dashboardComponent, requestId, data) {
|
|
450
|
+
if (dashboardComponent.promises[requestId]) {
|
|
451
|
+
dashboardComponent.promises[requestId].resolve(data);
|
|
452
|
+
delete dashboardComponent.promises[requestId];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function rejectPromise(dashboardComponent, requestId, data) {
|
|
456
|
+
if (dashboardComponent.promises[requestId]) {
|
|
457
|
+
dashboardComponent.promises[requestId].reject(data);
|
|
458
|
+
delete dashboardComponent.promises[requestId];
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
|
|
463
|
+
function containerStyles(dashboardComponent) {
|
|
464
|
+
const styles = {};
|
|
465
|
+
if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
|
|
466
|
+
styles.background = dashboardComponent.params.loaderBackground;
|
|
467
|
+
}
|
|
468
|
+
return styles;
|
|
469
|
+
}
|
|
470
|
+
function containerLoaderStyles(dashboardComponent) {
|
|
471
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
472
|
+
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
473
|
+
const display = dashboardComponent.iframeLoaded ? "none" : "";
|
|
474
|
+
return {
|
|
475
|
+
display,
|
|
476
|
+
height: `${chartHeightDefined ? height : dashboardComponent.minHeight}px`
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
function loaderStyles(dashboardComponent) {
|
|
480
|
+
const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
|
|
481
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
482
|
+
dashboardComponent.loaderSize = 24;
|
|
483
|
+
dashboardComponent.borderWidth = 4;
|
|
484
|
+
dashboardComponent.minHeight = 200;
|
|
485
|
+
const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
486
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
487
|
+
const chartWidthDefined = width !== "auto";
|
|
488
|
+
const chartHeightDefined = height !== "auto";
|
|
489
|
+
return {
|
|
490
|
+
background,
|
|
491
|
+
width: chartWidthDefined ? `${width}px` : "100%",
|
|
492
|
+
height: `${chartHeightDefined ? height : "200"}px`,
|
|
493
|
+
"min-height": chartHeightDefined ? "" : "200px"
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
background
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
function generateBorderStyle(borderWidth, color) {
|
|
501
|
+
return `${borderWidth}px solid ${color}`;
|
|
502
|
+
}
|
|
503
|
+
function plStyles(dashboardComponent) {
|
|
504
|
+
const {
|
|
505
|
+
loaderSpinnerColor: defaultSpinnerColor,
|
|
506
|
+
loaderSpinnerBackground: defaultSpinnerBackground
|
|
507
|
+
} = DEFAULT_PARAMETERS;
|
|
508
|
+
const spinnerColorBorder = generateBorderStyle(
|
|
509
|
+
dashboardComponent.borderWidth,
|
|
510
|
+
dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
|
|
511
|
+
);
|
|
512
|
+
const spinnerBackgroundBorder = generateBorderStyle(
|
|
513
|
+
dashboardComponent.borderWidth,
|
|
514
|
+
dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
|
|
515
|
+
);
|
|
516
|
+
const size = `${dashboardComponent.loaderSize}px`;
|
|
517
|
+
return {
|
|
518
|
+
"border-top": spinnerColorBorder,
|
|
519
|
+
"border-right": spinnerColorBorder,
|
|
520
|
+
"border-bottom": spinnerBackgroundBorder,
|
|
521
|
+
"border-left": spinnerBackgroundBorder,
|
|
522
|
+
width: size,
|
|
523
|
+
height: size
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
function lcStyles(dashboardComponent) {
|
|
527
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
528
|
+
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
529
|
+
const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
|
|
530
|
+
const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
|
|
531
|
+
return {
|
|
532
|
+
padding: `${verticalPadding} 16px`
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
function calculateIframeStyles(dashboardComponent) {
|
|
536
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
537
|
+
const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
538
|
+
if (dashboardComponent.params.itemEmbedding && height !== "auto") {
|
|
539
|
+
dashboardComponent.iframeHeight = `${height}px`;
|
|
540
|
+
} else if (dashboardComponent.params.itemEmbedding) {
|
|
541
|
+
dashboardComponent.iframeHeight = "200px";
|
|
542
|
+
} else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
|
|
543
|
+
dashboardComponent.iframeHeight = "100%";
|
|
544
|
+
} else {
|
|
545
|
+
dashboardComponent.iframeHeight = "400px";
|
|
546
|
+
}
|
|
547
|
+
dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
|
|
548
|
+
const styles = {
|
|
549
|
+
height: dashboardComponent.iframeHeight,
|
|
550
|
+
width: dashboardComponent.iframeWidth
|
|
551
|
+
};
|
|
552
|
+
if (dashboardComponent.iframeLoaded) {
|
|
553
|
+
styles.opacity = 1;
|
|
554
|
+
} else if (dashboardComponent.error) {
|
|
555
|
+
styles.opacity = 1;
|
|
556
|
+
styles.width = "100%";
|
|
557
|
+
styles.height = "400px";
|
|
558
|
+
} else {
|
|
559
|
+
styles.opacity = 0;
|
|
560
|
+
}
|
|
561
|
+
return styles;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
|
|
565
|
+
var updateIframeUrl = (iframe, iframeUrl) => {
|
|
566
|
+
if (iframe?.contentWindow) {
|
|
567
|
+
iframe.contentWindow.location.replace(iframeUrl);
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/set-selected-data-utils.ts
|
|
572
|
+
var selectedDataUtils = {
|
|
573
|
+
merge(...filters) {
|
|
574
|
+
return filters.reduce((acc, filter) => {
|
|
575
|
+
acc.and.push(...filter.and);
|
|
576
|
+
return acc;
|
|
577
|
+
}, {
|
|
578
|
+
and: []
|
|
579
|
+
});
|
|
580
|
+
},
|
|
581
|
+
isIn(slot, values, otherOptions) {
|
|
582
|
+
return {
|
|
583
|
+
and: [{
|
|
584
|
+
expression: "? in ?",
|
|
585
|
+
parameters: [
|
|
586
|
+
{
|
|
587
|
+
slot,
|
|
588
|
+
...otherOptions
|
|
589
|
+
},
|
|
590
|
+
values
|
|
591
|
+
]
|
|
592
|
+
}]
|
|
593
|
+
};
|
|
594
|
+
},
|
|
595
|
+
between(slot, values, otherOptions) {
|
|
596
|
+
return {
|
|
597
|
+
and: [{
|
|
598
|
+
expression: "? between ?",
|
|
599
|
+
parameters: [
|
|
600
|
+
{
|
|
601
|
+
slot,
|
|
602
|
+
...otherOptions
|
|
603
|
+
},
|
|
604
|
+
[values[0], values[1]]
|
|
605
|
+
]
|
|
606
|
+
}]
|
|
607
|
+
};
|
|
608
|
+
},
|
|
609
|
+
range(slot, values, otherOptions) {
|
|
610
|
+
const expressions = otherOptions?.expressions ?? ["? >= ?", "? < ?"];
|
|
611
|
+
return {
|
|
612
|
+
and: [{
|
|
613
|
+
expression: expressions[0],
|
|
614
|
+
parameters: [
|
|
615
|
+
{
|
|
616
|
+
slot,
|
|
617
|
+
...otherOptions
|
|
618
|
+
},
|
|
619
|
+
[values[0]]
|
|
620
|
+
]
|
|
621
|
+
}, {
|
|
622
|
+
expression: expressions[1],
|
|
623
|
+
parameters: [
|
|
624
|
+
{
|
|
625
|
+
slot,
|
|
626
|
+
...otherOptions
|
|
627
|
+
},
|
|
628
|
+
[values[1]]
|
|
629
|
+
]
|
|
630
|
+
}]
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
// libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
|
|
636
|
+
var exportDashboard = (dashboardComponent, iframe, format) => {
|
|
637
|
+
const requestId = uuidv4();
|
|
638
|
+
if (iframe?.contentWindow) {
|
|
639
|
+
iframe.contentWindow.postMessage(
|
|
640
|
+
{
|
|
641
|
+
action: "exportDashboard",
|
|
642
|
+
format: format || "png",
|
|
643
|
+
_version: dashboardComponent.libVersion,
|
|
644
|
+
requestId
|
|
645
|
+
},
|
|
646
|
+
"*"
|
|
647
|
+
);
|
|
648
|
+
return new Promise((resolve, reject) => {
|
|
649
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
650
|
+
setTimeout(() => {
|
|
651
|
+
if (dashboardComponent.promises[requestId]) {
|
|
652
|
+
const errorMessage = "exportDashboard request timed out.";
|
|
653
|
+
dashboardComponent.promises[requestId].reject(
|
|
654
|
+
new Error(errorMessage)
|
|
655
|
+
);
|
|
656
|
+
delete dashboardComponent.promises[requestId];
|
|
657
|
+
}
|
|
658
|
+
}, 12e5);
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
|
|
665
|
+
var getAccessibleDashboards = async (dashboardComponent) => {
|
|
666
|
+
await dashboardComponent.updateComplete;
|
|
667
|
+
if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
|
|
668
|
+
const fetchUser = new Promise((resolve, reject) => {
|
|
669
|
+
void (() => {
|
|
670
|
+
try {
|
|
671
|
+
const responsePromise = window.fetch(
|
|
672
|
+
// With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
|
|
673
|
+
// Fixes incorrect url with embedMode="webComponent"
|
|
674
|
+
`${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
|
|
675
|
+
{
|
|
676
|
+
method: "POST",
|
|
677
|
+
mode: "cors",
|
|
678
|
+
cache: "no-cache",
|
|
679
|
+
headers: { "Content-Type": "application/json" },
|
|
680
|
+
redirect: "follow",
|
|
681
|
+
body: JSON.stringify({
|
|
682
|
+
action: "get",
|
|
683
|
+
version: "0.1.0",
|
|
684
|
+
key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
|
|
685
|
+
token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
|
|
686
|
+
find: {
|
|
687
|
+
where: { id: dashboardComponent.authKey },
|
|
688
|
+
attributes: ["id", "integration_id"],
|
|
689
|
+
include: [
|
|
690
|
+
{
|
|
691
|
+
model: "User",
|
|
692
|
+
attributes: ["id", "name", "locale_id"],
|
|
693
|
+
include: [{ model: "Group" }]
|
|
694
|
+
}
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
})
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
701
|
+
if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user) {
|
|
702
|
+
reject("Authorization failed, please check authKey and authToken. If the problem persists, please contact support@luzmo.com.");
|
|
703
|
+
} else {
|
|
704
|
+
data.rows[0].user.userGroups = data.rows[0].user.groups.map(
|
|
705
|
+
(group) => group.id
|
|
706
|
+
);
|
|
707
|
+
delete data.rows[0].user.groups;
|
|
708
|
+
resolve({
|
|
709
|
+
integrationId: data.rows[0].integration_id,
|
|
710
|
+
user: data.rows[0].user
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
} catch (error) {
|
|
715
|
+
reject(error);
|
|
716
|
+
}
|
|
717
|
+
})();
|
|
718
|
+
});
|
|
719
|
+
return new Promise((resolve, reject) => void (() => {
|
|
720
|
+
try {
|
|
721
|
+
fetchUser.then((authorizationData) => {
|
|
722
|
+
const responsePromise = window.fetch(
|
|
723
|
+
// With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
|
|
724
|
+
// Fixes incorrect url with embedMode="webComponent"
|
|
725
|
+
`${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
|
|
726
|
+
{
|
|
727
|
+
method: "POST",
|
|
728
|
+
mode: "cors",
|
|
729
|
+
cache: "no-cache",
|
|
730
|
+
headers: { "Content-Type": "application/json" },
|
|
731
|
+
redirect: "follow",
|
|
732
|
+
body: JSON.stringify({
|
|
733
|
+
action: "get",
|
|
734
|
+
version: "0.1.0",
|
|
735
|
+
key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
|
|
736
|
+
token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
|
|
737
|
+
find: {
|
|
738
|
+
where: { type: "dashboard", is_variant: false },
|
|
739
|
+
attributes: ["id", "name", "modified_at"],
|
|
740
|
+
order: [["modified_at", "desc"]],
|
|
741
|
+
include: [
|
|
742
|
+
{ model: "Tag", attributes: ["tag"] },
|
|
743
|
+
{ model: "User", attributes: ["id", "name"] },
|
|
744
|
+
{
|
|
745
|
+
model: "Group",
|
|
746
|
+
attributes: ["id", "name", "public"]
|
|
747
|
+
},
|
|
748
|
+
{ model: "Integration", attributes: ["id", "name"] }
|
|
749
|
+
]
|
|
750
|
+
}
|
|
751
|
+
})
|
|
752
|
+
}
|
|
753
|
+
);
|
|
754
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
755
|
+
const dashboardList = data.rows.length > 0 ? formatDashboardList(
|
|
756
|
+
data.rows,
|
|
757
|
+
authorizationData.integrationId,
|
|
758
|
+
authorizationData.user,
|
|
759
|
+
dashboardComponent
|
|
760
|
+
) : [];
|
|
761
|
+
resolve(dashboardList);
|
|
762
|
+
});
|
|
763
|
+
}).catch((error) => {
|
|
764
|
+
reject(error);
|
|
765
|
+
});
|
|
766
|
+
} catch (error) {
|
|
767
|
+
reject(error);
|
|
768
|
+
}
|
|
769
|
+
})());
|
|
770
|
+
}
|
|
771
|
+
throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
|
|
775
|
+
var getDashboardContext = (dashboardComponent, iframe) => {
|
|
776
|
+
if (iframe?.contentWindow) {
|
|
777
|
+
const requestId = uuidv4();
|
|
778
|
+
iframe.contentWindow.postMessage(
|
|
779
|
+
{ action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
|
|
780
|
+
"*"
|
|
781
|
+
);
|
|
782
|
+
return new Promise((resolve, reject) => {
|
|
783
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
784
|
+
setTimeout(() => {
|
|
785
|
+
if (dashboardComponent.promises[requestId]) {
|
|
786
|
+
const errorMessage = "getDashboardContext request timed out.";
|
|
787
|
+
dashboardComponent.promises[requestId].reject(
|
|
788
|
+
new Error(errorMessage)
|
|
789
|
+
);
|
|
790
|
+
delete dashboardComponent.promises[requestId];
|
|
791
|
+
}
|
|
792
|
+
}, 2e3);
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
|
|
799
|
+
var getData = (dashboardComponent, iframe, itemId) => {
|
|
800
|
+
if (iframe?.contentWindow) {
|
|
801
|
+
const requestId = uuidv4();
|
|
802
|
+
iframe.contentWindow.postMessage(
|
|
803
|
+
{
|
|
804
|
+
action: "getData",
|
|
805
|
+
id: itemId,
|
|
806
|
+
_version: dashboardComponent.libVersion,
|
|
807
|
+
requestId
|
|
808
|
+
},
|
|
809
|
+
"*"
|
|
810
|
+
);
|
|
811
|
+
return new Promise((resolve, reject) => {
|
|
812
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
813
|
+
setTimeout(() => {
|
|
814
|
+
if (dashboardComponent.promises[requestId]) {
|
|
815
|
+
const errorMessage = "getData request timed out.";
|
|
816
|
+
dashboardComponent.promises[requestId].reject(
|
|
817
|
+
new Error(errorMessage)
|
|
818
|
+
);
|
|
819
|
+
delete dashboardComponent.promises[requestId];
|
|
820
|
+
}
|
|
821
|
+
}, 2e3);
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
|
|
828
|
+
var getFilters = (dashboardComponent, iframe) => {
|
|
829
|
+
if (iframe?.contentWindow) {
|
|
830
|
+
const requestId = uuidv4();
|
|
831
|
+
iframe.contentWindow.postMessage(
|
|
832
|
+
{ action: "getFilters", _version: dashboardComponent.libVersion, requestId },
|
|
833
|
+
"*"
|
|
834
|
+
);
|
|
835
|
+
return new Promise((resolve, reject) => {
|
|
836
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
837
|
+
setTimeout(() => {
|
|
838
|
+
if (dashboardComponent.promises[requestId]) {
|
|
839
|
+
const errorMessage = "getFilters request timed out.";
|
|
840
|
+
dashboardComponent.promises[requestId].reject(
|
|
841
|
+
new Error(errorMessage)
|
|
842
|
+
);
|
|
843
|
+
delete dashboardComponent.promises[requestId];
|
|
844
|
+
}
|
|
845
|
+
}, 2e3);
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
|
|
852
|
+
var getInsights = (dashboardComponent, iframe, options = {}) => {
|
|
853
|
+
if (!iframe?.contentWindow) {
|
|
854
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
855
|
+
}
|
|
856
|
+
const requestId = uuidv4();
|
|
857
|
+
iframe.contentWindow.postMessage(
|
|
858
|
+
{
|
|
859
|
+
action: "getInsights",
|
|
860
|
+
options,
|
|
861
|
+
_version: dashboardComponent.libVersion,
|
|
862
|
+
requestId
|
|
863
|
+
},
|
|
864
|
+
"*"
|
|
865
|
+
);
|
|
866
|
+
return new Promise((resolve, reject) => {
|
|
867
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
868
|
+
setTimeout(() => {
|
|
869
|
+
if (dashboardComponent.promises[requestId]) {
|
|
870
|
+
dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
|
|
871
|
+
delete dashboardComponent.promises[requestId];
|
|
872
|
+
}
|
|
873
|
+
}, 6e4);
|
|
874
|
+
});
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
// libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
|
|
878
|
+
var refreshData = (dashboardComponent, iframe, itemId) => {
|
|
879
|
+
if (iframe) {
|
|
880
|
+
iframe.contentWindow.postMessage(
|
|
881
|
+
{
|
|
882
|
+
action: "refreshData",
|
|
883
|
+
id: itemId ?? null,
|
|
884
|
+
_version: dashboardComponent.libVersion
|
|
885
|
+
},
|
|
886
|
+
"*"
|
|
887
|
+
);
|
|
888
|
+
return Promise.resolve();
|
|
889
|
+
}
|
|
890
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
// libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
|
|
894
|
+
var reloadDashboard = (dashboardComponent, iframe) => {
|
|
895
|
+
if (iframe) {
|
|
896
|
+
iframe.contentWindow.postMessage(
|
|
897
|
+
{ action: "reloadDashboard", _version: dashboardComponent.libVersion },
|
|
898
|
+
"*"
|
|
899
|
+
);
|
|
900
|
+
return Promise.resolve();
|
|
901
|
+
}
|
|
902
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
// libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
|
|
906
|
+
var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
|
|
907
|
+
if (iframe) {
|
|
908
|
+
iframe.contentWindow.postMessage(
|
|
909
|
+
{
|
|
910
|
+
action: "sendExportEmail",
|
|
911
|
+
type: type || "once",
|
|
912
|
+
subject,
|
|
913
|
+
message,
|
|
914
|
+
_version: dashboardComponent.libVersion
|
|
915
|
+
},
|
|
916
|
+
"*"
|
|
917
|
+
);
|
|
918
|
+
return Promise.resolve();
|
|
919
|
+
}
|
|
920
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
|
|
924
|
+
var setAuthorization = (dashboardComponent, iframe, key, token) => {
|
|
925
|
+
if (iframe) {
|
|
926
|
+
iframe.contentWindow.postMessage(
|
|
927
|
+
{
|
|
928
|
+
action: "setAuthorization",
|
|
929
|
+
key,
|
|
930
|
+
token,
|
|
931
|
+
_version: dashboardComponent.libVersion
|
|
932
|
+
},
|
|
933
|
+
"*"
|
|
934
|
+
);
|
|
935
|
+
return Promise.resolve();
|
|
936
|
+
}
|
|
937
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
|
|
941
|
+
var setEditMode = (dashboardComponent, iframe, editMode) => {
|
|
942
|
+
if (iframe && iframe.contentWindow) {
|
|
943
|
+
const requestId = uuidv4();
|
|
944
|
+
if (dashboardComponent.params.editMode === editMode) {
|
|
945
|
+
return Promise.reject(
|
|
946
|
+
new Error("editMode parameter is currently already set to " + editMode)
|
|
947
|
+
);
|
|
948
|
+
} else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
|
|
949
|
+
return Promise.reject(
|
|
950
|
+
new Error(
|
|
951
|
+
"The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
|
|
952
|
+
)
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
iframe.contentWindow.postMessage(
|
|
956
|
+
{
|
|
957
|
+
action: "setEditMode",
|
|
958
|
+
editMode,
|
|
959
|
+
_version: dashboardComponent.libVersion,
|
|
960
|
+
requestId
|
|
961
|
+
},
|
|
962
|
+
"*"
|
|
963
|
+
);
|
|
964
|
+
return new Promise((resolve, reject) => {
|
|
965
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
|
|
972
|
+
var setPreview = (dashboardComponent, iframe, preview) => {
|
|
973
|
+
if (iframe) {
|
|
974
|
+
const requestId = uuidv4();
|
|
975
|
+
iframe.contentWindow.postMessage(
|
|
976
|
+
{
|
|
977
|
+
action: "setPreview",
|
|
978
|
+
preview,
|
|
979
|
+
requestId,
|
|
980
|
+
_version: dashboardComponent.libVersion
|
|
981
|
+
},
|
|
982
|
+
"*"
|
|
983
|
+
);
|
|
984
|
+
return new Promise((resolve, reject) => {
|
|
985
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
986
|
+
setTimeout(() => {
|
|
987
|
+
if (dashboardComponent.promises[requestId]) {
|
|
988
|
+
const errorMessage = "setPreview request timed out.";
|
|
989
|
+
dashboardComponent.promises[requestId].reject(
|
|
990
|
+
new Error(errorMessage)
|
|
991
|
+
);
|
|
992
|
+
delete dashboardComponent.promises[requestId];
|
|
993
|
+
}
|
|
994
|
+
}, 2e3);
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
|
|
1001
|
+
var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
|
|
1002
|
+
if (iframe) {
|
|
1003
|
+
const requestId = uuidv4();
|
|
1004
|
+
iframe.contentWindow.postMessage(
|
|
1005
|
+
{
|
|
1006
|
+
action: "setSelectedData",
|
|
1007
|
+
itemId,
|
|
1008
|
+
filters,
|
|
1009
|
+
_version: dashboardComponent.libVersion,
|
|
1010
|
+
requestId
|
|
1011
|
+
},
|
|
1012
|
+
"*"
|
|
1013
|
+
);
|
|
1014
|
+
return new Promise((resolve, reject) => {
|
|
1015
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
1016
|
+
setTimeout(() => {
|
|
1017
|
+
if (dashboardComponent.promises[requestId]) {
|
|
1018
|
+
const errorMessage = "setSelectedData request timed out.";
|
|
1019
|
+
dashboardComponent.promises[requestId].reject(
|
|
1020
|
+
new Error(errorMessage)
|
|
1021
|
+
);
|
|
1022
|
+
delete dashboardComponent.promises[requestId];
|
|
1023
|
+
}
|
|
1024
|
+
}, 2e3);
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
return Promise.reject();
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
// libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
|
|
1031
|
+
var _setCalculatedDimensions = (dashboardComponent) => {
|
|
1032
|
+
if (!dashboardComponent.dimensions) {
|
|
1033
|
+
dashboardComponent.params.error = true;
|
|
1034
|
+
_handleError("Got no valid dimensions.", dashboardComponent.params);
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
const dashboardDimensionKeys = Object.keys(
|
|
1038
|
+
dashboardComponent.dimensions
|
|
1039
|
+
);
|
|
1040
|
+
const availableScreenModeExtents = [];
|
|
1041
|
+
let currentMode;
|
|
1042
|
+
let currentWidth = 0;
|
|
1043
|
+
let currentHeight = 0;
|
|
1044
|
+
if (!dashboardComponent.params.switchScreenModeOnResize && dashboardComponent.currentScreenMode) {
|
|
1045
|
+
dashboardComponent.params.screenMode = dashboardComponent.currentScreenMode;
|
|
1046
|
+
}
|
|
1047
|
+
if (dashboardComponent.dimensions && dashboardDimensionKeys?.[0] === "fixed") {
|
|
1048
|
+
currentMode = "fixed";
|
|
1049
|
+
currentWidth = dashboardComponent.dimensions.fixed[0];
|
|
1050
|
+
currentHeight = dashboardComponent.dimensions.fixed[1];
|
|
1051
|
+
} else {
|
|
1052
|
+
const screenModes = [
|
|
1053
|
+
"mobile",
|
|
1054
|
+
"tablet",
|
|
1055
|
+
"desktop",
|
|
1056
|
+
"largeScreen"
|
|
1057
|
+
];
|
|
1058
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
1059
|
+
const [firstMatch] = dashboardDimensionKeys;
|
|
1060
|
+
let match = firstMatch;
|
|
1061
|
+
for (const screenMode of screenModes) {
|
|
1062
|
+
const found = dashboardDimensionKeys.find((key) => key === screenMode);
|
|
1063
|
+
if (found) {
|
|
1064
|
+
match = found;
|
|
1065
|
+
} else {
|
|
1066
|
+
dashboardComponent.dimensions[screenMode] = dashboardComponent.dimensions[match];
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
for (const key of dashboardDimensionKeys) {
|
|
1071
|
+
if (screenModes.includes(key)) {
|
|
1072
|
+
const screenMode = EXTENTS.find((extent) => extent.mode === key);
|
|
1073
|
+
availableScreenModeExtents.push({
|
|
1074
|
+
...screenMode,
|
|
1075
|
+
height: dashboardComponent.dimensions[key][1] || 50
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
if (!availableScreenModeExtents.map((screenModeExtent) => screenModeExtent.mode).includes(dashboardComponent.params.screenMode)) {
|
|
1080
|
+
dashboardComponent.params.screenMode = "auto";
|
|
1081
|
+
}
|
|
1082
|
+
if (dashboardComponent.params.screenMode === "auto") {
|
|
1083
|
+
availableScreenModeExtents.sort(
|
|
1084
|
+
(a, b) => screenModes.indexOf(a.mode) - screenModes.indexOf(b.mode)
|
|
1085
|
+
);
|
|
1086
|
+
for (const screenModeExtent of availableScreenModeExtents) {
|
|
1087
|
+
const [screenModeExtentMinWidth, screenModeExtentMaxWidth] = screenModeExtent.width;
|
|
1088
|
+
if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
1089
|
+
if (screenModeExtentMinWidth < dashboardComponent.params.itemDimensions.width) {
|
|
1090
|
+
currentMode = screenModeExtent.mode;
|
|
1091
|
+
currentWidth = Number.parseInt(
|
|
1092
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1093
|
+
10
|
|
1094
|
+
);
|
|
1095
|
+
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
1096
|
+
}
|
|
1097
|
+
} else {
|
|
1098
|
+
if (screenModeExtentMinWidth < dashboardComponent.containerWidth) {
|
|
1099
|
+
currentMode = screenModeExtent.mode;
|
|
1100
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
1101
|
+
currentWidth = dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto" ? Number.parseInt(
|
|
1102
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1103
|
+
10
|
|
1104
|
+
) : Math.min(
|
|
1105
|
+
dashboardComponent.containerWidth,
|
|
1106
|
+
screenModeExtentMaxWidth
|
|
1107
|
+
);
|
|
1108
|
+
currentHeight = dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto" ? Number.parseInt(
|
|
1109
|
+
dashboardComponent.params.itemDimensions.height,
|
|
1110
|
+
10
|
|
1111
|
+
) : dashboardComponent.dimensions[currentMode][1];
|
|
1112
|
+
if (dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
1113
|
+
currentWidth = Number.parseInt(
|
|
1114
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1115
|
+
10
|
|
1116
|
+
);
|
|
1117
|
+
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
1118
|
+
}
|
|
1119
|
+
} else {
|
|
1120
|
+
currentWidth = Math.max(
|
|
1121
|
+
Math.min(
|
|
1122
|
+
screenModeExtentMaxWidth,
|
|
1123
|
+
dashboardComponent.containerWidth
|
|
1124
|
+
),
|
|
1125
|
+
screenModeExtentMinWidth
|
|
1126
|
+
);
|
|
1127
|
+
currentHeight = screenModeExtent.height;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
} else {
|
|
1133
|
+
const {
|
|
1134
|
+
height: chosenModeHeight,
|
|
1135
|
+
width: [chosenModeMinWidth, chosenModeMaxWidth]
|
|
1136
|
+
} = availableScreenModeExtents.find(
|
|
1137
|
+
(d) => d.mode === dashboardComponent.params.screenMode
|
|
1138
|
+
);
|
|
1139
|
+
currentMode = dashboardComponent.params.screenMode;
|
|
1140
|
+
currentWidth = Math.max(
|
|
1141
|
+
Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
|
|
1142
|
+
chosenModeMinWidth
|
|
1143
|
+
);
|
|
1144
|
+
currentHeight = chosenModeHeight;
|
|
1145
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
1146
|
+
if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
|
|
1147
|
+
currentWidth = Number.parseInt(
|
|
1148
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1149
|
+
10
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
if (dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto") {
|
|
1153
|
+
currentHeight = Number.parseInt(
|
|
1154
|
+
dashboardComponent.params.itemDimensions.height,
|
|
1155
|
+
10
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
if (!currentMode && availableScreenModeExtents.length > 0) {
|
|
1161
|
+
const [lowestModeExtent] = availableScreenModeExtents;
|
|
1162
|
+
currentMode = lowestModeExtent.mode;
|
|
1163
|
+
currentWidth = lowestModeExtent.width[0];
|
|
1164
|
+
currentHeight = lowestModeExtent.height;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
dashboardComponent.currentScreenMode = currentMode;
|
|
1168
|
+
const style = {
|
|
1169
|
+
height: currentHeight === 0 ? "100%" : `${String(currentHeight)}px`,
|
|
1170
|
+
width: currentWidth === 0 ? "100%" : `${String(currentWidth)}px`,
|
|
1171
|
+
opacity: 1
|
|
1172
|
+
};
|
|
1173
|
+
const dashboardEditModes = ["editFull", "editLimited"];
|
|
1174
|
+
if (dashboardEditModes.includes(dashboardComponent.params.editMode)) {
|
|
1175
|
+
style.height = "100%";
|
|
1176
|
+
style.width = "100%";
|
|
1177
|
+
} else if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions) {
|
|
1178
|
+
style.height = dashboardComponent.params.itemDimensions.height === "auto" ? style.height : `${String(dashboardComponent.params.itemDimensions.height).replace(
|
|
1179
|
+
"px",
|
|
1180
|
+
""
|
|
1181
|
+
)}px`;
|
|
1182
|
+
style.width = dashboardComponent.params.itemDimensions.width === "auto" ? style.width : `${String(dashboardComponent.params.itemDimensions.width).replace(
|
|
1183
|
+
"px",
|
|
1184
|
+
""
|
|
1185
|
+
)}px`;
|
|
1186
|
+
} else {
|
|
1187
|
+
style.height = currentHeight === 0 ? "100%" : `${String(currentHeight)}px`;
|
|
1188
|
+
style.width = currentWidth === 0 ? "100%" : `${String(currentWidth)}px`;
|
|
1189
|
+
}
|
|
1190
|
+
dashboardComponent.currentScreenMode = currentMode;
|
|
1191
|
+
dashboardComponent.iframeStyle = style;
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
// libs/embed-libs/embed/src/lib/shared/service/extend-and-validate.ts
|
|
1195
|
+
var _extendAndValidate = (dashboardContent) => {
|
|
1196
|
+
const defaultKeys = Object.keys(
|
|
1197
|
+
DEFAULT_PARAMETERS
|
|
1198
|
+
);
|
|
1199
|
+
const errorMessages = [];
|
|
1200
|
+
const requiredStringParams = [
|
|
1201
|
+
"appServer",
|
|
1202
|
+
"language",
|
|
1203
|
+
"apiHost"
|
|
1204
|
+
];
|
|
1205
|
+
const requiredStringOrEmptyParams = [
|
|
1206
|
+
"key",
|
|
1207
|
+
"token",
|
|
1208
|
+
"screenMode",
|
|
1209
|
+
"timezoneId",
|
|
1210
|
+
"itemId",
|
|
1211
|
+
"container",
|
|
1212
|
+
"loaderBackground",
|
|
1213
|
+
"loaderFontColor",
|
|
1214
|
+
"loaderSpinnerColor",
|
|
1215
|
+
"loaderSpinnerBackground"
|
|
1216
|
+
];
|
|
1217
|
+
const objectParams = ["itemDimensions"];
|
|
1218
|
+
const screenModes = [
|
|
1219
|
+
"mobile",
|
|
1220
|
+
"tablet",
|
|
1221
|
+
"desktop",
|
|
1222
|
+
"largeScreen",
|
|
1223
|
+
"fixed",
|
|
1224
|
+
"auto"
|
|
1225
|
+
];
|
|
1226
|
+
for (const key of defaultKeys) {
|
|
1227
|
+
if (dashboardContent.params[key] === null) {
|
|
1228
|
+
delete dashboardContent.params[key];
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
dashboardContent.params = defaultsDeep(
|
|
1232
|
+
dashboardContent.params,
|
|
1233
|
+
DEFAULT_PARAMETERS
|
|
1234
|
+
);
|
|
1235
|
+
if ((!dashboardContent.params.dashboardId || typeof dashboardContent.params.dashboardId !== "string") && (!dashboardContent.params.dashboardSlug || typeof dashboardContent.params.dashboardSlug !== "string")) {
|
|
1236
|
+
delete dashboardContent.params.dashboardId;
|
|
1237
|
+
delete dashboardContent.params.dashboardSlug;
|
|
1238
|
+
}
|
|
1239
|
+
for (const key of requiredStringParams) {
|
|
1240
|
+
if (typeof dashboardContent.params[key] !== "string") {
|
|
1241
|
+
delete dashboardContent.params[key];
|
|
1242
|
+
errorMessages.push(`${key} needs to be of type string.`);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
for (const key of requiredStringOrEmptyParams) {
|
|
1246
|
+
if (typeof dashboardContent.params[key] !== "string" && dashboardContent.params[key] !== null && dashboardContent.params[key] !== void 0) {
|
|
1247
|
+
delete dashboardContent.params[key];
|
|
1248
|
+
errorMessages.push(`${key} needs to be of type string or empty.`);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
if (dashboardContent.params.screenMode && !screenModes.includes(dashboardContent.params.screenMode)) {
|
|
1252
|
+
const validTypesString = screenModes.map((mode) => `"${mode}"`).join(", ");
|
|
1253
|
+
errorMessages.push(
|
|
1254
|
+
`"screenMode" needs should be one of these types: ${validTypesString}`
|
|
1255
|
+
);
|
|
1256
|
+
dashboardContent.params.screenMode = "auto";
|
|
1257
|
+
}
|
|
1258
|
+
if (dashboardContent.params.itemId) {
|
|
1259
|
+
dashboardContent.params.itemEmbedding = true;
|
|
1260
|
+
}
|
|
1261
|
+
for (const key of objectParams) {
|
|
1262
|
+
if (typeof dashboardContent.params[key] !== "object" && dashboardContent.params[key] !== null) {
|
|
1263
|
+
delete dashboardContent.params[key];
|
|
1264
|
+
errorMessages.push(`${key} needs to be of type object or empty.`);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
if (typeof dashboardContent.params.switchScreenModeOnResize !== "boolean") {
|
|
1268
|
+
errorMessages.push("switchScreenModeOnResize needs to be of type boolean.");
|
|
1269
|
+
dashboardContent.params.switchScreenModeOnResize = true;
|
|
1270
|
+
}
|
|
1271
|
+
if (dashboardContent.params.itemDimensions) {
|
|
1272
|
+
const itemDimensionsKeys = [
|
|
1273
|
+
"width",
|
|
1274
|
+
"height"
|
|
1275
|
+
];
|
|
1276
|
+
for (const key of itemDimensionsKeys) {
|
|
1277
|
+
if (!["string", "number"].includes(
|
|
1278
|
+
typeof dashboardContent.params.itemDimensions[key]
|
|
1279
|
+
) && dashboardContent.params.itemDimensions[key] !== null) {
|
|
1280
|
+
errorMessages.push(
|
|
1281
|
+
`itemDimensions ${key} needs to be of type string, number or empty.`
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
dashboardContent.params = defaultsDeep(
|
|
1287
|
+
dashboardContent.params,
|
|
1288
|
+
DEFAULT_PARAMETERS
|
|
1289
|
+
);
|
|
1290
|
+
if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
|
|
1291
|
+
dashboardContent.params.switchScreenModeOnResize = false;
|
|
1292
|
+
}
|
|
1293
|
+
if (dashboardContent.params.itemDimensions.width !== "auto") {
|
|
1294
|
+
dashboardContent.params.itemDimensions.width = Number.parseInt(
|
|
1295
|
+
`${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
|
|
1296
|
+
10
|
|
1297
|
+
) || "auto";
|
|
1298
|
+
}
|
|
1299
|
+
if (dashboardContent.params.itemDimensions.height !== "auto") {
|
|
1300
|
+
dashboardContent.params.itemDimensions.height = Number.parseInt(
|
|
1301
|
+
`${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
|
|
1302
|
+
10
|
|
1303
|
+
) || "auto";
|
|
1304
|
+
}
|
|
1305
|
+
dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
|
|
1306
|
+
if (dashboardContent.params.error || errorMessages.length > 0) {
|
|
1307
|
+
_handleError(errorMessages.join("\n"), dashboardContent.params);
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
// libs/embed-libs/embed/src/lib/shared/models/viz-item.model.ts
|
|
1312
|
+
var libraryTypeToWebComponentTypeMapping = {
|
|
1313
|
+
type: "type",
|
|
1314
|
+
slots: "slots",
|
|
1315
|
+
options: "options",
|
|
1316
|
+
appServer: "app-server",
|
|
1317
|
+
apiHost: "api-host",
|
|
1318
|
+
authKey: "auth-key",
|
|
1319
|
+
authToken: "auth-token",
|
|
1320
|
+
contextId: "context-id",
|
|
1321
|
+
canFilter: "can-filter",
|
|
1322
|
+
filters: "filters",
|
|
1323
|
+
dashboardId: "dashboard-id",
|
|
1324
|
+
itemId: "item-id",
|
|
1325
|
+
aiMessageAssetId: "ai-message-asset-id",
|
|
1326
|
+
dashboardContentsVersion: "dashboard-contents-version",
|
|
1327
|
+
libVersion: "lib-version"
|
|
1328
|
+
};
|
|
1329
|
+
var libraryAcceptedParametersList = ["appServer", "apiHost", "options", "type", "authKey", "authToken", "slots", "filters", "canFilter", "contextId", "itemId", "dashboardId", "aiMessageAssetId", "libVersion"];
|
|
1330
|
+
|
|
1331
|
+
// libs/embed-libs/embed/src/lib/shared/constants/class-constants.ts
|
|
1332
|
+
var luzmoEmbedContainerClass = "luzmo-embed-container";
|
|
1333
|
+
|
|
1334
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/remote-federation.ts
|
|
1335
|
+
var import_runtime = require("@module-federation/runtime");
|
|
1336
|
+
var federationRuntime = (0, import_runtime.createInstance)({
|
|
1337
|
+
name: "luzmo-embed-runtime",
|
|
1338
|
+
remotes: []
|
|
1339
|
+
});
|
|
1340
|
+
var remoteCache = /* @__PURE__ */ new Map();
|
|
1341
|
+
var remoteCounter = 0;
|
|
1342
|
+
var preconnectedOrigins = /* @__PURE__ */ new Set();
|
|
1343
|
+
function injectPreconnect(appServer) {
|
|
1344
|
+
if (typeof document === "undefined") {
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
let origin;
|
|
1348
|
+
try {
|
|
1349
|
+
origin = new URL(removeTrailingSlash(appServer)).origin;
|
|
1350
|
+
} catch {
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
if (preconnectedOrigins.has(origin)) {
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
preconnectedOrigins.add(origin);
|
|
1357
|
+
const link = document.createElement("link");
|
|
1358
|
+
link.rel = "preconnect";
|
|
1359
|
+
link.href = origin;
|
|
1360
|
+
link.crossOrigin = "anonymous";
|
|
1361
|
+
(document.head ?? document.documentElement).append(link);
|
|
1362
|
+
}
|
|
1363
|
+
function getManifestEntry(appServer, componentName) {
|
|
1364
|
+
const baseUrl = removeTrailingSlash(appServer);
|
|
1365
|
+
if (appServer.startsWith("http://localhost")) {
|
|
1366
|
+
return `${baseUrl}/mf-manifest.json`;
|
|
1367
|
+
}
|
|
1368
|
+
switch (componentName) {
|
|
1369
|
+
case "DashboardApp":
|
|
1370
|
+
case "VizItemApp": {
|
|
1371
|
+
return `${baseUrl}/dashboard-app/mf-manifest.json`;
|
|
1372
|
+
}
|
|
1373
|
+
case "IQApp": {
|
|
1374
|
+
return `${baseUrl}/iq-app/mf-manifest.json`;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function getCacheKey(appServer, componentName) {
|
|
1379
|
+
return `${appServer}|${componentName}`;
|
|
1380
|
+
}
|
|
1381
|
+
function getOrCreateRemote(appServer, componentName) {
|
|
1382
|
+
const cacheKey = getCacheKey(appServer, componentName);
|
|
1383
|
+
const cachedRemote = remoteCache.get(cacheKey);
|
|
1384
|
+
if (cachedRemote) {
|
|
1385
|
+
return cachedRemote;
|
|
1386
|
+
}
|
|
1387
|
+
const remote = {
|
|
1388
|
+
entry: getManifestEntry(appServer, componentName),
|
|
1389
|
+
registered: false,
|
|
1390
|
+
remoteName: `luzmo_embed_${remoteCounter++}`
|
|
1391
|
+
};
|
|
1392
|
+
remoteCache.set(cacheKey, remote);
|
|
1393
|
+
return remote;
|
|
1394
|
+
}
|
|
1395
|
+
function loadLibrary(appServer, componentName = "DashboardApp") {
|
|
1396
|
+
injectPreconnect(appServer);
|
|
1397
|
+
const remote = getOrCreateRemote(appServer, componentName);
|
|
1398
|
+
if (remote.module) {
|
|
1399
|
+
return Promise.resolve(remote.module);
|
|
1400
|
+
}
|
|
1401
|
+
if (remote.loadPromise) {
|
|
1402
|
+
return remote.loadPromise;
|
|
1403
|
+
}
|
|
1404
|
+
if (!remote.registered) {
|
|
1405
|
+
federationRuntime.registerRemotes([
|
|
1406
|
+
{
|
|
1407
|
+
name: remote.remoteName,
|
|
1408
|
+
entry: remote.entry
|
|
1409
|
+
}
|
|
1410
|
+
]);
|
|
1411
|
+
remote.registered = true;
|
|
1412
|
+
}
|
|
1413
|
+
remote.loadPromise = federationRuntime.loadRemote(`${remote.remoteName}/${componentName}`).then((module2) => {
|
|
1414
|
+
if (!module2) {
|
|
1415
|
+
throw new Error(`Failed to load "${componentName}" from "${remote.entry}".`);
|
|
1416
|
+
}
|
|
1417
|
+
remote.module = module2;
|
|
1418
|
+
return module2;
|
|
1419
|
+
}).finally(() => {
|
|
1420
|
+
remote.loadPromise = void 0;
|
|
1421
|
+
});
|
|
1422
|
+
return remote.loadPromise;
|
|
1423
|
+
}
|
|
1424
|
+
function preloadDashboard(appServer = "https://app.luzmo.com") {
|
|
1425
|
+
loadLibrary(appServer, "DashboardApp").catch(() => {
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
function preloadVizItem(appServer = "https://app.luzmo.com") {
|
|
1429
|
+
loadLibrary(appServer, "VizItemApp").catch(() => {
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
function preloadIQ(appServer = "https://app.luzmo.com") {
|
|
1433
|
+
loadLibrary(appServer, "IQApp").catch(() => {
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1437
|
+
0 && (module.exports = {
|
|
1438
|
+
DEFAULT_PARAMETERS,
|
|
1439
|
+
EXTENTS,
|
|
1440
|
+
TRANSLATIONS,
|
|
1441
|
+
VERSION,
|
|
1442
|
+
_browserCheck,
|
|
1443
|
+
_extendAndValidate,
|
|
1444
|
+
_handleError,
|
|
1445
|
+
_setCalculatedDimensions,
|
|
1446
|
+
addTrailingSlash,
|
|
1447
|
+
calculateIframeStyles,
|
|
1448
|
+
cloneDeep,
|
|
1449
|
+
containerLoaderStyles,
|
|
1450
|
+
containerStyles,
|
|
1451
|
+
createIframeUrl,
|
|
1452
|
+
defaultsDeep,
|
|
1453
|
+
exportDashboard,
|
|
1454
|
+
formatDashboardList,
|
|
1455
|
+
getAccessibleDashboards,
|
|
1456
|
+
getDashboardContext,
|
|
1457
|
+
getData,
|
|
1458
|
+
getFilters,
|
|
1459
|
+
getInsights,
|
|
1460
|
+
getLoader,
|
|
1461
|
+
lcStyles,
|
|
1462
|
+
libraryAcceptedParametersList,
|
|
1463
|
+
libraryTypeToWebComponentTypeMapping,
|
|
1464
|
+
loadLibrary,
|
|
1465
|
+
loaderStyles,
|
|
1466
|
+
luzmoEmbedContainerClass,
|
|
1467
|
+
plStyles,
|
|
1468
|
+
preloadDashboard,
|
|
1469
|
+
preloadIQ,
|
|
1470
|
+
preloadVizItem,
|
|
1471
|
+
refreshData,
|
|
1472
|
+
rejectPromise,
|
|
1473
|
+
reloadDashboard,
|
|
1474
|
+
removeTrailingSlash,
|
|
1475
|
+
resolvePromise,
|
|
1476
|
+
s4,
|
|
1477
|
+
sanitizeUrl,
|
|
1478
|
+
selectedDataUtils,
|
|
1479
|
+
sendExportEmail,
|
|
1480
|
+
setAuthorization,
|
|
1481
|
+
setEditMode,
|
|
1482
|
+
setPreview,
|
|
1483
|
+
setSelectedData,
|
|
1484
|
+
updateIframeUrl,
|
|
1485
|
+
uuidv4
|
|
1486
|
+
});
|