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