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