@luzmo/embed 5.1.4 → 5.1.6

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.libs.cjs DELETED
@@ -1,1104 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var __decorateClass = (decorators, target, key, kind) => {
30
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
31
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
32
- if (decorator = decorators[i])
33
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
34
- if (kind && result)
35
- __defProp(target, key, result);
36
- return result;
37
- };
38
-
39
- // libs/embed-libs/embed/src/index.libs.ts
40
- var index_libs_exports = {};
41
- __export(index_libs_exports, {
42
- LuzmoDashboardWebComponent: () => LuzmoDashboardWebComponent
43
- });
44
- module.exports = __toCommonJS(index_libs_exports);
45
-
46
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
47
- var import_decorators2 = require("lit/decorators.js");
48
-
49
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
50
- var SharedLib2 = __toESM(require("@luzmo/shared-embed"), 1);
51
- var import_lit2 = require("lit");
52
- var import_decorators = require("lit/decorators.js");
53
- var import_style_map = require("lit/directives/style-map.js");
54
- var import_shared_embed = require("@luzmo/shared-embed");
55
-
56
- // libs/embed-libs/embed/package.json
57
- var version = "5.1.4";
58
-
59
- // libs/embed-libs/embed/src/lib/luzmo-service.ts
60
- var LuzmoService = class {
61
- constructor() {
62
- this._components = [];
63
- }
64
- };
65
- var luzmo_service_default = new LuzmoService();
66
-
67
- // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
68
- var SharedLib = __toESM(require("@luzmo/shared-embed"), 1);
69
- var _setEventHandler = () => {
70
- if (typeof window.__luzmoMessageHandler === "function") {
71
- return;
72
- }
73
- window.__luzmoMessageHandler = (event) => {
74
- const dashboardComponent = luzmo_service_default._components.find(
75
- (c) => event.data.name === c._iframeId
76
- );
77
- if (!dashboardComponent) {
78
- return;
79
- }
80
- switch (event.data?.type) {
81
- case "load": {
82
- dashboardComponent.dispatchEvent(
83
- new CustomEvent("load", { detail: { data: event.data } })
84
- );
85
- if (dashboardComponent._loadTimeoutHandle) {
86
- clearTimeout(dashboardComponent._loadTimeoutHandle);
87
- dashboardComponent._loadTimeoutHandle = void 0;
88
- }
89
- dashboardComponent.iframeLoaded = true;
90
- dashboardComponent.dimensions = event.data.dimensions;
91
- dashboardComponent._calculateDimAfterDashboardLoaded();
92
- break;
93
- }
94
- case "error": {
95
- dashboardComponent.dashboardError = true;
96
- if (dashboardComponent._loadTimeoutHandle) {
97
- clearTimeout(dashboardComponent._loadTimeoutHandle);
98
- dashboardComponent._loadTimeoutHandle = void 0;
99
- }
100
- dashboardComponent.iframeLoaded = true;
101
- dashboardComponent._displayError();
102
- console.error("Dashboard error: ", event.data.errorMsg);
103
- break;
104
- }
105
- case "data": {
106
- SharedLib.resolvePromise(
107
- dashboardComponent,
108
- event.data.requestId,
109
- event.data.data
110
- );
111
- break;
112
- }
113
- case "filters": {
114
- SharedLib.resolvePromise(
115
- dashboardComponent,
116
- event.data.requestId,
117
- event.data.filters
118
- );
119
- break;
120
- }
121
- case "getAccessibleDashboards": {
122
- SharedLib.resolvePromise(
123
- dashboardComponent,
124
- event.data.requestId,
125
- event.data.accessibleDashboards
126
- );
127
- break;
128
- }
129
- case "dashboardAction": {
130
- dashboardComponent.dispatchEvent(
131
- new CustomEvent("dashboardAction", { detail: { data: event.data } })
132
- );
133
- break;
134
- }
135
- case "export": {
136
- if (event.data.error) {
137
- SharedLib.rejectPromise(
138
- dashboardComponent,
139
- event.data.requestId,
140
- event.data
141
- );
142
- } else {
143
- dashboardComponent.dispatchEvent(
144
- new CustomEvent("exported", { detail: { data: event.data } })
145
- );
146
- SharedLib.resolvePromise(
147
- dashboardComponent,
148
- event.data.requestId,
149
- event.data
150
- );
151
- }
152
- break;
153
- }
154
- case "changedFilters": {
155
- dashboardComponent.dispatchEvent(
156
- new CustomEvent("changedFilters", { detail: { data: event.data } })
157
- );
158
- break;
159
- }
160
- case "customEvent": {
161
- dashboardComponent.dispatchEvent(
162
- new CustomEvent("customEvent", { detail: { data: event.data } })
163
- );
164
- break;
165
- }
166
- case "chartsRendered":
167
- case "itemsRendered": {
168
- event.data.type = "itemsRendered";
169
- dashboardComponent.dispatchEvent(
170
- new CustomEvent("itemsRendered", { detail: { data: event.data } })
171
- );
172
- break;
173
- }
174
- case "setEditMode": {
175
- if (event.data.error) {
176
- SharedLib.rejectPromise(
177
- dashboardComponent,
178
- event.data.requestId,
179
- event.data
180
- );
181
- } else {
182
- SharedLib.resolvePromise(
183
- dashboardComponent,
184
- event.data.requestId,
185
- event.data
186
- );
187
- dashboardComponent.params.editMode = event.data.editMode;
188
- dashboardComponent._containerStyle = SharedLib.containerStyles(dashboardComponent);
189
- if (dashboardComponent.dimensions) {
190
- SharedLib._setCalculatedDimensions(dashboardComponent);
191
- }
192
- }
193
- break;
194
- }
195
- case "setFilters": {
196
- event.data.error ? SharedLib.rejectPromise(
197
- dashboardComponent,
198
- event.data.requestId,
199
- event.data
200
- ) : SharedLib.resolvePromise(
201
- dashboardComponent,
202
- event.data.requestId,
203
- event.data
204
- );
205
- break;
206
- }
207
- case "setPreview": {
208
- event.data.error ? SharedLib.rejectPromise(
209
- dashboardComponent,
210
- event.data.requestId,
211
- event.data
212
- ) : SharedLib.resolvePromise(
213
- dashboardComponent,
214
- event.data.requestId,
215
- event.data
216
- );
217
- break;
218
- }
219
- }
220
- };
221
- window.addEventListener("message", window.__luzmoMessageHandler, false);
222
- };
223
-
224
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-styles.ts
225
- var import_lit = require("lit");
226
- var dashboardStyles = import_lit.css`
227
- :host {
228
- display: block;
229
- height: 100%;
230
- }
231
-
232
- @-webkit-keyframes spin {
233
- 0% {
234
- -webkit-transform: rotate(0deg);
235
- transform: rotate(0deg);
236
- }
237
- 100% {
238
- -webkit-transform: rotate(360deg);
239
- transform: rotate(360deg);
240
- }
241
- }
242
-
243
- @keyframes spin {
244
- 0% {
245
- -webkit-transform: rotate(0deg);
246
- transform: rotate(0deg);
247
- }
248
- 100% {
249
- -webkit-transform: rotate(360deg);
250
- transform: rotate(360deg);
251
- }
252
- }
253
- :host {
254
- position: relative;
255
- width: 100%;
256
- }
257
-
258
- .luzmo-embed-dashboard {
259
- background: transparent;
260
- padding: 0;
261
- border: 0;
262
- }
263
-
264
- .luzmo-embed-dashboard-ede {
265
- }
266
-
267
- .luzmo-embed-container-ede {
268
- width: 100%;
269
- height: 100%;
270
- }
271
-
272
- .luzmo-container-loader {
273
- width: 100%;
274
- position: relative;
275
- }
276
-
277
- .luzmo-lc {
278
- margin: 0 auto;
279
- }
280
-
281
- .luzmo-loading-message {
282
- width: 100%;
283
- height: 20px;
284
- text-align: center;
285
- margin-bottom: 16px;
286
- font-family: Helvetica, Arial, sans-serif;
287
- font-size: 14px;
288
- }
289
-
290
- .luzmo-loading-circle {
291
- box-sizing: border-box;
292
- margin: 16px auto;
293
- position: relative;
294
- text-indent: -9999em;
295
- animation: spin 0.6s infinite linear;
296
- }
297
-
298
- .luzmo-loading-circle,
299
- .luzmo-loading-circle:after {
300
- border-radius: 50%;
301
- width: 32px;
302
- height: 32px;
303
- }
304
-
305
- .itemEmbedding:after {
306
- width: 24px;
307
- height: 24px;
308
- }
309
-
310
- .luzmo-error {
311
- background: transparent;
312
- padding: 48px 0;
313
- margin: 0 auto;
314
- width: 80%;
315
- border: 0;
316
- text-align: center;
317
- min-height: 192px;
318
- }
319
-
320
- .dashboard-error {
321
- font-size: 30px;
322
- background: transparent;
323
- padding: 48px 0;
324
- margin: 0 auto;
325
- width: 80%;
326
- border: 0;
327
- text-align: center;
328
- min-height: 192px;
329
- }
330
-
331
- .luzmo-loader {
332
- top: 0;
333
- left: 0;
334
- width: 100%;
335
- min-height: 400px;
336
- position: absolute;
337
- transition-duration: 0.3s;
338
- }
339
- `;
340
-
341
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
342
- var LuzmoDashboard = class extends import_lit2.LitElement {
343
- constructor(inputParameters) {
344
- super();
345
- this.language = "auto";
346
- this.screenMode = "auto";
347
- this.switchScreenModeOnResize = true;
348
- this.editMode = "view";
349
- this.experimental = false;
350
- this.iframeStyle = {};
351
- this._containerStyle = {};
352
- this._loaderStyle = {};
353
- this._lcStyle = {};
354
- this._loadingCircleStyle = {};
355
- this._containerLoaderStyle = {};
356
- this._loaderMsg = "";
357
- this._itemEmbedding = false;
358
- this.browserError = false;
359
- this.browserErrorMsg = "";
360
- this.dashboardError = false;
361
- this.browserNotSupported = [];
362
- this.VERSION = version + "-wc-luzmo";
363
- this.isLibraryLoaded = false;
364
- this.currentAuthKey = null;
365
- this.currentAuthToken = null;
366
- this.attributesMap = {
367
- dashboardId: "dashboard-id",
368
- dashboardSlug: "dashboard-slug",
369
- itemId: "item-id",
370
- language: "language",
371
- qeVersion: "qe-version",
372
- screenMode: "screen-mode",
373
- switchScreenModeOnResize: "switch-screen-mode-on-resize",
374
- authKey: "auth-key",
375
- authToken: "auth-token",
376
- editMode: "edit-mode",
377
- mainColor: "main-color",
378
- accentColor: "accent-color",
379
- loaderBackground: "loader-background",
380
- loaderFontColor: "loader-font-color",
381
- loaderSpinnerColor: "loader-spinner-color",
382
- loaderSpinnerBackground: "loader-spinner-background",
383
- appServer: "app-server",
384
- apiHost: "api-host",
385
- itemDimensions: "item-dimensions",
386
- timezoneId: "timezone-id"
387
- };
388
- this.loaderSize = 32;
389
- this.borderWidth = 3;
390
- this.minHeight = 400;
391
- this._containerId = SharedLib2.uuidv4();
392
- this._iframeId = `luzmo-dashboard-${this._containerId}`;
393
- this.iframeLoaded = false;
394
- this.promises = {};
395
- this.setInputParameters(inputParameters);
396
- this.params = this._setOptions();
397
- this._onResize = () => {
398
- if (this.shadowRoot?.querySelector(".dashboard-container")) {
399
- this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
400
- if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
401
- for (const d of SharedLib2.EXTENTS) {
402
- if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
403
- this.currentScreenMode = d.mode;
404
- }
405
- }
406
- }
407
- if (this.iframeLoaded) {
408
- this._calculateDimAfterDashboardLoaded();
409
- } else {
410
- if (this.dimensions) {
411
- this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
412
- SharedLib2._setCalculatedDimensions(this);
413
- }
414
- }
415
- }
416
- };
417
- this._resizeObserver = new ResizeObserver((entries) => {
418
- window.requestAnimationFrame(() => {
419
- if (!Array.isArray(entries) || entries.length === 0) {
420
- return;
421
- }
422
- this._onResize();
423
- });
424
- });
425
- }
426
- loadLibrary(appServer) {
427
- if (import_shared_embed.remotesMap[appServer]) {
428
- return Promise.resolve(import_shared_embed.remotesMap[appServer].module);
429
- }
430
- import_shared_embed.remotesMap[appServer] = {
431
- url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
432
- format: "esm",
433
- from: "vite",
434
- module: void 0
435
- };
436
- return (0, import_shared_embed.__federationMethodGetRemote)(appServer, "./DashboardApp").then((module2) => {
437
- const wrappedModule = (0, import_shared_embed.__federationMethodWrapDefault)(module2, true);
438
- import_shared_embed.remotesMap[appServer].module = wrappedModule;
439
- return wrappedModule;
440
- });
441
- }
442
- setInputParameters(inputParameters) {
443
- if (!inputParameters) {
444
- return;
445
- }
446
- const params = [
447
- "dashboardId",
448
- "dashboardSlug",
449
- "itemId",
450
- "language",
451
- "qeVersion",
452
- "screenMode",
453
- "switchScreenModeOnResize",
454
- "accentColor",
455
- "mainColor",
456
- "authToken",
457
- "authKey",
458
- "editMode",
459
- "loaderBackground",
460
- "loaderFontColor",
461
- "loaderSpinnerColor",
462
- "loaderSpinnerBackground",
463
- "timezoneId",
464
- "itemDimensions",
465
- "apiHost"
466
- ];
467
- for (const key of params) {
468
- const value = inputParameters[key];
469
- if (value) {
470
- this[key] = value;
471
- }
472
- }
473
- if (inputParameters.experimental) {
474
- this.experimental = inputParameters.experimental;
475
- }
476
- if (inputParameters.appServer) {
477
- this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
478
- }
479
- }
480
- // Set resize event listener
481
- connectedCallback() {
482
- super.connectedCallback();
483
- }
484
- // Set resize event listener
485
- disconnectedCallback() {
486
- super.disconnectedCallback();
487
- this._resizeObserver.disconnect();
488
- for (const promiseKey of Object.keys(this.promises)) {
489
- this.promises[promiseKey].reject(
490
- new Error("Dashboard component was removed")
491
- );
492
- }
493
- }
494
- firstUpdated() {
495
- this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
496
- this._loaderStyles();
497
- luzmo_service_default._components.push(this);
498
- this.initComponent();
499
- if (this.luzmoEmbedContainer) {
500
- this._resizeObserver.observe(this.luzmoEmbedContainer);
501
- }
502
- }
503
- initComponent() {
504
- this.params = this._setOptions();
505
- if (this.getIsViewMode()) {
506
- this.loadLibrary(this.params.appServer).then(async () => {
507
- this.isLibraryLoaded = true;
508
- await this.updateComplete;
509
- const oldReference = this.renderRoot.querySelector("dashboard-component");
510
- this.dashboardReference = oldReference.cloneNode(true);
511
- oldReference.replaceWith(this.dashboardReference);
512
- this.dashboardReference.addEventListener("load", (payload) => {
513
- this.containerWidth = this.dashboardReference.offsetWidth;
514
- this.dimensions = payload.detail.dimensions;
515
- SharedLib2._setCalculatedDimensions(this);
516
- window.dispatchEvent(new Event("resize"));
517
- this.dispatchEvent(new CustomEvent("load", payload));
518
- });
519
- this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
520
- this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
521
- this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
522
- this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
523
- this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
524
- this.setAllAttributes();
525
- });
526
- } else {
527
- this.containerWidth = this.container?.clientWidth;
528
- SharedLib2._extendAndValidate(this);
529
- SharedLib2._browserCheck(this);
530
- this._setupLoader();
531
- if (!this.params.error) {
532
- this._loaderStyles();
533
- _setEventHandler();
534
- this._iframeUrl = SharedLib2.createIframeUrl(this);
535
- this.iframe?.setAttribute("src", this._iframeUrl);
536
- this.iframeStyle = SharedLib2.calculateIframeStyles(this);
537
- }
538
- }
539
- }
540
- setAllAttributes() {
541
- if (this.dashboardReference) {
542
- for (const key in this.attributesMap) {
543
- if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
544
- this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
545
- }
546
- if (this.params.itemDimensions) {
547
- this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
548
- }
549
- if (this.params.apiHost) {
550
- this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
551
- }
552
- if (this.params.key) {
553
- this.dashboardReference.setAttribute("auth-key", this.params.key);
554
- }
555
- if (this.params.token) {
556
- this.dashboardReference.setAttribute("auth-token", this.params.token);
557
- }
558
- }
559
- }
560
- }
561
- // Reload dashboard when triggerproperty changes
562
- updated(changedProperties) {
563
- const triggerProperties = /* @__PURE__ */ new Set([
564
- "dashboardId",
565
- "dashboardSlug",
566
- "itemId",
567
- "language",
568
- "qeVersion",
569
- "editMode",
570
- "screenMode",
571
- "switchScreenModeOnResize",
572
- "authToken",
573
- "authKey",
574
- "appServer",
575
- "timezoneId",
576
- "itemDimensions"
577
- ]);
578
- if (this.getIsViewMode()) {
579
- if (this.dashboardReference) {
580
- for (const [propertyName] of changedProperties.entries()) {
581
- if (propertyName === "appSever") {
582
- this.loadLibrary(changedProperties[propertyName]).then(async () => {
583
- this.isLibraryLoaded = true;
584
- await this.updateComplete;
585
- this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
586
- this.setAllAttributes();
587
- });
588
- } else if (this.attributesMap[propertyName]) {
589
- const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
590
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
591
- this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
592
- }
593
- }
594
- }
595
- } else {
596
- for (const [propertyName] of changedProperties.entries()) {
597
- if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
598
- this.iframeLoaded = false;
599
- if (this._loadTimeoutHandle) {
600
- clearTimeout(this._loadTimeoutHandle);
601
- }
602
- this._loadTimeoutHandle = setTimeout(() => {
603
- console.warn(
604
- "Failed to load dashboard, appServer is likely down or unreachable."
605
- );
606
- }, 15 * 1e3);
607
- this.params = this._setOptions();
608
- SharedLib2._extendAndValidate(this);
609
- this._setupLoader();
610
- this._loaderStyles();
611
- this._iframeUrl = SharedLib2.createIframeUrl(this);
612
- if (this.iframe) {
613
- this._updateIframeUrl();
614
- }
615
- this.iframeStyle = SharedLib2.calculateIframeStyles(this);
616
- } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
617
- if (this.iframeLoaded) {
618
- this.setEditMode(this.editMode);
619
- }
620
- this.params = this._setOptions();
621
- }
622
- }
623
- }
624
- }
625
- // Set params
626
- _setOptions() {
627
- const defaultParameters = {
628
- dashboardId: this.dashboardId,
629
- dashboardSlug: this.dashboardSlug
630
- };
631
- if (this.itemId) {
632
- defaultParameters.itemId = this.itemId;
633
- this._itemEmbedding = true;
634
- } else {
635
- this._itemEmbedding = false;
636
- }
637
- if (this.language) {
638
- defaultParameters.language = this.language;
639
- }
640
- if (this.qeVersion) {
641
- defaultParameters.qeVersion = this.qeVersion;
642
- }
643
- if (this.screenMode) {
644
- defaultParameters.screenMode = this.screenMode;
645
- }
646
- defaultParameters.switchScreenModeOnResize = this.switchScreenModeOnResize;
647
- if (this.authToken) {
648
- defaultParameters.token = this.authToken;
649
- }
650
- if (this.authKey) {
651
- defaultParameters.key = this.authKey;
652
- }
653
- if (this.editMode) {
654
- defaultParameters.editMode = this.editMode;
655
- }
656
- if (this.mainColor) {
657
- defaultParameters.mainColor = this.mainColor;
658
- }
659
- if (this.accentColor) {
660
- defaultParameters.accentColor = this.accentColor;
661
- }
662
- if (this.loaderBackground) {
663
- defaultParameters.loaderBackground = this.loaderBackground;
664
- }
665
- if (this.loaderFontColor) {
666
- defaultParameters.loaderFontColor = this.loaderFontColor;
667
- }
668
- if (this.loaderSpinnerColor) {
669
- defaultParameters.loaderSpinnerColor = this.loaderSpinnerColor;
670
- }
671
- if (this.loaderSpinnerBackground) {
672
- defaultParameters.loaderSpinnerBackground = this.loaderSpinnerBackground;
673
- }
674
- if (this.timezoneId) {
675
- defaultParameters.timezoneId = this.timezoneId;
676
- }
677
- if (this.itemDimensions) {
678
- defaultParameters.itemDimensions = this.itemDimensions;
679
- }
680
- if (this.appServer) {
681
- this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
682
- defaultParameters.appServer = this.appServer;
683
- } else {
684
- this.appServer = SharedLib2.addTrailingSlash(
685
- SharedLib2.DEFAULT_PARAMETERS.appServer
686
- );
687
- defaultParameters.appServer = this.appServer;
688
- }
689
- if (this.apiHost) {
690
- this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
691
- defaultParameters.apiHost = this.apiHost;
692
- } else {
693
- this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
694
- defaultParameters.apiHost = this.apiHost;
695
- }
696
- this.currentAuthKey = this.authKey;
697
- this.currentAuthToken = this.authToken;
698
- return defaultParameters;
699
- }
700
- _updateIframeUrl() {
701
- SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
702
- }
703
- // Setup loader / browser error
704
- _setupLoader() {
705
- const data = SharedLib2.getLoader(this);
706
- this._loaderMsg = data.loadingMsg;
707
- if (data.errorMsg) {
708
- this.browserError = true;
709
- this.browserErrorMsg = data.errorMsg;
710
- this._displayError();
711
- }
712
- }
713
- _displayError() {
714
- if (this.dashboardError) {
715
- this._loaderStyles();
716
- this.iframeStyle.opacity = 1;
717
- }
718
- if (this.browserError) {
719
- this._containerStyle.display = "none";
720
- }
721
- }
722
- _calculateDimAfterDashboardLoaded() {
723
- this.dashboardError = false;
724
- this._loaderStyles();
725
- SharedLib2._setCalculatedDimensions(this);
726
- }
727
- // Set loader styles
728
- _loaderStyles() {
729
- this._containerStyle = SharedLib2.containerStyles(this);
730
- this._loaderStyle = SharedLib2.loaderStyles(this);
731
- this._loadingCircleStyle = SharedLib2.plStyles(this);
732
- this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
733
- this._lcStyle = SharedLib2.lcStyles(this);
734
- }
735
- static get styles() {
736
- return [dashboardStyles];
737
- }
738
- render() {
739
- let toBeRenderedHTML;
740
- const loader = import_lit2.html`
741
- <div
742
- class="luzmo-container-loader"
743
- id="luzmo-container-loader-${this._containerId}"
744
- style=${(0, import_style_map.styleMap)(
745
- this._containerLoaderStyle
746
- )}
747
- >
748
- <div
749
- class="luzmo-loader"
750
- id="luzmo-loader-${this._containerId}"
751
- style=${(0, import_style_map.styleMap)(this._loaderStyle)}
752
- >
753
- <div
754
- class="luzmo-lc"
755
- style=${(0, import_style_map.styleMap)(this._lcStyle)}
756
- >
757
- <div
758
- class="luzmo-loading-circle"
759
- style=${(0, import_style_map.styleMap)(
760
- this._loadingCircleStyle
761
- )}
762
- ></div>
763
- ${this._itemEmbedding ? "" : import_lit2.html`
764
- <div
765
- class="luzmo-loading-message"
766
- style=${(0, import_style_map.styleMap)({ color: this.loaderFontColor })}
767
- >
768
- ${this._loaderMsg}
769
- </div>
770
- `}
771
- </div>
772
- </div>
773
- </div>
774
- `;
775
- if (this.getIsViewMode()) {
776
- toBeRenderedHTML = this.isLibraryLoaded ? import_lit2.html`
777
- ${this.dashboardId || this.dashboardSlug ? import_lit2.html`
778
- <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
779
- api-host="${this.params.apiHost}"></dashboard-component>` : import_lit2.html`
780
- <div id="luzmo-error-${this._containerId}">
781
- <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
782
- </div>
783
- `}
784
- ` : import_lit2.html`${loader}`;
785
- } else {
786
- toBeRenderedHTML = import_lit2.html`
787
- ${this.dashboardId || this.dashboardSlug ? import_lit2.html`
788
- ${loader}
789
- <iframe
790
- class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
791
- id="${this._iframeId}"
792
- name="${this._iframeId}"
793
- style=${(0, import_style_map.styleMap)(this.iframeStyle)}
794
- src="${this._iframeUrl}"
795
- frameborder="0"
796
- ></iframe>
797
- ` : import_lit2.html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
798
- ${this.browserError ? import_lit2.html`
799
- <div id="luzmo-error-${this._containerId}">
800
- <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
801
- </div>
802
- ` : ""}
803
- `;
804
- }
805
- return import_lit2.html`
806
- <div class="${import_shared_embed.luzmoEmbedContainerClass} ${!this.getIsViewMode() ? `${import_shared_embed.luzmoEmbedContainerClass}-ede` : ""}">
807
- <div
808
- class="dashboard-container"
809
- style=${(0, import_style_map.styleMap)(Object.assign({}, this._containerStyle, {
810
- width: this.iframeStyle.width ?? "100%",
811
- height: this.iframeStyle.height ?? "100%"
812
- }))}
813
- >
814
- ${toBeRenderedHTML}
815
- </div>
816
- </div>
817
-
818
- `;
819
- }
820
- getDashboards() {
821
- return new Promise(
822
- (resolve) => resolve(luzmo_service_default._components)
823
- );
824
- }
825
- // Public methods
826
- getData(itemId) {
827
- if (this.getIsViewMode() && this.dashboardReference) {
828
- return this.dashboardReference.getData(itemId);
829
- }
830
- if (!this.getIsViewMode()) {
831
- return SharedLib2.getData(this, this.iframe, itemId);
832
- }
833
- return Promise.reject();
834
- }
835
- getFilters() {
836
- if (this.getIsViewMode() && this.dashboardReference) {
837
- return this.dashboardReference.getFilters();
838
- }
839
- if (!this.getIsViewMode()) {
840
- return SharedLib2.getFilters(this, this.iframe);
841
- }
842
- return Promise.reject();
843
- }
844
- setFilters(itemId, filters) {
845
- if (this.getIsViewMode() && this.dashboardReference) {
846
- return this.dashboardReference.setFilters(itemId, filters);
847
- }
848
- if (!this.getIsViewMode()) {
849
- return SharedLib2.setFilters(this, this.iframe, itemId, filters);
850
- }
851
- return Promise.reject();
852
- }
853
- setAuthorization(key, token) {
854
- this.currentAuthKey = key;
855
- this.currentAuthToken = token;
856
- if (this.getIsViewMode() && this.dashboardReference) {
857
- return this.dashboardReference.setAuthorization(key, token);
858
- }
859
- if (!this.getIsViewMode()) {
860
- return SharedLib2.setAuthorization(this, this.iframe, key, token);
861
- }
862
- return Promise.reject();
863
- }
864
- refreshData(itemId) {
865
- if (this.getIsViewMode() && this.dashboardReference) {
866
- return this.dashboardReference.refreshData(itemId);
867
- }
868
- if (!this.getIsViewMode()) {
869
- return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
870
- }
871
- return Promise.reject();
872
- }
873
- reloadDashboard() {
874
- if (this.getIsViewMode() && this.dashboardReference) {
875
- return this.dashboardReference.reloadDashboard();
876
- }
877
- if (!this.getIsViewMode()) {
878
- return SharedLib2.reloadDashboard(this, this.iframe);
879
- }
880
- return Promise.reject();
881
- }
882
- exportDashboard(format) {
883
- if (this.getIsViewMode() && this.dashboardReference) {
884
- return this.dashboardReference.exportDashboard(format);
885
- }
886
- if (!this.getIsViewMode()) {
887
- return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
888
- }
889
- return Promise.reject();
890
- }
891
- getAccessibleDashboards() {
892
- return SharedLib2.getAccessibleDashboards(this);
893
- }
894
- addFilters(itemId, filters) {
895
- return this.dashboardReference.addFilters(itemId, filters);
896
- }
897
- setEditMode(editMode) {
898
- if (this.dashboardReference && editMode === "view") {
899
- this.editMode = "view";
900
- this.params.editMode = "view";
901
- this.initComponent();
902
- return Promise.resolve({
903
- type: "setEditMode",
904
- editMode
905
- });
906
- }
907
- if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
908
- this.editMode = editMode;
909
- this.params.editMode = editMode;
910
- this.initComponent();
911
- return Promise.resolve({
912
- type: "setEditMode",
913
- editMode
914
- });
915
- }
916
- if (this.getIsViewMode() && this.dashboardReference) {
917
- return this.dashboardReference.setEditMode(editMode);
918
- }
919
- if (!this.getIsViewMode()) {
920
- return SharedLib2.setEditMode(this, this.iframe, editMode);
921
- }
922
- return Promise.reject();
923
- }
924
- setPreview(preview) {
925
- if (this.getIsViewMode() && this.dashboardReference) {
926
- return this.dashboardReference.setPreview(preview);
927
- }
928
- return SharedLib2.setPreview(this, this.iframe, preview);
929
- }
930
- getIsViewMode() {
931
- return this.experimental && this.params.editMode === "view" || this.params.editMode === void 0;
932
- }
933
- };
934
- __decorateClass([
935
- (0, import_decorators.query)(".dashboard-container")
936
- ], LuzmoDashboard.prototype, "container", 2);
937
- __decorateClass([
938
- (0, import_decorators.query)(`.${import_shared_embed.luzmoEmbedContainerClass}`)
939
- ], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
940
- __decorateClass([
941
- (0, import_decorators.query)("iframe")
942
- ], LuzmoDashboard.prototype, "iframe", 2);
943
- __decorateClass([
944
- (0, import_decorators.property)()
945
- ], LuzmoDashboard.prototype, "dashboardId", 2);
946
- __decorateClass([
947
- (0, import_decorators.property)()
948
- ], LuzmoDashboard.prototype, "dashboardSlug", 2);
949
- __decorateClass([
950
- (0, import_decorators.property)()
951
- ], LuzmoDashboard.prototype, "itemId", 2);
952
- __decorateClass([
953
- (0, import_decorators.property)()
954
- ], LuzmoDashboard.prototype, "language", 2);
955
- __decorateClass([
956
- (0, import_decorators.property)()
957
- ], LuzmoDashboard.prototype, "qeVersion", 2);
958
- __decorateClass([
959
- (0, import_decorators.property)()
960
- ], LuzmoDashboard.prototype, "screenMode", 2);
961
- __decorateClass([
962
- (0, import_decorators.property)({
963
- converter: {
964
- fromAttribute: (value) => value === "true",
965
- toAttribute: String
966
- }
967
- })
968
- ], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2);
969
- __decorateClass([
970
- (0, import_decorators.property)()
971
- ], LuzmoDashboard.prototype, "editMode", 2);
972
- __decorateClass([
973
- (0, import_decorators.property)()
974
- ], LuzmoDashboard.prototype, "mainColor", 2);
975
- __decorateClass([
976
- (0, import_decorators.property)()
977
- ], LuzmoDashboard.prototype, "accentColor", 2);
978
- __decorateClass([
979
- (0, import_decorators.property)()
980
- ], LuzmoDashboard.prototype, "authToken", 2);
981
- __decorateClass([
982
- (0, import_decorators.property)()
983
- ], LuzmoDashboard.prototype, "authKey", 2);
984
- __decorateClass([
985
- (0, import_decorators.property)()
986
- ], LuzmoDashboard.prototype, "loaderBackground", 2);
987
- __decorateClass([
988
- (0, import_decorators.property)()
989
- ], LuzmoDashboard.prototype, "loaderFontColor", 2);
990
- __decorateClass([
991
- (0, import_decorators.property)()
992
- ], LuzmoDashboard.prototype, "loaderSpinnerColor", 2);
993
- __decorateClass([
994
- (0, import_decorators.property)()
995
- ], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2);
996
- __decorateClass([
997
- (0, import_decorators.property)()
998
- ], LuzmoDashboard.prototype, "appServer", 2);
999
- __decorateClass([
1000
- (0, import_decorators.property)()
1001
- ], LuzmoDashboard.prototype, "timezoneId", 2);
1002
- __decorateClass([
1003
- (0, import_decorators.property)()
1004
- ], LuzmoDashboard.prototype, "apiHost", 2);
1005
- __decorateClass([
1006
- (0, import_decorators.property)({ type: Object })
1007
- ], LuzmoDashboard.prototype, "itemDimensions", 2);
1008
- __decorateClass([
1009
- (0, import_decorators.property)({
1010
- converter: {
1011
- fromAttribute: (value) => value === "true",
1012
- toAttribute: String
1013
- }
1014
- })
1015
- ], LuzmoDashboard.prototype, "experimental", 2);
1016
- __decorateClass([
1017
- (0, import_decorators.property)({ attribute: false })
1018
- ], LuzmoDashboard.prototype, "_containerId", 2);
1019
- __decorateClass([
1020
- (0, import_decorators.property)({ attribute: false })
1021
- ], LuzmoDashboard.prototype, "_iframeId", 2);
1022
- __decorateClass([
1023
- (0, import_decorators.property)({ attribute: false })
1024
- ], LuzmoDashboard.prototype, "params", 2);
1025
- __decorateClass([
1026
- (0, import_decorators.property)({ attribute: false })
1027
- ], LuzmoDashboard.prototype, "_iframeUrl", 2);
1028
- __decorateClass([
1029
- (0, import_decorators.property)({ attribute: false })
1030
- ], LuzmoDashboard.prototype, "iframeLoaded", 2);
1031
- __decorateClass([
1032
- (0, import_decorators.property)({ attribute: false })
1033
- ], LuzmoDashboard.prototype, "promises", 2);
1034
- __decorateClass([
1035
- (0, import_decorators.property)({ attribute: false })
1036
- ], LuzmoDashboard.prototype, "iframeStyle", 2);
1037
- __decorateClass([
1038
- (0, import_decorators.property)({ attribute: false })
1039
- ], LuzmoDashboard.prototype, "_containerStyle", 2);
1040
- __decorateClass([
1041
- (0, import_decorators.property)({ attribute: false })
1042
- ], LuzmoDashboard.prototype, "_loaderStyle", 2);
1043
- __decorateClass([
1044
- (0, import_decorators.property)({ attribute: false })
1045
- ], LuzmoDashboard.prototype, "_lcStyle", 2);
1046
- __decorateClass([
1047
- (0, import_decorators.property)({ attribute: false })
1048
- ], LuzmoDashboard.prototype, "_loadingCircleStyle", 2);
1049
- __decorateClass([
1050
- (0, import_decorators.property)({ attribute: false })
1051
- ], LuzmoDashboard.prototype, "_containerLoaderStyle", 2);
1052
- __decorateClass([
1053
- (0, import_decorators.property)({ attribute: false })
1054
- ], LuzmoDashboard.prototype, "_loaderMsg", 2);
1055
- __decorateClass([
1056
- (0, import_decorators.property)({ attribute: false })
1057
- ], LuzmoDashboard.prototype, "containerWidth", 2);
1058
- __decorateClass([
1059
- (0, import_decorators.property)({ attribute: false })
1060
- ], LuzmoDashboard.prototype, "dimensions", 2);
1061
- __decorateClass([
1062
- (0, import_decorators.property)({ attribute: false })
1063
- ], LuzmoDashboard.prototype, "currentScreenMode", 2);
1064
- __decorateClass([
1065
- (0, import_decorators.property)({ attribute: false })
1066
- ], LuzmoDashboard.prototype, "_itemEmbedding", 2);
1067
- __decorateClass([
1068
- (0, import_decorators.property)({ attribute: false })
1069
- ], LuzmoDashboard.prototype, "browserError", 2);
1070
- __decorateClass([
1071
- (0, import_decorators.property)({ attribute: false })
1072
- ], LuzmoDashboard.prototype, "browserErrorMsg", 2);
1073
- __decorateClass([
1074
- (0, import_decorators.property)({ attribute: false })
1075
- ], LuzmoDashboard.prototype, "dashboardError", 2);
1076
- __decorateClass([
1077
- (0, import_decorators.property)({ attribute: false })
1078
- ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1079
- __decorateClass([
1080
- (0, import_decorators.property)()
1081
- ], LuzmoDashboard.prototype, "VERSION", 2);
1082
- __decorateClass([
1083
- (0, import_decorators.state)()
1084
- ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
1085
- __decorateClass([
1086
- (0, import_decorators.state)()
1087
- ], LuzmoDashboard.prototype, "dashboardReference", 2);
1088
- __decorateClass([
1089
- (0, import_decorators.state)()
1090
- ], LuzmoDashboard.prototype, "currentAuthKey", 2);
1091
- __decorateClass([
1092
- (0, import_decorators.state)()
1093
- ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1094
-
1095
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
1096
- var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
1097
- };
1098
- LuzmoDashboardWebComponent = __decorateClass([
1099
- (0, import_decorators2.customElement)("luzmo-dashboard-web-component")
1100
- ], LuzmoDashboardWebComponent);
1101
- // Annotate the CommonJS export names for ESM import in node:
1102
- 0 && (module.exports = {
1103
- LuzmoDashboardWebComponent
1104
- });