intelica-library-ui 0.1.228 → 0.1.230

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, Injectable, signal, Pipe, Component, HostListener, Directive, EventEmitter, Output, Input, forwardRef, TemplateRef, ContentChild, ContentChildren, ViewChild, PLATFORM_ID, Inject, ChangeDetectorRef, computed, effect, ViewChildren, Optional, Host } from '@angular/core';
2
+ import { inject, Injectable, signal, Pipe, Component, HostListener, Directive, EventEmitter, Output, Input, forwardRef, TemplateRef, ContentChild, ContentChildren, ViewChild, PLATFORM_ID, Inject, ChangeDetectorRef, input, computed, output, effect, ViewChildren, Optional, Host } from '@angular/core';
3
3
  import { getCookie, Cookies, setCookie } from 'typescript-cookie';
4
- import { HttpClient, HttpHeaders, HttpResponse, HttpParams } from '@angular/common/http';
4
+ import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
5
5
  import { BehaviorSubject, catchError, throwError, from, switchMap, Subject, Subscription, firstValueFrom, of, tap as tap$1, map } from 'rxjs';
6
6
  import Swal from 'sweetalert2';
7
7
  import { tap } from 'rxjs/operators';
@@ -49,6 +49,8 @@ import { AccordionModule } from 'primeng/accordion';
49
49
  import { ActivatedRoute } from '@angular/router';
50
50
  import { createEmbeddingContext } from 'amazon-quicksight-embedding-sdk';
51
51
  import { toSignal } from '@angular/core/rxjs-interop';
52
+ import * as i2$4 from 'primeng/panel';
53
+ import { PanelModule } from 'primeng/panel';
52
54
  import * as XLSX from 'xlsx';
53
55
  import { Workbook } from 'exceljs';
54
56
  import { saveAs } from 'file-saver';
