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