@luzmo/embed 5.0.7 → 5.0.9
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 +12 -0
- package/README.md +2 -27
- package/index.cjs +102 -1246
- package/index.js +89 -1238
- package/lib/dashboard-component/dashboard-component.d.ts +1 -0
- package/luzmo-embed.min.js +2836 -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,1180 +10,8 @@ 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/helpers/remote-federation.ts
|
|
1122
|
-
var remotesMap = {
|
|
1123
|
-
// "remote_app": { url: "http://localhost:4201/remoteEntry.mjs", format: "esm", from: "vite" },
|
|
1124
|
-
};
|
|
1125
|
-
var loadJS = async (url, fn) => {
|
|
1126
|
-
const resolvedUrl = typeof url === "function" ? await url() : url;
|
|
1127
|
-
const script = document.createElement("script");
|
|
1128
|
-
script.type = "text/javascript";
|
|
1129
|
-
script.addEventListener("load", fn);
|
|
1130
|
-
script.src = resolvedUrl;
|
|
1131
|
-
document.querySelectorAll("head")[0].append(script);
|
|
1132
|
-
};
|
|
1133
|
-
var wrapShareModule = (remoteFrom) => ({});
|
|
1134
|
-
async function __federationMethodEnsure(remoteId) {
|
|
1135
|
-
const remote = remotesMap[remoteId];
|
|
1136
|
-
if (remote.inited) {
|
|
1137
|
-
return remote.lib;
|
|
1138
|
-
}
|
|
1139
|
-
if (remote.format === "var") {
|
|
1140
|
-
return new Promise((resolve) => {
|
|
1141
|
-
const callback = () => {
|
|
1142
|
-
if (!remote.inited) {
|
|
1143
|
-
remote.lib = window[remoteId];
|
|
1144
|
-
remote.lib.init(wrapShareModule(remote.from));
|
|
1145
|
-
remote.inited = true;
|
|
1146
|
-
}
|
|
1147
|
-
resolve(remote.lib);
|
|
1148
|
-
};
|
|
1149
|
-
return loadJS(remote.url, callback);
|
|
1150
|
-
});
|
|
1151
|
-
} else if (["esm", "systemjs"].includes(remote.format)) {
|
|
1152
|
-
return new Promise((resolve, reject) => {
|
|
1153
|
-
const getUrl = typeof remote.url === "function" ? remote.url : () => Promise.resolve(remote.url);
|
|
1154
|
-
getUrl().then((url) => {
|
|
1155
|
-
import(
|
|
1156
|
-
/* @vite-ignore */
|
|
1157
|
-
/* webpackIgnore: true */
|
|
1158
|
-
url
|
|
1159
|
-
).then((lib) => {
|
|
1160
|
-
if (!remote.inited) {
|
|
1161
|
-
const shareScope = wrapShareModule(remote.from);
|
|
1162
|
-
lib.init(shareScope);
|
|
1163
|
-
remote.lib = lib;
|
|
1164
|
-
remote.lib.init(shareScope);
|
|
1165
|
-
remote.inited = true;
|
|
1166
|
-
}
|
|
1167
|
-
resolve(remote.lib);
|
|
1168
|
-
}).catch(reject);
|
|
1169
|
-
});
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
function __federationMethodWrapDefault(module, need) {
|
|
1174
|
-
if (!(module == null ? void 0 : module.default) && need) {
|
|
1175
|
-
const obj = /* @__PURE__ */ Object.create(null);
|
|
1176
|
-
obj.default = module;
|
|
1177
|
-
obj.__esModule = true;
|
|
1178
|
-
return obj;
|
|
1179
|
-
}
|
|
1180
|
-
return module;
|
|
1181
|
-
}
|
|
1182
|
-
async function __federationMethodGetRemote(remoteName, componentName) {
|
|
1183
|
-
return __federationMethodEnsure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
13
|
// libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
|
|
14
|
+
import * as SharedLib2 from "@luzmo/shared-embed";
|
|
1187
15
|
import {
|
|
1188
16
|
html,
|
|
1189
17
|
LitElement
|
|
@@ -1197,9 +25,15 @@ import {
|
|
|
1197
25
|
import {
|
|
1198
26
|
styleMap
|
|
1199
27
|
} from "lit/directives/style-map.js";
|
|
28
|
+
import {
|
|
29
|
+
__federationMethodGetRemote,
|
|
30
|
+
__federationMethodWrapDefault,
|
|
31
|
+
remotesMap,
|
|
32
|
+
luzmoEmbedContainerClass
|
|
33
|
+
} from "@luzmo/shared-embed";
|
|
1200
34
|
|
|
1201
35
|
// libs/embed-libs/embed/package.json
|
|
1202
|
-
var version = "5.0.
|
|
36
|
+
var version = "5.0.9";
|
|
1203
37
|
|
|
1204
38
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
1205
39
|
var LuzmoService = class {
|
|
@@ -1210,6 +44,7 @@ var LuzmoService = class {
|
|
|
1210
44
|
var luzmo_service_default = new LuzmoService();
|
|
1211
45
|
|
|
1212
46
|
// libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
|
|
47
|
+
import * as SharedLib from "@luzmo/shared-embed";
|
|
1213
48
|
var _setEventHandler = () => {
|
|
1214
49
|
if (typeof window.__luzmoMessageHandler === "function") {
|
|
1215
50
|
return;
|
|
@@ -1246,7 +81,7 @@ var _setEventHandler = () => {
|
|
|
1246
81
|
break;
|
|
1247
82
|
}
|
|
1248
83
|
case "data": {
|
|
1249
|
-
resolvePromise(
|
|
84
|
+
SharedLib.resolvePromise(
|
|
1250
85
|
dashboardComponent,
|
|
1251
86
|
event.data.requestId,
|
|
1252
87
|
event.data.data
|
|
@@ -1254,7 +89,7 @@ var _setEventHandler = () => {
|
|
|
1254
89
|
break;
|
|
1255
90
|
}
|
|
1256
91
|
case "filters": {
|
|
1257
|
-
resolvePromise(
|
|
92
|
+
SharedLib.resolvePromise(
|
|
1258
93
|
dashboardComponent,
|
|
1259
94
|
event.data.requestId,
|
|
1260
95
|
event.data.filters
|
|
@@ -1262,7 +97,7 @@ var _setEventHandler = () => {
|
|
|
1262
97
|
break;
|
|
1263
98
|
}
|
|
1264
99
|
case "getAccessibleDashboards": {
|
|
1265
|
-
resolvePromise(
|
|
100
|
+
SharedLib.resolvePromise(
|
|
1266
101
|
dashboardComponent,
|
|
1267
102
|
event.data.requestId,
|
|
1268
103
|
event.data.accessibleDashboards
|
|
@@ -1277,7 +112,7 @@ var _setEventHandler = () => {
|
|
|
1277
112
|
}
|
|
1278
113
|
case "export": {
|
|
1279
114
|
if (event.data.error) {
|
|
1280
|
-
rejectPromise(
|
|
115
|
+
SharedLib.rejectPromise(
|
|
1281
116
|
dashboardComponent,
|
|
1282
117
|
event.data.requestId,
|
|
1283
118
|
event.data
|
|
@@ -1286,7 +121,7 @@ var _setEventHandler = () => {
|
|
|
1286
121
|
dashboardComponent.dispatchEvent(
|
|
1287
122
|
new CustomEvent("exported", { detail: { data: event.data } })
|
|
1288
123
|
);
|
|
1289
|
-
resolvePromise(
|
|
124
|
+
SharedLib.resolvePromise(
|
|
1290
125
|
dashboardComponent,
|
|
1291
126
|
event.data.requestId,
|
|
1292
127
|
event.data
|
|
@@ -1316,31 +151,31 @@ var _setEventHandler = () => {
|
|
|
1316
151
|
}
|
|
1317
152
|
case "setEditMode": {
|
|
1318
153
|
if (event.data.error) {
|
|
1319
|
-
rejectPromise(
|
|
154
|
+
SharedLib.rejectPromise(
|
|
1320
155
|
dashboardComponent,
|
|
1321
156
|
event.data.requestId,
|
|
1322
157
|
event.data
|
|
1323
158
|
);
|
|
1324
159
|
} else {
|
|
1325
|
-
resolvePromise(
|
|
160
|
+
SharedLib.resolvePromise(
|
|
1326
161
|
dashboardComponent,
|
|
1327
162
|
event.data.requestId,
|
|
1328
163
|
event.data
|
|
1329
164
|
);
|
|
1330
165
|
dashboardComponent.params.editMode = event.data.editMode;
|
|
1331
|
-
dashboardComponent._containerStyle = containerStyles(dashboardComponent);
|
|
166
|
+
dashboardComponent._containerStyle = SharedLib.containerStyles(dashboardComponent);
|
|
1332
167
|
if (dashboardComponent.dimensions) {
|
|
1333
|
-
_setCalculatedDimensions(dashboardComponent);
|
|
168
|
+
SharedLib._setCalculatedDimensions(dashboardComponent);
|
|
1334
169
|
}
|
|
1335
170
|
}
|
|
1336
171
|
break;
|
|
1337
172
|
}
|
|
1338
173
|
case "setFilters": {
|
|
1339
|
-
event.data.error ? rejectPromise(
|
|
174
|
+
event.data.error ? SharedLib.rejectPromise(
|
|
1340
175
|
dashboardComponent,
|
|
1341
176
|
event.data.requestId,
|
|
1342
177
|
event.data
|
|
1343
|
-
) : resolvePromise(
|
|
178
|
+
) : SharedLib.resolvePromise(
|
|
1344
179
|
dashboardComponent,
|
|
1345
180
|
event.data.requestId,
|
|
1346
181
|
event.data
|
|
@@ -1348,11 +183,11 @@ var _setEventHandler = () => {
|
|
|
1348
183
|
break;
|
|
1349
184
|
}
|
|
1350
185
|
case "setPreview": {
|
|
1351
|
-
event.data.error ? rejectPromise(
|
|
186
|
+
event.data.error ? SharedLib.rejectPromise(
|
|
1352
187
|
dashboardComponent,
|
|
1353
188
|
event.data.requestId,
|
|
1354
189
|
event.data
|
|
1355
|
-
) : resolvePromise(
|
|
190
|
+
) : SharedLib.resolvePromise(
|
|
1356
191
|
dashboardComponent,
|
|
1357
192
|
event.data.requestId,
|
|
1358
193
|
event.data
|
|
@@ -1399,6 +234,11 @@ var dashboardStyles = css`
|
|
|
1399
234
|
border: 0;
|
|
1400
235
|
}
|
|
1401
236
|
|
|
237
|
+
.luzmo-embed-container-ede {
|
|
238
|
+
width: 100%;
|
|
239
|
+
height: 100%;
|
|
240
|
+
}
|
|
241
|
+
|
|
1402
242
|
.luzmo-container-loader {
|
|
1403
243
|
width: 100%;
|
|
1404
244
|
position: relative;
|
|
@@ -1516,7 +356,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1516
356
|
this.loaderSize = 32;
|
|
1517
357
|
this.borderWidth = 3;
|
|
1518
358
|
this.minHeight = 400;
|
|
1519
|
-
this._containerId = uuidv4();
|
|
359
|
+
this._containerId = SharedLib2.uuidv4();
|
|
1520
360
|
this._iframeId = `luzmo-dashboard-${this._containerId}`;
|
|
1521
361
|
this.iframeLoaded = false;
|
|
1522
362
|
this.promises = {};
|
|
@@ -1524,9 +364,9 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1524
364
|
this.params = this._setOptions();
|
|
1525
365
|
this._onResize = () => {
|
|
1526
366
|
if (this.shadowRoot?.querySelector(".dashboard-container")) {
|
|
1527
|
-
this.containerWidth = this.
|
|
367
|
+
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
1528
368
|
if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
|
|
1529
|
-
for (const d of EXTENTS) {
|
|
369
|
+
for (const d of SharedLib2.EXTENTS) {
|
|
1530
370
|
if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
|
|
1531
371
|
this.currentScreenMode = d.mode;
|
|
1532
372
|
}
|
|
@@ -1534,6 +374,11 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1534
374
|
}
|
|
1535
375
|
if (this.iframeLoaded) {
|
|
1536
376
|
this._calculateDimAfterDashboardLoaded();
|
|
377
|
+
} else {
|
|
378
|
+
if (this.dimensions) {
|
|
379
|
+
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
380
|
+
SharedLib2._setCalculatedDimensions(this);
|
|
381
|
+
}
|
|
1537
382
|
}
|
|
1538
383
|
}
|
|
1539
384
|
};
|
|
@@ -1550,7 +395,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1550
395
|
if (remotesMap[appServer]) {
|
|
1551
396
|
return Promise.resolve(remotesMap[appServer].module);
|
|
1552
397
|
}
|
|
1553
|
-
remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
|
|
398
|
+
remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
|
|
1554
399
|
return __federationMethodGetRemote(appServer, "./DashboardApp").then((module) => {
|
|
1555
400
|
const wrappedModule = __federationMethodWrapDefault(module, true);
|
|
1556
401
|
remotesMap[appServer].module = wrappedModule;
|
|
@@ -1592,7 +437,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1592
437
|
this.experimental = inputParameters.experimental;
|
|
1593
438
|
}
|
|
1594
439
|
if (inputParameters.appServer) {
|
|
1595
|
-
this.appServer = addTrailingSlash(inputParameters.appServer);
|
|
440
|
+
this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
|
|
1596
441
|
}
|
|
1597
442
|
}
|
|
1598
443
|
// Set resize event listener
|
|
@@ -1610,10 +455,13 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1610
455
|
}
|
|
1611
456
|
}
|
|
1612
457
|
firstUpdated() {
|
|
1613
|
-
this._loaderMsg = getLoader(this)?.loadingMsg;
|
|
458
|
+
this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
|
|
1614
459
|
this._loaderStyles();
|
|
1615
460
|
luzmo_service_default._components.push(this);
|
|
1616
461
|
this.initComponent();
|
|
462
|
+
if (this.luzmoEmbedContainer) {
|
|
463
|
+
this._resizeObserver.observe(this.luzmoEmbedContainer);
|
|
464
|
+
}
|
|
1617
465
|
}
|
|
1618
466
|
initComponent() {
|
|
1619
467
|
this.params = this._setOptions();
|
|
@@ -1628,31 +476,28 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1628
476
|
setTimeout(() => {
|
|
1629
477
|
this.containerWidth = this.dashboardReference.offsetWidth;
|
|
1630
478
|
this.dimensions = payload.detail.dimensions;
|
|
1631
|
-
_setCalculatedDimensions(this);
|
|
1632
|
-
this.dispatchEvent(new CustomEvent("load", payload.detail));
|
|
479
|
+
SharedLib2._setCalculatedDimensions(this);
|
|
1633
480
|
});
|
|
481
|
+
this.dispatchEvent(new CustomEvent("load", payload));
|
|
1634
482
|
});
|
|
1635
|
-
this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload
|
|
1636
|
-
this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload
|
|
1637
|
-
this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload
|
|
1638
|
-
this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload
|
|
1639
|
-
this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload
|
|
483
|
+
this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
|
|
484
|
+
this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
|
|
485
|
+
this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
|
|
486
|
+
this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
|
|
487
|
+
this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
|
|
1640
488
|
this.setAllAttributes();
|
|
1641
489
|
});
|
|
1642
490
|
} else {
|
|
1643
491
|
this.containerWidth = this.container?.clientWidth;
|
|
1644
|
-
_extendAndValidate(this);
|
|
1645
|
-
_browserCheck(this);
|
|
492
|
+
SharedLib2._extendAndValidate(this);
|
|
493
|
+
SharedLib2._browserCheck(this);
|
|
1646
494
|
this._setupLoader();
|
|
1647
495
|
if (!this.params.error) {
|
|
1648
496
|
this._loaderStyles();
|
|
1649
497
|
_setEventHandler();
|
|
1650
|
-
this._iframeUrl = createIframeUrl(this);
|
|
498
|
+
this._iframeUrl = SharedLib2.createIframeUrl(this);
|
|
1651
499
|
this.iframe?.setAttribute("src", this._iframeUrl);
|
|
1652
|
-
this.iframeStyle = calculateIframeStyles(this);
|
|
1653
|
-
}
|
|
1654
|
-
if (this.container) {
|
|
1655
|
-
this._resizeObserver.observe(this.container);
|
|
500
|
+
this.iframeStyle = SharedLib2.calculateIframeStyles(this);
|
|
1656
501
|
}
|
|
1657
502
|
}
|
|
1658
503
|
}
|
|
@@ -1666,7 +511,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1666
511
|
this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
|
|
1667
512
|
}
|
|
1668
513
|
if (this.params.apiHost) {
|
|
1669
|
-
this.dashboardReference.setAttribute("api-host", removeTrailingSlash(this.params.apiHost));
|
|
514
|
+
this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
|
|
1670
515
|
}
|
|
1671
516
|
if (this.params.key) {
|
|
1672
517
|
this.dashboardReference.setAttribute("auth-key", this.params.key);
|
|
@@ -1724,14 +569,14 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1724
569
|
);
|
|
1725
570
|
}, 15 * 1e3);
|
|
1726
571
|
this.params = this._setOptions();
|
|
1727
|
-
_extendAndValidate(this);
|
|
572
|
+
SharedLib2._extendAndValidate(this);
|
|
1728
573
|
this._setupLoader();
|
|
1729
574
|
this._loaderStyles();
|
|
1730
|
-
this._iframeUrl = createIframeUrl(this);
|
|
575
|
+
this._iframeUrl = SharedLib2.createIframeUrl(this);
|
|
1731
576
|
if (this.iframe) {
|
|
1732
577
|
this._updateIframeUrl();
|
|
1733
578
|
}
|
|
1734
|
-
this.iframeStyle = calculateIframeStyles(this);
|
|
579
|
+
this.iframeStyle = SharedLib2.calculateIframeStyles(this);
|
|
1735
580
|
} else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
|
|
1736
581
|
if (this.iframeLoaded) {
|
|
1737
582
|
this.setEditMode(this.editMode);
|
|
@@ -1797,16 +642,16 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1797
642
|
defaultParameters.itemDimensions = this.itemDimensions;
|
|
1798
643
|
}
|
|
1799
644
|
if (this.appServer) {
|
|
1800
|
-
this.appServer = this.getIsViewMode() ? removeTrailingSlash(this.appServer) : addTrailingSlash(this.appServer);
|
|
645
|
+
this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
|
|
1801
646
|
defaultParameters.appServer = this.appServer;
|
|
1802
647
|
} else {
|
|
1803
|
-
this.appServer = addTrailingSlash(
|
|
1804
|
-
DEFAULT_PARAMETERS.appServer
|
|
648
|
+
this.appServer = SharedLib2.addTrailingSlash(
|
|
649
|
+
SharedLib2.DEFAULT_PARAMETERS.appServer
|
|
1805
650
|
);
|
|
1806
651
|
defaultParameters.appServer = this.appServer;
|
|
1807
652
|
}
|
|
1808
653
|
if (this.apiHost) {
|
|
1809
|
-
this.apiHost = this.getIsViewMode() ? removeTrailingSlash(this.apiHost) : addTrailingSlash(this.apiHost);
|
|
654
|
+
this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
|
|
1810
655
|
defaultParameters.apiHost = this.apiHost;
|
|
1811
656
|
} else {
|
|
1812
657
|
this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
|
|
@@ -1815,11 +660,11 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1815
660
|
return defaultParameters;
|
|
1816
661
|
}
|
|
1817
662
|
_updateIframeUrl() {
|
|
1818
|
-
updateIframeUrl(this.iframe, this._iframeUrl);
|
|
663
|
+
SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
|
|
1819
664
|
}
|
|
1820
665
|
// Setup loader / browser error
|
|
1821
666
|
_setupLoader() {
|
|
1822
|
-
const data = getLoader(this);
|
|
667
|
+
const data = SharedLib2.getLoader(this);
|
|
1823
668
|
this._loaderMsg = data.loadingMsg;
|
|
1824
669
|
if (data.errorMsg) {
|
|
1825
670
|
this.browserError = true;
|
|
@@ -1839,15 +684,15 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1839
684
|
_calculateDimAfterDashboardLoaded() {
|
|
1840
685
|
this.dashboardError = false;
|
|
1841
686
|
this._loaderStyles();
|
|
1842
|
-
_setCalculatedDimensions(this);
|
|
687
|
+
SharedLib2._setCalculatedDimensions(this);
|
|
1843
688
|
}
|
|
1844
689
|
// Set loader styles
|
|
1845
690
|
_loaderStyles() {
|
|
1846
|
-
this._containerStyle = containerStyles(this);
|
|
1847
|
-
this._loaderStyle = loaderStyles(this);
|
|
1848
|
-
this._loadingCircleStyle = plStyles(this);
|
|
1849
|
-
this._containerLoaderStyle = containerLoaderStyles(this);
|
|
1850
|
-
this._lcStyle = lcStyles(this);
|
|
691
|
+
this._containerStyle = SharedLib2.containerStyles(this);
|
|
692
|
+
this._loaderStyle = SharedLib2.loaderStyles(this);
|
|
693
|
+
this._loadingCircleStyle = SharedLib2.plStyles(this);
|
|
694
|
+
this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
|
|
695
|
+
this._lcStyle = SharedLib2.lcStyles(this);
|
|
1851
696
|
}
|
|
1852
697
|
static get styles() {
|
|
1853
698
|
return [dashboardStyles];
|
|
@@ -1918,15 +763,18 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1918
763
|
`;
|
|
1919
764
|
}
|
|
1920
765
|
return html`
|
|
1921
|
-
<div
|
|
1922
|
-
|
|
1923
|
-
|
|
766
|
+
<div class="${luzmoEmbedContainerClass} ${!this.getIsViewMode() ? `${luzmoEmbedContainerClass}-ede` : ""}">
|
|
767
|
+
<div
|
|
768
|
+
class="dashboard-container"
|
|
769
|
+
style=${styleMap(Object.assign({}, this._containerStyle, {
|
|
1924
770
|
width: this.iframeStyle.width ?? "100%",
|
|
1925
771
|
height: this.iframeStyle.height ?? "100%"
|
|
1926
772
|
}))}
|
|
1927
|
-
|
|
1928
|
-
|
|
773
|
+
>
|
|
774
|
+
${toBeRenderedHTML}
|
|
775
|
+
</div>
|
|
1929
776
|
</div>
|
|
777
|
+
|
|
1930
778
|
`;
|
|
1931
779
|
}
|
|
1932
780
|
getDashboards() {
|
|
@@ -1940,7 +788,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1940
788
|
return this.dashboardReference.getData(itemId);
|
|
1941
789
|
}
|
|
1942
790
|
if (!this.getIsViewMode()) {
|
|
1943
|
-
return getData(this, this.iframe, itemId);
|
|
791
|
+
return SharedLib2.getData(this, this.iframe, itemId);
|
|
1944
792
|
}
|
|
1945
793
|
return Promise.reject();
|
|
1946
794
|
}
|
|
@@ -1949,7 +797,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1949
797
|
return this.dashboardReference.getFilters();
|
|
1950
798
|
}
|
|
1951
799
|
if (!this.getIsViewMode()) {
|
|
1952
|
-
return getFilters(this, this.iframe);
|
|
800
|
+
return SharedLib2.getFilters(this, this.iframe);
|
|
1953
801
|
}
|
|
1954
802
|
return Promise.reject();
|
|
1955
803
|
}
|
|
@@ -1958,7 +806,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1958
806
|
return this.dashboardReference.setFilters(itemId, filters);
|
|
1959
807
|
}
|
|
1960
808
|
if (!this.getIsViewMode()) {
|
|
1961
|
-
return setFilters(this, this.iframe, itemId, filters);
|
|
809
|
+
return SharedLib2.setFilters(this, this.iframe, itemId, filters);
|
|
1962
810
|
}
|
|
1963
811
|
return Promise.reject();
|
|
1964
812
|
}
|
|
@@ -1967,7 +815,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1967
815
|
return this.dashboardReference.setAuthorization(key, token);
|
|
1968
816
|
}
|
|
1969
817
|
if (!this.getIsViewMode()) {
|
|
1970
|
-
return setAuthorization(this, this.iframe, key, token);
|
|
818
|
+
return SharedLib2.setAuthorization(this, this.iframe, key, token);
|
|
1971
819
|
}
|
|
1972
820
|
return Promise.reject();
|
|
1973
821
|
}
|
|
@@ -1976,7 +824,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1976
824
|
return this.dashboardReference.refreshData(itemId);
|
|
1977
825
|
}
|
|
1978
826
|
if (!this.getIsViewMode()) {
|
|
1979
|
-
return itemId ? refreshData(this, this.iframe, itemId) : refreshData(this, this.iframe);
|
|
827
|
+
return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
|
|
1980
828
|
}
|
|
1981
829
|
return Promise.reject();
|
|
1982
830
|
}
|
|
@@ -1985,7 +833,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1985
833
|
return this.dashboardReference.reloadDashboard();
|
|
1986
834
|
}
|
|
1987
835
|
if (!this.getIsViewMode()) {
|
|
1988
|
-
return reloadDashboard(this, this.iframe);
|
|
836
|
+
return SharedLib2.reloadDashboard(this, this.iframe);
|
|
1989
837
|
}
|
|
1990
838
|
return Promise.reject();
|
|
1991
839
|
}
|
|
@@ -1994,13 +842,13 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1994
842
|
return this.dashboardReference.exportDashboard(format);
|
|
1995
843
|
}
|
|
1996
844
|
if (!this.getIsViewMode()) {
|
|
1997
|
-
return format ? exportDashboard(this, this.iframe, format) : exportDashboard(this, this.iframe);
|
|
845
|
+
return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
|
|
1998
846
|
}
|
|
1999
847
|
return Promise.reject();
|
|
2000
848
|
}
|
|
2001
849
|
getAccessibleDashboards() {
|
|
2002
850
|
if (!this.getIsViewMode()) {
|
|
2003
|
-
return getAccessibleDashboards(this, this.iframe);
|
|
851
|
+
return SharedLib2.getAccessibleDashboards(this, this.iframe);
|
|
2004
852
|
}
|
|
2005
853
|
if (this.getIsViewMode() && this.dashboardReference) {
|
|
2006
854
|
return this.dashboardReference.getAccessibleDashboards();
|
|
@@ -2033,7 +881,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
2033
881
|
return this.dashboardReference.setEditMode(editMode);
|
|
2034
882
|
}
|
|
2035
883
|
if (!this.getIsViewMode()) {
|
|
2036
|
-
return setEditMode(this, this.iframe, editMode);
|
|
884
|
+
return SharedLib2.setEditMode(this, this.iframe, editMode);
|
|
2037
885
|
}
|
|
2038
886
|
return Promise.reject();
|
|
2039
887
|
}
|
|
@@ -2041,7 +889,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
2041
889
|
if (this.getIsViewMode() && this.dashboardReference) {
|
|
2042
890
|
return this.dashboardReference.setPreview(preview);
|
|
2043
891
|
}
|
|
2044
|
-
return setPreview(this, this.iframe, preview);
|
|
892
|
+
return SharedLib2.setPreview(this, this.iframe, preview);
|
|
2045
893
|
}
|
|
2046
894
|
getIsViewMode() {
|
|
2047
895
|
if (this.experimental && this.params.editMode === "view" || this.params.editMode === void 0) {
|
|
@@ -2053,6 +901,9 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
2053
901
|
__decorateClass([
|
|
2054
902
|
query(".dashboard-container")
|
|
2055
903
|
], LuzmoDashboard.prototype, "container", 2);
|
|
904
|
+
__decorateClass([
|
|
905
|
+
query(`.${luzmoEmbedContainerClass}`)
|
|
906
|
+
], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
|
|
2056
907
|
__decorateClass([
|
|
2057
908
|
query("iframe")
|
|
2058
909
|
], LuzmoDashboard.prototype, "iframe", 2);
|