@schneideress/dashboardframework 0.0.145 → 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.
@@ -368,6 +368,8 @@ var RAEvent = {
368
368
  ConfigAddClick: "configAddClick",
369
369
  /** triggers when a user click on the save button in widget configuration window */
370
370
  ConfigChanged: "configChanged",
371
+ /**To rearrange widgets in a dashboard */
372
+ RearrangeClicked: "rearrangeClicked",
371
373
  /**dashboard customize button click */
372
374
  DashboardCustomizeClick: "dashboardCustomizeClick",
373
375
  /**triggers when user clicks on the dashboard change icon in header section */
@@ -785,8 +787,11 @@ var RADashboardArea = /** @class */ (function () {
785
787
  * @return {?}
786
788
  */
787
789
  function (item) {
790
+ console.log('in item change clal back');
791
+ if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
792
+ areaContext.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
793
+ }
788
794
  areaContext.setAreaHeight();
789
- areaContext.updateWidgets();
790
795
  });
791
796
  };
792
797
  /** To initiate eventbus subsctiptions */
@@ -836,6 +841,19 @@ var RADashboardArea = /** @class */ (function () {
836
841
  _this.addWidget(e);
837
842
  }));
838
843
  }));
844
+ this.rearrangeWidgetClick = this.raDashboardEventBus.subscribe(RAEvent.RearrangeClicked).subscribe((/**
845
+ * @param {?} e
846
+ * @return {?}
847
+ */
848
+ function (e) {
849
+ _this.ngZone.run((/**
850
+ * @return {?}
851
+ */
852
+ function () {
853
+ console.log('rearrange event bus triggered');
854
+ _this.rearrangeWidgets();
855
+ }));
856
+ }));
839
857
  this.widgetLibraryDoneClick = this.raDashboardEventBus.subscribe(RAEvent.widgetLibraryDoneClick).subscribe((/**
840
858
  * @param {?} widgetList
841
859
  * @return {?}
@@ -912,6 +930,8 @@ var RADashboardArea = /** @class */ (function () {
912
930
  this.widgetDeleteEvent.unsubscribe();
913
931
  if (this.widgetLibraryDoneClick)
914
932
  this.widgetLibraryDoneClick.unsubscribe();
933
+ if (this.rearrangeWidgetClick)
934
+ this.rearrangeWidgetClick.unsubscribe();
915
935
  };
916
936
  /**To update position/dimention of all widgets in the area */
917
937
  /**
@@ -931,6 +951,69 @@ var RADashboardArea = /** @class */ (function () {
931
951
  }));
932
952
  return true;
933
953
  };
954
+ /**To update widget dimensions */
955
+ /**
956
+ * To update widget dimensions
957
+ * @param {?} widgetInstanceId
958
+ * @return {?}
959
+ */
960
+ RADashboardArea.prototype.updateWidgetPosition = /**
961
+ * To update widget dimensions
962
+ * @param {?} widgetInstanceId
963
+ * @return {?}
964
+ */
965
+ function (widgetInstanceId) {
966
+ /** @type {?} */
967
+ var widgetFilteredList = [];
968
+ /** @type {?} */
969
+ var widget = this.widgetList.filter((/**
970
+ * @param {?} filtered
971
+ * @return {?}
972
+ */
973
+ function (filtered) { return filtered.widgetInfo && filtered.widgetInfo.widgetInstanceId == widgetInstanceId; }));
974
+ if (widget && widget.length > 0) {
975
+ widgetFilteredList.push(widget[0]);
976
+ /** @type {?} */
977
+ var widgetList = this.mapGridsterListToObject(widgetFilteredList);
978
+ this.dashboardService.updateWidgets(this.formatWidgetDataForPositionDetails(widgetList), this.appConfig).subscribe((/**
979
+ * @param {?} widgets
980
+ * @return {?}
981
+ */
982
+ function (widgets) {
983
+ }));
984
+ }
985
+ return true;
986
+ };
987
+ /**To restrict request payload to be of min size (position & size details) */
988
+ /**
989
+ * To restrict request payload to be of min size (position & size details)
990
+ * @param {?} widgetItemList
991
+ * @return {?}
992
+ */
993
+ RADashboardArea.prototype.formatWidgetDataForPositionDetails = /**
994
+ * To restrict request payload to be of min size (position & size details)
995
+ * @param {?} widgetItemList
996
+ * @return {?}
997
+ */
998
+ function (widgetItemList) {
999
+ /** @type {?} */
1000
+ var itemList = [];
1001
+ widgetItemList.forEach((/**
1002
+ * @param {?} widgetItem
1003
+ * @return {?}
1004
+ */
1005
+ function (widgetItem) {
1006
+ /** @type {?} */
1007
+ var item = (/** @type {?} */ ({}));
1008
+ item.widgetInstanceId = widgetItem.widgetInstanceId;
1009
+ item.position_x = widgetItem.position_x;
1010
+ item.position_y = widgetItem.position_y;
1011
+ item.width = widgetItem.width;
1012
+ item.height = widgetItem.height;
1013
+ itemList.push(item);
1014
+ }));
1015
+ return itemList;
1016
+ };
934
1017
  /** To retrieve widgets based on userDashboardid and area name */
935
1018
  /**
936
1019
  * To retrieve widgets based on userDashboardid and area name
@@ -1036,7 +1119,6 @@ var RADashboardArea = /** @class */ (function () {
1036
1119
  */
1037
1120
  function (widgetInstanceId, isalertDisabled) {
1038
1121
  if (isalertDisabled === void 0) { isalertDisabled = false; }
1039
- console.log("goCorona");
1040
1122
  /** @type {?} */
1041
1123
  var widget = this.widgetList.filter((/**
1042
1124
  * @param {?} item
@@ -1051,12 +1133,23 @@ var RADashboardArea = /** @class */ (function () {
1051
1133
  if (!isalertDisabled) {
1052
1134
  this.notifier.notify('success', " " + this.translateService.translate('Common.Widgettext') + " " + widget[0].widgetInfo.widgetTitle + " " + this.translateService.translate('Common.deletedSuccesfully') + " ");
1053
1135
  }
1054
- this.options.compactType = 'compactLeft&Up';
1055
- this.options.api.optionsChanged();
1056
- this.options.compactType = 'none';
1057
- this.options.api.optionsChanged();
1058
1136
  }
1059
1137
  };
1138
+ /**To rearrange widgets position in the dashboard, compactLeft&Up,compactLeft,compactUp,etc*/
1139
+ /**
1140
+ * To rearrange widgets position in the dashboard, compactLeft&Up,compactLeft,compactUp,etc
1141
+ * @return {?}
1142
+ */
1143
+ RADashboardArea.prototype.rearrangeWidgets = /**
1144
+ * To rearrange widgets position in the dashboard, compactLeft&Up,compactLeft,compactUp,etc
1145
+ * @return {?}
1146
+ */
1147
+ function () {
1148
+ this.options.compactType = 'compactUp&Left';
1149
+ this.options.api.optionsChanged();
1150
+ this.options.compactType = 'none';
1151
+ this.options.api.optionsChanged();
1152
+ };
1060
1153
  /**To add widget instance to the database with the next available position and to make changes in
1061
1154
  * dashboard area.
1062
1155
  */
@@ -1107,13 +1200,18 @@ var RADashboardArea = /** @class */ (function () {
1107
1200
  _this.gridcellHeight = curRowHeight;
1108
1201
  }
1109
1202
  }
1110
- /**To save added widget position in db */
1111
- setTimeout((/**
1112
- * @return {?}
1113
- */
1114
- function () {
1115
- _this.updateWidgets();
1116
- }), 1000);
1203
+ /** @type {?} */
1204
+ var widgetInstanceId = 0;
1205
+ if (widget && widget.widgetInstanceId) {
1206
+ widgetInstanceId = widget.widgetInstanceId;
1207
+ /**To save added widget position in db */
1208
+ setTimeout((/**
1209
+ * @return {?}
1210
+ */
1211
+ function () {
1212
+ _this.updateWidgetPosition(widgetInstanceId);
1213
+ }), 1000);
1214
+ }
1117
1215
  _this.raDashboardEventBus.publish(RAEvent.WidgetAdded, widget);
1118
1216
  }));
1119
1217
  };
@@ -1265,6 +1363,11 @@ if (false) {
1265
1363
  * @private
1266
1364
  */
1267
1365
  RADashboardArea.prototype.conifgAddClick;
1366
+ /**
1367
+ * @type {?}
1368
+ * @private
1369
+ */
1370
+ RADashboardArea.prototype.rearrangeWidgetClick;
1268
1371
  /**
1269
1372
  * @type {?}
1270
1373
  * @private
@@ -1481,12 +1584,13 @@ var RAWidgetContainer = /** @class */ (function () {
1481
1584
  */
1482
1585
  function (isHover) {
1483
1586
  if (isHover === void 0) { isHover = true; }
1484
- console.log('in mousehover value');
1485
- console.log(isHover);
1486
1587
  if (this.widgetElement) {
1487
- console.log(1);
1488
- this.widgetElement.hoverStatus(isHover);
1489
- console.log(2);
1588
+ if (typeof this.widgetElement.hoverStatus === "function") {
1589
+ this.widgetElement.hoverStatus(isHover);
1590
+ }
1591
+ else {
1592
+ console.warn('widget framework outdated, please update to version 0.0.96');
1593
+ }
1490
1594
  }
1491
1595
  if (!isHover) {
1492
1596
  this.hideDropDown();
@@ -1691,8 +1795,6 @@ var RAWidgetContainer = /** @class */ (function () {
1691
1795
  * @return {?}
1692
1796
  */
1693
1797
  function (e) {
1694
- console.log('in widget default state');
1695
- console.log(e);
1696
1798
  widgetContainer.setEmptyState(e.detail);
1697
1799
  }));
1698
1800
  titleLineEnabled = widgetContainer.widgetElement.titleLineEnabled();
@@ -1770,16 +1872,11 @@ var RAWidgetContainer = /** @class */ (function () {
1770
1872
  */
1771
1873
  function (widgetInfo, forceEnable) {
1772
1874
  if (forceEnable === void 0) { forceEnable = false; }
1773
- console.log('in set no configured');
1774
- console.log(widgetInfo);
1775
- console.log(forceEnable);
1776
1875
  if ((widgetInfo.showDefaultState && (widgetInfo.widgetConfigInfo.config == "" || Object.keys(JSON.parse(widgetInfo.widgetConfigInfo.config)).length == 0)) || (forceEnable)) {
1777
- console.log('ininf');
1778
1876
  this.isWidgetStateApplicable = true;
1779
1877
  this.widgetEmptyState = WidgetViewState.emptyConfig.toString();
1780
1878
  }
1781
1879
  else {
1782
- console.log('in else');
1783
1880
  this.widgetEmptyState = '';
1784
1881
  this.isWidgetStateApplicable = false;
1785
1882
  }
@@ -1796,24 +1893,19 @@ var RAWidgetContainer = /** @class */ (function () {
1796
1893
  * @return {?}
1797
1894
  */
1798
1895
  function (widgetState) {
1799
- console.log('in wc contanjiner widget state');
1800
- console.log(widgetState);
1801
1896
  this.widgetEmptyState = widgetState;
1802
1897
  if (widgetState != WidgetViewState.normal) {
1803
1898
  this.isWidgetStateApplicable = true;
1804
1899
  this.isDownloadIconVisible = false;
1805
1900
  }
1806
1901
  else {
1807
- console.log('in else case');
1808
1902
  this.isWidgetStateApplicable = false;
1809
1903
  }
1810
1904
  switch (widgetState) {
1811
1905
  case WidgetViewState.emptyConfig:
1812
- console.log('in case emptyconfig');
1813
1906
  this.setNotConfiguredState(this.data.widgetInfo, true);
1814
1907
  break;
1815
1908
  case WidgetViewState.emptyData:
1816
- console.log('in case empty');
1817
1909
  break;
1818
1910
  case WidgetViewState.error:
1819
1911
  break;