@luzmo/embed 5.0.13-beta.1 → 5.0.13

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