@luzmo/embed 7.5.0-es2021 → 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 +1589 -143
- package/index.js +1583 -129
- 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 +197 -96
- package/package.json +22 -2
- 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.js
CHANGED
|
@@ -9,20 +9,1378 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
9
|
return result;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/error.ts
|
|
13
|
+
var _handleError = (errorMessage, parameters) => {
|
|
14
|
+
let message = "The dashboard component encountered an error";
|
|
15
|
+
if (typeof parameters?.dashboardId === "string") {
|
|
16
|
+
message += ` for dashboard with id ${parameters.dashboardId}`;
|
|
17
|
+
}
|
|
18
|
+
if (typeof parameters?.dashboardSlug === "string") {
|
|
19
|
+
message += ` for dashboard with slug ${parameters.dashboardSlug}`;
|
|
20
|
+
}
|
|
21
|
+
if (typeof parameters?.container === "string") {
|
|
22
|
+
message += ` in container ${parameters.container}`;
|
|
23
|
+
}
|
|
24
|
+
if (errorMessage) {
|
|
25
|
+
message += `:
|
|
26
|
+
${errorMessage}`;
|
|
27
|
+
console.warn(message);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/browser-check.ts
|
|
32
|
+
var _browserCheck = (dashboardComponent) => {
|
|
33
|
+
let hasError = false;
|
|
34
|
+
let errorMessage = "";
|
|
35
|
+
const document_ = document.body || document.documentElement;
|
|
36
|
+
const style = document_.style;
|
|
37
|
+
const browserCheck = {
|
|
38
|
+
svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
|
|
39
|
+
flexbox: style.webkitFlexWrap === "" || style.flexWrap === "",
|
|
40
|
+
postMessage: !!window.postMessage
|
|
41
|
+
};
|
|
42
|
+
const browserCheckKeys = ["svg", "flexbox", "postMessage"];
|
|
43
|
+
for (const key of browserCheckKeys) {
|
|
44
|
+
if (!browserCheck[key]) {
|
|
45
|
+
hasError = true;
|
|
46
|
+
dashboardComponent.browserNotSupported = dashboardComponent.browserNotSupported || [];
|
|
47
|
+
dashboardComponent.browserNotSupported.push(key);
|
|
48
|
+
errorMessage += `Your browser does not support: ${key}
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const ua = window.navigator.userAgent;
|
|
53
|
+
const msie = ua.includes("MSIE");
|
|
54
|
+
const trident = ua.includes("Trident/");
|
|
55
|
+
if (msie || trident) {
|
|
56
|
+
hasError = true;
|
|
57
|
+
errorMessage = "IE is not supported.";
|
|
58
|
+
}
|
|
59
|
+
if (hasError) {
|
|
60
|
+
_handleError(errorMessage);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/default-parameters.ts
|
|
65
|
+
var DEFAULT_PARAMETERS = {
|
|
66
|
+
appServer: "https://app.luzmo.com/",
|
|
67
|
+
apiHost: "https://api.luzmo.com/",
|
|
68
|
+
dashboardId: null,
|
|
69
|
+
dashboardSlug: null,
|
|
70
|
+
container: null,
|
|
71
|
+
key: null,
|
|
72
|
+
token: null,
|
|
73
|
+
language: "auto",
|
|
74
|
+
editorLanguage: "auto",
|
|
75
|
+
editMode: null,
|
|
76
|
+
screenMode: null,
|
|
77
|
+
switchScreenModeOnResize: true,
|
|
78
|
+
itemId: null,
|
|
79
|
+
theme: "",
|
|
80
|
+
mainColor: "",
|
|
81
|
+
itemDimensions: {
|
|
82
|
+
width: "auto",
|
|
83
|
+
height: "auto"
|
|
84
|
+
},
|
|
85
|
+
loaderBackground: "#f9f9f9",
|
|
86
|
+
loaderFontColor: "#5a5a5a",
|
|
87
|
+
loaderSpinnerColor: "rgb(68, 52, 255)",
|
|
88
|
+
loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
|
|
89
|
+
timezoneId: null,
|
|
90
|
+
contextId: null
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/extents.ts
|
|
94
|
+
var EXTENTS = [
|
|
95
|
+
{ mode: "mobile", width: [150, 767] },
|
|
96
|
+
{ mode: "tablet", width: [768, 1199] },
|
|
97
|
+
{ mode: "desktop", width: [1200, 1599] },
|
|
98
|
+
{ mode: "largeScreen", width: [1600, 9999] },
|
|
99
|
+
{ mode: "fixed", width: [] }
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/translations.ts
|
|
103
|
+
var TRANSLATIONS = {
|
|
104
|
+
initializing: {
|
|
105
|
+
en: "Initializing...",
|
|
106
|
+
nl: "Laden...",
|
|
107
|
+
fr: "Chargement...",
|
|
108
|
+
de: "Initialisiere...",
|
|
109
|
+
es: "Inicializando..."
|
|
110
|
+
},
|
|
111
|
+
errorDashboard: {
|
|
112
|
+
en: "Oops, we could not load this dashboard!",
|
|
113
|
+
nl: "Oeps, we konden het dashboard niet laden.",
|
|
114
|
+
fr: "Le chargement a echou\xE9.",
|
|
115
|
+
de: "Hoppla, wir konnten dieses Dashboard nicht laden!",
|
|
116
|
+
es: "\xA1Ups! No pudimos cargar este tablero."
|
|
117
|
+
},
|
|
118
|
+
errorItem: {
|
|
119
|
+
en: "Oops, we could not load this item!",
|
|
120
|
+
nl: "Oeps, we konden de grafiek niet laden.",
|
|
121
|
+
fr: "Le chargement a echou\xE9.",
|
|
122
|
+
de: "Hoppla, wir konnten dieses Diagramm nicht laden!",
|
|
123
|
+
es: "\xA1Ups! No pudimos cargar este elemento."
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var translations_default = TRANSLATIONS;
|
|
127
|
+
|
|
128
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/utils.ts
|
|
129
|
+
var addTrailingSlash = (serverUrl) => {
|
|
130
|
+
if (!serverUrl) {
|
|
131
|
+
return "";
|
|
132
|
+
}
|
|
133
|
+
return serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
|
|
134
|
+
};
|
|
135
|
+
var removeTrailingSlash = (serverUrl) => {
|
|
136
|
+
if (!serverUrl) {
|
|
137
|
+
return "";
|
|
138
|
+
}
|
|
139
|
+
return serverUrl.endsWith("/") ? serverUrl.slice(0, -1) : serverUrl;
|
|
140
|
+
};
|
|
141
|
+
var formatDashboardList = (dashboards, integrationId, user, dashboardComponent) => {
|
|
142
|
+
const combineRights = (securable, accessUser) => {
|
|
143
|
+
const matchingUser = securable.users.find((u) => u.id === accessUser.id);
|
|
144
|
+
const securableAccessRights = matchingUser && matchingUser.userAccessRight ? {
|
|
145
|
+
flagRead: matchingUser.userAccessRight.flagRead,
|
|
146
|
+
flagUse: matchingUser.userAccessRight.flagUse,
|
|
147
|
+
flagModify: matchingUser.userAccessRight.flagModify,
|
|
148
|
+
flagOwn: matchingUser.userAccessRight.flagOwn
|
|
149
|
+
} : {
|
|
150
|
+
flagRead: false,
|
|
151
|
+
flagUse: false,
|
|
152
|
+
flagModify: false,
|
|
153
|
+
flagOwn: false
|
|
154
|
+
};
|
|
155
|
+
const groups = securable.groups.filter(
|
|
156
|
+
(group) => accessUser.userGroups.includes(group.id) || group.public === true
|
|
157
|
+
);
|
|
158
|
+
const groupsAccess = groups.map((group) => {
|
|
159
|
+
if (group.groupAccessRight) {
|
|
160
|
+
return group.groupAccessRight;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
for (const groupAccess of groupsAccess) {
|
|
164
|
+
if (!securableAccessRights.flagRead && groupAccess.flagRead) {
|
|
165
|
+
securableAccessRights.flagRead = groupAccess.flagRead;
|
|
166
|
+
}
|
|
167
|
+
if (!securableAccessRights.flagUse && groupAccess.flagUse) {
|
|
168
|
+
securableAccessRights.flagUse = groupAccess.flagUse;
|
|
169
|
+
}
|
|
170
|
+
if (!securableAccessRights.flagModify && groupAccess.flagModify) {
|
|
171
|
+
securableAccessRights.flagModify = groupAccess.flagModify;
|
|
172
|
+
}
|
|
173
|
+
if (!securableAccessRights.flagOwn && groupAccess.flagOwn) {
|
|
174
|
+
securableAccessRights.flagOwn = groupAccess.flagOwn;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const integrationsAccess = securable.integrations?.length > 0 ? securable.integrations.map((integration) => {
|
|
178
|
+
if (integration.integrationAccessRight) {
|
|
179
|
+
return integration.integrationAccessRight;
|
|
180
|
+
}
|
|
181
|
+
}) : [];
|
|
182
|
+
for (const integrationAccess of integrationsAccess) {
|
|
183
|
+
if (!securableAccessRights.flagRead && integrationAccess.flagRead) {
|
|
184
|
+
securableAccessRights.flagRead = integrationAccess.flagRead;
|
|
185
|
+
}
|
|
186
|
+
if (!securableAccessRights.flagUse && integrationAccess.flagUse) {
|
|
187
|
+
securableAccessRights.flagUse = integrationAccess.flagUse;
|
|
188
|
+
}
|
|
189
|
+
if (!securableAccessRights.flagModify && integrationAccess.flagModify) {
|
|
190
|
+
securableAccessRights.flagModify = integrationAccess.flagModify;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return securableAccessRights;
|
|
194
|
+
};
|
|
195
|
+
const localize = (item, locale) => {
|
|
196
|
+
if (item === null || item === void 0) {
|
|
197
|
+
return "";
|
|
198
|
+
}
|
|
199
|
+
if (typeof item !== "object" || Object.keys(item).length === 0) {
|
|
200
|
+
if (typeof item === "object" && Object.keys(item).length === 0) {
|
|
201
|
+
return "";
|
|
202
|
+
}
|
|
203
|
+
return item;
|
|
204
|
+
}
|
|
205
|
+
let localizedItem;
|
|
206
|
+
localizedItem = locale && item[locale] ? item[locale] : item[Object.keys(item)[0]];
|
|
207
|
+
if (localizedItem === void 0 || localizedItem === null) {
|
|
208
|
+
localizedItem = "";
|
|
209
|
+
}
|
|
210
|
+
return localizedItem;
|
|
211
|
+
};
|
|
212
|
+
const treatedDashboards = [];
|
|
213
|
+
for (const dashboard of dashboards) {
|
|
214
|
+
const treatedDashboard = {
|
|
215
|
+
accessibleBy: [],
|
|
216
|
+
accessRights: combineRights(dashboard, user),
|
|
217
|
+
id: dashboard.id,
|
|
218
|
+
modifiedAt: dashboard.modified_at,
|
|
219
|
+
name: localize(dashboard.name, dashboardComponent.language),
|
|
220
|
+
slug: null,
|
|
221
|
+
tags: dashboard.tags.map((t) => t.tag).sort((t1, t2) => t1.localeCompare(t2))
|
|
222
|
+
};
|
|
223
|
+
const currentIntegration = dashboard.integrations.find(
|
|
224
|
+
(i) => i.id === integrationId
|
|
225
|
+
);
|
|
226
|
+
if (currentIntegration?.integrationAccessRight?.slug) {
|
|
227
|
+
treatedDashboard.slug = currentIntegration.integrationAccessRight.slug;
|
|
228
|
+
}
|
|
229
|
+
const users = dashboard.users.map((u) => ({
|
|
230
|
+
model: "User",
|
|
231
|
+
id: u.id,
|
|
232
|
+
name: localize(u.name, user.locale_id)
|
|
233
|
+
}));
|
|
234
|
+
const groups = dashboard.groups.map((g) => ({
|
|
235
|
+
model: "Group",
|
|
236
|
+
id: g.id,
|
|
237
|
+
name: localize(g.name, user.locale_id) || {}
|
|
238
|
+
}));
|
|
239
|
+
const integrations = dashboard.integrations.map((i) => ({
|
|
240
|
+
model: "Integration",
|
|
241
|
+
id: i.id,
|
|
242
|
+
name: localize(i.name, user.locale_id) || {}
|
|
243
|
+
}));
|
|
244
|
+
treatedDashboard.accessibleBy = [...users, ...groups, ...integrations];
|
|
245
|
+
treatedDashboards.push(treatedDashboard);
|
|
246
|
+
}
|
|
247
|
+
return treatedDashboards;
|
|
248
|
+
};
|
|
249
|
+
var VERSION = "0.0.0-unknown-luzmo";
|
|
250
|
+
var sanitizeUrl = (url) => {
|
|
251
|
+
const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
|
|
252
|
+
const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
|
|
253
|
+
const urlSchemeRegex = /^([^:]+):/gm;
|
|
254
|
+
const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
|
|
255
|
+
const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
|
|
256
|
+
if (!url) {
|
|
257
|
+
return "about:blank";
|
|
258
|
+
}
|
|
259
|
+
const sanitizedUrl = url.replaceAll(ctrlCharactersRegex, "").trim();
|
|
260
|
+
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
261
|
+
return sanitizedUrl;
|
|
262
|
+
}
|
|
263
|
+
const urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
|
|
264
|
+
if (!urlSchemeParseResults) {
|
|
265
|
+
return sanitizedUrl;
|
|
266
|
+
}
|
|
267
|
+
const urlScheme = urlSchemeParseResults[0];
|
|
268
|
+
if (invalidPrototcolRegex.test(urlScheme)) {
|
|
269
|
+
return "about:blank";
|
|
270
|
+
}
|
|
271
|
+
return sanitizedUrl;
|
|
272
|
+
};
|
|
273
|
+
var isObject = (o) => o && typeof o === "object";
|
|
274
|
+
var defaultsDeep = (target, defaults) => {
|
|
275
|
+
Object.entries(defaults).forEach(([k, v]) => {
|
|
276
|
+
if (k in target) {
|
|
277
|
+
if (target[k] === void 0) {
|
|
278
|
+
target[k] = v;
|
|
279
|
+
} else {
|
|
280
|
+
target[k] = isObject(v) ? defaultsDeep(
|
|
281
|
+
target[k],
|
|
282
|
+
v
|
|
283
|
+
) : target[k];
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
target[k] = v;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
return target;
|
|
290
|
+
};
|
|
291
|
+
var uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(c) {
|
|
292
|
+
const r = Math.trunc(Math.random() * 16);
|
|
293
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
294
|
+
return v.toString(16);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/iframe-url.ts
|
|
298
|
+
var createIframeUrl = (dashboardContent) => {
|
|
299
|
+
const searchString = [];
|
|
300
|
+
const {
|
|
301
|
+
appServer,
|
|
302
|
+
language,
|
|
303
|
+
editorLanguage,
|
|
304
|
+
loaderBackground,
|
|
305
|
+
loaderSpinnerColor,
|
|
306
|
+
loaderSpinnerBackground,
|
|
307
|
+
loaderFontColor,
|
|
308
|
+
screenMode,
|
|
309
|
+
key,
|
|
310
|
+
token,
|
|
311
|
+
timezoneId,
|
|
312
|
+
itemEmbedding,
|
|
313
|
+
itemDimensions,
|
|
314
|
+
dashboardId,
|
|
315
|
+
dashboardSlug,
|
|
316
|
+
itemId,
|
|
317
|
+
theme,
|
|
318
|
+
mainColor,
|
|
319
|
+
editMode
|
|
320
|
+
} = dashboardContent.params;
|
|
321
|
+
if (language && language !== "auto") {
|
|
322
|
+
searchString.push(`language=${language}`);
|
|
323
|
+
}
|
|
324
|
+
if (editorLanguage && editorLanguage !== "auto") {
|
|
325
|
+
searchString.push(`editorLanguage=${editorLanguage}`);
|
|
326
|
+
}
|
|
327
|
+
if (loaderBackground) {
|
|
328
|
+
searchString.push(`ldrbg=${loaderBackground}`);
|
|
329
|
+
}
|
|
330
|
+
if (loaderFontColor) {
|
|
331
|
+
searchString.push(`ldrftclr=${loaderFontColor}`);
|
|
332
|
+
}
|
|
333
|
+
if (loaderSpinnerColor) {
|
|
334
|
+
searchString.push(`ldrspclr=${loaderSpinnerColor}`);
|
|
335
|
+
}
|
|
336
|
+
if (loaderSpinnerBackground) {
|
|
337
|
+
searchString.push(`ldrspbg=${loaderSpinnerBackground}`);
|
|
338
|
+
}
|
|
339
|
+
if (theme) {
|
|
340
|
+
searchString.push(`theme=${theme}`);
|
|
341
|
+
}
|
|
342
|
+
if (mainColor) {
|
|
343
|
+
searchString.push(`mainColor=${mainColor}`);
|
|
344
|
+
}
|
|
345
|
+
if (screenMode && screenMode !== "auto") {
|
|
346
|
+
searchString.push(`screenMode=${screenMode}`);
|
|
347
|
+
}
|
|
348
|
+
if (timezoneId) {
|
|
349
|
+
searchString.push("timezoneId=" + timezoneId);
|
|
350
|
+
}
|
|
351
|
+
if (itemEmbedding && itemDimensions && itemDimensions.width) {
|
|
352
|
+
searchString.push("width=" + itemDimensions.width);
|
|
353
|
+
}
|
|
354
|
+
if (itemEmbedding && itemDimensions && itemDimensions.height) {
|
|
355
|
+
searchString.push("height=" + itemDimensions.height);
|
|
356
|
+
}
|
|
357
|
+
if (editMode) {
|
|
358
|
+
searchString.push("editMode=" + editMode);
|
|
359
|
+
}
|
|
360
|
+
const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
|
|
361
|
+
searchString.push("version=" + (dashboardContent.libVersion || VERSION));
|
|
362
|
+
const appServerWithSlash = addTrailingSlash(appServer);
|
|
363
|
+
const iframeUrl = itemEmbedding ? `${appServerWithSlash}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
|
|
364
|
+
searchString.join("&")
|
|
365
|
+
)}${keyTokenUrlAnchor}` : `${appServerWithSlash}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
|
|
366
|
+
searchString.join("&")
|
|
367
|
+
)}${keyTokenUrlAnchor}`;
|
|
368
|
+
return sanitizeUrl(iframeUrl);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
|
|
372
|
+
var getLoader = (dashboardComponent) => {
|
|
373
|
+
let errorMsg;
|
|
374
|
+
if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
|
|
375
|
+
dashboardComponent.params.error = true;
|
|
376
|
+
if (dashboardComponent.browserNotSupported) {
|
|
377
|
+
errorMsg = "Browser is not supported.";
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
|
|
381
|
+
return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
|
|
385
|
+
function resolvePromise(dashboardComponent, requestId, data) {
|
|
386
|
+
if (dashboardComponent.promises[requestId]) {
|
|
387
|
+
dashboardComponent.promises[requestId].resolve(data);
|
|
388
|
+
delete dashboardComponent.promises[requestId];
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function rejectPromise(dashboardComponent, requestId, data) {
|
|
392
|
+
if (dashboardComponent.promises[requestId]) {
|
|
393
|
+
dashboardComponent.promises[requestId].reject(data);
|
|
394
|
+
delete dashboardComponent.promises[requestId];
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
|
|
399
|
+
function containerStyles(dashboardComponent) {
|
|
400
|
+
const styles = {};
|
|
401
|
+
if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
|
|
402
|
+
styles.background = dashboardComponent.params.loaderBackground;
|
|
403
|
+
}
|
|
404
|
+
return styles;
|
|
405
|
+
}
|
|
406
|
+
function containerLoaderStyles(dashboardComponent) {
|
|
407
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
408
|
+
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
409
|
+
const display = dashboardComponent.iframeLoaded ? "none" : "";
|
|
410
|
+
return {
|
|
411
|
+
display,
|
|
412
|
+
height: `${chartHeightDefined ? height : dashboardComponent.minHeight}px`
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function loaderStyles(dashboardComponent) {
|
|
416
|
+
const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
|
|
417
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
418
|
+
dashboardComponent.loaderSize = 24;
|
|
419
|
+
dashboardComponent.borderWidth = 4;
|
|
420
|
+
dashboardComponent.minHeight = 200;
|
|
421
|
+
const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
422
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
423
|
+
const chartWidthDefined = width !== "auto";
|
|
424
|
+
const chartHeightDefined = height !== "auto";
|
|
425
|
+
return {
|
|
426
|
+
background,
|
|
427
|
+
width: chartWidthDefined ? `${width}px` : "100%",
|
|
428
|
+
height: `${chartHeightDefined ? height : "200"}px`,
|
|
429
|
+
"min-height": chartHeightDefined ? "" : "200px"
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
return {
|
|
433
|
+
background
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function generateBorderStyle(borderWidth, color) {
|
|
437
|
+
return `${borderWidth}px solid ${color}`;
|
|
438
|
+
}
|
|
439
|
+
function plStyles(dashboardComponent) {
|
|
440
|
+
const {
|
|
441
|
+
loaderSpinnerColor: defaultSpinnerColor,
|
|
442
|
+
loaderSpinnerBackground: defaultSpinnerBackground
|
|
443
|
+
} = DEFAULT_PARAMETERS;
|
|
444
|
+
const spinnerColorBorder = generateBorderStyle(
|
|
445
|
+
dashboardComponent.borderWidth,
|
|
446
|
+
dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
|
|
447
|
+
);
|
|
448
|
+
const spinnerBackgroundBorder = generateBorderStyle(
|
|
449
|
+
dashboardComponent.borderWidth,
|
|
450
|
+
dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
|
|
451
|
+
);
|
|
452
|
+
const size = `${dashboardComponent.loaderSize}px`;
|
|
453
|
+
return {
|
|
454
|
+
"border-top": spinnerColorBorder,
|
|
455
|
+
"border-right": spinnerColorBorder,
|
|
456
|
+
"border-bottom": spinnerBackgroundBorder,
|
|
457
|
+
"border-left": spinnerBackgroundBorder,
|
|
458
|
+
width: size,
|
|
459
|
+
height: size
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function lcStyles(dashboardComponent) {
|
|
463
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
464
|
+
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
465
|
+
const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
|
|
466
|
+
const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
|
|
467
|
+
return {
|
|
468
|
+
padding: `${verticalPadding} 16px`
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
function calculateIframeStyles(dashboardComponent) {
|
|
472
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
473
|
+
const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
474
|
+
if (dashboardComponent.params.itemEmbedding && height !== "auto") {
|
|
475
|
+
dashboardComponent.iframeHeight = `${height}px`;
|
|
476
|
+
} else if (dashboardComponent.params.itemEmbedding) {
|
|
477
|
+
dashboardComponent.iframeHeight = "200px";
|
|
478
|
+
} else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
|
|
479
|
+
dashboardComponent.iframeHeight = "100%";
|
|
480
|
+
} else {
|
|
481
|
+
dashboardComponent.iframeHeight = "400px";
|
|
482
|
+
}
|
|
483
|
+
dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
|
|
484
|
+
const styles = {
|
|
485
|
+
height: dashboardComponent.iframeHeight,
|
|
486
|
+
width: dashboardComponent.iframeWidth
|
|
487
|
+
};
|
|
488
|
+
if (dashboardComponent.iframeLoaded) {
|
|
489
|
+
styles.opacity = 1;
|
|
490
|
+
} else if (dashboardComponent.error) {
|
|
491
|
+
styles.opacity = 1;
|
|
492
|
+
styles.width = "100%";
|
|
493
|
+
styles.height = "400px";
|
|
494
|
+
} else {
|
|
495
|
+
styles.opacity = 0;
|
|
496
|
+
}
|
|
497
|
+
return styles;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
|
|
501
|
+
var updateIframeUrl = (iframe, iframeUrl) => {
|
|
502
|
+
if (iframe?.contentWindow) {
|
|
503
|
+
iframe.contentWindow.location.replace(iframeUrl);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/set-selected-data-utils.ts
|
|
508
|
+
var selectedDataUtils = {
|
|
509
|
+
merge(...filters) {
|
|
510
|
+
return filters.reduce((acc, filter) => {
|
|
511
|
+
acc.and.push(...filter.and);
|
|
512
|
+
return acc;
|
|
513
|
+
}, {
|
|
514
|
+
and: []
|
|
515
|
+
});
|
|
516
|
+
},
|
|
517
|
+
isIn(slot, values, otherOptions) {
|
|
518
|
+
return {
|
|
519
|
+
and: [{
|
|
520
|
+
expression: "? in ?",
|
|
521
|
+
parameters: [
|
|
522
|
+
{
|
|
523
|
+
slot,
|
|
524
|
+
...otherOptions
|
|
525
|
+
},
|
|
526
|
+
values
|
|
527
|
+
]
|
|
528
|
+
}]
|
|
529
|
+
};
|
|
530
|
+
},
|
|
531
|
+
between(slot, values, otherOptions) {
|
|
532
|
+
return {
|
|
533
|
+
and: [{
|
|
534
|
+
expression: "? between ?",
|
|
535
|
+
parameters: [
|
|
536
|
+
{
|
|
537
|
+
slot,
|
|
538
|
+
...otherOptions
|
|
539
|
+
},
|
|
540
|
+
[values[0], values[1]]
|
|
541
|
+
]
|
|
542
|
+
}]
|
|
543
|
+
};
|
|
544
|
+
},
|
|
545
|
+
range(slot, values, otherOptions) {
|
|
546
|
+
const expressions = otherOptions?.expressions ?? ["? >= ?", "? < ?"];
|
|
547
|
+
return {
|
|
548
|
+
and: [{
|
|
549
|
+
expression: expressions[0],
|
|
550
|
+
parameters: [
|
|
551
|
+
{
|
|
552
|
+
slot,
|
|
553
|
+
...otherOptions
|
|
554
|
+
},
|
|
555
|
+
[values[0]]
|
|
556
|
+
]
|
|
557
|
+
}, {
|
|
558
|
+
expression: expressions[1],
|
|
559
|
+
parameters: [
|
|
560
|
+
{
|
|
561
|
+
slot,
|
|
562
|
+
...otherOptions
|
|
563
|
+
},
|
|
564
|
+
[values[1]]
|
|
565
|
+
]
|
|
566
|
+
}]
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
|
|
572
|
+
var exportDashboard = (dashboardComponent, iframe, format) => {
|
|
573
|
+
const requestId = uuidv4();
|
|
574
|
+
if (iframe?.contentWindow) {
|
|
575
|
+
iframe.contentWindow.postMessage(
|
|
576
|
+
{
|
|
577
|
+
action: "exportDashboard",
|
|
578
|
+
format: format || "png",
|
|
579
|
+
_version: dashboardComponent.libVersion,
|
|
580
|
+
requestId
|
|
581
|
+
},
|
|
582
|
+
"*"
|
|
583
|
+
);
|
|
584
|
+
return new Promise((resolve, reject) => {
|
|
585
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
586
|
+
setTimeout(() => {
|
|
587
|
+
if (dashboardComponent.promises[requestId]) {
|
|
588
|
+
const errorMessage = "exportDashboard request timed out.";
|
|
589
|
+
dashboardComponent.promises[requestId].reject(
|
|
590
|
+
new Error(errorMessage)
|
|
591
|
+
);
|
|
592
|
+
delete dashboardComponent.promises[requestId];
|
|
593
|
+
}
|
|
594
|
+
}, 12e5);
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
|
|
601
|
+
var getAccessibleDashboards = async (dashboardComponent) => {
|
|
602
|
+
await dashboardComponent.updateComplete;
|
|
603
|
+
if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
|
|
604
|
+
const fetchUser = new Promise((resolve, reject) => {
|
|
605
|
+
void (() => {
|
|
606
|
+
try {
|
|
607
|
+
const responsePromise = window.fetch(
|
|
608
|
+
// With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
|
|
609
|
+
// Fixes incorrect url with embedMode="webComponent"
|
|
610
|
+
`${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
|
|
611
|
+
{
|
|
612
|
+
method: "POST",
|
|
613
|
+
mode: "cors",
|
|
614
|
+
cache: "no-cache",
|
|
615
|
+
headers: { "Content-Type": "application/json" },
|
|
616
|
+
redirect: "follow",
|
|
617
|
+
body: JSON.stringify({
|
|
618
|
+
action: "get",
|
|
619
|
+
version: "0.1.0",
|
|
620
|
+
key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
|
|
621
|
+
token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
|
|
622
|
+
find: {
|
|
623
|
+
where: { id: dashboardComponent.authKey },
|
|
624
|
+
attributes: ["id", "integration_id"],
|
|
625
|
+
include: [
|
|
626
|
+
{
|
|
627
|
+
model: "User",
|
|
628
|
+
attributes: ["id", "name", "locale_id"],
|
|
629
|
+
include: [{ model: "Group" }]
|
|
630
|
+
}
|
|
631
|
+
]
|
|
632
|
+
}
|
|
633
|
+
})
|
|
634
|
+
}
|
|
635
|
+
);
|
|
636
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
637
|
+
if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user) {
|
|
638
|
+
reject("Authorization failed, please check authKey and authToken. If the problem persists, please contact support@luzmo.com.");
|
|
639
|
+
} else {
|
|
640
|
+
data.rows[0].user.userGroups = data.rows[0].user.groups.map(
|
|
641
|
+
(group) => group.id
|
|
642
|
+
);
|
|
643
|
+
delete data.rows[0].user.groups;
|
|
644
|
+
resolve({
|
|
645
|
+
integrationId: data.rows[0].integration_id,
|
|
646
|
+
user: data.rows[0].user
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
} catch (error) {
|
|
651
|
+
reject(error);
|
|
652
|
+
}
|
|
653
|
+
})();
|
|
654
|
+
});
|
|
655
|
+
return new Promise((resolve, reject) => void (() => {
|
|
656
|
+
try {
|
|
657
|
+
fetchUser.then((authorizationData) => {
|
|
658
|
+
const responsePromise = window.fetch(
|
|
659
|
+
// With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
|
|
660
|
+
// Fixes incorrect url with embedMode="webComponent"
|
|
661
|
+
`${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
|
|
662
|
+
{
|
|
663
|
+
method: "POST",
|
|
664
|
+
mode: "cors",
|
|
665
|
+
cache: "no-cache",
|
|
666
|
+
headers: { "Content-Type": "application/json" },
|
|
667
|
+
redirect: "follow",
|
|
668
|
+
body: JSON.stringify({
|
|
669
|
+
action: "get",
|
|
670
|
+
version: "0.1.0",
|
|
671
|
+
key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
|
|
672
|
+
token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
|
|
673
|
+
find: {
|
|
674
|
+
where: { type: "dashboard", is_variant: false },
|
|
675
|
+
attributes: ["id", "name", "modified_at"],
|
|
676
|
+
order: [["modified_at", "desc"]],
|
|
677
|
+
include: [
|
|
678
|
+
{ model: "Tag", attributes: ["tag"] },
|
|
679
|
+
{ model: "User", attributes: ["id", "name"] },
|
|
680
|
+
{
|
|
681
|
+
model: "Group",
|
|
682
|
+
attributes: ["id", "name", "public"]
|
|
683
|
+
},
|
|
684
|
+
{ model: "Integration", attributes: ["id", "name"] }
|
|
685
|
+
]
|
|
686
|
+
}
|
|
687
|
+
})
|
|
688
|
+
}
|
|
689
|
+
);
|
|
690
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
691
|
+
const dashboardList = data.rows.length > 0 ? formatDashboardList(
|
|
692
|
+
data.rows,
|
|
693
|
+
authorizationData.integrationId,
|
|
694
|
+
authorizationData.user,
|
|
695
|
+
dashboardComponent
|
|
696
|
+
) : [];
|
|
697
|
+
resolve(dashboardList);
|
|
698
|
+
});
|
|
699
|
+
}).catch((error) => {
|
|
700
|
+
reject(error);
|
|
701
|
+
});
|
|
702
|
+
} catch (error) {
|
|
703
|
+
reject(error);
|
|
704
|
+
}
|
|
705
|
+
})());
|
|
706
|
+
}
|
|
707
|
+
throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
|
|
711
|
+
var getDashboardContext = (dashboardComponent, iframe) => {
|
|
712
|
+
if (iframe?.contentWindow) {
|
|
713
|
+
const requestId = uuidv4();
|
|
714
|
+
iframe.contentWindow.postMessage(
|
|
715
|
+
{ action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
|
|
716
|
+
"*"
|
|
717
|
+
);
|
|
718
|
+
return new Promise((resolve, reject) => {
|
|
719
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
720
|
+
setTimeout(() => {
|
|
721
|
+
if (dashboardComponent.promises[requestId]) {
|
|
722
|
+
const errorMessage = "getDashboardContext request timed out.";
|
|
723
|
+
dashboardComponent.promises[requestId].reject(
|
|
724
|
+
new Error(errorMessage)
|
|
725
|
+
);
|
|
726
|
+
delete dashboardComponent.promises[requestId];
|
|
727
|
+
}
|
|
728
|
+
}, 2e3);
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
|
|
735
|
+
var getData = (dashboardComponent, iframe, itemId) => {
|
|
736
|
+
if (iframe?.contentWindow) {
|
|
737
|
+
const requestId = uuidv4();
|
|
738
|
+
iframe.contentWindow.postMessage(
|
|
739
|
+
{
|
|
740
|
+
action: "getData",
|
|
741
|
+
id: itemId,
|
|
742
|
+
_version: dashboardComponent.libVersion,
|
|
743
|
+
requestId
|
|
744
|
+
},
|
|
745
|
+
"*"
|
|
746
|
+
);
|
|
747
|
+
return new Promise((resolve, reject) => {
|
|
748
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
749
|
+
setTimeout(() => {
|
|
750
|
+
if (dashboardComponent.promises[requestId]) {
|
|
751
|
+
const errorMessage = "getData request timed out.";
|
|
752
|
+
dashboardComponent.promises[requestId].reject(
|
|
753
|
+
new Error(errorMessage)
|
|
754
|
+
);
|
|
755
|
+
delete dashboardComponent.promises[requestId];
|
|
756
|
+
}
|
|
757
|
+
}, 2e3);
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
|
|
764
|
+
var getFilters = (dashboardComponent, iframe) => {
|
|
765
|
+
if (iframe?.contentWindow) {
|
|
766
|
+
const requestId = uuidv4();
|
|
767
|
+
iframe.contentWindow.postMessage(
|
|
768
|
+
{ action: "getFilters", _version: dashboardComponent.libVersion, requestId },
|
|
769
|
+
"*"
|
|
770
|
+
);
|
|
771
|
+
return new Promise((resolve, reject) => {
|
|
772
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
773
|
+
setTimeout(() => {
|
|
774
|
+
if (dashboardComponent.promises[requestId]) {
|
|
775
|
+
const errorMessage = "getFilters request timed out.";
|
|
776
|
+
dashboardComponent.promises[requestId].reject(
|
|
777
|
+
new Error(errorMessage)
|
|
778
|
+
);
|
|
779
|
+
delete dashboardComponent.promises[requestId];
|
|
780
|
+
}
|
|
781
|
+
}, 2e3);
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
|
|
788
|
+
var getInsights = (dashboardComponent, iframe, options = {}) => {
|
|
789
|
+
if (!iframe?.contentWindow) {
|
|
790
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
791
|
+
}
|
|
792
|
+
const requestId = uuidv4();
|
|
793
|
+
iframe.contentWindow.postMessage(
|
|
794
|
+
{
|
|
795
|
+
action: "getInsights",
|
|
796
|
+
options,
|
|
797
|
+
_version: dashboardComponent.libVersion,
|
|
798
|
+
requestId
|
|
799
|
+
},
|
|
800
|
+
"*"
|
|
801
|
+
);
|
|
802
|
+
return new Promise((resolve, reject) => {
|
|
803
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
804
|
+
setTimeout(() => {
|
|
805
|
+
if (dashboardComponent.promises[requestId]) {
|
|
806
|
+
dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
|
|
807
|
+
delete dashboardComponent.promises[requestId];
|
|
808
|
+
}
|
|
809
|
+
}, 6e4);
|
|
810
|
+
});
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
// libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
|
|
814
|
+
var refreshData = (dashboardComponent, iframe, itemId) => {
|
|
815
|
+
if (iframe) {
|
|
816
|
+
iframe.contentWindow.postMessage(
|
|
817
|
+
{
|
|
818
|
+
action: "refreshData",
|
|
819
|
+
id: itemId ?? null,
|
|
820
|
+
_version: dashboardComponent.libVersion
|
|
821
|
+
},
|
|
822
|
+
"*"
|
|
823
|
+
);
|
|
824
|
+
return Promise.resolve();
|
|
825
|
+
}
|
|
826
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
// libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
|
|
830
|
+
var reloadDashboard = (dashboardComponent, iframe) => {
|
|
831
|
+
if (iframe) {
|
|
832
|
+
iframe.contentWindow.postMessage(
|
|
833
|
+
{ action: "reloadDashboard", _version: dashboardComponent.libVersion },
|
|
834
|
+
"*"
|
|
835
|
+
);
|
|
836
|
+
return Promise.resolve();
|
|
837
|
+
}
|
|
838
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
// libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
|
|
842
|
+
var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
|
|
843
|
+
if (iframe) {
|
|
844
|
+
iframe.contentWindow.postMessage(
|
|
845
|
+
{
|
|
846
|
+
action: "sendExportEmail",
|
|
847
|
+
type: type || "once",
|
|
848
|
+
subject,
|
|
849
|
+
message,
|
|
850
|
+
_version: dashboardComponent.libVersion
|
|
851
|
+
},
|
|
852
|
+
"*"
|
|
853
|
+
);
|
|
854
|
+
return Promise.resolve();
|
|
855
|
+
}
|
|
856
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
|
|
860
|
+
var setAuthorization = (dashboardComponent, iframe, key, token) => {
|
|
861
|
+
if (iframe) {
|
|
862
|
+
iframe.contentWindow.postMessage(
|
|
863
|
+
{
|
|
864
|
+
action: "setAuthorization",
|
|
865
|
+
key,
|
|
866
|
+
token,
|
|
867
|
+
_version: dashboardComponent.libVersion
|
|
868
|
+
},
|
|
869
|
+
"*"
|
|
870
|
+
);
|
|
871
|
+
return Promise.resolve();
|
|
872
|
+
}
|
|
873
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
|
|
877
|
+
var setEditMode = (dashboardComponent, iframe, editMode) => {
|
|
878
|
+
if (iframe && iframe.contentWindow) {
|
|
879
|
+
const requestId = uuidv4();
|
|
880
|
+
if (dashboardComponent.params.editMode === editMode) {
|
|
881
|
+
return Promise.reject(
|
|
882
|
+
new Error("editMode parameter is currently already set to " + editMode)
|
|
883
|
+
);
|
|
884
|
+
} else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
|
|
885
|
+
return Promise.reject(
|
|
886
|
+
new Error(
|
|
887
|
+
"The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
|
|
888
|
+
)
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
iframe.contentWindow.postMessage(
|
|
892
|
+
{
|
|
893
|
+
action: "setEditMode",
|
|
894
|
+
editMode,
|
|
895
|
+
_version: dashboardComponent.libVersion,
|
|
896
|
+
requestId
|
|
897
|
+
},
|
|
898
|
+
"*"
|
|
899
|
+
);
|
|
900
|
+
return new Promise((resolve, reject) => {
|
|
901
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
905
|
+
};
|
|
906
|
+
|
|
907
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
|
|
908
|
+
var setPreview = (dashboardComponent, iframe, preview) => {
|
|
909
|
+
if (iframe) {
|
|
910
|
+
const requestId = uuidv4();
|
|
911
|
+
iframe.contentWindow.postMessage(
|
|
912
|
+
{
|
|
913
|
+
action: "setPreview",
|
|
914
|
+
preview,
|
|
915
|
+
requestId,
|
|
916
|
+
_version: dashboardComponent.libVersion
|
|
917
|
+
},
|
|
918
|
+
"*"
|
|
919
|
+
);
|
|
920
|
+
return new Promise((resolve, reject) => {
|
|
921
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
922
|
+
setTimeout(() => {
|
|
923
|
+
if (dashboardComponent.promises[requestId]) {
|
|
924
|
+
const errorMessage = "setPreview request timed out.";
|
|
925
|
+
dashboardComponent.promises[requestId].reject(
|
|
926
|
+
new Error(errorMessage)
|
|
927
|
+
);
|
|
928
|
+
delete dashboardComponent.promises[requestId];
|
|
929
|
+
}
|
|
930
|
+
}, 2e3);
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
|
|
937
|
+
var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
|
|
938
|
+
if (iframe) {
|
|
939
|
+
const requestId = uuidv4();
|
|
940
|
+
iframe.contentWindow.postMessage(
|
|
941
|
+
{
|
|
942
|
+
action: "setSelectedData",
|
|
943
|
+
itemId,
|
|
944
|
+
filters,
|
|
945
|
+
_version: dashboardComponent.libVersion,
|
|
946
|
+
requestId
|
|
947
|
+
},
|
|
948
|
+
"*"
|
|
949
|
+
);
|
|
950
|
+
return new Promise((resolve, reject) => {
|
|
951
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
952
|
+
setTimeout(() => {
|
|
953
|
+
if (dashboardComponent.promises[requestId]) {
|
|
954
|
+
const errorMessage = "setSelectedData request timed out.";
|
|
955
|
+
dashboardComponent.promises[requestId].reject(
|
|
956
|
+
new Error(errorMessage)
|
|
957
|
+
);
|
|
958
|
+
delete dashboardComponent.promises[requestId];
|
|
959
|
+
}
|
|
960
|
+
}, 2e3);
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
return Promise.reject();
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
// libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
|
|
967
|
+
var _setCalculatedDimensions = (dashboardComponent) => {
|
|
968
|
+
if (!dashboardComponent.dimensions) {
|
|
969
|
+
dashboardComponent.params.error = true;
|
|
970
|
+
_handleError("Got no valid dimensions.", dashboardComponent.params);
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
const dashboardDimensionKeys = Object.keys(
|
|
974
|
+
dashboardComponent.dimensions
|
|
975
|
+
);
|
|
976
|
+
const availableScreenModeExtents = [];
|
|
977
|
+
let currentMode;
|
|
978
|
+
let currentWidth = 0;
|
|
979
|
+
let currentHeight = 0;
|
|
980
|
+
if (!dashboardComponent.params.switchScreenModeOnResize && dashboardComponent.currentScreenMode) {
|
|
981
|
+
dashboardComponent.params.screenMode = dashboardComponent.currentScreenMode;
|
|
982
|
+
}
|
|
983
|
+
if (dashboardComponent.dimensions && dashboardDimensionKeys?.[0] === "fixed") {
|
|
984
|
+
currentMode = "fixed";
|
|
985
|
+
currentWidth = dashboardComponent.dimensions.fixed[0];
|
|
986
|
+
currentHeight = dashboardComponent.dimensions.fixed[1];
|
|
987
|
+
} else {
|
|
988
|
+
const screenModes = [
|
|
989
|
+
"mobile",
|
|
990
|
+
"tablet",
|
|
991
|
+
"desktop",
|
|
992
|
+
"largeScreen"
|
|
993
|
+
];
|
|
994
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
995
|
+
const [firstMatch] = dashboardDimensionKeys;
|
|
996
|
+
let match = firstMatch;
|
|
997
|
+
for (const screenMode of screenModes) {
|
|
998
|
+
const found = dashboardDimensionKeys.find((key) => key === screenMode);
|
|
999
|
+
if (found) {
|
|
1000
|
+
match = found;
|
|
1001
|
+
} else {
|
|
1002
|
+
dashboardComponent.dimensions[screenMode] = dashboardComponent.dimensions[match];
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
for (const key of dashboardDimensionKeys) {
|
|
1007
|
+
if (screenModes.includes(key)) {
|
|
1008
|
+
const screenMode = EXTENTS.find((extent) => extent.mode === key);
|
|
1009
|
+
availableScreenModeExtents.push({
|
|
1010
|
+
...screenMode,
|
|
1011
|
+
height: dashboardComponent.dimensions[key][1] || 50
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
if (!availableScreenModeExtents.map((screenModeExtent) => screenModeExtent.mode).includes(dashboardComponent.params.screenMode)) {
|
|
1016
|
+
dashboardComponent.params.screenMode = "auto";
|
|
1017
|
+
}
|
|
1018
|
+
if (dashboardComponent.params.screenMode === "auto") {
|
|
1019
|
+
availableScreenModeExtents.sort(
|
|
1020
|
+
(a, b) => screenModes.indexOf(a.mode) - screenModes.indexOf(b.mode)
|
|
1021
|
+
);
|
|
1022
|
+
for (const screenModeExtent of availableScreenModeExtents) {
|
|
1023
|
+
const [screenModeExtentMinWidth, screenModeExtentMaxWidth] = screenModeExtent.width;
|
|
1024
|
+
if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
1025
|
+
if (screenModeExtentMinWidth < dashboardComponent.params.itemDimensions.width) {
|
|
1026
|
+
currentMode = screenModeExtent.mode;
|
|
1027
|
+
currentWidth = Number.parseInt(
|
|
1028
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1029
|
+
10
|
|
1030
|
+
);
|
|
1031
|
+
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
1032
|
+
}
|
|
1033
|
+
} else {
|
|
1034
|
+
if (screenModeExtentMinWidth < dashboardComponent.containerWidth) {
|
|
1035
|
+
currentMode = screenModeExtent.mode;
|
|
1036
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
1037
|
+
currentWidth = dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto" ? Number.parseInt(
|
|
1038
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1039
|
+
10
|
|
1040
|
+
) : Math.min(
|
|
1041
|
+
dashboardComponent.containerWidth,
|
|
1042
|
+
screenModeExtentMaxWidth
|
|
1043
|
+
);
|
|
1044
|
+
currentHeight = dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto" ? Number.parseInt(
|
|
1045
|
+
dashboardComponent.params.itemDimensions.height,
|
|
1046
|
+
10
|
|
1047
|
+
) : dashboardComponent.dimensions[currentMode][1];
|
|
1048
|
+
if (dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
1049
|
+
currentWidth = Number.parseInt(
|
|
1050
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1051
|
+
10
|
|
1052
|
+
);
|
|
1053
|
+
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
1054
|
+
}
|
|
1055
|
+
} else {
|
|
1056
|
+
currentWidth = Math.max(
|
|
1057
|
+
Math.min(
|
|
1058
|
+
screenModeExtentMaxWidth,
|
|
1059
|
+
dashboardComponent.containerWidth
|
|
1060
|
+
),
|
|
1061
|
+
screenModeExtentMinWidth
|
|
1062
|
+
);
|
|
1063
|
+
currentHeight = screenModeExtent.height;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
} else {
|
|
1069
|
+
const {
|
|
1070
|
+
height: chosenModeHeight,
|
|
1071
|
+
width: [chosenModeMinWidth, chosenModeMaxWidth]
|
|
1072
|
+
} = availableScreenModeExtents.find(
|
|
1073
|
+
(d) => d.mode === dashboardComponent.params.screenMode
|
|
1074
|
+
);
|
|
1075
|
+
currentMode = dashboardComponent.params.screenMode;
|
|
1076
|
+
currentWidth = Math.max(
|
|
1077
|
+
Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
|
|
1078
|
+
chosenModeMinWidth
|
|
1079
|
+
);
|
|
1080
|
+
currentHeight = chosenModeHeight;
|
|
1081
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
1082
|
+
if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
|
|
1083
|
+
currentWidth = Number.parseInt(
|
|
1084
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1085
|
+
10
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1088
|
+
if (dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto") {
|
|
1089
|
+
currentHeight = Number.parseInt(
|
|
1090
|
+
dashboardComponent.params.itemDimensions.height,
|
|
1091
|
+
10
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if (!currentMode && availableScreenModeExtents.length > 0) {
|
|
1097
|
+
const [lowestModeExtent] = availableScreenModeExtents;
|
|
1098
|
+
currentMode = lowestModeExtent.mode;
|
|
1099
|
+
currentWidth = lowestModeExtent.width[0];
|
|
1100
|
+
currentHeight = lowestModeExtent.height;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
dashboardComponent.currentScreenMode = currentMode;
|
|
1104
|
+
const style = {
|
|
1105
|
+
height: currentHeight === 0 ? "100%" : `${String(currentHeight)}px`,
|
|
1106
|
+
width: currentWidth === 0 ? "100%" : `${String(currentWidth)}px`,
|
|
1107
|
+
opacity: 1
|
|
1108
|
+
};
|
|
1109
|
+
const dashboardEditModes = ["editFull", "editLimited"];
|
|
1110
|
+
if (dashboardEditModes.includes(dashboardComponent.params.editMode)) {
|
|
1111
|
+
style.height = "100%";
|
|
1112
|
+
style.width = "100%";
|
|
1113
|
+
} else if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions) {
|
|
1114
|
+
style.height = dashboardComponent.params.itemDimensions.height === "auto" ? style.height : `${String(dashboardComponent.params.itemDimensions.height).replace(
|
|
1115
|
+
"px",
|
|
1116
|
+
""
|
|
1117
|
+
)}px`;
|
|
1118
|
+
style.width = dashboardComponent.params.itemDimensions.width === "auto" ? style.width : `${String(dashboardComponent.params.itemDimensions.width).replace(
|
|
1119
|
+
"px",
|
|
1120
|
+
""
|
|
1121
|
+
)}px`;
|
|
1122
|
+
} else {
|
|
1123
|
+
style.height = currentHeight === 0 ? "100%" : `${String(currentHeight)}px`;
|
|
1124
|
+
style.width = currentWidth === 0 ? "100%" : `${String(currentWidth)}px`;
|
|
1125
|
+
}
|
|
1126
|
+
dashboardComponent.currentScreenMode = currentMode;
|
|
1127
|
+
dashboardComponent.iframeStyle = style;
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1130
|
+
// libs/embed-libs/embed/src/lib/shared/service/extend-and-validate.ts
|
|
1131
|
+
var _extendAndValidate = (dashboardContent) => {
|
|
1132
|
+
const defaultKeys = Object.keys(
|
|
1133
|
+
DEFAULT_PARAMETERS
|
|
1134
|
+
);
|
|
1135
|
+
const errorMessages = [];
|
|
1136
|
+
const requiredStringParams = [
|
|
1137
|
+
"appServer",
|
|
1138
|
+
"language",
|
|
1139
|
+
"apiHost"
|
|
1140
|
+
];
|
|
1141
|
+
const requiredStringOrEmptyParams = [
|
|
1142
|
+
"key",
|
|
1143
|
+
"token",
|
|
1144
|
+
"screenMode",
|
|
1145
|
+
"timezoneId",
|
|
1146
|
+
"itemId",
|
|
1147
|
+
"container",
|
|
1148
|
+
"loaderBackground",
|
|
1149
|
+
"loaderFontColor",
|
|
1150
|
+
"loaderSpinnerColor",
|
|
1151
|
+
"loaderSpinnerBackground"
|
|
1152
|
+
];
|
|
1153
|
+
const objectParams = ["itemDimensions"];
|
|
1154
|
+
const screenModes = [
|
|
1155
|
+
"mobile",
|
|
1156
|
+
"tablet",
|
|
1157
|
+
"desktop",
|
|
1158
|
+
"largeScreen",
|
|
1159
|
+
"fixed",
|
|
1160
|
+
"auto"
|
|
1161
|
+
];
|
|
1162
|
+
for (const key of defaultKeys) {
|
|
1163
|
+
if (dashboardContent.params[key] === null) {
|
|
1164
|
+
delete dashboardContent.params[key];
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
dashboardContent.params = defaultsDeep(
|
|
1168
|
+
dashboardContent.params,
|
|
1169
|
+
DEFAULT_PARAMETERS
|
|
1170
|
+
);
|
|
1171
|
+
if ((!dashboardContent.params.dashboardId || typeof dashboardContent.params.dashboardId !== "string") && (!dashboardContent.params.dashboardSlug || typeof dashboardContent.params.dashboardSlug !== "string")) {
|
|
1172
|
+
delete dashboardContent.params.dashboardId;
|
|
1173
|
+
delete dashboardContent.params.dashboardSlug;
|
|
1174
|
+
}
|
|
1175
|
+
for (const key of requiredStringParams) {
|
|
1176
|
+
if (typeof dashboardContent.params[key] !== "string") {
|
|
1177
|
+
delete dashboardContent.params[key];
|
|
1178
|
+
errorMessages.push(`${key} needs to be of type string.`);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
for (const key of requiredStringOrEmptyParams) {
|
|
1182
|
+
if (typeof dashboardContent.params[key] !== "string" && dashboardContent.params[key] !== null && dashboardContent.params[key] !== void 0) {
|
|
1183
|
+
delete dashboardContent.params[key];
|
|
1184
|
+
errorMessages.push(`${key} needs to be of type string or empty.`);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
if (dashboardContent.params.screenMode && !screenModes.includes(dashboardContent.params.screenMode)) {
|
|
1188
|
+
const validTypesString = screenModes.map((mode) => `"${mode}"`).join(", ");
|
|
1189
|
+
errorMessages.push(
|
|
1190
|
+
`"screenMode" needs should be one of these types: ${validTypesString}`
|
|
1191
|
+
);
|
|
1192
|
+
dashboardContent.params.screenMode = "auto";
|
|
1193
|
+
}
|
|
1194
|
+
if (dashboardContent.params.itemId) {
|
|
1195
|
+
dashboardContent.params.itemEmbedding = true;
|
|
1196
|
+
}
|
|
1197
|
+
for (const key of objectParams) {
|
|
1198
|
+
if (typeof dashboardContent.params[key] !== "object" && dashboardContent.params[key] !== null) {
|
|
1199
|
+
delete dashboardContent.params[key];
|
|
1200
|
+
errorMessages.push(`${key} needs to be of type object or empty.`);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (typeof dashboardContent.params.switchScreenModeOnResize !== "boolean") {
|
|
1204
|
+
errorMessages.push("switchScreenModeOnResize needs to be of type boolean.");
|
|
1205
|
+
dashboardContent.params.switchScreenModeOnResize = true;
|
|
1206
|
+
}
|
|
1207
|
+
if (dashboardContent.params.itemDimensions) {
|
|
1208
|
+
const itemDimensionsKeys = [
|
|
1209
|
+
"width",
|
|
1210
|
+
"height"
|
|
1211
|
+
];
|
|
1212
|
+
for (const key of itemDimensionsKeys) {
|
|
1213
|
+
if (!["string", "number"].includes(
|
|
1214
|
+
typeof dashboardContent.params.itemDimensions[key]
|
|
1215
|
+
) && dashboardContent.params.itemDimensions[key] !== null) {
|
|
1216
|
+
errorMessages.push(
|
|
1217
|
+
`itemDimensions ${key} needs to be of type string, number or empty.`
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
dashboardContent.params = defaultsDeep(
|
|
1223
|
+
dashboardContent.params,
|
|
1224
|
+
DEFAULT_PARAMETERS
|
|
1225
|
+
);
|
|
1226
|
+
if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
|
|
1227
|
+
dashboardContent.params.switchScreenModeOnResize = false;
|
|
1228
|
+
}
|
|
1229
|
+
if (dashboardContent.params.itemDimensions.width !== "auto") {
|
|
1230
|
+
dashboardContent.params.itemDimensions.width = Number.parseInt(
|
|
1231
|
+
`${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
|
|
1232
|
+
10
|
|
1233
|
+
) || "auto";
|
|
1234
|
+
}
|
|
1235
|
+
if (dashboardContent.params.itemDimensions.height !== "auto") {
|
|
1236
|
+
dashboardContent.params.itemDimensions.height = Number.parseInt(
|
|
1237
|
+
`${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
|
|
1238
|
+
10
|
|
1239
|
+
) || "auto";
|
|
1240
|
+
}
|
|
1241
|
+
dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
|
|
1242
|
+
if (dashboardContent.params.error || errorMessages.length > 0) {
|
|
1243
|
+
_handleError(errorMessages.join("\n"), dashboardContent.params);
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1247
|
+
// libs/embed-libs/embed/src/lib/shared/models/viz-item.model.ts
|
|
1248
|
+
var libraryTypeToWebComponentTypeMapping = {
|
|
1249
|
+
type: "type",
|
|
1250
|
+
slots: "slots",
|
|
1251
|
+
options: "options",
|
|
1252
|
+
appServer: "app-server",
|
|
1253
|
+
apiHost: "api-host",
|
|
1254
|
+
authKey: "auth-key",
|
|
1255
|
+
authToken: "auth-token",
|
|
1256
|
+
contextId: "context-id",
|
|
1257
|
+
canFilter: "can-filter",
|
|
1258
|
+
filters: "filters",
|
|
1259
|
+
dashboardId: "dashboard-id",
|
|
1260
|
+
itemId: "item-id",
|
|
1261
|
+
aiMessageAssetId: "ai-message-asset-id",
|
|
1262
|
+
dashboardContentsVersion: "dashboard-contents-version",
|
|
1263
|
+
libVersion: "lib-version"
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
// libs/embed-libs/embed/src/lib/shared/constants/class-constants.ts
|
|
1267
|
+
var luzmoEmbedContainerClass = "luzmo-embed-container";
|
|
1268
|
+
|
|
1269
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/remote-federation.ts
|
|
1270
|
+
import { createInstance } from "@module-federation/runtime";
|
|
1271
|
+
var federationRuntime = createInstance({
|
|
1272
|
+
name: "luzmo-embed-runtime",
|
|
1273
|
+
remotes: []
|
|
1274
|
+
});
|
|
1275
|
+
var remoteCache = /* @__PURE__ */ new Map();
|
|
1276
|
+
var remoteCounter = 0;
|
|
1277
|
+
var preconnectedOrigins = /* @__PURE__ */ new Set();
|
|
1278
|
+
function injectPreconnect(appServer) {
|
|
1279
|
+
if (typeof document === "undefined") {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
let origin;
|
|
1283
|
+
try {
|
|
1284
|
+
origin = new URL(removeTrailingSlash(appServer)).origin;
|
|
1285
|
+
} catch {
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
if (preconnectedOrigins.has(origin)) {
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
preconnectedOrigins.add(origin);
|
|
1292
|
+
const link = document.createElement("link");
|
|
1293
|
+
link.rel = "preconnect";
|
|
1294
|
+
link.href = origin;
|
|
1295
|
+
link.crossOrigin = "anonymous";
|
|
1296
|
+
(document.head ?? document.documentElement).append(link);
|
|
1297
|
+
}
|
|
1298
|
+
function getManifestEntry(appServer, componentName) {
|
|
1299
|
+
const baseUrl = removeTrailingSlash(appServer);
|
|
1300
|
+
if (appServer.startsWith("http://localhost")) {
|
|
1301
|
+
return `${baseUrl}/mf-manifest.json`;
|
|
1302
|
+
}
|
|
1303
|
+
switch (componentName) {
|
|
1304
|
+
case "DashboardApp":
|
|
1305
|
+
case "VizItemApp": {
|
|
1306
|
+
return `${baseUrl}/dashboard-app/mf-manifest.json`;
|
|
1307
|
+
}
|
|
1308
|
+
case "IQApp": {
|
|
1309
|
+
return `${baseUrl}/iq-app/mf-manifest.json`;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
function getCacheKey(appServer, componentName) {
|
|
1314
|
+
return `${appServer}|${componentName}`;
|
|
1315
|
+
}
|
|
1316
|
+
function getOrCreateRemote(appServer, componentName) {
|
|
1317
|
+
const cacheKey = getCacheKey(appServer, componentName);
|
|
1318
|
+
const cachedRemote = remoteCache.get(cacheKey);
|
|
1319
|
+
if (cachedRemote) {
|
|
1320
|
+
return cachedRemote;
|
|
1321
|
+
}
|
|
1322
|
+
const remote = {
|
|
1323
|
+
entry: getManifestEntry(appServer, componentName),
|
|
1324
|
+
registered: false,
|
|
1325
|
+
remoteName: `luzmo_embed_${remoteCounter++}`
|
|
1326
|
+
};
|
|
1327
|
+
remoteCache.set(cacheKey, remote);
|
|
1328
|
+
return remote;
|
|
1329
|
+
}
|
|
1330
|
+
function loadLibrary(appServer, componentName = "DashboardApp") {
|
|
1331
|
+
injectPreconnect(appServer);
|
|
1332
|
+
const remote = getOrCreateRemote(appServer, componentName);
|
|
1333
|
+
if (remote.module) {
|
|
1334
|
+
return Promise.resolve(remote.module);
|
|
1335
|
+
}
|
|
1336
|
+
if (remote.loadPromise) {
|
|
1337
|
+
return remote.loadPromise;
|
|
1338
|
+
}
|
|
1339
|
+
if (!remote.registered) {
|
|
1340
|
+
federationRuntime.registerRemotes([
|
|
1341
|
+
{
|
|
1342
|
+
name: remote.remoteName,
|
|
1343
|
+
entry: remote.entry
|
|
1344
|
+
}
|
|
1345
|
+
]);
|
|
1346
|
+
remote.registered = true;
|
|
1347
|
+
}
|
|
1348
|
+
remote.loadPromise = federationRuntime.loadRemote(`${remote.remoteName}/${componentName}`).then((module) => {
|
|
1349
|
+
if (!module) {
|
|
1350
|
+
throw new Error(`Failed to load "${componentName}" from "${remote.entry}".`);
|
|
1351
|
+
}
|
|
1352
|
+
remote.module = module;
|
|
1353
|
+
return module;
|
|
1354
|
+
}).finally(() => {
|
|
1355
|
+
remote.loadPromise = void 0;
|
|
1356
|
+
});
|
|
1357
|
+
return remote.loadPromise;
|
|
1358
|
+
}
|
|
1359
|
+
function preloadDashboard(appServer = "https://app.luzmo.com") {
|
|
1360
|
+
loadLibrary(appServer, "DashboardApp").catch(() => {
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
function preloadVizItem(appServer = "https://app.luzmo.com") {
|
|
1364
|
+
loadLibrary(appServer, "VizItemApp").catch(() => {
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
function preloadIQ(appServer = "https://app.luzmo.com") {
|
|
1368
|
+
loadLibrary(appServer, "IQApp").catch(() => {
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
|
|
12
1372
|
// libs/embed-libs/embed/src/index.ts
|
|
13
|
-
import { selectedDataUtils, preloadDashboard, preloadVizItem, preloadIQ } from "@luzmo/shared-embed";
|
|
14
1373
|
import { LitElement as LitElement5 } from "lit";
|
|
15
1374
|
|
|
16
1375
|
// libs/embed-libs/embed/src/lib/dashboard/dashboard-base.ts
|
|
17
|
-
import * as SharedLib2 from "@luzmo/shared-embed";
|
|
18
1376
|
import { html, LitElement } from "lit";
|
|
19
1377
|
import { property, query, state } from "lit/decorators.js";
|
|
20
1378
|
import { styleMap } from "lit/directives/style-map.js";
|
|
21
1379
|
|
|
22
1380
|
// libs/embed-libs/embed/package.json
|
|
23
|
-
var version = "
|
|
1381
|
+
var version = "8.0.0";
|
|
24
1382
|
|
|
25
|
-
// libs/embed-libs/embed/src/lib/
|
|
1383
|
+
// libs/embed-libs/embed/src/lib/utils/embed-error.utils.ts
|
|
26
1384
|
function buildEmbedErrorDetail(errorMsg) {
|
|
27
1385
|
const payload = {
|
|
28
1386
|
type: "error",
|
|
@@ -36,14 +1394,13 @@ function firstString(...values) {
|
|
|
36
1394
|
}
|
|
37
1395
|
function normalizeEmbedErrorDetail(detail) {
|
|
38
1396
|
const wrapped = detail;
|
|
39
|
-
const
|
|
1397
|
+
const fromWrapped = wrapped?.data;
|
|
1398
|
+
const fromDetail = detail && typeof detail === "object" ? detail : void 0;
|
|
1399
|
+
const raw = fromWrapped ?? fromDetail ?? {};
|
|
40
1400
|
const errorMsg = firstString(raw.errorMsg, raw.error?.msg) ?? "Unknown error";
|
|
41
1401
|
return buildEmbedErrorDetail(errorMsg);
|
|
42
1402
|
}
|
|
43
1403
|
|
|
44
|
-
// libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
|
|
45
|
-
import * as SharedLib from "@luzmo/shared-embed";
|
|
46
|
-
|
|
47
1404
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
48
1405
|
var LuzmoDashboardService = class {
|
|
49
1406
|
constructor() {
|
|
@@ -52,7 +1409,7 @@ var LuzmoDashboardService = class {
|
|
|
52
1409
|
};
|
|
53
1410
|
var luzmo_service_default = new LuzmoDashboardService();
|
|
54
1411
|
|
|
55
|
-
// libs/embed-libs/embed/src/lib/
|
|
1412
|
+
// libs/embed-libs/embed/src/lib/utils/event-bus-handler.ts
|
|
56
1413
|
var _setEventHandler = () => {
|
|
57
1414
|
if (typeof window.__luzmoMessageHandler === "function") {
|
|
58
1415
|
return;
|
|
@@ -83,7 +1440,7 @@ var _setEventHandler = () => {
|
|
|
83
1440
|
break;
|
|
84
1441
|
}
|
|
85
1442
|
case "data": {
|
|
86
|
-
|
|
1443
|
+
resolvePromise(
|
|
87
1444
|
dashboardComponent,
|
|
88
1445
|
event.data.requestId,
|
|
89
1446
|
event.data.data
|
|
@@ -91,7 +1448,7 @@ var _setEventHandler = () => {
|
|
|
91
1448
|
break;
|
|
92
1449
|
}
|
|
93
1450
|
case "filters": {
|
|
94
|
-
|
|
1451
|
+
resolvePromise(
|
|
95
1452
|
dashboardComponent,
|
|
96
1453
|
event.data.requestId,
|
|
97
1454
|
event.data.filters
|
|
@@ -100,13 +1457,13 @@ var _setEventHandler = () => {
|
|
|
100
1457
|
}
|
|
101
1458
|
case "insights": {
|
|
102
1459
|
if (event.data.error) {
|
|
103
|
-
|
|
1460
|
+
rejectPromise(
|
|
104
1461
|
dashboardComponent,
|
|
105
1462
|
event.data.requestId,
|
|
106
1463
|
new Error(event.data.error.message)
|
|
107
1464
|
);
|
|
108
1465
|
} else {
|
|
109
|
-
|
|
1466
|
+
resolvePromise(
|
|
110
1467
|
dashboardComponent,
|
|
111
1468
|
event.data.requestId,
|
|
112
1469
|
event.data.summary
|
|
@@ -115,7 +1472,7 @@ var _setEventHandler = () => {
|
|
|
115
1472
|
break;
|
|
116
1473
|
}
|
|
117
1474
|
case "dashboardContext": {
|
|
118
|
-
|
|
1475
|
+
resolvePromise(
|
|
119
1476
|
dashboardComponent,
|
|
120
1477
|
event.data.requestId,
|
|
121
1478
|
event.data.context
|
|
@@ -123,7 +1480,7 @@ var _setEventHandler = () => {
|
|
|
123
1480
|
break;
|
|
124
1481
|
}
|
|
125
1482
|
case "getAccessibleDashboards": {
|
|
126
|
-
|
|
1483
|
+
resolvePromise(
|
|
127
1484
|
dashboardComponent,
|
|
128
1485
|
event.data.requestId,
|
|
129
1486
|
event.data.accessibleDashboards
|
|
@@ -138,7 +1495,7 @@ var _setEventHandler = () => {
|
|
|
138
1495
|
}
|
|
139
1496
|
case "export": {
|
|
140
1497
|
if (event.data.error) {
|
|
141
|
-
|
|
1498
|
+
rejectPromise(
|
|
142
1499
|
dashboardComponent,
|
|
143
1500
|
event.data.requestId,
|
|
144
1501
|
event.data
|
|
@@ -147,7 +1504,7 @@ var _setEventHandler = () => {
|
|
|
147
1504
|
dashboardComponent.dispatchEvent(
|
|
148
1505
|
new CustomEvent("exported", { detail: { data: event.data } })
|
|
149
1506
|
);
|
|
150
|
-
|
|
1507
|
+
resolvePromise(
|
|
151
1508
|
dashboardComponent,
|
|
152
1509
|
event.data.requestId,
|
|
153
1510
|
event.data
|
|
@@ -184,28 +1541,28 @@ var _setEventHandler = () => {
|
|
|
184
1541
|
}
|
|
185
1542
|
case "setEditMode": {
|
|
186
1543
|
if (event.data.error) {
|
|
187
|
-
|
|
1544
|
+
rejectPromise(
|
|
188
1545
|
dashboardComponent,
|
|
189
1546
|
event.data.requestId,
|
|
190
1547
|
event.data
|
|
191
1548
|
);
|
|
192
1549
|
} else {
|
|
193
|
-
|
|
1550
|
+
resolvePromise(
|
|
194
1551
|
dashboardComponent,
|
|
195
1552
|
event.data.requestId,
|
|
196
1553
|
event.data
|
|
197
1554
|
);
|
|
198
1555
|
dashboardComponent.params.editMode = event.data.editMode;
|
|
199
|
-
dashboardComponent._containerStyle =
|
|
1556
|
+
dashboardComponent._containerStyle = containerStyles(dashboardComponent);
|
|
200
1557
|
if (dashboardComponent.dimensions) {
|
|
201
|
-
|
|
1558
|
+
_setCalculatedDimensions(dashboardComponent);
|
|
202
1559
|
}
|
|
203
1560
|
}
|
|
204
1561
|
break;
|
|
205
1562
|
}
|
|
206
1563
|
case "calculatedDimensions": {
|
|
207
1564
|
dashboardComponent.dimensions = event.data.dimensions;
|
|
208
|
-
|
|
1565
|
+
_setCalculatedDimensions(dashboardComponent);
|
|
209
1566
|
break;
|
|
210
1567
|
}
|
|
211
1568
|
case "trackViewport": {
|
|
@@ -219,13 +1576,13 @@ var _setEventHandler = () => {
|
|
|
219
1576
|
case "setSelectedData":
|
|
220
1577
|
case "setFilters": {
|
|
221
1578
|
if (event.data.error) {
|
|
222
|
-
|
|
1579
|
+
rejectPromise(
|
|
223
1580
|
dashboardComponent,
|
|
224
1581
|
event.data.requestId,
|
|
225
1582
|
event.data
|
|
226
1583
|
);
|
|
227
1584
|
} else {
|
|
228
|
-
|
|
1585
|
+
resolvePromise(
|
|
229
1586
|
dashboardComponent,
|
|
230
1587
|
event.data.requestId,
|
|
231
1588
|
event.data
|
|
@@ -235,13 +1592,13 @@ var _setEventHandler = () => {
|
|
|
235
1592
|
}
|
|
236
1593
|
case "setPreview": {
|
|
237
1594
|
if (event.data.error) {
|
|
238
|
-
|
|
1595
|
+
rejectPromise(
|
|
239
1596
|
dashboardComponent,
|
|
240
1597
|
event.data.requestId,
|
|
241
1598
|
event.data
|
|
242
1599
|
);
|
|
243
1600
|
} else {
|
|
244
|
-
|
|
1601
|
+
resolvePromise(
|
|
245
1602
|
dashboardComponent,
|
|
246
1603
|
event.data.requestId,
|
|
247
1604
|
event.data
|
|
@@ -329,6 +1686,31 @@ var dashboardStyles = css`
|
|
|
329
1686
|
margin: 0 auto;
|
|
330
1687
|
}
|
|
331
1688
|
|
|
1689
|
+
.luzmo-embed-container:not(.luzmo-embed-container-ede) .luzmo-container-loader {
|
|
1690
|
+
height: 100% !important;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
.luzmo-embed-container:not(.luzmo-embed-container-ede) .luzmo-loader {
|
|
1694
|
+
display: flex;
|
|
1695
|
+
align-items: center;
|
|
1696
|
+
justify-content: center;
|
|
1697
|
+
height: 100%;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
.luzmo-embed-container:not(.luzmo-embed-container-ede) .luzmo-lc {
|
|
1701
|
+
display: flex;
|
|
1702
|
+
flex-direction: column;
|
|
1703
|
+
align-items: center;
|
|
1704
|
+
padding: 0 !important;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
.luzmo-embed-container:not(.luzmo-embed-container-ede) .luzmo-loading-message {
|
|
1708
|
+
height: auto;
|
|
1709
|
+
margin: 12px 0 0;
|
|
1710
|
+
line-height: 1.5;
|
|
1711
|
+
font-weight: 300;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
332
1714
|
.luzmo-loading-message {
|
|
333
1715
|
width: 100%;
|
|
334
1716
|
height: 20px;
|
|
@@ -399,7 +1781,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
399
1781
|
this.screenMode = "auto";
|
|
400
1782
|
this.switchScreenModeOnResize = true;
|
|
401
1783
|
this.editMode = "view";
|
|
402
|
-
this.embedMode = "
|
|
1784
|
+
this.embedMode = "webComponent";
|
|
403
1785
|
this.iframeStyle = {};
|
|
404
1786
|
this._containerStyle = {};
|
|
405
1787
|
this._loaderStyle = {};
|
|
@@ -411,6 +1793,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
411
1793
|
this.browserError = false;
|
|
412
1794
|
this.browserErrorMsg = "";
|
|
413
1795
|
this.dashboardError = false;
|
|
1796
|
+
this.dashboardErrorMsg = "";
|
|
414
1797
|
this.browserNotSupported = [];
|
|
415
1798
|
this.libVersion = version + "-wc-luzmo";
|
|
416
1799
|
this.isLibraryLoaded = false;
|
|
@@ -422,9 +1805,8 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
422
1805
|
dashboardSlug: "dashboard-slug",
|
|
423
1806
|
itemId: "item-id",
|
|
424
1807
|
language: "language",
|
|
425
|
-
editorLanguage: "
|
|
1808
|
+
editorLanguage: "editor-language",
|
|
426
1809
|
screenMode: "screen-mode",
|
|
427
|
-
switchScreenModeOnResize: "switch-screen-mode-on-resize",
|
|
428
1810
|
authKey: "auth-key",
|
|
429
1811
|
authToken: "auth-token",
|
|
430
1812
|
editMode: "edit-mode",
|
|
@@ -443,12 +1825,13 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
443
1825
|
this.borderWidth = 3;
|
|
444
1826
|
this.minHeight = 400;
|
|
445
1827
|
this._viewportTrackingActive = false;
|
|
1828
|
+
this._webComponentLibraryLoadId = 0;
|
|
446
1829
|
// Post synchronously on scroll/resize (not via requestAnimationFrame) so the iframe receives the
|
|
447
1830
|
// new slice as early as possible in the frame, minimizing the lag of the pinned analyst panel.
|
|
448
1831
|
this._onViewportChange = () => {
|
|
449
1832
|
this._postViewport();
|
|
450
1833
|
};
|
|
451
|
-
this._containerId =
|
|
1834
|
+
this._containerId = uuidv4();
|
|
452
1835
|
this._iframeId = `luzmo-dashboard-${this._containerId}`;
|
|
453
1836
|
this.iframeLoaded = false;
|
|
454
1837
|
this.promises = {};
|
|
@@ -457,7 +1840,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
457
1840
|
if (this.shadowRoot?.querySelector(".dashboard-container")) {
|
|
458
1841
|
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
459
1842
|
if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
|
|
460
|
-
for (const d of
|
|
1843
|
+
for (const d of EXTENTS) {
|
|
461
1844
|
if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
|
|
462
1845
|
this.currentScreenMode = d.mode;
|
|
463
1846
|
}
|
|
@@ -468,7 +1851,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
468
1851
|
} else {
|
|
469
1852
|
if (this.dimensions) {
|
|
470
1853
|
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
471
|
-
|
|
1854
|
+
_setCalculatedDimensions(this);
|
|
472
1855
|
}
|
|
473
1856
|
}
|
|
474
1857
|
}
|
|
@@ -501,7 +1884,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
501
1884
|
// overlays (e.g. the IQ analyst) can pin themselves to the visible area while the host page
|
|
502
1885
|
// scrolls the full-height iframe. Opt-in: started when the iframe requests it via 'trackViewport'.
|
|
503
1886
|
_startViewportTracking() {
|
|
504
|
-
if (this.
|
|
1887
|
+
if (this.isWebComponentViewMode()) {
|
|
505
1888
|
return;
|
|
506
1889
|
}
|
|
507
1890
|
if (!this._viewportTrackingActive) {
|
|
@@ -533,7 +1916,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
533
1916
|
contentWindow.postMessage({ action: "setViewport", offsetTop, visibleHeight }, "*");
|
|
534
1917
|
}
|
|
535
1918
|
firstUpdated() {
|
|
536
|
-
this._loaderMsg =
|
|
1919
|
+
this._loaderMsg = getLoader(this)?.loadingMsg;
|
|
537
1920
|
this._loaderStyles();
|
|
538
1921
|
luzmo_service_default._dashboardComponents.push(this);
|
|
539
1922
|
if (this.luzmoEmbedContainer) {
|
|
@@ -543,15 +1926,37 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
543
1926
|
initComponent() {
|
|
544
1927
|
this.params = this._setOptions();
|
|
545
1928
|
if (this.isWebComponentViewMode()) {
|
|
546
|
-
|
|
1929
|
+
this.params.itemEmbedding = this._itemEmbedding;
|
|
1930
|
+
this.iframeLoaded = false;
|
|
1931
|
+
this._loaderStyles();
|
|
1932
|
+
if (!this.iframeStyle.height) {
|
|
1933
|
+
this.iframeStyle = calculateIframeStyles(this);
|
|
1934
|
+
}
|
|
1935
|
+
this.dashboardError = false;
|
|
1936
|
+
this.dashboardErrorMsg = "";
|
|
1937
|
+
const appServer = this.params.appServer;
|
|
1938
|
+
const libraryLoadId = ++this._webComponentLibraryLoadId;
|
|
1939
|
+
loadLibrary(appServer, dashboardRemote).then(async () => {
|
|
1940
|
+
if (libraryLoadId !== this._webComponentLibraryLoadId || !this.isWebComponentViewMode() || this.params.appServer !== appServer) {
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
547
1943
|
this.isLibraryLoaded = true;
|
|
548
1944
|
await this.updateComplete;
|
|
1945
|
+
if (libraryLoadId !== this._webComponentLibraryLoadId) {
|
|
1946
|
+
return;
|
|
1947
|
+
}
|
|
549
1948
|
const el = document.createElement("dashboard-component");
|
|
550
1949
|
this.setAllAttributesOnElement(el);
|
|
551
1950
|
el.addEventListener("load", (payload) => {
|
|
1951
|
+
this.dashboardErrorMsg = "";
|
|
552
1952
|
this.containerWidth = el.offsetWidth;
|
|
553
1953
|
this.dimensions = payload.detail.dimensions;
|
|
554
|
-
|
|
1954
|
+
if (this._loadTimeoutHandle) {
|
|
1955
|
+
clearTimeout(this._loadTimeoutHandle);
|
|
1956
|
+
this._loadTimeoutHandle = void 0;
|
|
1957
|
+
}
|
|
1958
|
+
this.iframeLoaded = true;
|
|
1959
|
+
this._calculateDimAfterDashboardLoaded();
|
|
555
1960
|
window.dispatchEvent(new Event("resize"));
|
|
556
1961
|
this.dispatchEvent(new CustomEvent("load", payload));
|
|
557
1962
|
});
|
|
@@ -569,18 +1974,24 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
569
1974
|
container.append(el);
|
|
570
1975
|
this.dashboardReference = el;
|
|
571
1976
|
}
|
|
1977
|
+
}).catch((error) => {
|
|
1978
|
+
if (libraryLoadId !== this._webComponentLibraryLoadId || !this.isWebComponentViewMode() || this.params.appServer !== appServer) {
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1981
|
+
const errorMsg = error instanceof Error ? error.message : "Failed to load the dashboard application.";
|
|
1982
|
+
this._handleEmbedError({ errorMsg });
|
|
572
1983
|
});
|
|
573
1984
|
} else {
|
|
574
1985
|
this.containerWidth = this.container?.clientWidth;
|
|
575
|
-
|
|
576
|
-
|
|
1986
|
+
_extendAndValidate(this);
|
|
1987
|
+
_browserCheck(this);
|
|
577
1988
|
this._setupLoader();
|
|
578
1989
|
if (!this.params.error) {
|
|
579
1990
|
this._loaderStyles();
|
|
580
1991
|
_setEventHandler();
|
|
581
|
-
this._iframeUrl =
|
|
1992
|
+
this._iframeUrl = createIframeUrl(this);
|
|
582
1993
|
this.iframe?.setAttribute("src", this._iframeUrl);
|
|
583
|
-
this.iframeStyle =
|
|
1994
|
+
this.iframeStyle = calculateIframeStyles(this);
|
|
584
1995
|
}
|
|
585
1996
|
}
|
|
586
1997
|
}
|
|
@@ -593,29 +2004,37 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
593
2004
|
if (!el) {
|
|
594
2005
|
return;
|
|
595
2006
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
2007
|
+
const propertyNames = Object.keys(this.attributesMap);
|
|
2008
|
+
const prioritizedPropertyNames = ["dashboardId", "appServer", "apiHost"];
|
|
2009
|
+
for (const propertyName of [
|
|
2010
|
+
...prioritizedPropertyNames,
|
|
2011
|
+
...propertyNames.filter((name) => !prioritizedPropertyNames.includes(name))
|
|
2012
|
+
]) {
|
|
2013
|
+
this.setAttributeOnElement(el, propertyName);
|
|
601
2014
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (!["authKey", "authToken", "apiHost", "itemDimensions", "dashboardId", "appServer"].includes(key) && this.params[key]) {
|
|
607
|
-
el.setAttribute(this.attributesMap[key], this.params[key]);
|
|
608
|
-
}
|
|
2015
|
+
}
|
|
2016
|
+
getAttributeValue(propertyName) {
|
|
2017
|
+
if (propertyName === "authKey") {
|
|
2018
|
+
return this.params.key;
|
|
609
2019
|
}
|
|
610
|
-
if (
|
|
611
|
-
|
|
2020
|
+
if (propertyName === "authToken") {
|
|
2021
|
+
return this.params.token;
|
|
612
2022
|
}
|
|
613
|
-
|
|
614
|
-
|
|
2023
|
+
return this.params[propertyName];
|
|
2024
|
+
}
|
|
2025
|
+
setAttributeOnElement(el, propertyName) {
|
|
2026
|
+
const attributeName = this.attributesMap[propertyName];
|
|
2027
|
+
if (!attributeName) {
|
|
2028
|
+
return;
|
|
615
2029
|
}
|
|
616
|
-
|
|
617
|
-
|
|
2030
|
+
const value = this.getAttributeValue(propertyName);
|
|
2031
|
+
if (value === null || value === void 0) {
|
|
2032
|
+
el.removeAttribute(attributeName);
|
|
2033
|
+
return;
|
|
618
2034
|
}
|
|
2035
|
+
const normalizedValue = ["appServer", "apiHost"].includes(propertyName) && typeof value === "string" ? removeTrailingSlash(value) : value;
|
|
2036
|
+
const attributeValue = typeof normalizedValue === "object" ? JSON.stringify(normalizedValue) : String(normalizedValue);
|
|
2037
|
+
el.setAttribute(attributeName, attributeValue);
|
|
619
2038
|
}
|
|
620
2039
|
// Reload dashboard when triggerproperty changes
|
|
621
2040
|
updated(changedProperties) {
|
|
@@ -636,19 +2055,36 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
636
2055
|
"timezoneId",
|
|
637
2056
|
"itemDimensions"
|
|
638
2057
|
]);
|
|
2058
|
+
const webComponentRenderProperties = /* @__PURE__ */ new Set([
|
|
2059
|
+
"dashboardId",
|
|
2060
|
+
"dashboardSlug",
|
|
2061
|
+
"itemId",
|
|
2062
|
+
"language",
|
|
2063
|
+
"editorLanguage",
|
|
2064
|
+
"theme",
|
|
2065
|
+
"screenMode",
|
|
2066
|
+
"timezoneId",
|
|
2067
|
+
"itemDimensions"
|
|
2068
|
+
]);
|
|
639
2069
|
const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
|
|
640
2070
|
let callInitComponent = false;
|
|
641
2071
|
for (const condition of conditionsToCheck) {
|
|
642
|
-
callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition] !== void 0;
|
|
2072
|
+
callInitComponent = callInitComponent || changedProperties.has(condition) && changedProperties.get(condition) === void 0 && this[condition] !== void 0;
|
|
643
2073
|
}
|
|
644
|
-
|
|
2074
|
+
const isDashboardReferenceMissing = !this.dashboardReference || !this.dashboardReference.isConnected;
|
|
2075
|
+
if (callInitComponent && (!this.isInitCalled || isDashboardReferenceMissing)) {
|
|
2076
|
+
if (isDashboardReferenceMissing) {
|
|
2077
|
+
this.dashboardReference = void 0;
|
|
2078
|
+
}
|
|
645
2079
|
this.initComponent();
|
|
646
2080
|
this.isInitCalled = true;
|
|
647
2081
|
return;
|
|
648
2082
|
}
|
|
649
2083
|
if (this.isWebComponentViewMode()) {
|
|
650
|
-
if (changedProperties.has("editMode") && !this.dashboardReference) {
|
|
2084
|
+
if (changedProperties.has("editMode") && (!this.dashboardReference || !this.dashboardReference.isConnected)) {
|
|
651
2085
|
this.iframeLoaded = false;
|
|
2086
|
+
this.dashboardReference = void 0;
|
|
2087
|
+
this._webComponentLibraryLoadId++;
|
|
652
2088
|
if (this._loadTimeoutHandle) {
|
|
653
2089
|
clearTimeout(this._loadTimeoutHandle);
|
|
654
2090
|
this._loadTimeoutHandle = void 0;
|
|
@@ -657,24 +2093,37 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
657
2093
|
this.initComponent();
|
|
658
2094
|
return;
|
|
659
2095
|
}
|
|
2096
|
+
if ([...changedProperties.keys()].some((propertyName) => triggerProperties.has(propertyName))) {
|
|
2097
|
+
this.params = this._setOptions();
|
|
2098
|
+
}
|
|
2099
|
+
if (changedProperties.has("screenMode") || changedProperties.has("switchScreenModeOnResize")) {
|
|
2100
|
+
this._onResize();
|
|
2101
|
+
}
|
|
2102
|
+
if (changedProperties.has("appServer") || changedProperties.has("apiHost") || changedProperties.has("authKey") || changedProperties.has("authToken")) {
|
|
2103
|
+
this.dashboardReference?.remove();
|
|
2104
|
+
this.dashboardReference = void 0;
|
|
2105
|
+
this.initComponent();
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
660
2108
|
if (this.dashboardReference) {
|
|
2109
|
+
if ([...changedProperties.keys()].some((propertyName) => webComponentRenderProperties.has(propertyName))) {
|
|
2110
|
+
this.iframeLoaded = false;
|
|
2111
|
+
this._loaderStyles();
|
|
2112
|
+
}
|
|
661
2113
|
for (const [propertyName] of changedProperties.entries()) {
|
|
662
|
-
if (propertyName
|
|
663
|
-
|
|
664
|
-
this.isLibraryLoaded = true;
|
|
665
|
-
await this.updateComplete;
|
|
666
|
-
this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
|
|
667
|
-
this.setAllAttributes();
|
|
668
|
-
});
|
|
669
|
-
} else if (this.attributesMap[propertyName]) {
|
|
670
|
-
const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
|
|
671
|
-
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
|
|
672
|
-
this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
|
|
2114
|
+
if (this.attributesMap[propertyName] && propertyName !== "editMode") {
|
|
2115
|
+
this.setAttributeOnElement(this.dashboardReference, propertyName);
|
|
673
2116
|
}
|
|
674
2117
|
}
|
|
675
2118
|
}
|
|
676
2119
|
} else {
|
|
677
|
-
for (const [propertyName] of changedProperties.entries()) {
|
|
2120
|
+
for (const [propertyName, previousValue] of changedProperties.entries()) {
|
|
2121
|
+
if (propertyName === "editMode" && this.embedMode === "webComponent" && (previousValue === "view" || previousValue === void 0)) {
|
|
2122
|
+
this.dashboardReference = void 0;
|
|
2123
|
+
this._webComponentLibraryLoadId++;
|
|
2124
|
+
this._reloadIframeContent();
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
678
2127
|
if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
|
|
679
2128
|
this._reloadIframeContent();
|
|
680
2129
|
} else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
|
|
@@ -690,7 +2139,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
690
2139
|
}
|
|
691
2140
|
_reloadIframeContent() {
|
|
692
2141
|
this.params = this._setOptions();
|
|
693
|
-
|
|
2142
|
+
_extendAndValidate(this);
|
|
694
2143
|
this._setupLoader();
|
|
695
2144
|
if (this.params.error) {
|
|
696
2145
|
if (this._loadTimeoutHandle) {
|
|
@@ -710,11 +2159,11 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
710
2159
|
);
|
|
711
2160
|
}, 15 * 1e3);
|
|
712
2161
|
this._loaderStyles();
|
|
713
|
-
this._iframeUrl =
|
|
2162
|
+
this._iframeUrl = createIframeUrl(this);
|
|
714
2163
|
if (this.iframe) {
|
|
715
2164
|
this._updateIframeUrl();
|
|
716
2165
|
}
|
|
717
|
-
this.iframeStyle =
|
|
2166
|
+
this.iframeStyle = calculateIframeStyles(this);
|
|
718
2167
|
}
|
|
719
2168
|
// Set params
|
|
720
2169
|
_setOptions() {
|
|
@@ -772,16 +2221,16 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
772
2221
|
defaultParameters.itemDimensions = this.itemDimensions;
|
|
773
2222
|
}
|
|
774
2223
|
if (this.appServer) {
|
|
775
|
-
this.appServer = this.isWebComponentViewMode() ?
|
|
2224
|
+
this.appServer = this.isWebComponentViewMode() ? removeTrailingSlash(this.appServer) : addTrailingSlash(this.appServer);
|
|
776
2225
|
defaultParameters.appServer = this.appServer;
|
|
777
2226
|
} else {
|
|
778
|
-
this.appServer =
|
|
779
|
-
|
|
2227
|
+
this.appServer = addTrailingSlash(
|
|
2228
|
+
DEFAULT_PARAMETERS.appServer
|
|
780
2229
|
);
|
|
781
2230
|
defaultParameters.appServer = this.appServer;
|
|
782
2231
|
}
|
|
783
2232
|
if (this.apiHost) {
|
|
784
|
-
this.apiHost = this.isWebComponentViewMode() ?
|
|
2233
|
+
this.apiHost = this.isWebComponentViewMode() ? removeTrailingSlash(this.apiHost) : addTrailingSlash(this.apiHost);
|
|
785
2234
|
defaultParameters.apiHost = this.apiHost;
|
|
786
2235
|
} else {
|
|
787
2236
|
this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
|
|
@@ -792,11 +2241,11 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
792
2241
|
return defaultParameters;
|
|
793
2242
|
}
|
|
794
2243
|
_updateIframeUrl() {
|
|
795
|
-
|
|
2244
|
+
updateIframeUrl(this.iframe, this._iframeUrl);
|
|
796
2245
|
}
|
|
797
2246
|
// Setup loader / browser error
|
|
798
2247
|
_setupLoader() {
|
|
799
|
-
const data =
|
|
2248
|
+
const data = getLoader(this);
|
|
800
2249
|
this._loaderMsg = data.loadingMsg;
|
|
801
2250
|
if (data.errorMsg) {
|
|
802
2251
|
this._handleEmbedError({ errorMsg: data.errorMsg }, "browser");
|
|
@@ -814,6 +2263,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
814
2263
|
this.browserErrorMsg = errorMsg;
|
|
815
2264
|
} else {
|
|
816
2265
|
this.dashboardError = true;
|
|
2266
|
+
this.dashboardErrorMsg = errorMsg;
|
|
817
2267
|
this.iframeLoaded = true;
|
|
818
2268
|
}
|
|
819
2269
|
if (this._loadTimeoutHandle) {
|
|
@@ -836,15 +2286,15 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
836
2286
|
_calculateDimAfterDashboardLoaded() {
|
|
837
2287
|
this.dashboardError = false;
|
|
838
2288
|
this._loaderStyles();
|
|
839
|
-
|
|
2289
|
+
_setCalculatedDimensions(this);
|
|
840
2290
|
}
|
|
841
2291
|
// Set loader styles
|
|
842
2292
|
_loaderStyles() {
|
|
843
|
-
this._containerStyle =
|
|
844
|
-
this._loaderStyle =
|
|
845
|
-
this._loadingCircleStyle =
|
|
846
|
-
this._containerLoaderStyle =
|
|
847
|
-
this._lcStyle =
|
|
2293
|
+
this._containerStyle = containerStyles(this);
|
|
2294
|
+
this._loaderStyle = loaderStyles(this);
|
|
2295
|
+
this._loadingCircleStyle = plStyles(this);
|
|
2296
|
+
this._containerLoaderStyle = containerLoaderStyles(this);
|
|
2297
|
+
this._lcStyle = lcStyles(this);
|
|
848
2298
|
}
|
|
849
2299
|
static get styles() {
|
|
850
2300
|
return [dashboardStyles];
|
|
@@ -887,15 +2337,19 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
887
2337
|
</div>
|
|
888
2338
|
`;
|
|
889
2339
|
if (this.isWebComponentViewMode()) {
|
|
890
|
-
toBeRenderedHTML = this.
|
|
891
|
-
|
|
892
|
-
<
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
2340
|
+
toBeRenderedHTML = this.dashboardError ? html`
|
|
2341
|
+
<div id="luzmo-error-${this._containerId}">
|
|
2342
|
+
<h3 class="luzmo-error">${this.dashboardErrorMsg}</h3>
|
|
2343
|
+
</div>
|
|
2344
|
+
` : this.isLibraryLoaded ? html`
|
|
2345
|
+
${this.dashboardId || this.dashboardSlug ? html`
|
|
2346
|
+
<div id="dashboard-wc-container"></div>
|
|
2347
|
+
` : html`
|
|
2348
|
+
<div id="luzmo-error-${this._containerId}">
|
|
2349
|
+
<h3 class="luzmo-error">${this.browserErrorMsg}</h3>
|
|
2350
|
+
</div>
|
|
2351
|
+
`}
|
|
2352
|
+
` : html`${loader}`;
|
|
899
2353
|
} else {
|
|
900
2354
|
toBeRenderedHTML = html`
|
|
901
2355
|
${this.dashboardId || this.dashboardSlug ? html`
|
|
@@ -917,7 +2371,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
917
2371
|
`;
|
|
918
2372
|
}
|
|
919
2373
|
return html`
|
|
920
|
-
<div class="${
|
|
2374
|
+
<div class="${luzmoEmbedContainerClass} ${this.isWebComponentViewMode() ? "" : `${luzmoEmbedContainerClass}-ede`}">
|
|
921
2375
|
<div
|
|
922
2376
|
class="dashboard-container"
|
|
923
2377
|
style=${styleMap(Object.assign({}, this._containerStyle, {
|
|
@@ -939,10 +2393,10 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
939
2393
|
// Public methods
|
|
940
2394
|
getData(itemId) {
|
|
941
2395
|
if (this.isWebComponentViewMode() && this.dashboardReference) {
|
|
942
|
-
return this.dashboardReference.getData(itemId);
|
|
2396
|
+
return Promise.resolve().then(() => this.dashboardReference.getData(itemId));
|
|
943
2397
|
}
|
|
944
2398
|
if (!this.isWebComponentViewMode()) {
|
|
945
|
-
return
|
|
2399
|
+
return getData(this, this.iframe, itemId);
|
|
946
2400
|
}
|
|
947
2401
|
return Promise.reject();
|
|
948
2402
|
}
|
|
@@ -951,7 +2405,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
951
2405
|
return this.dashboardReference.getFilters();
|
|
952
2406
|
}
|
|
953
2407
|
if (!this.isWebComponentViewMode()) {
|
|
954
|
-
return
|
|
2408
|
+
return getFilters(this, this.iframe);
|
|
955
2409
|
}
|
|
956
2410
|
return Promise.reject();
|
|
957
2411
|
}
|
|
@@ -960,7 +2414,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
960
2414
|
return this.dashboardReference.getInsights(options);
|
|
961
2415
|
}
|
|
962
2416
|
if (!this.isWebComponentViewMode()) {
|
|
963
|
-
return
|
|
2417
|
+
return getInsights(this, this.iframe, options);
|
|
964
2418
|
}
|
|
965
2419
|
return Promise.reject(new Error("getInsights is not available: dashboard reference is not ready."));
|
|
966
2420
|
}
|
|
@@ -969,7 +2423,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
969
2423
|
return this.dashboardReference.getDashboardContext();
|
|
970
2424
|
}
|
|
971
2425
|
if (!this.isWebComponentViewMode()) {
|
|
972
|
-
return
|
|
2426
|
+
return getDashboardContext(this, this.iframe);
|
|
973
2427
|
}
|
|
974
2428
|
return Promise.reject(new Error("getDashboardContext is not available: dashboard reference is not ready."));
|
|
975
2429
|
}
|
|
@@ -978,7 +2432,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
978
2432
|
return this.dashboardReference.setSelectedData(itemId, filters);
|
|
979
2433
|
}
|
|
980
2434
|
if (!this.isWebComponentViewMode()) {
|
|
981
|
-
return
|
|
2435
|
+
return setSelectedData(this, this.iframe, itemId, filters);
|
|
982
2436
|
}
|
|
983
2437
|
return Promise.reject();
|
|
984
2438
|
}
|
|
@@ -989,7 +2443,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
989
2443
|
return this.dashboardReference.setAuthorization(key, token);
|
|
990
2444
|
}
|
|
991
2445
|
if (!this.isWebComponentViewMode()) {
|
|
992
|
-
return
|
|
2446
|
+
return setAuthorization(this, this.iframe, key, token);
|
|
993
2447
|
}
|
|
994
2448
|
return Promise.reject();
|
|
995
2449
|
}
|
|
@@ -998,7 +2452,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
998
2452
|
return this.dashboardReference.refreshData(itemId);
|
|
999
2453
|
}
|
|
1000
2454
|
if (!this.isWebComponentViewMode()) {
|
|
1001
|
-
return itemId ?
|
|
2455
|
+
return itemId ? refreshData(this, this.iframe, itemId) : refreshData(this, this.iframe);
|
|
1002
2456
|
}
|
|
1003
2457
|
return Promise.reject();
|
|
1004
2458
|
}
|
|
@@ -1007,7 +2461,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1007
2461
|
return this.dashboardReference.reloadDashboard();
|
|
1008
2462
|
}
|
|
1009
2463
|
if (!this.isWebComponentViewMode()) {
|
|
1010
|
-
return
|
|
2464
|
+
return reloadDashboard(this, this.iframe);
|
|
1011
2465
|
}
|
|
1012
2466
|
return Promise.reject();
|
|
1013
2467
|
}
|
|
@@ -1016,12 +2470,12 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1016
2470
|
return this.dashboardReference.exportDashboard(format);
|
|
1017
2471
|
}
|
|
1018
2472
|
if (!this.isWebComponentViewMode()) {
|
|
1019
|
-
return format ?
|
|
2473
|
+
return format ? exportDashboard(this, this.iframe, format) : exportDashboard(this, this.iframe);
|
|
1020
2474
|
}
|
|
1021
2475
|
return Promise.reject();
|
|
1022
2476
|
}
|
|
1023
2477
|
getAccessibleDashboards() {
|
|
1024
|
-
return
|
|
2478
|
+
return getAccessibleDashboards(this);
|
|
1025
2479
|
}
|
|
1026
2480
|
addFilters(itemId, filters) {
|
|
1027
2481
|
return this.dashboardReference.addFilters(itemId, filters);
|
|
@@ -1049,7 +2503,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1049
2503
|
return this.dashboardReference.setEditMode(editMode);
|
|
1050
2504
|
}
|
|
1051
2505
|
if (!this.isWebComponentViewMode()) {
|
|
1052
|
-
return
|
|
2506
|
+
return setEditMode(this, this.iframe, editMode);
|
|
1053
2507
|
}
|
|
1054
2508
|
return Promise.reject();
|
|
1055
2509
|
}
|
|
@@ -1057,13 +2511,13 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1057
2511
|
if (this.isWebComponentViewMode() && this.dashboardReference) {
|
|
1058
2512
|
return this.dashboardReference.setPreview(preview);
|
|
1059
2513
|
}
|
|
1060
|
-
return
|
|
2514
|
+
return setPreview(this, this.iframe, preview);
|
|
1061
2515
|
}
|
|
1062
2516
|
sendExportEmail(type, subject, message) {
|
|
1063
2517
|
if (this.isWebComponentViewMode() && this.dashboardReference) {
|
|
1064
2518
|
return this.dashboardReference.sendExportEmail(type, subject, message);
|
|
1065
2519
|
} else if (!this.isWebComponentViewMode()) {
|
|
1066
|
-
return
|
|
2520
|
+
return sendExportEmail(this, this.iframe, type, subject, message);
|
|
1067
2521
|
}
|
|
1068
2522
|
return Promise.reject();
|
|
1069
2523
|
}
|
|
@@ -1075,7 +2529,7 @@ __decorateClass([
|
|
|
1075
2529
|
query(".dashboard-container")
|
|
1076
2530
|
], LuzmoDashboard.prototype, "container", 2);
|
|
1077
2531
|
__decorateClass([
|
|
1078
|
-
query(`.${
|
|
2532
|
+
query(`.${luzmoEmbedContainerClass}`)
|
|
1079
2533
|
], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
|
|
1080
2534
|
__decorateClass([
|
|
1081
2535
|
query("iframe")
|
|
@@ -1208,6 +2662,9 @@ __decorateClass([
|
|
|
1208
2662
|
__decorateClass([
|
|
1209
2663
|
property({ attribute: false })
|
|
1210
2664
|
], LuzmoDashboard.prototype, "dashboardError", 2);
|
|
2665
|
+
__decorateClass([
|
|
2666
|
+
property({ attribute: false })
|
|
2667
|
+
], LuzmoDashboard.prototype, "dashboardErrorMsg", 2);
|
|
1211
2668
|
__decorateClass([
|
|
1212
2669
|
property({ attribute: false })
|
|
1213
2670
|
], LuzmoDashboard.prototype, "browserNotSupported", 2);
|
|
@@ -1241,7 +2698,6 @@ if (!customElements.get("luzmo-embed-dashboard")) {
|
|
|
1241
2698
|
import {
|
|
1242
2699
|
CONTENTS_VERSION
|
|
1243
2700
|
} from "@luzmo/dashboard-contents-types";
|
|
1244
|
-
import * as SharedLib3 from "@luzmo/shared-embed";
|
|
1245
2701
|
import { css as css2, html as html2, LitElement as LitElement2 } from "lit";
|
|
1246
2702
|
import { property as property2 } from "lit/decorators.js";
|
|
1247
2703
|
var dashboardContentsVersion = CONTENTS_VERSION;
|
|
@@ -1335,7 +2791,7 @@ var LuzmoBaseVizItem = class extends LitElement2 {
|
|
|
1335
2791
|
async firstUpdated(_changedProperties) {
|
|
1336
2792
|
super.firstUpdated(_changedProperties);
|
|
1337
2793
|
if (this.canInitializeVizItem()) {
|
|
1338
|
-
await
|
|
2794
|
+
await loadLibrary(this.appServer, vizItemRemote);
|
|
1339
2795
|
this.createAndAppendElement();
|
|
1340
2796
|
}
|
|
1341
2797
|
}
|
|
@@ -1379,12 +2835,12 @@ var LuzmoBaseVizItem = class extends LitElement2 {
|
|
|
1379
2835
|
}
|
|
1380
2836
|
updateVizItemProperties() {
|
|
1381
2837
|
if (this.chartElement) {
|
|
1382
|
-
for (const key in
|
|
2838
|
+
for (const key in libraryTypeToWebComponentTypeMapping) {
|
|
1383
2839
|
const value = this[key];
|
|
1384
2840
|
if (value) {
|
|
1385
|
-
const attributeValue = ["appServer", "apiHost"].includes(key) ?
|
|
2841
|
+
const attributeValue = ["appServer", "apiHost"].includes(key) ? removeTrailingSlash(value) : value;
|
|
1386
2842
|
this.chartElement.setAttribute(
|
|
1387
|
-
|
|
2843
|
+
libraryTypeToWebComponentTypeMapping[key],
|
|
1388
2844
|
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
1389
2845
|
);
|
|
1390
2846
|
}
|
|
@@ -1394,13 +2850,13 @@ var LuzmoBaseVizItem = class extends LitElement2 {
|
|
|
1394
2850
|
async updated(changedProperties) {
|
|
1395
2851
|
if (this.chartElement) {
|
|
1396
2852
|
for (const [propertyName] of changedProperties.entries()) {
|
|
1397
|
-
const mappedAttributeName =
|
|
2853
|
+
const mappedAttributeName = libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
|
|
1398
2854
|
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
|
|
1399
2855
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1400
2856
|
}
|
|
1401
2857
|
} else {
|
|
1402
2858
|
if (this.canInitializeVizItem()) {
|
|
1403
|
-
await
|
|
2859
|
+
await loadLibrary(this.appServer, vizItemRemote);
|
|
1404
2860
|
this.createAndAppendElement();
|
|
1405
2861
|
}
|
|
1406
2862
|
}
|
|
@@ -1491,7 +2947,6 @@ if (!customElements.get("luzmo-embed-viz-item")) {
|
|
|
1491
2947
|
}
|
|
1492
2948
|
|
|
1493
2949
|
// libs/embed-libs/embed/src/lib/iq-components/luzmo-iq-chat.ts
|
|
1494
|
-
import { loadLibrary as loadLibrary3, removeTrailingSlash as removeTrailingSlash3 } from "@luzmo/shared-embed";
|
|
1495
2950
|
import { css as css3, html as html3, LitElement as LitElement3 } from "lit";
|
|
1496
2951
|
import { property as property3 } from "lit/decorators.js";
|
|
1497
2952
|
var inputMap = {
|
|
@@ -1528,7 +2983,7 @@ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
|
|
|
1528
2983
|
}
|
|
1529
2984
|
async firstUpdated(_changedProperties) {
|
|
1530
2985
|
super.firstUpdated(_changedProperties);
|
|
1531
|
-
await
|
|
2986
|
+
await loadLibrary(this.calculatedAppServer, "IQApp");
|
|
1532
2987
|
this.createAndAppendElement();
|
|
1533
2988
|
}
|
|
1534
2989
|
get calculatedAppServer() {
|
|
@@ -1551,7 +3006,7 @@ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
|
|
|
1551
3006
|
for (const key in inputMap) {
|
|
1552
3007
|
const value = this[key];
|
|
1553
3008
|
if (value) {
|
|
1554
|
-
const attributeValue = ["appServer", "apiHost", "aydHost"].includes(key) ?
|
|
3009
|
+
const attributeValue = ["appServer", "apiHost", "aydHost"].includes(key) ? removeTrailingSlash(value) : value;
|
|
1555
3010
|
this.chartElement.setAttribute(
|
|
1556
3011
|
inputMap[key],
|
|
1557
3012
|
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
@@ -1573,7 +3028,7 @@ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
|
|
|
1573
3028
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1574
3029
|
}
|
|
1575
3030
|
} else {
|
|
1576
|
-
await
|
|
3031
|
+
await loadLibrary(this.calculatedAppServer, "IQApp");
|
|
1577
3032
|
this.createAndAppendElement();
|
|
1578
3033
|
}
|
|
1579
3034
|
}
|
|
@@ -1663,7 +3118,6 @@ if (!customElements.get(embedChatTag)) {
|
|
|
1663
3118
|
// libs/embed-libs/embed/src/lib/iq-components/luzmo-iq-answer.ts
|
|
1664
3119
|
import { css as css4, html as html4, LitElement as LitElement4 } from "lit";
|
|
1665
3120
|
import { property as property4 } from "lit/decorators.js";
|
|
1666
|
-
import { loadLibrary as loadLibrary4, removeTrailingSlash as removeTrailingSlash4 } from "@luzmo/shared-embed";
|
|
1667
3121
|
var inputMap2 = {
|
|
1668
3122
|
aiEndPoint: "ai-end-point",
|
|
1669
3123
|
appServer: "app-server",
|
|
@@ -1690,7 +3144,7 @@ var LuzmoIQEmbedAnswerComponent = class extends LitElement4 {
|
|
|
1690
3144
|
}
|
|
1691
3145
|
async firstUpdated(_changedProperties) {
|
|
1692
3146
|
super.firstUpdated(_changedProperties);
|
|
1693
|
-
await
|
|
3147
|
+
await loadLibrary(this.calculatedAppServer, "IQApp");
|
|
1694
3148
|
this.createAndAppendElement();
|
|
1695
3149
|
}
|
|
1696
3150
|
get calculatedAppServer() {
|
|
@@ -1710,7 +3164,7 @@ var LuzmoIQEmbedAnswerComponent = class extends LitElement4 {
|
|
|
1710
3164
|
for (const key in inputMap2) {
|
|
1711
3165
|
const value = this[key];
|
|
1712
3166
|
if (value) {
|
|
1713
|
-
const attributeValue = ["appServer", "apiHost"].includes(key) ?
|
|
3167
|
+
const attributeValue = ["appServer", "apiHost"].includes(key) ? removeTrailingSlash(value) : value;
|
|
1714
3168
|
this.chartElement.setAttribute(
|
|
1715
3169
|
inputMap2[key],
|
|
1716
3170
|
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
@@ -1727,7 +3181,7 @@ var LuzmoIQEmbedAnswerComponent = class extends LitElement4 {
|
|
|
1727
3181
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1728
3182
|
}
|
|
1729
3183
|
} else {
|
|
1730
|
-
await
|
|
3184
|
+
await loadLibrary(this.calculatedAppServer, "IQApp");
|
|
1731
3185
|
this.createAndAppendElement();
|
|
1732
3186
|
}
|
|
1733
3187
|
}
|
|
@@ -1777,7 +3231,7 @@ if (!customElements.get(componentTag)) {
|
|
|
1777
3231
|
customElements.define(componentTag, LuzmoIQEmbedAnswerComponent);
|
|
1778
3232
|
}
|
|
1779
3233
|
|
|
1780
|
-
// libs/embed-libs/embed/src/lib/
|
|
3234
|
+
// libs/embed-libs/embed/src/lib/utils/json-schema-utils.ts
|
|
1781
3235
|
var cachedSchemas = {};
|
|
1782
3236
|
function addJSONSchemas(schemas) {
|
|
1783
3237
|
if (schemas.some((schema) => !schema.$id)) {
|