@luzmo/embed 5.0.8 → 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 +6 -0
- package/index.cjs +79 -1237
- package/index.js +65 -1228
- package/luzmo-embed.min.js +7 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10,1183 +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/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
|
-
|
|
1189
13
|
// libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
|
|
14
|
+
import * as SharedLib2 from "@luzmo/shared-embed";
|
|
1190
15
|
import {
|
|
1191
16
|
html,
|
|
1192
17
|
LitElement
|
|
@@ -1200,9 +25,15 @@ import {
|
|
|
1200
25
|
import {
|
|
1201
26
|
styleMap
|
|
1202
27
|
} from "lit/directives/style-map.js";
|
|
28
|
+
import {
|
|
29
|
+
__federationMethodGetRemote,
|
|
30
|
+
__federationMethodWrapDefault,
|
|
31
|
+
remotesMap,
|
|
32
|
+
luzmoEmbedContainerClass
|
|
33
|
+
} from "@luzmo/shared-embed";
|
|
1203
34
|
|
|
1204
35
|
// libs/embed-libs/embed/package.json
|
|
1205
|
-
var version = "5.0.
|
|
36
|
+
var version = "5.0.9";
|
|
1206
37
|
|
|
1207
38
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
1208
39
|
var LuzmoService = class {
|
|
@@ -1213,6 +44,7 @@ var LuzmoService = class {
|
|
|
1213
44
|
var luzmo_service_default = new LuzmoService();
|
|
1214
45
|
|
|
1215
46
|
// libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
|
|
47
|
+
import * as SharedLib from "@luzmo/shared-embed";
|
|
1216
48
|
var _setEventHandler = () => {
|
|
1217
49
|
if (typeof window.__luzmoMessageHandler === "function") {
|
|
1218
50
|
return;
|
|
@@ -1249,7 +81,7 @@ var _setEventHandler = () => {
|
|
|
1249
81
|
break;
|
|
1250
82
|
}
|
|
1251
83
|
case "data": {
|
|
1252
|
-
resolvePromise(
|
|
84
|
+
SharedLib.resolvePromise(
|
|
1253
85
|
dashboardComponent,
|
|
1254
86
|
event.data.requestId,
|
|
1255
87
|
event.data.data
|
|
@@ -1257,7 +89,7 @@ var _setEventHandler = () => {
|
|
|
1257
89
|
break;
|
|
1258
90
|
}
|
|
1259
91
|
case "filters": {
|
|
1260
|
-
resolvePromise(
|
|
92
|
+
SharedLib.resolvePromise(
|
|
1261
93
|
dashboardComponent,
|
|
1262
94
|
event.data.requestId,
|
|
1263
95
|
event.data.filters
|
|
@@ -1265,7 +97,7 @@ var _setEventHandler = () => {
|
|
|
1265
97
|
break;
|
|
1266
98
|
}
|
|
1267
99
|
case "getAccessibleDashboards": {
|
|
1268
|
-
resolvePromise(
|
|
100
|
+
SharedLib.resolvePromise(
|
|
1269
101
|
dashboardComponent,
|
|
1270
102
|
event.data.requestId,
|
|
1271
103
|
event.data.accessibleDashboards
|
|
@@ -1280,7 +112,7 @@ var _setEventHandler = () => {
|
|
|
1280
112
|
}
|
|
1281
113
|
case "export": {
|
|
1282
114
|
if (event.data.error) {
|
|
1283
|
-
rejectPromise(
|
|
115
|
+
SharedLib.rejectPromise(
|
|
1284
116
|
dashboardComponent,
|
|
1285
117
|
event.data.requestId,
|
|
1286
118
|
event.data
|
|
@@ -1289,7 +121,7 @@ var _setEventHandler = () => {
|
|
|
1289
121
|
dashboardComponent.dispatchEvent(
|
|
1290
122
|
new CustomEvent("exported", { detail: { data: event.data } })
|
|
1291
123
|
);
|
|
1292
|
-
resolvePromise(
|
|
124
|
+
SharedLib.resolvePromise(
|
|
1293
125
|
dashboardComponent,
|
|
1294
126
|
event.data.requestId,
|
|
1295
127
|
event.data
|
|
@@ -1319,31 +151,31 @@ var _setEventHandler = () => {
|
|
|
1319
151
|
}
|
|
1320
152
|
case "setEditMode": {
|
|
1321
153
|
if (event.data.error) {
|
|
1322
|
-
rejectPromise(
|
|
154
|
+
SharedLib.rejectPromise(
|
|
1323
155
|
dashboardComponent,
|
|
1324
156
|
event.data.requestId,
|
|
1325
157
|
event.data
|
|
1326
158
|
);
|
|
1327
159
|
} else {
|
|
1328
|
-
resolvePromise(
|
|
160
|
+
SharedLib.resolvePromise(
|
|
1329
161
|
dashboardComponent,
|
|
1330
162
|
event.data.requestId,
|
|
1331
163
|
event.data
|
|
1332
164
|
);
|
|
1333
165
|
dashboardComponent.params.editMode = event.data.editMode;
|
|
1334
|
-
dashboardComponent._containerStyle = containerStyles(dashboardComponent);
|
|
166
|
+
dashboardComponent._containerStyle = SharedLib.containerStyles(dashboardComponent);
|
|
1335
167
|
if (dashboardComponent.dimensions) {
|
|
1336
|
-
_setCalculatedDimensions(dashboardComponent);
|
|
168
|
+
SharedLib._setCalculatedDimensions(dashboardComponent);
|
|
1337
169
|
}
|
|
1338
170
|
}
|
|
1339
171
|
break;
|
|
1340
172
|
}
|
|
1341
173
|
case "setFilters": {
|
|
1342
|
-
event.data.error ? rejectPromise(
|
|
174
|
+
event.data.error ? SharedLib.rejectPromise(
|
|
1343
175
|
dashboardComponent,
|
|
1344
176
|
event.data.requestId,
|
|
1345
177
|
event.data
|
|
1346
|
-
) : resolvePromise(
|
|
178
|
+
) : SharedLib.resolvePromise(
|
|
1347
179
|
dashboardComponent,
|
|
1348
180
|
event.data.requestId,
|
|
1349
181
|
event.data
|
|
@@ -1351,11 +183,11 @@ var _setEventHandler = () => {
|
|
|
1351
183
|
break;
|
|
1352
184
|
}
|
|
1353
185
|
case "setPreview": {
|
|
1354
|
-
event.data.error ? rejectPromise(
|
|
186
|
+
event.data.error ? SharedLib.rejectPromise(
|
|
1355
187
|
dashboardComponent,
|
|
1356
188
|
event.data.requestId,
|
|
1357
189
|
event.data
|
|
1358
|
-
) : resolvePromise(
|
|
190
|
+
) : SharedLib.resolvePromise(
|
|
1359
191
|
dashboardComponent,
|
|
1360
192
|
event.data.requestId,
|
|
1361
193
|
event.data
|
|
@@ -1402,6 +234,11 @@ var dashboardStyles = css`
|
|
|
1402
234
|
border: 0;
|
|
1403
235
|
}
|
|
1404
236
|
|
|
237
|
+
.luzmo-embed-container-ede {
|
|
238
|
+
width: 100%;
|
|
239
|
+
height: 100%;
|
|
240
|
+
}
|
|
241
|
+
|
|
1405
242
|
.luzmo-container-loader {
|
|
1406
243
|
width: 100%;
|
|
1407
244
|
position: relative;
|
|
@@ -1519,7 +356,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1519
356
|
this.loaderSize = 32;
|
|
1520
357
|
this.borderWidth = 3;
|
|
1521
358
|
this.minHeight = 400;
|
|
1522
|
-
this._containerId = uuidv4();
|
|
359
|
+
this._containerId = SharedLib2.uuidv4();
|
|
1523
360
|
this._iframeId = `luzmo-dashboard-${this._containerId}`;
|
|
1524
361
|
this.iframeLoaded = false;
|
|
1525
362
|
this.promises = {};
|
|
@@ -1529,7 +366,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1529
366
|
if (this.shadowRoot?.querySelector(".dashboard-container")) {
|
|
1530
367
|
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
1531
368
|
if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
|
|
1532
|
-
for (const d of EXTENTS) {
|
|
369
|
+
for (const d of SharedLib2.EXTENTS) {
|
|
1533
370
|
if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
|
|
1534
371
|
this.currentScreenMode = d.mode;
|
|
1535
372
|
}
|
|
@@ -1540,7 +377,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1540
377
|
} else {
|
|
1541
378
|
if (this.dimensions) {
|
|
1542
379
|
this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
|
|
1543
|
-
_setCalculatedDimensions(this);
|
|
380
|
+
SharedLib2._setCalculatedDimensions(this);
|
|
1544
381
|
}
|
|
1545
382
|
}
|
|
1546
383
|
}
|
|
@@ -1558,7 +395,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1558
395
|
if (remotesMap[appServer]) {
|
|
1559
396
|
return Promise.resolve(remotesMap[appServer].module);
|
|
1560
397
|
}
|
|
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 };
|
|
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 };
|
|
1562
399
|
return __federationMethodGetRemote(appServer, "./DashboardApp").then((module) => {
|
|
1563
400
|
const wrappedModule = __federationMethodWrapDefault(module, true);
|
|
1564
401
|
remotesMap[appServer].module = wrappedModule;
|
|
@@ -1600,7 +437,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1600
437
|
this.experimental = inputParameters.experimental;
|
|
1601
438
|
}
|
|
1602
439
|
if (inputParameters.appServer) {
|
|
1603
|
-
this.appServer = addTrailingSlash(inputParameters.appServer);
|
|
440
|
+
this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
|
|
1604
441
|
}
|
|
1605
442
|
}
|
|
1606
443
|
// Set resize event listener
|
|
@@ -1618,7 +455,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1618
455
|
}
|
|
1619
456
|
}
|
|
1620
457
|
firstUpdated() {
|
|
1621
|
-
this._loaderMsg = getLoader(this)?.loadingMsg;
|
|
458
|
+
this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
|
|
1622
459
|
this._loaderStyles();
|
|
1623
460
|
luzmo_service_default._components.push(this);
|
|
1624
461
|
this.initComponent();
|
|
@@ -1639,7 +476,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1639
476
|
setTimeout(() => {
|
|
1640
477
|
this.containerWidth = this.dashboardReference.offsetWidth;
|
|
1641
478
|
this.dimensions = payload.detail.dimensions;
|
|
1642
|
-
_setCalculatedDimensions(this);
|
|
479
|
+
SharedLib2._setCalculatedDimensions(this);
|
|
1643
480
|
});
|
|
1644
481
|
this.dispatchEvent(new CustomEvent("load", payload));
|
|
1645
482
|
});
|
|
@@ -1652,15 +489,15 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1652
489
|
});
|
|
1653
490
|
} else {
|
|
1654
491
|
this.containerWidth = this.container?.clientWidth;
|
|
1655
|
-
_extendAndValidate(this);
|
|
1656
|
-
_browserCheck(this);
|
|
492
|
+
SharedLib2._extendAndValidate(this);
|
|
493
|
+
SharedLib2._browserCheck(this);
|
|
1657
494
|
this._setupLoader();
|
|
1658
495
|
if (!this.params.error) {
|
|
1659
496
|
this._loaderStyles();
|
|
1660
497
|
_setEventHandler();
|
|
1661
|
-
this._iframeUrl = createIframeUrl(this);
|
|
498
|
+
this._iframeUrl = SharedLib2.createIframeUrl(this);
|
|
1662
499
|
this.iframe?.setAttribute("src", this._iframeUrl);
|
|
1663
|
-
this.iframeStyle = calculateIframeStyles(this);
|
|
500
|
+
this.iframeStyle = SharedLib2.calculateIframeStyles(this);
|
|
1664
501
|
}
|
|
1665
502
|
}
|
|
1666
503
|
}
|
|
@@ -1674,7 +511,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1674
511
|
this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
|
|
1675
512
|
}
|
|
1676
513
|
if (this.params.apiHost) {
|
|
1677
|
-
this.dashboardReference.setAttribute("api-host", removeTrailingSlash(this.params.apiHost));
|
|
514
|
+
this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
|
|
1678
515
|
}
|
|
1679
516
|
if (this.params.key) {
|
|
1680
517
|
this.dashboardReference.setAttribute("auth-key", this.params.key);
|
|
@@ -1732,14 +569,14 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1732
569
|
);
|
|
1733
570
|
}, 15 * 1e3);
|
|
1734
571
|
this.params = this._setOptions();
|
|
1735
|
-
_extendAndValidate(this);
|
|
572
|
+
SharedLib2._extendAndValidate(this);
|
|
1736
573
|
this._setupLoader();
|
|
1737
574
|
this._loaderStyles();
|
|
1738
|
-
this._iframeUrl = createIframeUrl(this);
|
|
575
|
+
this._iframeUrl = SharedLib2.createIframeUrl(this);
|
|
1739
576
|
if (this.iframe) {
|
|
1740
577
|
this._updateIframeUrl();
|
|
1741
578
|
}
|
|
1742
|
-
this.iframeStyle = calculateIframeStyles(this);
|
|
579
|
+
this.iframeStyle = SharedLib2.calculateIframeStyles(this);
|
|
1743
580
|
} else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
|
|
1744
581
|
if (this.iframeLoaded) {
|
|
1745
582
|
this.setEditMode(this.editMode);
|
|
@@ -1805,16 +642,16 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1805
642
|
defaultParameters.itemDimensions = this.itemDimensions;
|
|
1806
643
|
}
|
|
1807
644
|
if (this.appServer) {
|
|
1808
|
-
this.appServer = this.getIsViewMode() ? removeTrailingSlash(this.appServer) : addTrailingSlash(this.appServer);
|
|
645
|
+
this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
|
|
1809
646
|
defaultParameters.appServer = this.appServer;
|
|
1810
647
|
} else {
|
|
1811
|
-
this.appServer = addTrailingSlash(
|
|
1812
|
-
DEFAULT_PARAMETERS.appServer
|
|
648
|
+
this.appServer = SharedLib2.addTrailingSlash(
|
|
649
|
+
SharedLib2.DEFAULT_PARAMETERS.appServer
|
|
1813
650
|
);
|
|
1814
651
|
defaultParameters.appServer = this.appServer;
|
|
1815
652
|
}
|
|
1816
653
|
if (this.apiHost) {
|
|
1817
|
-
this.apiHost = this.getIsViewMode() ? removeTrailingSlash(this.apiHost) : addTrailingSlash(this.apiHost);
|
|
654
|
+
this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
|
|
1818
655
|
defaultParameters.apiHost = this.apiHost;
|
|
1819
656
|
} else {
|
|
1820
657
|
this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
|
|
@@ -1823,11 +660,11 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1823
660
|
return defaultParameters;
|
|
1824
661
|
}
|
|
1825
662
|
_updateIframeUrl() {
|
|
1826
|
-
updateIframeUrl(this.iframe, this._iframeUrl);
|
|
663
|
+
SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
|
|
1827
664
|
}
|
|
1828
665
|
// Setup loader / browser error
|
|
1829
666
|
_setupLoader() {
|
|
1830
|
-
const data = getLoader(this);
|
|
667
|
+
const data = SharedLib2.getLoader(this);
|
|
1831
668
|
this._loaderMsg = data.loadingMsg;
|
|
1832
669
|
if (data.errorMsg) {
|
|
1833
670
|
this.browserError = true;
|
|
@@ -1847,15 +684,15 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1847
684
|
_calculateDimAfterDashboardLoaded() {
|
|
1848
685
|
this.dashboardError = false;
|
|
1849
686
|
this._loaderStyles();
|
|
1850
|
-
_setCalculatedDimensions(this);
|
|
687
|
+
SharedLib2._setCalculatedDimensions(this);
|
|
1851
688
|
}
|
|
1852
689
|
// Set loader styles
|
|
1853
690
|
_loaderStyles() {
|
|
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);
|
|
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);
|
|
1859
696
|
}
|
|
1860
697
|
static get styles() {
|
|
1861
698
|
return [dashboardStyles];
|
|
@@ -1926,7 +763,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1926
763
|
`;
|
|
1927
764
|
}
|
|
1928
765
|
return html`
|
|
1929
|
-
<div class="${luzmoEmbedContainerClass}">
|
|
766
|
+
<div class="${luzmoEmbedContainerClass} ${!this.getIsViewMode() ? `${luzmoEmbedContainerClass}-ede` : ""}">
|
|
1930
767
|
<div
|
|
1931
768
|
class="dashboard-container"
|
|
1932
769
|
style=${styleMap(Object.assign({}, this._containerStyle, {
|
|
@@ -1951,7 +788,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1951
788
|
return this.dashboardReference.getData(itemId);
|
|
1952
789
|
}
|
|
1953
790
|
if (!this.getIsViewMode()) {
|
|
1954
|
-
return getData(this, this.iframe, itemId);
|
|
791
|
+
return SharedLib2.getData(this, this.iframe, itemId);
|
|
1955
792
|
}
|
|
1956
793
|
return Promise.reject();
|
|
1957
794
|
}
|
|
@@ -1960,7 +797,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1960
797
|
return this.dashboardReference.getFilters();
|
|
1961
798
|
}
|
|
1962
799
|
if (!this.getIsViewMode()) {
|
|
1963
|
-
return getFilters(this, this.iframe);
|
|
800
|
+
return SharedLib2.getFilters(this, this.iframe);
|
|
1964
801
|
}
|
|
1965
802
|
return Promise.reject();
|
|
1966
803
|
}
|
|
@@ -1969,7 +806,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1969
806
|
return this.dashboardReference.setFilters(itemId, filters);
|
|
1970
807
|
}
|
|
1971
808
|
if (!this.getIsViewMode()) {
|
|
1972
|
-
return setFilters(this, this.iframe, itemId, filters);
|
|
809
|
+
return SharedLib2.setFilters(this, this.iframe, itemId, filters);
|
|
1973
810
|
}
|
|
1974
811
|
return Promise.reject();
|
|
1975
812
|
}
|
|
@@ -1978,7 +815,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1978
815
|
return this.dashboardReference.setAuthorization(key, token);
|
|
1979
816
|
}
|
|
1980
817
|
if (!this.getIsViewMode()) {
|
|
1981
|
-
return setAuthorization(this, this.iframe, key, token);
|
|
818
|
+
return SharedLib2.setAuthorization(this, this.iframe, key, token);
|
|
1982
819
|
}
|
|
1983
820
|
return Promise.reject();
|
|
1984
821
|
}
|
|
@@ -1987,7 +824,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1987
824
|
return this.dashboardReference.refreshData(itemId);
|
|
1988
825
|
}
|
|
1989
826
|
if (!this.getIsViewMode()) {
|
|
1990
|
-
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);
|
|
1991
828
|
}
|
|
1992
829
|
return Promise.reject();
|
|
1993
830
|
}
|
|
@@ -1996,7 +833,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
1996
833
|
return this.dashboardReference.reloadDashboard();
|
|
1997
834
|
}
|
|
1998
835
|
if (!this.getIsViewMode()) {
|
|
1999
|
-
return reloadDashboard(this, this.iframe);
|
|
836
|
+
return SharedLib2.reloadDashboard(this, this.iframe);
|
|
2000
837
|
}
|
|
2001
838
|
return Promise.reject();
|
|
2002
839
|
}
|
|
@@ -2005,13 +842,13 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
2005
842
|
return this.dashboardReference.exportDashboard(format);
|
|
2006
843
|
}
|
|
2007
844
|
if (!this.getIsViewMode()) {
|
|
2008
|
-
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);
|
|
2009
846
|
}
|
|
2010
847
|
return Promise.reject();
|
|
2011
848
|
}
|
|
2012
849
|
getAccessibleDashboards() {
|
|
2013
850
|
if (!this.getIsViewMode()) {
|
|
2014
|
-
return getAccessibleDashboards(this, this.iframe);
|
|
851
|
+
return SharedLib2.getAccessibleDashboards(this, this.iframe);
|
|
2015
852
|
}
|
|
2016
853
|
if (this.getIsViewMode() && this.dashboardReference) {
|
|
2017
854
|
return this.dashboardReference.getAccessibleDashboards();
|
|
@@ -2044,7 +881,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
2044
881
|
return this.dashboardReference.setEditMode(editMode);
|
|
2045
882
|
}
|
|
2046
883
|
if (!this.getIsViewMode()) {
|
|
2047
|
-
return setEditMode(this, this.iframe, editMode);
|
|
884
|
+
return SharedLib2.setEditMode(this, this.iframe, editMode);
|
|
2048
885
|
}
|
|
2049
886
|
return Promise.reject();
|
|
2050
887
|
}
|
|
@@ -2052,7 +889,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
2052
889
|
if (this.getIsViewMode() && this.dashboardReference) {
|
|
2053
890
|
return this.dashboardReference.setPreview(preview);
|
|
2054
891
|
}
|
|
2055
|
-
return setPreview(this, this.iframe, preview);
|
|
892
|
+
return SharedLib2.setPreview(this, this.iframe, preview);
|
|
2056
893
|
}
|
|
2057
894
|
getIsViewMode() {
|
|
2058
895
|
if (this.experimental && this.params.editMode === "view" || this.params.editMode === void 0) {
|