@@ -6644,32 +6646,14 @@ class Shared {
6644
6646
  http = inject(HttpClient);
6645
6647
  configService = inject(ConfigService);
6646
6648
  path = `${this.configService.environment?.sharedPath}/Quicksight`;
6647
- getEmbedUrl(dashboardId) {
6648
- return this.http.get(`${this.path}/embed-url/${dashboardId}`);
6649
- }
6650
- getEmbedVisualUrl(request) {
6651
- let params = new HttpParams()
6652
- .set('dashboardId', request.dashboardId)
6653
- .set('sheetId', request.sheetId)
6654
- .set('visualId', request.visualId);
6655
- Object.entries(request.parameters).forEach(([key, values]) => {
6656
- values.forEach(value => {
6657
- params = params.append(`parameters[${key}]`, value);
6658
- });
6659
- });
6660
- return this.http.get(`${this.path}/embed-visual-url`, { params });
6661
- }
6662
- getEmbedVisualUrlsAnonymous(request) {
6663
- let params = new HttpParams()
6664
- .set('dashboardId', request.dashboardId)
6665
- .set('sheetId', request.sheetId)
6666
- .set('visualId', request.visualId);
6667
- Object.entries(request.parameters).forEach(([key, values]) => {
6668
- values.forEach(value => {
6669
- params = params.append(`parameters[${key}]`, value);
6670
- });
6671
- });
6672
- return this.http.get(`${this.path}/embed-visual-anonymous`, { params });
6649
+ getEmbedUrl(command) {
6650
+ return this.http.post(`${this.path}/embed-url`, command);
6651
+ }
6652
+ getEmbedVisualUrl(command) {
6653
+ return this.http.post(`${this.path}/embed-visual-url`, command);
6654
+ }
6655
+ getEmbedVisualUrlsAnonymous(command) {
6656
+ return this.http.post(`${this.path}/embed-visual-anonymous`, command);
6673
6657
  }
6674
6658
  async createEmbedContext(embedUrl, container, options) {
6675
6659
  const embeddingContext = await createEmbeddingContext();
@@ -6680,10 +6664,29 @@ class Shared {
6680
6664
  ...(options?.width && { width: options.width }),
6681
6665
  });
6682
6666
  }
6683
- async embedDashboard(dashboardId, container, options) {
6684
- const { embedUrl } = await firstValueFrom(this.getEmbedUrl(dashboardId));
6667
+ async embedDashboard(command, container, options) {
6668
+ container.replaceChildren();
6669
+ const embedUrl = await firstValueFrom(this.getEmbedUrl(command));
6685
6670
  await this.createEmbedContext(embedUrl, container, options);
6686
6671
  }
6672
+ async embedDashboardInteractive(command, container, options) {
6673
+ container.replaceChildren();
6674
+ const embedUrl = await firstValueFrom(this.getEmbedUrl({ ...command, parameters: undefined }));
6675
+ const embeddingContext = await createEmbeddingContext();
6676
+ const sdkParameters = command.parameters
6677
+ ? Object.entries(command.parameters).map(([Name, Values]) => ({ Name, Values }))
6678
+ : undefined;
6679
+ return await embeddingContext.embedDashboard({
6680
+ url: embedUrl,
6681
+ container,
6682
+ ...(options?.height && { height: options.height }),
6683
+ ...(options?.width && { width: options.width }),
6684
+ }, sdkParameters ? { parameters: sdkParameters } : undefined);
6685
+ }
6686
+ async setDashboardParameters(dashboard, parameters) {
6687
+ const sdkParameters = Object.entries(parameters).map(([Name, Values]) => ({ Name, Values }));
6688
+ await dashboard.setParameters(sdkParameters);
6689
+ }
6687
6690
  async createEmbedVisualContext(embedUrl, container, options) {
6688
6691
  const embeddingContext = await createEmbeddingContext();
6689
6692
  await embeddingContext.embedVisual({
@@ -6693,16 +6696,41 @@ class Shared {
6693
6696
  ...(options?.width && { width: options.width }),
6694
6697
  }, { scaleToContainer: true, fitToIframeWidth: false });
6695
6698
  }
6696
- async embedSequentialVisuals(dashboardId, sheetId, parameters, configs, onVisualLoaded) {
6699
+ async embedSequentialVisuals(command, configs, onVisualLoaded) {
6697
6700
  for (const config of configs) {
6698
6701
  config.container?.nativeElement?.replaceChildren();
6699
- const { visual } = await firstValueFrom(this.getEmbedVisualUrl({ dashboardId, sheetId, visualId: config.visualId, parameters }));
6702
+ const { visual } = await firstValueFrom(this.getEmbedVisualUrl({ dashboardId: command.dashboardId, sheetId: command.sheetId, visualId: config.visualId, parameters: command.parameters }));
6700
6703
  if (!visual)
6701
6704
  continue;
6702
6705
  await this.createEmbedVisualContext(visual.embedUrl, config.container.nativeElement);
6703
6706
  onVisualLoaded?.(config.visualId);
6704
6707
  }
6705
6708
  }
6709
+ async embedSequentialVisualsInteractive(command, configs, onVisualLoaded) {
6710
+ const refs = new Map();
6711
+ const sdkParameters = command.parameters
6712
+ ? Object.entries(command.parameters).map(([Name, Values]) => ({ Name, Values }))
6713
+ : undefined;
6714
+ for (const config of configs) {
6715
+ config.container?.nativeElement?.replaceChildren();
6716
+ const { visual } = await firstValueFrom(this.getEmbedVisualUrl({ dashboardId: command.dashboardId, sheetId: command.sheetId, visualId: config.visualId, parameters: {} }));
6717
+ if (!visual)
6718
+ continue;
6719
+ const embeddingContext = await createEmbeddingContext();
6720
+ const visualRef = await embeddingContext.embedVisual({ url: visual.embedUrl, container: config.container.nativeElement }, { scaleToContainer: true, fitToIframeWidth: false, ...(sdkParameters ? { parameters: sdkParameters } : {}) });
6721
+ refs.set(config.visualId, visualRef);
6722
+ onVisualLoaded?.(config.visualId, visualRef);
6723
+ }
6724
+ return refs;
6725
+ }
6726
+ async setVisualParameters(visual, parameters) {
6727
+ const sdkParameters = Object.entries(parameters).map(([Name, Values]) => ({ Name, Values }));
6728
+ await visual.setParameters(sdkParameters);
6729
+ }
6730
+ async setVisualsParameters(visuals, parameters) {
6731
+ const sdkParameters = Object.entries(parameters).map(([Name, Values]) => ({ Name, Values }));
6732
+ await Promise.all([...visuals].map(v => v.setParameters(sdkParameters)));
6733
+ }
6706
6734
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: Shared, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6707
6735
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: Shared, providedIn: 'root' });
6708
6736
  }
@@ -6717,29 +6745,38 @@ class DashboardQsComponent {
6717
6745
  sharedService = inject(Shared);
6718
6746
  route = inject(ActivatedRoute);
6719
6747
  containers;
6748
+ dashboardIdInput = input(undefined, { alias: 'dashboardId' });
6749
+ parametersInput = input(undefined, { alias: 'parameters' });
6750
+ heightInput = input(undefined, { alias: 'height' });
6720
6751
  routeData = toSignal(this.route.data, { initialValue: this.route.snapshot.data });
6721
- dashboardId = computed(() => this.routeData()['dashboardId']);
6722
- height = computed(() => this.routeData()['height'] ?? '700px');
6752
+ dashboardId = computed(() => this.dashboardIdInput() ?? this.routeData()['dashboardId']);
6753
+ parameters = computed(() => this.parametersInput() ?? this.routeData()['parameters']);
6754
+ height = computed(() => this.heightInput() ?? this.routeData()['height']);
6723
6755
  isLoading = signal(true);
6756
+ isLoadingChange = output();
6724
6757
  viewReady = signal(false);
6725
6758
  constructor() {
6759
+ effect(() => {
6760
+ this.isLoadingChange.emit(this.isLoading());
6761
+ });
6726
6762
  effect(() => {
6727
6763
  const id = this.dashboardId();
6764
+ const parameters = this.parameters();
6728
6765
  if (!this.viewReady() || !id)
6729
6766
  return;
6730
- this.EmbedDashboard(id);
6767
+ this.EmbedDashboard(id, parameters);
6731
6768
  });
6732
6769
  }
6733
6770
  ngAfterViewInit() {
6734
6771
  this.viewReady.set(true);
6735
6772
  }
6736
- async EmbedDashboard(dashboardId) {
6773
+ async EmbedDashboard(dashboardId, parameters) {
6737
6774
  const container = this.containers.first?.nativeElement;
6738
6775
  if (!container)
6739
6776
  return;
6740
6777
  this.isLoading.set(true);
6741
6778
  try {
6742
- await this.sharedService.embedDashboard(dashboardId, container);
6779
+ await this.sharedService.embedDashboard({ dashboardId, parameters }, container, { height: this.height() ?? `${window.innerHeight - 50}px` });
6743
6780
  }
6744
6781
  catch (error) {
6745
6782
  console.error('Error embedding dashboard:', error);
@@ -6749,11 +6786,11 @@ class DashboardQsComponent {
6749
6786
  }
6750
6787
  }
6751
6788
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: DashboardQsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
6752
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.1", type: DashboardQsComponent, isStandalone: true, selector: "intelica-dashboard-qs", viewQueries: [{ propertyName: "containers", predicate: ["visualContainer"], descendants: true }], ngImport: i0, template: "<div #visualContainer [style.height]=\"height()\" [class.hidden]=\"isLoading()\"></div>" });
6789
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.1", type: DashboardQsComponent, isStandalone: true, selector: "intelica-dashboard-qs", inputs: { dashboardIdInput: { classPropertyName: "dashboardIdInput", publicName: "dashboardId", isSignal: true, isRequired: false, transformFunction: null }, parametersInput: { classPropertyName: "parametersInput", publicName: "parameters", isSignal: true, isRequired: false, transformFunction: null }, heightInput: { classPropertyName: "heightInput", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { isLoadingChange: "isLoadingChange" }, viewQueries: [{ propertyName: "containers", predicate: ["visualContainer"], descendants: true }], ngImport: i0, template: "@if (isLoading()) {\r\n<div class=\"u-display-flex u-flex-column u-gap-sm\">\r\n <div class=\"u-display-flex u-background-white u-px-1 u-pt-1\">\r\n <div class=\"u-display-flex u-flex-column u-px-1\" style=\"height: 33px\">\r\n <p-skeleton class=\"prSkeleton u-m-auto\" [width]=\"'61px'\" [height]=\"'14px'\" />\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'2px'\" />\r\n </div>\r\n <div class=\"u-display-flex u-flex-column u-px-1\" style=\"height: 33px\">\r\n <p-skeleton class=\"prSkeleton u-m-auto\" [width]=\"'61px'\" [height]=\"'14px'\" />\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'2px'\" />\r\n </div>\r\n </div>\r\n <div class=\"u-display-flex u-flex-column u-gap-sm\">\r\n <p-panel class=\"prPanel u-flex-grow-1 u-flex-basis-0 u-shadow-none\" showHeader=\"false\">\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'100%'\" [style]=\"{ 'aspect-ratio': '1061.57 / 93.02' }\" />\r\n </p-panel>\r\n </div>\r\n <div class=\"u-display-flex u-flex-row u-gap-sm\">\r\n @for (_ of [].constructor(4); track $index) {\r\n <p-panel class=\"prPanel u-flex-grow-1 u-flex-basis-0 u-shadow-none\" showHeader=\"false\">\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'100%'\" [style]=\"{ 'aspect-ratio': '244.87 / 123.12' }\" />\r\n </p-panel>\r\n }\r\n </div>\r\n <div class=\"u-display-flex u-flex-column u-gap-sm\">\r\n <p-panel class=\"prPanel u-flex-grow-1 u-flex-basis-0 u-shadow-none\" showHeader=\"false\">\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'100%'\" [style]=\"{ 'aspect-ratio': '1061.57 / 303.7' }\" />\r\n </p-panel>\r\n </div>\r\n <div class=\"u-display-flex u-flex-row u-gap-sm\">\r\n @for (_ of [].constructor(2); track $index) {\r\n <p-panel class=\"prPanel u-flex-grow-1 u-flex-basis-0 u-shadow-none\" showHeader=\"false\">\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'100%'\" [style]=\"{ 'aspect-ratio': '517.1 / 123.12' }\" />\r\n </p-panel>\r\n }\r\n </div>\r\n</div>\r\n}\r\n<div #visualContainer [style.height]=\"height()\" [hidden]=\"isLoading()\"></div>", dependencies: [{ kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i2$3.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "style", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "ngmodule", type: PanelModule }, { kind: "component", type: i2$4.Panel, selector: "p-panel", inputs: ["toggleable", "header", "collapsed", "style", "styleClass", "iconPos", "expandIcon", "collapseIcon", "showHeader", "toggler", "transitionOptions", "toggleButtonProps"], outputs: ["collapsedChange", "onBeforeToggle", "onAfterToggle"] }] });
6753
6790
  }
6754
6791
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: DashboardQsComponent, decorators: [{
6755
6792
  type: Component,
6756
- args: [{ selector: 'intelica-dashboard-qs', imports: [], template: "<div #visualContainer [style.height]=\"height()\" [class.hidden]=\"isLoading()\"></div>" }]
6793
+ args: [{ selector: 'intelica-dashboard-qs', imports: [SkeletonModule, PanelModule], template: "@if (isLoading()) {\r\n<div class=\"u-display-flex u-flex-column u-gap-sm\">\r\n <div class=\"u-display-flex u-background-white u-px-1 u-pt-1\">\r\n <div class=\"u-display-flex u-flex-column u-px-1\" style=\"height: 33px\">\r\n <p-skeleton class=\"prSkeleton u-m-auto\" [width]=\"'61px'\" [height]=\"'14px'\" />\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'2px'\" />\r\n </div>\r\n <div class=\"u-display-flex u-flex-column u-px-1\" style=\"height: 33px\">\r\n <p-skeleton class=\"prSkeleton u-m-auto\" [width]=\"'61px'\" [height]=\"'14px'\" />\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'2px'\" />\r\n </div>\r\n </div>\r\n <div class=\"u-display-flex u-flex-column u-gap-sm\">\r\n <p-panel class=\"prPanel u-flex-grow-1 u-flex-basis-0 u-shadow-none\" showHeader=\"false\">\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'100%'\" [style]=\"{ 'aspect-ratio': '1061.57 / 93.02' }\" />\r\n </p-panel>\r\n </div>\r\n <div class=\"u-display-flex u-flex-row u-gap-sm\">\r\n @for (_ of [].constructor(4); track $index) {\r\n <p-panel class=\"prPanel u-flex-grow-1 u-flex-basis-0 u-shadow-none\" showHeader=\"false\">\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'100%'\" [style]=\"{ 'aspect-ratio': '244.87 / 123.12' }\" />\r\n </p-panel>\r\n }\r\n </div>\r\n <div class=\"u-display-flex u-flex-column u-gap-sm\">\r\n <p-panel class=\"prPanel u-flex-grow-1 u-flex-basis-0 u-shadow-none\" showHeader=\"false\">\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'100%'\" [style]=\"{ 'aspect-ratio': '1061.57 / 303.7' }\" />\r\n </p-panel>\r\n </div>\r\n <div class=\"u-display-flex u-flex-row u-gap-sm\">\r\n @for (_ of [].constructor(2); track $index) {\r\n <p-panel class=\"prPanel u-flex-grow-1 u-flex-basis-0 u-shadow-none\" showHeader=\"false\">\r\n <p-skeleton class=\"prSkeleton\" [width]=\"'100%'\" [height]=\"'100%'\" [style]=\"{ 'aspect-ratio': '517.1 / 123.12' }\" />\r\n </p-panel>\r\n }\r\n </div>\r\n</div>\r\n}\r\n<div #visualContainer [style.height]=\"height()\" [hidden]=\"isLoading()\"></div>" }]
6757
6794
  }], ctorParameters: () => [], propDecorators: { containers: [{
6758
6795
  type: ViewChildren,
6759
6796
  args: ['visualContainer']