@luzmo/embed 5.0.11 → 5.0.13-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
 
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [5.0.12] - 2024-03-19
5
+
6
+ ### Bugfixes
7
+
8
+ - Fixed getAccessibleDashboards() to correctly work with embed tokens.
9
+
4
10
  ## [5.0.11] - 2024-03-18
5
11
 
6
12
  ### Updates
package/index.cjs CHANGED
@@ -39,7 +39,8 @@ 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
- LuzmoDashboard: () => LuzmoDashboard2
42
+ LuzmoDashboard: () => LuzmoDashboard2,
43
+ LuzmoVizItem: () => LuzmoVizItem
43
44
  });
44
45
  module.exports = __toCommonJS(src_exports);
45
46
 
@@ -54,7 +55,7 @@ var import_style_map = require("lit/directives/style-map.js");
54
55
  var import_shared_embed = require("@luzmo/shared-embed");
55
56
 
56
57
  // libs/embed-libs/embed/package.json
57
- var version = "5.0.11";
58
+ var version = "5.0.13-beta.0";
58
59
 
59
60
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
60
61
  var LuzmoService = class {
@@ -356,6 +357,8 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
356
357
  this.browserNotSupported = [];
357
358
  this.VERSION = version + "-wc-luzmo";
358
359
  this.isLibraryLoaded = false;
360
+ this.currentAuthKey = null;
361
+ this.currentAuthToken = null;
359
362
  this.attributesMap = {
360
363
  dashboardId: "dashboard-id",
361
364
  dashboardSlug: "dashboard-slug",
@@ -503,11 +506,10 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
503
506
  this.dashboardReference = oldReference.cloneNode(true);
504
507
  oldReference.replaceWith(this.dashboardReference);
505
508
  this.dashboardReference.addEventListener("load", (payload) => {
506
- setTimeout(() => {
507
- this.containerWidth = this.dashboardReference.offsetWidth;
508
- this.dimensions = payload.detail.dimensions;
509
- SharedLib2._setCalculatedDimensions(this);
510
- });
509
+ this.containerWidth = this.dashboardReference.offsetWidth;
510
+ this.dimensions = payload.detail.dimensions;
511
+ SharedLib2._setCalculatedDimensions(this);
512
+ window.dispatchEvent(new Event("resize"));
511
513
  this.dispatchEvent(new CustomEvent("load", payload));
512
514
  });
513
515
  this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
@@ -687,6 +689,8 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
687
689
  this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
688
690
  defaultParameters.apiHost = this.apiHost;
689
691
  }
692
+ this.currentAuthKey = this.authKey;
693
+ this.currentAuthToken = this.authToken;
690
694
  return defaultParameters;
691
695
  }
692
696
  _updateIframeUrl() {
@@ -843,6 +847,8 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
843
847
  return Promise.reject();
844
848
  }
845
849
  setAuthorization(key, token) {
850
+ this.currentAuthKey = key;
851
+ this.currentAuthToken = token;
846
852
  if (this.getIsViewMode() && this.dashboardReference) {
847
853
  return this.dashboardReference.setAuthorization(key, token);
848
854
  }
@@ -879,13 +885,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
879
885
  return Promise.reject();
880
886
  }
881
887
  getAccessibleDashboards() {
882
- if (!this.getIsViewMode()) {
883
- return SharedLib2.getAccessibleDashboards(this, this.iframe);
884
- }
885
- if (this.getIsViewMode() && this.dashboardReference) {
886
- return this.dashboardReference.getAccessibleDashboards();
887
- }
888
- return Promise.reject();
888
+ return SharedLib2.getAccessibleDashboards(this);
889
889
  }
