@luzmo/embed 5.1.5 → 6.0.0-beta.0

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,1058 +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.5";
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() {
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.isInitCalled = false;
348
- this.attributesMap = {
349
- dashboardId: "dashboard-id",
350
- dashboardSlug: "dashboard-slug",
351
- itemId: "item-id",
352
- language: "language",
353
- qeVersion: "qe-version",
354
- screenMode: "screen-mode",
355
- switchScreenModeOnResize: "switch-screen-mode-on-resize",
356
- authKey: "auth-key",
357
- authToken: "auth-token",
358
- editMode: "edit-mode",
359
- mainColor: "main-color",
360
- accentColor: "accent-color",
361
- loaderBackground: "loader-background",
362
- loaderFontColor: "loader-font-color",
363
- loaderSpinnerColor: "loader-spinner-color",
364
- loaderSpinnerBackground: "loader-spinner-background",
365
- appServer: "app-server",
366
- apiHost: "api-host",
367
- itemDimensions: "item-dimensions",
368
- timezoneId: "timezone-id"
369
- };
370
- this.loaderSize = 32;
371
- this.borderWidth = 3;
372
- this.minHeight = 400;
373
- this._containerId = SharedLib2.uuidv4();
374
- this._iframeId = `luzmo-dashboard-${this._containerId}`;
375
- this.iframeLoaded = false;
376
- this.promises = {};
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
- // Set resize event listener
424
- connectedCallback() {
425
- super.connectedCallback();
426
- }
427
- // Set resize event listener
428
- disconnectedCallback() {
429
- super.disconnectedCallback();
430
- this._resizeObserver.disconnect();
431
- for (const promiseKey of Object.keys(this.promises)) {
432
- this.promises[promiseKey].reject(
433
- new Error("Dashboard component was removed")
434
- );
435
- }
436
- }
437
- firstUpdated() {
438
- this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
439
- this._loaderStyles();
440
- luzmo_service_default._components.push(this);
441
- if (this.luzmoEmbedContainer) {
442
- this._resizeObserver.observe(this.luzmoEmbedContainer);
443
- }
444
- }
445
- initComponent() {
446
- this.params = this._setOptions();
447
- if (this.getIsViewMode()) {
448
- this.loadLibrary(this.params.appServer).then(async () => {
449
- this.isLibraryLoaded = true;
450
- await this.updateComplete;
451
- const oldReference = this.renderRoot.querySelector("dashboard-component");
452
- this.dashboardReference = oldReference.cloneNode(true);
453
- oldReference.replaceWith(this.dashboardReference);
454
- this.dashboardReference.addEventListener("load", (payload) => {
455
- this.containerWidth = this.dashboardReference.offsetWidth;
456
- this.dimensions = payload.detail.dimensions;
457
- SharedLib2._setCalculatedDimensions(this);
458
- window.dispatchEvent(new Event("resize"));
459
- this.dispatchEvent(new CustomEvent("load", payload));
460
- });
461
- this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
462
- this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
463
- this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
464
- this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
465
- this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
466
- this.setAllAttributes();
467
- });
468
- } else {
469
- this.containerWidth = this.container?.clientWidth;
470
- SharedLib2._extendAndValidate(this);
471
- SharedLib2._browserCheck(this);
472
- this._setupLoader();
473
- if (!this.params.error) {
474
- this._loaderStyles();
475
- _setEventHandler();
476
- this._iframeUrl = SharedLib2.createIframeUrl(this);
477
- this.iframe?.setAttribute("src", this._iframeUrl);
478
- this.iframeStyle = SharedLib2.calculateIframeStyles(this);
479
- }
480
- }
481
- }
482
- setAllAttributes() {
483
- if (this.dashboardReference) {
484
- for (const key in this.attributesMap) {
485
- if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
486
- this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
487
- }
488
- if (this.params.itemDimensions) {
489
- this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
490
- }
491
- if (this.params.apiHost) {
492
- this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
493
- }
494
- if (this.params.key) {
495
- this.dashboardReference.setAttribute("auth-key", this.params.key);
496
- }
497
- if (this.params.token) {
498
- this.dashboardReference.setAttribute("auth-token", this.params.token);
499
- }
500
- }
501
- }
502
- }
503
- // Reload dashboard when triggerproperty changes
504
- updated(changedProperties) {
505
- const triggerProperties = /* @__PURE__ */ new Set([
506
- "dashboardId",
507
- "dashboardSlug",
508
- "itemId",
509
- "language",
510
- "qeVersion",
511
- "editMode",
512
- "screenMode",
513
- "switchScreenModeOnResize",
514
- "authToken",
515
- "authKey",
516
- "appServer",
517
- "timezoneId",
518
- "itemDimensions"
519
- ]);
520
- const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
521
- let callInitComponent = false;
522
- for (const condition of conditionsToCheck) {
523
- callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition] !== void 0;
524
- }
525
- if (callInitComponent && !this.isInitCalled) {
526
- this.initComponent();
527
- this.isInitCalled = true;
528
- return;
529
- }
530
- if (this.getIsViewMode()) {
531
- if (this.dashboardReference) {
532
- for (const [propertyName] of changedProperties.entries()) {
533
- if (propertyName === "appSever") {
534
- this.loadLibrary(changedProperties[propertyName]).then(async () => {
535
- this.isLibraryLoaded = true;
536
- await this.updateComplete;
537
- this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
538
- this.setAllAttributes();
539
- });
540
- } else if (this.attributesMap[propertyName]) {
541
- const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
542
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
543
- this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
544
- }
545
- }
546
- }
547
- } else {
548
- for (const [propertyName] of changedProperties.entries()) {
549
- if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
550
- this.iframeLoaded = false;
551
- if (this._loadTimeoutHandle) {
552
- clearTimeout(this._loadTimeoutHandle);
553
- }
554
- this._loadTimeoutHandle = setTimeout(() => {
555
- console.warn(
556
- "Failed to load dashboard, appServer is likely down or unreachable."
557
- );
558
- }, 15 * 1e3);
559
- this.params = this._setOptions();
560
- SharedLib2._extendAndValidate(this);
561
- this._setupLoader();
562
- this._loaderStyles();
563
- this._iframeUrl = SharedLib2.createIframeUrl(this);
564
- if (this.iframe) {
565
- this._updateIframeUrl();
566
- }
567
- this.iframeStyle = SharedLib2.calculateIframeStyles(this);
568
- } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
569
- if (this.iframeLoaded) {
570
- this.setEditMode(this.editMode);
571
- }
572
- this.params = this._setOptions();
573
- }
574
- }
575
- }
576
- }
577
- // Set params
578
- _setOptions() {
579
- const defaultParameters = {
580
- dashboardId: this.dashboardId,
581
- dashboardSlug: this.dashboardSlug
582
- };
583
- if (this.itemId) {
584
- defaultParameters.itemId = this.itemId;
585
- this._itemEmbedding = true;
586
- } else {
587
- this._itemEmbedding = false;
588
- }
589
- if (this.language) {
590
- defaultParameters.language = this.language;
591
- }
592
- if (this.qeVersion) {
593
- defaultParameters.qeVersion = this.qeVersion;
594
- }
595
- if (this.screenMode) {
596
- defaultParameters.screenMode = this.screenMode;
597
- }
598
- defaultParameters.switchScreenModeOnResize = this.switchScreenModeOnResize;
599
- if (this.authToken) {
600
- defaultParameters.token = this.authToken;
601
- }
602
- if (this.authKey) {
603
- defaultParameters.key = this.authKey;
604
- }
605
- if (this.editMode) {
606
- defaultParameters.editMode = this.editMode;
607
- }
608
- if (this.mainColor) {
609
- defaultParameters.mainColor = this.mainColor;
610
- }
611
- if (this.accentColor) {
612
- defaultParameters.accentColor = this.accentColor;
613
- }
614
- if (this.loaderBackground) {
615
- defaultParameters.loaderBackground = this.loaderBackground;
616
- }
617
- if (this.loaderFontColor) {
618
- defaultParameters.loaderFontColor = this.loaderFontColor;
619
- }
620
- if (this.loaderSpinnerColor) {
621
- defaultParameters.loaderSpinnerColor = this.loaderSpinnerColor;
622
- }
623
- if (this.loaderSpinnerBackground) {
624
- defaultParameters.loaderSpinnerBackground = this.loaderSpinnerBackground;
625
- }
626
- if (this.timezoneId) {
627
- defaultParameters.timezoneId = this.timezoneId;
628
- }
629
- if (this.itemDimensions) {
630
- defaultParameters.itemDimensions = this.itemDimensions;
631
- }
632
- if (this.appServer) {
633
- this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
634
- defaultParameters.appServer = this.appServer;
635
- } else {
636
- this.appServer = SharedLib2.addTrailingSlash(
637
- SharedLib2.DEFAULT_PARAMETERS.appServer
638
- );
639
- defaultParameters.appServer = this.appServer;
640
- }
641
- if (this.apiHost) {
642
- this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
643
- defaultParameters.apiHost = this.apiHost;
644
- } else {
645
- this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
646
- defaultParameters.apiHost = this.apiHost;
647
- }
648
- this.currentAuthKey = this.authKey;
649
- this.currentAuthToken = this.authToken;
650
- return defaultParameters;
651
- }
652
- _updateIframeUrl() {
653
- SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
654
- }
655
- // Setup loader / browser error
656
- _setupLoader() {
657
- const data = SharedLib2.getLoader(this);
658
- this._loaderMsg = data.loadingMsg;
659
- if (data.errorMsg) {
660
- this.browserError = true;
661
- this.browserErrorMsg = data.errorMsg;
662
- this._displayError();
663
- }
664
- }
665
- _displayError() {
666
- if (this.dashboardError) {
667
- this._loaderStyles();
668
- this.iframeStyle.opacity = 1;
669
- }
670
- if (this.browserError) {
671
- this._containerStyle.display = "none";
672
- }
673
- }
674
- _calculateDimAfterDashboardLoaded() {
675
- this.dashboardError = false;
676
- this._loaderStyles();
677
- SharedLib2._setCalculatedDimensions(this);
678
- }
679
- // Set loader styles
680
- _loaderStyles() {
681
- this._containerStyle = SharedLib2.containerStyles(this);
682
- this._loaderStyle = SharedLib2.loaderStyles(this);
683
- this._loadingCircleStyle = SharedLib2.plStyles(this);
684
- this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
685
- this._lcStyle = SharedLib2.lcStyles(this);
686
- }
687
- static get styles() {
688
- return [dashboardStyles];
689
- }
690
- render() {
691
- let toBeRenderedHTML;
692
- const loader = html`
693
- <div
694
- class="luzmo-container-loader"
695
- id="luzmo-container-loader-${this._containerId}"
696
- style=${styleMap(
697
- this._containerLoaderStyle
698
- )}
699
- >
700
- <div
701
- class="luzmo-loader"
702
- id="luzmo-loader-${this._containerId}"
703
- style=${styleMap(this._loaderStyle)}
704
- >
705
- <div
706
- class="luzmo-lc"
707
- style=${styleMap(this._lcStyle)}
708
- >
709
- <div
710
- class="luzmo-loading-circle"
711
- style=${styleMap(
712
- this._loadingCircleStyle
713
- )}
714
- ></div>
715
- ${this._itemEmbedding ? "" : html`
716
- <div
717
- class="luzmo-loading-message"
718
- style=${styleMap({ color: this.loaderFontColor })}
719
- >
720
- ${this._loaderMsg}
721
- </div>
722
- `}
723
- </div>
724
- </div>
725
- </div>
726
- `;
727
- if (this.getIsViewMode()) {
728
- toBeRenderedHTML = this.isLibraryLoaded ? html`
729
- ${this.dashboardId || this.dashboardSlug ? html`
730
- <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
731
- api-host="${this.params.apiHost}"></dashboard-component>` : html`
732
- <div id="luzmo-error-${this._containerId}">
733
- <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
734
- </div>
735
- `}
736
- ` : html`${loader}`;
737
- } else {
738
- toBeRenderedHTML = html`
739
- ${this.dashboardId || this.dashboardSlug ? html`
740
- ${loader}
741
- <iframe
742
- class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
743
- id="${this._iframeId}"
744
- name="${this._iframeId}"
745
- style=${styleMap(this.iframeStyle)}
746
- src="${this._iframeUrl}"
747
- frameborder="0"
748
- ></iframe>
749
- ` : html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
750
- ${this.browserError ? html`
751
- <div id="luzmo-error-${this._containerId}">
752
- <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
753
- </div>
754
- ` : ""}
755
- `;
756
- }
757
- return html`
758
- <div class="${luzmoEmbedContainerClass} ${!this.getIsViewMode() ? `${luzmoEmbedContainerClass}-ede` : ""}">
759
- <div
760
- class="dashboard-container"
761
- style=${styleMap(Object.assign({}, this._containerStyle, {
762
- width: this.iframeStyle.width ?? "100%",
763
- height: this.iframeStyle.height ?? "100%"
764
- }))}
765
- >
766
- ${toBeRenderedHTML}
767
- </div>
768
- </div>
769
-
770
- `;
771
- }
772
- getDashboards() {
773
- return new Promise(
774
- (resolve) => resolve(luzmo_service_default._components)
775
- );
776
- }
777
- // Public methods
778
- getData(itemId) {
779
- if (this.getIsViewMode() && this.dashboardReference) {
780
- return this.dashboardReference.getData(itemId);
781
- }
782
- if (!this.getIsViewMode()) {
783
- return SharedLib2.getData(this, this.iframe, itemId);
784
- }
785
- return Promise.reject();
786
- }
787
- getFilters() {
788
- if (this.getIsViewMode() && this.dashboardReference) {
789
- return this.dashboardReference.getFilters();
790
- }
791
- if (!this.getIsViewMode()) {
792
- return SharedLib2.getFilters(this, this.iframe);
793
- }
794
- return Promise.reject();
795
- }
796
- setFilters(itemId, filters) {
797
- if (this.getIsViewMode() && this.dashboardReference) {
798
- return this.dashboardReference.setFilters(itemId, filters);
799
- }
800
- if (!this.getIsViewMode()) {
801
- return SharedLib2.setFilters(this, this.iframe, itemId, filters);
802
- }
803
- return Promise.reject();
804
- }
805
- setAuthorization(key, token) {
806
- this.currentAuthKey = key;
807
- this.currentAuthToken = token;
808
- if (this.getIsViewMode() && this.dashboardReference) {
809
- return this.dashboardReference.setAuthorization(key, token);
810
- }
811
- if (!this.getIsViewMode()) {
812
- return SharedLib2.setAuthorization(this, this.iframe, key, token);
813
- }
814
- return Promise.reject();
815
- }
816
- refreshData(itemId) {
817
- if (this.getIsViewMode() && this.dashboardReference) {
818
- return this.dashboardReference.refreshData(itemId);
819
- }
820
- if (!this.getIsViewMode()) {
821
- return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
822
- }
823
- return Promise.reject();
824
- }
825
- reloadDashboard() {
826
- if (this.getIsViewMode() && this.dashboardReference) {
827
- return this.dashboardReference.reloadDashboard();
828
- }
829
- if (!this.getIsViewMode()) {
830
- return SharedLib2.reloadDashboard(this, this.iframe);
831
- }
832
- return Promise.reject();
833
- }
834
- exportDashboard(format) {
835
- if (this.getIsViewMode() && this.dashboardReference) {
836
- return this.dashboardReference.exportDashboard(format);
837
- }
838
- if (!this.getIsViewMode()) {
839
- return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
840
- }
841
- return Promise.reject();
842
- }
843
- getAccessibleDashboards() {
844
- return SharedLib2.getAccessibleDashboards(this);
845
- }
846
- addFilters(itemId, filters) {
847
- return this.dashboardReference.addFilters(itemId, filters);
848
- }
849
- setEditMode(editMode) {
850
- if (this.dashboardReference && editMode === "view") {
851
- this.editMode = "view";
852
- this.params.editMode = "view";
853
- this.initComponent();
854
- return Promise.resolve({
855
- type: "setEditMode",
856
- editMode
857
- });
858
- }
859
- if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
860
- this.editMode = editMode;
861
- this.params.editMode = editMode;
862
- this.initComponent();
863
- return Promise.resolve({
864
- type: "setEditMode",
865
- editMode
866
- });
867
- }
868
- if (this.getIsViewMode() && this.dashboardReference) {
869
- return this.dashboardReference.setEditMode(editMode);
870
- }
871
- if (!this.getIsViewMode()) {
872
- return SharedLib2.setEditMode(this, this.iframe, editMode);
873
- }
874
- return Promise.reject();
875
- }
876
- setPreview(preview) {
877
- if (this.getIsViewMode() && this.dashboardReference) {
878
- return this.dashboardReference.setPreview(preview);
879
- }
880
- return SharedLib2.setPreview(this, this.iframe, preview);
881
- }
882
- getIsViewMode() {
883
- return this.experimental && this.params.editMode === "view" || this.params.editMode === void 0;
884
- }
885
- };
886
- __decorateClass([
887
- query(".dashboard-container")
888
- ], LuzmoDashboard.prototype, "container", 2);
889
- __decorateClass([
890
- query(`.${luzmoEmbedContainerClass}`)
891
- ], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
892
- __decorateClass([
893
- query("iframe")
894
- ], LuzmoDashboard.prototype, "iframe", 2);
895
- __decorateClass([
896
- property()
897
- ], LuzmoDashboard.prototype, "dashboardId", 2);
898
- __decorateClass([
899
- property()
900
- ], LuzmoDashboard.prototype, "dashboardSlug", 2);
901
- __decorateClass([
902
- property()
903
- ], LuzmoDashboard.prototype, "itemId", 2);
904
- __decorateClass([
905
- property()
906
- ], LuzmoDashboard.prototype, "language", 2);
907
- __decorateClass([
908
- property()
909
- ], LuzmoDashboard.prototype, "qeVersion", 2);
910
- __decorateClass([
911
- property()
912
- ], LuzmoDashboard.prototype, "screenMode", 2);
913
- __decorateClass([
914
- property({
915
- converter: {
916
- fromAttribute: (value) => value === "true",
917
- toAttribute: String
918
- }
919
- })
920
- ], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2);
921
- __decorateClass([
922
- property()
923
- ], LuzmoDashboard.prototype, "editMode", 2);
924
- __decorateClass([
925
- property()
926
- ], LuzmoDashboard.prototype, "mainColor", 2);
927
- __decorateClass([
928
- property()
929
- ], LuzmoDashboard.prototype, "accentColor", 2);
930
- __decorateClass([
931
- property()
932
- ], LuzmoDashboard.prototype, "authToken", 2);
933
- __decorateClass([
934
- property()
935
- ], LuzmoDashboard.prototype, "authKey", 2);
936
- __decorateClass([
937
- property()
938
- ], LuzmoDashboard.prototype, "loaderBackground", 2);
939
- __decorateClass([
940
- property()
941
- ], LuzmoDashboard.prototype, "loaderFontColor", 2);
942
- __decorateClass([
943
- property()
944
- ], LuzmoDashboard.prototype, "loaderSpinnerColor", 2);
945
- __decorateClass([
946
- property()
947
- ], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2);
948
- __decorateClass([
949
- property()
950
- ], LuzmoDashboard.prototype, "appServer", 2);
951
- __decorateClass([
952
- property()
953
- ], LuzmoDashboard.prototype, "timezoneId", 2);
954
- __decorateClass([
955
- property()
956
- ], LuzmoDashboard.prototype, "apiHost", 2);
957
- __decorateClass([
958
- property({ type: Object })
959
- ], LuzmoDashboard.prototype, "itemDimensions", 2);
960
- __decorateClass([
961
- property({
962
- converter: {
963
- fromAttribute: (value) => value === "true",
964
- toAttribute: String
965
- }
966
- })
967
- ], LuzmoDashboard.prototype, "experimental", 2);
968
- __decorateClass([
969
- property({ attribute: false })
970
- ], LuzmoDashboard.prototype, "_containerId", 2);
971
- __decorateClass([
972
- property({ attribute: false })
973
- ], LuzmoDashboard.prototype, "_iframeId", 2);
974
- __decorateClass([
975
- property({ attribute: false })
976
- ], LuzmoDashboard.prototype, "params", 2);
977
- __decorateClass([
978
- property({ attribute: false })
979
- ], LuzmoDashboard.prototype, "_iframeUrl", 2);
980
- __decorateClass([
981
- property({ attribute: false })
982
- ], LuzmoDashboard.prototype, "iframeLoaded", 2);
983
- __decorateClass([
984
- property({ attribute: false })
985
- ], LuzmoDashboard.prototype, "promises", 2);
986
- __decorateClass([
987
- property({ attribute: false })
988
- ], LuzmoDashboard.prototype, "iframeStyle", 2);
989
- __decorateClass([
990
- property({ attribute: false })
991
- ], LuzmoDashboard.prototype, "_containerStyle", 2);
992
- __decorateClass([
993
- property({ attribute: false })
994
- ], LuzmoDashboard.prototype, "_loaderStyle", 2);
995
- __decorateClass([
996
- property({ attribute: false })
997
- ], LuzmoDashboard.prototype, "_lcStyle", 2);
998
- __decorateClass([
999
- property({ attribute: false })
1000
- ], LuzmoDashboard.prototype, "_loadingCircleStyle", 2);
1001
- __decorateClass([
1002
- property({ attribute: false })
1003
- ], LuzmoDashboard.prototype, "_containerLoaderStyle", 2);
1004
- __decorateClass([
1005
- property({ attribute: false })
1006
- ], LuzmoDashboard.prototype, "_loaderMsg", 2);
1007
- __decorateClass([
1008
- property({ attribute: false })
1009
- ], LuzmoDashboard.prototype, "containerWidth", 2);
1010
- __decorateClass([
1011
- property({ attribute: false })
1012
- ], LuzmoDashboard.prototype, "dimensions", 2);
1013
- __decorateClass([
1014
- property({ attribute: false })
1015
- ], LuzmoDashboard.prototype, "currentScreenMode", 2);
1016
- __decorateClass([
1017
- property({ attribute: false })
1018
- ], LuzmoDashboard.prototype, "_itemEmbedding", 2);
1019
- __decorateClass([
1020
- property({ attribute: false })
1021
- ], LuzmoDashboard.prototype, "browserError", 2);
1022
- __decorateClass([
1023
- property({ attribute: false })
1024
- ], LuzmoDashboard.prototype, "browserErrorMsg", 2);
1025
- __decorateClass([
1026
- property({ attribute: false })
1027
- ], LuzmoDashboard.prototype, "dashboardError", 2);
1028
- __decorateClass([
1029
- property({ attribute: false })
1030
- ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1031
- __decorateClass([
1032
- property()
1033
- ], LuzmoDashboard.prototype, "VERSION", 2);
1034
- __decorateClass([
1035
- state()
1036
- ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
1037
- __decorateClass([
1038
- state()
1039
- ], LuzmoDashboard.prototype, "dashboardReference", 2);
1040
- __decorateClass([
1041
- state()
1042
- ], LuzmoDashboard.prototype, "currentAuthKey", 2);
1043
- __decorateClass([
1044
- state()
1045
- ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1046
- __decorateClass([
1047
- state()
1048
- ], LuzmoDashboard.prototype, "isInitCalled", 2);
1049
-
1050
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
1051
- var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
1052
- };
1053
- LuzmoDashboardWebComponent = __decorateClass([
1054
- customElement("luzmo-dashboard-web-component")
1055
- ], LuzmoDashboardWebComponent);
1056
- export {
1057
- LuzmoDashboardWebComponent
1058
- };