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