890
890
  addFilters(itemId, filters) {
891
891
  return this.dashboardReference.addFilters(itemId, filters);
@@ -1081,6 +1081,12 @@ __decorateClass([
1081
1081
  __decorateClass([
1082
1082
  (0, import_decorators.state)()
1083
1083
  ], LuzmoDashboard.prototype, "dashboardReference", 2);
1084
+ __decorateClass([
1085
+ (0, import_decorators.state)()
1086
+ ], LuzmoDashboard.prototype, "currentAuthKey", 2);
1087
+ __decorateClass([
1088
+ (0, import_decorators.state)()
1089
+ ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1084
1090
 
1085
1091
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
1086
1092
  var LuzmoDashboard2 = class extends LuzmoDashboard {
@@ -1088,7 +1094,85 @@ var LuzmoDashboard2 = class extends LuzmoDashboard {
1088
1094
  LuzmoDashboard2 = __decorateClass([
1089
1095
  (0, import_decorators2.customElement)("luzmo-dashboard")
1090
1096
  ], LuzmoDashboard2);
1097
+
1098
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1099
+ var import_decorators3 = require("lit/decorators.js");
1100
+ var import_lit3 = require("lit");
1101
+ var SharedLib3 = __toESM(require("@luzmo/shared-embed"), 1);
1102
+ var LuzmoVizItem = class extends import_lit3.LitElement {
1103
+ constructor() {
1104
+ super();
1105
+ this.appServer = "http://localhost:4201";
1106
+ this.apiHost = "https://api.luzmo.com";
1107
+ this.slots = [];
1108
+ this.options = {
1109
+ title: {
1110
+ en: ""
1111
+ },
1112
+ theme: "default"
1113
+ };
1114
+ SharedLib3.loadLibrary(this.appServer, "DashboardApp").then((lib) => {
1115
+ this.chartElement = document.createElement("chart-component");
1116
+ this.chartElement.setAttribute("embedding-mode", "chart-embedding");
1117
+ this.upadateVizItemProperties();
1118
+ this.renderRoot.append(this.chartElement);
1119
+ });
1120
+ }
1121
+ firstUpdated(_changedProperties) {
1122
+ super.firstUpdated(_changedProperties);
1123
+ }
1124
+ upadateVizItemProperties() {
1125
+ if (this.chartElement) {
1126
+ this.chartElement.setAttribute("app-server", this.appServer);
1127
+ this.chartElement.setAttribute("api-host", this.apiHost);
1128
+ for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
1129
+ if (this[key]) {
1130
+ this.chartElement.setAttribute(
1131
+ SharedLib3.libraryTypeToWebComponentTypeMapping[key],
1132
+ typeof this[key] === "object" ? JSON.stringify(this[key]) : this[key]
1133
+ );
1134
+ }
1135
+ }
1136
+ }
1137
+ }
1138
+ render() {
1139
+ return import_lit3.html``;
1140
+ }
1141
+ };
1142
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1143
+ LuzmoVizItem.styles = import_lit3.css`
1144
+ :host {
1145
+ display: block;
1146
+ width: 100%;
1147
+ height: 100%;
1148
+ }
1149
+ `;
1150
+ __decorateClass([
1151
+ (0, import_decorators3.property)()
1152
+ ], LuzmoVizItem.prototype, "appServer", 2);
1153
+ __decorateClass([
1154
+ (0, import_decorators3.property)()
1155
+ ], LuzmoVizItem.prototype, "apiHost", 2);
1156
+ __decorateClass([
1157
+ (0, import_decorators3.property)({ type: Array })
1158
+ ], LuzmoVizItem.prototype, "slots", 2);
1159
+ __decorateClass([
1160
+ (0, import_decorators3.property)({ type: Object })
1161
+ ], LuzmoVizItem.prototype, "options", 2);
1162
+ __decorateClass([
1163
+ (0, import_decorators3.property)()
1164
+ ], LuzmoVizItem.prototype, "type", 2);
1165
+ __decorateClass([
1166
+ (0, import_decorators3.property)()
1167
+ ], LuzmoVizItem.prototype, "authKey", 2);
1168
+ __decorateClass([
1169
+ (0, import_decorators3.property)()
1170
+ ], LuzmoVizItem.prototype, "authToken", 2);
1171
+ LuzmoVizItem = __decorateClass([
1172
+ (0, import_decorators3.customElement)("luzmo-embed-viz-item")
1173
+ ], LuzmoVizItem);
1091
1174
  // Annotate the CommonJS export names for ESM import in node:
1092
1175
  0 && (module.exports = {
1093
- LuzmoDashboard
1176
+ LuzmoDashboard,
1177
+ LuzmoVizItem
1094
1178
  });
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export type { LoadEvent, ChangedFiltersEvent, CustomEvent, ItemsRenderedEvent, ExportedEvent, DashboardActionEvent, Filter, FilterExpression, FilterOrigin, FilterInput, FilterGroup, ExportType, ItemData, ExportDashboard, AccessibleDashboard, SetEditMode } from '@luzmo/shared-embed';
2
2
  export * from './lib/dashboard-component/dashboard-component';
3
+ export * from './lib/viz-item/viz-item.base';
package/index.js CHANGED
@@ -37,7 +37,7 @@ import {
37
37
  } from "@luzmo/shared-embed";
38
38
 
39
39
  // libs/embed-libs/embed/package.json
40
- var version = "5.0.11";
40
+ var version = "5.0.13-beta.0";
41
41
 
42
42
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
43
43
  var LuzmoService = class {
@@ -339,6 +339,8 @@ var LuzmoDashboard = class extends LitElement {
339
339
  this.browserNotSupported = [];
340
340
  this.VERSION = version + "-wc-luzmo";
341
341
  this.isLibraryLoaded = false;
342
+ this.currentAuthKey = null;
343
+ this.currentAuthToken = null;
342
344
  this.attributesMap = {
343
345
  dashboardId: "dashboard-id",
344
346
  dashboardSlug: "dashboard-slug",
@@ -486,11 +488,10 @@ var LuzmoDashboard = class extends LitElement {
486
488
  this.dashboardReference = oldReference.cloneNode(true);
487
489
  oldReference.replaceWith(this.dashboardReference);
488
490
  this.dashboardReference.addEventListener("load", (payload) => {
489
- setTimeout(() => {
490
- this.containerWidth = this.dashboardReference.offsetWidth;
491
- this.dimensions = payload.detail.dimensions;
492
- SharedLib2._setCalculatedDimensions(this);
493
- });
491
+ this.containerWidth = this.dashboardReference.offsetWidth;
492
+ this.dimensions = payload.detail.dimensions;
493
+ SharedLib2._setCalculatedDimensions(this);
494
+ window.dispatchEvent(new Event("resize"));
494
495
  this.dispatchEvent(new CustomEvent("load", payload));
495
496
  });
496
497
  this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
@@ -670,6 +671,8 @@ var LuzmoDashboard = class extends LitElement {
670
671
  this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
671
672
  defaultParameters.apiHost = this.apiHost;
672
673
  }
674
+ this.currentAuthKey = this.authKey;
675
+ this.currentAuthToken = this.authToken;
673
676
  return defaultParameters;
674
677
  }
675
678
  _updateIframeUrl() {
@@ -826,6 +829,8 @@ var LuzmoDashboard = class extends LitElement {
826
829
  return Promise.reject();
827
830
  }
828
831
  setAuthorization(key, token) {
832
+ this.currentAuthKey = key;
833
+ this.currentAuthToken = token;
829
834
  if (this.getIsViewMode() && this.dashboardReference) {
830
835
  return this.dashboardReference.setAuthorization(key, token);
831
836
  }
@@ -862,13 +867,7 @@ var LuzmoDashboard = class extends LitElement {
862
867
  return Promise.reject();
863
868
  }
864
869
  getAccessibleDashboards() {
865
- if (!this.getIsViewMode()) {
866
- return SharedLib2.getAccessibleDashboards(this, this.iframe);
867
- }
868
- if (this.getIsViewMode() && this.dashboardReference) {
869
- return this.dashboardReference.getAccessibleDashboards();
870
- }
871
- return Promise.reject();
870
+ return SharedLib2.getAccessibleDashboards(this);
872
871
  }
873
872
  addFilters(itemId, filters) {
874
873
  return this.dashboardReference.addFilters(itemId, filters);
@@ -1064,6 +1063,12 @@ __decorateClass([
1064
1063
  __decorateClass([
1065
1064
  state()
1066
1065
  ], LuzmoDashboard.prototype, "dashboardReference", 2);
1066
+ __decorateClass([
1067
+ state()
1068
+ ], LuzmoDashboard.prototype, "currentAuthKey", 2);
1069
+ __decorateClass([
1070
+ state()
1071
+ ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1067
1072
 
1068
1073
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
1069
1074
  var LuzmoDashboard2 = class extends LuzmoDashboard {
@@ -1071,6 +1076,84 @@ var LuzmoDashboard2 = class extends LuzmoDashboard {
1071
1076
  LuzmoDashboard2 = __decorateClass([
1072
1077
  customElement("luzmo-dashboard")
1073
1078
  ], LuzmoDashboard2);
1079
+
1080
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1081
+ import { customElement as customElement2, property as property2 } from "lit/decorators.js";
1082
+ import { LitElement as LitElement2, html as html2, css as css2 } from "lit";
1083
+ import * as SharedLib3 from "@luzmo/shared-embed";
1084
+ var LuzmoVizItem = class extends LitElement2 {
1085
+ constructor() {
1086
+ super();
1087
+ this.appServer = "http://localhost:4201";
1088
+ this.apiHost = "https://api.luzmo.com";
1089
+ this.slots = [];
1090
+ this.options = {
1091
+ title: {
1092
+ en: ""
1093
+ },
1094
+ theme: "default"
1095
+ };
1096
+ SharedLib3.loadLibrary(this.appServer, "DashboardApp").then((lib) => {
1097
+ this.chartElement = document.createElement("chart-component");
1098
+ this.chartElement.setAttribute("embedding-mode", "chart-embedding");
1099
+ this.upadateVizItemProperties();
1100
+ this.renderRoot.append(this.chartElement);
1101
+ });
1102
+ }
1103
+ firstUpdated(_changedProperties) {
1104
+ super.firstUpdated(_changedProperties);
1105
+ }
1106
+ upadateVizItemProperties() {
1107
+ if (this.chartElement) {
1108
+ this.chartElement.setAttribute("app-server", this.appServer);
1109
+ this.chartElement.setAttribute("api-host", this.apiHost);
1110
+ for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
1111
+ if (this[key]) {
1112
+ this.chartElement.setAttribute(
1113
+ SharedLib3.libraryTypeToWebComponentTypeMapping[key],
1114
+ typeof this[key] === "object" ? JSON.stringify(this[key]) : this[key]
1115
+ );
1116
+ }
1117
+ }
1118
+ }
1119
+ }
1120
+ render() {
1121
+ return html2``;
1122
+ }
1123
+ };
1124
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1125
+ LuzmoVizItem.styles = css2`
1126
+ :host {
1127
+ display: block;
1128
+ width: 100%;
1129
+ height: 100%;
1130
+ }
1131
+ `;
1132
+ __decorateClass([
1133
+ property2()
1134
+ ], LuzmoVizItem.prototype, "appServer", 2);
1135
+ __decorateClass([
1136
+ property2()
1137
+ ], LuzmoVizItem.prototype, "apiHost", 2);
1138
+ __decorateClass([
1139
+ property2({ type: Array })
1140
+ ], LuzmoVizItem.prototype, "slots", 2);
1141
+ __decorateClass([
1142
+ property2({ type: Object })
1143
+ ], LuzmoVizItem.prototype, "options", 2);
1144
+ __decorateClass([
1145
+ property2()
1146
+ ], LuzmoVizItem.prototype, "type", 2);
1147
+ __decorateClass([
1148
+ property2()
1149
+ ], LuzmoVizItem.prototype, "authKey", 2);
1150
+ __decorateClass([
1151
+ property2()
1152
+ ], LuzmoVizItem.prototype, "authToken", 2);
1153
+ LuzmoVizItem = __decorateClass([
1154
+ customElement2("luzmo-embed-viz-item")
1155
+ ], LuzmoVizItem);
1074
1156
  export {
1075
- LuzmoDashboard2 as LuzmoDashboard
1157
+ LuzmoDashboard2 as LuzmoDashboard,
1158
+ LuzmoVizItem
1076
1159
  };
package/index.libs.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './lib/dashboard-component/dashboard-web-component';
2
+ export * from './lib/viz-item/viz-item.base';
@@ -54,6 +54,8 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
54
54
  VERSION: string;
55
55
  protected isLibraryLoaded: boolean;
56
56
  protected dashboardReference: SharedLib.LuzmoElement;
57
+ currentAuthKey: string;
58
+ currentAuthToken: string;
57
59
  private attributesMap;
58
60
  _loadTimeoutHandle?: number;
59
61
  _onResize: () => void;
@@ -0,0 +1,17 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import * as SharedLib from '@luzmo/shared-embed';
3
+ export declare class LuzmoVizItem extends LitElement {
4
+ appServer: string;
5
+ apiHost: string;
6
+ slots: SharedLib.Slots;
7
+ options: SharedLib.VizItemOptions;
8
+ type?: SharedLib.ItemType;
9
+ authKey?: string;
10
+ authToken?: string;
11
+ chartElement: HTMLElement;
12
+ static styles: import("lit").CSSResult;
13
+ constructor();
14
+ protected firstUpdated(_changedProperties: PropertyValues): void;
15
+ private upadateVizItemProperties;
16
+ protected render(): unknown;
17
+ }
@@ -42,7 +42,8 @@ var __decorateClass = (decorators, target, key, kind) => {
42
42
  // libs/embed-libs/embed/src/index.libs.ts
43
43
  var index_libs_exports = {};
44
44
  __export(index_libs_exports, {
45
- LuzmoDashboardWebComponent: () => LuzmoDashboardWebComponent
45
+ LuzmoDashboardWebComponent: () => LuzmoDashboardWebComponent,
46
+ LuzmoVizItem: () => LuzmoVizItem
46
47
  });
47
48
  module.exports = __toCommonJS(index_libs_exports);
48
49
 
@@ -912,128 +913,108 @@ var exportDashboard = (dashboardComponent, iframe, format) => {
912
913
  };
913
914
 
914
915
  // libs/embed-libs/shared-embed/src/lib/methods/get-accessible-dashboards.ts
915
- var getAccessibleDashboards = (dashboardComponent, iframe) => {
916
- if ((dashboardComponent.dashboardId || dashboardComponent.dashboardSlug) && iframe?.contentWindow) {
917
- const requestId = uuidv4();
918
- iframe.contentWindow.postMessage(
919
- {
920
- action: "getAccessibleDashboards",
921
- _version: dashboardComponent.VERSION,
922
- requestId
923
- },
924
- "*"
925
- );
926
- return new Promise((resolve, reject) => {
927
- dashboardComponent.promises[requestId] = { resolve, reject };
928
- setTimeout(() => {
929
- if (dashboardComponent.promises[requestId]) {
930
- const errorMessage = "getAccessibleDashboards request timed out.";
931
- dashboardComponent.promises[requestId].reject(
932
- new Error(errorMessage)
916
+ var getAccessibleDashboards = (dashboardComponent) => {
917
+ if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
918
+ const fetchUser = new Promise((resolve, reject) => {
919
+ void (() => {
920
+ try {
921
+ const responsePromise = window.fetch(
922
+ `${String(dashboardComponent.params.apiHost)}0.1.0/authorization`,
923
+ {
924
+ method: "POST",
925
+ mode: "cors",
926
+ cache: "no-cache",
927
+ headers: { "Content-Type": "application/json" },
928
+ redirect: "follow",
929
+ body: JSON.stringify({
930
+ action: "get",
931
+ version: "0.1.0",
932
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
933
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
934
+ find: {
935
+ where: { id: dashboardComponent.authKey },
936
+ attributes: ["id", "integration_id"],
937
+ include: [
938
+ {
939
+ model: "User",
940
+ attributes: ["id", "name", "locale_id"],
941
+ include: [{ model: "Group" }]
942
+ }
943
+ ]
944
+ }
945
+ })
946
+ }
933
947
  );
934
- delete dashboardComponent.promises[requestId];
948
+ responsePromise.then((response) => response.json()).then((data) => {
949
+ if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user) {
950
+ reject("Authorization failed, please check authKey and authToken. If the problem persists, please contact support@luzmo.com.");
951
+ } else {
952
+ data.rows[0].user.userGroups = data.rows[0].user.groups.map(
953
+ (group) => group.id
954
+ );
955
+ delete data.rows[0].user.groups;
956
+ resolve({
957
+ integrationId: data.rows[0].integration_id,
958
+ user: data.rows[0].user
959
+ });
960
+ }
961
+ });
962
+ } catch (error) {
963
+ reject(error);
935
964
  }
936
- }, 2e3);
965
+ })();
937
966
  });
938
- }
939
- const fetchUser = new Promise((resolve, reject) => {
940
- void (() => {
967
+ return new Promise((resolve, reject) => void (() => {
941
968
  try {
942
- const responsePromise = window.fetch(
943
- `${String(dashboardComponent.params.apiHost)}0.1.0/authorization`,
944
- {
945
- method: "POST",
946
- mode: "cors",
947
- cache: "no-cache",
948
- headers: { "Content-Type": "application/json" },
949
- redirect: "follow",
950
- body: JSON.stringify({
951
- action: "get",
952
- version: "0.1.0",
953
- key: dashboardComponent.authKey,
954
- token: dashboardComponent.authToken,
955
- find: {
956
- where: { id: dashboardComponent.authKey },
957
- attributes: ["id", "integration_id"],
958
- include: [
959
- {
960
- model: "User",
961
- attributes: ["id", "name", "locale_id"],
962
- include: [{ model: "Group" }]
963
- }
964
- ]
965
- }
966
- })
967
- }
968
- );
969
- responsePromise.then((response) => response.json()).then((data) => {
970
- if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user || !data.rows[0].integration_id) {
971
- reject();
972
- } else {
973
- data.rows[0].user.userGroups = data.rows[0].user.groups.map(
974
- (group) => group.id
975
- );
976
- delete data.rows[0].user.groups;
977
- resolve({
978
- integrationId: data.rows[0].integration_id,
979
- user: data.rows[0].user
980
- });
981
- }
969
+ fetchUser.then((authorizationData) => {
970
+ const responsePromise = window.fetch(
971
+ `${String(dashboardComponent.params.apiHost)}0.1.0/securable`,
972
+ {
973
+ method: "POST",
974
+ mode: "cors",
975
+ cache: "no-cache",
976
+ headers: { "Content-Type": "application/json" },
977
+ redirect: "follow",
978
+ body: JSON.stringify({
979
+ action: "get",
980
+ version: "0.1.0",
981
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
982
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
983
+ find: {
984
+ where: { type: "dashboard", is_variant: false },
985
+ attributes: ["id", "name", "modified_at"],
986
+ order: [["modified_at", "desc"]],
987
+ include: [
988
+ { model: "Tag", attributes: ["tag"] },
989
+ { model: "User", attributes: ["id", "name"] },
990
+ {
991
+ model: "Group",
992
+ attributes: ["id", "name", "public"]
993
+ },
994
+ { model: "Integration", attributes: ["id", "name"] }
995
+ ]
996
+ }
997
+ })
998
+ }
999
+ );
1000
+ responsePromise.then((response) => response.json()).then((data) => {
1001
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
1002
+ data.rows,
1003
+ authorizationData.integrationId,
1004
+ authorizationData.user,
1005
+ dashboardComponent
1006
+ ) : [];
1007
+ resolve(dashboardList);
1008
+ });
1009
+ }).catch((error) => {
1010
+ reject(error);
982
1011
  });
983
1012
  } catch (error) {
984
1013
  reject(error);
985
1014
  }
986
- })();
987
- });
988
- return new Promise((resolve, reject) => void (() => {
989
- try {
990
- fetchUser.then((authorizationData) => {
991
- const responsePromise = window.fetch(
992
- `${String(dashboardComponent.params.apiHost)}0.1.0/securable`,
993
- {
994
- method: "POST",
995
- mode: "cors",
996
- cache: "no-cache",
997
- headers: { "Content-Type": "application/json" },
998
- redirect: "follow",
999
- body: JSON.stringify({
1000
- action: "get",
1001
- version: "0.1.0",
1002
- key: dashboardComponent.authKey,
1003
- token: dashboardComponent.authToken,
1004
- find: {
1005
- where: { type: "dashboard", is_variant: false },
1006
- attributes: ["id", "name", "modified_at"],
1007
- order: [["modified_at", "desc"]],
1008
- include: [
1009
- { model: "Tag", attributes: ["tag"] },
1010
- { model: "User", attributes: ["id", "name"] },
1011
- {
1012
- model: "Group",
1013
- attributes: ["id", "name", "public"]
1014
- },
1015
- { model: "Integration", attributes: ["id", "name"] }
1016
- ]
1017
- }
1018
- })
1019
- }
1020
- );
1021
- responsePromise.then((response) => response.json()).then((data) => {
1022
- const dashboardList = data.rows.length > 0 ? formatDashboardList(
1023
- data.rows,
1024
- authorizationData.integrationId,
1025
- authorizationData.user,
1026
- dashboardComponent
1027
- ) : [];
1028
- resolve(dashboardList);
1029
- });
1030
- }).catch((error) => {
1031
- reject(error);
1032
- });
1033
- } catch (error) {
1034
- reject(error);
1035
- }
1036
- })());
1015
+ })());
1016
+ }
1017
+ throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
1037
1018
  };
1038
1019
 
1039
1020
  // libs/embed-libs/shared-embed/src/lib/methods/get-data.ts
@@ -1505,6 +1486,19 @@ var _extendAndValidate = (dashboardContent) => {
1505
1486
  }
1506
1487
  };
1507
1488
 
1489
+ // libs/embed-libs/shared-embed/src/lib/models/viz-item.model.ts
1490
+ var libraryTypeToWebComponentTypeMapping = {
1491
+ type: "type",
1492
+ theme: "theme",
1493
+ slots: "slots",
1494
+ options: "options",
1495
+ itemId: "chart-id",
1496
+ appServer: "app-server",
1497
+ apiHost: "api-host",
1498
+ authKey: "auth-key",
1499
+ authToken: "auth-token"
1500
+ };
1501
+
1508
1502
  // libs/embed-libs/shared-embed/src/lib/constants/class-constants.ts
1509
1503
  var luzmoEmbedContainerClass = "luzmo-embed-container";
1510
1504
 
@@ -1572,6 +1566,16 @@ function __federationMethodWrapDefault(module2, need) {
1572
1566
  async function __federationMethodGetRemote(remoteName, componentName) {
1573
1567
  return __federationMethodEnsure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
1574
1568
  }
1569
+ async function loadLibrary(appServer, componentName) {
1570
+ if (remotesMap[appServer]) {
1571
+ return remotesMap[appServer].module;
1572
+ }
1573
+ remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
1574
+ const module2 = await __federationMethodGetRemote(appServer, `./${componentName}`);
1575
+ const wrappedModule = __federationMethodWrapDefault(module2, true);
1576
+ remotesMap[appServer].module = wrappedModule;
1577
+ return wrappedModule;
1578
+ }
1575
1579
 
1576
1580
  // node_modules/lit-html/lit-html.js
1577
1581
  var t3 = globalThis;
@@ -1922,7 +1926,7 @@ var o5 = e6(class extends i4 {
1922
1926
  });
1923
1927
 
1924
1928
  // libs/embed-libs/embed/package.json
1925
- var version = "5.0.11";
1929
+ var version = "5.0.13-beta.0";
1926
1930
 
1927
1931
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
1928
1932
  var LuzmoService = class {
@@ -2222,6 +2226,8 @@ var LuzmoDashboard = class extends s3 {
2222
2226
  this.browserNotSupported = [];
2223
2227
  this.VERSION = version + "-wc-luzmo";
2224
2228
  this.isLibraryLoaded = false;
2229
+ this.currentAuthKey = null;
2230
+ this.currentAuthToken = null;
2225
2231
  this.attributesMap = {
2226
2232
  dashboardId: "dashboard-id",
2227
2233
  dashboardSlug: "dashboard-slug",
@@ -2369,11 +2375,10 @@ var LuzmoDashboard = class extends s3 {
2369
2375
  this.dashboardReference = oldReference.cloneNode(true);
2370
2376
  oldReference.replaceWith(this.dashboardReference);
2371
2377
  this.dashboardReference.addEventListener("load", (payload) => {
2372
- setTimeout(() => {
2373
- this.containerWidth = this.dashboardReference.offsetWidth;
2374
- this.dimensions = payload.detail.dimensions;
2375
- _setCalculatedDimensions(this);
2376
- });
2378
+ this.containerWidth = this.dashboardReference.offsetWidth;
2379
+ this.dimensions = payload.detail.dimensions;
2380
+ _setCalculatedDimensions(this);
2381
+ window.dispatchEvent(new Event("resize"));
2377
2382
  this.dispatchEvent(new CustomEvent("load", payload));
2378
2383
  });
2379
2384
  this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
@@ -2553,6 +2558,8 @@ var LuzmoDashboard = class extends s3 {
2553
2558
  this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
2554
2559
  defaultParameters.apiHost = this.apiHost;
2555
2560
  }
2561
+ this.currentAuthKey = this.authKey;
2562
+ this.currentAuthToken = this.authToken;
2556
2563
  return defaultParameters;
2557
2564
  }
2558
2565
  _updateIframeUrl() {
@@ -2709,6 +2716,8 @@ var LuzmoDashboard = class extends s3 {
2709
2716
  return Promise.reject();
2710
2717
  }
2711
2718
  setAuthorization(key, token) {
2719
+ this.currentAuthKey = key;
2720
+ this.currentAuthToken = token;
2712
2721
  if (this.getIsViewMode() && this.dashboardReference) {
2713
2722
  return this.dashboardReference.setAuthorization(key, token);
2714
2723
  }
@@ -2745,13 +2754,7 @@ var LuzmoDashboard = class extends s3 {
2745
2754
  return Promise.reject();
2746
2755
  }
2747
2756
  getAccessibleDashboards() {
2748
- if (!this.getIsViewMode()) {
2749
- return getAccessibleDashboards(this, this.iframe);
2750
- }
2751
- if (this.getIsViewMode() && this.dashboardReference) {
2752
- return this.dashboardReference.getAccessibleDashboards();
2753
- }
2754
- return Promise.reject();
2757
+ return getAccessibleDashboards(this);
2755
2758
  }
2756
2759
  addFilters(itemId, filters) {
2757
2760
  return this.dashboardReference.addFilters(itemId, filters);
@@ -2947,6 +2950,12 @@ __decorateClass([
2947
2950
  __decorateClass([
2948
2951
  r4()
2949
2952
  ], LuzmoDashboard.prototype, "dashboardReference", 2);
2953
+ __decorateClass([
2954
+ r4()
2955
+ ], LuzmoDashboard.prototype, "currentAuthKey", 2);
2956
+ __decorateClass([
2957
+ r4()
2958
+ ], LuzmoDashboard.prototype, "currentAuthToken", 2);
2950
2959
 
2951
2960
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
2952
2961
  var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
@@ -2954,6 +2963,80 @@ var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
2954
2963
  LuzmoDashboardWebComponent = __decorateClass([
2955
2964
  t("luzmo-dashboard-web-component")
2956
2965
  ], LuzmoDashboardWebComponent);
2966
+
2967
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
2968
+ var LuzmoVizItem = class extends s3 {
2969
+ constructor() {
2970
+ super();
2971
+ this.appServer = "http://localhost:4201";
2972
+ this.apiHost = "https://api.luzmo.com";
2973
+ this.slots = [];
2974
+ this.options = {
2975
+ title: {
2976
+ en: ""
2977
+ },
2978
+ theme: "default"
2979
+ };
2980
+ loadLibrary(this.appServer, "DashboardApp").then((lib) => {
2981
+ this.chartElement = document.createElement("chart-component");
2982
+ this.chartElement.setAttribute("embedding-mode", "chart-embedding");
2983
+ this.upadateVizItemProperties();
2984
+ this.renderRoot.append(this.chartElement);
2985
+ });
2986
+ }
2987
+ firstUpdated(_changedProperties) {
2988
+ super.firstUpdated(_changedProperties);
2989
+ }
2990
+ upadateVizItemProperties() {
2991
+ if (this.chartElement) {
2992
+ this.chartElement.setAttribute("app-server", this.appServer);
2993
+ this.chartElement.setAttribute("api-host", this.apiHost);
2994
+ for (const key in libraryTypeToWebComponentTypeMapping) {
2995
+ if (this[key]) {
2996
+ this.chartElement.setAttribute(
2997
+ libraryTypeToWebComponentTypeMapping[key],
2998
+ typeof this[key] === "object" ? JSON.stringify(this[key]) : this[key]
2999
+ );
3000
+ }
3001
+ }
3002
+ }
3003
+ }
3004
+ render() {
3005
+ return x``;
3006
+ }
3007
+ };
3008
+ // Static styles to set host display to block, else it is not shown at all for some reason.
3009
+ LuzmoVizItem.styles = i`
3010
+ :host {
3011
+ display: block;
3012
+ width: 100%;
3013
+ height: 100%;
3014
+ }
3015
+ `;
3016
+ __decorateClass([
3017
+ n3()
3018
+ ], LuzmoVizItem.prototype, "appServer", 2);
3019
+ __decorateClass([
3020
+ n3()
3021
+ ], LuzmoVizItem.prototype, "apiHost", 2);
3022
+ __decorateClass([
3023
+ n3({ type: Array })
3024
+ ], LuzmoVizItem.prototype, "slots", 2);
3025
+ __decorateClass([
3026
+ n3({ type: Object })
3027
+ ], LuzmoVizItem.prototype, "options", 2);
3028
+ __decorateClass([
3029
+ n3()
3030
+ ], LuzmoVizItem.prototype, "type", 2);
3031
+ __decorateClass([
3032
+ n3()
3033
+ ], LuzmoVizItem.prototype, "authKey", 2);
3034
+ __decorateClass([
3035
+ n3()
3036
+ ], LuzmoVizItem.prototype, "authToken", 2);
3037
+ LuzmoVizItem = __decorateClass([
3038
+ t("luzmo-embed-viz-item")
3039
+ ], LuzmoVizItem);
2957
3040
  /*! Bundled license information:
2958
3041
 
2959
3042
  @lit/reactive-element/decorators/custom-element.js:
@@ -42,7 +42,8 @@ var __decorateClass = (decorators, target, key, kind) => {
42
42
  // libs/embed-libs/embed/src/index.ts
43
43
  var src_exports2 = {};
44
44
  __export(src_exports2, {
45
- LuzmoDashboard: () => LuzmoDashboard2
45
+ LuzmoDashboard: () => LuzmoDashboard2,
46
+ LuzmoVizItem: () => LuzmoVizItem
46
47
  });
47
48
  module.exports = __toCommonJS(src_exports2);
48
49
 
@@ -912,128 +913,108 @@ var exportDashboard = (dashboardComponent, iframe, format) => {
912
913
  };
913
914
 
914
915
  // libs/embed-libs/shared-embed/src/lib/methods/get-accessible-dashboards.ts
915
- var getAccessibleDashboards = (dashboardComponent, iframe) => {
916
- if ((dashboardComponent.dashboardId || dashboardComponent.dashboardSlug) && iframe?.contentWindow) {
917
- const requestId = uuidv4();
918
- iframe.contentWindow.postMessage(
919
- {
920
- action: "getAccessibleDashboards",
921
- _version: dashboardComponent.VERSION,
922
- requestId
923
- },
924
- "*"
925
- );
926
- return new Promise((resolve, reject) => {
927
- dashboardComponent.promises[requestId] = { resolve, reject };
928
- setTimeout(() => {
929
- if (dashboardComponent.promises[requestId]) {
930
- const errorMessage = "getAccessibleDashboards request timed out.";
931
- dashboardComponent.promises[requestId].reject(
932
- new Error(errorMessage)
916
+ var getAccessibleDashboards = (dashboardComponent) => {
917
+ if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
918
+ const fetchUser = new Promise((resolve, reject) => {
919
+ void (() => {
920
+ try {
921
+ const responsePromise = window.fetch(
922
+ `${String(dashboardComponent.params.apiHost)}0.1.0/authorization`,
923
+ {
924
+ method: "POST",
925
+ mode: "cors",
926
+ cache: "no-cache",
927
+ headers: { "Content-Type": "application/json" },
928
+ redirect: "follow",
929
+ body: JSON.stringify({
930
+ action: "get",
931
+ version: "0.1.0",
932
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
933
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
934
+ find: {
935
+ where: { id: dashboardComponent.authKey },
936
+ attributes: ["id", "integration_id"],
937
+ include: [
938
+ {
939
+ model: "User",
940
+ attributes: ["id", "name", "locale_id"],
941
+ include: [{ model: "Group" }]
942
+ }
943
+ ]
944
+ }
945
+ })
946
+ }
933
947
  );
934
- delete dashboardComponent.promises[requestId];
948
+ responsePromise.then((response) => response.json()).then((data) => {
949
+ if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user) {
950
+ reject("Authorization failed, please check authKey and authToken. If the problem persists, please contact support@luzmo.com.");
951
+ } else {
952
+ data.rows[0].user.userGroups = data.rows[0].user.groups.map(
953
+ (group) => group.id
954
+ );
955
+ delete data.rows[0].user.groups;
956
+ resolve({
957
+ integrationId: data.rows[0].integration_id,
958
+ user: data.rows[0].user
959
+ });
960
+ }
961
+ });
962
+ } catch (error) {
963
+ reject(error);
935
964
  }
936
- }, 2e3);
965
+ })();
937
966
  });
938
- }
939
- const fetchUser = new Promise((resolve, reject) => {
940
- void (() => {
967
+ return new Promise((resolve, reject) => void (() => {
941
968
  try {
942
- const responsePromise = window.fetch(
943
- `${String(dashboardComponent.params.apiHost)}0.1.0/authorization`,
944
- {
945
- method: "POST",
946
- mode: "cors",
947
- cache: "no-cache",
948
- headers: { "Content-Type": "application/json" },
949
- redirect: "follow",
950
- body: JSON.stringify({
951
- action: "get",
952
- version: "0.1.0",
953
- key: dashboardComponent.authKey,
954
- token: dashboardComponent.authToken,
955
- find: {
956
- where: { id: dashboardComponent.authKey },
957
- attributes: ["id", "integration_id"],
958
- include: [
959
- {
960
- model: "User",
961
- attributes: ["id", "name", "locale_id"],
962
- include: [{ model: "Group" }]
963
- }
964
- ]
965
- }
966
- })
967
- }
968
- );
969
- responsePromise.then((response) => response.json()).then((data) => {
970
- if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user || !data.rows[0].integration_id) {
971
- reject();
972
- } else {
973
- data.rows[0].user.userGroups = data.rows[0].user.groups.map(
974
- (group) => group.id
975
- );
976
- delete data.rows[0].user.groups;
977
- resolve({
978
- integrationId: data.rows[0].integration_id,
979
- user: data.rows[0].user
980
- });
981
- }
969
+ fetchUser.then((authorizationData) => {
970
+ const responsePromise = window.fetch(
971
+ `${String(dashboardComponent.params.apiHost)}0.1.0/securable`,
972
+ {
973
+ method: "POST",
974
+ mode: "cors",
975
+ cache: "no-cache",
976
+ headers: { "Content-Type": "application/json" },
977
+ redirect: "follow",
978
+ body: JSON.stringify({
979
+ action: "get",
980
+ version: "0.1.0",
981
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
982
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
983
+ find: {
984
+ where: { type: "dashboard", is_variant: false },
985
+ attributes: ["id", "name", "modified_at"],
986
+ order: [["modified_at", "desc"]],
987
+ include: [
988
+ { model: "Tag", attributes: ["tag"] },
989
+ { model: "User", attributes: ["id", "name"] },
990
+ {
991
+ model: "Group",
992
+ attributes: ["id", "name", "public"]
993
+ },
994
+ { model: "Integration", attributes: ["id", "name"] }
995
+ ]
996
+ }
997
+ })
998
+ }
999
+ );
1000
+ responsePromise.then((response) => response.json()).then((data) => {
1001
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
1002
+ data.rows,
1003
+ authorizationData.integrationId,
1004
+ authorizationData.user,
1005
+ dashboardComponent
1006
+ ) : [];
1007
+ resolve(dashboardList);
1008
+ });
1009
+ }).catch((error) => {
1010
+ reject(error);
982
1011
  });
983
1012
  } catch (error) {
984
1013
  reject(error);
985
1014
  }
986
- })();
987
- });
988
- return new Promise((resolve, reject) => void (() => {
989
- try {
990
- fetchUser.then((authorizationData) => {
991
- const responsePromise = window.fetch(
992
- `${String(dashboardComponent.params.apiHost)}0.1.0/securable`,
993
- {
994
- method: "POST",
995
- mode: "cors",
996
- cache: "no-cache",
997
- headers: { "Content-Type": "application/json" },
998
- redirect: "follow",
999
- body: JSON.stringify({
1000
- action: "get",
1001
- version: "0.1.0",
1002
- key: dashboardComponent.authKey,
1003
- token: dashboardComponent.authToken,
1004
- find: {
1005
- where: { type: "dashboard", is_variant: false },
1006
- attributes: ["id", "name", "modified_at"],
1007
- order: [["modified_at", "desc"]],
1008
- include: [
1009
- { model: "Tag", attributes: ["tag"] },
1010
- { model: "User", attributes: ["id", "name"] },
1011
- {
1012
- model: "Group",
1013
- attributes: ["id", "name", "public"]
1014
- },
1015
- { model: "Integration", attributes: ["id", "name"] }
1016
- ]
1017
- }
1018
- })
1019
- }
1020
- );
1021
- responsePromise.then((response) => response.json()).then((data) => {
1022
- const dashboardList = data.rows.length > 0 ? formatDashboardList(
1023
- data.rows,
1024
- authorizationData.integrationId,
1025
- authorizationData.user,
1026
- dashboardComponent
1027
- ) : [];
1028
- resolve(dashboardList);
1029
- });
1030
- }).catch((error) => {
1031
- reject(error);
1032
- });
1033
- } catch (error) {
1034
- reject(error);
1035
- }
1036
- })());
1015
+ })());
1016
+ }
1017
+ throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
1037
1018
  };
1038
1019
 
1039
1020
  // libs/embed-libs/shared-embed/src/lib/methods/get-data.ts
@@ -1505,6 +1486,19 @@ var _extendAndValidate = (dashboardContent) => {
1505
1486
  }
1506
1487
  };
1507
1488
 
1489
+ // libs/embed-libs/shared-embed/src/lib/models/viz-item.model.ts
1490
+ var libraryTypeToWebComponentTypeMapping = {
1491
+ type: "type",
1492
+ theme: "theme",
1493
+ slots: "slots",
1494
+ options: "options",
1495
+ itemId: "chart-id",
1496
+ appServer: "app-server",
1497
+ apiHost: "api-host",
1498
+ authKey: "auth-key",
1499
+ authToken: "auth-token"
1500
+ };
1501
+
1508
1502
  // libs/embed-libs/shared-embed/src/lib/constants/class-constants.ts
1509
1503
  var luzmoEmbedContainerClass = "luzmo-embed-container";
1510
1504
 
@@ -1572,6 +1566,16 @@ function __federationMethodWrapDefault(module2, need) {
1572
1566
  async function __federationMethodGetRemote(remoteName, componentName) {
1573
1567
  return __federationMethodEnsure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
1574
1568
  }
1569
+ async function loadLibrary(appServer, componentName) {
1570
+ if (remotesMap[appServer]) {
1571
+ return remotesMap[appServer].module;
1572
+ }
1573
+ remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
1574
+ const module2 = await __federationMethodGetRemote(appServer, `./${componentName}`);
1575
+ const wrappedModule = __federationMethodWrapDefault(module2, true);
1576
+ remotesMap[appServer].module = wrappedModule;
1577
+ return wrappedModule;
1578
+ }
1575
1579
 
1576
1580
  // node_modules/lit-html/lit-html.js
1577
1581
  var t3 = globalThis;
@@ -1922,7 +1926,7 @@ var o5 = e6(class extends i4 {
1922
1926
  });
1923
1927
 
1924
1928
  // libs/embed-libs/embed/package.json
1925
- var version = "5.0.11";
1929
+ var version = "5.0.13-beta.0";
1926
1930
 
1927
1931
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
1928
1932
  var LuzmoService = class {
@@ -2222,6 +2226,8 @@ var LuzmoDashboard = class extends s3 {
2222
2226
  this.browserNotSupported = [];
2223
2227
  this.VERSION = version + "-wc-luzmo";
2224
2228
  this.isLibraryLoaded = false;
2229
+ this.currentAuthKey = null;
2230
+ this.currentAuthToken = null;
2225
2231
  this.attributesMap = {
2226
2232
  dashboardId: "dashboard-id",
2227
2233
  dashboardSlug: "dashboard-slug",
@@ -2369,11 +2375,10 @@ var LuzmoDashboard = class extends s3 {
2369
2375
  this.dashboardReference = oldReference.cloneNode(true);
2370
2376
  oldReference.replaceWith(this.dashboardReference);
2371
2377
  this.dashboardReference.addEventListener("load", (payload) => {
2372
- setTimeout(() => {
2373
- this.containerWidth = this.dashboardReference.offsetWidth;
2374
- this.dimensions = payload.detail.dimensions;
2375
- _setCalculatedDimensions(this);
2376
- });
2378
+ this.containerWidth = this.dashboardReference.offsetWidth;
2379
+ this.dimensions = payload.detail.dimensions;
2380
+ _setCalculatedDimensions(this);
2381
+ window.dispatchEvent(new Event("resize"));
2377
2382
  this.dispatchEvent(new CustomEvent("load", payload));
2378
2383
  });
2379
2384
  this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
@@ -2553,6 +2558,8 @@ var LuzmoDashboard = class extends s3 {
2553
2558
  this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
2554
2559
  defaultParameters.apiHost = this.apiHost;
2555
2560
  }
2561
+ this.currentAuthKey = this.authKey;
2562
+ this.currentAuthToken = this.authToken;
2556
2563
  return defaultParameters;
2557
2564
  }
2558
2565
  _updateIframeUrl() {
@@ -2709,6 +2716,8 @@ var LuzmoDashboard = class extends s3 {
2709
2716
  return Promise.reject();
2710
2717
  }
2711
2718
  setAuthorization(key, token) {
2719
+ this.currentAuthKey = key;
2720
+ this.currentAuthToken = token;
2712
2721
  if (this.getIsViewMode() && this.dashboardReference) {
2713
2722
  return this.dashboardReference.setAuthorization(key, token);
2714
2723
  }
@@ -2745,13 +2754,7 @@ var LuzmoDashboard = class extends s3 {
2745
2754
  return Promise.reject();
2746
2755
  }
2747
2756
  getAccessibleDashboards() {
2748
- if (!this.getIsViewMode()) {
2749
- return getAccessibleDashboards(this, this.iframe);
2750
- }
2751
- if (this.getIsViewMode() && this.dashboardReference) {
2752
- return this.dashboardReference.getAccessibleDashboards();
2753
- }
2754
- return Promise.reject();
2757
+ return getAccessibleDashboards(this);
2755
2758
  }
2756
2759
  addFilters(itemId, filters) {
2757
2760
  return this.dashboardReference.addFilters(itemId, filters);
@@ -2947,6 +2950,12 @@ __decorateClass([
2947
2950
  __decorateClass([
2948
2951
  r4()
2949
2952
  ], LuzmoDashboard.prototype, "dashboardReference", 2);
2953
+ __decorateClass([
2954
+ r4()
2955
+ ], LuzmoDashboard.prototype, "currentAuthKey", 2);
2956
+ __decorateClass([
2957
+ r4()
2958
+ ], LuzmoDashboard.prototype, "currentAuthToken", 2);
2950
2959
 
2951
2960
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
2952
2961
  var LuzmoDashboard2 = class extends LuzmoDashboard {
@@ -2954,6 +2963,80 @@ var LuzmoDashboard2 = class extends LuzmoDashboard {
2954
2963
  LuzmoDashboard2 = __decorateClass([
2955
2964
  t("luzmo-dashboard")
2956
2965
  ], LuzmoDashboard2);
2966
+
2967
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
2968
+ var LuzmoVizItem = class extends s3 {
2969
+ constructor() {
2970
+ super();
2971
+ this.appServer = "http://localhost:4201";
2972
+ this.apiHost = "https://api.luzmo.com";
2973
+ this.slots = [];
2974
+ this.options = {
2975
+ title: {
2976
+ en: ""
2977
+ },
2978
+ theme: "default"
2979
+ };
2980
+ loadLibrary(this.appServer, "DashboardApp").then((lib) => {
2981
+ this.chartElement = document.createElement("chart-component");
2982
+ this.chartElement.setAttribute("embedding-mode", "chart-embedding");
2983
+ this.upadateVizItemProperties();
2984
+ this.renderRoot.append(this.chartElement);
2985
+ });
2986
+ }
2987
+ firstUpdated(_changedProperties) {
2988
+ super.firstUpdated(_changedProperties);
2989
+ }
2990
+ upadateVizItemProperties() {
2991
+ if (this.chartElement) {
2992
+ this.chartElement.setAttribute("app-server", this.appServer);
2993
+ this.chartElement.setAttribute("api-host", this.apiHost);
2994
+ for (const key in libraryTypeToWebComponentTypeMapping) {
2995
+ if (this[key]) {
2996
+ this.chartElement.setAttribute(
2997
+ libraryTypeToWebComponentTypeMapping[key],
2998
+ typeof this[key] === "object" ? JSON.stringify(this[key]) : this[key]
2999
+ );
3000
+ }
3001
+ }
3002
+ }
3003
+ }
3004
+ render() {
3005
+ return x``;
3006
+ }
3007
+ };
3008
+ // Static styles to set host display to block, else it is not shown at all for some reason.
3009
+ LuzmoVizItem.styles = i`
3010
+ :host {
3011
+ display: block;
3012
+ width: 100%;
3013
+ height: 100%;
3014
+ }
3015
+ `;
3016
+ __decorateClass([
3017
+ n3()
3018
+ ], LuzmoVizItem.prototype, "appServer", 2);
3019
+ __decorateClass([
3020
+ n3()
3021
+ ], LuzmoVizItem.prototype, "apiHost", 2);
3022
+ __decorateClass([
3023
+ n3({ type: Array })
3024
+ ], LuzmoVizItem.prototype, "slots", 2);
3025
+ __decorateClass([
3026
+ n3({ type: Object })
3027
+ ], LuzmoVizItem.prototype, "options", 2);
3028
+ __decorateClass([
3029
+ n3()
3030
+ ], LuzmoVizItem.prototype, "type", 2);
3031
+ __decorateClass([
3032
+ n3()
3033
+ ], LuzmoVizItem.prototype, "authKey", 2);
3034
+ __decorateClass([
3035
+ n3()
3036
+ ], LuzmoVizItem.prototype, "authToken", 2);
3037
+ LuzmoVizItem = __decorateClass([
3038
+ t("luzmo-embed-viz-item")
3039
+ ], LuzmoVizItem);
2957
3040
  /*! Bundled license information:
2958
3041
 
2959
3042
  @lit/reactive-element/decorators/custom-element.js:
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@luzmo/embed",
3
- "version": "5.0.11",
3
+ "version": "5.0.13-beta.0",
4
4
  "dependencies": {
5
5
  "lit": "3.1.2",
6
- "@luzmo/shared-embed": "5.0.5"
6
+ "@luzmo/shared-embed": "5.0.6"
7
7
  },
8
8
  "type": "module",
9
9
  "keywords": [