@luzmo/embed 5.1.3-beta.0 → 5.1.3-beta.10
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.cjs +80 -11
- package/index.js +82 -13
- package/index.libs.cjs +80 -11
- package/index.libs.js +82 -13
- package/lib/dashboard-component/dashboard-base.d.ts +1 -1
- package/lib/viz-item/viz-item.base.d.ts +23 -6
- package/luzmo-embed.libs.js +4291 -24
- package/luzmo-embed.min.js +4291 -24
- package/package.json +3 -2
- package/src/lib/dashboard-component/dashboard-base.d.ts +1 -1
- package/src/lib/viz-item/viz-item.base.d.ts +23 -6
package/index.cjs
CHANGED
|
@@ -56,7 +56,7 @@ var import_style_map = require("lit/directives/style-map.js");
|
|
|
56
56
|
var import_shared_embed = require("@luzmo/shared-embed");
|
|
57
57
|
|
|
58
58
|
// libs/embed-libs/embed/package.json
|
|
59
|
-
var version = "5.1.3-beta.
|
|
59
|
+
var version = "5.1.3-beta.10";
|
|
60
60
|
|
|
61
61
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
62
62
|
var LuzmoService = class {
|
|
@@ -357,7 +357,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
357
357
|
this.browserErrorMsg = "";
|
|
358
358
|
this.dashboardError = false;
|
|
359
359
|
this.browserNotSupported = [];
|
|
360
|
-
this.
|
|
360
|
+
this.libVersion = version + "-wc-luzmo";
|
|
361
361
|
this.isLibraryLoaded = false;
|
|
362
362
|
this.currentAuthKey = null;
|
|
363
363
|
this.currentAuthToken = null;
|
|
@@ -1031,7 +1031,7 @@ __decorateClass([
|
|
|
1031
1031
|
], LuzmoDashboard.prototype, "browserNotSupported", 2);
|
|
1032
1032
|
__decorateClass([
|
|
1033
1033
|
(0, import_decorators.property)()
|
|
1034
|
-
], LuzmoDashboard.prototype, "
|
|
1034
|
+
], LuzmoDashboard.prototype, "libVersion", 2);
|
|
1035
1035
|
__decorateClass([
|
|
1036
1036
|
(0, import_decorators.state)()
|
|
1037
1037
|
], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
|
|
@@ -1067,19 +1067,16 @@ var import_decorators4 = require("lit/decorators.js");
|
|
|
1067
1067
|
var import_decorators3 = require("lit/decorators.js");
|
|
1068
1068
|
var import_lit3 = require("lit");
|
|
1069
1069
|
var SharedLib3 = __toESM(require("@luzmo/shared-embed"), 1);
|
|
1070
|
+
var import_zod_validation_error = require("zod-validation-error");
|
|
1070
1071
|
var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
1071
1072
|
constructor() {
|
|
1072
1073
|
super();
|
|
1073
1074
|
this.appServer = "https://app.luzmo.com";
|
|
1074
1075
|
this.apiHost = "https://api.luzmo.com";
|
|
1075
1076
|
this.slots = [];
|
|
1076
|
-
this.options = {
|
|
1077
|
-
title: {
|
|
1078
|
-
en: ""
|
|
1079
|
-
},
|
|
1080
|
-
theme: "default"
|
|
1081
|
-
};
|
|
1082
1077
|
this.version = version + "-wc-luzmo";
|
|
1078
|
+
this.libVersion = version + "-wc-luzmo";
|
|
1079
|
+
this.postInitCallQueue = [];
|
|
1083
1080
|
}
|
|
1084
1081
|
static {
|
|
1085
1082
|
// Static styles to set host display to block, else it is not shown at all for some reason.
|
|
@@ -1091,9 +1088,37 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1091
1088
|
}
|
|
1092
1089
|
`;
|
|
1093
1090
|
}
|
|
1091
|
+
canInitializeVizItem() {
|
|
1092
|
+
return !!(this.type || this.dashboardId && this.itemId);
|
|
1093
|
+
}
|
|
1094
|
+
getFilters() {
|
|
1095
|
+
return this.chartElement.getFilters();
|
|
1096
|
+
}
|
|
1097
|
+
export() {
|
|
1098
|
+
return this.chartElement.export();
|
|
1099
|
+
}
|
|
1100
|
+
getData() {
|
|
1101
|
+
return this.chartElement.getData();
|
|
1102
|
+
}
|
|
1103
|
+
refreshData() {
|
|
1104
|
+
return this.chartElement.refreshData();
|
|
1105
|
+
}
|
|
1106
|
+
setFilters(filterInput) {
|
|
1107
|
+
return this.chartElement.setFilters(void 0, filterInput);
|
|
1108
|
+
}
|
|
1109
|
+
attributeChangedCallback(name, _old, value) {
|
|
1110
|
+
super.attributeChangedCallback(name, _old, value);
|
|
1111
|
+
if (name === "selecteddata") {
|
|
1112
|
+
if (this.chartElement) {
|
|
1113
|
+
this.setFilters(JSON.parse(value ?? "{}"));
|
|
1114
|
+
} else {
|
|
1115
|
+
this.postInitCallQueue.push([this.setFilters, [JSON.parse(value ?? "{}")]]);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1094
1119
|
async firstUpdated(_changedProperties) {
|
|
1095
1120
|
super.firstUpdated(_changedProperties);
|
|
1096
|
-
if (this.
|
|
1121
|
+
if (this.canInitializeVizItem()) {
|
|
1097
1122
|
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1098
1123
|
this.createAndAppendElement();
|
|
1099
1124
|
}
|
|
@@ -1102,6 +1127,16 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1102
1127
|
if (!this.chartElement) {
|
|
1103
1128
|
this.chartElement = document.createElement("chart-component");
|
|
1104
1129
|
this.chartElement.setAttribute("embedding-mode", "chart");
|
|
1130
|
+
this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
|
|
1131
|
+
this.chartElement.addEventListener("rendered", (payload) => {
|
|
1132
|
+
for (const functionToCall of this.postInitCallQueue) {
|
|
1133
|
+
functionToCall[0].bind(this)(...functionToCall[1]);
|
|
1134
|
+
}
|
|
1135
|
+
this.dispatchEvent(new CustomEvent("rendered", payload));
|
|
1136
|
+
});
|
|
1137
|
+
this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
|
|
1138
|
+
this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
|
|
1139
|
+
this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
|
|
1105
1140
|
this.updateVizItemProperties();
|
|
1106
1141
|
this.renderRoot.append(this.chartElement);
|
|
1107
1142
|
}
|
|
@@ -1111,6 +1146,7 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1111
1146
|
for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
|
|
1112
1147
|
const value = this[key];
|
|
1113
1148
|
if (value) {
|
|
1149
|
+
this.parseAndValidate(key);
|
|
1114
1150
|
const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
|
|
1115
1151
|
this.chartElement.setAttribute(
|
|
1116
1152
|
SharedLib3.libraryTypeToWebComponentTypeMapping[key],
|
|
@@ -1124,16 +1160,37 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1124
1160
|
if (this.chartElement) {
|
|
1125
1161
|
for (const [propertyName] of changedProperties.entries()) {
|
|
1126
1162
|
const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
|
|
1163
|
+
this.parseAndValidate(propertyName);
|
|
1127
1164
|
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
|
|
1128
1165
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1129
1166
|
}
|
|
1130
1167
|
} else {
|
|
1131
|
-
if (this.
|
|
1168
|
+
if (this.canInitializeVizItem()) {
|
|
1169
|
+
if (this.type) {
|
|
1170
|
+
this.parseAndValidate("type");
|
|
1171
|
+
}
|
|
1132
1172
|
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1133
1173
|
this.createAndAppendElement();
|
|
1134
1174
|
}
|
|
1135
1175
|
}
|
|
1136
1176
|
}
|
|
1177
|
+
parseAndValidate(key) {
|
|
1178
|
+
try {
|
|
1179
|
+
if (key === "slots") {
|
|
1180
|
+
SharedLib3.slotsParser.parse(this.slots);
|
|
1181
|
+
} else if (key === "options") {
|
|
1182
|
+
SharedLib3.vizItemOptionsParser.parse(this.options);
|
|
1183
|
+
} else if (key === "canFilter") {
|
|
1184
|
+
SharedLib3.canFilterParser.parse(this.canFilter);
|
|
1185
|
+
} else if (key === "type") {
|
|
1186
|
+
SharedLib3.itemTypeParser.parse(this.type);
|
|
1187
|
+
}
|
|
1188
|
+
} catch (err) {
|
|
1189
|
+
const validationError = (0, import_zod_validation_error.fromError)(err);
|
|
1190
|
+
console.warn(err);
|
|
1191
|
+
console.warn(validationError.toString());
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1137
1194
|
render() {
|
|
1138
1195
|
return import_lit3.html` `;
|
|
1139
1196
|
}
|
|
@@ -1179,6 +1236,18 @@ __decorateClass([
|
|
|
1179
1236
|
__decorateClass([
|
|
1180
1237
|
(0, import_decorators3.property)({ type: Array })
|
|
1181
1238
|
], LuzmoBaseVizItem.prototype, "filters", 2);
|
|
1239
|
+
__decorateClass([
|
|
1240
|
+
(0, import_decorators3.property)()
|
|
1241
|
+
], LuzmoBaseVizItem.prototype, "dashboardId", 2);
|
|
1242
|
+
__decorateClass([
|
|
1243
|
+
(0, import_decorators3.property)()
|
|
1244
|
+
], LuzmoBaseVizItem.prototype, "itemId", 2);
|
|
1245
|
+
__decorateClass([
|
|
1246
|
+
(0, import_decorators3.property)({ type: Object })
|
|
1247
|
+
], LuzmoBaseVizItem.prototype, "selectedData", 2);
|
|
1248
|
+
__decorateClass([
|
|
1249
|
+
(0, import_decorators3.property)()
|
|
1250
|
+
], LuzmoBaseVizItem.prototype, "libVersion", 2);
|
|
1182
1251
|
|
|
1183
1252
|
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1184
1253
|
var LuzmoVizItem = class extends LuzmoBaseVizItem {
|
package/index.js
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from "@luzmo/shared-embed";
|
|
35
35
|
|
|
36
36
|
// libs/embed-libs/embed/package.json
|
|
37
|
-
var version = "5.1.3-beta.
|
|
37
|
+
var version = "5.1.3-beta.10";
|
|
38
38
|
|
|
39
39
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
40
40
|
var LuzmoService = class {
|
|
@@ -335,7 +335,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
335
335
|
this.browserErrorMsg = "";
|
|
336
336
|
this.dashboardError = false;
|
|
337
337
|
this.browserNotSupported = [];
|
|
338
|
-
this.
|
|
338
|
+
this.libVersion = version + "-wc-luzmo";
|
|
339
339
|
this.isLibraryLoaded = false;
|
|
340
340
|
this.currentAuthKey = null;
|
|
341
341
|
this.currentAuthToken = null;
|
|
@@ -1009,7 +1009,7 @@ __decorateClass([
|
|
|
1009
1009
|
], LuzmoDashboard.prototype, "browserNotSupported", 2);
|
|
1010
1010
|
__decorateClass([
|
|
1011
1011
|
property()
|
|
1012
|
-
], LuzmoDashboard.prototype, "
|
|
1012
|
+
], LuzmoDashboard.prototype, "libVersion", 2);
|
|
1013
1013
|
__decorateClass([
|
|
1014
1014
|
state()
|
|
1015
1015
|
], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
|
|
@@ -1039,25 +1039,22 @@ LuzmoEmbedDashboard = __decorateClass([
|
|
|
1039
1039
|
], LuzmoEmbedDashboard);
|
|
1040
1040
|
|
|
1041
1041
|
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1042
|
-
import { customElement as
|
|
1042
|
+
import { customElement as customElement2 } from "lit/decorators.js";
|
|
1043
1043
|
|
|
1044
1044
|
// libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
|
|
1045
1045
|
import { property as property2 } from "lit/decorators.js";
|
|
1046
1046
|
import { LitElement as LitElement2, html as html2, css as css2 } from "lit";
|
|
1047
1047
|
import * as SharedLib3 from "@luzmo/shared-embed";
|
|
1048
|
+
import { fromError } from "zod-validation-error";
|
|
1048
1049
|
var LuzmoBaseVizItem = class extends LitElement2 {
|
|
1049
1050
|
constructor() {
|
|
1050
1051
|
super();
|
|
1051
1052
|
this.appServer = "https://app.luzmo.com";
|
|
1052
1053
|
this.apiHost = "https://api.luzmo.com";
|
|
1053
1054
|
this.slots = [];
|
|
1054
|
-
this.options = {
|
|
1055
|
-
title: {
|
|
1056
|
-
en: ""
|
|
1057
|
-
},
|
|
1058
|
-
theme: "default"
|
|
1059
|
-
};
|
|
1060
1055
|
this.version = version + "-wc-luzmo";
|
|
1056
|
+
this.libVersion = version + "-wc-luzmo";
|
|
1057
|
+
this.postInitCallQueue = [];
|
|
1061
1058
|
}
|
|
1062
1059
|
static {
|
|
1063
1060
|
// Static styles to set host display to block, else it is not shown at all for some reason.
|
|
@@ -1069,9 +1066,37 @@ var LuzmoBaseVizItem = class extends LitElement2 {
|
|
|
1069
1066
|
}
|
|
1070
1067
|
`;
|
|
1071
1068
|
}
|
|
1069
|
+
canInitializeVizItem() {
|
|
1070
|
+
return !!(this.type || this.dashboardId && this.itemId);
|
|
1071
|
+
}
|
|
1072
|
+
getFilters() {
|
|
1073
|
+
return this.chartElement.getFilters();
|
|
1074
|
+
}
|
|
1075
|
+
export() {
|
|
1076
|
+
return this.chartElement.export();
|
|
1077
|
+
}
|
|
1078
|
+
getData() {
|
|
1079
|
+
return this.chartElement.getData();
|
|
1080
|
+
}
|
|
1081
|
+
refreshData() {
|
|
1082
|
+
return this.chartElement.refreshData();
|
|
1083
|
+
}
|
|
1084
|
+
setFilters(filterInput) {
|
|
1085
|
+
return this.chartElement.setFilters(void 0, filterInput);
|
|
1086
|
+
}
|
|
1087
|
+
attributeChangedCallback(name, _old, value) {
|
|
1088
|
+
super.attributeChangedCallback(name, _old, value);
|
|
1089
|
+
if (name === "selecteddata") {
|
|
1090
|
+
if (this.chartElement) {
|
|
1091
|
+
this.setFilters(JSON.parse(value ?? "{}"));
|
|
1092
|
+
} else {
|
|
1093
|
+
this.postInitCallQueue.push([this.setFilters, [JSON.parse(value ?? "{}")]]);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1072
1097
|
async firstUpdated(_changedProperties) {
|
|
1073
1098
|
super.firstUpdated(_changedProperties);
|
|
1074
|
-
if (this.
|
|
1099
|
+
if (this.canInitializeVizItem()) {
|
|
1075
1100
|
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1076
1101
|
this.createAndAppendElement();
|
|
1077
1102
|
}
|
|
@@ -1080,6 +1105,16 @@ var LuzmoBaseVizItem = class extends LitElement2 {
|
|
|
1080
1105
|
if (!this.chartElement) {
|
|
1081
1106
|
this.chartElement = document.createElement("chart-component");
|
|
1082
1107
|
this.chartElement.setAttribute("embedding-mode", "chart");
|
|
1108
|
+
this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
|
|
1109
|
+
this.chartElement.addEventListener("rendered", (payload) => {
|
|
1110
|
+
for (const functionToCall of this.postInitCallQueue) {
|
|
1111
|
+
functionToCall[0].bind(this)(...functionToCall[1]);
|
|
1112
|
+
}
|
|
1113
|
+
this.dispatchEvent(new CustomEvent("rendered", payload));
|
|
1114
|
+
});
|
|
1115
|
+
this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
|
|
1116
|
+
this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
|
|
1117
|
+
this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
|
|
1083
1118
|
this.updateVizItemProperties();
|
|
1084
1119
|
this.renderRoot.append(this.chartElement);
|
|
1085
1120
|
}
|
|
@@ -1089,6 +1124,7 @@ var LuzmoBaseVizItem = class extends LitElement2 {
|
|
|
1089
1124
|
for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
|
|
1090
1125
|
const value = this[key];
|
|
1091
1126
|
if (value) {
|
|
1127
|
+
this.parseAndValidate(key);
|
|
1092
1128
|
const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
|
|
1093
1129
|
this.chartElement.setAttribute(
|
|
1094
1130
|
SharedLib3.libraryTypeToWebComponentTypeMapping[key],
|
|
@@ -1102,16 +1138,37 @@ var LuzmoBaseVizItem = class extends LitElement2 {
|
|
|
1102
1138
|
if (this.chartElement) {
|
|
1103
1139
|
for (const [propertyName] of changedProperties.entries()) {
|
|
1104
1140
|
const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
|
|
1141
|
+
this.parseAndValidate(propertyName);
|
|
1105
1142
|
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
|
|
1106
1143
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1107
1144
|
}
|
|
1108
1145
|
} else {
|
|
1109
|
-
if (this.
|
|
1146
|
+
if (this.canInitializeVizItem()) {
|
|
1147
|
+
if (this.type) {
|
|
1148
|
+
this.parseAndValidate("type");
|
|
1149
|
+
}
|
|
1110
1150
|
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1111
1151
|
this.createAndAppendElement();
|
|
1112
1152
|
}
|
|
1113
1153
|
}
|
|
1114
1154
|
}
|
|
1155
|
+
parseAndValidate(key) {
|
|
1156
|
+
try {
|
|
1157
|
+
if (key === "slots") {
|
|
1158
|
+
SharedLib3.slotsParser.parse(this.slots);
|
|
1159
|
+
} else if (key === "options") {
|
|
1160
|
+
SharedLib3.vizItemOptionsParser.parse(this.options);
|
|
1161
|
+
} else if (key === "canFilter") {
|
|
1162
|
+
SharedLib3.canFilterParser.parse(this.canFilter);
|
|
1163
|
+
} else if (key === "type") {
|
|
1164
|
+
SharedLib3.itemTypeParser.parse(this.type);
|
|
1165
|
+
}
|
|
1166
|
+
} catch (err) {
|
|
1167
|
+
const validationError = fromError(err);
|
|
1168
|
+
console.warn(err);
|
|
1169
|
+
console.warn(validationError.toString());
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1115
1172
|
render() {
|
|
1116
1173
|
return html2` `;
|
|
1117
1174
|
}
|
|
@@ -1157,12 +1214,24 @@ __decorateClass([
|
|
|
1157
1214
|
__decorateClass([
|
|
1158
1215
|
property2({ type: Array })
|
|
1159
1216
|
], LuzmoBaseVizItem.prototype, "filters", 2);
|
|
1217
|
+
__decorateClass([
|
|
1218
|
+
property2()
|
|
1219
|
+
], LuzmoBaseVizItem.prototype, "dashboardId", 2);
|
|
1220
|
+
__decorateClass([
|
|
1221
|
+
property2()
|
|
1222
|
+
], LuzmoBaseVizItem.prototype, "itemId", 2);
|
|
1223
|
+
__decorateClass([
|
|
1224
|
+
property2({ type: Object })
|
|
1225
|
+
], LuzmoBaseVizItem.prototype, "selectedData", 2);
|
|
1226
|
+
__decorateClass([
|
|
1227
|
+
property2()
|
|
1228
|
+
], LuzmoBaseVizItem.prototype, "libVersion", 2);
|
|
1160
1229
|
|
|
1161
1230
|
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1162
1231
|
var LuzmoVizItem = class extends LuzmoBaseVizItem {
|
|
1163
1232
|
};
|
|
1164
1233
|
LuzmoVizItem = __decorateClass([
|
|
1165
|
-
|
|
1234
|
+
customElement2("luzmo-viz-item")
|
|
1166
1235
|
], LuzmoVizItem);
|
|
1167
1236
|
export {
|
|
1168
1237
|
LuzmoDashboard2 as LuzmoDashboard,
|
package/index.libs.cjs
CHANGED
|
@@ -55,7 +55,7 @@ var import_style_map = require("lit/directives/style-map.js");
|
|
|
55
55
|
var import_shared_embed = require("@luzmo/shared-embed");
|
|
56
56
|
|
|
57
57
|
// libs/embed-libs/embed/package.json
|
|
58
|
-
var version = "5.1.3-beta.
|
|
58
|
+
var version = "5.1.3-beta.10";
|
|
59
59
|
|
|
60
60
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
61
61
|
var LuzmoService = class {
|
|
@@ -356,7 +356,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
356
356
|
this.browserErrorMsg = "";
|
|
357
357
|
this.dashboardError = false;
|
|
358
358
|
this.browserNotSupported = [];
|
|
359
|
-
this.
|
|
359
|
+
this.libVersion = version + "-wc-luzmo";
|
|
360
360
|
this.isLibraryLoaded = false;
|
|
361
361
|
this.currentAuthKey = null;
|
|
362
362
|
this.currentAuthToken = null;
|
|
@@ -1030,7 +1030,7 @@ __decorateClass([
|
|
|
1030
1030
|
], LuzmoDashboard.prototype, "browserNotSupported", 2);
|
|
1031
1031
|
__decorateClass([
|
|
1032
1032
|
(0, import_decorators.property)()
|
|
1033
|
-
], LuzmoDashboard.prototype, "
|
|
1033
|
+
], LuzmoDashboard.prototype, "libVersion", 2);
|
|
1034
1034
|
__decorateClass([
|
|
1035
1035
|
(0, import_decorators.state)()
|
|
1036
1036
|
], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
|
|
@@ -1061,19 +1061,16 @@ var import_decorators4 = require("lit/decorators.js");
|
|
|
1061
1061
|
var import_decorators3 = require("lit/decorators.js");
|
|
1062
1062
|
var import_lit3 = require("lit");
|
|
1063
1063
|
var SharedLib3 = __toESM(require("@luzmo/shared-embed"), 1);
|
|
1064
|
+
var import_zod_validation_error = require("zod-validation-error");
|
|
1064
1065
|
var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
1065
1066
|
constructor() {
|
|
1066
1067
|
super();
|
|
1067
1068
|
this.appServer = "https://app.luzmo.com";
|
|
1068
1069
|
this.apiHost = "https://api.luzmo.com";
|
|
1069
1070
|
this.slots = [];
|
|
1070
|
-
this.options = {
|
|
1071
|
-
title: {
|
|
1072
|
-
en: ""
|
|
1073
|
-
},
|
|
1074
|
-
theme: "default"
|
|
1075
|
-
};
|
|
1076
1071
|
this.version = version + "-wc-luzmo";
|
|
1072
|
+
this.libVersion = version + "-wc-luzmo";
|
|
1073
|
+
this.postInitCallQueue = [];
|
|
1077
1074
|
}
|
|
1078
1075
|
static {
|
|
1079
1076
|
// Static styles to set host display to block, else it is not shown at all for some reason.
|
|
@@ -1085,9 +1082,37 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1085
1082
|
}
|
|
1086
1083
|
`;
|
|
1087
1084
|
}
|
|
1085
|
+
canInitializeVizItem() {
|
|
1086
|
+
return !!(this.type || this.dashboardId && this.itemId);
|
|
1087
|
+
}
|
|
1088
|
+
getFilters() {
|
|
1089
|
+
return this.chartElement.getFilters();
|
|
1090
|
+
}
|
|
1091
|
+
export() {
|
|
1092
|
+
return this.chartElement.export();
|
|
1093
|
+
}
|
|
1094
|
+
getData() {
|
|
1095
|
+
return this.chartElement.getData();
|
|
1096
|
+
}
|
|
1097
|
+
refreshData() {
|
|
1098
|
+
return this.chartElement.refreshData();
|
|
1099
|
+
}
|
|
1100
|
+
setFilters(filterInput) {
|
|
1101
|
+
return this.chartElement.setFilters(void 0, filterInput);
|
|
1102
|
+
}
|
|
1103
|
+
attributeChangedCallback(name, _old, value) {
|
|
1104
|
+
super.attributeChangedCallback(name, _old, value);
|
|
1105
|
+
if (name === "selecteddata") {
|
|
1106
|
+
if (this.chartElement) {
|
|
1107
|
+
this.setFilters(JSON.parse(value ?? "{}"));
|
|
1108
|
+
} else {
|
|
1109
|
+
this.postInitCallQueue.push([this.setFilters, [JSON.parse(value ?? "{}")]]);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1088
1113
|
async firstUpdated(_changedProperties) {
|
|
1089
1114
|
super.firstUpdated(_changedProperties);
|
|
1090
|
-
if (this.
|
|
1115
|
+
if (this.canInitializeVizItem()) {
|
|
1091
1116
|
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1092
1117
|
this.createAndAppendElement();
|
|
1093
1118
|
}
|
|
@@ -1096,6 +1121,16 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1096
1121
|
if (!this.chartElement) {
|
|
1097
1122
|
this.chartElement = document.createElement("chart-component");
|
|
1098
1123
|
this.chartElement.setAttribute("embedding-mode", "chart");
|
|
1124
|
+
this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
|
|
1125
|
+
this.chartElement.addEventListener("rendered", (payload) => {
|
|
1126
|
+
for (const functionToCall of this.postInitCallQueue) {
|
|
1127
|
+
functionToCall[0].bind(this)(...functionToCall[1]);
|
|
1128
|
+
}
|
|
1129
|
+
this.dispatchEvent(new CustomEvent("rendered", payload));
|
|
1130
|
+
});
|
|
1131
|
+
this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
|
|
1132
|
+
this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
|
|
1133
|
+
this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
|
|
1099
1134
|
this.updateVizItemProperties();
|
|
1100
1135
|
this.renderRoot.append(this.chartElement);
|
|
1101
1136
|
}
|
|
@@ -1105,6 +1140,7 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1105
1140
|
for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
|
|
1106
1141
|
const value = this[key];
|
|
1107
1142
|
if (value) {
|
|
1143
|
+
this.parseAndValidate(key);
|
|
1108
1144
|
const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
|
|
1109
1145
|
this.chartElement.setAttribute(
|
|
1110
1146
|
SharedLib3.libraryTypeToWebComponentTypeMapping[key],
|
|
@@ -1118,16 +1154,37 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
|
1118
1154
|
if (this.chartElement) {
|
|
1119
1155
|
for (const [propertyName] of changedProperties.entries()) {
|
|
1120
1156
|
const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
|
|
1157
|
+
this.parseAndValidate(propertyName);
|
|
1121
1158
|
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
|
|
1122
1159
|
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1123
1160
|
}
|
|
1124
1161
|
} else {
|
|
1125
|
-
if (this.
|
|
1162
|
+
if (this.canInitializeVizItem()) {
|
|
1163
|
+
if (this.type) {
|
|
1164
|
+
this.parseAndValidate("type");
|
|
1165
|
+
}
|
|
1126
1166
|
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1127
1167
|
this.createAndAppendElement();
|
|
1128
1168
|
}
|
|
1129
1169
|
}
|
|
1130
1170
|
}
|
|
1171
|
+
parseAndValidate(key) {
|
|
1172
|
+
try {
|
|
1173
|
+
if (key === "slots") {
|
|
1174
|
+
SharedLib3.slotsParser.parse(this.slots);
|
|
1175
|
+
} else if (key === "options") {
|
|
1176
|
+
SharedLib3.vizItemOptionsParser.parse(this.options);
|
|
1177
|
+
} else if (key === "canFilter") {
|
|
1178
|
+
SharedLib3.canFilterParser.parse(this.canFilter);
|
|
1179
|
+
} else if (key === "type") {
|
|
1180
|
+
SharedLib3.itemTypeParser.parse(this.type);
|
|
1181
|
+
}
|
|
1182
|
+
} catch (err) {
|
|
1183
|
+
const validationError = (0, import_zod_validation_error.fromError)(err);
|
|
1184
|
+
console.warn(err);
|
|
1185
|
+
console.warn(validationError.toString());
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1131
1188
|
render() {
|
|
1132
1189
|
return import_lit3.html` `;
|
|
1133
1190
|
}
|
|
@@ -1173,6 +1230,18 @@ __decorateClass([
|
|
|
1173
1230
|
__decorateClass([
|
|
1174
1231
|
(0, import_decorators3.property)({ type: Array })
|
|
1175
1232
|
], LuzmoBaseVizItem.prototype, "filters", 2);
|
|
1233
|
+
__decorateClass([
|
|
1234
|
+
(0, import_decorators3.property)()
|
|
1235
|
+
], LuzmoBaseVizItem.prototype, "dashboardId", 2);
|
|
1236
|
+
__decorateClass([
|
|
1237
|
+
(0, import_decorators3.property)()
|
|
1238
|
+
], LuzmoBaseVizItem.prototype, "itemId", 2);
|
|
1239
|
+
__decorateClass([
|
|
1240
|
+
(0, import_decorators3.property)({ type: Object })
|
|
1241
|
+
], LuzmoBaseVizItem.prototype, "selectedData", 2);
|
|
1242
|
+
__decorateClass([
|
|
1243
|
+
(0, import_decorators3.property)()
|
|
1244
|
+
], LuzmoBaseVizItem.prototype, "libVersion", 2);
|
|
1176
1245
|
|
|
1177
1246
|
// libs/embed-libs/embed/src/lib/viz-item/viz-item-web-component.ts
|
|
1178
1247
|
var LuzmoVizItemWebComponent = class extends LuzmoBaseVizItem {
|