@luzmo/embed 5.0.4 → 5.0.5
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/index.js +78 -1195
- package/index.mjs +63 -1196
- package/index.umd.js +79 -1197
- package/lib/dashboard-component/dashboard-component.d.ts +1 -1
- package/lib/models/filters.model.d.ts +6 -0
- package/luzmo-embed.min.js +79 -1197
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,1141 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
if (errorMessage) {
|
|
16
|
-
message += `:
|
|
17
|
-
${errorMessage}`;
|
|
18
|
-
console.error(message);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const _browserCheck = (dashboardComponent) => {
|
|
22
|
-
let hasError = false;
|
|
23
|
-
let errorMessage = "";
|
|
24
|
-
const document_ = document.body || document.documentElement;
|
|
25
|
-
const style = document_.style;
|
|
26
|
-
const browserCheck = {
|
|
27
|
-
svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
|
|
28
|
-
flexbox: style.webkitFlexWrap === "" || style.flexWrap === "",
|
|
29
|
-
postMessage: !!window.postMessage
|
|
30
|
-
};
|
|
31
|
-
const browserCheckKeys = ["svg", "flexbox", "postMessage"];
|
|
32
|
-
for (const key of browserCheckKeys) {
|
|
33
|
-
if (!browserCheck[key]) {
|
|
34
|
-
hasError = true;
|
|
35
|
-
dashboardComponent.browserNotSupported = dashboardComponent.browserNotSupported || [];
|
|
36
|
-
dashboardComponent.browserNotSupported.push(key);
|
|
37
|
-
errorMessage += `Your browser does not support: ${key}
|
|
38
|
-
`;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const ua = window.navigator.userAgent;
|
|
42
|
-
const msie = ua.includes("MSIE");
|
|
43
|
-
const trident = ua.includes("Trident/");
|
|
44
|
-
if (msie || trident) {
|
|
45
|
-
hasError = true;
|
|
46
|
-
errorMessage = "IE is not supported.";
|
|
47
|
-
}
|
|
48
|
-
if (hasError) {
|
|
49
|
-
_handleError(errorMessage);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const DEFAULT_PARAMETERS = {
|
|
53
|
-
appServer: "https://app.luzmo.com/",
|
|
54
|
-
apiHost: "https://api.luzmo.com/",
|
|
55
|
-
dashboardId: null,
|
|
56
|
-
dashboardSlug: null,
|
|
57
|
-
container: null,
|
|
58
|
-
key: null,
|
|
59
|
-
token: null,
|
|
60
|
-
language: "auto",
|
|
61
|
-
qeVersion: null,
|
|
62
|
-
editMode: null,
|
|
63
|
-
screenMode: null,
|
|
64
|
-
switchScreenModeOnResize: true,
|
|
65
|
-
itemId: null,
|
|
66
|
-
mainColor: "",
|
|
67
|
-
accentColor: "",
|
|
68
|
-
itemDimensions: {
|
|
69
|
-
width: "auto",
|
|
70
|
-
height: "auto"
|
|
71
|
-
},
|
|
72
|
-
loaderBackground: "#f9f9f9",
|
|
73
|
-
loaderFontColor: "#5a5a5a",
|
|
74
|
-
loaderSpinnerColor: "rgba(255, 165, 0, 0.7)",
|
|
75
|
-
loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
|
|
76
|
-
timezoneId: null
|
|
77
|
-
};
|
|
78
|
-
const EXTENTS = [
|
|
79
|
-
{ mode: "mobile", width: [150, 767] },
|
|
80
|
-
{ mode: "tablet", width: [768, 1199] },
|
|
81
|
-
{ mode: "desktop", width: [1200, 1599] },
|
|
82
|
-
{ mode: "largeScreen", width: [1600, 9999] },
|
|
83
|
-
{ mode: "fixed", width: [] }
|
|
84
|
-
];
|
|
85
|
-
const TRANSLATIONS = {
|
|
86
|
-
initializing: { en: "Initializing...", nl: "Laden...", fr: "Chargement..." },
|
|
87
|
-
errorDashboard: {
|
|
88
|
-
en: "Oops, we could not load this dashboard!",
|
|
89
|
-
nl: "Oeps, we konden het dashboard niet laden.",
|
|
90
|
-
fr: "Le chargement a echoué."
|
|
91
|
-
},
|
|
92
|
-
errorItem: {
|
|
93
|
-
en: "Oops, we could not load this item!",
|
|
94
|
-
nl: "Oeps, we konden de grafiek niet laden.",
|
|
95
|
-
fr: "Le chargement a echoué."
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const addTrailingSlash = (serverUrl) => {
|
|
99
|
-
if (!serverUrl) {
|
|
100
|
-
return "";
|
|
101
|
-
}
|
|
102
|
-
return serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
|
|
103
|
-
};
|
|
104
|
-
const removeTrailingSlash = (serverUrl) => {
|
|
105
|
-
if (!serverUrl) {
|
|
106
|
-
return "";
|
|
107
|
-
}
|
|
108
|
-
return serverUrl.endsWith("/") ? serverUrl.slice(0, -1) : serverUrl;
|
|
109
|
-
};
|
|
110
|
-
const formatDashboardList = (dashboards, integrationId, user, dashboardComponent) => {
|
|
111
|
-
var _a2;
|
|
112
|
-
const combineRights = (securable, user2) => {
|
|
113
|
-
var _a3;
|
|
114
|
-
const matchingUser = securable.users.find((u2) => u2.id === user2.id);
|
|
115
|
-
const securableAccessRights = matchingUser && matchingUser.userAccessRight ? {
|
|
116
|
-
flagRead: matchingUser.userAccessRight.flagRead,
|
|
117
|
-
flagUse: matchingUser.userAccessRight.flagUse,
|
|
118
|
-
flagModify: matchingUser.userAccessRight.flagModify,
|
|
119
|
-
flagOwn: matchingUser.userAccessRight.flagOwn
|
|
120
|
-
} : {
|
|
121
|
-
flagRead: false,
|
|
122
|
-
flagUse: false,
|
|
123
|
-
flagModify: false,
|
|
124
|
-
flagOwn: false
|
|
125
|
-
};
|
|
126
|
-
const groups = securable.groups.filter(
|
|
127
|
-
(group) => user2.userGroups.includes(group.id) || group.public === true
|
|
128
|
-
);
|
|
129
|
-
const groupsAccess = groups.map((group) => {
|
|
130
|
-
if (group.groupAccessRight) {
|
|
131
|
-
return group.groupAccessRight;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
for (const groupAccess of groupsAccess) {
|
|
135
|
-
if (!securableAccessRights.flagRead && groupAccess.flagRead) {
|
|
136
|
-
securableAccessRights.flagRead = groupAccess.flagRead;
|
|
137
|
-
}
|
|
138
|
-
if (!securableAccessRights.flagUse && groupAccess.flagUse) {
|
|
139
|
-
securableAccessRights.flagUse = groupAccess.flagUse;
|
|
140
|
-
}
|
|
141
|
-
if (!securableAccessRights.flagModify && groupAccess.flagModify) {
|
|
142
|
-
securableAccessRights.flagModify = groupAccess.flagModify;
|
|
143
|
-
}
|
|
144
|
-
if (!securableAccessRights.flagOwn && groupAccess.flagOwn) {
|
|
145
|
-
securableAccessRights.flagOwn = groupAccess.flagOwn;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
const integrationsAccess = ((_a3 = securable.integrations) == null ? void 0 : _a3.length) > 0 ? securable.integrations.map((integration) => {
|
|
149
|
-
if (integration.integrationAccessRight) {
|
|
150
|
-
return integration.integrationAccessRight;
|
|
151
|
-
}
|
|
152
|
-
}) : [];
|
|
153
|
-
for (const integrationAccess of integrationsAccess) {
|
|
154
|
-
if (!securableAccessRights.flagRead && integrationAccess.flagRead) {
|
|
155
|
-
securableAccessRights.flagRead = integrationAccess.flagRead;
|
|
156
|
-
}
|
|
157
|
-
if (!securableAccessRights.flagUse && integrationAccess.flagUse) {
|
|
158
|
-
securableAccessRights.flagUse = integrationAccess.flagUse;
|
|
159
|
-
}
|
|
160
|
-
if (!securableAccessRights.flagModify && integrationAccess.flagModify) {
|
|
161
|
-
securableAccessRights.flagModify = integrationAccess.flagModify;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return securableAccessRights;
|
|
165
|
-
};
|
|
166
|
-
const localize = (item, locale) => {
|
|
167
|
-
if (item === null || item === void 0) {
|
|
168
|
-
return "";
|
|
169
|
-
}
|
|
170
|
-
if (typeof item !== "object" || Object.keys(item).length === 0) {
|
|
171
|
-
if (typeof item === "object" && Object.keys(item).length === 0) {
|
|
172
|
-
return "";
|
|
173
|
-
}
|
|
174
|
-
return item;
|
|
175
|
-
}
|
|
176
|
-
let localizedItem;
|
|
177
|
-
localizedItem = locale && item[locale] ? item[locale] : item[Object.keys(item)[0]];
|
|
178
|
-
if (localizedItem === void 0 || localizedItem === null) {
|
|
179
|
-
localizedItem = "";
|
|
180
|
-
}
|
|
181
|
-
return localizedItem;
|
|
182
|
-
};
|
|
183
|
-
const treatedDashboards = [];
|
|
184
|
-
for (const dashboard of dashboards) {
|
|
185
|
-
const treatedDashboard = {
|
|
186
|
-
accessibleBy: [],
|
|
187
|
-
accessRights: combineRights(dashboard, user),
|
|
188
|
-
id: dashboard.id,
|
|
189
|
-
modifiedAt: dashboard.modified_at,
|
|
190
|
-
name: localize(dashboard.name, dashboardComponent.language),
|
|
191
|
-
slug: null,
|
|
192
|
-
tags: dashboard.tags.map((t2) => t2.tag).sort((t1, t2) => t1.localeCompare(t2))
|
|
193
|
-
};
|
|
194
|
-
const currentIntegration = dashboard.integrations.find(
|
|
195
|
-
(i3) => i3.id === integrationId
|
|
196
|
-
);
|
|
197
|
-
if ((_a2 = currentIntegration == null ? void 0 : currentIntegration.integrationAccessRight) == null ? void 0 : _a2.slug) {
|
|
198
|
-
treatedDashboard.slug = currentIntegration.integrationAccessRight.slug;
|
|
199
|
-
}
|
|
200
|
-
const users = dashboard.users.map((u2) => ({
|
|
201
|
-
model: "User",
|
|
202
|
-
id: u2.id,
|
|
203
|
-
name: localize(u2.name, user.locale_id)
|
|
204
|
-
}));
|
|
205
|
-
const groups = dashboard.groups.map((g2) => ({
|
|
206
|
-
model: "Group",
|
|
207
|
-
id: g2.id,
|
|
208
|
-
name: localize(g2.name, user.locale_id) || {}
|
|
209
|
-
}));
|
|
210
|
-
const integrations = dashboard.integrations.map((i3) => ({
|
|
211
|
-
model: "Integration",
|
|
212
|
-
id: i3.id,
|
|
213
|
-
name: localize(i3.name, user.locale_id) || {}
|
|
214
|
-
}));
|
|
215
|
-
treatedDashboard.accessibleBy = [...users, ...groups, ...integrations];
|
|
216
|
-
treatedDashboards.push(treatedDashboard);
|
|
217
|
-
}
|
|
218
|
-
return treatedDashboards;
|
|
219
|
-
};
|
|
220
|
-
const VERSION = "0.0.0-shared-luzmo";
|
|
221
|
-
const sanitizeUrl = (url) => {
|
|
222
|
-
const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
|
|
223
|
-
const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
|
|
224
|
-
const urlSchemeRegex = /^([^:]+):/gm;
|
|
225
|
-
const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
|
|
226
|
-
const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
|
|
227
|
-
if (!url) {
|
|
228
|
-
return "about:blank";
|
|
229
|
-
}
|
|
230
|
-
const sanitizedUrl = url.replaceAll(ctrlCharactersRegex, "").trim();
|
|
231
|
-
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
232
|
-
return sanitizedUrl;
|
|
233
|
-
}
|
|
234
|
-
const urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
|
|
235
|
-
if (!urlSchemeParseResults) {
|
|
236
|
-
return sanitizedUrl;
|
|
237
|
-
}
|
|
238
|
-
const urlScheme = urlSchemeParseResults[0];
|
|
239
|
-
if (invalidPrototcolRegex.test(urlScheme)) {
|
|
240
|
-
return "about:blank";
|
|
241
|
-
}
|
|
242
|
-
return sanitizedUrl;
|
|
243
|
-
};
|
|
244
|
-
const cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
|
|
245
|
-
const isObject = (o2) => o2 && typeof o2 === "object";
|
|
246
|
-
const defaultsDeep = (target, defaults) => {
|
|
247
|
-
Object.entries(defaults).forEach(([k2, v2]) => {
|
|
248
|
-
if (k2 in target) {
|
|
249
|
-
if (target[k2] === void 0) {
|
|
250
|
-
target[k2] = v2;
|
|
251
|
-
} else {
|
|
252
|
-
target[k2] = isObject(v2) ? defaultsDeep(
|
|
253
|
-
target[k2],
|
|
254
|
-
v2
|
|
255
|
-
) : target[k2];
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
target[k2] = v2;
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
return target;
|
|
262
|
-
};
|
|
263
|
-
const uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(c2) {
|
|
264
|
-
const r2 = Math.random() * 16 | 0;
|
|
265
|
-
const v2 = c2 == "x" ? r2 : r2 & 3 | 8;
|
|
266
|
-
return v2.toString(16);
|
|
267
|
-
});
|
|
268
|
-
const createIframeUrl = (dashboardContent) => {
|
|
269
|
-
const searchString = [];
|
|
270
|
-
const {
|
|
271
|
-
appServer,
|
|
272
|
-
language,
|
|
273
|
-
qeVersion,
|
|
274
|
-
loaderBackground,
|
|
275
|
-
loaderSpinnerColor,
|
|
276
|
-
loaderSpinnerBackground,
|
|
277
|
-
loaderFontColor,
|
|
278
|
-
screenMode,
|
|
279
|
-
key,
|
|
280
|
-
token,
|
|
281
|
-
timezoneId,
|
|
282
|
-
itemEmbedding,
|
|
283
|
-
itemDimensions,
|
|
284
|
-
dashboardId,
|
|
285
|
-
dashboardSlug,
|
|
286
|
-
itemId,
|
|
287
|
-
mainColor,
|
|
288
|
-
accentColor,
|
|
289
|
-
editMode
|
|
290
|
-
} = dashboardContent.params;
|
|
291
|
-
if (language && language !== "auto") {
|
|
292
|
-
searchString.push("language=" + language);
|
|
293
|
-
}
|
|
294
|
-
if (qeVersion) {
|
|
295
|
-
searchString.push(`qe_version=${qeVersion}`);
|
|
296
|
-
}
|
|
297
|
-
if (loaderBackground) {
|
|
298
|
-
searchString.push(`ldrbg=${loaderBackground}`);
|
|
299
|
-
}
|
|
300
|
-
if (loaderFontColor) {
|
|
301
|
-
searchString.push(`ldrftclr=${loaderFontColor}`);
|
|
302
|
-
}
|
|
303
|
-
if (loaderSpinnerColor) {
|
|
304
|
-
searchString.push(`ldrspclr=${loaderSpinnerColor}`);
|
|
305
|
-
}
|
|
306
|
-
if (loaderSpinnerBackground) {
|
|
307
|
-
searchString.push(`ldrspbg=${loaderSpinnerBackground}`);
|
|
308
|
-
}
|
|
309
|
-
if (mainColor) {
|
|
310
|
-
searchString.push(`mainColor=${mainColor}`);
|
|
311
|
-
}
|
|
312
|
-
if (accentColor) {
|
|
313
|
-
searchString.push(`accentColor=${accentColor}`);
|
|
314
|
-
}
|
|
315
|
-
if (screenMode && screenMode !== "auto") {
|
|
316
|
-
searchString.push("screenMode=" + screenMode);
|
|
317
|
-
}
|
|
318
|
-
if (timezoneId) {
|
|
319
|
-
searchString.push("timezoneId=" + timezoneId);
|
|
320
|
-
}
|
|
321
|
-
if (itemEmbedding && itemDimensions && itemDimensions.width) {
|
|
322
|
-
searchString.push("width=" + itemDimensions.width);
|
|
323
|
-
}
|
|
324
|
-
if (itemEmbedding && itemDimensions && itemDimensions.height) {
|
|
325
|
-
searchString.push("height=" + itemDimensions.height);
|
|
326
|
-
}
|
|
327
|
-
if (editMode) {
|
|
328
|
-
searchString.push("editMode=" + editMode);
|
|
329
|
-
}
|
|
330
|
-
const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
|
|
331
|
-
searchString.push("version=" + (dashboardContent.VERSION || VERSION));
|
|
332
|
-
const iframeUrl = itemEmbedding ? `${appServer}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
|
|
333
|
-
searchString.join("&")
|
|
334
|
-
)}${keyTokenUrlAnchor}` : `${appServer}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
|
|
335
|
-
searchString.join("&")
|
|
336
|
-
)}${keyTokenUrlAnchor}`;
|
|
337
|
-
return sanitizeUrl(iframeUrl);
|
|
338
|
-
};
|
|
339
|
-
const getLoader = (dashboardComponent) => {
|
|
340
|
-
let errorMsg;
|
|
341
|
-
if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
|
|
342
|
-
dashboardComponent.params.error = true;
|
|
343
|
-
if (dashboardComponent.browserNotSupported) {
|
|
344
|
-
errorMsg = "Browser is not supported.";
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
const loadingMsg = TRANSLATIONS.initializing[dashboardComponent.params.language] || TRANSLATIONS.initializing.en;
|
|
348
|
-
return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
|
|
349
|
-
};
|
|
350
|
-
function resolvePromise(dashboardComponent, requestId, data) {
|
|
351
|
-
if (dashboardComponent.promises[requestId]) {
|
|
352
|
-
dashboardComponent.promises[requestId].resolve(data);
|
|
353
|
-
delete dashboardComponent.promises[requestId];
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
function rejectPromise(dashboardComponent, requestId, data) {
|
|
357
|
-
if (dashboardComponent.promises[requestId]) {
|
|
358
|
-
dashboardComponent.promises[requestId].reject(data);
|
|
359
|
-
delete dashboardComponent.promises[requestId];
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
function containerStyles(dashboardComponent) {
|
|
363
|
-
const styles = {
|
|
364
|
-
width: "100%",
|
|
365
|
-
height: "100%"
|
|
366
|
-
};
|
|
367
|
-
if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
|
|
368
|
-
styles.background = dashboardComponent.params.loaderBackground;
|
|
369
|
-
}
|
|
370
|
-
return styles;
|
|
371
|
-
}
|
|
372
|
-
function containerLoaderStyles(dashboardComponent) {
|
|
373
|
-
var _a2;
|
|
374
|
-
const height = ((_a2 = dashboardComponent.params.itemDimensions) == null ? void 0 : _a2.height) || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
375
|
-
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
376
|
-
const display = dashboardComponent.iframeLoaded ? "none" : "";
|
|
377
|
-
return {
|
|
378
|
-
display,
|
|
379
|
-
height: `${chartHeightDefined ? height : dashboardComponent.minHeight}px`
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
function loaderStyles(dashboardComponent) {
|
|
383
|
-
var _a2, _b;
|
|
384
|
-
const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
|
|
385
|
-
if (dashboardComponent.params.itemEmbedding) {
|
|
386
|
-
dashboardComponent.loaderSize = 24;
|
|
387
|
-
dashboardComponent.borderWidth = 4;
|
|
388
|
-
dashboardComponent.minHeight = 200;
|
|
389
|
-
const width = ((_a2 = dashboardComponent.params.itemDimensions) == null ? void 0 : _a2.width) || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
390
|
-
const height = ((_b = dashboardComponent.params.itemDimensions) == null ? void 0 : _b.height) || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
391
|
-
const chartWidthDefined = width !== "auto";
|
|
392
|
-
const chartHeightDefined = height !== "auto";
|
|
393
|
-
return {
|
|
394
|
-
background,
|
|
395
|
-
width: chartWidthDefined ? `${width}px` : "100%",
|
|
396
|
-
height: `${chartHeightDefined ? height : "200"}px`,
|
|
397
|
-
"min-height": chartHeightDefined ? "" : "200px"
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
return {
|
|
401
|
-
background
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
function plStyles(dashboardComponent) {
|
|
405
|
-
const {
|
|
406
|
-
loaderSpinnerColor: defaultSpinnerColor,
|
|
407
|
-
loaderSpinnerBackground: defaultSpinnerBackground
|
|
408
|
-
} = DEFAULT_PARAMETERS;
|
|
409
|
-
const spinnerColorBorder = generateBorderStyle(
|
|
410
|
-
dashboardComponent.borderWidth,
|
|
411
|
-
dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
|
|
412
|
-
);
|
|
413
|
-
const spinnerBackgroundBorder = generateBorderStyle(
|
|
414
|
-
dashboardComponent.borderWidth,
|
|
415
|
-
dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
|
|
416
|
-
);
|
|
417
|
-
const size = `${dashboardComponent.loaderSize}px`;
|
|
418
|
-
return {
|
|
419
|
-
"border-top": spinnerColorBorder,
|
|
420
|
-
"border-right": spinnerColorBorder,
|
|
421
|
-
"border-bottom": spinnerBackgroundBorder,
|
|
422
|
-
"border-left": spinnerBackgroundBorder,
|
|
423
|
-
width: size,
|
|
424
|
-
height: size
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
function lcStyles(dashboardComponent) {
|
|
428
|
-
var _a2;
|
|
429
|
-
const height = ((_a2 = dashboardComponent.params.itemDimensions) == null ? void 0 : _a2.height) || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
430
|
-
const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
|
|
431
|
-
const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
|
|
432
|
-
const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
|
|
433
|
-
return {
|
|
434
|
-
padding: `${verticalPadding} 16px`
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
function calculateIframeStyles(dashboardComponent) {
|
|
438
|
-
var _a2, _b;
|
|
439
|
-
const height = ((_a2 = dashboardComponent.params.itemDimensions) == null ? void 0 : _a2.height) || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
440
|
-
const width = ((_b = dashboardComponent.params.itemDimensions) == null ? void 0 : _b.width) || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
441
|
-
if (dashboardComponent.params.itemEmbedding && height !== "auto") {
|
|
442
|
-
dashboardComponent.iframeHeight = `${height}px`;
|
|
443
|
-
} else if (dashboardComponent.params.itemEmbedding) {
|
|
444
|
-
dashboardComponent.iframeHeight = "200px";
|
|
445
|
-
} else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
|
|
446
|
-
dashboardComponent.iframeHeight = "100%";
|
|
447
|
-
} else {
|
|
448
|
-
dashboardComponent.iframeHeight = "400px";
|
|
449
|
-
}
|
|
450
|
-
dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
|
|
451
|
-
const styles = {
|
|
452
|
-
height: dashboardComponent.iframeHeight,
|
|
453
|
-
width: dashboardComponent.iframeWidth
|
|
454
|
-
};
|
|
455
|
-
if (dashboardComponent.iframeLoaded) {
|
|
456
|
-
styles.opacity = 1;
|
|
457
|
-
} else if (dashboardComponent.error) {
|
|
458
|
-
styles.opacity = 1;
|
|
459
|
-
styles.width = "100%";
|
|
460
|
-
styles.height = "400px";
|
|
461
|
-
} else {
|
|
462
|
-
styles.opacity = 0;
|
|
463
|
-
}
|
|
464
|
-
return styles;
|
|
465
|
-
}
|
|
466
|
-
function generateBorderStyle(borderWidth, color) {
|
|
467
|
-
return `${borderWidth}px solid ${color}`;
|
|
468
|
-
}
|
|
469
|
-
const updateIframeUrl = (iframe, iframeUrl) => {
|
|
470
|
-
if (iframe == null ? void 0 : iframe.contentWindow) {
|
|
471
|
-
iframe.contentWindow.location.replace(iframeUrl);
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
const remotesMap = {
|
|
475
|
-
// "remote_app": { url: "http://localhost:4201/remoteEntry.mjs", format: "esm", from: "vite" },
|
|
476
|
-
};
|
|
477
|
-
const loadJS = async (url, fn) => {
|
|
478
|
-
const resolvedUrl = typeof url === "function" ? await url() : url;
|
|
479
|
-
const script = document.createElement("script");
|
|
480
|
-
script.type = "text/javascript";
|
|
481
|
-
script.onload = fn;
|
|
482
|
-
script.src = resolvedUrl;
|
|
483
|
-
document.getElementsByTagName("head")[0].appendChild(script);
|
|
484
|
-
};
|
|
485
|
-
const wrapShareModule = (remoteFrom) => {
|
|
486
|
-
return {};
|
|
487
|
-
};
|
|
488
|
-
async function __federation_method_ensure(remoteId) {
|
|
489
|
-
const remote = remotesMap[remoteId];
|
|
490
|
-
if (!remote.inited) {
|
|
491
|
-
if ("var" === remote.format) {
|
|
492
|
-
return new Promise((resolve) => {
|
|
493
|
-
const callback = () => {
|
|
494
|
-
if (!remote.inited) {
|
|
495
|
-
remote.lib = window[remoteId];
|
|
496
|
-
remote.lib.init(wrapShareModule(remote.from));
|
|
497
|
-
remote.inited = true;
|
|
498
|
-
}
|
|
499
|
-
resolve(remote.lib);
|
|
500
|
-
};
|
|
501
|
-
return loadJS(remote.url, callback);
|
|
502
|
-
});
|
|
503
|
-
} else if (["esm", "systemjs"].includes(remote.format)) {
|
|
504
|
-
return new Promise((resolve, reject) => {
|
|
505
|
-
const getUrl = typeof remote.url === "function" ? remote.url : () => Promise.resolve(remote.url);
|
|
506
|
-
getUrl().then((url) => {
|
|
507
|
-
import(
|
|
508
|
-
/* @vite-ignore */
|
|
509
|
-
url
|
|
510
|
-
).then((lib) => {
|
|
511
|
-
if (!remote.inited) {
|
|
512
|
-
const shareScope = wrapShareModule(remote.from);
|
|
513
|
-
lib.init(shareScope);
|
|
514
|
-
remote.lib = lib;
|
|
515
|
-
remote.lib.init(shareScope);
|
|
516
|
-
remote.inited = true;
|
|
517
|
-
}
|
|
518
|
-
resolve(remote.lib);
|
|
519
|
-
}).catch(reject);
|
|
520
|
-
});
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
} else {
|
|
524
|
-
return remote.lib;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
function __federation_method_wrapDefault(module2, need) {
|
|
528
|
-
if (!(module2 == null ? void 0 : module2.default) && need) {
|
|
529
|
-
let obj = /* @__PURE__ */ Object.create(null);
|
|
530
|
-
obj.default = module2;
|
|
531
|
-
obj.__esModule = true;
|
|
532
|
-
return obj;
|
|
533
|
-
}
|
|
534
|
-
return module2;
|
|
535
|
-
}
|
|
536
|
-
function __federation_method_getRemote(remoteName, componentName) {
|
|
537
|
-
return __federation_method_ensure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
|
|
538
|
-
}
|
|
539
|
-
const exportDashboard = (dashboardComponent, iframe, format) => {
|
|
540
|
-
const requestId = uuidv4();
|
|
541
|
-
if (iframe == null ? void 0 : iframe.contentWindow) {
|
|
542
|
-
iframe.contentWindow.postMessage(
|
|
543
|
-
{
|
|
544
|
-
action: "exportDashboard",
|
|
545
|
-
format: format || "png",
|
|
546
|
-
_version: dashboardComponent.VERSION,
|
|
547
|
-
requestId
|
|
548
|
-
},
|
|
549
|
-
"*"
|
|
550
|
-
);
|
|
551
|
-
return new Promise((resolve, reject) => {
|
|
552
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
553
|
-
setTimeout(() => {
|
|
554
|
-
if (dashboardComponent.promises[requestId]) {
|
|
555
|
-
const errorMessage = "exportDashboard request timed out.";
|
|
556
|
-
dashboardComponent.promises[requestId].reject(
|
|
557
|
-
new Error(errorMessage)
|
|
558
|
-
);
|
|
559
|
-
delete dashboardComponent.promises[requestId];
|
|
560
|
-
}
|
|
561
|
-
}, 12e5);
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
565
|
-
};
|
|
566
|
-
const getAccessibleDashboards = (dashboardComponent, iframe) => {
|
|
567
|
-
if ((dashboardComponent.dashboardId || dashboardComponent.dashboardSlug) && (iframe == null ? void 0 : iframe.contentWindow)) {
|
|
568
|
-
const requestId = uuidv4();
|
|
569
|
-
iframe.contentWindow.postMessage(
|
|
570
|
-
{
|
|
571
|
-
action: "getAccessibleDashboards",
|
|
572
|
-
_version: dashboardComponent.VERSION,
|
|
573
|
-
requestId
|
|
574
|
-
},
|
|
575
|
-
"*"
|
|
576
|
-
);
|
|
577
|
-
return new Promise((resolve, reject) => {
|
|
578
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
579
|
-
setTimeout(() => {
|
|
580
|
-
if (dashboardComponent.promises[requestId]) {
|
|
581
|
-
const errorMessage = "getAccessibleDashboards request timed out.";
|
|
582
|
-
dashboardComponent.promises[requestId].reject(
|
|
583
|
-
new Error(errorMessage)
|
|
584
|
-
);
|
|
585
|
-
delete dashboardComponent.promises[requestId];
|
|
586
|
-
}
|
|
587
|
-
}, 2e3);
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
const fetchUser = new Promise((resolve, reject) => {
|
|
591
|
-
void (() => {
|
|
592
|
-
try {
|
|
593
|
-
const responsePromise = window.fetch(
|
|
594
|
-
`${String(dashboardComponent.params.apiHost)}0.1.0/authorization`,
|
|
595
|
-
{
|
|
596
|
-
method: "POST",
|
|
597
|
-
mode: "cors",
|
|
598
|
-
cache: "no-cache",
|
|
599
|
-
headers: { "Content-Type": "application/json" },
|
|
600
|
-
redirect: "follow",
|
|
601
|
-
body: JSON.stringify({
|
|
602
|
-
action: "get",
|
|
603
|
-
version: "0.1.0",
|
|
604
|
-
key: dashboardComponent.authKey,
|
|
605
|
-
token: dashboardComponent.authToken,
|
|
606
|
-
find: {
|
|
607
|
-
where: { id: dashboardComponent.authKey },
|
|
608
|
-
attributes: ["id", "integration_id"],
|
|
609
|
-
include: [
|
|
610
|
-
{
|
|
611
|
-
model: "User",
|
|
612
|
-
attributes: ["id", "name", "locale_id"],
|
|
613
|
-
include: [{ model: "Group" }]
|
|
614
|
-
}
|
|
615
|
-
]
|
|
616
|
-
}
|
|
617
|
-
})
|
|
618
|
-
}
|
|
619
|
-
);
|
|
620
|
-
responsePromise.then((response) => response.json()).then((data) => {
|
|
621
|
-
if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user || !data.rows[0].integration_id) {
|
|
622
|
-
reject();
|
|
623
|
-
} else {
|
|
624
|
-
data.rows[0].user.userGroups = data.rows[0].user.groups.map(
|
|
625
|
-
(group) => group.id
|
|
626
|
-
);
|
|
627
|
-
delete data.rows[0].user.groups;
|
|
628
|
-
resolve({
|
|
629
|
-
integrationId: data.rows[0].integration_id,
|
|
630
|
-
user: data.rows[0].user
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
} catch (error) {
|
|
635
|
-
reject(error);
|
|
636
|
-
}
|
|
637
|
-
})();
|
|
638
|
-
});
|
|
639
|
-
return new Promise((resolve, reject) => void (() => {
|
|
640
|
-
try {
|
|
641
|
-
fetchUser.then((authorizationData) => {
|
|
642
|
-
const responsePromise = window.fetch(
|
|
643
|
-
`${String(dashboardComponent.params.apiHost)}0.1.0/securable`,
|
|
644
|
-
{
|
|
645
|
-
method: "POST",
|
|
646
|
-
mode: "cors",
|
|
647
|
-
cache: "no-cache",
|
|
648
|
-
headers: { "Content-Type": "application/json" },
|
|
649
|
-
redirect: "follow",
|
|
650
|
-
body: JSON.stringify({
|
|
651
|
-
action: "get",
|
|
652
|
-
version: "0.1.0",
|
|
653
|
-
key: dashboardComponent.authKey,
|
|
654
|
-
token: dashboardComponent.authToken,
|
|
655
|
-
find: {
|
|
656
|
-
where: { type: "dashboard", is_variant: false },
|
|
657
|
-
attributes: ["id", "name", "modified_at"],
|
|
658
|
-
order: [["modified_at", "desc"]],
|
|
659
|
-
include: [
|
|
660
|
-
{ model: "Tag", attributes: ["tag"] },
|
|
661
|
-
{ model: "User", attributes: ["id", "name"] },
|
|
662
|
-
{
|
|
663
|
-
model: "Group",
|
|
664
|
-
attributes: ["id", "name", "public"]
|
|
665
|
-
},
|
|
666
|
-
{ model: "Integration", attributes: ["id", "name"] }
|
|
667
|
-
]
|
|
668
|
-
}
|
|
669
|
-
})
|
|
670
|
-
}
|
|
671
|
-
);
|
|
672
|
-
responsePromise.then((response) => response.json()).then((data) => {
|
|
673
|
-
const dashboardList = data.rows.length > 0 ? formatDashboardList(
|
|
674
|
-
data.rows,
|
|
675
|
-
authorizationData.integrationId,
|
|
676
|
-
authorizationData.user,
|
|
677
|
-
dashboardComponent
|
|
678
|
-
) : [];
|
|
679
|
-
resolve(dashboardList);
|
|
680
|
-
});
|
|
681
|
-
}).catch((error) => {
|
|
682
|
-
reject(error);
|
|
683
|
-
});
|
|
684
|
-
} catch (error) {
|
|
685
|
-
reject(error);
|
|
686
|
-
}
|
|
687
|
-
})());
|
|
688
|
-
};
|
|
689
|
-
const getData = (dashboardComponent, iframe, itemId) => {
|
|
690
|
-
if (iframe == null ? void 0 : iframe.contentWindow) {
|
|
691
|
-
const requestId = uuidv4();
|
|
692
|
-
iframe.contentWindow.postMessage(
|
|
693
|
-
{
|
|
694
|
-
action: "getData",
|
|
695
|
-
id: itemId,
|
|
696
|
-
_version: dashboardComponent.VERSION,
|
|
697
|
-
requestId
|
|
698
|
-
},
|
|
699
|
-
"*"
|
|
700
|
-
);
|
|
701
|
-
return new Promise((resolve, reject) => {
|
|
702
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
703
|
-
setTimeout(() => {
|
|
704
|
-
if (dashboardComponent.promises[requestId]) {
|
|
705
|
-
const errorMessage = "getData request timed out.";
|
|
706
|
-
dashboardComponent.promises[requestId].reject(
|
|
707
|
-
new Error(errorMessage)
|
|
708
|
-
);
|
|
709
|
-
delete dashboardComponent.promises[requestId];
|
|
710
|
-
}
|
|
711
|
-
}, 2e3);
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
715
|
-
};
|
|
716
|
-
const getFilters = (dashboardComponent, iframe) => {
|
|
717
|
-
if (iframe == null ? void 0 : iframe.contentWindow) {
|
|
718
|
-
const requestId = uuidv4();
|
|
719
|
-
iframe.contentWindow.postMessage(
|
|
720
|
-
{ action: "getFilters", _version: dashboardComponent.VERSION, requestId },
|
|
721
|
-
"*"
|
|
722
|
-
);
|
|
723
|
-
return new Promise((resolve, reject) => {
|
|
724
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
725
|
-
setTimeout(() => {
|
|
726
|
-
if (dashboardComponent.promises[requestId]) {
|
|
727
|
-
const errorMessage = "getFilters request timed out.";
|
|
728
|
-
dashboardComponent.promises[requestId].reject(
|
|
729
|
-
new Error(errorMessage)
|
|
730
|
-
);
|
|
731
|
-
delete dashboardComponent.promises[requestId];
|
|
732
|
-
}
|
|
733
|
-
}, 2e3);
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
737
|
-
};
|
|
738
|
-
const refreshData = (dashboardComponent, iframe, itemId) => {
|
|
739
|
-
if (iframe) {
|
|
740
|
-
iframe.contentWindow.postMessage(
|
|
741
|
-
{
|
|
742
|
-
action: "refreshData",
|
|
743
|
-
id: itemId ?? null,
|
|
744
|
-
_version: dashboardComponent.VERSION
|
|
745
|
-
},
|
|
746
|
-
"*"
|
|
747
|
-
);
|
|
748
|
-
return Promise.resolve();
|
|
749
|
-
}
|
|
750
|
-
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
751
|
-
};
|
|
752
|
-
const reloadDashboard = (dashboardComponent, iframe) => {
|
|
753
|
-
if (iframe) {
|
|
754
|
-
iframe.contentWindow.postMessage(
|
|
755
|
-
{ action: "reloadDashboard", _version: dashboardComponent.VERSION },
|
|
756
|
-
"*"
|
|
757
|
-
);
|
|
758
|
-
return Promise.resolve();
|
|
759
|
-
}
|
|
760
|
-
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
761
|
-
};
|
|
762
|
-
const setAuthorization = (dashboardComponent, iframe, key, token) => {
|
|
763
|
-
if (iframe) {
|
|
764
|
-
iframe.contentWindow.postMessage(
|
|
765
|
-
{
|
|
766
|
-
action: "setAuthorization",
|
|
767
|
-
key,
|
|
768
|
-
token,
|
|
769
|
-
_version: dashboardComponent.VERSION
|
|
770
|
-
},
|
|
771
|
-
"*"
|
|
772
|
-
);
|
|
773
|
-
return Promise.resolve();
|
|
774
|
-
}
|
|
775
|
-
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
776
|
-
};
|
|
777
|
-
const setEditMode = (dashboardComponent, iframe, editMode) => {
|
|
778
|
-
if (iframe && iframe.contentWindow) {
|
|
779
|
-
const requestId = uuidv4();
|
|
780
|
-
if (dashboardComponent.params.editMode === editMode) {
|
|
781
|
-
return Promise.reject(
|
|
782
|
-
new Error("editMode parameter is currently already set to " + editMode)
|
|
783
|
-
);
|
|
784
|
-
} else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
|
|
785
|
-
return Promise.reject(
|
|
786
|
-
new Error(
|
|
787
|
-
"The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
|
|
788
|
-
)
|
|
789
|
-
);
|
|
790
|
-
}
|
|
791
|
-
iframe.contentWindow.postMessage(
|
|
792
|
-
{
|
|
793
|
-
action: "setEditMode",
|
|
794
|
-
editMode,
|
|
795
|
-
_version: dashboardComponent.VERSION,
|
|
796
|
-
requestId
|
|
797
|
-
},
|
|
798
|
-
"*"
|
|
799
|
-
);
|
|
800
|
-
return new Promise((resolve, reject) => {
|
|
801
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
805
|
-
};
|
|
806
|
-
const setFilters = (dashboardComponent, iframe, itemId, filters) => {
|
|
807
|
-
if (iframe) {
|
|
808
|
-
const requestId = uuidv4();
|
|
809
|
-
iframe.contentWindow.postMessage(
|
|
810
|
-
{
|
|
811
|
-
action: "setFilters",
|
|
812
|
-
itemId,
|
|
813
|
-
filters,
|
|
814
|
-
_version: dashboardComponent.VERSION,
|
|
815
|
-
requestId
|
|
816
|
-
},
|
|
817
|
-
"*"
|
|
818
|
-
);
|
|
819
|
-
return new Promise((resolve, reject) => {
|
|
820
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
821
|
-
setTimeout(() => {
|
|
822
|
-
if (dashboardComponent.promises[requestId]) {
|
|
823
|
-
const errorMessage = "setFilters request timed out.";
|
|
824
|
-
dashboardComponent.promises[requestId].reject(
|
|
825
|
-
new Error(errorMessage)
|
|
826
|
-
);
|
|
827
|
-
delete dashboardComponent.promises[requestId];
|
|
828
|
-
}
|
|
829
|
-
}, 2e3);
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
return Promise.reject();
|
|
833
|
-
};
|
|
834
|
-
const setPreview = (dashboardComponent, iframe, preview) => {
|
|
835
|
-
if (iframe) {
|
|
836
|
-
const requestId = uuidv4();
|
|
837
|
-
iframe.contentWindow.postMessage(
|
|
838
|
-
{
|
|
839
|
-
action: "setPreview",
|
|
840
|
-
preview,
|
|
841
|
-
requestId,
|
|
842
|
-
_version: dashboardComponent.VERSION
|
|
843
|
-
},
|
|
844
|
-
"*"
|
|
845
|
-
);
|
|
846
|
-
return new Promise((resolve, reject) => {
|
|
847
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
848
|
-
setTimeout(() => {
|
|
849
|
-
if (dashboardComponent.promises[requestId]) {
|
|
850
|
-
const errorMessage = "setPreview request timed out.";
|
|
851
|
-
dashboardComponent.promises[requestId].reject(
|
|
852
|
-
new Error(errorMessage)
|
|
853
|
-
);
|
|
854
|
-
delete dashboardComponent.promises[requestId];
|
|
855
|
-
}
|
|
856
|
-
}, 2e3);
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
860
|
-
};
|
|
861
|
-
const _setCalculatedDimensions = (dashboardComponent) => {
|
|
862
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
863
|
-
if (!dashboardComponent.dimensions) {
|
|
864
|
-
dashboardComponent.params.error = true;
|
|
865
|
-
_handleError("Got no valid dimensions.", dashboardComponent.params);
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
const dashboardDimensionKeys = Object.keys(
|
|
869
|
-
dashboardComponent.dimensions
|
|
870
|
-
);
|
|
871
|
-
const availableScreenModeExtents = [];
|
|
872
|
-
let currentMode;
|
|
873
|
-
let currentWidth = 0;
|
|
874
|
-
let currentHeight = 0;
|
|
875
|
-
if (!dashboardComponent.params.switchScreenModeOnResize && dashboardComponent.currentScreenMode) {
|
|
876
|
-
dashboardComponent.params.screenMode = dashboardComponent.currentScreenMode;
|
|
877
|
-
}
|
|
878
|
-
if (dashboardComponent.dimensions && (dashboardDimensionKeys == null ? void 0 : dashboardDimensionKeys[0]) === "fixed") {
|
|
879
|
-
currentMode = "fixed";
|
|
880
|
-
currentWidth = dashboardComponent.dimensions.fixed[0];
|
|
881
|
-
currentHeight = dashboardComponent.dimensions.fixed[1];
|
|
882
|
-
} else {
|
|
883
|
-
const screenModes = [
|
|
884
|
-
"mobile",
|
|
885
|
-
"tablet",
|
|
886
|
-
"desktop",
|
|
887
|
-
"largeScreen"
|
|
888
|
-
];
|
|
889
|
-
if (dashboardComponent.params.itemEmbedding) {
|
|
890
|
-
const [firstMatch] = dashboardDimensionKeys;
|
|
891
|
-
let match = cloneDeep(firstMatch);
|
|
892
|
-
for (const screenMode of screenModes) {
|
|
893
|
-
const found = dashboardDimensionKeys.find((key) => key === screenMode);
|
|
894
|
-
if (found) {
|
|
895
|
-
match = cloneDeep(found);
|
|
896
|
-
} else {
|
|
897
|
-
dashboardComponent.dimensions[screenMode] = dashboardComponent.dimensions[match];
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
for (const key of dashboardDimensionKeys) {
|
|
902
|
-
if (screenModes.includes(key)) {
|
|
903
|
-
const screenMode = EXTENTS.find((extent) => extent.mode === key);
|
|
904
|
-
availableScreenModeExtents.push({
|
|
905
|
-
...screenMode,
|
|
906
|
-
height: dashboardComponent.dimensions[key][1] || 50
|
|
4
|
+
const SharedLib = require("@luzmo/shared-embed");
|
|
5
|
+
function _interopNamespaceDefault(e2) {
|
|
6
|
+
const n3 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
+
if (e2) {
|
|
8
|
+
for (const k2 in e2) {
|
|
9
|
+
if (k2 !== "default") {
|
|
10
|
+
const d2 = Object.getOwnPropertyDescriptor(e2, k2);
|
|
11
|
+
Object.defineProperty(n3, k2, d2.get ? d2 : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: () => e2[k2]
|
|
907
14
|
});
|
|
908
15
|
}
|
|
909
16
|
}
|
|
910
|
-
if (!availableScreenModeExtents.map((screenModeExtent) => screenModeExtent.mode).includes(dashboardComponent.params.screenMode)) {
|
|
911
|
-
dashboardComponent.params.screenMode = "auto";
|
|
912
|
-
}
|
|
913
|
-
if (dashboardComponent.params.screenMode === "auto") {
|
|
914
|
-
availableScreenModeExtents.sort(
|
|
915
|
-
(a2, b2) => screenModes.indexOf(a2.mode) - screenModes.indexOf(b2.mode)
|
|
916
|
-
);
|
|
917
|
-
for (const screenModeExtent of availableScreenModeExtents) {
|
|
918
|
-
const [screenModeExtentMinWidth, screenModeExtentMaxWidth] = screenModeExtent.width;
|
|
919
|
-
if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
920
|
-
if (screenModeExtentMinWidth < dashboardComponent.params.itemDimensions.width) {
|
|
921
|
-
currentMode = screenModeExtent.mode;
|
|
922
|
-
currentWidth = Number.parseInt(
|
|
923
|
-
dashboardComponent.params.itemDimensions.width,
|
|
924
|
-
10
|
|
925
|
-
);
|
|
926
|
-
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
927
|
-
}
|
|
928
|
-
} else {
|
|
929
|
-
if (screenModeExtentMinWidth < dashboardComponent.containerWidth) {
|
|
930
|
-
currentMode = screenModeExtent.mode;
|
|
931
|
-
if (dashboardComponent.params.itemEmbedding) {
|
|
932
|
-
currentWidth = ((_a2 = dashboardComponent.params.itemDimensions) == null ? void 0 : _a2.width) && ((_b = dashboardComponent.params.itemDimensions) == null ? void 0 : _b.width) !== "auto" ? Number.parseInt(
|
|
933
|
-
dashboardComponent.params.itemDimensions.width,
|
|
934
|
-
10
|
|
935
|
-
) : Math.min(
|
|
936
|
-
dashboardComponent.containerWidth,
|
|
937
|
-
screenModeExtentMaxWidth
|
|
938
|
-
);
|
|
939
|
-
currentHeight = ((_c = dashboardComponent.params.itemDimensions) == null ? void 0 : _c.height) && ((_d = dashboardComponent.params.itemDimensions) == null ? void 0 : _d.height) !== "auto" ? Number.parseInt(
|
|
940
|
-
dashboardComponent.params.itemDimensions.height,
|
|
941
|
-
10
|
|
942
|
-
) : dashboardComponent.dimensions[currentMode][1];
|
|
943
|
-
if (dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
|
|
944
|
-
currentWidth = Number.parseInt(
|
|
945
|
-
dashboardComponent.params.itemDimensions.width,
|
|
946
|
-
10
|
|
947
|
-
);
|
|
948
|
-
currentHeight = dashboardComponent.dimensions[currentMode][1];
|
|
949
|
-
}
|
|
950
|
-
} else {
|
|
951
|
-
currentWidth = Math.max(
|
|
952
|
-
Math.min(
|
|
953
|
-
screenModeExtentMaxWidth,
|
|
954
|
-
dashboardComponent.containerWidth
|
|
955
|
-
),
|
|
956
|
-
screenModeExtentMinWidth
|
|
957
|
-
);
|
|
958
|
-
currentHeight = screenModeExtent.height;
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
} else {
|
|
964
|
-
const {
|
|
965
|
-
height: chosenModeHeight,
|
|
966
|
-
width: [chosenModeMinWidth, chosenModeMaxWidth]
|
|
967
|
-
} = availableScreenModeExtents.find(
|
|
968
|
-
(d2) => d2.mode === dashboardComponent.params.screenMode
|
|
969
|
-
);
|
|
970
|
-
currentMode = dashboardComponent.params.screenMode;
|
|
971
|
-
currentWidth = Math.max(
|
|
972
|
-
Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
|
|
973
|
-
chosenModeMinWidth
|
|
974
|
-
);
|
|
975
|
-
currentHeight = chosenModeHeight;
|
|
976
|
-
if (dashboardComponent.params.itemEmbedding) {
|
|
977
|
-
if (((_e = dashboardComponent.params.itemDimensions) == null ? void 0 : _e.width) && ((_f = dashboardComponent.params.itemDimensions) == null ? void 0 : _f.width) !== "auto") {
|
|
978
|
-
currentWidth = Number.parseInt(
|
|
979
|
-
dashboardComponent.params.itemDimensions.width,
|
|
980
|
-
10
|
|
981
|
-
);
|
|
982
|
-
}
|
|
983
|
-
if (((_g = dashboardComponent.params.itemDimensions) == null ? void 0 : _g.height) && ((_h = dashboardComponent.params.itemDimensions) == null ? void 0 : _h.height) !== "auto") {
|
|
984
|
-
currentHeight = Number.parseInt(
|
|
985
|
-
dashboardComponent.params.itemDimensions.height,
|
|
986
|
-
10
|
|
987
|
-
);
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
if (!currentMode && availableScreenModeExtents.length > 0) {
|
|
992
|
-
const [lowestModeExtent] = availableScreenModeExtents;
|
|
993
|
-
currentMode = lowestModeExtent.mode;
|
|
994
|
-
currentWidth = lowestModeExtent.width[0];
|
|
995
|
-
currentHeight = lowestModeExtent.height;
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
dashboardComponent.currentScreenMode = currentMode;
|
|
999
|
-
const style = {
|
|
1000
|
-
height: currentHeight === 0 ? "100%" : `${String(currentHeight)}px`,
|
|
1001
|
-
width: currentWidth === 0 ? "100%" : `${String(currentWidth)}px`,
|
|
1002
|
-
opacity: 1
|
|
1003
|
-
};
|
|
1004
|
-
const dashboardEditModes = ["editFull", "editLimited"];
|
|
1005
|
-
if (dashboardEditModes.includes(dashboardComponent.params.editMode)) {
|
|
1006
|
-
style.height = "100%";
|
|
1007
|
-
style.width = "100%";
|
|
1008
|
-
} else if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions) {
|
|
1009
|
-
style.height = dashboardComponent.params.itemDimensions.height === "auto" ? style.height : `${String(dashboardComponent.params.itemDimensions.height).replace(
|
|
1010
|
-
"px",
|
|
1011
|
-
""
|
|
1012
|
-
)}px`;
|
|
1013
|
-
style.width = dashboardComponent.params.itemDimensions.width === "auto" ? style.width : `${String(dashboardComponent.params.itemDimensions.width).replace(
|
|
1014
|
-
"px",
|
|
1015
|
-
""
|
|
1016
|
-
)}px`;
|
|
1017
|
-
} else {
|
|
1018
|
-
style.height = currentHeight === 0 ? "100%" : `${String(currentHeight)}px`;
|
|
1019
|
-
style.width = currentWidth === 0 ? "100%" : `${String(currentWidth)}px`;
|
|
1020
|
-
}
|
|
1021
|
-
dashboardComponent.currentScreenMode = currentMode;
|
|
1022
|
-
dashboardComponent.iframeStyle = style;
|
|
1023
|
-
};
|
|
1024
|
-
const _extendAndValidate = (dashboardContent) => {
|
|
1025
|
-
const defaultKeys = Object.keys(
|
|
1026
|
-
DEFAULT_PARAMETERS
|
|
1027
|
-
);
|
|
1028
|
-
const errorMessages = [];
|
|
1029
|
-
const requiredStringParams = [
|
|
1030
|
-
"appServer",
|
|
1031
|
-
"language",
|
|
1032
|
-
"apiHost"
|
|
1033
|
-
];
|
|
1034
|
-
const requiredStringOrEmptyParams = [
|
|
1035
|
-
"key",
|
|
1036
|
-
"token",
|
|
1037
|
-
"screenMode",
|
|
1038
|
-
"timezoneId",
|
|
1039
|
-
"itemId",
|
|
1040
|
-
"container",
|
|
1041
|
-
"loaderBackground",
|
|
1042
|
-
"loaderFontColor",
|
|
1043
|
-
"loaderSpinnerColor",
|
|
1044
|
-
"loaderSpinnerBackground"
|
|
1045
|
-
];
|
|
1046
|
-
const objectParams = ["itemDimensions"];
|
|
1047
|
-
const screenModes = [
|
|
1048
|
-
"mobile",
|
|
1049
|
-
"tablet",
|
|
1050
|
-
"desktop",
|
|
1051
|
-
"largeScreen",
|
|
1052
|
-
"fixed",
|
|
1053
|
-
"auto"
|
|
1054
|
-
];
|
|
1055
|
-
for (const key of defaultKeys) {
|
|
1056
|
-
if (dashboardContent.params[key] === null) {
|
|
1057
|
-
delete dashboardContent.params[key];
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
dashboardContent.params = defaultsDeep(
|
|
1061
|
-
dashboardContent.params,
|
|
1062
|
-
DEFAULT_PARAMETERS
|
|
1063
|
-
);
|
|
1064
|
-
if ((!dashboardContent.params.dashboardId || typeof dashboardContent.params.dashboardId !== "string") && (!dashboardContent.params.dashboardSlug || typeof dashboardContent.params.dashboardSlug !== "string")) {
|
|
1065
|
-
delete dashboardContent.params.dashboardId;
|
|
1066
|
-
delete dashboardContent.params.dashboardSlug;
|
|
1067
|
-
}
|
|
1068
|
-
for (const key of requiredStringParams) {
|
|
1069
|
-
if (typeof dashboardContent.params[key] !== "string") {
|
|
1070
|
-
delete dashboardContent.params[key];
|
|
1071
|
-
errorMessages.push(`${key} needs to be of type string.`);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
for (const key of requiredStringOrEmptyParams) {
|
|
1075
|
-
if (typeof dashboardContent.params[key] !== "string" && dashboardContent.params[key] !== null && dashboardContent.params[key] !== void 0) {
|
|
1076
|
-
delete dashboardContent.params[key];
|
|
1077
|
-
errorMessages.push(`${key} needs to be of type string or empty.`);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
if (dashboardContent.params.screenMode && !screenModes.includes(dashboardContent.params.screenMode)) {
|
|
1081
|
-
const validTypesString = screenModes.map((mode) => `"${mode}"`).join(", ");
|
|
1082
|
-
errorMessages.push(
|
|
1083
|
-
`"screenMode" needs should be one of these types: ${validTypesString}`
|
|
1084
|
-
);
|
|
1085
|
-
dashboardContent.params.screenMode = "auto";
|
|
1086
|
-
}
|
|
1087
|
-
if (dashboardContent.params.itemId) {
|
|
1088
|
-
dashboardContent.params.itemEmbedding = true;
|
|
1089
|
-
}
|
|
1090
|
-
for (const key of objectParams) {
|
|
1091
|
-
if (typeof dashboardContent.params[key] !== "object" && dashboardContent.params[key] !== null) {
|
|
1092
|
-
delete dashboardContent.params[key];
|
|
1093
|
-
errorMessages.push(`${key} needs to be of type object or empty.`);
|
|
1094
|
-
}
|
|
1095
17
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
if (dashboardContent.params.itemDimensions) {
|
|
1101
|
-
const itemDimensionsKeys = [
|
|
1102
|
-
"width",
|
|
1103
|
-
"height"
|
|
1104
|
-
];
|
|
1105
|
-
for (const key of itemDimensionsKeys) {
|
|
1106
|
-
if (!["string", "number"].includes(
|
|
1107
|
-
typeof dashboardContent.params.itemDimensions[key]
|
|
1108
|
-
) && dashboardContent.params.itemDimensions[key] !== null) {
|
|
1109
|
-
errorMessages.push(
|
|
1110
|
-
`itemDimensions ${key} needs to be of type string, number or empty.`
|
|
1111
|
-
);
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
dashboardContent.params = defaultsDeep(
|
|
1116
|
-
dashboardContent.params,
|
|
1117
|
-
DEFAULT_PARAMETERS
|
|
1118
|
-
);
|
|
1119
|
-
if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
|
|
1120
|
-
dashboardContent.params.switchScreenModeOnResize = false;
|
|
1121
|
-
}
|
|
1122
|
-
if (dashboardContent.params.itemDimensions.width !== "auto") {
|
|
1123
|
-
dashboardContent.params.itemDimensions.width = Number.parseInt(
|
|
1124
|
-
`${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
|
|
1125
|
-
10
|
|
1126
|
-
) || "auto";
|
|
1127
|
-
}
|
|
1128
|
-
if (dashboardContent.params.itemDimensions.height !== "auto") {
|
|
1129
|
-
dashboardContent.params.itemDimensions.height = Number.parseInt(
|
|
1130
|
-
`${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
|
|
1131
|
-
10
|
|
1132
|
-
) || "auto";
|
|
1133
|
-
}
|
|
1134
|
-
dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
|
|
1135
|
-
if (dashboardContent.params.error || errorMessages.length > 0) {
|
|
1136
|
-
_handleError(errorMessages.join("\n"), dashboardContent.params);
|
|
1137
|
-
}
|
|
1138
|
-
};
|
|
18
|
+
n3.default = e2;
|
|
19
|
+
return Object.freeze(n3);
|
|
20
|
+
}
|
|
21
|
+
const SharedLib__namespace = /* @__PURE__ */ _interopNamespaceDefault(SharedLib);
|
|
1139
22
|
/**
|
|
1140
23
|
* @license
|
|
1141
24
|
* Copyright 2019 Google LLC
|
|
@@ -1350,16 +233,16 @@ class b extends HTMLElement {
|
|
|
1350
233
|
this._$Em = e2, this[e2] = r2.fromAttribute(s2, t3.type), this._$Em = null;
|
|
1351
234
|
}
|
|
1352
235
|
}
|
|
1353
|
-
requestUpdate(t2, s2, i3
|
|
236
|
+
requestUpdate(t2, s2, i3) {
|
|
1354
237
|
if (void 0 !== t2) {
|
|
1355
|
-
if (i3 ?? (i3 = this.constructor.getPropertyOptions(t2)), !(i3.hasChanged ?? f$1)(
|
|
238
|
+
if (i3 ?? (i3 = this.constructor.getPropertyOptions(t2)), !(i3.hasChanged ?? f$1)(this[t2], s2))
|
|
1356
239
|
return;
|
|
1357
240
|
this.C(t2, s2, i3);
|
|
1358
241
|
}
|
|
1359
242
|
false === this.isUpdatePending && (this._$Eg = this._$EP());
|
|
1360
243
|
}
|
|
1361
244
|
C(t2, s2, i3) {
|
|
1362
|
-
this._$AL.has(t2) || this._$AL.set(t2, s2), true === i3.reflect && this._$Em !== t2 && (this._$
|
|
245
|
+
this._$AL.has(t2) || this._$AL.set(t2, s2), true === i3.reflect && this._$Em !== t2 && (this._$ET ?? (this._$ET = /* @__PURE__ */ new Set())).add(t2);
|
|
1363
246
|
}
|
|
1364
247
|
async _$EP() {
|
|
1365
248
|
this.isUpdatePending = true;
|
|
@@ -1395,9 +278,9 @@ class b extends HTMLElement {
|
|
|
1395
278
|
t2 = this.shouldUpdate(s2), t2 ? (this.willUpdate(s2), (_a2 = this._$E_) == null ? void 0 : _a2.forEach((t3) => {
|
|
1396
279
|
var _a3;
|
|
1397
280
|
return (_a3 = t3.hostUpdate) == null ? void 0 : _a3.call(t3);
|
|
1398
|
-
}), this.update(s2)) : this._$
|
|
281
|
+
}), this.update(s2)) : this._$Ej();
|
|
1399
282
|
} catch (s3) {
|
|
1400
|
-
throw t2 = false, this._$
|
|
283
|
+
throw t2 = false, this._$Ej(), s3;
|
|
1401
284
|
}
|
|
1402
285
|
t2 && this._$AE(s2);
|
|
1403
286
|
}
|
|
@@ -1410,7 +293,7 @@ class b extends HTMLElement {
|
|
|
1410
293
|
return (_a3 = t3.hostUpdated) == null ? void 0 : _a3.call(t3);
|
|
1411
294
|
}), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t2)), this.updated(t2);
|
|
1412
295
|
}
|
|
1413
|
-
_$
|
|
296
|
+
_$Ej() {
|
|
1414
297
|
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
|
|
1415
298
|
}
|
|
1416
299
|
get updateComplete() {
|
|
@@ -1423,14 +306,14 @@ class b extends HTMLElement {
|
|
|
1423
306
|
return true;
|
|
1424
307
|
}
|
|
1425
308
|
update(t2) {
|
|
1426
|
-
this._$
|
|
309
|
+
this._$ET && (this._$ET = this._$ET.forEach((t3) => this._$EO(t3, this[t3]))), this._$Ej();
|
|
1427
310
|
}
|
|
1428
311
|
updated(t2) {
|
|
1429
312
|
}
|
|
1430
313
|
firstUpdated(t2) {
|
|
1431
314
|
}
|
|
1432
315
|
}
|
|
1433
|
-
b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[d$1("elementProperties")] = /* @__PURE__ */ new Map(), b[d$1("finalized")] = /* @__PURE__ */ new Map(), p$1 == null ? void 0 : p$1({ ReactiveElement: b }), (a$1.reactiveElementVersions ?? (a$1.reactiveElementVersions = [])).push("2.0.
|
|
316
|
+
b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[d$1("elementProperties")] = /* @__PURE__ */ new Map(), b[d$1("finalized")] = /* @__PURE__ */ new Map(), p$1 == null ? void 0 : p$1({ ReactiveElement: b }), (a$1.reactiveElementVersions ?? (a$1.reactiveElementVersions = [])).push("2.0.3");
|
|
1434
317
|
/**
|
|
1435
318
|
* @license
|
|
1436
319
|
* Copyright 2017 Google LLC
|
|
@@ -1672,7 +555,7 @@ class L {
|
|
|
1672
555
|
}
|
|
1673
556
|
}
|
|
1674
557
|
const Z = t$2.litHtmlPolyfillSupport;
|
|
1675
|
-
Z == null ? void 0 : Z(V, M), (t$2.litHtmlVersions ?? (t$2.litHtmlVersions = [])).push("3.1.
|
|
558
|
+
Z == null ? void 0 : Z(V, M), (t$2.litHtmlVersions ?? (t$2.litHtmlVersions = [])).push("3.1.1");
|
|
1676
559
|
const j = (t2, i3, s2) => {
|
|
1677
560
|
const e2 = (s2 == null ? void 0 : s2.renderBefore) ?? i3;
|
|
1678
561
|
let h2 = e2._$litPart$;
|
|
@@ -1715,7 +598,7 @@ class s extends b {
|
|
|
1715
598
|
s._$litElement$ = true, s["finalized"] = true, (_a = globalThis.litElementHydrateSupport) == null ? void 0 : _a.call(globalThis, { LitElement: s });
|
|
1716
599
|
const r$2 = globalThis.litElementPolyfillSupport;
|
|
1717
600
|
r$2 == null ? void 0 : r$2({ LitElement: s });
|
|
1718
|
-
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.0.
|
|
601
|
+
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.0.3");
|
|
1719
602
|
/**
|
|
1720
603
|
* @license
|
|
1721
604
|
* Copyright 2017 Google LLC
|
|
@@ -1858,7 +741,7 @@ const n2 = "important", i2 = " !" + n2, o = e(class extends i$1 {
|
|
|
1858
741
|
return w;
|
|
1859
742
|
}
|
|
1860
743
|
});
|
|
1861
|
-
const version = "5.0.
|
|
744
|
+
const version = "5.0.5";
|
|
1862
745
|
class LuzmoService {
|
|
1863
746
|
constructor() {
|
|
1864
747
|
this._components = [];
|
|
@@ -1902,7 +785,7 @@ const _setEventHandler = () => {
|
|
|
1902
785
|
break;
|
|
1903
786
|
}
|
|
1904
787
|
case "data": {
|
|
1905
|
-
resolvePromise(
|
|
788
|
+
SharedLib__namespace.resolvePromise(
|
|
1906
789
|
dashboardComponent,
|
|
1907
790
|
event.data.requestId,
|
|
1908
791
|
event.data.data
|
|
@@ -1910,7 +793,7 @@ const _setEventHandler = () => {
|
|
|
1910
793
|
break;
|
|
1911
794
|
}
|
|
1912
795
|
case "filters": {
|
|
1913
|
-
resolvePromise(
|
|
796
|
+
SharedLib__namespace.resolvePromise(
|
|
1914
797
|
dashboardComponent,
|
|
1915
798
|
event.data.requestId,
|
|
1916
799
|
event.data.filters
|
|
@@ -1918,7 +801,7 @@ const _setEventHandler = () => {
|
|
|
1918
801
|
break;
|
|
1919
802
|
}
|
|
1920
803
|
case "getAccessibleDashboards": {
|
|
1921
|
-
resolvePromise(
|
|
804
|
+
SharedLib__namespace.resolvePromise(
|
|
1922
805
|
dashboardComponent,
|
|
1923
806
|
event.data.requestId,
|
|
1924
807
|
event.data.accessibleDashboards
|
|
@@ -1933,7 +816,7 @@ const _setEventHandler = () => {
|
|
|
1933
816
|
}
|
|
1934
817
|
case "export": {
|
|
1935
818
|
if (event.data.error) {
|
|
1936
|
-
rejectPromise(
|
|
819
|
+
SharedLib__namespace.rejectPromise(
|
|
1937
820
|
dashboardComponent,
|
|
1938
821
|
event.data.requestId,
|
|
1939
822
|
event.data
|
|
@@ -1942,7 +825,7 @@ const _setEventHandler = () => {
|
|
|
1942
825
|
dashboardComponent.dispatchEvent(
|
|
1943
826
|
new CustomEvent("exported", { detail: { data: event.data } })
|
|
1944
827
|
);
|
|
1945
|
-
resolvePromise(
|
|
828
|
+
SharedLib__namespace.resolvePromise(
|
|
1946
829
|
dashboardComponent,
|
|
1947
830
|
event.data.requestId,
|
|
1948
831
|
event.data
|
|
@@ -1972,31 +855,31 @@ const _setEventHandler = () => {
|
|
|
1972
855
|
}
|
|
1973
856
|
case "setEditMode": {
|
|
1974
857
|
if (event.data.error) {
|
|
1975
|
-
rejectPromise(
|
|
858
|
+
SharedLib__namespace.rejectPromise(
|
|
1976
859
|
dashboardComponent,
|
|
1977
860
|
event.data.requestId,
|
|
1978
861
|
event.data
|
|
1979
862
|
);
|
|
1980
863
|
} else {
|
|
1981
|
-
resolvePromise(
|
|
864
|
+
SharedLib__namespace.resolvePromise(
|
|
1982
865
|
dashboardComponent,
|
|
1983
866
|
event.data.requestId,
|
|
1984
867
|
event.data
|
|
1985
868
|
);
|
|
1986
869
|
dashboardComponent.params.editMode = event.data.editMode;
|
|
1987
|
-
dashboardComponent._containerStyle = containerStyles(dashboardComponent);
|
|
870
|
+
dashboardComponent._containerStyle = SharedLib__namespace.containerStyles(dashboardComponent);
|
|
1988
871
|
if (dashboardComponent.dimensions) {
|
|
1989
|
-
_setCalculatedDimensions(dashboardComponent);
|
|
872
|
+
SharedLib__namespace._setCalculatedDimensions(dashboardComponent);
|
|
1990
873
|
}
|
|
1991
874
|
}
|
|
1992
875
|
break;
|
|
1993
876
|
}
|
|
1994
877
|
case "setFilters": {
|
|
1995
|
-
event.data.error ? rejectPromise(
|
|
878
|
+
event.data.error ? SharedLib__namespace.rejectPromise(
|
|
1996
879
|
dashboardComponent,
|
|
1997
880
|
event.data.requestId,
|
|
1998
881
|
event.data
|
|
1999
|
-
) : resolvePromise(
|
|
882
|
+
) : SharedLib__namespace.resolvePromise(
|
|
2000
883
|
dashboardComponent,
|
|
2001
884
|
event.data.requestId,
|
|
2002
885
|
event.data
|
|
@@ -2004,11 +887,11 @@ const _setEventHandler = () => {
|
|
|
2004
887
|
break;
|
|
2005
888
|
}
|
|
2006
889
|
case "setPreview": {
|
|
2007
|
-
event.data.error ? rejectPromise(
|
|
890
|
+
event.data.error ? SharedLib__namespace.rejectPromise(
|
|
2008
891
|
dashboardComponent,
|
|
2009
892
|
event.data.requestId,
|
|
2010
893
|
event.data
|
|
2011
|
-
) : resolvePromise(
|
|
894
|
+
) : SharedLib__namespace.resolvePromise(
|
|
2012
895
|
dashboardComponent,
|
|
2013
896
|
event.data.requestId,
|
|
2014
897
|
event.data
|
|
@@ -2178,7 +1061,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2178
1061
|
this.loaderSize = 32;
|
|
2179
1062
|
this.borderWidth = 3;
|
|
2180
1063
|
this.minHeight = 400;
|
|
2181
|
-
this._containerId = uuidv4();
|
|
1064
|
+
this._containerId = SharedLib__namespace.uuidv4();
|
|
2182
1065
|
this._iframeId = `luzmo-dashboard-${this._containerId}`;
|
|
2183
1066
|
this.iframeLoaded = false;
|
|
2184
1067
|
this.promises = {};
|
|
@@ -2189,7 +1072,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2189
1072
|
if ((_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(".dashboard-container")) {
|
|
2190
1073
|
this.containerWidth = this.container.clientWidth;
|
|
2191
1074
|
if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
|
|
2192
|
-
for (const d2 of EXTENTS) {
|
|
1075
|
+
for (const d2 of SharedLib__namespace.EXTENTS) {
|
|
2193
1076
|
if (d2.width[0] <= window.innerWidth && window.innerWidth <= d2.width[1]) {
|
|
2194
1077
|
this.currentScreenMode = d2.mode;
|
|
2195
1078
|
}
|
|
@@ -2210,13 +1093,13 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2210
1093
|
});
|
|
2211
1094
|
}
|
|
2212
1095
|
loadLibrary(appServer) {
|
|
2213
|
-
if (remotesMap[appServer]) {
|
|
2214
|
-
return Promise.resolve(remotesMap[appServer].module);
|
|
1096
|
+
if (SharedLib.remotesMap[appServer]) {
|
|
1097
|
+
return Promise.resolve(SharedLib.remotesMap[appServer].module);
|
|
2215
1098
|
}
|
|
2216
|
-
remotesMap[appServer] = { url: (appServer == null ? void 0 : appServer.startsWith("http://localhost")) ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
|
|
2217
|
-
return
|
|
2218
|
-
const wrappedModule =
|
|
2219
|
-
remotesMap[appServer].module = wrappedModule;
|
|
1099
|
+
SharedLib.remotesMap[appServer] = { url: (appServer == null ? void 0 : appServer.startsWith("http://localhost")) ? `${SharedLib__namespace.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib__namespace.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
|
|
1100
|
+
return SharedLib.__federationMethodGetRemote(appServer, "./DashboardApp").then((module2) => {
|
|
1101
|
+
const wrappedModule = SharedLib.__federationMethodWrapDefault(module2, true);
|
|
1102
|
+
SharedLib.remotesMap[appServer].module = wrappedModule;
|
|
2220
1103
|
return wrappedModule;
|
|
2221
1104
|
});
|
|
2222
1105
|
}
|
|
@@ -2255,7 +1138,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2255
1138
|
this.dev = inputParameters.dev;
|
|
2256
1139
|
}
|
|
2257
1140
|
if (inputParameters.appServer) {
|
|
2258
|
-
this.appServer = addTrailingSlash(inputParameters.appServer);
|
|
1141
|
+
this.appServer = SharedLib__namespace.addTrailingSlash(inputParameters.appServer);
|
|
2259
1142
|
}
|
|
2260
1143
|
}
|
|
2261
1144
|
// Set resize event listener
|
|
@@ -2274,7 +1157,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2274
1157
|
}
|
|
2275
1158
|
firstUpdated() {
|
|
2276
1159
|
var _a2;
|
|
2277
|
-
this._loaderMsg = (_a2 = getLoader(this)) == null ? void 0 : _a2.loadingMsg;
|
|
1160
|
+
this._loaderMsg = (_a2 = SharedLib__namespace.getLoader(this)) == null ? void 0 : _a2.loadingMsg;
|
|
2278
1161
|
this._loaderStyles();
|
|
2279
1162
|
LuzmoService$1._components.push(this);
|
|
2280
1163
|
this.initComponent();
|
|
@@ -2299,15 +1182,15 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2299
1182
|
});
|
|
2300
1183
|
} else {
|
|
2301
1184
|
this.containerWidth = (_a2 = this.container) == null ? void 0 : _a2.clientWidth;
|
|
2302
|
-
_extendAndValidate(this);
|
|
2303
|
-
_browserCheck(this);
|
|
1185
|
+
SharedLib__namespace._extendAndValidate(this);
|
|
1186
|
+
SharedLib__namespace._browserCheck(this);
|
|
2304
1187
|
this._setupLoader();
|
|
2305
1188
|
if (!this.params.error) {
|
|
2306
1189
|
this._loaderStyles();
|
|
2307
1190
|
_setEventHandler();
|
|
2308
|
-
this._iframeUrl = createIframeUrl(this);
|
|
1191
|
+
this._iframeUrl = SharedLib__namespace.createIframeUrl(this);
|
|
2309
1192
|
(_b = this.iframe) == null ? void 0 : _b.setAttribute("src", this._iframeUrl);
|
|
2310
|
-
this.iframeStyle = calculateIframeStyles(this);
|
|
1193
|
+
this.iframeStyle = SharedLib__namespace.calculateIframeStyles(this);
|
|
2311
1194
|
}
|
|
2312
1195
|
if (this.container) {
|
|
2313
1196
|
this._resizeObserver.observe(this.container);
|
|
@@ -2321,7 +1204,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2321
1204
|
this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
|
|
2322
1205
|
}
|
|
2323
1206
|
if (this.params.apiHost) {
|
|
2324
|
-
this.dashboardReference.setAttribute("api-host", removeTrailingSlash(this.params.apiHost));
|
|
1207
|
+
this.dashboardReference.setAttribute("api-host", SharedLib__namespace.removeTrailingSlash(this.params.apiHost));
|
|
2325
1208
|
}
|
|
2326
1209
|
if (this.params.key) {
|
|
2327
1210
|
this.dashboardReference.setAttribute("auth-key", this.params.key);
|
|
@@ -2362,14 +1245,14 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2362
1245
|
);
|
|
2363
1246
|
}, 15 * 1e3);
|
|
2364
1247
|
this.params = this._setOptions();
|
|
2365
|
-
_extendAndValidate(this);
|
|
1248
|
+
SharedLib__namespace._extendAndValidate(this);
|
|
2366
1249
|
this._setupLoader();
|
|
2367
1250
|
this._loaderStyles();
|
|
2368
|
-
this._iframeUrl = createIframeUrl(this);
|
|
1251
|
+
this._iframeUrl = SharedLib__namespace.createIframeUrl(this);
|
|
2369
1252
|
if (this.iframe) {
|
|
2370
1253
|
this._updateIframeUrl();
|
|
2371
1254
|
}
|
|
2372
|
-
this.iframeStyle = calculateIframeStyles(this);
|
|
1255
|
+
this.iframeStyle = SharedLib__namespace.calculateIframeStyles(this);
|
|
2373
1256
|
} else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
|
|
2374
1257
|
if (this.iframeLoaded) {
|
|
2375
1258
|
this.setEditMode(this.editMode);
|
|
@@ -2450,16 +1333,16 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2450
1333
|
defaultParameters.itemDimensions = this.itemDimensions;
|
|
2451
1334
|
}
|
|
2452
1335
|
if (this.appServer) {
|
|
2453
|
-
this.appServer = this.getIsViewMode() ? removeTrailingSlash(this.appServer) : addTrailingSlash(this.appServer);
|
|
1336
|
+
this.appServer = this.getIsViewMode() ? SharedLib__namespace.removeTrailingSlash(this.appServer) : SharedLib__namespace.addTrailingSlash(this.appServer);
|
|
2454
1337
|
defaultParameters.appServer = this.appServer;
|
|
2455
1338
|
} else {
|
|
2456
|
-
this.appServer = addTrailingSlash(
|
|
2457
|
-
DEFAULT_PARAMETERS.appServer
|
|
1339
|
+
this.appServer = SharedLib__namespace.addTrailingSlash(
|
|
1340
|
+
SharedLib__namespace.DEFAULT_PARAMETERS.appServer
|
|
2458
1341
|
);
|
|
2459
1342
|
defaultParameters.appServer = this.appServer;
|
|
2460
1343
|
}
|
|
2461
1344
|
if (this.apiHost) {
|
|
2462
|
-
this.apiHost = this.getIsViewMode() ? removeTrailingSlash(this.apiHost) : addTrailingSlash(this.apiHost);
|
|
1345
|
+
this.apiHost = this.getIsViewMode() ? SharedLib__namespace.removeTrailingSlash(this.apiHost) : SharedLib__namespace.addTrailingSlash(this.apiHost);
|
|
2463
1346
|
defaultParameters.apiHost = this.apiHost;
|
|
2464
1347
|
} else {
|
|
2465
1348
|
this.apiHost = this.appServer.endsWith("luzmo.com/") ? this.appServer.replace("app", "api") : this.appServer;
|
|
@@ -2468,11 +1351,11 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2468
1351
|
return defaultParameters;
|
|
2469
1352
|
}
|
|
2470
1353
|
_updateIframeUrl() {
|
|
2471
|
-
updateIframeUrl(this.iframe, this._iframeUrl);
|
|
1354
|
+
SharedLib__namespace.updateIframeUrl(this.iframe, this._iframeUrl);
|
|
2472
1355
|
}
|
|
2473
1356
|
// Setup loader / browser error
|
|
2474
1357
|
_setupLoader() {
|
|
2475
|
-
const data = getLoader(this);
|
|
1358
|
+
const data = SharedLib__namespace.getLoader(this);
|
|
2476
1359
|
this._loaderMsg = data.loadingMsg;
|
|
2477
1360
|
if (data.errorMsg) {
|
|
2478
1361
|
this.browserError = true;
|
|
@@ -2492,15 +1375,15 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2492
1375
|
_calculateDimAfterDashboardLoaded() {
|
|
2493
1376
|
this.dashboardError = false;
|
|
2494
1377
|
this._loaderStyles();
|
|
2495
|
-
_setCalculatedDimensions(this);
|
|
1378
|
+
SharedLib__namespace._setCalculatedDimensions(this);
|
|
2496
1379
|
}
|
|
2497
1380
|
// Set loader styles
|
|
2498
1381
|
_loaderStyles() {
|
|
2499
|
-
this._containerStyle = containerStyles(this);
|
|
2500
|
-
this._loaderStyle = loaderStyles(this);
|
|
2501
|
-
this._loadingCircleStyle = plStyles(this);
|
|
2502
|
-
this._containerLoaderStyle = containerLoaderStyles(this);
|
|
2503
|
-
this._lcStyle = lcStyles(this);
|
|
1382
|
+
this._containerStyle = SharedLib__namespace.containerStyles(this);
|
|
1383
|
+
this._loaderStyle = SharedLib__namespace.loaderStyles(this);
|
|
1384
|
+
this._loadingCircleStyle = SharedLib__namespace.plStyles(this);
|
|
1385
|
+
this._containerLoaderStyle = SharedLib__namespace.containerLoaderStyles(this);
|
|
1386
|
+
this._lcStyle = SharedLib__namespace.lcStyles(this);
|
|
2504
1387
|
}
|
|
2505
1388
|
static get styles() {
|
|
2506
1389
|
return [dashboardStyles];
|
|
@@ -2590,7 +1473,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2590
1473
|
return this.dashboardReference.getData(itemId);
|
|
2591
1474
|
}
|
|
2592
1475
|
if (!this.getIsViewMode()) {
|
|
2593
|
-
return getData(this, this.iframe, itemId);
|
|
1476
|
+
return SharedLib__namespace.getData(this, this.iframe, itemId);
|
|
2594
1477
|
}
|
|
2595
1478
|
return Promise.reject();
|
|
2596
1479
|
}
|
|
@@ -2599,7 +1482,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2599
1482
|
return this.dashboardReference.getFilters();
|
|
2600
1483
|
}
|
|
2601
1484
|
if (!this.getIsViewMode()) {
|
|
2602
|
-
return getFilters(this, this.iframe);
|
|
1485
|
+
return SharedLib__namespace.getFilters(this, this.iframe);
|
|
2603
1486
|
}
|
|
2604
1487
|
return Promise.reject();
|
|
2605
1488
|
}
|
|
@@ -2608,7 +1491,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2608
1491
|
return Promise.reject();
|
|
2609
1492
|
}
|
|
2610
1493
|
if (!this.getIsViewMode()) {
|
|
2611
|
-
return setFilters(this, this.iframe, itemId, filters);
|
|
1494
|
+
return SharedLib__namespace.setFilters(this, this.iframe, itemId, filters);
|
|
2612
1495
|
}
|
|
2613
1496
|
return Promise.reject();
|
|
2614
1497
|
}
|
|
@@ -2617,7 +1500,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2617
1500
|
return this.dashboardReference.setAuthorization(key, token);
|
|
2618
1501
|
}
|
|
2619
1502
|
if (!this.getIsViewMode()) {
|
|
2620
|
-
return setAuthorization(this, this.iframe, key, token);
|
|
1503
|
+
return SharedLib__namespace.setAuthorization(this, this.iframe, key, token);
|
|
2621
1504
|
}
|
|
2622
1505
|
return Promise.reject();
|
|
2623
1506
|
}
|
|
@@ -2626,7 +1509,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2626
1509
|
return this.dashboardReference.refreshData(itemId);
|
|
2627
1510
|
}
|
|
2628
1511
|
if (!this.getIsViewMode()) {
|
|
2629
|
-
return itemId ? refreshData(this, this.iframe, itemId) : refreshData(this, this.iframe);
|
|
1512
|
+
return itemId ? SharedLib__namespace.refreshData(this, this.iframe, itemId) : SharedLib__namespace.refreshData(this, this.iframe);
|
|
2630
1513
|
}
|
|
2631
1514
|
return Promise.reject();
|
|
2632
1515
|
}
|
|
@@ -2635,7 +1518,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2635
1518
|
return this.dashboardReference.reloadDashboard();
|
|
2636
1519
|
}
|
|
2637
1520
|
if (!this.getIsViewMode()) {
|
|
2638
|
-
return reloadDashboard(this, this.iframe);
|
|
1521
|
+
return SharedLib__namespace.reloadDashboard(this, this.iframe);
|
|
2639
1522
|
}
|
|
2640
1523
|
return Promise.reject();
|
|
2641
1524
|
}
|
|
@@ -2644,13 +1527,13 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2644
1527
|
return this.dashboardReference.exportDashboard(format);
|
|
2645
1528
|
}
|
|
2646
1529
|
if (!this.getIsViewMode()) {
|
|
2647
|
-
return format ? exportDashboard(this, this.iframe, format) : exportDashboard(this, this.iframe);
|
|
1530
|
+
return format ? SharedLib__namespace.exportDashboard(this, this.iframe, format) : SharedLib__namespace.exportDashboard(this, this.iframe);
|
|
2648
1531
|
}
|
|
2649
1532
|
return Promise.reject();
|
|
2650
1533
|
}
|
|
2651
1534
|
getAccessibleDashboards() {
|
|
2652
1535
|
if (!this.getIsViewMode()) {
|
|
2653
|
-
return getAccessibleDashboards(this, this.iframe);
|
|
1536
|
+
return SharedLib__namespace.getAccessibleDashboards(this, this.iframe);
|
|
2654
1537
|
}
|
|
2655
1538
|
if (this.getIsViewMode() && this.dashboardReference) {
|
|
2656
1539
|
return this.dashboardReference.getAccessibleDashboards();
|
|
@@ -2680,7 +1563,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2680
1563
|
return this.dashboardReference.setEditMode(editMode);
|
|
2681
1564
|
}
|
|
2682
1565
|
if (!this.getIsViewMode()) {
|
|
2683
|
-
return setEditMode(this, this.iframe, editMode);
|
|
1566
|
+
return SharedLib__namespace.setEditMode(this, this.iframe, editMode);
|
|
2684
1567
|
}
|
|
2685
1568
|
return Promise.reject();
|
|
2686
1569
|
}
|
|
@@ -2688,7 +1571,7 @@ exports.LuzmoDashboard = class LuzmoDashboard extends s {
|
|
|
2688
1571
|
if (this.getIsViewMode() && this.dashboardReference) {
|
|
2689
1572
|
return this.dashboardReference.setPreview(preview);
|
|
2690
1573
|
}
|
|
2691
|
-
return setPreview(this, this.iframe, preview);
|
|
1574
|
+
return SharedLib__namespace.setPreview(this, this.iframe, preview);
|
|
2692
1575
|
}
|
|
2693
1576
|
getIsViewMode() {
|
|
2694
1577
|
if (this.dev && this.params.editMode === "view" || this.params.editMode === void 0) {
|