@luzmo/embed 8.0.0-es2021 → 8.1.0-es2021
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/CHANGELOG.md +12 -0
- package/README.md +182 -145
- package/index.cjs +372 -290
- package/index.js +372 -290
- package/index.rn.cjs +329 -271
- package/index.rn.js +329 -271
- package/index.shared.cjs +329 -271
- package/index.shared.js +329 -271
- package/luzmo-embed.min.js +373 -291
- package/package.json +2 -2
- package/src/lib/dashboard/dashboard-base.d.ts +3 -3
- package/src/lib/iq-components/luzmo-iq-answer.d.ts +1 -1
- package/src/lib/iq-components/luzmo-iq-chat.d.ts +1 -1
- package/src/lib/luzmo-service.d.ts +1 -1
- package/src/lib/shared/helpers/default-parameters.d.ts +19 -2
- package/src/lib/shared/helpers/utils.d.ts +3 -3
- package/src/lib/shared/methods/export-dashboard.d.ts +1 -2
- package/src/lib/shared/methods/send-export-email.d.ts +3 -2
- package/src/lib/shared/models/common.model.d.ts +1 -1
- package/src/lib/shared/models/dashboard-context.model.d.ts +2 -0
- package/src/lib/shared/models/dashboard.model.d.ts +1 -2
- package/src/lib/shared/models/export.model.d.ts +3 -0
- package/src/lib/shared/models/index.d.ts +1 -0
- package/src/lib/viz-item/viz-item.base.d.ts +14 -5
package/index.rn.cjs
CHANGED
|
@@ -431,41 +431,46 @@ var createIframeUrl = (dashboardContent) => {
|
|
|
431
431
|
// libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
|
|
432
432
|
var getLoader = (dashboardComponent) => {
|
|
433
433
|
let errorMsg;
|
|
434
|
-
if (dashboardComponent.params
|
|
435
|
-
dashboardComponent.params
|
|
434
|
+
if (dashboardComponent.params?.error || (dashboardComponent.browserNotSupported?.length ?? 0) > 0) {
|
|
435
|
+
if (dashboardComponent.params) {
|
|
436
|
+
dashboardComponent.params.error = true;
|
|
437
|
+
}
|
|
436
438
|
if (dashboardComponent.browserNotSupported) {
|
|
437
439
|
errorMsg = "Browser is not supported.";
|
|
438
440
|
}
|
|
439
441
|
}
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
+
const language = dashboardComponent.params?.language;
|
|
443
|
+
const loadingMsg = (language ? translations_default.initializing[language] : void 0) || translations_default.initializing.en;
|
|
444
|
+
return dashboardComponent.browserNotSupported || dashboardComponent.params?.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
|
|
442
445
|
};
|
|
443
446
|
|
|
444
447
|
// libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
|
|
445
448
|
function resolvePromise(dashboardComponent, requestId, data) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
+
const promises = dashboardComponent.promises;
|
|
450
|
+
if (promises?.[requestId]) {
|
|
451
|
+
promises[requestId].resolve(data);
|
|
452
|
+
delete promises[requestId];
|
|
449
453
|
}
|
|
450
454
|
}
|
|
451
455
|
function rejectPromise(dashboardComponent, requestId, data) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
456
|
+
const promises = dashboardComponent.promises;
|
|
457
|
+
if (promises?.[requestId]) {
|
|
458
|
+
promises[requestId].reject(data);
|
|
459
|
+
delete promises[requestId];
|
|
455
460
|
}
|
|
456
461
|
}
|
|
457
462
|
|
|
458
463
|
// libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
|
|
459
464
|
function containerStyles(dashboardComponent) {
|
|
460
465
|
const styles = {};
|
|
461
|
-
if (dashboardComponent.params
|
|
466
|
+
if (dashboardComponent.params?.loaderBackground && !dashboardComponent.iframeLoaded) {
|
|
462
467
|
styles.background = dashboardComponent.params.loaderBackground;
|
|
463
468
|
}
|
|
464
469
|
return styles;
|
|
465
470
|
}
|
|
466
471
|
function containerLoaderStyles(dashboardComponent) {
|
|
467
|
-
const height = dashboardComponent.params
|
|
468
|
-
const chartHeightDefined = dashboardComponent.params
|
|
472
|
+
const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
473
|
+
const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
|
|
469
474
|
const display = dashboardComponent.iframeLoaded ? "none" : "";
|
|
470
475
|
return {
|
|
471
476
|
display,
|
|
@@ -473,8 +478,8 @@ function containerLoaderStyles(dashboardComponent) {
|
|
|
473
478
|
};
|
|
474
479
|
}
|
|
475
480
|
function loaderStyles(dashboardComponent) {
|
|
476
|
-
const background = dashboardComponent.params
|
|
477
|
-
if (dashboardComponent.params
|
|
481
|
+
const background = dashboardComponent.params?.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
|
|
482
|
+
if (dashboardComponent.params?.itemEmbedding) {
|
|
478
483
|
dashboardComponent.loaderSize = 24;
|
|
479
484
|
dashboardComponent.borderWidth = 4;
|
|
480
485
|
dashboardComponent.minHeight = 200;
|
|
@@ -503,11 +508,11 @@ function plStyles(dashboardComponent) {
|
|
|
503
508
|
} = DEFAULT_PARAMETERS;
|
|
504
509
|
const spinnerColorBorder = generateBorderStyle(
|
|
505
510
|
dashboardComponent.borderWidth,
|
|
506
|
-
dashboardComponent.params
|
|
511
|
+
dashboardComponent.params?.loaderSpinnerColor || defaultSpinnerColor
|
|
507
512
|
);
|
|
508
513
|
const spinnerBackgroundBorder = generateBorderStyle(
|
|
509
514
|
dashboardComponent.borderWidth,
|
|
510
|
-
dashboardComponent.params
|
|
515
|
+
dashboardComponent.params?.loaderSpinnerBackground || defaultSpinnerBackground
|
|
511
516
|
);
|
|
512
517
|
const size = `${dashboardComponent.loaderSize}px`;
|
|
513
518
|
return {
|
|
@@ -520,27 +525,28 @@ function plStyles(dashboardComponent) {
|
|
|
520
525
|
};
|
|
521
526
|
}
|
|
522
527
|
function lcStyles(dashboardComponent) {
|
|
523
|
-
const height = dashboardComponent.params
|
|
524
|
-
const chartHeightDefined = dashboardComponent.params
|
|
525
|
-
const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
|
|
526
|
-
const verticalPadding = dashboardComponent.params
|
|
528
|
+
const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
529
|
+
const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
|
|
530
|
+
const getPaddingStr = (value) => `${((value ?? Number.NaN) - (dashboardComponent.loaderSize ?? Number.NaN) - 32) / 2}px`;
|
|
531
|
+
const verticalPadding = dashboardComponent.params?.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
|
|
527
532
|
return {
|
|
528
533
|
padding: `${verticalPadding} 16px`
|
|
529
534
|
};
|
|
530
535
|
}
|
|
531
536
|
function calculateIframeStyles(dashboardComponent) {
|
|
532
|
-
const height = dashboardComponent.params
|
|
533
|
-
const width = dashboardComponent.params
|
|
534
|
-
|
|
537
|
+
const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
|
|
538
|
+
const width = dashboardComponent.params?.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
|
|
539
|
+
const editMode = dashboardComponent.params?.editMode;
|
|
540
|
+
if (dashboardComponent.params?.itemEmbedding && height !== "auto") {
|
|
535
541
|
dashboardComponent.iframeHeight = `${height}px`;
|
|
536
|
-
} else if (dashboardComponent.params
|
|
542
|
+
} else if (dashboardComponent.params?.itemEmbedding) {
|
|
537
543
|
dashboardComponent.iframeHeight = "200px";
|
|
538
|
-
} else if (["editFull", "editLimited"].includes(
|
|
544
|
+
} else if (editMode != null && ["editFull", "editLimited"].includes(editMode)) {
|
|
539
545
|
dashboardComponent.iframeHeight = "100%";
|
|
540
546
|
} else {
|
|
541
547
|
dashboardComponent.iframeHeight = "400px";
|
|
542
548
|
}
|
|
543
|
-
dashboardComponent.iframeWidth = dashboardComponent.params
|
|
549
|
+
dashboardComponent.iframeWidth = dashboardComponent.params?.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
|
|
544
550
|
const styles = {
|
|
545
551
|
height: dashboardComponent.iframeHeight,
|
|
546
552
|
width: dashboardComponent.iframeWidth
|
|
@@ -559,7 +565,7 @@ function calculateIframeStyles(dashboardComponent) {
|
|
|
559
565
|
|
|
560
566
|
// libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
|
|
561
567
|
var updateIframeUrl = (iframe, iframeUrl) => {
|
|
562
|
-
if (iframe?.contentWindow) {
|
|
568
|
+
if (iframe?.contentWindow && iframeUrl !== void 0) {
|
|
563
569
|
iframe.contentWindow.location.replace(iframeUrl);
|
|
564
570
|
}
|
|
565
571
|
};
|
|
@@ -568,7 +574,7 @@ var updateIframeUrl = (iframe, iframeUrl) => {
|
|
|
568
574
|
var selectedDataUtils = {
|
|
569
575
|
merge(...filters) {
|
|
570
576
|
return filters.reduce((acc, filter) => {
|
|
571
|
-
acc.and.push(...filter.and);
|
|
577
|
+
(acc.and ??= []).push(...filter.and ?? []);
|
|
572
578
|
return acc;
|
|
573
579
|
}, {
|
|
574
580
|
and: []
|
|
@@ -631,43 +637,46 @@ var selectedDataUtils = {
|
|
|
631
637
|
// libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
|
|
632
638
|
var exportDashboard = (dashboardComponent, iframe, format) => {
|
|
633
639
|
const requestId = uuidv4();
|
|
634
|
-
if (iframe?.contentWindow) {
|
|
635
|
-
|
|
636
|
-
{
|
|
637
|
-
action: "exportDashboard",
|
|
638
|
-
format: format || "png",
|
|
639
|
-
_version: dashboardComponent.libVersion,
|
|
640
|
-
requestId
|
|
641
|
-
},
|
|
642
|
-
"*"
|
|
643
|
-
);
|
|
644
|
-
return new Promise((resolve, reject) => {
|
|
645
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
646
|
-
setTimeout(() => {
|
|
647
|
-
if (dashboardComponent.promises[requestId]) {
|
|
648
|
-
const errorMessage = "exportDashboard request timed out.";
|
|
649
|
-
dashboardComponent.promises[requestId].reject(
|
|
650
|
-
new Error(errorMessage)
|
|
651
|
-
);
|
|
652
|
-
delete dashboardComponent.promises[requestId];
|
|
653
|
-
}
|
|
654
|
-
}, 12e5);
|
|
655
|
-
});
|
|
640
|
+
if (!iframe?.contentWindow) {
|
|
641
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
656
642
|
}
|
|
657
|
-
|
|
643
|
+
const { promises } = dashboardComponent;
|
|
644
|
+
if (!promises) {
|
|
645
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
646
|
+
}
|
|
647
|
+
iframe.contentWindow.postMessage(
|
|
648
|
+
{
|
|
649
|
+
action: "exportDashboard",
|
|
650
|
+
format: format || "png",
|
|
651
|
+
_version: dashboardComponent.libVersion,
|
|
652
|
+
requestId
|
|
653
|
+
},
|
|
654
|
+
"*"
|
|
655
|
+
);
|
|
656
|
+
return new Promise((resolve, reject) => {
|
|
657
|
+
promises[requestId] = { resolve, reject };
|
|
658
|
+
setTimeout(() => {
|
|
659
|
+
if (promises[requestId]) {
|
|
660
|
+
const errorMessage = "exportDashboard request timed out.";
|
|
661
|
+
promises[requestId].reject(new Error(errorMessage));
|
|
662
|
+
delete promises[requestId];
|
|
663
|
+
}
|
|
664
|
+
}, 12e5);
|
|
665
|
+
});
|
|
658
666
|
};
|
|
659
667
|
|
|
660
668
|
// libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
|
|
661
669
|
var getAccessibleDashboards = async (dashboardComponent) => {
|
|
662
670
|
await dashboardComponent.updateComplete;
|
|
663
|
-
if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
|
|
671
|
+
if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken) && dashboardComponent.params) {
|
|
672
|
+
const { params } = dashboardComponent;
|
|
664
673
|
const fetchUser = new Promise((resolve, reject) => {
|
|
665
674
|
void (() => {
|
|
666
675
|
try {
|
|
667
676
|
const responsePromise = window.fetch(
|
|
668
677
|
// With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
|
|
669
678
|
// Fixes incorrect url with embedMode="webComponent"
|
|
670
|
-
`${addTrailingSlash(
|
|
679
|
+
`${addTrailingSlash(params.apiHost)}0.1.0/authorization`,
|
|
671
680
|
{
|
|
672
681
|
method: "POST",
|
|
673
682
|
mode: "cors",
|
|
@@ -712,136 +721,144 @@ var getAccessibleDashboards = async (dashboardComponent) => {
|
|
|
712
721
|
}
|
|
713
722
|
})();
|
|
714
723
|
});
|
|
715
|
-
return new Promise((resolve, reject) =>
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
data.rows
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
724
|
+
return new Promise((resolve, reject) => {
|
|
725
|
+
void (() => {
|
|
726
|
+
try {
|
|
727
|
+
fetchUser.then((authorizationData) => {
|
|
728
|
+
const responsePromise = window.fetch(
|
|
729
|
+
// With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
|
|
730
|
+
// Fixes incorrect url with embedMode="webComponent"
|
|
731
|
+
`${addTrailingSlash(params.apiHost)}0.1.0/securable`,
|
|
732
|
+
{
|
|
733
|
+
method: "POST",
|
|
734
|
+
mode: "cors",
|
|
735
|
+
cache: "no-cache",
|
|
736
|
+
headers: { "Content-Type": "application/json" },
|
|
737
|
+
redirect: "follow",
|
|
738
|
+
body: JSON.stringify({
|
|
739
|
+
action: "get",
|
|
740
|
+
version: "0.1.0",
|
|
741
|
+
key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
|
|
742
|
+
token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
|
|
743
|
+
find: {
|
|
744
|
+
where: { type: "dashboard", is_variant: false },
|
|
745
|
+
attributes: ["id", "name", "modified_at"],
|
|
746
|
+
order: [["modified_at", "desc"]],
|
|
747
|
+
include: [
|
|
748
|
+
{ model: "Tag", attributes: ["tag"] },
|
|
749
|
+
{ model: "User", attributes: ["id", "name"] },
|
|
750
|
+
{
|
|
751
|
+
model: "Group",
|
|
752
|
+
attributes: ["id", "name", "public"]
|
|
753
|
+
},
|
|
754
|
+
{ model: "Integration", attributes: ["id", "name"] }
|
|
755
|
+
]
|
|
756
|
+
}
|
|
757
|
+
})
|
|
758
|
+
}
|
|
759
|
+
);
|
|
760
|
+
responsePromise.then((response) => response.json()).then((data) => {
|
|
761
|
+
const dashboardList = data.rows.length > 0 ? formatDashboardList(
|
|
762
|
+
data.rows,
|
|
763
|
+
authorizationData.integrationId,
|
|
764
|
+
authorizationData.user,
|
|
765
|
+
dashboardComponent
|
|
766
|
+
) : [];
|
|
767
|
+
resolve(dashboardList);
|
|
768
|
+
});
|
|
769
|
+
}).catch((error) => {
|
|
770
|
+
reject(error);
|
|
758
771
|
});
|
|
759
|
-
}
|
|
772
|
+
} catch (error) {
|
|
760
773
|
reject(error);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
}
|
|
765
|
-
})());
|
|
774
|
+
}
|
|
775
|
+
})();
|
|
776
|
+
});
|
|
766
777
|
}
|
|
767
778
|
throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
|
|
768
779
|
};
|
|
769
780
|
|
|
770
781
|
// libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
|
|
771
782
|
var getDashboardContext = (dashboardComponent, iframe) => {
|
|
772
|
-
if (iframe?.contentWindow) {
|
|
773
|
-
|
|
774
|
-
iframe.contentWindow.postMessage(
|
|
775
|
-
{ action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
|
|
776
|
-
"*"
|
|
777
|
-
);
|
|
778
|
-
return new Promise((resolve, reject) => {
|
|
779
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
780
|
-
setTimeout(() => {
|
|
781
|
-
if (dashboardComponent.promises[requestId]) {
|
|
782
|
-
const errorMessage = "getDashboardContext request timed out.";
|
|
783
|
-
dashboardComponent.promises[requestId].reject(
|
|
784
|
-
new Error(errorMessage)
|
|
785
|
-
);
|
|
786
|
-
delete dashboardComponent.promises[requestId];
|
|
787
|
-
}
|
|
788
|
-
}, 2e3);
|
|
789
|
-
});
|
|
783
|
+
if (!iframe?.contentWindow) {
|
|
784
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
790
785
|
}
|
|
791
|
-
|
|
786
|
+
const { promises } = dashboardComponent;
|
|
787
|
+
if (!promises) {
|
|
788
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
789
|
+
}
|
|
790
|
+
const requestId = uuidv4();
|
|
791
|
+
iframe.contentWindow.postMessage(
|
|
792
|
+
{ action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
|
|
793
|
+
"*"
|
|
794
|
+
);
|
|
795
|
+
return new Promise((resolve, reject) => {
|
|
796
|
+
promises[requestId] = { resolve, reject };
|
|
797
|
+
setTimeout(() => {
|
|
798
|
+
if (promises[requestId]) {
|
|
799
|
+
const errorMessage = "getDashboardContext request timed out.";
|
|
800
|
+
promises[requestId].reject(new Error(errorMessage));
|
|
801
|
+
delete promises[requestId];
|
|
802
|
+
}
|
|
803
|
+
}, 2e3);
|
|
804
|
+
});
|
|
792
805
|
};
|
|
793
806
|
|
|
794
807
|
// libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
|
|
795
808
|
var getData = (dashboardComponent, iframe, itemId) => {
|
|
796
|
-
if (iframe?.contentWindow) {
|
|
797
|
-
|
|
798
|
-
iframe.contentWindow.postMessage(
|
|
799
|
-
{
|
|
800
|
-
action: "getData",
|
|
801
|
-
id: itemId,
|
|
802
|
-
_version: dashboardComponent.libVersion,
|
|
803
|
-
requestId
|
|
804
|
-
},
|
|
805
|
-
"*"
|
|
806
|
-
);
|
|
807
|
-
return new Promise((resolve, reject) => {
|
|
808
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
809
|
-
setTimeout(() => {
|
|
810
|
-
if (dashboardComponent.promises[requestId]) {
|
|
811
|
-
const errorMessage = "getData request timed out.";
|
|
812
|
-
dashboardComponent.promises[requestId].reject(
|
|
813
|
-
new Error(errorMessage)
|
|
814
|
-
);
|
|
815
|
-
delete dashboardComponent.promises[requestId];
|
|
816
|
-
}
|
|
817
|
-
}, 2e3);
|
|
818
|
-
});
|
|
809
|
+
if (!iframe?.contentWindow) {
|
|
810
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
819
811
|
}
|
|
820
|
-
|
|
812
|
+
const { promises } = dashboardComponent;
|
|
813
|
+
if (!promises) {
|
|
814
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
815
|
+
}
|
|
816
|
+
const requestId = uuidv4();
|
|
817
|
+
iframe.contentWindow.postMessage(
|
|
818
|
+
{
|
|
819
|
+
action: "getData",
|
|
820
|
+
id: itemId,
|
|
821
|
+
_version: dashboardComponent.libVersion,
|
|
822
|
+
requestId
|
|
823
|
+
},
|
|
824
|
+
"*"
|
|
825
|
+
);
|
|
826
|
+
return new Promise((resolve, reject) => {
|
|
827
|
+
promises[requestId] = { resolve, reject };
|
|
828
|
+
setTimeout(() => {
|
|
829
|
+
if (promises[requestId]) {
|
|
830
|
+
const errorMessage = "getData request timed out.";
|
|
831
|
+
promises[requestId].reject(new Error(errorMessage));
|
|
832
|
+
delete promises[requestId];
|
|
833
|
+
}
|
|
834
|
+
}, 2e3);
|
|
835
|
+
});
|
|
821
836
|
};
|
|
822
837
|
|
|
823
838
|
// libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
|
|
824
839
|
var getFilters = (dashboardComponent, iframe) => {
|
|
825
|
-
if (iframe?.contentWindow) {
|
|
826
|
-
|
|
827
|
-
iframe.contentWindow.postMessage(
|
|
828
|
-
{ action: "getFilters", _version: dashboardComponent.libVersion, requestId },
|
|
829
|
-
"*"
|
|
830
|
-
);
|
|
831
|
-
return new Promise((resolve, reject) => {
|
|
832
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
833
|
-
setTimeout(() => {
|
|
834
|
-
if (dashboardComponent.promises[requestId]) {
|
|
835
|
-
const errorMessage = "getFilters request timed out.";
|
|
836
|
-
dashboardComponent.promises[requestId].reject(
|
|
837
|
-
new Error(errorMessage)
|
|
838
|
-
);
|
|
839
|
-
delete dashboardComponent.promises[requestId];
|
|
840
|
-
}
|
|
841
|
-
}, 2e3);
|
|
842
|
-
});
|
|
840
|
+
if (!iframe?.contentWindow) {
|
|
841
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
843
842
|
}
|
|
844
|
-
|
|
843
|
+
const { promises } = dashboardComponent;
|
|
844
|
+
if (!promises) {
|
|
845
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
846
|
+
}
|
|
847
|
+
const requestId = uuidv4();
|
|
848
|
+
iframe.contentWindow.postMessage(
|
|
849
|
+
{ action: "getFilters", _version: dashboardComponent.libVersion, requestId },
|
|
850
|
+
"*"
|
|
851
|
+
);
|
|
852
|
+
return new Promise((resolve, reject) => {
|
|
853
|
+
promises[requestId] = { resolve, reject };
|
|
854
|
+
setTimeout(() => {
|
|
855
|
+
if (promises[requestId]) {
|
|
856
|
+
const errorMessage = "getFilters request timed out.";
|
|
857
|
+
promises[requestId].reject(new Error(errorMessage));
|
|
858
|
+
delete promises[requestId];
|
|
859
|
+
}
|
|
860
|
+
}, 2e3);
|
|
861
|
+
});
|
|
845
862
|
};
|
|
846
863
|
|
|
847
864
|
// libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
|
|
@@ -849,6 +866,10 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
|
|
|
849
866
|
if (!iframe?.contentWindow) {
|
|
850
867
|
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
851
868
|
}
|
|
869
|
+
const { promises } = dashboardComponent;
|
|
870
|
+
if (!promises) {
|
|
871
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
872
|
+
}
|
|
852
873
|
const requestId = uuidv4();
|
|
853
874
|
iframe.contentWindow.postMessage(
|
|
854
875
|
{
|
|
@@ -860,11 +881,11 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
|
|
|
860
881
|
"*"
|
|
861
882
|
);
|
|
862
883
|
return new Promise((resolve, reject) => {
|
|
863
|
-
|
|
884
|
+
promises[requestId] = { resolve, reject };
|
|
864
885
|
setTimeout(() => {
|
|
865
|
-
if (
|
|
866
|
-
|
|
867
|
-
delete
|
|
886
|
+
if (promises[requestId]) {
|
|
887
|
+
promises[requestId].reject(new Error("getInsights request timed out."));
|
|
888
|
+
delete promises[requestId];
|
|
868
889
|
}
|
|
869
890
|
}, 6e4);
|
|
870
891
|
});
|
|
@@ -872,7 +893,7 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
|
|
|
872
893
|
|
|
873
894
|
// libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
|
|
874
895
|
var refreshData = (dashboardComponent, iframe, itemId) => {
|
|
875
|
-
if (iframe) {
|
|
896
|
+
if (iframe?.contentWindow) {
|
|
876
897
|
iframe.contentWindow.postMessage(
|
|
877
898
|
{
|
|
878
899
|
action: "refreshData",
|
|
@@ -888,7 +909,7 @@ var refreshData = (dashboardComponent, iframe, itemId) => {
|
|
|
888
909
|
|
|
889
910
|
// libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
|
|
890
911
|
var reloadDashboard = (dashboardComponent, iframe) => {
|
|
891
|
-
if (iframe) {
|
|
912
|
+
if (iframe?.contentWindow) {
|
|
892
913
|
iframe.contentWindow.postMessage(
|
|
893
914
|
{ action: "reloadDashboard", _version: dashboardComponent.libVersion },
|
|
894
915
|
"*"
|
|
@@ -900,7 +921,7 @@ var reloadDashboard = (dashboardComponent, iframe) => {
|
|
|
900
921
|
|
|
901
922
|
// libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
|
|
902
923
|
var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
|
|
903
|
-
if (iframe) {
|
|
924
|
+
if (iframe?.contentWindow) {
|
|
904
925
|
iframe.contentWindow.postMessage(
|
|
905
926
|
{
|
|
906
927
|
action: "sendExportEmail",
|
|
@@ -918,7 +939,7 @@ var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
|
|
|
918
939
|
|
|
919
940
|
// libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
|
|
920
941
|
var setAuthorization = (dashboardComponent, iframe, key, token) => {
|
|
921
|
-
if (iframe) {
|
|
942
|
+
if (iframe?.contentWindow) {
|
|
922
943
|
iframe.contentWindow.postMessage(
|
|
923
944
|
{
|
|
924
945
|
action: "setAuthorization",
|
|
@@ -935,92 +956,100 @@ var setAuthorization = (dashboardComponent, iframe, key, token) => {
|
|
|
935
956
|
|
|
936
957
|
// libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
|
|
937
958
|
var setEditMode = (dashboardComponent, iframe, editMode) => {
|
|
938
|
-
if (iframe
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
_version: dashboardComponent.libVersion,
|
|
956
|
-
requestId
|
|
957
|
-
},
|
|
958
|
-
"*"
|
|
959
|
+
if (!iframe?.contentWindow) {
|
|
960
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
961
|
+
}
|
|
962
|
+
const { params, promises } = dashboardComponent;
|
|
963
|
+
if (!params || !promises) {
|
|
964
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
965
|
+
}
|
|
966
|
+
const requestId = uuidv4();
|
|
967
|
+
if (params.editMode === editMode) {
|
|
968
|
+
return Promise.reject(
|
|
969
|
+
new Error("editMode parameter is currently already set to " + editMode)
|
|
970
|
+
);
|
|
971
|
+
} else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
|
|
972
|
+
return Promise.reject(
|
|
973
|
+
new Error(
|
|
974
|
+
"The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
|
|
975
|
+
)
|
|
959
976
|
);
|
|
960
|
-
return new Promise((resolve, reject) => {
|
|
961
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
962
|
-
});
|
|
963
977
|
}
|
|
964
|
-
|
|
978
|
+
iframe.contentWindow.postMessage(
|
|
979
|
+
{
|
|
980
|
+
action: "setEditMode",
|
|
981
|
+
editMode,
|
|
982
|
+
_version: dashboardComponent.libVersion,
|
|
983
|
+
requestId
|
|
984
|
+
},
|
|
985
|
+
"*"
|
|
986
|
+
);
|
|
987
|
+
return new Promise((resolve, reject) => {
|
|
988
|
+
promises[requestId] = { resolve, reject };
|
|
989
|
+
});
|
|
965
990
|
};
|
|
966
991
|
|
|
967
992
|
// libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
|
|
968
993
|
var setPreview = (dashboardComponent, iframe, preview) => {
|
|
969
|
-
if (iframe) {
|
|
970
|
-
|
|
971
|
-
iframe.contentWindow.postMessage(
|
|
972
|
-
{
|
|
973
|
-
action: "setPreview",
|
|
974
|
-
preview,
|
|
975
|
-
requestId,
|
|
976
|
-
_version: dashboardComponent.libVersion
|
|
977
|
-
},
|
|
978
|
-
"*"
|
|
979
|
-
);
|
|
980
|
-
return new Promise((resolve, reject) => {
|
|
981
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
982
|
-
setTimeout(() => {
|
|
983
|
-
if (dashboardComponent.promises[requestId]) {
|
|
984
|
-
const errorMessage = "setPreview request timed out.";
|
|
985
|
-
dashboardComponent.promises[requestId].reject(
|
|
986
|
-
new Error(errorMessage)
|
|
987
|
-
);
|
|
988
|
-
delete dashboardComponent.promises[requestId];
|
|
989
|
-
}
|
|
990
|
-
}, 2e3);
|
|
991
|
-
});
|
|
994
|
+
if (!iframe?.contentWindow) {
|
|
995
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
992
996
|
}
|
|
993
|
-
|
|
997
|
+
const { promises } = dashboardComponent;
|
|
998
|
+
if (!promises) {
|
|
999
|
+
return Promise.reject(new Error("Cannot retrieve contentWindow."));
|
|
1000
|
+
}
|
|
1001
|
+
const requestId = uuidv4();
|
|
1002
|
+
iframe.contentWindow.postMessage(
|
|
1003
|
+
{
|
|
1004
|
+
action: "setPreview",
|
|
1005
|
+
preview,
|
|
1006
|
+
requestId,
|
|
1007
|
+
_version: dashboardComponent.libVersion
|
|
1008
|
+
},
|
|
1009
|
+
"*"
|
|
1010
|
+
);
|
|
1011
|
+
return new Promise((resolve, reject) => {
|
|
1012
|
+
promises[requestId] = { resolve, reject };
|
|
1013
|
+
setTimeout(() => {
|
|
1014
|
+
if (promises[requestId]) {
|
|
1015
|
+
const errorMessage = "setPreview request timed out.";
|
|
1016
|
+
promises[requestId].reject(new Error(errorMessage));
|
|
1017
|
+
delete promises[requestId];
|
|
1018
|
+
}
|
|
1019
|
+
}, 2e3);
|
|
1020
|
+
});
|
|
994
1021
|
};
|
|
995
1022
|
|
|
996
1023
|
// libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
|
|
997
1024
|
var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
|
|
998
|
-
if (iframe) {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
filters,
|
|
1005
|
-
_version: dashboardComponent.libVersion,
|
|
1006
|
-
requestId
|
|
1007
|
-
},
|
|
1008
|
-
"*"
|
|
1009
|
-
);
|
|
1010
|
-
return new Promise((resolve, reject) => {
|
|
1011
|
-
dashboardComponent.promises[requestId] = { resolve, reject };
|
|
1012
|
-
setTimeout(() => {
|
|
1013
|
-
if (dashboardComponent.promises[requestId]) {
|
|
1014
|
-
const errorMessage = "setSelectedData request timed out.";
|
|
1015
|
-
dashboardComponent.promises[requestId].reject(
|
|
1016
|
-
new Error(errorMessage)
|
|
1017
|
-
);
|
|
1018
|
-
delete dashboardComponent.promises[requestId];
|
|
1019
|
-
}
|
|
1020
|
-
}, 2e3);
|
|
1021
|
-
});
|
|
1025
|
+
if (!iframe?.contentWindow) {
|
|
1026
|
+
return Promise.reject();
|
|
1027
|
+
}
|
|
1028
|
+
const { promises } = dashboardComponent;
|
|
1029
|
+
if (!promises) {
|
|
1030
|
+
return Promise.reject();
|
|
1022
1031
|
}
|
|
1023
|
-
|
|
1032
|
+
const requestId = uuidv4();
|
|
1033
|
+
iframe.contentWindow.postMessage(
|
|
1034
|
+
{
|
|
1035
|
+
action: "setSelectedData",
|
|
1036
|
+
itemId,
|
|
1037
|
+
filters,
|
|
1038
|
+
_version: dashboardComponent.libVersion,
|
|
1039
|
+
requestId
|
|
1040
|
+
},
|
|
1041
|
+
"*"
|
|
1042
|
+
);
|
|
1043
|
+
return new Promise((resolve, reject) => {
|
|
1044
|
+
promises[requestId] = { resolve, reject };
|
|
1045
|
+
setTimeout(() => {
|
|
1046
|
+
if (promises[requestId]) {
|
|
1047
|
+
const errorMessage = "setSelectedData request timed out.";
|
|
1048
|
+
promises[requestId].reject(new Error(errorMessage));
|
|
1049
|
+
delete promises[requestId];
|
|
1050
|
+
}
|
|
1051
|
+
}, 2e3);
|
|
1052
|
+
});
|
|
1024
1053
|
};
|
|
1025
1054
|
|
|
1026
1055
|
// libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
|
|
@@ -1066,6 +1095,9 @@ var _setCalculatedDimensions = (dashboardComponent) => {
|
|
|
1066
1095
|
for (const key of dashboardDimensionKeys) {
|
|
1067
1096
|
if (screenModes.includes(key)) {
|
|
1068
1097
|
const screenMode = EXTENTS.find((extent) => extent.mode === key);
|
|
1098
|
+
if (!screenMode) {
|
|
1099
|
+
continue;
|
|
1100
|
+
}
|
|
1069
1101
|
availableScreenModeExtents.push({
|
|
1070
1102
|
...screenMode,
|
|
1071
1103
|
height: dashboardComponent.dimensions[key][1] || 50
|
|
@@ -1120,24 +1152,27 @@ var _setCalculatedDimensions = (dashboardComponent) => {
|
|
|
1120
1152
|
),
|
|
1121
1153
|
screenModeExtentMinWidth
|
|
1122
1154
|
);
|
|
1123
|
-
currentHeight = screenModeExtent.height;
|
|
1155
|
+
currentHeight = screenModeExtent.height ?? 0;
|
|
1124
1156
|
}
|
|
1125
1157
|
}
|
|
1126
1158
|
}
|
|
1127
1159
|
}
|
|
1128
1160
|
} else {
|
|
1129
|
-
const
|
|
1130
|
-
height: chosenModeHeight,
|
|
1131
|
-
width: [chosenModeMinWidth, chosenModeMaxWidth]
|
|
1132
|
-
} = availableScreenModeExtents.find(
|
|
1161
|
+
const chosenModeExtent = availableScreenModeExtents.find(
|
|
1133
1162
|
(d) => d.mode === dashboardComponent.params.screenMode
|
|
1134
1163
|
);
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1164
|
+
if (chosenModeExtent) {
|
|
1165
|
+
const {
|
|
1166
|
+
height: chosenModeHeight,
|
|
1167
|
+
width: [chosenModeMinWidth, chosenModeMaxWidth]
|
|
1168
|
+
} = chosenModeExtent;
|
|
1169
|
+
currentMode = dashboardComponent.params.screenMode;
|
|
1170
|
+
currentWidth = Math.max(
|
|
1171
|
+
Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
|
|
1172
|
+
chosenModeMinWidth
|
|
1173
|
+
);
|
|
1174
|
+
currentHeight = chosenModeHeight ?? 0;
|
|
1175
|
+
}
|
|
1141
1176
|
if (dashboardComponent.params.itemEmbedding) {
|
|
1142
1177
|
if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
|
|
1143
1178
|
currentWidth = Number.parseInt(
|
|
@@ -1157,7 +1192,7 @@ var _setCalculatedDimensions = (dashboardComponent) => {
|
|
|
1157
1192
|
const [lowestModeExtent] = availableScreenModeExtents;
|
|
1158
1193
|
currentMode = lowestModeExtent.mode;
|
|
1159
1194
|
currentWidth = lowestModeExtent.width[0];
|
|
1160
|
-
currentHeight = lowestModeExtent.height;
|
|
1195
|
+
currentHeight = lowestModeExtent.height ?? 0;
|
|
1161
1196
|
}
|
|
1162
1197
|
}
|
|
1163
1198
|
dashboardComponent.currentScreenMode = currentMode;
|
|
@@ -1219,6 +1254,9 @@ var _extendAndValidate = (dashboardContent) => {
|
|
|
1219
1254
|
"fixed",
|
|
1220
1255
|
"auto"
|
|
1221
1256
|
];
|
|
1257
|
+
if (!dashboardContent.params) {
|
|
1258
|
+
dashboardContent.params = {};
|
|
1259
|
+
}
|
|
1222
1260
|
for (const key of defaultKeys) {
|
|
1223
1261
|
if (dashboardContent.params[key] === null) {
|
|
1224
1262
|
delete dashboardContent.params[key];
|
|
@@ -1286,17 +1324,20 @@ var _extendAndValidate = (dashboardContent) => {
|
|
|
1286
1324
|
if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
|
|
1287
1325
|
dashboardContent.params.switchScreenModeOnResize = false;
|
|
1288
1326
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1327
|
+
const itemDimensions = dashboardContent.params.itemDimensions;
|
|
1328
|
+
if (itemDimensions) {
|
|
1329
|
+
if (itemDimensions.width !== "auto") {
|
|
1330
|
+
itemDimensions.width = Number.parseInt(
|
|
1331
|
+
`${itemDimensions.width}`.replace("px", ""),
|
|
1332
|
+
10
|
|
1333
|
+
) || "auto";
|
|
1334
|
+
}
|
|
1335
|
+
if (itemDimensions.height !== "auto") {
|
|
1336
|
+
itemDimensions.height = Number.parseInt(
|
|
1337
|
+
`${itemDimensions.height}`.replace("px", ""),
|
|
1338
|
+
10
|
|
1339
|
+
) || "auto";
|
|
1340
|
+
}
|
|
1300
1341
|
}
|
|
1301
1342
|
dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
|
|
1302
1343
|
if (dashboardContent.params.error || errorMessages.length > 0) {
|
|
@@ -1308,6 +1349,7 @@ var _extendAndValidate = (dashboardContent) => {
|
|
|
1308
1349
|
var libraryTypeToWebComponentTypeMapping = {
|
|
1309
1350
|
type: "type",
|
|
1310
1351
|
slots: "slots",
|
|
1352
|
+
inlineData: "inline-data",
|
|
1311
1353
|
options: "options",
|
|
1312
1354
|
appServer: "app-server",
|
|
1313
1355
|
apiHost: "api-host",
|
|
@@ -1322,7 +1364,23 @@ var libraryTypeToWebComponentTypeMapping = {
|
|
|
1322
1364
|
dashboardContentsVersion: "dashboard-contents-version",
|
|
1323
1365
|
libVersion: "lib-version"
|
|
1324
1366
|
};
|
|
1325
|
-
var libraryAcceptedParametersList = [
|
|
1367
|
+
var libraryAcceptedParametersList = [
|
|
1368
|
+
"appServer",
|
|
1369
|
+
"apiHost",
|
|
1370
|
+
"options",
|
|
1371
|
+
"type",
|
|
1372
|
+
"authKey",
|
|
1373
|
+
"authToken",
|
|
1374
|
+
"slots",
|
|
1375
|
+
"inlineData",
|
|
1376
|
+
"filters",
|
|
1377
|
+
"canFilter",
|
|
1378
|
+
"contextId",
|
|
1379
|
+
"itemId",
|
|
1380
|
+
"dashboardId",
|
|
1381
|
+
"aiMessageAssetId",
|
|
1382
|
+
"libVersion"
|
|
1383
|
+
];
|
|
1326
1384
|
|
|
1327
1385
|
// libs/embed-libs/embed/src/lib/shared/constants/class-constants.ts
|
|
1328
1386
|
var luzmoEmbedContainerClass = "luzmo-embed-container";
|