@schneideress/dashboardframework 0.0.146 → 0.0.147

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.
@@ -254,6 +254,8 @@ const RAEvent = {
254
254
  ConfigAddClick: "configAddClick",
255
255
  /** triggers when a user click on the save button in widget configuration window */
256
256
  ConfigChanged: "configChanged",
257
+ /**To rearrange widgets in a dashboard */
258
+ RearrangeClicked: "rearrangeClicked",
257
259
  /**dashboard customize button click */
258
260
  DashboardCustomizeClick: "dashboardCustomizeClick",
259
261
  /**triggers when user clicks on the dashboard change icon in header section */
@@ -618,15 +620,6 @@ class RADashboardArea {
618
620
  */
619
621
  ngOnInit() {
620
622
  this.initiateGridsterConfig();
621
- this.widgetRearrangeSubject.subscribe((/**
622
- * @param {?} event
623
- * @return {?}
624
- */
625
- event => {
626
- console.log('in subscribe subject & value is');
627
- console.log(event);
628
- this.rearrangeWidgets();
629
- }));
630
623
  }
631
624
  /**
632
625
  * @param {?} changes
@@ -660,8 +653,11 @@ class RADashboardArea {
660
653
  * @return {?}
661
654
  */
662
655
  function (item) {
656
+ console.log('in item change clal back');
657
+ if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
658
+ areaContext.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
659
+ }
663
660
  areaContext.setAreaHeight();
664
- areaContext.updateWidgets();
665
661
  });
666
662
  }
667
663
  /**
@@ -705,6 +701,19 @@ class RADashboardArea {
705
701
  this.addWidget(e);
706
702
  }));
707
703
  }));
704
+ this.rearrangeWidgetClick = this.raDashboardEventBus.subscribe(RAEvent.RearrangeClicked).subscribe((/**
705
+ * @param {?} e
706
+ * @return {?}
707
+ */
708
+ (e) => {
709
+ this.ngZone.run((/**
710
+ * @return {?}
711
+ */
712
+ () => {
713
+ console.log('rearrange event bus triggered');
714
+ this.rearrangeWidgets();
715
+ }));
716
+ }));
708
717
  this.widgetLibraryDoneClick = this.raDashboardEventBus.subscribe(RAEvent.widgetLibraryDoneClick).subscribe((/**
709
718
  * @param {?} widgetList
710
719
  * @return {?}
@@ -765,8 +774,8 @@ class RADashboardArea {
765
774
  this.widgetDeleteEvent.unsubscribe();
766
775
  if (this.widgetLibraryDoneClick)
767
776
  this.widgetLibraryDoneClick.unsubscribe();
768
- if (this.widgetRearrangeSubject)
769
- this.widgetRearrangeSubject.unsubscribe();
777
+ if (this.rearrangeWidgetClick)
778
+ this.rearrangeWidgetClick.unsubscribe();
770
779
  }
771
780
  /**
772
781
  * To update position/dimention of all widgets in the area
@@ -781,6 +790,57 @@ class RADashboardArea {
781
790
  }));
782
791
  return true;
783
792
  }
793
+ /**
794
+ * To update widget dimensions
795
+ * @param {?} widgetInstanceId
796
+ * @return {?}
797
+ */
798
+ updateWidgetPosition(widgetInstanceId) {
799
+ /** @type {?} */
800
+ let widgetFilteredList = [];
801
+ /** @type {?} */
802
+ let widget = this.widgetList.filter((/**
803
+ * @param {?} filtered
804
+ * @return {?}
805
+ */
806
+ filtered => filtered.widgetInfo && filtered.widgetInfo.widgetInstanceId == widgetInstanceId));
807
+ if (widget && widget.length > 0) {
808
+ widgetFilteredList.push(widget[0]);
809
+ /** @type {?} */
810
+ let widgetList = this.mapGridsterListToObject(widgetFilteredList);
811
+ this.dashboardService.updateWidgets(this.formatWidgetDataForPositionDetails(widgetList), this.appConfig).subscribe((/**
812
+ * @param {?} widgets
813
+ * @return {?}
814
+ */
815
+ widgets => {
816
+ }));
817
+ }
818
+ return true;
819
+ }
820
+ /**
821
+ * To restrict request payload to be of min size (position & size details)
822
+ * @param {?} widgetItemList
823
+ * @return {?}
824
+ */
825
+ formatWidgetDataForPositionDetails(widgetItemList) {
826
+ /** @type {?} */
827
+ let itemList = [];
828
+ widgetItemList.forEach((/**
829
+ * @param {?} widgetItem
830
+ * @return {?}
831
+ */
832
+ function (widgetItem) {
833
+ /** @type {?} */
834
+ let item = (/** @type {?} */ ({}));
835
+ item.widgetInstanceId = widgetItem.widgetInstanceId;
836
+ item.position_x = widgetItem.position_x;
837
+ item.position_y = widgetItem.position_y;
838
+ item.width = widgetItem.width;
839
+ item.height = widgetItem.height;
840
+ itemList.push(item);
841
+ }));
842
+ return itemList;
843
+ }
784
844
  /**
785
845
  * To retrieve widgets based on userDashboardid and area name
786
846
  * @param {?} userDashboarId
@@ -885,7 +945,6 @@ class RADashboardArea {
885
945
  * @return {?}
886
946
  */
887
947
  rearrangeWidgets() {
888
- console.log('in rearrange widgets methd');
889
948
  this.options.compactType = 'compactUp&Left';
890
949
  this.options.api.optionsChanged();
891
950
  this.options.compactType = 'none';
@@ -931,13 +990,18 @@ class RADashboardArea {
931
990
  this.gridcellHeight = curRowHeight;
932
991
  }
933
992
  }
934
- /**To save added widget position in db */
935
- setTimeout((/**
936
- * @return {?}
937
- */
938
- () => {
939
- this.updateWidgets();
940
- }), 1000);
993
+ /** @type {?} */
994
+ var widgetInstanceId = 0;
995
+ if (widget && widget.widgetInstanceId) {
996
+ widgetInstanceId = widget.widgetInstanceId;
997
+ /**To save added widget position in db */
998
+ setTimeout((/**
999
+ * @return {?}
1000
+ */
1001
+ () => {
1002
+ this.updateWidgetPosition(widgetInstanceId);
1003
+ }), 1000);
1004
+ }
941
1005
  this.raDashboardEventBus.publish(RAEvent.WidgetAdded, widget);
942
1006
  }));
