@luzmo/embed 5.1.5 → 6.0.0-beta.1
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 +7 -0
- package/MIGRATIONS.md +6 -0
- package/index.cjs +212 -31
- package/index.d.ts +3 -1
- package/index.js +211 -32
- package/lib/dashboard-component/dashboard-base.d.ts +1 -2
- package/lib/dashboard-component/dashboard-component.d.ts +2 -10
- package/lib/viz-item/viz-item-component.d.ts +3 -0
- package/lib/viz-item/viz-item.base.d.ts +41 -0
- package/luzmo-embed.min.js +5749 -1282
- package/package.json +3 -2
- package/src/index.d.ts +3 -1
- package/src/lib/dashboard-component/dashboard-base.d.ts +1 -2
- package/src/lib/dashboard-component/dashboard-component.d.ts +2 -10
- package/src/lib/viz-item/viz-item-component.d.ts +3 -0
- package/src/lib/viz-item/viz-item.base.d.ts +41 -0
- package/index.libs.cjs +0 -1078
- package/index.libs.d.ts +0 -1
- package/index.libs.js +0 -1058
- package/lib/dashboard-component/dashboard-web-component.d.ts +0 -3
- package/luzmo-embed.libs.js +0 -3062
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [6.0.0] - 2024-05-31
|
|
5
|
+
|
|
6
|
+
### Breaking changes
|
|
7
|
+
|
|
8
|
+
- Removed `<luzmo-dashboard>` web component, It has been replaced with `<luzmo-embed-dashboard>`.
|
|
9
|
+
- `LuzmoDashboard` has been replaced with `LuzmoEmbedDashboard`
|
|
10
|
+
|
|
4
11
|
## [5.1.5] - 2024-05-03
|
|
5
12
|
|
|
6
13
|
### Bugfixes
|
package/MIGRATIONS.md
CHANGED
package/index.cjs
CHANGED
|
@@ -39,10 +39,12 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
39
39
|
// libs/embed-libs/embed/src/index.ts
|
|
40
40
|
var src_exports = {};
|
|
41
41
|
__export(src_exports, {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
LuzmoEmbedDashboard: () => LuzmoEmbedDashboard,
|
|
43
|
+
LuzmoEmbedVizItem: () => LuzmoEmbedVizItem,
|
|
44
|
+
filterUtils: () => import_shared_embed2.filterUtils
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(src_exports);
|
|
47
|
+
var import_shared_embed2 = require("@luzmo/shared-embed");
|
|
46
48
|
|
|
47
49
|
// libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
|
|
48
50
|
var import_decorators2 = require("lit/decorators.js");
|
|
@@ -55,7 +57,7 @@ var import_style_map = require("lit/directives/style-map.js");
|
|
|
55
57
|
var import_shared_embed = require("@luzmo/shared-embed");
|
|
56
58
|
|
|
57
59
|
// libs/embed-libs/embed/package.json
|
|
58
|
-
var version = "
|
|
60
|
+
var version = "6.0.0-beta.1";
|
|
59
61
|
|
|
60
62
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
61
63
|
var LuzmoService = class {
|
|
@@ -100,7 +102,7 @@ var _setEventHandler = () => {
|
|
|
100
102
|
}
|
|
101
103
|
dashboardComponent.iframeLoaded = true;
|
|
102
104
|
dashboardComponent._displayError();
|
|
103
|
-
console.error("Dashboard error: ", event.data.errorMsg);
|
|
105
|
+
console.error("Dashboard error: ", event.data.errorMsg ?? event.data.error?.msg);
|
|
104
106
|
break;
|
|
105
107
|
}
|
|
106
108
|
case "data": {
|
|
@@ -360,7 +362,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
360
362
|
this.browserErrorMsg = "";
|
|
361
363
|
this.dashboardError = false;
|
|
362
364
|
this.browserNotSupported = [];
|
|
363
|
-
this.
|
|
365
|
+
this.libVersion = version + "-wc-luzmo";
|
|
364
366
|
this.isLibraryLoaded = false;
|
|
365
367
|
this.currentAuthKey = null;
|
|
366
368
|
this.currentAuthToken = null;
|
|
@@ -424,22 +426,6 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
424
426
|
});
|
|
425
427
|
});
|
|
426
428
|
}
|
|
427
|
-
loadLibrary(appServer) {
|
|
428
|
-
if (import_shared_embed.remotesMap[appServer]) {
|
|
429
|
-
return Promise.resolve(import_shared_embed.remotesMap[appServer].module);
|
|
430
|
-
}
|
|
431
|
-
import_shared_embed.remotesMap[appServer] = {
|
|
432
|
-
url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
|
|
433
|
-
format: "esm",
|
|
434
|
-
from: "vite",
|
|
435
|
-
module: void 0
|
|
436
|
-
};
|
|
437
|
-
return (0, import_shared_embed.__federationMethodGetRemote)(appServer, "./DashboardApp").then((module2) => {
|
|
438
|
-
const wrappedModule = (0, import_shared_embed.__federationMethodWrapDefault)(module2, true);
|
|
439
|
-
import_shared_embed.remotesMap[appServer].module = wrappedModule;
|
|
440
|
-
return wrappedModule;
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
429
|
// Set resize event listener
|
|
444
430
|
connectedCallback() {
|
|
445
431
|
super.connectedCallback();
|
|
@@ -465,7 +451,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
465
451
|
initComponent() {
|
|
466
452
|
this.params = this._setOptions();
|
|
467
453
|
if (this.getIsViewMode()) {
|
|
468
|
-
|
|
454
|
+
SharedLib2.loadLibrary(this.params.appServer).then(async () => {
|
|
469
455
|
this.isLibraryLoaded = true;
|
|
470
456
|
await this.updateComplete;
|
|
471
457
|
const oldReference = this.renderRoot.querySelector("dashboard-component");
|
|
@@ -551,7 +537,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
|
|
|
551
537
|
if (this.dashboardReference) {
|
|
552
538
|
for (const [propertyName] of changedProperties.entries()) {
|
|
553
539
|
if (propertyName === "appSever") {
|
|
554
|
-
|
|
540
|
+
SharedLib2.loadLibrary(changedProperties[propertyName]).then(async () => {
|
|
555
541
|
this.isLibraryLoaded = true;
|
|
556
542
|
await this.updateComplete;
|
|
557
543
|
this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
|
|
@@ -1050,7 +1036,7 @@ __decorateClass([
|
|
|
1050
1036
|
], LuzmoDashboard.prototype, "browserNotSupported", 2);
|
|
1051
1037
|
__decorateClass([
|
|
1052
1038
|
(0, import_decorators.property)()
|
|
1053
|
-
], LuzmoDashboard.prototype, "
|
|
1039
|
+
], LuzmoDashboard.prototype, "libVersion", 2);
|
|
1054
1040
|
__decorateClass([
|
|
1055
1041
|
(0, import_decorators.state)()
|
|
1056
1042
|
], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
|
|
@@ -1068,18 +1054,213 @@ __decorateClass([
|
|
|
1068
1054
|
], LuzmoDashboard.prototype, "isInitCalled", 2);
|
|
1069
1055
|
|
|
1070
1056
|
// libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
|
|
1071
|
-
var LuzmoDashboard2 = class extends LuzmoDashboard {
|
|
1072
|
-
};
|
|
1073
|
-
LuzmoDashboard2 = __decorateClass([
|
|
1074
|
-
(0, import_decorators2.customElement)("luzmo-dashboard")
|
|
1075
|
-
], LuzmoDashboard2);
|
|
1076
1057
|
var LuzmoEmbedDashboard = class extends LuzmoDashboard {
|
|
1077
1058
|
};
|
|
1078
1059
|
LuzmoEmbedDashboard = __decorateClass([
|
|
1079
1060
|
(0, import_decorators2.customElement)("luzmo-embed-dashboard")
|
|
1080
1061
|
], LuzmoEmbedDashboard);
|
|
1062
|
+
|
|
1063
|
+
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1064
|
+
var import_decorators4 = require("lit/decorators.js");
|
|
1065
|
+
|
|
1066
|
+
// libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
|
|
1067
|
+
var import_decorators3 = require("lit/decorators.js");
|
|
1068
|
+
var import_lit3 = require("lit");
|
|
1069
|
+
var SharedLib3 = __toESM(require("@luzmo/shared-embed"), 1);
|
|
1070
|
+
var import_zod_validation_error = require("zod-validation-error");
|
|
1071
|
+
var LuzmoBaseVizItem = class extends import_lit3.LitElement {
|
|
1072
|
+
constructor() {
|
|
1073
|
+
super();
|
|
1074
|
+
this.appServer = "https://app.luzmo.com";
|
|
1075
|
+
this.apiHost = "https://api.luzmo.com";
|
|
1076
|
+
this.slots = [];
|
|
1077
|
+
this.version = version + "-wc-luzmo";
|
|
1078
|
+
this.libVersion = version + "-wc-luzmo";
|
|
1079
|
+
this.postInitCallQueue = [];
|
|
1080
|
+
}
|
|
1081
|
+
static {
|
|
1082
|
+
// Static styles to set host display to block, else it is not shown at all for some reason.
|
|
1083
|
+
this.styles = import_lit3.css`
|
|
1084
|
+
:host {
|
|
1085
|
+
display: block;
|
|
1086
|
+
width: 100%;
|
|
1087
|
+
height: 100%;
|
|
1088
|
+
}
|
|
1089
|
+
`;
|
|
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
|
+
setAuthorization(key, token) {
|
|
1110
|
+
return this.chartElement.setAuthorization(key, token);
|
|
1111
|
+
}
|
|
1112
|
+
attributeChangedCallback(name, _old, value) {
|
|
1113
|
+
super.attributeChangedCallback(name, _old, value);
|
|
1114
|
+
if (name === "selecteddata") {
|
|
1115
|
+
if (this.chartElement) {
|
|
1116
|
+
this.setFilters(JSON.parse(value ?? "{}"));
|
|
1117
|
+
} else {
|
|
1118
|
+
this.postInitCallQueue.push([this.setFilters, [JSON.parse(value ?? "{}")]]);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
async firstUpdated(_changedProperties) {
|
|
1123
|
+
super.firstUpdated(_changedProperties);
|
|
1124
|
+
if (this.canInitializeVizItem()) {
|
|
1125
|
+
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1126
|
+
this.createAndAppendElement();
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
createAndAppendElement() {
|
|
1130
|
+
if (!this.chartElement) {
|
|
1131
|
+
this.chartElement = document.createElement("chart-component");
|
|
1132
|
+
this.chartElement.setAttribute("embedding-mode", "chart");
|
|
1133
|
+
this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
|
|
1134
|
+
this.chartElement.addEventListener("rendered", (payload) => {
|
|
1135
|
+
for (const functionToCall of this.postInitCallQueue) {
|
|
1136
|
+
functionToCall[0].bind(this)(...functionToCall[1]);
|
|
1137
|
+
}
|
|
1138
|
+
this.dispatchEvent(new CustomEvent("rendered", payload));
|
|
1139
|
+
});
|
|
1140
|
+
this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
|
|
1141
|
+
this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
|
|
1142
|
+
this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
|
|
1143
|
+
this.updateVizItemProperties();
|
|
1144
|
+
this.renderRoot.append(this.chartElement);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
updateVizItemProperties() {
|
|
1148
|
+
if (this.chartElement) {
|
|
1149
|
+
for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
|
|
1150
|
+
const value = this[key];
|
|
1151
|
+
if (value) {
|
|
1152
|
+
this.parseAndValidate(key);
|
|
1153
|
+
const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
|
|
1154
|
+
this.chartElement.setAttribute(
|
|
1155
|
+
SharedLib3.libraryTypeToWebComponentTypeMapping[key],
|
|
1156
|
+
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
async updated(changedProperties) {
|
|
1163
|
+
if (this.chartElement) {
|
|
1164
|
+
for (const [propertyName] of changedProperties.entries()) {
|
|
1165
|
+
const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
|
|
1166
|
+
this.parseAndValidate(propertyName);
|
|
1167
|
+
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
|
|
1168
|
+
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1169
|
+
}
|
|
1170
|
+
} else {
|
|
1171
|
+
if (this.canInitializeVizItem()) {
|
|
1172
|
+
if (this.type) {
|
|
1173
|
+
this.parseAndValidate("type");
|
|
1174
|
+
}
|
|
1175
|
+
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1176
|
+
this.createAndAppendElement();
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
parseAndValidate(key) {
|
|
1181
|
+
try {
|
|
1182
|
+
if (key === "slots") {
|
|
1183
|
+
SharedLib3.slotsParser.parse(this.slots);
|
|
1184
|
+
} else if (key === "options") {
|
|
1185
|
+
SharedLib3.vizItemOptionsParser.parse(this.options);
|
|
1186
|
+
} else if (key === "canFilter") {
|
|
1187
|
+
SharedLib3.canFilterParser.parse(this.canFilter);
|
|
1188
|
+
} else if (key === "type") {
|
|
1189
|
+
SharedLib3.itemTypeParser.parse(this.type);
|
|
1190
|
+
}
|
|
1191
|
+
} catch (err) {
|
|
1192
|
+
const validationError = (0, import_zod_validation_error.fromError)(err);
|
|
1193
|
+
console.warn(err);
|
|
1194
|
+
console.warn(validationError.toString());
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
render() {
|
|
1198
|
+
return import_lit3.html` `;
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
__decorateClass([
|
|
1202
|
+
(0, import_decorators3.property)()
|
|
1203
|
+
], LuzmoBaseVizItem.prototype, "appServer", 2);
|
|
1204
|
+
__decorateClass([
|
|
1205
|
+
(0, import_decorators3.property)()
|
|
1206
|
+
], LuzmoBaseVizItem.prototype, "apiHost", 2);
|
|
1207
|
+
__decorateClass([
|
|
1208
|
+
(0, import_decorators3.property)({ type: Array })
|
|
1209
|
+
], LuzmoBaseVizItem.prototype, "slots", 2);
|
|
1210
|
+
__decorateClass([
|
|
1211
|
+
(0, import_decorators3.property)({ type: Object })
|
|
1212
|
+
], LuzmoBaseVizItem.prototype, "options", 2);
|
|
1213
|
+
__decorateClass([
|
|
1214
|
+
(0, import_decorators3.property)()
|
|
1215
|
+
], LuzmoBaseVizItem.prototype, "type", 2);
|
|
1216
|
+
__decorateClass([
|
|
1217
|
+
(0, import_decorators3.property)()
|
|
1218
|
+
], LuzmoBaseVizItem.prototype, "authKey", 2);
|
|
1219
|
+
__decorateClass([
|
|
1220
|
+
(0, import_decorators3.property)()
|
|
1221
|
+
], LuzmoBaseVizItem.prototype, "authToken", 2);
|
|
1222
|
+
__decorateClass([
|
|
1223
|
+
(0, import_decorators3.property)()
|
|
1224
|
+
], LuzmoBaseVizItem.prototype, "version", 2);
|
|
1225
|
+
__decorateClass([
|
|
1226
|
+
(0, import_decorators3.property)()
|
|
1227
|
+
], LuzmoBaseVizItem.prototype, "contextId", 2);
|
|
1228
|
+
__decorateClass([
|
|
1229
|
+
(0, import_decorators3.property)({
|
|
1230
|
+
converter: (value) => {
|
|
1231
|
+
try {
|
|
1232
|
+
return JSON.parse(value);
|
|
1233
|
+
} catch (exc) {
|
|
1234
|
+
return value;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
})
|
|
1238
|
+
], LuzmoBaseVizItem.prototype, "canFilter", 2);
|
|
1239
|
+
__decorateClass([
|
|
1240
|
+
(0, import_decorators3.property)({ type: Array })
|
|
1241
|
+
], LuzmoBaseVizItem.prototype, "filters", 2);
|
|
1242
|
+
__decorateClass([
|
|
1243
|
+
(0, import_decorators3.property)()
|
|
1244
|
+
], LuzmoBaseVizItem.prototype, "dashboardId", 2);
|
|
1245
|
+
__decorateClass([
|
|
1246
|
+
(0, import_decorators3.property)()
|
|
1247
|
+
], LuzmoBaseVizItem.prototype, "itemId", 2);
|
|
1248
|
+
__decorateClass([
|
|
1249
|
+
(0, import_decorators3.property)({ type: Object })
|
|
1250
|
+
], LuzmoBaseVizItem.prototype, "selectedData", 2);
|
|
1251
|
+
__decorateClass([
|
|
1252
|
+
(0, import_decorators3.property)()
|
|
1253
|
+
], LuzmoBaseVizItem.prototype, "libVersion", 2);
|
|
1254
|
+
|
|
1255
|
+
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1256
|
+
var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {
|
|
1257
|
+
};
|
|
1258
|
+
LuzmoEmbedVizItem = __decorateClass([
|
|
1259
|
+
(0, import_decorators4.customElement)("luzmo-embed-viz-item")
|
|
1260
|
+
], LuzmoEmbedVizItem);
|
|
1081
1261
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1082
1262
|
0 && (module.exports = {
|
|
1083
|
-
|
|
1084
|
-
|
|
1263
|
+
LuzmoEmbedDashboard,
|
|
1264
|
+
LuzmoEmbedVizItem,
|
|
1265
|
+
filterUtils
|
|
1085
1266
|
});
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export type { LoadEvent, ChangedFiltersEvent, CustomEvent, ItemsRenderedEvent, ExportedEvent, DashboardActionEvent, Filter, FilterExpression, FilterOrigin, FilterInput, FilterGroup, ExportType, ItemData, ExportDashboard, AccessibleDashboard, SetEditMode } from '@luzmo/shared-embed';
|
|
1
|
+
export type { LoadEvent, ChangedFiltersEvent, CustomEvent, ItemsRenderedEvent, ExportedEvent, DashboardActionEvent, Filter, FilterExpression, FilterOrigin, FilterInput, FilterGroup, ExportType, ItemData, ExportDashboard, AccessibleDashboard, SetEditMode, ItemType, Slots, VizItemOptions } from '@luzmo/shared-embed';
|
|
2
|
+
export { filterUtils } from '@luzmo/shared-embed';
|
|
2
3
|
export * from './lib/dashboard-component/dashboard-component';
|
|
4
|
+
export * from './lib/viz-item/viz-item-component';
|
package/index.js
CHANGED
|
@@ -10,6 +10,9 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
10
|
return result;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// libs/embed-libs/embed/src/index.ts
|
|
14
|
+
import { filterUtils } from "@luzmo/shared-embed";
|
|
15
|
+
|
|
13
16
|
// libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
|
|
14
17
|
import {
|
|
15
18
|
customElement
|
|
@@ -30,14 +33,11 @@ import {
|
|
|
30
33
|
styleMap
|
|
31
34
|
} from "lit/directives/style-map.js";
|
|
32
35
|
import {
|
|
33
|
-
__federationMethodGetRemote,
|
|
34
|
-
__federationMethodWrapDefault,
|
|
35
|
-
remotesMap,
|
|
36
36
|
luzmoEmbedContainerClass
|
|
37
37
|
} from "@luzmo/shared-embed";
|
|
38
38
|
|
|
39
39
|
// libs/embed-libs/embed/package.json
|
|
40
|
-
var version = "
|
|
40
|
+
var version = "6.0.0-beta.1";
|
|
41
41
|
|
|
42
42
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
43
43
|
var LuzmoService = class {
|
|
@@ -82,7 +82,7 @@ var _setEventHandler = () => {
|
|
|
82
82
|
}
|
|
83
83
|
dashboardComponent.iframeLoaded = true;
|
|
84
84
|
dashboardComponent._displayError();
|
|
85
|
-
console.error("Dashboard error: ", event.data.errorMsg);
|
|
85
|
+
console.error("Dashboard error: ", event.data.errorMsg ?? event.data.error?.msg);
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
88
88
|
case "data": {
|
|
@@ -342,7 +342,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
342
342
|
this.browserErrorMsg = "";
|
|
343
343
|
this.dashboardError = false;
|
|
344
344
|
this.browserNotSupported = [];
|
|
345
|
-
this.
|
|
345
|
+
this.libVersion = version + "-wc-luzmo";
|
|
346
346
|
this.isLibraryLoaded = false;
|
|
347
347
|
this.currentAuthKey = null;
|
|
348
348
|
this.currentAuthToken = null;
|
|
@@ -406,22 +406,6 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
406
406
|
});
|
|
407
407
|
});
|
|
408
408
|
}
|
|
409
|
-
loadLibrary(appServer) {
|
|
410
|
-
if (remotesMap[appServer]) {
|
|
411
|
-
return Promise.resolve(remotesMap[appServer].module);
|
|
412
|
-
}
|
|
413
|
-
remotesMap[appServer] = {
|
|
414
|
-
url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
|
|
415
|
-
format: "esm",
|
|
416
|
-
from: "vite",
|
|
417
|
-
module: void 0
|
|
418
|
-
};
|
|
419
|
-
return __federationMethodGetRemote(appServer, "./DashboardApp").then((module) => {
|
|
420
|
-
const wrappedModule = __federationMethodWrapDefault(module, true);
|
|
421
|
-
remotesMap[appServer].module = wrappedModule;
|
|
422
|
-
return wrappedModule;
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
409
|
// Set resize event listener
|
|
426
410
|
connectedCallback() {
|
|
427
411
|
super.connectedCallback();
|
|
@@ -447,7 +431,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
447
431
|
initComponent() {
|
|
448
432
|
this.params = this._setOptions();
|
|
449
433
|
if (this.getIsViewMode()) {
|
|
450
|
-
|
|
434
|
+
SharedLib2.loadLibrary(this.params.appServer).then(async () => {
|
|
451
435
|
this.isLibraryLoaded = true;
|
|
452
436
|
await this.updateComplete;
|
|
453
437
|
const oldReference = this.renderRoot.querySelector("dashboard-component");
|
|
@@ -533,7 +517,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
533
517
|
if (this.dashboardReference) {
|
|
534
518
|
for (const [propertyName] of changedProperties.entries()) {
|
|
535
519
|
if (propertyName === "appSever") {
|
|
536
|
-
|
|
520
|
+
SharedLib2.loadLibrary(changedProperties[propertyName]).then(async () => {
|
|
537
521
|
this.isLibraryLoaded = true;
|
|
538
522
|
await this.updateComplete;
|
|
539
523
|
this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
|
|
@@ -1032,7 +1016,7 @@ __decorateClass([
|
|
|
1032
1016
|
], LuzmoDashboard.prototype, "browserNotSupported", 2);
|
|
1033
1017
|
__decorateClass([
|
|
1034
1018
|
property()
|
|
1035
|
-
], LuzmoDashboard.prototype, "
|
|
1019
|
+
], LuzmoDashboard.prototype, "libVersion", 2);
|
|
1036
1020
|
__decorateClass([
|
|
1037
1021
|
state()
|
|
1038
1022
|
], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
|
|
@@ -1050,17 +1034,212 @@ __decorateClass([
|
|
|
1050
1034
|
], LuzmoDashboard.prototype, "isInitCalled", 2);
|
|
1051
1035
|
|
|
1052
1036
|
// libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
|
|
1053
|
-
var LuzmoDashboard2 = class extends LuzmoDashboard {
|
|
1054
|
-
};
|
|
1055
|
-
LuzmoDashboard2 = __decorateClass([
|
|
1056
|
-
customElement("luzmo-dashboard")
|
|
1057
|
-
], LuzmoDashboard2);
|
|
1058
1037
|
var LuzmoEmbedDashboard = class extends LuzmoDashboard {
|
|
1059
1038
|
};
|
|
1060
1039
|
LuzmoEmbedDashboard = __decorateClass([
|
|
1061
1040
|
customElement("luzmo-embed-dashboard")
|
|
1062
1041
|
], LuzmoEmbedDashboard);
|
|
1042
|
+
|
|
1043
|
+
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1044
|
+
import { customElement as customElement2 } from "lit/decorators.js";
|
|
1045
|
+
|
|
1046
|
+
// libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
|
|
1047
|
+
import { property as property2 } from "lit/decorators.js";
|
|
1048
|
+
import { LitElement as LitElement2, html as html2, css as css2 } from "lit";
|
|
1049
|
+
import * as SharedLib3 from "@luzmo/shared-embed";
|
|
1050
|
+
import { fromError } from "zod-validation-error";
|
|
1051
|
+
var LuzmoBaseVizItem = class extends LitElement2 {
|
|
1052
|
+
constructor() {
|
|
1053
|
+
super();
|
|
1054
|
+
this.appServer = "https://app.luzmo.com";
|
|
1055
|
+
this.apiHost = "https://api.luzmo.com";
|
|
1056
|
+
this.slots = [];
|
|
1057
|
+
this.version = version + "-wc-luzmo";
|
|
1058
|
+
this.libVersion = version + "-wc-luzmo";
|
|
1059
|
+
this.postInitCallQueue = [];
|
|
1060
|
+
}
|
|
1061
|
+
static {
|
|
1062
|
+
// Static styles to set host display to block, else it is not shown at all for some reason.
|
|
1063
|
+
this.styles = css2`
|
|
1064
|
+
:host {
|
|
1065
|
+
display: block;
|
|
1066
|
+
width: 100%;
|
|
1067
|
+
height: 100%;
|
|
1068
|
+
}
|
|
1069
|
+
`;
|
|
1070
|
+
}
|
|
1071
|
+
canInitializeVizItem() {
|
|
1072
|
+
return !!(this.type || this.dashboardId && this.itemId);
|
|
1073
|
+
}
|
|
1074
|
+
getFilters() {
|
|
1075
|
+
return this.chartElement.getFilters();
|
|
1076
|
+
}
|
|
1077
|
+
export() {
|
|
1078
|
+
return this.chartElement.export();
|
|
1079
|
+
}
|
|
1080
|
+
getData() {
|
|
1081
|
+
return this.chartElement.getData();
|
|
1082
|
+
}
|
|
1083
|
+
refreshData() {
|
|
1084
|
+
return this.chartElement.refreshData();
|
|
1085
|
+
}
|
|
1086
|
+
setFilters(filterInput) {
|
|
1087
|
+
return this.chartElement.setFilters(void 0, filterInput);
|
|
1088
|
+
}
|
|
1089
|
+
setAuthorization(key, token) {
|
|
1090
|
+
return this.chartElement.setAuthorization(key, token);
|
|
1091
|
+
}
|
|
1092
|
+
attributeChangedCallback(name, _old, value) {
|
|
1093
|
+
super.attributeChangedCallback(name, _old, value);
|
|
1094
|
+
if (name === "selecteddata") {
|
|
1095
|
+
if (this.chartElement) {
|
|
1096
|
+
this.setFilters(JSON.parse(value ?? "{}"));
|
|
1097
|
+
} else {
|
|
1098
|
+
this.postInitCallQueue.push([this.setFilters, [JSON.parse(value ?? "{}")]]);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
async firstUpdated(_changedProperties) {
|
|
1103
|
+
super.firstUpdated(_changedProperties);
|
|
1104
|
+
if (this.canInitializeVizItem()) {
|
|
1105
|
+
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1106
|
+
this.createAndAppendElement();
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
createAndAppendElement() {
|
|
1110
|
+
if (!this.chartElement) {
|
|
1111
|
+
this.chartElement = document.createElement("chart-component");
|
|
1112
|
+
this.chartElement.setAttribute("embedding-mode", "chart");
|
|
1113
|
+
this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
|
|
1114
|
+
this.chartElement.addEventListener("rendered", (payload) => {
|
|
1115
|
+
for (const functionToCall of this.postInitCallQueue) {
|
|
1116
|
+
functionToCall[0].bind(this)(...functionToCall[1]);
|
|
1117
|
+
}
|
|
1118
|
+
this.dispatchEvent(new CustomEvent("rendered", payload));
|
|
1119
|
+
});
|
|
1120
|
+
this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
|
|
1121
|
+
this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
|
|
1122
|
+
this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
|
|
1123
|
+
this.updateVizItemProperties();
|
|
1124
|
+
this.renderRoot.append(this.chartElement);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
updateVizItemProperties() {
|
|
1128
|
+
if (this.chartElement) {
|
|
1129
|
+
for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
|
|
1130
|
+
const value = this[key];
|
|
1131
|
+
if (value) {
|
|
1132
|
+
this.parseAndValidate(key);
|
|
1133
|
+
const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
|
|
1134
|
+
this.chartElement.setAttribute(
|
|
1135
|
+
SharedLib3.libraryTypeToWebComponentTypeMapping[key],
|
|
1136
|
+
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
async updated(changedProperties) {
|
|
1143
|
+
if (this.chartElement) {
|
|
1144
|
+
for (const [propertyName] of changedProperties.entries()) {
|
|
1145
|
+
const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
|
|
1146
|
+
this.parseAndValidate(propertyName);
|
|
1147
|
+
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
|
|
1148
|
+
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1149
|
+
}
|
|
1150
|
+
} else {
|
|
1151
|
+
if (this.canInitializeVizItem()) {
|
|
1152
|
+
if (this.type) {
|
|
1153
|
+
this.parseAndValidate("type");
|
|
1154
|
+
}
|
|
1155
|
+
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1156
|
+
this.createAndAppendElement();
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
parseAndValidate(key) {
|
|
1161
|
+
try {
|
|
1162
|
+
if (key === "slots") {
|
|
1163
|
+
SharedLib3.slotsParser.parse(this.slots);
|
|
1164
|
+
} else if (key === "options") {
|
|
1165
|
+
SharedLib3.vizItemOptionsParser.parse(this.options);
|
|
1166
|
+
} else if (key === "canFilter") {
|
|
1167
|
+
SharedLib3.canFilterParser.parse(this.canFilter);
|
|
1168
|
+
} else if (key === "type") {
|
|
1169
|
+
SharedLib3.itemTypeParser.parse(this.type);
|
|
1170
|
+
}
|
|
1171
|
+
} catch (err) {
|
|
1172
|
+
const validationError = fromError(err);
|
|
1173
|
+
console.warn(err);
|
|
1174
|
+
console.warn(validationError.toString());
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
render() {
|
|
1178
|
+
return html2` `;
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
__decorateClass([
|
|
1182
|
+
property2()
|
|
1183
|
+
], LuzmoBaseVizItem.prototype, "appServer", 2);
|
|
1184
|
+
__decorateClass([
|
|
1185
|
+
property2()
|
|
1186
|
+
], LuzmoBaseVizItem.prototype, "apiHost", 2);
|
|
1187
|
+
__decorateClass([
|
|
1188
|
+
property2({ type: Array })
|
|
1189
|
+
], LuzmoBaseVizItem.prototype, "slots", 2);
|
|
1190
|
+
__decorateClass([
|
|
1191
|
+
property2({ type: Object })
|
|
1192
|
+
], LuzmoBaseVizItem.prototype, "options", 2);
|
|
1193
|
+
__decorateClass([
|
|
1194
|
+
property2()
|
|
1195
|
+
], LuzmoBaseVizItem.prototype, "type", 2);
|
|
1196
|
+
__decorateClass([
|
|
1197
|
+
property2()
|
|
1198
|
+
], LuzmoBaseVizItem.prototype, "authKey", 2);
|
|
1199
|
+
__decorateClass([
|
|
1200
|
+
property2()
|
|
1201
|
+
], LuzmoBaseVizItem.prototype, "authToken", 2);
|
|
1202
|
+
__decorateClass([
|
|
1203
|
+
property2()
|
|
1204
|
+
], LuzmoBaseVizItem.prototype, "version", 2);
|
|
1205
|
+
__decorateClass([
|
|
1206
|
+
property2()
|
|
1207
|
+
], LuzmoBaseVizItem.prototype, "contextId", 2);
|
|
1208
|
+
__decorateClass([
|
|
1209
|
+
property2({
|
|
1210
|
+
converter: (value) => {
|
|
1211
|
+
try {
|
|
1212
|
+
return JSON.parse(value);
|
|
1213
|
+
} catch (exc) {
|
|
1214
|
+
return value;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
})
|
|
1218
|
+
], LuzmoBaseVizItem.prototype, "canFilter", 2);
|
|
1219
|
+
__decorateClass([
|
|
1220
|
+
property2({ type: Array })
|
|
1221
|
+
], LuzmoBaseVizItem.prototype, "filters", 2);
|
|
1222
|
+
__decorateClass([
|
|
1223
|
+
property2()
|
|
1224
|
+
], LuzmoBaseVizItem.prototype, "dashboardId", 2);
|
|
1225
|
+
__decorateClass([
|
|
1226
|
+
property2()
|
|
1227
|
+
], LuzmoBaseVizItem.prototype, "itemId", 2);
|
|
1228
|
+
__decorateClass([
|
|
1229
|
+
property2({ type: Object })
|
|
1230
|
+
], LuzmoBaseVizItem.prototype, "selectedData", 2);
|
|
1231
|
+
__decorateClass([
|
|
1232
|
+
property2()
|
|
1233
|
+
], LuzmoBaseVizItem.prototype, "libVersion", 2);
|
|
1234
|
+
|
|
1235
|
+
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1236
|
+
var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {
|
|
1237
|
+
};
|
|
1238
|
+
LuzmoEmbedVizItem = __decorateClass([
|
|
1239
|
+
customElement2("luzmo-embed-viz-item")
|
|
1240
|
+
], LuzmoEmbedVizItem);
|
|
1063
1241
|
export {
|
|
1064
|
-
|
|
1065
|
-
|
|
1242
|
+
LuzmoEmbedDashboard,
|
|
1243
|
+
LuzmoEmbedVizItem,
|
|
1244
|
+
filterUtils
|
|
1066
1245
|
};
|
|
@@ -51,7 +51,7 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
|
|
|
51
51
|
browserErrorMsg: string;
|
|
52
52
|
dashboardError: boolean;
|
|
53
53
|
browserNotSupported: any[];
|
|
54
|
-
|
|
54
|
+
libVersion: string;
|
|
55
55
|
protected isLibraryLoaded: boolean;
|
|
56
56
|
protected dashboardReference: SharedLib.LuzmoElement;
|
|
57
57
|
currentAuthKey: string;
|
|
@@ -67,7 +67,6 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
|
|
|
67
67
|
iframeWidth?: string;
|
|
68
68
|
_resizeObserver: ResizeObserver;
|
|
69
69
|
constructor();
|
|
70
|
-
private loadLibrary;
|
|
71
70
|
connectedCallback(): void;
|
|
72
71
|
disconnectedCallback(): void;
|
|
73
72
|
firstUpdated(): void;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import { LuzmoDashboard
|
|
2
|
-
/**!
|
|
3
|
-
* @element luzmo-dashboard
|
|
4
|
-
* @description Exposed by @luzmo/embed lib to everyone.
|
|
5
|
-
*
|
|
6
|
-
* @deprecated Will be removed in next major release. Switch to <luzmo-embed-dashboard> instead.
|
|
7
|
-
*/
|
|
8
|
-
export declare class LuzmoDashboard extends LuzmoBaseDashboard {
|
|
9
|
-
}
|
|
1
|
+
import { LuzmoDashboard } from './dashboard-base';
|
|
10
2
|
/**!
|
|
11
3
|
* @element luzmo-embed-dashboard
|
|
12
4
|
* @description Exposed by @luzmo/embed lib to everyone.
|
|
13
5
|
*
|
|
14
6
|
*/
|
|
15
|
-
export declare class LuzmoEmbedDashboard extends
|
|
7
|
+
export declare class LuzmoEmbedDashboard extends LuzmoDashboard {
|
|
16
8
|
}
|