@luzmo/embed 5.0.6 → 5.0.8
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 +13 -0
- package/README.md +0 -25
- package/index.cjs +1266 -85
- package/index.js +1258 -71
- package/lib/dashboard-component/dashboard-component.d.ts +1 -0
- package/luzmo-embed.min.js +2831 -54
- package/package.json +2 -2
- package/src/index.d.ts +0 -1
- package/src/lib/dashboard-component/dashboard-component.d.ts +0 -91
- package/src/lib/dashboard-component/dashboard-styles.d.ts +0 -1
- package/src/lib/helper/event-bus-handler.d.ts +0 -1
- package/src/lib/luzmo-service.d.ts +0 -6
package/index.js
CHANGED
|
@@ -10,8 +10,1183 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
10
|
return result;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/error.ts
|
|
14
|
+
var _handleError = (errorMessage, parameters) => {
|
|
15
|
+
let message = "The dashboard component encountered an error";
|
|
16
|
+
if (typeof parameters?.dashboardId === "string") {
|
|
17
|
+
message += ` for dashboard with id ${parameters.dashboardId}`;
|
|
18
|
+
}
|
|
19
|
+
if (typeof parameters?.dashboardSlug === "string") {
|
|
20
|
+
message += ` for dashboard with slug ${parameters.dashboardSlug}`;
|
|
21
|
+
}
|
|
22
|
+
if (typeof parameters?.container === "string") {
|
|
23
|
+
message += ` in container ${parameters.container}`;
|
|
24
|
+
}
|
|
25
|
+
if (errorMessage) {
|
|
26
|
+
message += `:
|
|
27
|
+
${errorMessage}`;
|
|
28
|
+
console.error(message);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/browser-check.ts
|
|
33
|
+
var _browserCheck = (dashboardComponent) => {
|
|
34
|
+
let hasError = false;
|
|
35
|
+
let errorMessage = "";
|
|
36
|
+
const document_ = document.body || document.documentElement;
|
|
37
|
+
const style = document_.style;
|
|
38
|
+
const browserCheck = {
|
|
39
|
+
svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
|
|
40
|
+
flexbox: style.webkitFlexWrap === "" || style.flexWrap === "",
|
|
41
|
+
postMessage: !!window.postMessage
|
|
42
|
+
};
|
|
43
|
+
const browserCheckKeys = ["svg", "flexbox", "postMessage"];
|
|
44
|
+
for (const key of browserCheckKeys) {
|
|
45
|
+
if (!browserCheck[key]) {
|
|
46
|
+
hasError = true;
|
|
47
|
+
dashboardComponent.browserNotSupported = dashboardComponent.browserNotSupported || [];
|
|
48
|
+
dashboardComponent.browserNotSupported.push(key);
|
|
49
|
+
errorMessage += `Your browser does not support: ${key}
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const ua = window.navigator.userAgent;
|
|
54
|
+
const msie = ua.includes("MSIE");
|
|
55
|
+
const trident = ua.includes("Trident/");
|
|
56
|
+
if (msie || trident) {
|
|
57
|
+
hasError = true;
|
|
58
|
+
errorMessage = "IE is not supported.";
|
|
59
|
+
}
|
|
60
|
+
if (hasError) {
|
|
61
|
+
_handleError(errorMessage);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/default-parameters.ts
|
|
66
|
+
var DEFAULT_PARAMETERS = {
|
|
67
|
+
appServer: "https://app.luzmo.com/",
|
|
68
|
+
apiHost: "https://api.luzmo.com/",
|
|
69
|
+
dashboardId: null,
|
|
70
|
+
dashboardSlug: null,
|
|
71
|
+
container: null,
|
|
72
|
+
key: null,
|
|
73
|
+
token: null,
|
|
74
|
+
language: "auto",
|
|
75
|
+
qeVersion: null,
|
|
76
|
+
editMode: null,
|
|
77
|
+
screenMode: null,
|
|
78
|
+
switchScreenModeOnResize: true,
|
|
79
|
+
itemId: null,
|
|
80
|
+
mainColor: "",
|
|
81
|
+
accentColor: "",
|
|
82
|
+
itemDimensions: {
|
|
83
|
+
width: "auto",
|
|
84
|
+
height: "auto"
|
|
85
|
+
},
|
|
86
|
+
loaderBackground: "#f9f9f9",
|
|
87
|
+
loaderFontColor: "#5a5a5a",
|
|
88
|
+
loaderSpinnerColor: "rgba(255, 165, 0, 0.7)",
|
|
89
|
+
loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
|
|
90
|
+
timezoneId: null,
|
|
91
|
+
contextId: null
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/extents.ts
|
|
95
|
+
var EXTENTS = [
|
|
96
|
+
{ mode: "mobile", width: [150, 767] },
|
|
97
|
+
{ mode: "tablet", width: [768, 1199] },
|
|
98
|
+
{ mode: "desktop", width: [1200, 1599] },
|
|
99
|
+
{ mode: "largeScreen", width: [1600, 9999] },
|
|
100
|
+
{ mode: "fixed", width: [] }
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/translations.ts
|
|
104
|
+
var TRANSLATIONS = {
|
|
105
|
+
initializing: { en: "Initializing...", nl: "Laden...", fr: "Chargement..." },
|
|
106
|
+
errorDashboard: {
|
|
107
|
+
en: "Oops, we could not load this dashboard!",
|
|
108
|
+
nl: "Oeps, we konden het dashboard niet laden.",
|
|
109
|
+
fr: "Le chargement a echou\xE9."
|
|
110
|
+
},
|
|
111
|
+
errorItem: {
|
|
112
|
+
en: "Oops, we could not load this item!",
|
|
113
|
+
nl: "Oeps, we konden de grafiek niet laden.",
|
|
114
|
+
fr: "Le chargement a echou\xE9."
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var translations_default = TRANSLATIONS;
|
|
118
|
+
|
|
119
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/utils.ts
|
|
120
|
+
var addTrailingSlash = (serverUrl) => {
|
|
121
|
+
if (!serverUrl) {
|
|
122
|
+
return "";
|
|
123
|
+
}
|
|
124
|
+
return serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
|
|
125
|
+
};
|
|
126
|
+
var removeTrailingSlash = (serverUrl) => {
|
|
127
|
+
if (!serverUrl) {
|
|
128
|
+
return "";
|
|
129
|
+
}
|
|
130
|
+
return serverUrl.endsWith("/") ? serverUrl.slice(0, -1) : serverUrl;
|
|
131
|
+
};
|
|
132
|
+
var formatDashboardList = (dashboards, integrationId, user, dashboardComponent) => {
|
|
133
|
+
const combineRights = (securable, user2) => {
|
|
134
|
+
const matchingUser = securable.users.find((u) => u.id === user2.id);
|
|
135
|
+
const securableAccessRights = matchingUser && matchingUser.userAccessRight ? {
|
|
136
|
+
flagRead: matchingUser.userAccessRight.flagRead,
|
|
137
|
+
flagUse: matchingUser.userAccessRight.flagUse,
|
|
138
|
+
flagModify: matchingUser.userAccessRight.flagModify,
|
|
139
|
+
flagOwn: matchingUser.userAccessRight.flagOwn
|
|
140
|
+
} : {
|
|
141
|
+
flagRead: false,
|
|
142
|
+
flagUse: false,
|
|
143
|
+
flagModify: false,
|
|
144
|
+
flagOwn: false
|
|
145
|
+
};
|
|
146
|
+
const groups = securable.groups.filter(
|
|
147
|
+
(group) => user2.userGroups.includes(group.id) || group.public === true
|
|
148
|
+
);
|
|
149
|
+
const groupsAccess = groups.map((group) => {
|
|
150
|
+
if (group.groupAccessRight) {
|
|
151
|
+
return group.groupAccessRight;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
for (const groupAccess of groupsAccess) {
|
|
155
|
+
if (!securableAccessRights.flagRead && groupAccess.flagRead) {
|
|
156
|
+
securableAccessRights.flagRead = groupAccess.flagRead;
|
|
157
|
+
}
|
|
158
|
+
if (!securableAccessRights.flagUse && groupAccess.flagUse) {
|
|
159
|
+
securableAccessRights.flagUse = groupAccess.flagUse;
|
|
160
|
+
}
|
|
161
|
+
if (!securableAccessRights.flagModify && groupAccess.flagModify) {
|
|
162
|
+
securableAccessRights.flagModify = groupAccess.flagModify;
|
|
163
|
+
}
|
|
164
|
+
if (!securableAccessRights.flagOwn && groupAccess.flagOwn) {
|
|
165
|
+
securableAccessRights.flagOwn = groupAccess.flagOwn;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const integrationsAccess = securable.integrations?.length > 0 ? securable.integrations.map((integration) => {
|
|
169
|
+
if (integration.integrationAccessRight) {
|
|
170
|
+
return integration.integrationAccessRight;
|
|
171
|
+
}
|
|
172
|
+
}) : [];
|
|
173
|
+
for (const integrationAccess of integrationsAccess) {
|
|
174
|
+
if (!securableAccessRights.flagRead && integrationAccess.flagRead) {
|
|
175
|
+
securableAccessRights.flagRead = integrationAccess.flagRead;
|
|
176
|
+
}
|
|
177
|
+
if (!securableAccessRights.flagUse && integrationAccess.flagUse) {
|
|
178
|
+
securableAccessRights.flagUse = integrationAccess.flagUse;
|
|
179
|
+
}
|
|
180
|
+
if (!securableAccessRights.flagModify && integrationAccess.flagModify) {
|
|
181
|
+
securableAccessRights.flagModify = integrationAccess.flagModify;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return securableAccessRights;
|
|
185
|
+
};
|
|
186
|
+
const localize = (item, locale) => {
|
|
187
|
+
if (item === null || item === void 0) {
|
|
188
|
+
return "";
|
|
189
|
+
}
|
|
190
|
+
if (typeof item !== "object" || Object.keys(item).length === 0) {
|
|
191
|
+
if (typeof item === "object" && Object.keys(item).length === 0) {
|
|
192
|
+
return "";
|
|
193
|
+
}
|
|
194
|
+
return item;
|
|
195
|
+
}
|
|
196
|
+
let localizedItem;
|
|
197
|
+
localizedItem = locale && item[locale] ? item[locale] : item[Object.keys(item)[0]];
|
|
198
|
+
if (localizedItem === void 0 || localizedItem === null) {
|
|
199
|
+
localizedItem = "";
|
|
200
|
+
}
|
|
201
|
+
return localizedItem;
|
|
202
|
+
};
|
|
203
|
+
const treatedDashboards = [];
|
|
204
|
+
for (const dashboard of dashboards) {
|
|
205
|
+
const treatedDashboard = {
|
|
206
|
+
accessibleBy: [],
|
|
207
|
+
accessRights: combineRights(dashboard, user),
|
|
208
|
+
id: dashboard.id,
|
|
209
|
+
modifiedAt: dashboard.modified_at,
|
|
210
|
+
name: localize(dashboard.name, dashboardComponent.language),
|
|
211
|
+
slug: null,
|
|
212
|
+
tags: dashboard.tags.map((t) => t.tag).sort((t1, t2) => t1.localeCompare(t2))
|
|
213
|
+
};
|
|
214
|
+
const currentIntegration = dashboard.integrations.find(
|
|
215
|
+
(i) => i.id === integrationId
|
|
216
|
+
);
|
|
217
|
+
if (currentIntegration?.integrationAccessRight?.slug) {
|
|
218
|
+
treatedDashboard.slug = currentIntegration.integrationAccessRight.slug;
|
|
219
|
+
}
|
|
220
|
+
const users = dashboard.users.map((u) => ({
|
|
221
|
+
model: "User",
|
|
222
|
+
id: u.id,
|
|
223
|
+
name: localize(u.name, user.locale_id)
|
|
224
|
+
}));
|
|
225
|
+
const groups = dashboard.groups.map((g) => ({
|
|
226
|
+
model: "Group",
|
|
227
|
+
id: g.id,
|
|
228
|
+
name: localize(g.name, user.locale_id) || {}
|
|
229
|
+
}));
|
|
230
|
+
const integrations = dashboard.integrations.map((i) => ({
|
|
231
|
+
model: "Integration",
|
|
232
|
+
id: i.id,
|
|
233
|
+
name: localize(i.name, user.locale_id) || {}
|
|
234
|
+
}));
|
|
235
|
+
treatedDashboard.accessibleBy = [...users, ...groups, ...integrations];
|
|
236
|
+
treatedDashboards.push(treatedDashboard);
|
|
237
|
+
}
|
|
238
|
+
return treatedDashboards;
|
|
239
|
+
};
|
|
240
|
+
var VERSION = "0.0.0-shared-luzmo";
|
|
241
|
+
var sanitizeUrl = (url) => {
|
|
242
|
+
const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
|
|
243
|
+
const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
|
|
244
|
+
const urlSchemeRegex = /^([^:]+):/gm;
|
|
245
|
+
const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
|
|
246
|
+
const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
|
|
247
|
+
if (!url) {
|
|
248
|
+
return "about:blank";
|
|
249
|
+
}
|
|
250
|
+
const sanitizedUrl = url.replaceAll(ctrlCharactersRegex, "").trim();
|
|
251
|
+
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
252
|
+
return sanitizedUrl;
|
|
253
|
+
}
|
|
254
|
+
const urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
|
|
255
|
+
if (!urlSchemeParseResults) {
|
|
256
|
+
return sanitizedUrl;
|
|
257
|
+
}
|
|
258
|
+
const urlScheme = urlSchemeParseResults[0];
|
|
259
|
+
if (invalidPrototcolRegex.test(urlScheme)) {
|
|
260
|
+
return "about:blank";
|
|
261
|
+
}
|
|
262
|
+
return sanitizedUrl;
|
|
263
|
+
};
|
|
264
|
+
var cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
|
|
265
|
+
var isObject = (o) => o && typeof o === "object";
|
|
266
|
+
var defaultsDeep = (target, defaults) => {
|
|
267
|
+
Object.entries(defaults).forEach(([k, v]) => {
|
|
268
|
+
if (k in target) {
|
|
269
|
+
if (target[k] === void 0) {
|
|
270
|
+
target[k] = v;
|
|
271
|
+
} else {
|
|
272
|
+
target[k] = isObject(v) ? defaultsDeep(
|
|
273
|
+
target[k],
|
|
274
|
+
v
|
|
275
|
+
) : target[k];
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
target[k] = v;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
return target;
|
|
282
|
+
};
|
|
283
|
+
var uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(c) {
|
|
284
|
+
const r = Math.random() * 16 | 0;
|
|
285
|
+
const v = c == "x" ? r : r & 3 | 8;
|
|
286
|
+
return v.toString(16);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/iframe-url.ts
|
|
290
|
+
var createIframeUrl = (dashboardContent) => {
|
|
291
|
+
const searchString = [];
|
|
292
|
+
const {
|
|
293
|
+
appServer,
|
|
294
|
+
language,
|
|
295
|
+
qeVersion,
|
|
296
|
+
loaderBackground,
|
|
297
|
+
loaderSpinnerColor,
|
|
298
|
+
loaderSpinnerBackground,
|
|
299
|
+
loaderFontColor,
|
|
300
|
+
screenMode,
|
|
301
|
+
key,
|
|
302
|
+
token,
|
|
303
|
+
timezoneId,
|
|
304
|
+
itemEmbedding,
|
|
305
|
+
itemDimensions,
|
|
306
|
+
dashboardId,
|
|
307
|
+
dashboardSlug,
|
|
308
|
+
itemId,
|
|
309
|
+
mainColor,
|
|
310
|
+
accentColor,
|
|
311
|
+
editMode
|
|
312
|
+
} = dashboardContent.params;
|
|
313
|
+
if (language && language !== "auto") {
|
|
314
|
+
searchString.push("language=" + language);
|
|
315
|
+
}
|
|
316
|
+
if (qeVersion) {
|
|
317
|
+
searchString.push(`qe_version=${qeVersion}`);
|
|
318
|
+
}
|
|
319
|
+
if (loaderBackground) {
|
|
320
|
+
searchString.push(`ldrbg=${loaderBackground}`);
|
|
321
|
+
}
|
|
322
|
+
if (loaderFontColor) {
|
|
323
|
+
searchString.push(`ldrftclr=${loaderFontColor}`);
|
|
324
|
+
}
|
|
325
|
+
if (loaderSpinnerColor) {
|
|
326
|
+
searchString.push(`ldrspclr=${loaderSpinnerColor}`);
|
|
327
|
+
}
|
|
328
|
+
if (loaderSpinnerBackground) {
|
|
329
|
+
searchString.push(`ldrspbg=${loaderSpinnerBackground}`);
|
|
330
|
+
}
|
|
331
|
+
if (mainColor) {
|
|
332
|
+
searchString.push(`mainColor=${mainColor}`);
|
|
333
|
+
}
|
|
334
|
+
if (accentColor) {
|
|
335
|
+
searchString.push(`accentColor=${accentColor}`);
|
|
336
|
+
}
|
|
337
|
+
if (screenMode && screenMode !== "auto") {
|
|
338
|
+
searchString.push("screenMode=" + screenMode);
|
|
339
|
+
}
|
|
340
|
+
if (timezoneId) {
|
|
341
|
+
searchString.push("timezoneId=" + timezoneId);
|
|
342
|
+
}
|
|
343
|
+
if (itemEmbedding && itemDimensions && itemDimensions.width) {
|
|
344
|
+
searchString.push("width=" + itemDimensions.width);
|
|
345
|
+
}
|
|
346
|
+
if (itemEmbedding && itemDimensions && itemDimensions.height) {
|
|
347
|
+
searchString.push("height=" + itemDimensions.height);
|
|
348
|
+
}
|
|
349
|
+
if (editMode) {
|
|
350
|
+
searchString.push("editMode=" + editMode);
|
|
351
|
+
}
|
|
352
|
+
const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
|
|
353
|
+
searchString.push("version=" + (dashboardContent.VERSION || VERSION));
|
|
354
|
+
const iframeUrl = itemEmbedding ? `${appServer}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
|
|
355
|
+
searchString.join("&")
|
|
356
|
+
)}${keyTokenUrlAnchor}` : `${appServer}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
|
|
357
|
+
searchString.join("&")
|
|
358
|
+
)}${keyTokenUrlAnchor}`;
|
|
359
|
+
return sanitizeUrl(iframeUrl);
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/get-loader.ts
|
|
363
|
+
var getLoader = (dashboardComponent) => {
|
|
364
|
+
let errorMsg;
|
|
365
|
+
if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
|
|
366
|
+
dashboardComponent.params.error = true;
|
|
367
|
+
if (dashboardComponent.browserNotSupported) {
|
|
368
|
+
errorMsg = "Browser is not supported.";
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
|
|
372
|
+
return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/promise-dispatch.ts
|
|
376
|
+
function resolvePromise(dashboardComponent, requestId, data) {
|
|
377
|
+
if (dashboardComponent.promises[requestId]) {
|
|
378
|
+
dashboardComponent.promises[requestId].resolve(data);
|
|
379
|
+
delete dashboardComponent.promises[requestId];
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function rejectPromise(dashboardComponent, requestId, data) {
|
|
383
|
+
if (dashboardComponent.promises[requestId]) {
|
|
384
|
+
dashboardComponent.promises[requestId].reject(data);
|
|
385
|
+
delete dashboardComponent.promises[requestId];
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/styles.ts
|
|
390
|
+
function containerStyles(dashboardComponent) {
|
|
391
|
+
const styles = {};
|
|
392
|
+
if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
|
|
393
|
+
styles.background = dashboardComponent.params.loaderBackground;
|
|
394
|
+
}
|
|
395
|
+
return styles;
|
|
396
|
+
}
|
|
397
|
+
function containerLoaderStyles(dashboardComponent) {
|
|
398
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
399
|
+
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
400
|
+
const display = dashboardComponent.iframeLoaded ? "none" : "";
|
|
401
|
+
return {
|
|
402
|
+
display,
|
|
403
|
+
height: `${chartHeightDefined ? height : dashboardComponent.minHeight}px`
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function loaderStyles(dashboardComponent) {
|
|
407
|
+
const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
|
|
408
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
409
|
+
dashboardComponent.loaderSize = 24;
|
|
410
|
+
dashboardComponent.borderWidth = 4;
|
|
411
|
+
dashboardComponent.minHeight = 200;
|
|
412
|
+
const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
413
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
414
|
+
const chartWidthDefined = width !== "auto";
|
|
415
|
+
const chartHeightDefined = height !== "auto";
|
|
416
|
+
return {
|
|
417
|
+
background,
|
|
418
|
+
width: chartWidthDefined ? `${width}px` : "100%",
|
|
419
|
+
height: `${chartHeightDefined ? height : "200"}px`,
|
|
420
|
+
"min-height": chartHeightDefined ? "" : "200px"
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
background
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
function plStyles(dashboardComponent) {
|
|
428
|
+
const {
|
|
429
|
+
loaderSpinnerColor: defaultSpinnerColor,
|
|
430
|
+
loaderSpinnerBackground: defaultSpinnerBackground
|
|
431
|
+
} = DEFAULT_PARAMETERS;
|
|
432
|
+
const spinnerColorBorder = generateBorderStyle(
|
|
433
|
+
dashboardComponent.borderWidth,
|
|
434
|
+
dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
|
|
435
|
+
);
|
|
436
|
+
const spinnerBackgroundBorder = generateBorderStyle(
|
|
437
|
+
dashboardComponent.borderWidth,
|
|
438
|
+
dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
|
|
439
|
+
);
|
|
440
|
+
const size = `${dashboardComponent.loaderSize}px`;
|
|
441
|
+
return {
|
|
442
|
+
"border-top": spinnerColorBorder,
|
|
443
|
+
"border-right": spinnerColorBorder,
|
|
444
|
+
"border-bottom": spinnerBackgroundBorder,
|
|
445
|
+
"border-left": spinnerBackgroundBorder,
|
|
446
|
+
width: size,
|
|
447
|
+
height: size
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function lcStyles(dashboardComponent) {
|
|
451
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
452
|
+
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
453
|
+
const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
|
|
454
|
+
const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
|
|
455
|
+
return {
|
|
456
|
+
padding: `${verticalPadding} 16px`
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function calculateIframeStyles(dashboardComponent) {
|
|
460
|
+
const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
461
|
+
const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
462
|
+
if (dashboardComponent.params.itemEmbedding && height !== "auto") {
|
|
463
|
+
dashboardComponent.iframeHeight = `${height}px`;
|
|
464
|
+
} else if (dashboardComponent.params.itemEmbedding) {
|
|
465
|
+
dashboardComponent.iframeHeight = "200px";
|
|
466
|
+
} else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
|
|
467
|
+
dashboardComponent.iframeHeight = "100%";
|
|
468
|
+
} else {
|
|
469
|
+
dashboardComponent.iframeHeight = "400px";
|
|
470
|
+
}
|
|
471
|
+
dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
|
|
472
|
+
const styles = {
|
|
473
|
+
height: dashboardComponent.iframeHeight,
|
|
474
|
+
width: dashboardComponent.iframeWidth
|
|
475
|
+
};
|
|
476
|
+
if (dashboardComponent.iframeLoaded) {
|
|
477
|
+
styles.opacity = 1;
|
|
478
|
+
} else if (dashboardComponent.error) {
|
|
479
|
+
styles.opacity = 1;
|
|
480
|
+
styles.width = "100%";
|
|
481
|
+
styles.height = "400px";
|
|
482
|
+
} else {
|
|
483
|
+
styles.opacity = 0;
|
|
484
|
+
}
|
|
485
|
+
return styles;
|
|
486
|
+
}
|
|
487
|
+
function generateBorderStyle(borderWidth, color) {
|
|
488
|
+
return `${borderWidth}px solid ${color}`;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/update-iframe-url.ts
|
|
492
|
+
var updateIframeUrl = (iframe, iframeUrl) => {
|
|
493
|
+
if (iframe?.contentWindow) {
|
|
494
|
+
iframe.contentWindow.location.replace(iframeUrl);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
// libs/embed-libs/shared-embed/src/lib/methods/export-dashboard.ts
|
|
499
|
+
var exportDashboard = (dashboardComponent, iframe, format) => {
|
|
500
|
+
const requestId = uuidv4();
|
|
501
|
+
if (iframe?.contentWindow) {
|
|
502
|
+
iframe.contentWindow.postMessage(
|
|
503
|
+
{
|
|
504
|
+
action: "exportDashboard",
|
|
505
|
+
format: format || "png",
|
|
506
|
+
_version: dashboardComponent.VERSION,
|
|
507
|
+
requestId
|
|
508
|
+
},
|
|
509
|
+
"*"
|
|
510
|
+
);
|
|
511
|
+
return new Promise((resolve, reject) => {
|
|
512
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
513
|
+
setTimeout(() => {
|
|
514
|
+
if (dashboardComponent.promises[requestId]) {
|
|
515
|
+
const errorMessage = "exportDashboard request timed out.";
|
|
516
|
+
dashboardComponent.promises[requestId].reject(
|
|
517
|
+
new Error(errorMessage)
|
|
518
|
+
);
|
|
519
|
+
delete dashboardComponent.promises[requestId];
|
|
520
|
+
}
|
|
521
|
+
}, 12e5);
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
// libs/embed-libs/shared-embed/src/lib/methods/get-accessible-dashboards.ts
|
|
528
|
+
var getAccessibleDashboards = (dashboardComponent, iframe) => {
|
|
529
|
+
if ((dashboardComponent.dashboardId || dashboardComponent.dashboardSlug) && iframe?.contentWindow) {
|
|
530
|
+
const requestId = uuidv4();
|
|
531
|
+
iframe.contentWindow.postMessage(
|
|
532
|
+
{
|
|
533
|
+
action: "getAccessibleDashboards",
|
|
534
|
+
_version: dashboardComponent.VERSION,
|
|
535
|
+
requestId
|
|
536
|
+
},
|
|
537
|
+
"*"
|
|
538
|
+
);
|
|
539
|
+
return new Promise((resolve, reject) => {
|
|
540
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
541
|
+
setTimeout(() => {
|
|
542
|
+
if (dashboardComponent.promises[requestId]) {
|
|
543
|
+
const errorMessage = "getAccessibleDashboards request timed out.";
|
|
544
|
+
dashboardComponent.promises[requestId].reject(
|
|
545
|
+
new Error(errorMessage)
|
|
546
|
+
);
|
|
547
|
+
delete dashboardComponent.promises[requestId];
|
|
548
|
+
}
|
|
549
|
+
}, 2e3);
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
const fetchUser = new Promise((resolve, reject) => {
|
|
553
|
+
void (() => {
|
|
554
|
+
try {
|
|
555
|
+
const responsePromise = window.fetch(
|
|
556
|
+
`${String(dashboardComponent.params.apiHost)}0.1.0/authorization`,
|
|
557
|
+
{
|
|
558
|
+
method: "POST",
|
|
559
|
+
mode: "cors",
|
|
560
|
+
cache: "no-cache",
|
|
561
|
+
headers: { "Content-Type": "application/json" },
|
|
562
|
+
redirect: "follow",
|
|
563
|
+
body: JSON.stringify({
|
|
564
|
+
action: "get",
|
|
565
|
+
version: "0.1.0",
|
|
566
|
+
key: dashboardComponent.authKey,
|
|
567
|
+
token: dashboardComponent.authToken,
|
|
568
|
+
find: {
|
|
569
|
+
where: { id: dashboardComponent.authKey },
|
|
570
|
+
attributes: ["id", "integration_id"],
|
|
571
|
+
include: [
|
|
572
|
+
{
|
|
573
|
+
model: "User",
|
|
574
|
+
attributes: ["id", "name", "locale_id"],
|
|
575
|
+
include: [{ model: "Group" }]
|
|
576
|
+
}
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
})
|
|
580
|
+
}
|
|
581
|
+
);
|
|
582
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
583
|
+
if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user || !data.rows[0].integration_id) {
|
|
584
|
+
reject();
|
|
585
|
+
} else {
|
|
586
|
+
data.rows[0].user.userGroups = data.rows[0].user.groups.map(
|
|
587
|
+
(group) => group.id
|
|
588
|
+
);
|
|
589
|
+
delete data.rows[0].user.groups;
|
|
590
|
+
resolve({
|
|
591
|
+
integrationId: data.rows[0].integration_id,
|
|
592
|
+
user: data.rows[0].user
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
} catch (error) {
|
|
597
|
+
reject(error);
|
|
598
|
+
}
|
|
599
|
+
})();
|
|
600
|
+
});
|
|
601
|
+
return new Promise((resolve, reject) => void (() => {
|
|
602
|
+
try {
|
|
603
|
+
fetchUser.then((authorizationData) => {
|
|
604
|
+
const responsePromise = window.fetch(
|
|
605
|
+
`${String(dashboardComponent.params.apiHost)}0.1.0/securable`,
|
|
606
|
+
{
|
|
607
|
+
method: "POST",
|
|
608
|
+
mode: "cors",
|
|
609
|
+
cache: "no-cache",
|
|
610
|
+
headers: { "Content-Type": "application/json" },
|
|
611
|
+
redirect: "follow",
|
|
612
|
+
body: JSON.stringify({
|
|
613
|
+
action: "get",
|
|
614
|
+
version: "0.1.0",
|
|
615
|
+
key: dashboardComponent.authKey,
|
|
616
|
+
token: dashboardComponent.authToken,
|
|
617
|
+
find: {
|
|
618
|
+
where: { type: "dashboard", is_variant: false },
|
|
619
|
+
attributes: ["id", "name", "modified_at"],
|
|
620
|
+
order: [["modified_at", "desc"]],
|
|
621
|
+
include: [
|
|
622
|
+
{ model: "Tag", attributes: ["tag"] },
|
|
623
|
+
{ model: "User", attributes: ["id", "name"] },
|
|
624
|
+
{
|
|
625
|
+
model: "Group",
|
|
626
|
+
attributes: ["id", "name", "public"]
|
|
627
|
+
},
|
|
628
|
+
{ model: "Integration", attributes: ["id", "name"] }
|
|
629
|
+
]
|
|
630
|
+
}
|
|
631
|
+
})
|
|
632
|
+
}
|
|
633
|
+
);
|
|
634
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
635
|
+
const dashboardList = data.rows.length > 0 ? formatDashboardList(
|
|
636
|
+
data.rows,
|
|
637
|
+
authorizationData.integrationId,
|
|
638
|
+
authorizationData.user,
|
|
639
|
+
dashboardComponent
|
|
640
|
+
) : [];
|
|
641
|
+
resolve(dashboardList);
|
|
642
|
+
});
|
|
643
|
+
}).catch((error) => {
|
|
644
|
+
reject(error);
|
|
645
|
+
});
|
|
646
|
+
} catch (error) {
|
|
647
|
+
reject(error);
|
|
648
|
+
}
|
|
649
|
+
})());
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
// libs/embed-libs/shared-embed/src/lib/methods/get-data.ts
|
|
653
|
+
var getData = (dashboardComponent, iframe, itemId) => {
|
|
654
|
+
if (iframe?.contentWindow) {
|
|
655
|
+
const requestId = uuidv4();
|
|
656
|
+
iframe.contentWindow.postMessage(
|
|
657
|
+
{
|
|
658
|
+
action: "getData",
|
|
659
|
+
id: itemId,
|
|
660
|
+
_version: dashboardComponent.VERSION,
|
|
661
|
+
requestId
|
|
662
|
+
},
|
|
663
|
+
"*"
|
|
664
|
+
);
|
|
665
|
+
return new Promise((resolve, reject) => {
|
|
666
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
667
|
+
setTimeout(() => {
|
|
668
|
+
if (dashboardComponent.promises[requestId]) {
|
|
669
|
+
const errorMessage = "getData request timed out.";
|
|
670
|
+
dashboardComponent.promises[requestId].reject(
|
|
671
|
+
new Error(errorMessage)
|
|
672
|
+
);
|
|
673
|
+
delete dashboardComponent.promises[requestId];
|
|
674
|
+
}
|
|
675
|
+
}, 2e3);
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
// libs/embed-libs/shared-embed/src/lib/methods/get-filters.ts
|
|
682
|
+
var getFilters = (dashboardComponent, iframe) => {
|
|
683
|
+
if (iframe?.contentWindow) {
|
|
684
|
+
const requestId = uuidv4();
|
|
685
|
+
iframe.contentWindow.postMessage(
|
|
686
|
+
{ action: "getFilters", _version: dashboardComponent.VERSION, requestId },
|
|
687
|
+
"*"
|
|
688
|
+
);
|
|
689
|
+
return new Promise((resolve, reject) => {
|
|
690
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
691
|
+
setTimeout(() => {
|
|
692
|
+
if (dashboardComponent.promises[requestId]) {
|
|
693
|
+
const errorMessage = "getFilters request timed out.";
|
|
694
|
+
dashboardComponent.promises[requestId].reject(
|
|
695
|
+
new Error(errorMessage)
|
|
696
|
+
);
|
|
697
|
+
delete dashboardComponent.promises[requestId];
|
|
698
|
+
}
|
|
699
|
+
}, 2e3);
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
// libs/embed-libs/shared-embed/src/lib/methods/refresh-data.ts
|
|
706
|
+
var refreshData = (dashboardComponent, iframe, itemId) => {
|
|
707
|
+
if (iframe) {
|
|
708
|
+
iframe.contentWindow.postMessage(
|
|
709
|
+
{
|
|
710
|
+
action: "refreshData",
|
|
711
|
+
id: itemId ?? null,
|
|
712
|
+
_version: dashboardComponent.VERSION
|
|
713
|
+
},
|
|
714
|
+
"*"
|
|
715
|
+
);
|
|
716
|
+
return Promise.resolve();
|
|
717
|
+
}
|
|
718
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
// libs/embed-libs/shared-embed/src/lib/methods/reload-dashboard.ts
|
|
722
|
+
var reloadDashboard = (dashboardComponent, iframe) => {
|
|
723
|
+
if (iframe) {
|
|
724
|
+
iframe.contentWindow.postMessage(
|
|
725
|
+
{ action: "reloadDashboard", _version: dashboardComponent.VERSION },
|
|
726
|
+
"*"
|
|
727
|
+
);
|
|
728
|
+
return Promise.resolve();
|
|
729
|
+
}
|
|
730
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// libs/embed-libs/shared-embed/src/lib/methods/set-authorization.ts
|
|
734
|
+
var setAuthorization = (dashboardComponent, iframe, key, token) => {
|
|
735
|
+
if (iframe) {
|
|
736
|
+
iframe.contentWindow.postMessage(
|
|
737
|
+
{
|
|
738
|
+
action: "setAuthorization",
|
|
739
|
+
key,
|
|
740
|
+
token,
|
|
741
|
+
_version: dashboardComponent.VERSION
|
|
742
|
+
},
|
|
743
|
+
"*"
|
|
744
|
+
);
|
|
745
|
+
return Promise.resolve();
|
|
746
|
+
}
|
|
747
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
// libs/embed-libs/shared-embed/src/lib/methods/set-edit-mode.ts
|
|
751
|
+
var setEditMode = (dashboardComponent, iframe, editMode) => {
|
|
752
|
+
if (iframe && iframe.contentWindow) {
|
|
753
|
+
const requestId = uuidv4();
|
|
754
|
+
if (dashboardComponent.params.editMode === editMode) {
|
|
755
|
+
return Promise.reject(
|
|
756
|
+
new Error("editMode parameter is currently already set to " + editMode)
|
|
757
|
+
);
|
|
758
|
+
} else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
|
|
759
|
+
return Promise.reject(
|
|
760
|
+
new Error(
|
|
761
|
+
"The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
|
|
762
|
+
)
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
iframe.contentWindow.postMessage(
|
|
766
|
+
{
|
|
767
|
+
action: "setEditMode",
|
|
768
|
+
editMode,
|
|
769
|
+
_version: dashboardComponent.VERSION,
|
|
770
|
+
requestId
|
|
771
|
+
},
|
|
772
|
+
"*"
|
|
773
|
+
);
|
|
774
|
+
return new Promise((resolve, reject) => {
|
|
775
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
// libs/embed-libs/shared-embed/src/lib/methods/set-filters.ts
|
|
782
|
+
var setFilters = (dashboardComponent, iframe, itemId, filters) => {
|
|
783
|
+
if (iframe) {
|
|
784
|
+
const requestId = uuidv4();
|
|
785
|
+
iframe.contentWindow.postMessage(
|
|
786
|
+
{
|
|
787
|
+
action: "setFilters",
|
|
788
|
+
itemId,
|
|
789
|
+
filters,
|
|
790
|
+
_version: dashboardComponent.VERSION,
|
|
791
|
+
requestId
|
|
792
|
+
},
|
|
793
|
+
"*"
|
|
794
|
+
);
|
|
795
|
+
return new Promise((resolve, reject) => {
|
|
796
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
797
|
+
setTimeout(() => {
|
|
798
|
+
if (dashboardComponent.promises[requestId]) {
|
|
799
|
+
const errorMessage = "setFilters request timed out.";
|
|
800
|
+
dashboardComponent.promises[requestId].reject(
|
|
801
|
+
new Error(errorMessage)
|
|
802
|
+
);
|
|
803
|
+
delete dashboardComponent.promises[requestId];
|
|
804
|
+
}
|
|
805
|
+
}, 2e3);
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
return Promise.reject();
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
// libs/embed-libs/shared-embed/src/lib/methods/set-preview.ts
|
|
812
|
+
var setPreview = (dashboardComponent, iframe, preview) => {
|
|
813
|
+
if (iframe) {
|
|
814
|
+
const requestId = uuidv4();
|
|
815
|
+
iframe.contentWindow.postMessage(
|
|
816
|
+
{
|
|
817
|
+
action: "setPreview",
|
|
818
|
+
preview,
|
|
819
|
+
requestId,
|
|
820
|
+
_version: dashboardComponent.VERSION
|
|
821
|
+
},
|
|
822
|
+
"*"
|
|
823
|
+
);
|
|
824
|
+
return new Promise((resolve, reject) => {
|
|
825
|
+
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
826
|
+
setTimeout(() => {
|
|
827
|
+
if (dashboardComponent.promises[requestId]) {
|
|
828
|
+
const errorMessage = "setPreview request timed out.";
|
|
829
|
+
dashboardComponent.promises[requestId].reject(
|
|
830
|
+
new Error(errorMessage)
|
|
831
|
+
);
|
|
832
|
+
delete dashboardComponent.promises[requestId];
|
|
833
|
+
}
|
|
834
|
+
}, 2e3);
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
// libs/embed-libs/shared-embed/src/lib/service/calculate-dimensions.ts
|
|
841
|
+
var _setCalculatedDimensions = (dashboardComponent) => {
|
|
842
|
+
if (!dashboardComponent.dimensions) {
|
|
843
|
+
dashboardComponent.params.error = true;
|
|
844
|
+
_handleError("Got no valid dimensions.", dashboardComponent.params);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
const dashboardDimensionKeys = Object.keys(
|
|
848
|
+
dashboardComponent.dimensions
|
|
849
|
+
);
|
|
850
|
+
const availableScreenModeExtents = [];
|
|
851
|
+
let currentMode;
|
|
852
|
+
let currentWidth = 0;
|
|
853
|
+
let currentHeight = 0;
|
|
854
|
+
if (!dashboardComponent.params.switchScreenModeOnResize && dashboardComponent.currentScreenMode) {
|
|
855
|
+
dashboardComponent.params.screenMode = dashboardComponent.currentScreenMode;
|
|
856
|
+
}
|
|
857
|
+
if (dashboardComponent.dimensions && dashboardDimensionKeys?.[0] === "fixed") {
|
|
858
|
+
currentMode = "fixed";
|
|
859
|
+
currentWidth = dashboardComponent.dimensions.fixed[0];
|
|
860
|
+
currentHeight = dashboardComponent.dimensions.fixed[1];
|
|
861
|
+
} else {
|
|
862
|
+
const screenModes = [
|
|
863
|
+
"mobile",
|
|
864
|
+
"tablet",
|
|
865
|
+
"desktop",
|
|
866
|
+
"largeScreen"
|
|
867
|
+
];
|
|
868
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
869
|
+
const [firstMatch] = dashboardDimensionKeys;
|
|
870
|
+
let match = cloneDeep(firstMatch);
|
|
871
|
+
for (const screenMode of screenModes) {
|
|
872
|
+
const found = dashboardDimensionKeys.find((key) => key === screenMode);
|
|
873
|
+
if (found) {
|
|
874
|
+
match = cloneDeep(found);
|
|
875
|
+
} else {
|
|
876
|
+
dashboardComponent.dimensions[screenMode] = dashboardComponent.dimensions[match];
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
for (const key of dashboardDimensionKeys) {
|
|
881
|
+
if (screenModes.includes(key)) {
|
|
882
|
+
const screenMode = EXTENTS.find((extent) => extent.mode === key);
|
|
883
|
+
availableScreenModeExtents.push({
|
|
884
|
+
...screenMode,
|
|
885
|
+
height: dashboardComponent.dimensions[key][1] || 50
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
if (!availableScreenModeExtents.map((screenModeExtent) => screenModeExtent.mode).includes(dashboardComponent.params.screenMode)) {
|
|
890
|
+
dashboardComponent.params.screenMode = "auto";
|
|
891
|
+
}
|
|
892
|
+
if (dashboardComponent.params.screenMode === "auto") {
|
|
893
|
+
availableScreenModeExtents.sort(
|
|
894
|
+
(a, b) => screenModes.indexOf(a.mode) - screenModes.indexOf(b.mode)
|
|
895
|
+
);
|
|
896
|
+
for (const screenModeExtent of availableScreenModeExtents) {
|
|
897
|
+
const [screenModeExtentMinWidth, screenModeExtentMaxWidth] = screenModeExtent.width;
|
|
898
|
+
if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
899
|
+
if (screenModeExtentMinWidth < dashboardComponent.params.itemDimensions.width) {
|
|
900
|
+
currentMode = screenModeExtent.mode;
|
|
901
|
+
currentWidth = Number.parseInt(
|
|
902
|
+
dashboardComponent.params.itemDimensions.width,
|
|
903
|
+
10
|
|
904
|
+
);
|
|
905
|
+
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
906
|
+
}
|
|
907
|
+
} else {
|
|
908
|
+
if (screenModeExtentMinWidth < dashboardComponent.containerWidth) {
|
|
909
|
+
currentMode = screenModeExtent.mode;
|
|
910
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
911
|
+
currentWidth = dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto" ? Number.parseInt(
|
|
912
|
+
dashboardComponent.params.itemDimensions.width,
|
|
913
|
+
10
|
|
914
|
+
) : Math.min(
|
|
915
|
+
dashboardComponent.containerWidth,
|
|
916
|
+
screenModeExtentMaxWidth
|
|
917
|
+
);
|
|
918
|
+
currentHeight = dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto" ? Number.parseInt(
|
|
919
|
+
dashboardComponent.params.itemDimensions.height,
|
|
920
|
+
10
|
|
921
|
+
) : dashboardComponent.dimensions[currentMode][1];
|
|
922
|
+
if (dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
923
|
+
currentWidth = Number.parseInt(
|
|
924
|
+
dashboardComponent.params.itemDimensions.width,
|
|
925
|
+
10
|
|
926
|
+
);
|
|
927
|
+
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
928
|
+
}
|
|
929
|
+
} else {
|
|
930
|
+
currentWidth = Math.max(
|
|
931
|
+
Math.min(
|
|
932
|
+
screenModeExtentMaxWidth,
|
|
933
|
+
dashboardComponent.containerWidth
|
|
934
|
+
),
|
|
935
|
+
screenModeExtentMinWidth
|
|
936
|
+
);
|
|
937
|
+
currentHeight = screenModeExtent.height;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
} else {
|
|
943
|
+
const {
|
|
944
|
+
height: chosenModeHeight,
|
|
945
|
+
width: [chosenModeMinWidth, chosenModeMaxWidth]
|
|
946
|
+
} = availableScreenModeExtents.find(
|
|
947
|
+
(d) => d.mode === dashboardComponent.params.screenMode
|
|
948
|
+
);
|
|
949
|
+
currentMode = dashboardComponent.params.screenMode;
|
|
950
|
+
currentWidth = Math.max(
|
|
951
|
+
Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
|
|
952
|
+
chosenModeMinWidth
|
|
953
|
+
);
|
|
954
|
+
currentHeight = chosenModeHeight;
|
|
955
|
+
if (dashboardComponent.params.itemEmbedding) {
|
|
956
|
+
if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
|
|
957
|
+
currentWidth = Number.parseInt(
|
|
958
|
+
dashboardComponent.params.itemDimensions.width,
|
|
959
|
+
10
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
if (dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto") {
|
|
963
|
+
currentHeight = Number.parseInt(
|
|
964
|
+
dashboardComponent.params.itemDimensions.height,
|
|
965
|
+
10
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
if (!currentMode && availableScreenModeExtents.length > 0) {
|
|
971
|
+
const [lowestModeExtent] = availableScreenModeExtents;
|
|
972
|
+
currentMode = lowestModeExtent.mode;
|
|
973
|
+
currentWidth = lowestModeExtent.width[0];
|
|
974
|
+
currentHeight = lowestModeExtent.height;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
dashboardComponent.currentScreenMode = currentMode;
|
|
978
|
+
const style = {
|
|
979
|
+
height: currentHeight === 0 ? "100%" : `${String(currentHeight)}px`,
|
|
980
|
+
width: currentWidth === 0 ? "100%" : `${String(currentWidth)}px`,
|
|
981
|
+
opacity: 1
|
|
982
|
+
};
|
|
983
|
+
const dashboardEditModes = ["editFull", "editLimited"];
|
|
984
|
+
if (dashboardEditModes.includes(dashboardComponent.params.editMode)) {
|
|
985
|
+
style.height = "100%";
|
|
986
|
+
style.width = "100%";
|
|
987
|
+
} else if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions) {
|
|
988
|
+
style.height = dashboardComponent.params.itemDimensions.height === "auto" ? style.height : `${String(dashboardComponent.params.itemDimensions.height).replace(
|
|
989
|
+
"px",
|
|
990
|
+
""
|
|
991
|
+
)}px`;
|
|
992
|
+
style.width = dashboardComponent.params.itemDimensions.width === "auto" ? style.width : `${String(dashboardComponent.params.itemDimensions.width).replace(
|
|
993
|
+
"px",
|
|
994
|
+
""
|
|
995
|
+
)}px`;
|
|
996
|
+
} else {
|
|
997
|
+
style.height = currentHeight === 0 ? "100%" : `${String(currentHeight)}px`;
|
|
998
|
+
style.width = currentWidth === 0 ? "100%" : `${String(currentWidth)}px`;
|
|
999
|
+
}
|
|
1000
|
+
dashboardComponent.currentScreenMode = currentMode;
|
|
1001
|
+
dashboardComponent.iframeStyle = style;
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
// libs/embed-libs/shared-embed/src/lib/service/extend-and-validate.ts
|
|
1005
|
+
var _extendAndValidate = (dashboardContent) => {
|
|
1006
|
+
const defaultKeys = Object.keys(
|
|
1007
|
+
DEFAULT_PARAMETERS
|
|
1008
|
+
);
|
|
1009
|
+
const errorMessages = [];
|
|
1010
|
+
const requiredStringParams = [
|
|
1011
|
+
"appServer",
|
|
1012
|
+
"language",
|
|
1013
|
+
"apiHost"
|
|
1014
|
+
];
|
|
1015
|
+
const requiredStringOrEmptyParams = [
|
|
1016
|
+
"key",
|
|
1017
|
+
"token",
|
|
1018
|
+
"screenMode",
|
|
1019
|
+
"timezoneId",
|
|
1020
|
+
"itemId",
|
|
1021
|
+
"container",
|
|
1022
|
+
"loaderBackground",
|
|
1023
|
+
"loaderFontColor",
|
|
1024
|
+
"loaderSpinnerColor",
|
|
1025
|
+
"loaderSpinnerBackground"
|
|
1026
|
+
];
|
|
1027
|
+
const objectParams = ["itemDimensions"];
|
|
1028
|
+
const screenModes = [
|
|
1029
|
+
"mobile",
|
|
1030
|
+
"tablet",
|
|
1031
|
+
"desktop",
|
|
1032
|
+
"largeScreen",
|
|
1033
|
+
"fixed",
|
|
1034
|
+
"auto"
|
|
1035
|
+
];
|
|
1036
|
+
for (const key of defaultKeys) {
|
|
1037
|
+
if (dashboardContent.params[key] === null) {
|
|
1038
|
+
delete dashboardContent.params[key];
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
dashboardContent.params = defaultsDeep(
|
|
1042
|
+
dashboardContent.params,
|
|
1043
|
+
DEFAULT_PARAMETERS
|
|
1044
|
+
);
|
|
1045
|
+
if ((!dashboardContent.params.dashboardId || typeof dashboardContent.params.dashboardId !== "string") && (!dashboardContent.params.dashboardSlug || typeof dashboardContent.params.dashboardSlug !== "string")) {
|
|
1046
|
+
delete dashboardContent.params.dashboardId;
|
|
1047
|
+
delete dashboardContent.params.dashboardSlug;
|
|
1048
|
+
}
|
|
1049
|
+
for (const key of requiredStringParams) {
|
|
1050
|
+
if (typeof dashboardContent.params[key] !== "string") {
|
|
1051
|
+
delete dashboardContent.params[key];
|
|
1052
|
+
errorMessages.push(`${key} needs to be of type string.`);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
for (const key of requiredStringOrEmptyParams) {
|
|
1056
|
+
if (typeof dashboardContent.params[key] !== "string" && dashboardContent.params[key] !== null && dashboardContent.params[key] !== void 0) {
|
|
1057
|
+
delete dashboardContent.params[key];
|
|
1058
|
+
errorMessages.push(`${key} needs to be of type string or empty.`);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
if (dashboardContent.params.screenMode && !screenModes.includes(dashboardContent.params.screenMode)) {
|
|
1062
|
+
const validTypesString = screenModes.map((mode) => `"${mode}"`).join(", ");
|
|
1063
|
+
errorMessages.push(
|
|
1064
|
+
`"screenMode" needs should be one of these types: ${validTypesString}`
|
|
1065
|
+
);
|
|
1066
|
+
dashboardContent.params.screenMode = "auto";
|
|
1067
|
+
}
|
|
1068
|
+
if (dashboardContent.params.itemId) {
|
|
1069
|
+
dashboardContent.params.itemEmbedding = true;
|
|
1070
|
+
}
|
|
1071
|
+
for (const key of objectParams) {
|
|
1072
|
+
if (typeof dashboardContent.params[key] !== "object" && dashboardContent.params[key] !== null) {
|
|
1073
|
+
delete dashboardContent.params[key];
|
|
1074
|
+
errorMessages.push(`${key} needs to be of type object or empty.`);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
if (typeof dashboardContent.params.switchScreenModeOnResize !== "boolean") {
|
|
1078
|
+
errorMessages.push("switchScreenModeOnResize needs to be of type boolean.");
|
|
1079
|
+
dashboardContent.params.switchScreenModeOnResize = true;
|
|
1080
|
+
}
|
|
1081
|
+
if (dashboardContent.params.itemDimensions) {
|
|
1082
|
+
const itemDimensionsKeys = [
|
|
1083
|
+
"width",
|
|
1084
|
+
"height"
|
|
1085
|
+
];
|
|
1086
|
+
for (const key of itemDimensionsKeys) {
|
|
1087
|
+
if (!["string", "number"].includes(
|
|
1088
|
+
typeof dashboardContent.params.itemDimensions[key]
|
|
1089
|
+
) && dashboardContent.params.itemDimensions[key] !== null) {
|
|
1090
|
+
errorMessages.push(
|
|
1091
|
+
`itemDimensions ${key} needs to be of type string, number or empty.`
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
dashboardContent.params = defaultsDeep(
|
|
1097
|
+
dashboardContent.params,
|
|
1098
|
+
DEFAULT_PARAMETERS
|
|
1099
|
+
);
|
|
1100
|
+
if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
|
|
1101
|
+
dashboardContent.params.switchScreenModeOnResize = false;
|
|
1102
|
+
}
|
|
1103
|
+
if (dashboardContent.params.itemDimensions.width !== "auto") {
|
|
1104
|
+
dashboardContent.params.itemDimensions.width = Number.parseInt(
|
|
1105
|
+
`${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
|
|
1106
|
+
10
|
|
1107
|
+
) || "auto";
|
|
1108
|
+
}
|
|
1109
|
+
if (dashboardContent.params.itemDimensions.height !== "auto") {
|
|
1110
|
+
dashboardContent.params.itemDimensions.height = Number.parseInt(
|
|
1111
|
+
`${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
|
|
1112
|
+
10
|
|
1113
|
+
) || "auto";
|
|
1114
|
+
}
|
|
1115
|
+
dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
|
|
1116
|
+
if (dashboardContent.params.error || errorMessages.length > 0) {
|
|
1117
|
+
_handleError(errorMessages.join("\n"), dashboardContent.params);
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
// libs/embed-libs/shared-embed/src/lib/constants/class-constants.ts
|
|
1122
|
+
var luzmoEmbedContainerClass = "luzmo-embed-container";
|
|
1123
|
+
|
|
1124
|
+
// libs/embed-libs/shared-embed/src/lib/helpers/remote-federation.ts
|
|
1125
|
+
var remotesMap = {
|
|
1126
|
+
// "remote_app": { url: "http://localhost:4201/remoteEntry.mjs", format: "esm", from: "vite" },
|
|
1127
|
+
};
|
|
1128
|
+
var loadJS = async (url, fn) => {
|
|
1129
|
+
const resolvedUrl = typeof url === "function" ? await url() : url;
|
|
1130
|
+
const script = document.createElement("script");
|
|
1131
|
+
script.type = "text/javascript";
|
|
1132
|
+
script.addEventListener("load", fn);
|
|
1133
|
+
script.src = resolvedUrl;
|
|
1134
|
+
document.querySelectorAll("head")[0].append(script);
|
|
1135
|
+
};
|
|
1136
|
+
var wrapShareModule = (remoteFrom) => ({});
|
|
1137
|
+
async function __federationMethodEnsure(remoteId) {
|
|
1138
|
+
const remote = remotesMap[remoteId];
|
|
1139
|
+
if (remote.inited) {
|
|
1140
|
+
return remote.lib;
|
|
1141
|
+
}
|
|
1142
|
+
if (remote.format === "var") {
|
|
1143
|
+
return new Promise((resolve) => {
|
|
1144
|
+
const callback = () => {
|
|
1145
|
+
if (!remote.inited) {
|
|
1146
|
+
remote.lib = window[remoteId];
|
|
1147
|
+
remote.lib.init(wrapShareModule(remote.from));
|
|
1148
|
+
remote.inited = true;
|
|
1149
|
+
}
|
|
1150
|
+
resolve(remote.lib);
|
|
1151
|
+
};
|
|
1152
|
+
return loadJS(remote.url, callback);
|
|
1153
|
+
});
|
|
1154
|
+
} else if (["esm", "systemjs"].includes(remote.format)) {
|
|
1155
|
+
return new Promise((resolve, reject) => {
|
|
1156
|
+
const getUrl = typeof remote.url === "function" ? remote.url : () => Promise.resolve(remote.url);
|
|
1157
|
+
getUrl().then((url) => {
|
|
1158
|
+
import(
|
|
1159
|
+
/* @vite-ignore */
|
|
1160
|
+
/* webpackIgnore: true */
|
|
1161
|
+
url
|
|
1162
|
+
).then((lib) => {
|
|
1163
|
+
if (!remote.inited) {
|
|
1164
|
+
const shareScope = wrapShareModule(remote.from);
|
|
1165
|
+
lib.init(shareScope);
|
|
1166
|
+
remote.lib = lib;
|
|
1167
|
+
remote.lib.init(shareScope);
|
|
1168
|
+
remote.inited = true;
|
|
1169
|
+
}
|
|
1170
|
+
resolve(remote.lib);
|
|
1171
|
+
}).catch(reject);
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
function __federationMethodWrapDefault(module, need) {
|
|
1177
|
+
if (!(module == null ? void 0 : module.default) && need) {
|
|
1178
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
1179
|
+
obj.default = module;
|
|
1180
|
+
obj.__esModule = true;
|
|
1181
|
+
return obj;
|
|
1182
|
+
}
|
|
1183
|
+
return module;
|
|
1184
|
+
}
|
|
1185
|
+
async function __federationMethodGetRemote(remoteName, componentName) {
|
|
1186
|
+
return __federationMethodEnsure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
|
|
1187
|
+
}
|
|
1188
|
+
|
|
13
1189
|
// libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
|
|
14
|
-
import * as SharedLib2 from "@luzmo/shared-embed";
|
|
15
1190
|
import {
|
|
16
1191
|
html,
|
|
17
1192
|
LitElement
|
|
@@ -25,14 +1200,9 @@ import {
|
|
|
25
1200
|
import {
|
|
26
1201
|
styleMap
|
|
27
1202
|
} from "lit/directives/style-map.js";
|
|
28
|
-
import {
|
|
29
|
-
__federationMethodGetRemote,
|
|
30
|
-
__federationMethodWrapDefault,
|
|
31
|
-
remotesMap
|
|
32
|
-
} from "@luzmo/shared-embed";
|
|
33
1203
|
|
|
34
1204
|
// libs/embed-libs/embed/package.json
|
|
35
|
-
var version = "5.0.
|
|
1205
|
+
var version = "5.0.8";
|
|
36
1206
|
|
|
37
1207
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
38
1208
|
var LuzmoService = class {
|
|
@@ -43,7 +1213,6 @@ var LuzmoService = class {
|
|
|
43
1213
|
var luzmo_service_default = new LuzmoService();
|
|
44
1214
|
|
|
45
1215
|
// libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
|
|
46
|
-
import * as SharedLib from "@luzmo/shared-embed";
|
|
47
1216
|
var _setEventHandler = () => {
|
|
48
1217
|
if (typeof window.__luzmoMessageHandler === "function") {
|
|
49
1218
|
return;
|
|
@@ -80,7 +1249,7 @@ var _setEventHandler = () => {
|
|
|
80
1249
|
break;
|
|
81
1250
|
}
|
|
82
1251
|
case "data": {
|
|
83
|
-
|
|
1252
|
+
resolvePromise(
|
|
84
1253
|
dashboardComponent,
|
|
85
1254
|
event.data.requestId,
|
|
86
1255
|
event.data.data
|
|
@@ -88,7 +1257,7 @@ var _setEventHandler = () => {
|
|
|
88
1257
|
break;
|
|
89
1258
|
}
|
|
90
1259
|
case "filters": {
|
|
91
|
-
|
|
1260
|
+
resolvePromise(
|
|
92
1261
|
dashboardComponent,
|
|
93
1262
|
event.data.requestId,
|
|
94
1263
|
event.data.filters
|
|
@@ -96,7 +1265,7 @@ var _setEventHandler = () => {
|
|
|
96
1265
|
break;
|
|
97
1266
|
}
|
|
98
1267
|
case "getAccessibleDashboards": {
|
|
99
|
-
|
|
1268
|
+
resolvePromise(
|
|
100
1269
|
dashboardComponent,
|
|
101
1270
|
event.data.requestId,
|
|
102
1271
|
event.data.accessibleDashboards
|
|
@@ -111,7 +1280,7 @@ var _setEventHandler = () => {
|
|
|
111
1280
|
}
|
|
112
1281
|
case "export": {
|
|
113
1282
|
if (event.data.error) {
|
|
114
|
-
|
|
1283
|
+
rejectPromise(
|
|
115
1284
|
dashboardComponent,
|
|
116
1285
|
event.data.requestId,
|
|
117
1286
|
event.data
|
|
@@ -120,7 +1289,7 @@ var _setEventHandler = () => {
|
|
|
120
1289
|
dashboardComponent.dispatchEvent(
|
|
121
1290
|
new CustomEvent("exported", { detail: { data: event.data } })
|
|
122
1291
|
);
|
|
123
|
-
|
|
1292
|
+
resolvePromise(
|
|
124
1293
|
dashboardComponent,
|
|
125
1294
|
event.data.requestId,
|
|
126
1295
|
event.data
|
|
@@ -150,31 +1319,31 @@ var _setEventHandler = () => {
|
|
|
150
1319
|
}
|
|
151
1320
|
case "setEditMode": {
|
|
152
1321
|
if (event.data.error) {
|
|
153
|
-
|
|
1322
|
+
rejectPromise(
|
|
154
1323
|
dashboardComponent,
|
|
155
1324
|
event.data.requestId,
|
|
156
1325
|
event.data
|
|
157
1326
|
);
|
|
158
1327
|
} else {
|
|
159
|
-
|
|
1328
|
+
resolvePromise(
|
|
160
1329
|
dashboardComponent,
|
|
161
1330
|
event.data.requestId,
|
|
162
1331
|
event.data
|
|
163
1332
|
);
|
|
164
1333
|
dashboardComponent.params.editMode = event.data.editMode;
|
|
165
|
-
dashboardComponent._containerStyle =
|
|
1334
|
+
dashboardComponent._containerStyle = containerStyles(dashboardComponent);
|
|
166
1335
|
if (dashboardComponent.dimensions) {
|
|
167
|
-
|
|
1336
|
+
_setCalculatedDimensions(dashboardComponent);
|
|
168
1337
|
}
|
|
169
1338
|
}
|
|
170
1339
|
break;
|
|
171
1340
|
}
|
|
172
1341
|
case "setFilters": {
|
|
173
|
-
event.data.error ?
|
|
1342
|
+
event.data.error ? rejectPromise(
|
|
174
1343
|
dashboardComponent,
|
|
175
1344
|
event.data.requestId,
|
|
176
1345
|
event.data
|
|
177
|
-
) :
|
|
1346
|
+
) : resolvePromise(
|
|
178
1347
|
dashboardComponent,
|
|
179
1348
|
event.data.requestId,
|
|
180
1349
|
event.data
|
|
@@ -182,11 +1351,11 @@ var _setEventHandler = () => {
|
|
|
182
1351
|
break;
|
|
183
1352
|
}
|
|
184
1353
|
case "setPreview": {
|
|
185
|
-
event.data.error ?
|
|
1354
|
+
event.data.error ? rejectPromise(
|
|
186
1355
|
dashboardComponent,
|
|
187
1356
|
event.data.requestId,
|
|
188
1357
|
event.data
|
|
189
|
-
) :
|
|
1358
|
+
) : resolvePromise(
|
|
190
1359
|
dashboardComponent,
|
|
191
1360
|
event.data.requestId,
|
|
192
1361
|
event.data
|
|
@@ -350,7 +1519,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
350
1519
|
this.loaderSize = 32;
|
|
351
1520
|
this.borderWidth = 3;
|
|
352
1521
|
this.minHeight = 400;
|
|
353
|
-
this._containerId =
|
|
1522
|
+
this._containerId = uuidv4();
|
|
354
1523
|
this._iframeId = `luzmo-dashboard-${this._containerId}`;
|
|
355
1524
|
this.iframeLoaded = false;
|
|
356
1525
|
this.promises = {};
|
|
@@ -358,9 +1527,9 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
358
1527
|
this.params = this._setOptions();
|
|
359
1528
|
this._onResize = () => {
|
|
360
1529
|
if (this.shadowRoot?.querySelector(".dashboard-container")) {
|
|
361
|
-
this.containerWidth = this.
|
|
1530
|
+
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
362
1531
|
if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
|
|
363
|
-
for (const d of
|
|
1532
|
+
for (const d of EXTENTS) {
|
|
364
1533
|
if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
|
|
365
1534
|
this.currentScreenMode = d.mode;
|
|
366
1535
|
}
|
|
@@ -368,6 +1537,11 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
368
1537
|
}
|
|
369
1538
|
if (this.iframeLoaded) {
|
|
370
1539
|
this._calculateDimAfterDashboardLoaded();
|
|
1540
|
+
} else {
|
|
1541
|
+
if (this.dimensions) {
|
|
1542
|
+
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
1543
|
+
_setCalculatedDimensions(this);
|
|
1544
|
+
}
|
|
371
1545
|
}
|
|
372
1546
|
}
|
|
373
1547
|
};
|
|
@@ -384,7 +1558,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
384
1558
|
if (remotesMap[appServer]) {
|
|
385
1559
|
return Promise.resolve(remotesMap[appServer].module);
|
|
386
1560
|
}
|
|
387
|
-
remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${
|
|
1561
|
+
remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
|
|
388
1562
|
return __federationMethodGetRemote(appServer, "./DashboardApp").then((module) => {
|
|
389
1563
|
const wrappedModule = __federationMethodWrapDefault(module, true);
|
|
390
1564
|
remotesMap[appServer].module = wrappedModule;
|
|
@@ -426,7 +1600,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
426
1600
|
this.experimental = inputParameters.experimental;
|
|
427
1601
|
}
|
|
428
1602
|
if (inputParameters.appServer) {
|
|
429
|
-
this.appServer =
|
|
1603
|
+
this.appServer = addTrailingSlash(inputParameters.appServer);
|
|
430
1604
|
}
|
|
431
1605
|
}
|
|
432
1606
|
// Set resize event listener
|
|
@@ -444,10 +1618,13 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
444
1618
|
}
|
|
445
1619
|
}
|
|
446
1620
|
firstUpdated() {
|
|
447
|
-
this._loaderMsg =
|
|
1621
|
+
this._loaderMsg = getLoader(this)?.loadingMsg;
|
|
448
1622
|
this._loaderStyles();
|
|
449
1623
|
luzmo_service_default._components.push(this);
|
|
450
1624
|
this.initComponent();
|
|
1625
|
+
if (this.luzmoEmbedContainer) {
|
|
1626
|
+
this._resizeObserver.observe(this.luzmoEmbedContainer);
|
|
1627
|
+
}
|
|
451
1628
|
}
|
|
452
1629
|
initComponent() {
|
|
453
1630
|
this.params = this._setOptions();
|
|
@@ -458,28 +1635,32 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
458
1635
|
const oldReference = this.renderRoot.querySelector("dashboard-component");
|
|
459
1636
|
this.dashboardReference = oldReference.cloneNode(true);
|
|
460
1637
|
oldReference.replaceWith(this.dashboardReference);
|
|
461
|
-
this.dashboardReference.addEventListener("load", (payload) =>
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
1638
|
+
this.dashboardReference.addEventListener("load", (payload) => {
|
|
1639
|
+
setTimeout(() => {
|
|
1640
|
+
this.containerWidth = this.dashboardReference.offsetWidth;
|
|
1641
|
+
this.dimensions = payload.detail.dimensions;
|
|
1642
|
+
_setCalculatedDimensions(this);
|
|
1643
|
+
});
|
|
1644
|
+
this.dispatchEvent(new CustomEvent("load", payload));
|
|
1645
|
+
});
|
|
1646
|
+
this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
|
|
1647
|
+
this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
|
|
1648
|
+
this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
|
|
1649
|
+
this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
|
|
1650
|
+
this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
|
|
467
1651
|
this.setAllAttributes();
|
|
468
1652
|
});
|
|
469
1653
|
} else {
|
|
470
1654
|
this.containerWidth = this.container?.clientWidth;
|
|
471
|
-
|
|
472
|
-
|
|
1655
|
+
_extendAndValidate(this);
|
|
1656
|
+
_browserCheck(this);
|
|
473
1657
|
this._setupLoader();
|
|
474
1658
|
if (!this.params.error) {
|
|
475
1659
|
this._loaderStyles();
|
|
476
1660
|
_setEventHandler();
|
|
477
|
-
this._iframeUrl =
|
|
1661
|
+
this._iframeUrl = createIframeUrl(this);
|
|
478
1662
|
this.iframe?.setAttribute("src", this._iframeUrl);
|
|
479
|
-
this.iframeStyle =
|
|
480
|
-
}
|
|
481
|
-
if (this.container) {
|
|
482
|
-
this._resizeObserver.observe(this.container);
|
|
1663
|
+
this.iframeStyle = calculateIframeStyles(this);
|
|
483
1664
|
}
|
|
484
1665
|
}
|
|
485
1666
|
}
|
|
@@ -493,7 +1674,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
493
1674
|
this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
|
|
494
1675
|
}
|
|
495
1676
|
if (this.params.apiHost) {
|
|
496
|
-
this.dashboardReference.setAttribute("api-host",
|
|
1677
|
+
this.dashboardReference.setAttribute("api-host", removeTrailingSlash(this.params.apiHost));
|
|
497
1678
|
}
|
|
498
1679
|
if (this.params.key) {
|
|
499
1680
|
this.dashboardReference.setAttribute("auth-key", this.params.key);
|
|
@@ -551,14 +1732,14 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
551
1732
|
);
|
|
552
1733
|
}, 15 * 1e3);
|
|
553
1734
|
this.params = this._setOptions();
|
|
554
|
-
|
|
1735
|
+
_extendAndValidate(this);
|
|
555
1736
|
this._setupLoader();
|
|
556
1737
|
this._loaderStyles();
|
|
557
|
-
this._iframeUrl =
|
|
1738
|
+
this._iframeUrl = createIframeUrl(this);
|
|
558
1739
|
if (this.iframe) {
|
|
559
1740
|
this._updateIframeUrl();
|
|
560
1741
|
}
|
|
561
|
-
this.iframeStyle =
|
|
1742
|
+
this.iframeStyle = calculateIframeStyles(this);
|
|
562
1743
|
} else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
|
|
563
1744
|
if (this.iframeLoaded) {
|
|
564
1745
|
this.setEditMode(this.editMode);
|
|
@@ -624,16 +1805,16 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
624
1805
|
defaultParameters.itemDimensions = this.itemDimensions;
|
|
625
1806
|
}
|
|
626
1807
|
if (this.appServer) {
|
|
627
|
-
this.appServer = this.getIsViewMode() ?
|
|
1808
|
+
this.appServer = this.getIsViewMode() ? removeTrailingSlash(this.appServer) : addTrailingSlash(this.appServer);
|
|
628
1809
|
defaultParameters.appServer = this.appServer;
|
|
629
1810
|
} else {
|
|
630
|
-
this.appServer =
|
|
631
|
-
|
|
1811
|
+
this.appServer = addTrailingSlash(
|
|
1812
|
+
DEFAULT_PARAMETERS.appServer
|
|
632
1813
|
);
|
|
633
1814
|
defaultParameters.appServer = this.appServer;
|
|
634
1815
|
}
|
|
635
1816
|
if (this.apiHost) {
|
|
636
|
-
this.apiHost = this.getIsViewMode() ?
|
|
1817
|
+
this.apiHost = this.getIsViewMode() ? removeTrailingSlash(this.apiHost) : addTrailingSlash(this.apiHost);
|
|
637
1818
|
defaultParameters.apiHost = this.apiHost;
|
|
638
1819
|
} else {
|
|
639
1820
|
this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
|
|
@@ -642,11 +1823,11 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
642
1823
|
return defaultParameters;
|
|
643
1824
|
}
|
|
644
1825
|
_updateIframeUrl() {
|
|
645
|
-
|
|
1826
|
+
updateIframeUrl(this.iframe, this._iframeUrl);
|
|
646
1827
|
}
|
|
647
1828
|
// Setup loader / browser error
|
|
648
1829
|
_setupLoader() {
|
|
649
|
-
const data =
|
|
1830
|
+
const data = getLoader(this);
|
|
650
1831
|
this._loaderMsg = data.loadingMsg;
|
|
651
1832
|
if (data.errorMsg) {
|
|
652
1833
|
this.browserError = true;
|
|
@@ -666,15 +1847,15 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
666
1847
|
_calculateDimAfterDashboardLoaded() {
|
|
667
1848
|
this.dashboardError = false;
|
|
668
1849
|
this._loaderStyles();
|
|
669
|
-
|
|
1850
|
+
_setCalculatedDimensions(this);
|
|
670
1851
|
}
|
|
671
1852
|
// Set loader styles
|
|
672
1853
|
_loaderStyles() {
|
|
673
|
-
this._containerStyle =
|
|
674
|
-
this._loaderStyle =
|
|
675
|
-
this._loadingCircleStyle =
|
|
676
|
-
this._containerLoaderStyle =
|
|
677
|
-
this._lcStyle =
|
|
1854
|
+
this._containerStyle = containerStyles(this);
|
|
1855
|
+
this._loaderStyle = loaderStyles(this);
|
|
1856
|
+
this._loadingCircleStyle = plStyles(this);
|
|
1857
|
+
this._containerLoaderStyle = containerLoaderStyles(this);
|
|
1858
|
+
this._lcStyle = lcStyles(this);
|
|
678
1859
|
}
|
|
679
1860
|
static get styles() {
|
|
680
1861
|
return [dashboardStyles];
|
|
@@ -745,15 +1926,18 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
745
1926
|
`;
|
|
746
1927
|
}
|
|
747
1928
|
return html`
|
|
748
|
-
<div
|
|
749
|
-
|
|
750
|
-
|
|
1929
|
+
<div class="${luzmoEmbedContainerClass}">
|
|
1930
|
+
<div
|
|
1931
|
+
class="dashboard-container"
|
|
1932
|
+
style=${styleMap(Object.assign({}, this._containerStyle, {
|
|
751
1933
|
width: this.iframeStyle.width ?? "100%",
|
|
752
1934
|
height: this.iframeStyle.height ?? "100%"
|
|
753
1935
|
}))}
|
|
754
|
-
|
|
755
|
-
|
|
1936
|
+
>
|
|
1937
|
+
${toBeRenderedHTML}
|
|
1938
|
+
</div>
|
|
756
1939
|
</div>
|
|
1940
|
+
|
|
757
1941
|
`;
|
|
758
1942
|
}
|
|
759
1943
|
getDashboards() {
|
|
@@ -767,7 +1951,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
767
1951
|
return this.dashboardReference.getData(itemId);
|
|
768
1952
|
}
|
|
769
1953
|
if (!this.getIsViewMode()) {
|
|
770
|
-
return
|
|
1954
|
+
return getData(this, this.iframe, itemId);
|
|
771
1955
|
}
|
|
772
1956
|
return Promise.reject();
|
|
773
1957
|
}
|
|
@@ -776,7 +1960,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
776
1960
|
return this.dashboardReference.getFilters();
|
|
777
1961
|
}
|
|
778
1962
|
if (!this.getIsViewMode()) {
|
|
779
|
-
return
|
|
1963
|
+
return getFilters(this, this.iframe);
|
|
780
1964
|
}
|
|
781
1965
|
return Promise.reject();
|
|
782
1966
|
}
|
|
@@ -785,7 +1969,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
785
1969
|
return this.dashboardReference.setFilters(itemId, filters);
|
|
786
1970
|
}
|
|
787
1971
|
if (!this.getIsViewMode()) {
|
|
788
|
-
return
|
|
1972
|
+
return setFilters(this, this.iframe, itemId, filters);
|
|
789
1973
|
}
|
|
790
1974
|
return Promise.reject();
|
|
791
1975
|
}
|
|
@@ -794,7 +1978,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
794
1978
|
return this.dashboardReference.setAuthorization(key, token);
|
|
795
1979
|
}
|
|
796
1980
|
if (!this.getIsViewMode()) {
|
|
797
|
-
return
|
|
1981
|
+
return setAuthorization(this, this.iframe, key, token);
|
|
798
1982
|
}
|
|
799
1983
|
return Promise.reject();
|
|
800
1984
|
}
|
|
@@ -803,7 +1987,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
803
1987
|
return this.dashboardReference.refreshData(itemId);
|
|
804
1988
|
}
|
|
805
1989
|
if (!this.getIsViewMode()) {
|
|
806
|
-
return itemId ?
|
|
1990
|
+
return itemId ? refreshData(this, this.iframe, itemId) : refreshData(this, this.iframe);
|
|
807
1991
|
}
|
|
808
1992
|
return Promise.reject();
|
|
809
1993
|
}
|
|
@@ -812,7 +1996,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
812
1996
|
return this.dashboardReference.reloadDashboard();
|
|
813
1997
|
}
|
|
814
1998
|
if (!this.getIsViewMode()) {
|
|
815
|
-
return
|
|
1999
|
+
return reloadDashboard(this, this.iframe);
|
|
816
2000
|
}
|
|
817
2001
|
return Promise.reject();
|
|
818
2002
|
}
|
|
@@ -821,13 +2005,13 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
821
2005
|
return this.dashboardReference.exportDashboard(format);
|
|
822
2006
|
}
|
|
823
2007
|
if (!this.getIsViewMode()) {
|
|
824
|
-
return format ?
|
|
2008
|
+
return format ? exportDashboard(this, this.iframe, format) : exportDashboard(this, this.iframe);
|
|
825
2009
|
}
|
|
826
2010
|
return Promise.reject();
|
|
827
2011
|
}
|
|
828
2012
|
getAccessibleDashboards() {
|
|
829
2013
|
if (!this.getIsViewMode()) {
|
|
830
|
-
return
|
|
2014
|
+
return getAccessibleDashboards(this, this.iframe);
|
|
831
2015
|
}
|
|
832
2016
|
if (this.getIsViewMode() && this.dashboardReference) {
|
|
833
2017
|
return this.dashboardReference.getAccessibleDashboards();
|
|
@@ -860,7 +2044,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
860
2044
|
return this.dashboardReference.setEditMode(editMode);
|
|
861
2045
|
}
|
|
862
2046
|
if (!this.getIsViewMode()) {
|
|
863
|
-
return
|
|
2047
|
+
return setEditMode(this, this.iframe, editMode);
|
|
864
2048
|
}
|
|
865
2049
|
return Promise.reject();
|
|
866
2050
|
}
|
|
@@ -868,7 +2052,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
868
2052
|
if (this.getIsViewMode() && this.dashboardReference) {
|
|
869
2053
|
return this.dashboardReference.setPreview(preview);
|
|
870
2054
|
}
|
|
871
|
-
return
|
|
2055
|
+
return setPreview(this, this.iframe, preview);
|
|
872
2056
|
}
|
|
873
2057
|
getIsViewMode() {
|
|
874
2058
|
if (this.experimental && this.params.editMode === "view" || this.params.editMode === void 0) {
|
|
@@ -880,6 +2064,9 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
880
2064
|
__decorateClass([
|
|
881
2065
|
query(".dashboard-container")
|
|
882
2066
|
], LuzmoDashboard.prototype, "container", 2);
|
|
2067
|
+
__decorateClass([
|
|
2068
|
+
query(`.${luzmoEmbedContainerClass}`)
|
|
2069
|
+
], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
|
|
883
2070
|
__decorateClass([
|
|
884
2071
|
query("iframe")
|
|
885
2072
|
], LuzmoDashboard.prototype, "iframe", 2);
|