943
1007
  }
@@ -1045,7 +1109,6 @@ RADashboardArea.propDecorators = {
1045
1109
  widgetHeight: [{ type: Input, args: ['widget-height',] }],
1046
1110
  widgetWidth: [{ type: Input, args: ['widget-width',] }],
1047
1111
  appConfig: [{ type: Input, args: ['app-config',] }],
1048
- widgetRearrangeSubject: [{ type: Input }],
1049
1112
  gridWrapper: [{ type: ViewChild, args: ['gridWrapper', { static: false },] }],
1050
1113
  onResize: [{ type: HostListener, args: ['window:resize', ['$event'],] }]
1051
1114
  };
@@ -1063,6 +1126,11 @@ if (false) {
1063
1126
  * @private
1064
1127
  */
1065
1128
  RADashboardArea.prototype.conifgAddClick;
1129
+ /**
1130
+ * @type {?}
1131
+ * @private
1132
+ */
1133
+ RADashboardArea.prototype.rearrangeWidgetClick;
1066
1134
  /**
1067
1135
  * @type {?}
1068
1136
  * @private
@@ -1100,8 +1168,6 @@ if (false) {
1100
1168
  /** @type {?} */
1101
1169
  RADashboardArea.prototype.appConfig;
1102
1170
  /** @type {?} */
1103
- RADashboardArea.prototype.widgetRearrangeSubject;
1104
- /** @type {?} */
1105
1171
  RADashboardArea.prototype.gridWrapper;
1106
1172
  /**
1107
1173
  * @type {?}
@@ -6437,7 +6503,6 @@ class RaBaseDashboardTemplate {
6437
6503
  */
6438
6504
  constructor(ngZone) {
6439
6505
  this.ngZone = ngZone;
6440
- this.widgetRearrangeSubject = new Subject();
6441
6506
  this.initialize = (/**
6442
6507
  * @param {?} eventBus
6443
6508
  * @param {?} userDashboardId
@@ -6455,17 +6520,6 @@ class RaBaseDashboardTemplate {
6455
6520
  }));
6456
6521
  this.init();
6457
6522
  });
6458
- this.rearrangeWidgets = (/**
6459
- * @return {?}
6460
- */
6461
- () => {
6462
- this.ngZone.run((/**
6463
- * @return {?}
6464
- */
6465
- () => {
6466
- this.widgetRearrangeSubject.next(true);
6467
- }));
6468
- });
6469
6523
  }
6470
6524
  /**
6471
6525
  * @return {?}
@@ -6479,8 +6533,7 @@ class RaBaseDashboardTemplate {
6479
6533
  RaBaseDashboardTemplate.propDecorators = {
6480
6534
  dashboardId: [{ type: Input, args: ['dashboard-id',] }],
6481
6535
  globalFilter: [{ type: Input, args: ['global-filter',] }],
6482
- initialize: [{ type: Input }],
6483
- rearrangeWidgets: [{ type: Input }]
6536
+ initialize: [{ type: Input }]
6484
6537
  };
6485
6538
  if (false) {
6486
6539
  /** @type {?} */
@@ -6490,15 +6543,11 @@ if (false) {
6490
6543
  /** @type {?} */
6491
6544
  RaBaseDashboardTemplate.prototype.appConfig;
6492
6545
  /** @type {?} */
6493
- RaBaseDashboardTemplate.prototype.widgetRearrangeSubject;
6494
- /** @type {?} */
6495
6546
  RaBaseDashboardTemplate.prototype.dashboardId;
6496
6547
  /** @type {?} */
6497
6548
  RaBaseDashboardTemplate.prototype.globalFilter;
6498
6549
  /** @type {?} */
6499
6550
  RaBaseDashboardTemplate.prototype.initialize;
6500
- /** @type {?} */
6501
- RaBaseDashboardTemplate.prototype.rearrangeWidgets;
6502
6551
  /**
6503
6552
  * @type {?}
6504
6553
  * @private