@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.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
30
20
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
@@ -48,25 +38,1385 @@ __export(index_exports, {
|
|
|
48
38
|
getCachedJSONSchemas: () => getCachedJSONSchemas,
|
|
49
39
|
getJSONSchemaUrl: () => getJSONSchemaUrl,
|
|
50
40
|
luzmoRefParserOptions: () => luzmoRefParserOptions,
|
|
51
|
-
preloadDashboard: () =>
|
|
52
|
-
preloadIQ: () =>
|
|
53
|
-
preloadVizItem: () =>
|
|
54
|
-
selectedDataUtils: () =>
|
|
41
|
+
preloadDashboard: () => preloadDashboard,
|
|
42
|
+
preloadIQ: () => preloadIQ,
|
|
43
|
+
preloadVizItem: () => preloadVizItem,
|
|
44
|
+
selectedDataUtils: () => selectedDataUtils
|
|
55
45
|
});
|
|
56
46
|
module.exports = __toCommonJS(index_exports);
|
|
57
|
-
|
|
47
|
+
|
|
48
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/error.ts
|
|
49
|
+
var _handleError = (errorMessage, parameters) => {
|
|
50
|
+
let message = "The dashboard component encountered an error";
|
|
51
|
+
if (typeof parameters?.dashboardId === "string") {
|
|
52
|
+
message += ` for dashboard with id ${parameters.dashboardId}`;
|
|
53
|
+
}
|
|
54
|
+
if (typeof parameters?.dashboardSlug === "string") {
|
|
55
|
+
message += ` for dashboard with slug ${parameters.dashboardSlug}`;
|
|
56
|
+
}
|
|
57
|
+
if (typeof parameters?.container === "string") {
|
|
58
|
+
message += ` in container ${parameters.container}`;
|
|
59
|
+
}
|
|
60
|
+
if (errorMessage) {
|
|
61
|
+
message += `:
|
|
62
|
+
${errorMessage}`;
|
|
63
|
+
console.warn(message);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/browser-check.ts
|
|
68
|
+
var _browserCheck = (dashboardComponent) => {
|
|
69
|
+
let hasError = false;
|
|
70
|
+
let errorMessage = "";
|
|
71
|
+
const document_ = document.body || document.documentElement;
|
|
72
|
+
const style = document_.style;
|
|
73
|
+
const browserCheck = {
|
|
74
|
+
svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
|
|
75
|
+
flexbox: style.webkitFlexWrap === "" || style.flexWrap === "",
|
|
76
|
+
postMessage: !!window.postMessage
|
|
77
|
+
};
|
|
78
|
+
const browserCheckKeys = ["svg", "flexbox", "postMessage"];
|
|
79
|
+
for (const key of browserCheckKeys) {
|
|
80
|
+
if (!browserCheck[key]) {
|
|
81
|
+
hasError = true;
|
|
82
|
+
dashboardComponent.browserNotSupported = dashboardComponent.browserNotSupported || [];
|
|
83
|
+
dashboardComponent.browserNotSupported.push(key);
|
|
84
|
+
errorMessage += `Your browser does not support: ${key}
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const ua = window.navigator.userAgent;
|
|
89
|
+
const msie = ua.includes("MSIE");
|
|
90
|
+
const trident = ua.includes("Trident/");
|
|
91
|
+
if (msie || trident) {
|
|
92
|
+
hasError = true;
|
|
93
|
+
errorMessage = "IE is not supported.";
|
|
94
|
+
}
|
|
95
|
+
if (hasError) {
|
|
96
|
+
_handleError(errorMessage);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/default-parameters.ts
|
|
101
|
+
var DEFAULT_PARAMETERS = {
|
|
102
|
+
appServer: "https://app.luzmo.com/",
|
|
103
|
+
apiHost: "https://api.luzmo.com/",
|
|
104
|
+
dashboardId: null,
|
|
105
|
+
dashboardSlug: null,
|
|
106
|
+
container: null,
|
|
107
|
+
key: null,
|
|
108
|
+
token: null,
|
|
109
|
+
language: "auto",
|
|
110
|
+
editorLanguage: "auto",
|
|
111
|
+
editMode: null,
|
|
112
|
+
screenMode: null,
|
|
113
|
+
switchScreenModeOnResize: true,
|
|
114
|
+
itemId: null,
|
|
115
|
+
theme: "",
|
|
116
|
+
mainColor: "",
|
|
117
|
+
itemDimensions: {
|
|
118
|
+
width: "auto",
|
|
119
|
+
height: "auto"
|
|
120
|
+
},
|
|
121
|
+
loaderBackground: "#f9f9f9",
|
|
122
|
+
loaderFontColor: "#5a5a5a",
|
|
123
|
+
loaderSpinnerColor: "rgb(68, 52, 255)",
|
|
124
|
+
loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
|
|
125
|
+
timezoneId: null,
|
|
126
|
+
contextId: null
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/extents.ts
|
|
130
|
+
var EXTENTS = [
|
|
131
|
+
{ mode: "mobile", width: [150, 767] },
|
|
132
|
+
{ mode: "tablet", width: [768, 1199] },
|
|
133
|
+
{ mode: "desktop", width: [1200, 1599] },
|
|
134
|
+
{ mode: "largeScreen", width: [1600, 9999] },
|
|
135
|
+
{ mode: "fixed", width: [] }
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/translations.ts
|
|
139
|
+
var TRANSLATIONS = {
|
|
140
|
+
initializing: {
|
|
141
|
+
en: "Initializing...",
|
|
142
|
+
nl: "Laden...",
|
|
143
|
+
fr: "Chargement...",
|
|
144
|
+
de: "Initialisiere...",
|
|
145
|
+
es: "Inicializando..."
|
|
146
|
+
},
|
|
147
|
+
errorDashboard: {
|
|
148
|
+
en: "Oops, we could not load this dashboard!",
|
|
149
|
+
nl: "Oeps, we konden het dashboard niet laden.",
|
|
150
|
+
fr: "Le chargement a echou\xE9.",
|
|
151
|
+
de: "Hoppla, wir konnten dieses Dashboard nicht laden!",
|
|
152
|
+
es: "\xA1Ups! No pudimos cargar este tablero."
|
|
153
|
+
},
|
|
154
|
+
errorItem: {
|
|
155
|
+
en: "Oops, we could not load this item!",
|
|
156
|
+
nl: "Oeps, we konden de grafiek niet laden.",
|
|
157
|
+
fr: "Le chargement a echou\xE9.",
|
|
158
|
+
de: "Hoppla, wir konnten dieses Diagramm nicht laden!",
|
|
159
|
+
es: "\xA1Ups! No pudimos cargar este elemento."
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
var translations_default = TRANSLATIONS;
|
|
163
|
+
|
|
164
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/utils.ts
|
|
165
|
+
var addTrailingSlash = (serverUrl) => {
|
|
166
|
+
if (!serverUrl) {
|
|
167
|
+
return "";
|
|
168
|
+
}
|
|
169
|
+
return serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
|
|
170
|
+
};
|
|
171
|
+
var removeTrailingSlash = (serverUrl) => {
|
|
172
|
+
if (!serverUrl) {
|
|
173
|
+
return "";
|
|
174
|
+
}
|
|
175
|
+
return serverUrl.endsWith("/") ? serverUrl.slice(0, -1) : serverUrl;
|
|
176
|
+
};
|
|
177
|
+
var formatDashboardList = (dashboards, integrationId, user, dashboardComponent) => {
|
|
178
|
+
const combineRights = (securable, accessUser) => {
|
|
179
|
+
const matchingUser = securable.users.find((u) => u.id === accessUser.id);
|
|
180
|
+
const securableAccessRights = matchingUser && matchingUser.userAccessRight ? {
|
|
181
|
+
flagRead: matchingUser.userAccessRight.flagRead,
|
|
182
|
+
flagUse: matchingUser.userAccessRight.flagUse,
|
|
183
|
+
flagModify: matchingUser.userAccessRight.flagModify,
|
|
184
|
+
flagOwn: matchingUser.userAccessRight.flagOwn
|
|
185
|
+
} : {
|
|
186
|
+
flagRead: false,
|
|
187
|
+
flagUse: false,
|
|
188
|
+
flagModify: false,
|
|
189
|
+
flagOwn: false
|
|
190
|
+
};
|
|
191
|
+
const groups = securable.groups.filter(
|
|
192
|
+
(group) => accessUser.userGroups.includes(group.id) || group.public === true
|
|
193
|
+
);
|
|
194
|
+
const groupsAccess = groups.map((group) => {
|
|
195
|
+
if (group.groupAccessRight) {
|
|
196
|
+
return group.groupAccessRight;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
for (const groupAccess of groupsAccess) {
|
|
200
|
+
if (!securableAccessRights.flagRead && groupAccess.flagRead) {
|
|
201
|
+
securableAccessRights.flagRead = groupAccess.flagRead;
|
|
202
|
+
}
|
|
203
|
+
if (!securableAccessRights.flagUse && groupAccess.flagUse) {
|
|
204
|
+
securableAccessRights.flagUse = groupAccess.flagUse;
|
|
205
|
+
}
|
|
206
|
+
if (!securableAccessRights.flagModify && groupAccess.flagModify) {
|
|
207
|
+
securableAccessRights.flagModify = groupAccess.flagModify;
|
|
208
|
+
}
|
|
209
|
+
if (!securableAccessRights.flagOwn && groupAccess.flagOwn) {
|
|
210
|
+
securableAccessRights.flagOwn = groupAccess.flagOwn;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const integrationsAccess = securable.integrations?.length > 0 ? securable.integrations.map((integration) => {
|
|
214
|
+
if (integration.integrationAccessRight) {
|
|
215
|
+
return integration.integrationAccessRight;
|
|
216
|
+
}
|
|
217
|
+
}) : [];
|
|
218
|
+
for (const integrationAccess of integrationsAccess) {
|
|
219
|
+
if (!securableAccessRights.flagRead && integrationAccess.flagRead) {
|
|
220
|
+
securableAccessRights.flagRead = integrationAccess.flagRead;
|
|
221
|
+
}
|
|
222
|
+
if (!securableAccessRights.flagUse && integrationAccess.flagUse) {
|
|
223
|
+
securableAccessRights.flagUse = integrationAccess.flagUse;
|
|
224
|
+
}
|
|
225
|
+
if (!securableAccessRights.flagModify && integrationAccess.flagModify) {
|
|
226
|
+
securableAccessRights.flagModify = integrationAccess.flagModify;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return securableAccessRights;
|
|
230
|
+
};
|
|
231
|
+
const localize = (item, locale) => {
|
|
232
|
+
if (item === null || item === void 0) {
|
|
233
|
+
return "";
|
|
234
|
+
}
|
|
235
|
+
if (typeof item !== "object" || Object.keys(item).length === 0) {
|
|
236
|
+
if (typeof item === "object" && Object.keys(item).length === 0) {
|
|
237
|
+
return "";
|
|
238
|
+
}
|
|
239
|
+
return item;
|
|
240
|
+
}
|
|
241
|
+
let localizedItem;
|
|
242
|
+
localizedItem = locale && item[locale] ? item[locale] : item[Object.keys(item)[0]];
|
|
243
|
+
if (localizedItem === void 0 || localizedItem === null) {
|
|
244
|
+
localizedItem = "";
|
|
245
|
+
}
|
|
246
|
+
return localizedItem;
|
|
247
|
+
};
|
|
248
|
+
const treatedDashboards = [];
|
|
249
|
+
for (const dashboard of dashboards) {
|
|
250
|
+
const treatedDashboard = {
|
|
251
|
+
accessibleBy: [],
|
|
252
|
+
accessRights: combineRights(dashboard, user),
|
|
253
|
+
id: dashboard.id,
|
|
254
|
+
modifiedAt: dashboard.modified_at,
|
|
255
|
+
name: localize(dashboard.name, dashboardComponent.language),
|
|
256
|
+
slug: null,
|
|
257
|
+
tags: dashboard.tags.map((t) => t.tag).sort((t1, t2) => t1.localeCompare(t2))
|
|
258
|
+
};
|
|
259
|
+
const currentIntegration = dashboard.integrations.find(
|
|
260
|
+
(i) => i.id === integrationId
|
|
261
|
+
);
|
|
262
|
+
if (currentIntegration?.integrationAccessRight?.slug) {
|
|
263
|
+
treatedDashboard.slug = currentIntegration.integrationAccessRight.slug;
|
|
264
|
+
}
|
|
265
|
+
const users = dashboard.users.map((u) => ({
|
|
266
|
+
model: "User",
|
|
267
|
+
id: u.id,
|
|
268
|
+
name: localize(u.name, user.locale_id)
|
|
269
|
+
}));
|
|
270
|
+
const groups = dashboard.groups.map((g) => ({
|
|
271
|
+
model: "Group",
|
|
272
|
+
id: g.id,
|
|
273
|
+
name: localize(g.name, user.locale_id) || {}
|
|
274
|
+
}));
|
|
275
|
+
const integrations = dashboard.integrations.map((i) => ({
|
|
276
|
+
model: "Integration",
|
|
277
|
+
id: i.id,
|
|
278
|
+
name: localize(i.name, user.locale_id) || {}
|
|
279
|
+
}));
|
|
280
|
+
treatedDashboard.accessibleBy = [...users, ...groups, ...integrations];
|
|
281
|
+
treatedDashboards.push(treatedDashboard);
|
|
282
|
+
}
|
|
283
|
+
return treatedDashboards;
|
|
284
|
+
};
|
|
285
|
+
var VERSION = "0.0.0-unknown-luzmo";
|
|
286
|
+
var sanitizeUrl = (url) => {
|
|
287
|
+
const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
|
|
288
|
+
const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
|
|
289
|
+
const urlSchemeRegex = /^([^:]+):/gm;
|
|
290
|
+
const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
|
|
291
|
+
const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
|
|
292
|
+
if (!url) {
|
|
293
|
+
return "about:blank";
|
|
294
|
+
}
|
|
295
|
+
const sanitizedUrl = url.replaceAll(ctrlCharactersRegex, "").trim();
|
|
296
|
+
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
297
|
+
return sanitizedUrl;
|
|
298
|
+
}
|
|
299
|
+
const urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
|
|
300
|
+
if (!urlSchemeParseResults) {
|
|
301
|
+
return sanitizedUrl;
|
|
302
|
+
}
|
|
303
|
+
const urlScheme = urlSchemeParseResults[0];
|
|
304
|
+
if (invalidPrototcolRegex.test(urlScheme)) {
|
|
305
|
+
return "about:blank";
|
|
306
|
+
}
|
|
307
|
+
return sanitizedUrl;
|
|
308
|
+
};
|
|
309
|
+
var isObject = (o) => o && typeof o === "object";
|
|
310
|
+
var defaultsDeep = (target, defaults) => {
|
|
311
|
+
Object.entries(defaults).forEach(([k, v]) => {
|
|
312
|
+
if (k in target) {
|
|
313
|
+
if (target[k] === void 0) {
|
|
314
|
+
target[k] = v;
|
|
315
|
+
} else {
|
|
316
|
+
target[k] = isObject(v) ? defaultsDeep(
|
|
317
|
+
target[k],
|
|
318
|
+
v
|
|
319
|
+
) : target[k];
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
target[k] = v;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
return target;
|
|
326
|
+
};
|
|
327
|
+
var uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(c) {
|
|
328
|
+
const r = Math.trunc(Math.random() * 16);
|
|
329
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
330
|
+
return v.toString(16);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/iframe-url.ts
|
|
334
|
+
var createIframeUrl = (dashboardContent) => {
|
|
335
|
+
const searchString = [];
|
|
336
|
+
const {
|
|
337
|
+
appServer,
|
|
338
|
+
language,
|
|
339
|
+
editorLanguage,
|
|
340
|
+
loaderBackground,
|
|
341
|
+
loaderSpinnerColor,
|
|
342
|
+
loaderSpinnerBackground,
|
|
343
|
+
loaderFontColor,
|
|
344
|
+
screenMode,
|
|
345
|
+
key,
|
|
346
|
+
token,
|
|
347
|
+
timezoneId,
|
|
348
|
+
itemEmbedding,
|
|
349
|
+
itemDimensions,
|
|
350
|
+
dashboardId,
|
|
351
|
+
dashboardSlug,
|
|
352
|
+
itemId,
|
|
353
|
+
theme,
|
|
354
|
+
mainColor,
|
|
355
|
+
editMode
|
|
356
|
+
} = dashboardContent.params;
|
|
357
|
+
if (language && language !== "auto") {
|
|
358
|
+
searchString.push(`language=${language}`);
|
|
359
|
+
}
|
|
360
|
+
if (editorLanguage && editorLanguage !== "auto") {
|
|
361
|
+
searchString.push(`editorLanguage=${editorLanguage}`);
|
|
362
|
+
}
|
|
363
|
+
if (loaderBackground) {
|
|
364
|
+
searchString.push(`ldrbg=${loaderBackground}`);
|
|
365
|
+
}
|
|
366
|
+
if (loaderFontColor) {
|
|
367
|
+
searchString.push(`ldrftclr=${loaderFontColor}`);
|
|
368
|
+
}
|
|
369
|
+
if (loaderSpinnerColor) {
|
|
370
|
+
searchString.push(`ldrspclr=${loaderSpinnerColor}`);
|
|
371
|
+
}
|
|
372
|
+
if (loaderSpinnerBackground) {
|
|
373
|
+
searchString.push(`ldrspbg=${loaderSpinnerBackground}`);
|
|
374
|
+
}
|
|
375
|
+
if (theme) {
|
|
376
|
+
searchString.push(`theme=${theme}`);
|
|
377
|
+
}
|
|
378
|
+
if (mainColor) {
|
|
379
|
+
searchString.push(`mainColor=${mainColor}`);
|
|
380
|
+
}
|
|
381
|
+
if (screenMode && screenMode !== "auto") {
|
|
382
|
+
searchString.push(`screenMode=${screenMode}`);
|
|
383
|
+
}
|
|
384
|
+
if (timezoneId) {
|
|
385
|
+
searchString.push("timezoneId=" + timezoneId);
|
|
386
|
+
}
|
|
387
|
+
if (itemEmbedding && itemDimensions && itemDimensions.width) {
|
|
388
|
+
searchString.push("width=" + itemDimensions.width);
|
|
389
|
+
}
|
|
390
|
+
if (itemEmbedding && itemDimensions && itemDimensions.height) {
|
|
391
|
+
searchString.push("height=" + itemDimensions.height);
|
|
392
|
+
}
|
|
393
|
+
if (editMode) {
|
|
394
|
+
searchString.push("editMode=" + editMode);
|
|
395
|
+
}
|
|
396
|
+
const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
|
|
397
|
+
searchString.push("version=" + (dashboardContent.libVersion || VERSION));
|
|
398
|
+
const appServerWithSlash = addTrailingSlash(appServer);
|
|
399
|
+
const iframeUrl = itemEmbedding ? `${appServerWithSlash}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
|
|
400
|
+
searchString.join("&")
|
|
401
|
+
)}${keyTokenUrlAnchor}` : `${appServerWithSlash}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
|
|
402
|
+
searchString.join("&")
|
|
403
|
+
)}${keyTokenUrlAnchor}`;
|
|
404
|
+
return sanitizeUrl(iframeUrl);
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
|
|
408
|
+
var getLoader = (dashboardComponent) => {
|
|
409
|
+
let errorMsg;
|
|
410
|
+
if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
|
|
411
|
+
dashboardComponent.params.error = true;
|
|
412
|
+
if (dashboardComponent.browserNotSupported) {
|
|
413
|
+
errorMsg = "Browser is not supported.";
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
|
|
417
|
+
return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
|
|
421
|
+
function resolvePromise(dashboardComponent, requestId, data) {
|
|
422
|
+
if (dashboardComponent.promises[requestId]) {
|
|
423
|
+
dashboardComponent.promises[requestId].resolve(data);
|
|
424
|
+
delete dashboardComponent.promises[requestId];
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function rejectPromise(dashboardComponent, requestId, data) {
|
|
428
|
+
if (dashboardComponent.promises[requestId]) {
|
|
429
|
+
dashboardComponent.promises[requestId].reject(data);
|
|
430
|
+
delete dashboardComponent.promises[requestId];
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
|
|
435
|
+
function containerStyles(dashboardComponent) {
|
|
436
|
+
const styles = {};
|
|
437
|
+
if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
|
|
438
|
+
styles.background = dashboardComponent.params.loaderBackground;
|
|
439
|
+
}
|
|
440
|
+
return styles;
|
|
441
|
+
}
|
|
442
|
+
function containerLoaderStyles(dashboardComponent) {
|
|
443
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
444
|
+
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
445
|
+
const display = dashboardComponent.iframeLoaded ? "none" : "";
|
|
446
|
+
return {
|
|
447
|
+
display,
|
|
448
|
+
height: `${chartHeightDefined ? height : dashboardComponent.minHeight}px`
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function loaderStyles(dashboardComponent) {
|
|
452
|
+
const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
|
|
453
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
454
|
+
dashboardComponent.loaderSize = 24;
|
|
455
|
+
dashboardComponent.borderWidth = 4;
|
|
456
|
+
dashboardComponent.minHeight = 200;
|
|
457
|
+
const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
458
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
459
|
+
const chartWidthDefined = width !== "auto";
|
|
460
|
+
const chartHeightDefined = height !== "auto";
|
|
461
|
+
return {
|
|
462
|
+
background,
|
|
463
|
+
width: chartWidthDefined ? `${width}px` : "100%",
|
|
464
|
+
height: `${chartHeightDefined ? height : "200"}px`,
|
|
465
|
+
"min-height": chartHeightDefined ? "" : "200px"
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
background
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function generateBorderStyle(borderWidth, color) {
|
|
473
|
+
return `${borderWidth}px solid ${color}`;
|
|
474
|
+
}
|
|
475
|
+
function plStyles(dashboardComponent) {
|
|
476
|
+
const {
|
|
477
|
+
loaderSpinnerColor: defaultSpinnerColor,
|
|
478
|
+
loaderSpinnerBackground: defaultSpinnerBackground
|
|
479
|
+
} = DEFAULT_PARAMETERS;
|
|
480
|
+
const spinnerColorBorder = generateBorderStyle(
|
|
481
|
+
dashboardComponent.borderWidth,
|
|
482
|
+
dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
|
|
483
|
+
);
|
|
484
|
+
const spinnerBackgroundBorder = generateBorderStyle(
|
|
485
|
+
dashboardComponent.borderWidth,
|
|
486
|
+
dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
|
|
487
|
+
);
|
|
488
|
+
const size = `${dashboardComponent.loaderSize}px`;
|
|
489
|
+
return {
|
|
490
|
+
"border-top": spinnerColorBorder,
|
|
491
|
+
"border-right": spinnerColorBorder,
|
|
492
|
+
"border-bottom": spinnerBackgroundBorder,
|
|
493
|
+
"border-left": spinnerBackgroundBorder,
|
|
494
|
+
width: size,
|
|
495
|
+
height: size
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function lcStyles(dashboardComponent) {
|
|
499
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
500
|
+
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
501
|
+
const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
|
|
502
|
+
const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
|
|
503
|
+
return {
|
|
504
|
+
padding: `${verticalPadding} 16px`
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function calculateIframeStyles(dashboardComponent) {
|
|
508
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
509
|
+
const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
510
|
+
if (dashboardComponent.params.itemEmbedding && height !== "auto") {
|
|
511
|
+
dashboardComponent.iframeHeight = `${height}px`;
|
|
512
|
+
} else if (dashboardComponent.params.itemEmbedding) {
|
|
513
|
+
dashboardComponent.iframeHeight = "200px";
|
|
514
|
+
} else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
|
|
515
|
+
dashboardComponent.iframeHeight = "100%";
|
|
516
|
+
} else {
|
|
517
|
+
dashboardComponent.iframeHeight = "400px";
|
|
518
|
+
}
|
|
519
|
+
dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
|
|
520
|
+
const styles = {
|
|
521
|
+
height: dashboardComponent.iframeHeight,
|
|
522
|
+
width: dashboardComponent.iframeWidth
|
|
523
|
+
};
|
|
524
|
+
if (dashboardComponent.iframeLoaded) {
|
|
525
|
+
styles.opacity = 1;
|
|
526
|
+
} else if (dashboardComponent.error) {
|
|
527
|
+
styles.opacity = 1;
|
|
528
|
+
styles.width = "100%";
|
|
529
|
+
styles.height = "400px";
|
|
530
|
+
} else {
|
|
531
|
+
styles.opacity = 0;
|
|
532
|
+
}
|
|
533
|
+
return styles;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
|
|
537
|
+
var updateIframeUrl = (iframe, iframeUrl) => {
|
|
538
|
+
if (iframe?.contentWindow) {
|
|
539
|
+
iframe.contentWindow.location.replace(iframeUrl);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/set-selected-data-utils.ts
|
|
544
|
+
var selectedDataUtils = {
|
|
545
|
+
merge(...filters) {
|
|
546
|
+
return filters.reduce((acc, filter) => {
|
|
547
|
+
acc.and.push(...filter.and);
|
|
548
|
+
return acc;
|
|
549
|
+
}, {
|
|
550
|
+
and: []
|
|
551
|
+
});
|
|
552
|
+
},
|
|
553
|
+
isIn(slot, values, otherOptions) {
|
|
554
|
+
return {
|
|
555
|
+
and: [{
|
|
556
|
+
expression: "? in ?",
|
|
557
|
+
parameters: [
|
|
558
|
+
{
|
|
559
|
+
slot,
|
|
560
|
+
...otherOptions
|
|
561
|
+
},
|
|
562
|
+
values
|
|
563
|
+
]
|
|
564
|
+
}]
|
|
565
|
+
};
|
|
566
|
+
},
|
|
567
|
+
between(slot, values, otherOptions) {
|
|
568
|
+
return {
|
|
569
|
+
and: [{
|
|
570
|
+
expression: "? between ?",
|
|
571
|
+
parameters: [
|
|
572
|
+
{
|
|
573
|
+
slot,
|
|
574
|
+
...otherOptions
|
|
575
|
+
},
|
|
576
|
+
[values[0], values[1]]
|
|
577
|
+
]
|
|
578
|
+
}]
|
|
579
|
+
};
|
|
580
|
+
},
|
|
581
|
+
range(slot, values, otherOptions) {
|
|
582
|
+
const expressions = otherOptions?.expressions ?? ["? >= ?", "? < ?"];
|
|
583
|
+
return {
|
|
584
|
+
and: [{
|
|
585
|
+
expression: expressions[0],
|
|
586
|
+
parameters: [
|
|
587
|
+
{
|
|
588
|
+
slot,
|
|
589
|
+
...otherOptions
|
|
590
|
+
},
|
|
591
|
+
[values[0]]
|
|
592
|
+
]
|
|
593
|
+
}, {
|
|
594
|
+
expression: expressions[1],
|
|
595
|
+
parameters: [
|
|
596
|
+
{
|
|
597
|
+
slot,
|
|
598
|
+
...otherOptions
|
|
599
|
+
},
|
|
600
|
+
[values[1]]
|
|
601
|
+
]
|
|
602
|
+
}]
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
// libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
|
|
608
|
+
var exportDashboard = (dashboardComponent, iframe, format) => {
|
|
609
|
+
const requestId = uuidv4();
|
|
610
|
+
if (iframe?.contentWindow) {
|
|
611
|
+
iframe.contentWindow.postMessage(
|
|
612
|
+
{
|
|
613
|
+
action: "exportDashboard",
|
|
614
|
+
format: format || "png",
|
|
615
|
+
_version: dashboardComponent.libVersion,
|
|
616
|
+
requestId
|
|
617
|
+
},
|
|
618
|
+
"*"
|
|
619
|
+
);
|
|
620
|
+
return new Promise((resolve, reject) => {
|
|
621
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
622
|
+
setTimeout(() => {
|
|
623
|
+
if (dashboardComponent.promises[requestId]) {
|
|
624
|
+
const errorMessage = "exportDashboard request timed out.";
|
|
625
|
+
dashboardComponent.promises[requestId].reject(
|
|
626
|
+
new Error(errorMessage)
|
|
627
|
+
);
|
|
628
|
+
delete dashboardComponent.promises[requestId];
|
|
629
|
+
}
|
|
630
|
+
}, 12e5);
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
|
|
637
|
+
var getAccessibleDashboards = async (dashboardComponent) => {
|
|
638
|
+
await dashboardComponent.updateComplete;
|
|
639
|
+
if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
|
|
640
|
+
const fetchUser = new Promise((resolve, reject) => {
|
|
641
|
+
void (() => {
|
|
642
|
+
try {
|
|
643
|
+
const responsePromise = window.fetch(
|
|
644
|
+
// With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
|
|
645
|
+
// Fixes incorrect url with embedMode="webComponent"
|
|
646
|
+
`${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
|
|
647
|
+
{
|
|
648
|
+
method: "POST",
|
|
649
|
+
mode: "cors",
|
|
650
|
+
cache: "no-cache",
|
|
651
|
+
headers: { "Content-Type": "application/json" },
|
|
652
|
+
redirect: "follow",
|
|
653
|
+
body: JSON.stringify({
|
|
654
|
+
action: "get",
|
|
655
|
+
version: "0.1.0",
|
|
656
|
+
key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
|
|
657
|
+
token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
|
|
658
|
+
find: {
|
|
659
|
+
where: { id: dashboardComponent.authKey },
|
|
660
|
+
attributes: ["id", "integration_id"],
|
|
661
|
+
include: [
|
|
662
|
+
{
|
|
663
|
+
model: "User",
|
|
664
|
+
attributes: ["id", "name", "locale_id"],
|
|
665
|
+
include: [{ model: "Group" }]
|
|
666
|
+
}
|
|
667
|
+
]
|
|
668
|
+
}
|
|
669
|
+
})
|
|
670
|
+
}
|
|
671
|
+
);
|
|
672
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
673
|
+
if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user) {
|
|
674
|
+
reject("Authorization failed, please check authKey and authToken. If the problem persists, please contact support@luzmo.com.");
|
|
675
|
+
} else {
|
|
676
|
+
data.rows[0].user.userGroups = data.rows[0].user.groups.map(
|
|
677
|
+
(group) => group.id
|
|
678
|
+
);
|
|
679
|
+
delete data.rows[0].user.groups;
|
|
680
|
+
resolve({
|
|
681
|
+
integrationId: data.rows[0].integration_id,
|
|
682
|
+
user: data.rows[0].user
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
} catch (error) {
|
|
687
|
+
reject(error);
|
|
688
|
+
}
|
|
689
|
+
})();
|
|
690
|
+
});
|
|
691
|
+
return new Promise((resolve, reject) => void (() => {
|
|
692
|
+
try {
|
|
693
|
+
fetchUser.then((authorizationData) => {
|
|
694
|
+
const responsePromise = window.fetch(
|
|
695
|
+
// With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
|
|
696
|
+
// Fixes incorrect url with embedMode="webComponent"
|
|
697
|
+
`${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
|
|
698
|
+
{
|
|
699
|
+
method: "POST",
|
|
700
|
+
mode: "cors",
|
|
701
|
+
cache: "no-cache",
|
|
702
|
+
headers: { "Content-Type": "application/json" },
|
|
703
|
+
redirect: "follow",
|
|
704
|
+
body: JSON.stringify({
|
|
705
|
+
action: "get",
|
|
706
|
+
version: "0.1.0",
|
|
707
|
+
key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
|
|
708
|
+
token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
|
|
709
|
+
find: {
|
|
710
|
+
where: { type: "dashboard", is_variant: false },
|
|
711
|
+
attributes: ["id", "name", "modified_at"],
|
|
712
|
+
order: [["modified_at", "desc"]],
|
|
713
|
+
include: [
|
|
714
|
+
{ model: "Tag", attributes: ["tag"] },
|
|
715
|
+
{ model: "User", attributes: ["id", "name"] },
|
|
716
|
+
{
|
|
717
|
+
model: "Group",
|
|
718
|
+
attributes: ["id", "name", "public"]
|
|
719
|
+
},
|
|
720
|
+
{ model: "Integration", attributes: ["id", "name"] }
|
|
721
|
+
]
|
|
722
|
+
}
|
|
723
|
+
})
|
|
724
|
+
}
|
|
725
|
+
);
|
|
726
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
727
|
+
const dashboardList = data.rows.length > 0 ? formatDashboardList(
|
|
728
|
+
data.rows,
|
|
729
|
+
authorizationData.integrationId,
|
|
730
|
+
authorizationData.user,
|
|
731
|
+
dashboardComponent
|
|
732
|
+
) : [];
|
|
733
|
+
resolve(dashboardList);
|
|
734
|
+
});
|
|
735
|
+
}).catch((error) => {
|
|
736
|
+
reject(error);
|
|
737
|
+
});
|
|
738
|
+
} catch (error) {
|
|
739
|
+
reject(error);
|
|
740
|
+
}
|
|
741
|
+
})());
|
|
742
|
+
}
|
|
743
|
+
throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
|
|
747
|
+
var getDashboardContext = (dashboardComponent, iframe) => {
|
|
748
|
+
if (iframe?.contentWindow) {
|
|
749
|
+
const requestId = uuidv4();
|
|
750
|
+
iframe.contentWindow.postMessage(
|
|
751
|
+
{ action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
|
|
752
|
+
"*"
|
|
753
|
+
);
|
|
754
|
+
return new Promise((resolve, reject) => {
|
|
755
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
756
|
+
setTimeout(() => {
|
|
757
|
+
if (dashboardComponent.promises[requestId]) {
|
|
758
|
+
const errorMessage = "getDashboardContext request timed out.";
|
|
759
|
+
dashboardComponent.promises[requestId].reject(
|
|
760
|
+
new Error(errorMessage)
|
|
761
|
+
);
|
|
762
|
+
delete dashboardComponent.promises[requestId];
|
|
763
|
+
}
|
|
764
|
+
}, 2e3);
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
|
|
771
|
+
var getData = (dashboardComponent, iframe, itemId) => {
|
|
772
|
+
if (iframe?.contentWindow) {
|
|
773
|
+
const requestId = uuidv4();
|
|
774
|
+
iframe.contentWindow.postMessage(
|
|
775
|
+
{
|
|
776
|
+
action: "getData",
|
|
777
|
+
id: itemId,
|
|
778
|
+
_version: dashboardComponent.libVersion,
|
|
779
|
+
requestId
|
|
780
|
+
},
|
|
781
|
+
"*"
|
|
782
|
+
);
|
|
783
|
+
return new Promise((resolve, reject) => {
|
|
784
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
785
|
+
setTimeout(() => {
|
|
786
|
+
if (dashboardComponent.promises[requestId]) {
|
|
787
|
+
const errorMessage = "getData request timed out.";
|
|
788
|
+
dashboardComponent.promises[requestId].reject(
|
|
789
|
+
new Error(errorMessage)
|
|
790
|
+
);
|
|
791
|
+
delete dashboardComponent.promises[requestId];
|
|
792
|
+
}
|
|
793
|
+
}, 2e3);
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
|
|
800
|
+
var getFilters = (dashboardComponent, iframe) => {
|
|
801
|
+
if (iframe?.contentWindow) {
|
|
802
|
+
const requestId = uuidv4();
|
|
803
|
+
iframe.contentWindow.postMessage(
|
|
804
|
+
{ action: "getFilters", _version: dashboardComponent.libVersion, requestId },
|
|
805
|
+
"*"
|
|
806
|
+
);
|
|
807
|
+
return new Promise((resolve, reject) => {
|
|
808
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
809
|
+
setTimeout(() => {
|
|
810
|
+
if (dashboardComponent.promises[requestId]) {
|
|
811
|
+
const errorMessage = "getFilters request timed out.";
|
|
812
|
+
dashboardComponent.promises[requestId].reject(
|
|
813
|
+
new Error(errorMessage)
|
|
814
|
+
);
|
|
815
|
+
delete dashboardComponent.promises[requestId];
|
|
816
|
+
}
|
|
817
|
+
}, 2e3);
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
// libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
|
|
824
|
+
var getInsights = (dashboardComponent, iframe, options = {}) => {
|
|
825
|
+
if (!iframe?.contentWindow) {
|
|
826
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
827
|
+
}
|
|
828
|
+
const requestId = uuidv4();
|
|
829
|
+
iframe.contentWindow.postMessage(
|
|
830
|
+
{
|
|
831
|
+
action: "getInsights",
|
|
832
|
+
options,
|
|
833
|
+
_version: dashboardComponent.libVersion,
|
|
834
|
+
requestId
|
|
835
|
+
},
|
|
836
|
+
"*"
|
|
837
|
+
);
|
|
838
|
+
return new Promise((resolve, reject) => {
|
|
839
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
840
|
+
setTimeout(() => {
|
|
841
|
+
if (dashboardComponent.promises[requestId]) {
|
|
842
|
+
dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
|
|
843
|
+
delete dashboardComponent.promises[requestId];
|
|
844
|
+
}
|
|
845
|
+
}, 6e4);
|
|
846
|
+
});
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
// libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
|
|
850
|
+
var refreshData = (dashboardComponent, iframe, itemId) => {
|
|
851
|
+
if (iframe) {
|
|
852
|
+
iframe.contentWindow.postMessage(
|
|
853
|
+
{
|
|
854
|
+
action: "refreshData",
|
|
855
|
+
id: itemId ?? null,
|
|
856
|
+
_version: dashboardComponent.libVersion
|
|
857
|
+
},
|
|
858
|
+
"*"
|
|
859
|
+
);
|
|
860
|
+
return Promise.resolve();
|
|
861
|
+
}
|
|
862
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
// libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
|
|
866
|
+
var reloadDashboard = (dashboardComponent, iframe) => {
|
|
867
|
+
if (iframe) {
|
|
868
|
+
iframe.contentWindow.postMessage(
|
|
869
|
+
{ action: "reloadDashboard", _version: dashboardComponent.libVersion },
|
|
870
|
+
"*"
|
|
871
|
+
);
|
|
872
|
+
return Promise.resolve();
|
|
873
|
+
}
|
|
874
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
// libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
|
|
878
|
+
var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
|
|
879
|
+
if (iframe) {
|
|
880
|
+
iframe.contentWindow.postMessage(
|
|
881
|
+
{
|
|
882
|
+
action: "sendExportEmail",
|
|
883
|
+
type: type || "once",
|
|
884
|
+
subject,
|
|
885
|
+
message,
|
|
886
|
+
_version: dashboardComponent.libVersion
|
|
887
|
+
},
|
|
888
|
+
"*"
|
|
889
|
+
);
|
|
890
|
+
return Promise.resolve();
|
|
891
|
+
}
|
|
892
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
|
|
896
|
+
var setAuthorization = (dashboardComponent, iframe, key, token) => {
|
|
897
|
+
if (iframe) {
|
|
898
|
+
iframe.contentWindow.postMessage(
|
|
899
|
+
{
|
|
900
|
+
action: "setAuthorization",
|
|
901
|
+
key,
|
|
902
|
+
token,
|
|
903
|
+
_version: dashboardComponent.libVersion
|
|
904
|
+
},
|
|
905
|
+
"*"
|
|
906
|
+
);
|
|
907
|
+
return Promise.resolve();
|
|
908
|
+
}
|
|
909
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
|
|
913
|
+
var setEditMode = (dashboardComponent, iframe, editMode) => {
|
|
914
|
+
if (iframe && iframe.contentWindow) {
|
|
915
|
+
const requestId = uuidv4();
|
|
916
|
+
if (dashboardComponent.params.editMode === editMode) {
|
|
917
|
+
return Promise.reject(
|
|
918
|
+
new Error("editMode parameter is currently already set to " + editMode)
|
|
919
|
+
);
|
|
920
|
+
} else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
|
|
921
|
+
return Promise.reject(
|
|
922
|
+
new Error(
|
|
923
|
+
"The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
|
|
924
|
+
)
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
iframe.contentWindow.postMessage(
|
|
928
|
+
{
|
|
929
|
+
action: "setEditMode",
|
|
930
|
+
editMode,
|
|
931
|
+
_version: dashboardComponent.libVersion,
|
|
932
|
+
requestId
|
|
933
|
+
},
|
|
934
|
+
"*"
|
|
935
|
+
);
|
|
936
|
+
return new Promise((resolve, reject) => {
|
|
937
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
|
|
944
|
+
var setPreview = (dashboardComponent, iframe, preview) => {
|
|
945
|
+
if (iframe) {
|
|
946
|
+
const requestId = uuidv4();
|
|
947
|
+
iframe.contentWindow.postMessage(
|
|
948
|
+
{
|
|
949
|
+
action: "setPreview",
|
|
950
|
+
preview,
|
|
951
|
+
requestId,
|
|
952
|
+
_version: dashboardComponent.libVersion
|
|
953
|
+
},
|
|
954
|
+
"*"
|
|
955
|
+
);
|
|
956
|
+
return new Promise((resolve, reject) => {
|
|
957
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
958
|
+
setTimeout(() => {
|
|
959
|
+
if (dashboardComponent.promises[requestId]) {
|
|
960
|
+
const errorMessage = "setPreview request timed out.";
|
|
961
|
+
dashboardComponent.promises[requestId].reject(
|
|
962
|
+
new Error(errorMessage)
|
|
963
|
+
);
|
|
964
|
+
delete dashboardComponent.promises[requestId];
|
|
965
|
+
}
|
|
966
|
+
}, 2e3);
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
// libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
|
|
973
|
+
var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
|
|
974
|
+
if (iframe) {
|
|
975
|
+
const requestId = uuidv4();
|
|
976
|
+
iframe.contentWindow.postMessage(
|
|
977
|
+
{
|
|
978
|
+
action: "setSelectedData",
|
|
979
|
+
itemId,
|
|
980
|
+
filters,
|
|
981
|
+
_version: dashboardComponent.libVersion,
|
|
982
|
+
requestId
|
|
983
|
+
},
|
|
984
|
+
"*"
|
|
985
|
+
);
|
|
986
|
+
return new Promise((resolve, reject) => {
|
|
987
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
988
|
+
setTimeout(() => {
|
|
989
|
+
if (dashboardComponent.promises[requestId]) {
|
|
990
|
+
const errorMessage = "setSelectedData request timed out.";
|
|
991
|
+
dashboardComponent.promises[requestId].reject(
|
|
992
|
+
new Error(errorMessage)
|
|
993
|
+
);
|
|
994
|
+
delete dashboardComponent.promises[requestId];
|
|
995
|
+
}
|
|
996
|
+
}, 2e3);
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
return Promise.reject();
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
// libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
|
|
1003
|
+
var _setCalculatedDimensions = (dashboardComponent) => {
|
|
1004
|
+
if (!dashboardComponent.dimensions) {
|
|
1005
|
+
dashboardComponent.params.error = true;
|
|
1006
|
+
_handleError("Got no valid dimensions.", dashboardComponent.params);
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
const dashboardDimensionKeys = Object.keys(
|
|
1010
|
+
dashboardComponent.dimensions
|
|
1011
|
+
);
|
|
1012
|
+
const availableScreenModeExtents = [];
|
|
1013
|
+
let currentMode;
|
|
1014
|
+
let currentWidth = 0;
|
|
1015
|
+
let currentHeight = 0;
|
|
1016
|
+
if (!dashboardComponent.params.switchScreenModeOnResize && dashboardComponent.currentScreenMode) {
|
|
1017
|
+
dashboardComponent.params.screenMode = dashboardComponent.currentScreenMode;
|
|
1018
|
+
}
|
|
1019
|
+
if (dashboardComponent.dimensions && dashboardDimensionKeys?.[0] === "fixed") {
|
|
1020
|
+
currentMode = "fixed";
|
|
1021
|
+
currentWidth = dashboardComponent.dimensions.fixed[0];
|
|
1022
|
+
currentHeight = dashboardComponent.dimensions.fixed[1];
|
|
1023
|
+
} else {
|
|
1024
|
+
const screenModes = [
|
|
1025
|
+
"mobile",
|
|
1026
|
+
"tablet",
|
|
1027
|
+
"desktop",
|
|
1028
|
+
"largeScreen"
|
|
1029
|
+
];
|
|
1030
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
1031
|
+
const [firstMatch] = dashboardDimensionKeys;
|
|
1032
|
+
let match = firstMatch;
|
|
1033
|
+
for (const screenMode of screenModes) {
|
|
1034
|
+
const found = dashboardDimensionKeys.find((key) => key === screenMode);
|
|
1035
|
+
if (found) {
|
|
1036
|
+
match = found;
|
|
1037
|
+
} else {
|
|
1038
|
+
dashboardComponent.dimensions[screenMode] = dashboardComponent.dimensions[match];
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
for (const key of dashboardDimensionKeys) {
|
|
1043
|
+
if (screenModes.includes(key)) {
|
|
1044
|
+
const screenMode = EXTENTS.find((extent) => extent.mode === key);
|
|
1045
|
+
availableScreenModeExtents.push({
|
|
1046
|
+
...screenMode,
|
|
1047
|
+
height: dashboardComponent.dimensions[key][1] || 50
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (!availableScreenModeExtents.map((screenModeExtent) => screenModeExtent.mode).includes(dashboardComponent.params.screenMode)) {
|
|
1052
|
+
dashboardComponent.params.screenMode = "auto";
|
|
1053
|
+
}
|
|
1054
|
+
if (dashboardComponent.params.screenMode === "auto") {
|
|
1055
|
+
availableScreenModeExtents.sort(
|
|
1056
|
+
(a, b) => screenModes.indexOf(a.mode) - screenModes.indexOf(b.mode)
|
|
1057
|
+
);
|
|
1058
|
+
for (const screenModeExtent of availableScreenModeExtents) {
|
|
1059
|
+
const [screenModeExtentMinWidth, screenModeExtentMaxWidth] = screenModeExtent.width;
|
|
1060
|
+
if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
1061
|
+
if (screenModeExtentMinWidth < dashboardComponent.params.itemDimensions.width) {
|
|
1062
|
+
currentMode = screenModeExtent.mode;
|
|
1063
|
+
currentWidth = Number.parseInt(
|
|
1064
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1065
|
+
10
|
|
1066
|
+
);
|
|
1067
|
+
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
1068
|
+
}
|
|
1069
|
+
} else {
|
|
1070
|
+
if (screenModeExtentMinWidth < dashboardComponent.containerWidth) {
|
|
1071
|
+
currentMode = screenModeExtent.mode;
|
|
1072
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
1073
|
+
currentWidth = dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto" ? Number.parseInt(
|
|
1074
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1075
|
+
10
|
|
1076
|
+
) : Math.min(
|
|
1077
|
+
dashboardComponent.containerWidth,
|
|
1078
|
+
screenModeExtentMaxWidth
|
|
1079
|
+
);
|
|
1080
|
+
currentHeight = dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto" ? Number.parseInt(
|
|
1081
|
+
dashboardComponent.params.itemDimensions.height,
|
|
1082
|
+
10
|
|
1083
|
+
) : dashboardComponent.dimensions[currentMode][1];
|
|
1084
|
+
if (dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
1085
|
+
currentWidth = Number.parseInt(
|
|
1086
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1087
|
+
10
|
|
1088
|
+
);
|
|
1089
|
+
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
1090
|
+
}
|
|
1091
|
+
} else {
|
|
1092
|
+
currentWidth = Math.max(
|
|
1093
|
+
Math.min(
|
|
1094
|
+
screenModeExtentMaxWidth,
|
|
1095
|
+
dashboardComponent.containerWidth
|
|
1096
|
+
),
|
|
1097
|
+
screenModeExtentMinWidth
|
|
1098
|
+
);
|
|
1099
|
+
currentHeight = screenModeExtent.height;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
} else {
|
|
1105
|
+
const {
|
|
1106
|
+
height: chosenModeHeight,
|
|
1107
|
+
width: [chosenModeMinWidth, chosenModeMaxWidth]
|
|
1108
|
+
} = availableScreenModeExtents.find(
|
|
1109
|
+
(d) => d.mode === dashboardComponent.params.screenMode
|
|
1110
|
+
);
|
|
1111
|
+
currentMode = dashboardComponent.params.screenMode;
|
|
1112
|
+
currentWidth = Math.max(
|
|
1113
|
+
Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
|
|
1114
|
+
chosenModeMinWidth
|
|
1115
|
+
);
|
|
1116
|
+
currentHeight = chosenModeHeight;
|
|
1117
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
1118
|
+
if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
|
|
1119
|
+
currentWidth = Number.parseInt(
|
|
1120
|
+
dashboardComponent.params.itemDimensions.width,
|
|
1121
|
+
10
|
|
1122
|
+
);
|
|
1123
|
+
}
|
|
1124
|
+
if (dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto") {
|
|
1125
|
+
currentHeight = Number.parseInt(
|
|
1126
|
+
dashboardComponent.params.itemDimensions.height,
|
|
1127
|
+
10
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
if (!currentMode && availableScreenModeExtents.length > 0) {
|
|
1133
|
+
const [lowestModeExtent] = availableScreenModeExtents;
|
|
1134
|
+
currentMode = lowestModeExtent.mode;
|
|
1135
|
+
currentWidth = lowestModeExtent.width[0];
|
|
1136
|
+
currentHeight = lowestModeExtent.height;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
dashboardComponent.currentScreenMode = currentMode;
|
|
1140
|
+
const style = {
|
|
1141
|
+
height: currentHeight === 0 ? "100%" : `${String(currentHeight)}px`,
|
|
1142
|
+
width: currentWidth === 0 ? "100%" : `${String(currentWidth)}px`,
|
|
1143
|
+
opacity: 1
|
|
1144
|
+
};
|
|
1145
|
+
const dashboardEditModes = ["editFull", "editLimited"];
|
|
1146
|
+
if (dashboardEditModes.includes(dashboardComponent.params.editMode)) {
|
|
1147
|
+
style.height = "100%";
|
|
1148
|
+
style.width = "100%";
|
|
1149
|
+
} else if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions) {
|
|
1150
|
+
style.height = dashboardComponent.params.itemDimensions.height === "auto" ? style.height : `${String(dashboardComponent.params.itemDimensions.height).replace(
|
|
1151
|
+
"px",
|
|
1152
|
+
""
|
|
1153
|
+
)}px`;
|
|
1154
|
+
style.width = dashboardComponent.params.itemDimensions.width === "auto" ? style.width : `${String(dashboardComponent.params.itemDimensions.width).replace(
|
|
1155
|
+
"px",
|
|
1156
|
+
""
|
|
1157
|
+
)}px`;
|
|
1158
|
+
} else {
|
|
1159
|
+
style.height = currentHeight === 0 ? "100%" : `${String(currentHeight)}px`;
|
|
1160
|
+
style.width = currentWidth === 0 ? "100%" : `${String(currentWidth)}px`;
|
|
1161
|
+
}
|
|
1162
|
+
dashboardComponent.currentScreenMode = currentMode;
|
|
1163
|
+
dashboardComponent.iframeStyle = style;
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
// libs/embed-libs/embed/src/lib/shared/service/extend-and-validate.ts
|
|
1167
|
+
var _extendAndValidate = (dashboardContent) => {
|
|
1168
|
+
const defaultKeys = Object.keys(
|
|
1169
|
+
DEFAULT_PARAMETERS
|
|
1170
|
+
);
|
|
1171
|
+
const errorMessages = [];
|
|
1172
|
+
const requiredStringParams = [
|
|
1173
|
+
"appServer",
|
|
1174
|
+
"language",
|
|
1175
|
+
"apiHost"
|
|
1176
|
+
];
|
|
1177
|
+
const requiredStringOrEmptyParams = [
|
|
1178
|
+
"key",
|
|
1179
|
+
"token",
|
|
1180
|
+
"screenMode",
|
|
1181
|
+
"timezoneId",
|
|
1182
|
+
"itemId",
|
|
1183
|
+
"container",
|
|
1184
|
+
"loaderBackground",
|
|
1185
|
+
"loaderFontColor",
|
|
1186
|
+
"loaderSpinnerColor",
|
|
1187
|
+
"loaderSpinnerBackground"
|
|
1188
|
+
];
|
|
1189
|
+
const objectParams = ["itemDimensions"];
|
|
1190
|
+
const screenModes = [
|
|
1191
|
+
"mobile",
|
|
1192
|
+
"tablet",
|
|
1193
|
+
"desktop",
|
|
1194
|
+
"largeScreen",
|
|
1195
|
+
"fixed",
|
|
1196
|
+
"auto"
|
|
1197
|
+
];
|
|
1198
|
+
for (const key of defaultKeys) {
|
|
1199
|
+
if (dashboardContent.params[key] === null) {
|
|
1200
|
+
delete dashboardContent.params[key];
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
dashboardContent.params = defaultsDeep(
|
|
1204
|
+
dashboardContent.params,
|
|
1205
|
+
DEFAULT_PARAMETERS
|
|
1206
|
+
);
|
|
1207
|
+
if ((!dashboardContent.params.dashboardId || typeof dashboardContent.params.dashboardId !== "string") && (!dashboardContent.params.dashboardSlug || typeof dashboardContent.params.dashboardSlug !== "string")) {
|
|
1208
|
+
delete dashboardContent.params.dashboardId;
|
|
1209
|
+
delete dashboardContent.params.dashboardSlug;
|
|
1210
|
+
}
|
|
1211
|
+
for (const key of requiredStringParams) {
|
|
1212
|
+
if (typeof dashboardContent.params[key] !== "string") {
|
|
1213
|
+
delete dashboardContent.params[key];
|
|
1214
|
+
errorMessages.push(`${key} needs to be of type string.`);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
for (const key of requiredStringOrEmptyParams) {
|
|
1218
|
+
if (typeof dashboardContent.params[key] !== "string" && dashboardContent.params[key] !== null && dashboardContent.params[key] !== void 0) {
|
|
1219
|
+
delete dashboardContent.params[key];
|
|
1220
|
+
errorMessages.push(`${key} needs to be of type string or empty.`);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
if (dashboardContent.params.screenMode && !screenModes.includes(dashboardContent.params.screenMode)) {
|
|
1224
|
+
const validTypesString = screenModes.map((mode) => `"${mode}"`).join(", ");
|
|
1225
|
+
errorMessages.push(
|
|
1226
|
+
`"screenMode" needs should be one of these types: ${validTypesString}`
|
|
1227
|
+
);
|
|
1228
|
+
dashboardContent.params.screenMode = "auto";
|
|
1229
|
+
}
|
|
1230
|
+
if (dashboardContent.params.itemId) {
|
|
1231
|
+
dashboardContent.params.itemEmbedding = true;
|
|
1232
|
+
}
|
|
1233
|
+
for (const key of objectParams) {
|
|
1234
|
+
if (typeof dashboardContent.params[key] !== "object" && dashboardContent.params[key] !== null) {
|
|
1235
|
+
delete dashboardContent.params[key];
|
|
1236
|
+
errorMessages.push(`${key} needs to be of type object or empty.`);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
if (typeof dashboardContent.params.switchScreenModeOnResize !== "boolean") {
|
|
1240
|
+
errorMessages.push("switchScreenModeOnResize needs to be of type boolean.");
|
|
1241
|
+
dashboardContent.params.switchScreenModeOnResize = true;
|
|
1242
|
+
}
|
|
1243
|
+
if (dashboardContent.params.itemDimensions) {
|
|
1244
|
+
const itemDimensionsKeys = [
|
|
1245
|
+
"width",
|
|
1246
|
+
"height"
|
|
1247
|
+
];
|
|
1248
|
+
for (const key of itemDimensionsKeys) {
|
|
1249
|
+
if (!["string", "number"].includes(
|
|
1250
|
+
typeof dashboardContent.params.itemDimensions[key]
|
|
1251
|
+
) && dashboardContent.params.itemDimensions[key] !== null) {
|
|
1252
|
+
errorMessages.push(
|
|
1253
|
+
`itemDimensions ${key} needs to be of type string, number or empty.`
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
dashboardContent.params = defaultsDeep(
|
|
1259
|
+
dashboardContent.params,
|
|
1260
|
+
DEFAULT_PARAMETERS
|
|
1261
|
+
);
|
|
1262
|
+
if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
|
|
1263
|
+
dashboardContent.params.switchScreenModeOnResize = false;
|
|
1264
|
+
}
|
|
1265
|
+
if (dashboardContent.params.itemDimensions.width !== "auto") {
|
|
1266
|
+
dashboardContent.params.itemDimensions.width = Number.parseInt(
|
|
1267
|
+
`${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
|
|
1268
|
+
10
|
|
1269
|
+
) || "auto";
|
|
1270
|
+
}
|
|
1271
|
+
if (dashboardContent.params.itemDimensions.height !== "auto") {
|
|
1272
|
+
dashboardContent.params.itemDimensions.height = Number.parseInt(
|
|
1273
|
+
`${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
|
|
1274
|
+
10
|
|
1275
|
+
) || "auto";
|
|
1276
|
+
}
|
|
1277
|
+
dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
|
|
1278
|
+
if (dashboardContent.params.error || errorMessages.length > 0) {
|
|
1279
|
+
_handleError(errorMessages.join("\n"), dashboardContent.params);
|
|
1280
|
+
}
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
// libs/embed-libs/embed/src/lib/shared/models/viz-item.model.ts
|
|
1284
|
+
var libraryTypeToWebComponentTypeMapping = {
|
|
1285
|
+
type: "type",
|
|
1286
|
+
slots: "slots",
|
|
1287
|
+
options: "options",
|
|
1288
|
+
appServer: "app-server",
|
|
1289
|
+
apiHost: "api-host",
|
|
1290
|
+
authKey: "auth-key",
|
|
1291
|
+
authToken: "auth-token",
|
|
1292
|
+
contextId: "context-id",
|
|
1293
|
+
canFilter: "can-filter",
|
|
1294
|
+
filters: "filters",
|
|
1295
|
+
dashboardId: "dashboard-id",
|
|
1296
|
+
itemId: "item-id",
|
|
1297
|
+
aiMessageAssetId: "ai-message-asset-id",
|
|
1298
|
+
dashboardContentsVersion: "dashboard-contents-version",
|
|
1299
|
+
libVersion: "lib-version"
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
// libs/embed-libs/embed/src/lib/shared/constants/class-constants.ts
|
|
1303
|
+
var luzmoEmbedContainerClass = "luzmo-embed-container";
|
|
1304
|
+
|
|
1305
|
+
// libs/embed-libs/embed/src/lib/shared/helpers/remote-federation.ts
|
|
1306
|
+
var import_runtime = require("@module-federation/runtime");
|
|
1307
|
+
var federationRuntime = (0, import_runtime.createInstance)({
|
|
1308
|
+
name: "luzmo-embed-runtime",
|
|
1309
|
+
remotes: []
|
|
1310
|
+
});
|
|
1311
|
+
var remoteCache = /* @__PURE__ */ new Map();
|
|
1312
|
+
var remoteCounter = 0;
|
|
1313
|
+
var preconnectedOrigins = /* @__PURE__ */ new Set();
|
|
1314
|
+
function injectPreconnect(appServer) {
|
|
1315
|
+
if (typeof document === "undefined") {
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
let origin;
|
|
1319
|
+
try {
|
|
1320
|
+
origin = new URL(removeTrailingSlash(appServer)).origin;
|
|
1321
|
+
} catch {
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
if (preconnectedOrigins.has(origin)) {
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
preconnectedOrigins.add(origin);
|
|
1328
|
+
const link = document.createElement("link");
|
|
1329
|
+
link.rel = "preconnect";
|
|
1330
|
+
link.href = origin;
|
|
1331
|
+
link.crossOrigin = "anonymous";
|
|
1332
|
+
(document.head ?? document.documentElement).append(link);
|
|
1333
|
+
}
|
|
1334
|
+
function getManifestEntry(appServer, componentName) {
|
|
1335
|
+
const baseUrl = removeTrailingSlash(appServer);
|
|
1336
|
+
if (appServer.startsWith("http://localhost")) {
|
|
1337
|
+
return `${baseUrl}/mf-manifest.json`;
|
|
1338
|
+
}
|
|
1339
|
+
switch (componentName) {
|
|
1340
|
+
case "DashboardApp":
|
|
1341
|
+
case "VizItemApp": {
|
|
1342
|
+
return `${baseUrl}/dashboard-app/mf-manifest.json`;
|
|
1343
|
+
}
|
|
1344
|
+
case "IQApp": {
|
|
1345
|
+
return `${baseUrl}/iq-app/mf-manifest.json`;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
function getCacheKey(appServer, componentName) {
|
|
1350
|
+
return `${appServer}|${componentName}`;
|
|
1351
|
+
}
|
|
1352
|
+
function getOrCreateRemote(appServer, componentName) {
|
|
1353
|
+
const cacheKey = getCacheKey(appServer, componentName);
|
|
1354
|
+
const cachedRemote = remoteCache.get(cacheKey);
|
|
1355
|
+
if (cachedRemote) {
|
|
1356
|
+
return cachedRemote;
|
|
1357
|
+
}
|
|
1358
|
+
const remote = {
|
|
1359
|
+
entry: getManifestEntry(appServer, componentName),
|
|
1360
|
+
registered: false,
|
|
1361
|
+
remoteName: `luzmo_embed_${remoteCounter++}`
|
|
1362
|
+
};
|
|
1363
|
+
remoteCache.set(cacheKey, remote);
|
|
1364
|
+
return remote;
|
|
1365
|
+
}
|
|
1366
|
+
function loadLibrary(appServer, componentName = "DashboardApp") {
|
|
1367
|
+
injectPreconnect(appServer);
|
|
1368
|
+
const remote = getOrCreateRemote(appServer, componentName);
|
|
1369
|
+
if (remote.module) {
|
|
1370
|
+
return Promise.resolve(remote.module);
|
|
1371
|
+
}
|
|
1372
|
+
if (remote.loadPromise) {
|
|
1373
|
+
return remote.loadPromise;
|
|
1374
|
+
}
|
|
1375
|
+
if (!remote.registered) {
|
|
1376
|
+
federationRuntime.registerRemotes([
|
|
1377
|
+
{
|
|
1378
|
+
name: remote.remoteName,
|
|
1379
|
+
entry: remote.entry
|
|
1380
|
+
}
|
|
1381
|
+
]);
|
|
1382
|
+
remote.registered = true;
|
|
1383
|
+
}
|
|
1384
|
+
remote.loadPromise = federationRuntime.loadRemote(`${remote.remoteName}/${componentName}`).then((module2) => {
|
|
1385
|
+
if (!module2) {
|
|
1386
|
+
throw new Error(`Failed to load "${componentName}" from "${remote.entry}".`);
|
|
1387
|
+
}
|
|
1388
|
+
remote.module = module2;
|
|
1389
|
+
return module2;
|
|
1390
|
+
}).finally(() => {
|
|
1391
|
+
remote.loadPromise = void 0;
|
|
1392
|
+
});
|
|
1393
|
+
return remote.loadPromise;
|
|
1394
|
+
}
|
|
1395
|
+
function preloadDashboard(appServer = "https://app.luzmo.com") {
|
|
1396
|
+
loadLibrary(appServer, "DashboardApp").catch(() => {
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
function preloadVizItem(appServer = "https://app.luzmo.com") {
|
|
1400
|
+
loadLibrary(appServer, "VizItemApp").catch(() => {
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
function preloadIQ(appServer = "https://app.luzmo.com") {
|
|
1404
|
+
loadLibrary(appServer, "IQApp").catch(() => {
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
// libs/embed-libs/embed/src/index.ts
|
|
58
1409
|
var import_lit6 = require("lit");
|
|
59
1410
|
|
|
60
1411
|
// libs/embed-libs/embed/src/lib/dashboard/dashboard-base.ts
|
|
61
|
-
var SharedLib2 = __toESM(require("@luzmo/shared-embed"));
|
|
62
1412
|
var import_lit2 = require("lit");
|
|
63
1413
|
var import_decorators = require("lit/decorators.js");
|
|
64
1414
|
var import_style_map = require("lit/directives/style-map.js");
|
|
65
1415
|
|
|
66
1416
|
// libs/embed-libs/embed/package.json
|
|
67
|
-
var version = "
|
|
1417
|
+
var version = "8.0.0";
|
|
68
1418
|
|
|
69
|
-
// libs/embed-libs/embed/src/lib/
|
|
1419
|
+
// libs/embed-libs/embed/src/lib/utils/embed-error.utils.ts
|
|
70
1420
|
function buildEmbedErrorDetail(errorMsg) {
|
|
71
1421
|
const payload = {
|
|
72
1422
|
type: "error",
|
|
@@ -80,14 +1430,13 @@ function firstString(...values) {
|
|
|
80
1430
|
}
|
|
81
1431
|
function normalizeEmbedErrorDetail(detail) {
|
|
82
1432
|
const wrapped = detail;
|
|
83
|
-
const
|
|
1433
|
+
const fromWrapped = wrapped?.data;
|
|
1434
|
+
const fromDetail = detail && typeof detail === "object" ? detail : void 0;
|
|
1435
|
+
const raw = fromWrapped ?? fromDetail ?? {};
|
|
84
1436
|
const errorMsg = firstString(raw.errorMsg, raw.error?.msg) ?? "Unknown error";
|
|
85
1437
|
return buildEmbedErrorDetail(errorMsg);
|
|
86
1438
|
}
|
|
87
1439
|
|
|
88
|
-
// libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
|
|
89
|
-
var SharedLib = __toESM(require("@luzmo/shared-embed"));
|
|
90
|
-
|
|
91
1440
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
92
1441
|
var LuzmoDashboardService = class {
|
|
93
1442
|
constructor() {
|
|
@@ -96,7 +1445,7 @@ var LuzmoDashboardService = class {
|
|
|
96
1445
|
};
|
|
97
1446
|
var luzmo_service_default = new LuzmoDashboardService();
|
|
98
1447
|
|
|
99
|
-
// libs/embed-libs/embed/src/lib/
|
|
1448
|
+
// libs/embed-libs/embed/src/lib/utils/event-bus-handler.ts
|
|
100
1449
|
var _setEventHandler = () => {
|
|
101
1450
|
if (typeof window.__luzmoMessageHandler === "function") {
|
|
102
1451
|
return;
|
|
@@ -127,7 +1476,7 @@ var _setEventHandler = () => {
|
|
|
127
1476
|
break;
|
|
128
1477
|
}
|
|
129
1478
|
case "data": {
|
|
130
|
-
|
|
1479
|
+
resolvePromise(
|
|
131
1480
|
dashboardComponent,
|
|
132
1481
|
event.data.requestId,
|
|
133
1482
|
event.data.data
|
|
@@ -135,7 +1484,7 @@ var _setEventHandler = () => {
|
|
|
135
1484
|
break;
|
|
136
1485
|
}
|
|
137
1486
|
case "filters": {
|
|
138
|
-
|
|
1487
|
+
resolvePromise(
|
|
139
1488
|
dashboardComponent,
|
|
140
1489
|
event.data.requestId,
|
|
141
1490
|
event.data.filters
|
|
@@ -144,13 +1493,13 @@ var _setEventHandler = () => {
|
|
|
144
1493
|
}
|
|
145
1494
|
case "insights": {
|
|
146
1495
|
if (event.data.error) {
|
|
147
|
-
|
|
1496
|
+
rejectPromise(
|
|
148
1497
|
dashboardComponent,
|
|
149
1498
|
event.data.requestId,
|
|
150
1499
|
new Error(event.data.error.message)
|
|
151
1500
|
);
|
|
152
1501
|
} else {
|
|
153
|
-
|
|
1502
|
+
resolvePromise(
|
|
154
1503
|
dashboardComponent,
|
|
155
1504
|
event.data.requestId,
|
|
156
1505
|
event.data.summary
|
|
@@ -159,7 +1508,7 @@ var _setEventHandler = () => {
|
|
|
159
1508
|
break;
|
|
160
1509
|
}
|
|
161
1510
|
case "dashboardContext": {
|
|
162
|
-
|
|
1511
|
+
resolvePromise(
|
|
163
1512
|
dashboardComponent,
|
|
164
1513
|
event.data.requestId,
|
|
165
1514
|
event.data.context
|
|
@@ -167,7 +1516,7 @@ var _setEventHandler = () => {
|
|
|
167
1516
|
break;
|
|
168
1517
|
}
|
|
169
1518
|
case "getAccessibleDashboards": {
|
|
170
|
-
|
|
1519
|
+
resolvePromise(
|
|
171
1520
|
dashboardComponent,
|
|
172
1521
|
event.data.requestId,
|
|
173
1522
|
event.data.accessibleDashboards
|
|
@@ -182,7 +1531,7 @@ var _setEventHandler = () => {
|
|
|
182
1531
|
}
|
|
183
1532
|
case "export": {
|
|
184
1533
|
if (event.data.error) {
|
|
185
|
-
|
|
1534
|
+
rejectPromise(
|
|
186
1535
|
dashboardComponent,
|
|
187
1536
|
event.data.requestId,
|
|
188
1537
|
event.data
|
|
@@ -191,7 +1540,7 @@ var _setEventHandler = () => {
|
|
|
191
1540
|
dashboardComponent.dispatchEvent(
|
|
192
1541
|
new CustomEvent("exported", { detail: { data: event.data } })
|
|
193
1542
|
);
|
|
194
|
-
|
|
1543
|
+
resolvePromise(
|
|
195
1544
|
dashboardComponent,
|
|
196
1545
|
event.data.requestId,
|
|
197
1546
|
event.data
|
|
@@ -228,28 +1577,28 @@ var _setEventHandler = () => {
|
|
|
228
1577
|
}
|
|
229
1578
|
case "setEditMode": {
|
|
230
1579
|
if (event.data.error) {
|
|
231
|
-
|
|
1580
|
+
rejectPromise(
|
|
232
1581
|
dashboardComponent,
|
|
233
1582
|
event.data.requestId,
|
|
234
1583
|
event.data
|
|
235
1584
|
);
|
|
236
1585
|
} else {
|
|
237
|
-
|
|
1586
|
+
resolvePromise(
|
|
238
1587
|
dashboardComponent,
|
|
239
1588
|
event.data.requestId,
|
|
240
1589
|
event.data
|
|
241
1590
|
);
|
|
242
1591
|
dashboardComponent.params.editMode = event.data.editMode;
|
|
243
|
-
dashboardComponent._containerStyle =
|
|
1592
|
+
dashboardComponent._containerStyle = containerStyles(dashboardComponent);
|
|
244
1593
|
if (dashboardComponent.dimensions) {
|
|
245
|
-
|
|
1594
|
+
_setCalculatedDimensions(dashboardComponent);
|
|
246
1595
|
}
|
|
247
1596
|
}
|
|
248
1597
|
break;
|
|
249
1598
|
}
|
|
250
1599
|
case "calculatedDimensions": {
|
|
251
1600
|
dashboardComponent.dimensions = event.data.dimensions;
|
|
252
|
-
|
|
1601
|
+
_setCalculatedDimensions(dashboardComponent);
|
|
253
1602
|
break;
|
|
254
1603
|
}
|
|
255
1604
|
case "trackViewport": {
|
|
@@ -263,13 +1612,13 @@ var _setEventHandler = () => {
|
|
|
263
1612
|
case "setSelectedData":
|
|
264
1613
|
case "setFilters": {
|
|
265
1614
|
if (event.data.error) {
|
|
266
|
-
|
|
1615
|
+
rejectPromise(
|
|
267
1616
|
dashboardComponent,
|
|
268
1617
|
event.data.requestId,
|
|
269
1618
|
event.data
|
|
270
1619
|
);
|
|
271
1620
|
} else {
|
|
272
|
-
|
|
1621
|
+
resolvePromise(
|
|
273
1622
|
dashboardComponent,
|
|
274
1623
|
event.data.requestId,
|
|
275
1624
|
event.data
|
|
@@ -279,13 +1628,13 @@ var _setEventHandler = () => {
|
|
|
279
1628
|
}
|
|
280
1629
|
case "setPreview": {
|
|
281
1630
|
if (event.data.error) {
|
|
282
|
-
|
|
1631
|
+
rejectPromise(
|
|
283
1632
|
dashboardComponent,
|
|
284
1633
|
event.data.requestId,
|
|
285
1634
|
event.data
|
|
286
1635
|
);
|
|
287
1636
|
} else {
|
|
288
|
-
|
|
1637
|
+
resolvePromise(
|
|
289
1638
|
dashboardComponent,
|
|
290
1639
|
event.data.requestId,
|
|
291
1640
|
event.data
|
|
@@ -373,6 +1722,31 @@ var dashboardStyles = import_lit.css`
|
|
|
373
1722
|
margin: 0 auto;
|
|
374
1723
|
}
|
|
375
1724
|
|
|
1725
|
+
.luzmo-embed-container:not(.luzmo-embed-container-ede) .luzmo-container-loader {
|
|
1726
|
+
height: 100% !important;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
.luzmo-embed-container:not(.luzmo-embed-container-ede) .luzmo-loader {
|
|
1730
|
+
display: flex;
|
|
1731
|
+
align-items: center;
|
|
1732
|
+
justify-content: center;
|
|
1733
|
+
height: 100%;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
.luzmo-embed-container:not(.luzmo-embed-container-ede) .luzmo-lc {
|
|
1737
|
+
display: flex;
|
|
1738
|
+
flex-direction: column;
|
|
1739
|
+
align-items: center;
|
|
1740
|
+
padding: 0 !important;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
.luzmo-embed-container:not(.luzmo-embed-container-ede) .luzmo-loading-message {
|
|
1744
|
+
height: auto;
|
|
1745
|
+
margin: 12px 0 0;
|
|
1746
|
+
line-height: 1.5;
|
|
1747
|
+
font-weight: 300;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
376
1750
|
.luzmo-loading-message {
|
|
377
1751
|
width: 100%;
|
|
378
1752
|
height: 20px;
|
|
@@ -443,7 +1817,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
443
1817
|
this.screenMode = "auto";
|
|
444
1818
|
this.switchScreenModeOnResize = true;
|
|
445
1819
|
this.editMode = "view";
|
|
446
|
-
this.embedMode = "
|
|
1820
|
+
this.embedMode = "webComponent";
|
|
447
1821
|
this.iframeStyle = {};
|
|
448
1822
|
this._containerStyle = {};
|
|
449
1823
|
this._loaderStyle = {};
|
|
@@ -455,6 +1829,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
455
1829
|
this.browserError = false;
|
|
456
1830
|
this.browserErrorMsg = "";
|
|
457
1831
|
this.dashboardError = false;
|
|
1832
|
+
this.dashboardErrorMsg = "";
|
|
458
1833
|
this.browserNotSupported = [];
|
|
459
1834
|
this.libVersion = version + "-wc-luzmo";
|
|
460
1835
|
this.isLibraryLoaded = false;
|
|
@@ -466,9 +1841,8 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
466
1841
|
dashboardSlug: "dashboard-slug",
|
|
467
1842
|
itemId: "item-id",
|
|
468
1843
|
language: "language",
|
|
469
|
-
editorLanguage: "
|
|
1844
|
+
editorLanguage: "editor-language",
|
|
470
1845
|
screenMode: "screen-mode",
|
|
471
|
-
switchScreenModeOnResize: "switch-screen-mode-on-resize",
|
|
472
1846
|
authKey: "auth-key",
|
|
473
1847
|
authToken: "auth-token",
|
|
474
1848
|
editMode: "edit-mode",
|
|
@@ -487,12 +1861,13 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
487
1861
|
this.borderWidth = 3;
|
|
488
1862
|
this.minHeight = 400;
|
|
489
1863
|
this._viewportTrackingActive = false;
|
|
1864
|
+
this._webComponentLibraryLoadId = 0;
|
|
490
1865
|
// Post synchronously on scroll/resize (not via requestAnimationFrame) so the iframe receives the
|
|
491
1866
|
// new slice as early as possible in the frame, minimizing the lag of the pinned analyst panel.
|
|
492
1867
|
this._onViewportChange = () => {
|
|
493
1868
|
this._postViewport();
|
|
494
1869
|
};
|
|
495
|
-
this._containerId =
|
|
1870
|
+
this._containerId = uuidv4();
|
|
496
1871
|
this._iframeId = `luzmo-dashboard-${this._containerId}`;
|
|
497
1872
|
this.iframeLoaded = false;
|
|
498
1873
|
this.promises = {};
|
|
@@ -501,7 +1876,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
501
1876
|
if (this.shadowRoot?.querySelector(".dashboard-container")) {
|
|
502
1877
|
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
503
1878
|
if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
|
|
504
|
-
for (const d of
|
|
1879
|
+
for (const d of EXTENTS) {
|
|
505
1880
|
if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
|
|
506
1881
|
this.currentScreenMode = d.mode;
|
|
507
1882
|
}
|
|
@@ -512,7 +1887,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
512
1887
|
} else {
|
|
513
1888
|
if (this.dimensions) {
|
|
514
1889
|
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
515
|
-
|
|
1890
|
+
_setCalculatedDimensions(this);
|
|
516
1891
|
}
|
|
517
1892
|
}
|
|
518
1893
|
}
|
|
@@ -545,7 +1920,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
545
1920
|
// overlays (e.g. the IQ analyst) can pin themselves to the visible area while the host page
|
|
546
1921
|
// scrolls the full-height iframe. Opt-in: started when the iframe requests it via 'trackViewport'.
|
|
547
1922
|
_startViewportTracking() {
|
|
548
|
-
if (this.
|
|
1923
|
+
if (this.isWebComponentViewMode()) {
|
|
549
1924
|
return;
|
|
550
1925
|
}
|
|
551
1926
|
if (!this._viewportTrackingActive) {
|
|
@@ -577,7 +1952,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
577
1952
|
contentWindow.postMessage({ action: "setViewport", offsetTop, visibleHeight }, "*");
|
|
578
1953
|
}
|
|
579
1954
|
firstUpdated() {
|
|
580
|
-
this._loaderMsg =
|
|
1955
|
+
this._loaderMsg = getLoader(this)?.loadingMsg;
|
|
581
1956
|
this._loaderStyles();
|
|
582
1957
|
luzmo_service_default._dashboardComponents.push(this);
|
|
583
1958
|
if (this.luzmoEmbedContainer) {
|
|
@@ -587,15 +1962,37 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
587
1962
|
initComponent() {
|
|
588
1963
|
this.params = this._setOptions();
|
|
589
1964
|
if (this.isWebComponentViewMode()) {
|
|
590
|
-
|
|
1965
|
+
this.params.itemEmbedding = this._itemEmbedding;
|
|
1966
|
+
this.iframeLoaded = false;
|
|
1967
|
+
this._loaderStyles();
|
|
1968
|
+
if (!this.iframeStyle.height) {
|
|
1969
|
+
this.iframeStyle = calculateIframeStyles(this);
|
|
1970
|
+
}
|
|
1971
|
+
this.dashboardError = false;
|
|
1972
|
+
this.dashboardErrorMsg = "";
|
|
1973
|
+
const appServer = this.params.appServer;
|
|
1974
|
+
const libraryLoadId = ++this._webComponentLibraryLoadId;
|
|
1975
|
+
loadLibrary(appServer, dashboardRemote).then(async () => {
|
|
1976
|
+
if (libraryLoadId !== this._webComponentLibraryLoadId || !this.isWebComponentViewMode() || this.params.appServer !== appServer) {
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
591
1979
|
this.isLibraryLoaded = true;
|
|
592
1980
|
await this.updateComplete;
|
|
1981
|
+
if (libraryLoadId !== this._webComponentLibraryLoadId) {
|
|
1982
|
+
return;
|
|
1983
|
+
}
|
|
593
1984
|
const el = document.createElement("dashboard-component");
|
|
594
1985
|
this.setAllAttributesOnElement(el);
|
|
595
1986
|
el.addEventListener("load", (payload) => {
|
|
1987
|
+
this.dashboardErrorMsg = "";
|
|
596
1988
|
this.containerWidth = el.offsetWidth;
|
|
597
1989
|
this.dimensions = payload.detail.dimensions;
|
|
598
|
-
|
|
1990
|
+
if (this._loadTimeoutHandle) {
|
|
1991
|
+
clearTimeout(this._loadTimeoutHandle);
|
|
1992
|
+
this._loadTimeoutHandle = void 0;
|
|
1993
|
+
}
|
|
1994
|
+
this.iframeLoaded = true;
|
|
1995
|
+
this._calculateDimAfterDashboardLoaded();
|
|
599
1996
|
window.dispatchEvent(new Event("resize"));
|
|
600
1997
|
this.dispatchEvent(new CustomEvent("load", payload));
|
|
601
1998
|
});
|
|
@@ -613,18 +2010,24 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
613
2010
|
container.append(el);
|
|
614
2011
|
this.dashboardReference = el;
|
|
615
2012
|
}
|
|
2013
|
+
}).catch((error) => {
|
|
2014
|
+
if (libraryLoadId !== this._webComponentLibraryLoadId || !this.isWebComponentViewMode() || this.params.appServer !== appServer) {
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
const errorMsg = error instanceof Error ? error.message : "Failed to load the dashboard application.";
|
|
2018
|
+
this._handleEmbedError({ errorMsg });
|
|
616
2019
|
});
|
|
617
2020
|
} else {
|
|
618
2021
|
this.containerWidth = this.container?.clientWidth;
|
|
619
|
-
|
|
620
|
-
|
|
2022
|
+
_extendAndValidate(this);
|
|
2023
|
+
_browserCheck(this);
|
|
621
2024
|
this._setupLoader();
|
|
622
2025
|
if (!this.params.error) {
|
|
623
2026
|
this._loaderStyles();
|
|
624
2027
|
_setEventHandler();
|
|
625
|
-
this._iframeUrl =
|
|
2028
|
+
this._iframeUrl = createIframeUrl(this);
|
|
626
2029
|
this.iframe?.setAttribute("src", this._iframeUrl);
|
|
627
|
-
this.iframeStyle =
|
|
2030
|
+
this.iframeStyle = calculateIframeStyles(this);
|
|
628
2031
|
}
|
|
629
2032
|
}
|
|
630
2033
|
}
|
|
@@ -637,29 +2040,37 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
637
2040
|
if (!el) {
|
|
638
2041
|
return;
|
|
639
2042
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
2043
|
+
const propertyNames = Object.keys(this.attributesMap);
|
|
2044
|
+
const prioritizedPropertyNames = ["dashboardId", "appServer", "apiHost"];
|
|
2045
|
+
for (const propertyName of [
|
|
2046
|
+
...prioritizedPropertyNames,
|
|
2047
|
+
...propertyNames.filter((name) => !prioritizedPropertyNames.includes(name))
|
|
2048
|
+
]) {
|
|
2049
|
+
this.setAttributeOnElement(el, propertyName);
|
|
645
2050
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
if (!["authKey", "authToken", "apiHost", "itemDimensions", "dashboardId", "appServer"].includes(key) && this.params[key]) {
|
|
651
|
-
el.setAttribute(this.attributesMap[key], this.params[key]);
|
|
652
|
-
}
|
|
2051
|
+
}
|
|
2052
|
+
getAttributeValue(propertyName) {
|
|
2053
|
+
if (propertyName === "authKey") {
|
|
2054
|
+
return this.params.key;
|
|
653
2055
|
}
|
|
654
|
-
if (
|
|
655
|
-
|
|
2056
|
+
if (propertyName === "authToken") {
|
|
2057
|
+
return this.params.token;
|
|
656
2058
|
}
|
|
657
|
-
|
|
658
|
-
|
|
2059
|
+
return this.params[propertyName];
|
|
2060
|
+
}
|
|
2061
|
+
setAttributeOnElement(el, propertyName) {
|
|
2062
|
+
const attributeName = this.attributesMap[propertyName];
|
|
2063
|
+
if (!attributeName) {
|
|
2064
|
+
return;
|
|
659
2065
|
}
|
|
660
|
-
|
|
661
|
-
|
|
2066
|
+
const value = this.getAttributeValue(propertyName);
|
|
2067
|
+
if (value === null || value === void 0) {
|
|
2068
|
+
el.removeAttribute(attributeName);
|
|
2069
|
+
return;
|
|
662
2070
|
}
|
|
2071
|
+
const normalizedValue = ["appServer", "apiHost"].includes(propertyName) && typeof value === "string" ? removeTrailingSlash(value) : value;
|
|
2072
|
+
const attributeValue = typeof normalizedValue === "object" ? JSON.stringify(normalizedValue) : String(normalizedValue);
|
|
2073
|
+
el.setAttribute(attributeName, attributeValue);
|
|
663
2074
|
}
|
|
664
2075
|
// Reload dashboard when triggerproperty changes
|
|
665
2076
|
updated(changedProperties) {
|
|
@@ -680,19 +2091,36 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
680
2091
|
"timezoneId",
|
|
681
2092
|
"itemDimensions"
|
|
682
2093
|
]);
|
|
2094
|
+
const webComponentRenderProperties = /* @__PURE__ */ new Set([
|
|
2095
|
+
"dashboardId",
|
|
2096
|
+
"dashboardSlug",
|
|
2097
|
+
"itemId",
|
|
2098
|
+
"language",
|
|
2099
|
+
"editorLanguage",
|
|
2100
|
+
"theme",
|
|
2101
|
+
"screenMode",
|
|
2102
|
+
"timezoneId",
|
|
2103
|
+
"itemDimensions"
|
|
2104
|
+
]);
|
|
683
2105
|
const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
|
|
684
2106
|
let callInitComponent = false;
|
|
685
2107
|
for (const condition of conditionsToCheck) {
|
|
686
|
-
callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition] !== void 0;
|
|
2108
|
+
callInitComponent = callInitComponent || changedProperties.has(condition) && changedProperties.get(condition) === void 0 && this[condition] !== void 0;
|
|
687
2109
|
}
|
|
688
|
-
|
|
2110
|
+
const isDashboardReferenceMissing = !this.dashboardReference || !this.dashboardReference.isConnected;
|
|
2111
|
+
if (callInitComponent && (!this.isInitCalled || isDashboardReferenceMissing)) {
|
|
2112
|
+
if (isDashboardReferenceMissing) {
|
|
2113
|
+
this.dashboardReference = void 0;
|
|
2114
|
+
}
|
|
689
2115
|
this.initComponent();
|
|
690
2116
|
this.isInitCalled = true;
|
|
691
2117
|
return;
|
|
692
2118
|
}
|
|
693
2119
|
if (this.isWebComponentViewMode()) {
|
|
694
|
-
if (changedProperties.has("editMode") && !this.dashboardReference) {
|
|
2120
|
+
if (changedProperties.has("editMode") && (!this.dashboardReference || !this.dashboardReference.isConnected)) {
|
|
695
2121
|
this.iframeLoaded = false;
|
|
2122
|
+
this.dashboardReference = void 0;
|
|
2123
|
+
this._webComponentLibraryLoadId++;
|
|
696
2124
|
if (this._loadTimeoutHandle) {
|
|
697
2125
|
clearTimeout(this._loadTimeoutHandle);
|
|
698
2126
|
this._loadTimeoutHandle = void 0;
|
|
@@ -701,24 +2129,37 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
701
2129
|
this.initComponent();
|
|
702
2130
|
return;
|
|
703
2131
|
}
|
|
2132
|
+
if ([...changedProperties.keys()].some((propertyName) => triggerProperties.has(propertyName))) {
|
|
2133
|
+
this.params = this._setOptions();
|
|
2134
|
+
}
|
|
2135
|
+
if (changedProperties.has("screenMode") || changedProperties.has("switchScreenModeOnResize")) {
|
|
2136
|
+
this._onResize();
|
|
2137
|
+
}
|
|
2138
|
+
if (changedProperties.has("appServer") || changedProperties.has("apiHost") || changedProperties.has("authKey") || changedProperties.has("authToken")) {
|
|
2139
|
+
this.dashboardReference?.remove();
|
|
2140
|
+
this.dashboardReference = void 0;
|
|
2141
|
+
this.initComponent();
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
704
2144
|
if (this.dashboardReference) {
|
|
2145
|
+
if ([...changedProperties.keys()].some((propertyName) => webComponentRenderProperties.has(propertyName))) {
|
|
2146
|
+
this.iframeLoaded = false;
|
|
2147
|
+
this._loaderStyles();
|
|
2148
|
+
}
|
|
705
2149
|
for (const [propertyName] of changedProperties.entries()) {
|
|
706
|
-
if (propertyName
|
|
707
|
-
|
|
708
|
-
this.isLibraryLoaded = true;
|
|
709
|
-
await this.updateComplete;
|
|
710
|
-
this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
|
|
711
|
-
this.setAllAttributes();
|
|
712
|
-
});
|
|
713
|
-
} else if (this.attributesMap[propertyName]) {
|
|
714
|
-
const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
|
|
715
|
-
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
|
|
716
|
-
this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
|
|
2150
|
+
if (this.attributesMap[propertyName] && propertyName !== "editMode") {
|
|
2151
|
+
this.setAttributeOnElement(this.dashboardReference, propertyName);
|
|
717
2152
|
}
|
|
718
2153
|
}
|
|
719
2154
|
}
|
|
720
2155
|
} else {
|
|
721
|
-
for (const [propertyName] of changedProperties.entries()) {
|
|
2156
|
+
for (const [propertyName, previousValue] of changedProperties.entries()) {
|
|
2157
|
+
if (propertyName === "editMode" && this.embedMode === "webComponent" && (previousValue === "view" || previousValue === void 0)) {
|
|
2158
|
+
this.dashboardReference = void 0;
|
|
2159
|
+
this._webComponentLibraryLoadId++;
|
|
2160
|
+
this._reloadIframeContent();
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
722
2163
|
if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
|
|
723
2164
|
this._reloadIframeContent();
|
|
724
2165
|
} else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
|
|
@@ -734,7 +2175,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
734
2175
|
}
|
|
735
2176
|
_reloadIframeContent() {
|
|
736
2177
|
this.params = this._setOptions();
|
|
737
|
-
|
|
2178
|
+
_extendAndValidate(this);
|
|
738
2179
|
this._setupLoader();
|
|
739
2180
|
if (this.params.error) {
|
|
740
2181
|
if (this._loadTimeoutHandle) {
|
|
@@ -754,11 +2195,11 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
754
2195
|
);
|
|
755
2196
|
}, 15 * 1e3);
|
|
756
2197
|
this._loaderStyles();
|
|
757
|
-
this._iframeUrl =
|
|
2198
|
+
this._iframeUrl = createIframeUrl(this);
|
|
758
2199
|
if (this.iframe) {
|
|
759
2200
|
this._updateIframeUrl();
|
|
760
2201
|
}
|
|
761
|
-
this.iframeStyle =
|
|
2202
|
+
this.iframeStyle = calculateIframeStyles(this);
|
|
762
2203
|
}
|
|
763
2204
|
// Set params
|
|
764
2205
|
_setOptions() {
|
|
@@ -816,16 +2257,16 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
816
2257
|
defaultParameters.itemDimensions = this.itemDimensions;
|
|
817
2258
|
}
|
|
818
2259
|
if (this.appServer) {
|
|
819
|
-
this.appServer = this.isWebComponentViewMode() ?
|
|
2260
|
+
this.appServer = this.isWebComponentViewMode() ? removeTrailingSlash(this.appServer) : addTrailingSlash(this.appServer);
|
|
820
2261
|
defaultParameters.appServer = this.appServer;
|
|
821
2262
|
} else {
|
|
822
|
-
this.appServer =
|
|
823
|
-
|
|
2263
|
+
this.appServer = addTrailingSlash(
|
|
2264
|
+
DEFAULT_PARAMETERS.appServer
|
|
824
2265
|
);
|
|
825
2266
|
defaultParameters.appServer = this.appServer;
|
|
826
2267
|
}
|
|
827
2268
|
if (this.apiHost) {
|
|
828
|
-
this.apiHost = this.isWebComponentViewMode() ?
|
|
2269
|
+
this.apiHost = this.isWebComponentViewMode() ? removeTrailingSlash(this.apiHost) : addTrailingSlash(this.apiHost);
|
|
829
2270
|
defaultParameters.apiHost = this.apiHost;
|
|
830
2271
|
} else {
|
|
831
2272
|
this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
|
|
@@ -836,11 +2277,11 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
836
2277
|
return defaultParameters;
|
|
837
2278
|
}
|
|
838
2279
|
_updateIframeUrl() {
|
|
839
|
-
|
|
2280
|
+
updateIframeUrl(this.iframe, this._iframeUrl);
|
|
840
2281
|
}
|
|
841
2282
|
// Setup loader / browser error
|
|
842
2283
|
_setupLoader() {
|
|
843
|
-
const data =
|
|
2284
|
+
const data = getLoader(this);
|
|
844
2285
|
this._loaderMsg = data.loadingMsg;
|
|
845
2286
|
if (data.errorMsg) {
|
|
846
2287
|
this._handleEmbedError({ errorMsg: data.errorMsg }, "browser");
|
|
@@ -858,6 +2299,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
858
2299
|
this.browserErrorMsg = errorMsg;
|
|
859
2300
|
} else {
|
|
860
2301
|
this.dashboardError = true;
|
|
2302
|
+
this.dashboardErrorMsg = errorMsg;
|
|
861
2303
|
this.iframeLoaded = true;
|
|
862
2304
|
}
|
|
863
2305
|
if (this._loadTimeoutHandle) {
|
|
@@ -880,15 +2322,15 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
880
2322
|
_calculateDimAfterDashboardLoaded() {
|
|
881
2323
|
this.dashboardError = false;
|
|
882
2324
|
this._loaderStyles();
|
|
883
|
-
|
|
2325
|
+
_setCalculatedDimensions(this);
|
|
884
2326
|
}
|
|
885
2327
|
// Set loader styles
|
|
886
2328
|
_loaderStyles() {
|
|
887
|
-
this._containerStyle =
|
|
888
|
-
this._loaderStyle =
|
|
889
|
-
this._loadingCircleStyle =
|
|
890
|
-
this._containerLoaderStyle =
|
|
891
|
-
this._lcStyle =
|
|
2329
|
+
this._containerStyle = containerStyles(this);
|
|
2330
|
+
this._loaderStyle = loaderStyles(this);
|
|
2331
|
+
this._loadingCircleStyle = plStyles(this);
|
|
2332
|
+
this._containerLoaderStyle = containerLoaderStyles(this);
|
|
2333
|
+
this._lcStyle = lcStyles(this);
|
|
892
2334
|
}
|
|
893
2335
|
static get styles() {
|
|
894
2336
|
return [dashboardStyles];
|
|
@@ -931,15 +2373,19 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
931
2373
|
</div>
|
|
932
2374
|
`;
|
|
933
2375
|
if (this.isWebComponentViewMode()) {
|
|
934
|
-
toBeRenderedHTML = this.
|
|
935
|
-
|
|
936
|
-
<
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
2376
|
+
toBeRenderedHTML = this.dashboardError ? import_lit2.html`
|
|
2377
|
+
<div id="luzmo-error-${this._containerId}">
|
|
2378
|
+
<h3 class="luzmo-error">${this.dashboardErrorMsg}</h3>
|
|
2379
|
+
</div>
|
|
2380
|
+
` : this.isLibraryLoaded ? import_lit2.html`
|
|
2381
|
+
${this.dashboardId || this.dashboardSlug ? import_lit2.html`
|
|
2382
|
+
<div id="dashboard-wc-container"></div>
|
|
2383
|
+
` : import_lit2.html`
|
|
2384
|
+
<div id="luzmo-error-${this._containerId}">
|
|
2385
|
+
<h3 class="luzmo-error">${this.browserErrorMsg}</h3>
|
|
2386
|
+
</div>
|
|
2387
|
+
`}
|
|
2388
|
+
` : import_lit2.html`${loader}`;
|
|
943
2389
|
} else {
|
|
944
2390
|
toBeRenderedHTML = import_lit2.html`
|
|
945
2391
|
${this.dashboardId || this.dashboardSlug ? import_lit2.html`
|
|
@@ -961,7 +2407,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
961
2407
|
`;
|
|
962
2408
|
}
|
|
963
2409
|
return import_lit2.html`
|
|
964
|
-
<div class="${
|
|
2410
|
+
<div class="${luzmoEmbedContainerClass} ${this.isWebComponentViewMode() ? "" : `${luzmoEmbedContainerClass}-ede`}">
|
|
965
2411
|
<div
|
|
966
2412
|
class="dashboard-container"
|
|
967
2413
|
style=${(0, import_style_map.styleMap)(Object.assign({}, this._containerStyle, {
|
|
@@ -983,10 +2429,10 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
983
2429
|
// Public methods
|
|
984
2430
|
getData(itemId) {
|
|
985
2431
|
if (this.isWebComponentViewMode() && this.dashboardReference) {
|
|
986
|
-
return this.dashboardReference.getData(itemId);
|
|
2432
|
+
return Promise.resolve().then(() => this.dashboardReference.getData(itemId));
|
|
987
2433
|
}
|
|
988
2434
|
if (!this.isWebComponentViewMode()) {
|
|
989
|
-
return
|
|
2435
|
+
return getData(this, this.iframe, itemId);
|
|
990
2436
|
}
|
|
991
2437
|
return Promise.reject();
|
|
992
2438
|
}
|
|
@@ -995,7 +2441,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
995
2441
|
return this.dashboardReference.getFilters();
|
|
996
2442
|
}
|
|
997
2443
|
if (!this.isWebComponentViewMode()) {
|
|
998
|
-
return
|
|
2444
|
+
return getFilters(this, this.iframe);
|
|
999
2445
|
}
|
|
1000
2446
|
return Promise.reject();
|
|
1001
2447
|
}
|
|
@@ -1004,7 +2450,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1004
2450
|
return this.dashboardReference.getInsights(options);
|
|
1005
2451
|
}
|
|
1006
2452
|
if (!this.isWebComponentViewMode()) {
|
|
1007
|
-
return
|
|
2453
|
+
return getInsights(this, this.iframe, options);
|
|
1008
2454
|
}
|
|
1009
2455
|
return Promise.reject(new Error("getInsights is not available: dashboard reference is not ready."));
|
|
1010
2456
|
}
|
|
@@ -1013,7 +2459,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1013
2459
|
return this.dashboardReference.getDashboardContext();
|
|
1014
2460
|
}
|
|
1015
2461
|
if (!this.isWebComponentViewMode()) {
|
|
1016
|
-
return
|
|
2462
|
+
return getDashboardContext(this, this.iframe);
|
|
1017
2463
|
}
|
|
1018
2464
|
return Promise.reject(new Error("getDashboardContext is not available: dashboard reference is not ready."));
|
|
1019
2465
|
}
|
|
@@ -1022,7 +2468,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1022
2468
|
return this.dashboardReference.setSelectedData(itemId, filters);
|
|
1023
2469
|
}
|
|
1024
2470
|
if (!this.isWebComponentViewMode()) {
|
|
1025
|
-
return
|
|
2471
|
+
return setSelectedData(this, this.iframe, itemId, filters);
|
|
1026
2472
|
}
|
|
1027
2473
|
return Promise.reject();
|
|
1028
2474
|
}
|
|
@@ -1033,7 +2479,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1033
2479
|
return this.dashboardReference.setAuthorization(key, token);
|
|
1034
2480
|
}
|
|
1035
2481
|
if (!this.isWebComponentViewMode()) {
|
|
1036
|
-
return
|
|
2482
|
+
return setAuthorization(this, this.iframe, key, token);
|
|
1037
2483
|
}
|
|
1038
2484
|
return Promise.reject();
|
|
1039
2485
|
}
|
|
@@ -1042,7 +2488,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1042
2488
|
return this.dashboardReference.refreshData(itemId);
|
|
1043
2489
|
}
|
|
1044
2490
|
if (!this.isWebComponentViewMode()) {
|
|
1045
|
-
return itemId ?
|
|
2491
|
+
return itemId ? refreshData(this, this.iframe, itemId) : refreshData(this, this.iframe);
|
|
1046
2492
|
}
|
|
1047
2493
|
return Promise.reject();
|
|
1048
2494
|
}
|
|
@@ -1051,7 +2497,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1051
2497
|
return this.dashboardReference.reloadDashboard();
|
|
1052
2498
|
}
|
|
1053
2499
|
if (!this.isWebComponentViewMode()) {
|
|
1054
|
-
return
|
|
2500
|
+
return reloadDashboard(this, this.iframe);
|
|
1055
2501
|
}
|
|
1056
2502
|
return Promise.reject();
|
|
1057
2503
|
}
|
|
@@ -1060,12 +2506,12 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1060
2506
|
return this.dashboardReference.exportDashboard(format);
|
|
1061
2507
|
}
|
|
1062
2508
|
if (!this.isWebComponentViewMode()) {
|
|
1063
|
-
return format ?
|
|
2509
|
+
return format ? exportDashboard(this, this.iframe, format) : exportDashboard(this, this.iframe);
|
|
1064
2510
|
}
|
|
1065
2511
|
return Promise.reject();
|
|
1066
2512
|
}
|
|
1067
2513
|
getAccessibleDashboards() {
|
|
1068
|
-
return
|
|
2514
|
+
return getAccessibleDashboards(this);
|
|
1069
2515
|
}
|
|
1070
2516
|
addFilters(itemId, filters) {
|
|
1071
2517
|
return this.dashboardReference.addFilters(itemId, filters);
|
|
@@ -1093,7 +2539,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1093
2539
|
return this.dashboardReference.setEditMode(editMode);
|
|
1094
2540
|
}
|
|
1095
2541
|
if (!this.isWebComponentViewMode()) {
|
|
1096
|
-
return
|
|
2542
|
+
return setEditMode(this, this.iframe, editMode);
|
|
1097
2543
|
}
|
|
1098
2544
|
return Promise.reject();
|
|
1099
2545
|
}
|
|
@@ -1101,13 +2547,13 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
1101
2547
|
if (this.isWebComponentViewMode() && this.dashboardReference) {
|
|
1102
2548
|
return this.dashboardReference.setPreview(preview);
|
|
1103
2549
|
}
|
|
1104
|
-
return
|
|
2550
|
+
return setPreview(this, this.iframe, preview);
|
|
1105
2551
|
}
|
|
1106
2552
|
sendExportEmail(type, subject, message) {
|
|
1107
2553
|
if (this.isWebComponentViewMode() && this.dashboardReference) {
|
|
1108
2554
|
return this.dashboardReference.sendExportEmail(type, subject, message);
|
|
1109
2555
|
} else if (!this.isWebComponentViewMode()) {
|
|
1110
|
-
return
|
|
2556
|
+
return sendExportEmail(this, this.iframe, type, subject, message);
|
|
1111
2557
|
}
|
|
1112
2558
|
return Promise.reject();
|
|
1113
2559
|
}
|
|
@@ -1119,7 +2565,7 @@ __decorateClass([
|
|
|
1119
2565
|
(0, import_decorators.query)(".dashboard-container")
|
|
1120
2566
|
], LuzmoDashboard.prototype, "container", 2);
|
|
1121
2567
|
__decorateClass([
|
|
1122
|
-
(0, import_decorators.query)(`.${
|
|
2568
|
+
(0, import_decorators.query)(`.${luzmoEmbedContainerClass}`)
|
|
1123
2569
|
], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
|
|
1124
2570
|
__decorateClass([
|
|
1125
2571
|
(0, import_decorators.query)("iframe")
|
|
@@ -1252,6 +2698,9 @@ __decorateClass([
|
|
|
1252
2698
|
__decorateClass([
|
|
1253
2699
|
(0, import_decorators.property)({ attribute: false })
|
|
1254
2700
|
], LuzmoDashboard.prototype, "dashboardError", 2);
|
|
2701
|
+
__decorateClass([
|
|
2702
|
+
(0, import_decorators.property)({ attribute: false })
|
|
2703
|
+
], LuzmoDashboard.prototype, "dashboardErrorMsg", 2);
|
|
1255
2704
|
__decorateClass([
|
|
1256
2705
|
(0, import_decorators.property)({ attribute: false })
|
|
1257
2706
|
], LuzmoDashboard.prototype, "browserNotSupported", 2);
|
|
@@ -1283,7 +2732,6 @@ if (!customElements.get("luzmo-embed-dashboard")) {
|
|
|
1283
2732
|
|
|
1284
2733
|
// libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
|
|
1285
2734
|
var import_dashboard_contents_types = require("@luzmo/dashboard-contents-types");
|
|
1286
|
-
var SharedLib3 = __toESM(require("@luzmo/shared-embed"));
|
|
1287
2735
|
var import_lit3 = require("lit");
|
|
1288
2736
|
var import_decorators2 = require("lit/decorators.js");
|
|
1289
2737
|
var dashboardContentsVersion = import_dashboard_contents_types.CONTENTS_VERSION;
|
|
@@ -1377,7 +2825,7 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1377
2825
|
async firstUpdated(_changedProperties) {
|
|
1378
2826
|
super.firstUpdated(_changedProperties);
|
|
1379
2827
|
if (this.canInitializeVizItem()) {
|
|
1380
|
-
await
|
|
2828
|
+
await loadLibrary(this.appServer, vizItemRemote);
|
|
1381
2829
|
this.createAndAppendElement();
|
|
1382
2830
|
}
|
|
1383
2831
|
}
|
|
@@ -1421,12 +2869,12 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1421
2869
|
}
|
|
1422
2870
|
updateVizItemProperties() {
|
|
1423
2871
|
if (this.chartElement) {
|
|
1424
|
-
for (const key in
|
|
2872
|
+
for (const key in libraryTypeToWebComponentTypeMapping) {
|
|
1425
2873
|
const value = this[key];
|
|
1426
2874
|
if (value) {
|
|
1427
|
-
const attributeValue = ["appServer", "apiHost"].includes(key) ?
|
|
2875
|
+
const attributeValue = ["appServer", "apiHost"].includes(key) ? removeTrailingSlash(value) : value;
|
|
1428
2876
|
this.chartElement.setAttribute(
|
|
1429
|
-
|
|
2877
|
+
libraryTypeToWebComponentTypeMapping[key],
|
|
1430
2878
|
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
1431
2879
|
);
|
|
1432
2880
|
}
|
|
@@ -1436,13 +2884,13 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1436
2884
|
async updated(changedProperties) {
|
|
1437
2885
|
if (this.chartElement) {
|
|
1438
2886
|
for (const [propertyName] of changedProperties.entries()) {
|
|
1439
|
-
const mappedAttributeName =
|
|
2887
|
+
const mappedAttributeName = libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
|
|
1440
2888
|
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
|
|
1441
2889
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1442
2890
|
}
|
|
1443
2891
|
} else {
|
|
1444
2892
|
if (this.canInitializeVizItem()) {
|
|
1445
|
-
await
|
|
2893
|
+
await loadLibrary(this.appServer, vizItemRemote);
|
|
1446
2894
|
this.createAndAppendElement();
|
|
1447
2895
|
}
|
|
1448
2896
|
}
|
|
@@ -1533,7 +2981,6 @@ if (!customElements.get("luzmo-embed-viz-item")) {
|
|
|
1533
2981
|
}
|
|
1534
2982
|
|
|
1535
2983
|
// libs/embed-libs/embed/src/lib/iq-components/luzmo-iq-chat.ts
|
|
1536
|
-
var import_shared_embed = require("@luzmo/shared-embed");
|
|
1537
2984
|
var import_lit4 = require("lit");
|
|
1538
2985
|
var import_decorators3 = require("lit/decorators.js");
|
|
1539
2986
|
var inputMap = {
|
|
@@ -1570,7 +3017,7 @@ var LuzmoIQEmbedChatComponent = class extends import_lit4.LitElement {
|
|
|
1570
3017
|
}
|
|
1571
3018
|
async firstUpdated(_changedProperties) {
|
|
1572
3019
|
super.firstUpdated(_changedProperties);
|
|
1573
|
-
await
|
|
3020
|
+
await loadLibrary(this.calculatedAppServer, "IQApp");
|
|
1574
3021
|
this.createAndAppendElement();
|
|
1575
3022
|
}
|
|
1576
3023
|
get calculatedAppServer() {
|
|
@@ -1593,7 +3040,7 @@ var LuzmoIQEmbedChatComponent = class extends import_lit4.LitElement {
|
|
|
1593
3040
|
for (const key in inputMap) {
|
|
1594
3041
|
const value = this[key];
|
|
1595
3042
|
if (value) {
|
|
1596
|
-
const attributeValue = ["appServer", "apiHost", "aydHost"].includes(key) ?
|
|
3043
|
+
const attributeValue = ["appServer", "apiHost", "aydHost"].includes(key) ? removeTrailingSlash(value) : value;
|
|
1597
3044
|
this.chartElement.setAttribute(
|
|
1598
3045
|
inputMap[key],
|
|
1599
3046
|
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
@@ -1615,7 +3062,7 @@ var LuzmoIQEmbedChatComponent = class extends import_lit4.LitElement {
|
|
|
1615
3062
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1616
3063
|
}
|
|
1617
3064
|
} else {
|
|
1618
|
-
await
|
|
3065
|
+
await loadLibrary(this.calculatedAppServer, "IQApp");
|
|
1619
3066
|
this.createAndAppendElement();
|
|
1620
3067
|
}
|
|
1621
3068
|
}
|
|
@@ -1705,7 +3152,6 @@ if (!customElements.get(embedChatTag)) {
|
|
|
1705
3152
|
// libs/embed-libs/embed/src/lib/iq-components/luzmo-iq-answer.ts
|
|
1706
3153
|
var import_lit5 = require("lit");
|
|
1707
3154
|
var import_decorators4 = require("lit/decorators.js");
|
|
1708
|
-
var import_shared_embed2 = require("@luzmo/shared-embed");
|
|
1709
3155
|
var inputMap2 = {
|
|
1710
3156
|
aiEndPoint: "ai-end-point",
|
|
1711
3157
|
appServer: "app-server",
|
|
@@ -1732,7 +3178,7 @@ var LuzmoIQEmbedAnswerComponent = class extends import_lit5.LitElement {
|
|
|
1732
3178
|
}
|
|
1733
3179
|
async firstUpdated(_changedProperties) {
|
|
1734
3180
|
super.firstUpdated(_changedProperties);
|
|
1735
|
-
await
|
|
3181
|
+
await loadLibrary(this.calculatedAppServer, "IQApp");
|
|
1736
3182
|
this.createAndAppendElement();
|
|
1737
3183
|
}
|
|
1738
3184
|
get calculatedAppServer() {
|
|
@@ -1752,7 +3198,7 @@ var LuzmoIQEmbedAnswerComponent = class extends import_lit5.LitElement {
|
|
|
1752
3198
|
for (const key in inputMap2) {
|
|
1753
3199
|
const value = this[key];
|
|
1754
3200
|
if (value) {
|
|
1755
|
-
const attributeValue = ["appServer", "apiHost"].includes(key) ?
|
|
3201
|
+
const attributeValue = ["appServer", "apiHost"].includes(key) ? removeTrailingSlash(value) : value;
|
|
1756
3202
|
this.chartElement.setAttribute(
|
|
1757
3203
|
inputMap2[key],
|
|
1758
3204
|
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
@@ -1769,7 +3215,7 @@ var LuzmoIQEmbedAnswerComponent = class extends import_lit5.LitElement {
|
|
|
1769
3215
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1770
3216
|
}
|
|
1771
3217
|
} else {
|
|
1772
|
-
await
|
|
3218
|
+
await loadLibrary(this.calculatedAppServer, "IQApp");
|
|
1773
3219
|
this.createAndAppendElement();
|
|
1774
3220
|
}
|
|
1775
3221
|
}
|
|
@@ -1819,7 +3265,7 @@ if (!customElements.get(componentTag)) {
|
|
|
1819
3265
|
customElements.define(componentTag, LuzmoIQEmbedAnswerComponent);
|
|
1820
3266
|
}
|
|
1821
3267
|
|
|
1822
|
-
// libs/embed-libs/embed/src/lib/
|
|
3268
|
+
// libs/embed-libs/embed/src/lib/utils/json-schema-utils.ts
|
|
1823
3269
|
var cachedSchemas = {};
|
|
1824
3270
|
function addJSONSchemas(schemas) {
|
|
1825
3271
|
if (schemas.some((schema) => !schema.$id)) {
|