@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.
@@ -579,6 +579,8 @@
579
579
  ConfigAddClick: "configAddClick",
580
580
  /** triggers when a user click on the save button in widget configuration window */
581
581
  ConfigChanged: "configChanged",
582
+ /**To rearrange widgets in a dashboard */
583
+ RearrangeClicked: "rearrangeClicked",
582
584
  /**dashboard customize button click */
583
585
  DashboardCustomizeClick: "dashboardCustomizeClick",
584
586
  /**triggers when user clicks on the dashboard change icon in header section */
@@ -996,8 +998,11 @@
996
998
  * @return {?}
997
999
  */
998
1000
  function (item) {
1001
+ console.log('in item change clal back');
1002
+ if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
1003
+ areaContext.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
1004
+ }
999
1005
  areaContext.setAreaHeight();
1000
- areaContext.updateWidgets();
1001
1006
  });
1002
1007
  };
1003
1008
  /** To initiate eventbus subsctiptions */
@@ -1047,6 +1052,19 @@
1047
1052
  _this.addWidget(e);
1048
1053
  }));
1049
1054
  }));
1055
+ this.rearrangeWidgetClick = this.raDashboardEventBus.subscribe(RAEvent.RearrangeClicked).subscribe((/**
1056
+ * @param {?} e
1057
+ * @return {?}
1058
+ */
1059
+ function (e) {
1060
+ _this.ngZone.run((/**
1061
+ * @return {?}
1062
+ */
1063
+ function () {
1064
+ console.log('rearrange event bus triggered');
1065
+ _this.rearrangeWidgets();
1066
+ }));
1067
+ }));
1050
1068
  this.widgetLibraryDoneClick = this.raDashboardEventBus.subscribe(RAEvent.widgetLibraryDoneClick).subscribe((/**
1051
1069
  * @param {?} widgetList
1052
1070
  * @return {?}
@@ -1123,6 +1141,8 @@
1123
1141
  this.widgetDeleteEvent.unsubscribe();
1124
1142
  if (this.widgetLibraryDoneClick)
1125
1143
  this.widgetLibraryDoneClick.unsubscribe();
1144
+ if (this.rearrangeWidgetClick)
1145
+ this.rearrangeWidgetClick.unsubscribe();
1126
1146
  };
1127
1147
  /**To update position/dimention of all widgets in the area */
1128
1148
  /**
@@ -1142,6 +1162,69 @@
1142
1162
  }));
1143
1163
  return true;
1144
1164
  };
1165
+ /**To update widget dimensions */
1166
+ /**
1167
+ * To update widget dimensions
1168
+ * @param {?} widgetInstanceId
1169
+ * @return {?}
1170
+ */
1171
+ RADashboardArea.prototype.updateWidgetPosition = /**
1172
+ * To update widget dimensions
1173
+ * @param {?} widgetInstanceId
1174
+ * @return {?}
1175
+ */
1176
+ function (widgetInstanceId) {
1177
+ /** @type {?} */
1178
+ var widgetFilteredList = [];
1179
+ /** @type {?} */
1180
+ var widget = this.widgetList.filter((/**
1181
+ * @param {?} filtered
1182
+ * @return {?}
1183
+ */
1184
+ function (filtered) { return filtered.widgetInfo && filtered.widgetInfo.widgetInstanceId == widgetInstanceId; }));
1185
+ if (widget && widget.length > 0) {
1186
+ widgetFilteredList.push(widget[0]);
1187
+ /** @type {?} */
1188
+ var widgetList = this.mapGridsterListToObject(widgetFilteredList);
1189
+ this.dashboardService.updateWidgets(this.formatWidgetDataForPositionDetails(widgetList), this.appConfig).subscribe((/**
1190
+ * @param {?} widgets
1191
+ * @return {?}
1192
+ */
1193
+ function (widgets) {
1194
+ }));
1195
+ }
1196
+ return true;
1197
+ };
1198
+ /**To restrict request payload to be of min size (position & size details) */
1199
+ /**
1200
+ * To restrict request payload to be of min size (position & size details)
1201
+ * @param {?} widgetItemList
1202
+ * @return {?}
1203
+ */
1204
+ RADashboardArea.prototype.formatWidgetDataForPositionDetails = /**
1205
+ * To restrict request payload to be of min size (position & size details)
1206
+ * @param {?} widgetItemList
1207
+ * @return {?}
1208
+ */
1209
+ function (widgetItemList) {
1210
+ /** @type {?} */
1211
+ var itemList = [];
1212
+ widgetItemList.forEach((/**
1213
+ * @param {?} widgetItem
1214
+ * @return {?}
1215
+ */
1216
+ function (widgetItem) {
1217
+ /** @type {?} */
1218
+ var item = (/** @type {?} */ ({}));
1219
+ item.widgetInstanceId = widgetItem.widgetInstanceId;
1220
+ item.position_x = widgetItem.position_x;
1221
+ item.position_y = widgetItem.position_y;
1222
+ item.width = widgetItem.width;
1223
+ item.height = widgetItem.height;
1224
+ itemList.push(item);
1225
+ }));
1226
+ return itemList;
1227
+ };
1145
1228
  /** To retrieve widgets based on userDashboardid and area name */
1146
1229
  /**
1147
1230
  * To retrieve widgets based on userDashboardid and area name
@@ -1247,7 +1330,6 @@
1247
1330
  */
1248
1331
  function (widgetInstanceId, isalertDisabled) {
1249
1332
  if (isalertDisabled === void 0) { isalertDisabled = false; }
1250
- console.log("goCorona");
1251
1333
  /** @type {?} */
1252
1334
  var widget = this.widgetList.filter((/**
1253
1335
  * @param {?} item
@@ -1262,12 +1344,23 @@
1262
1344
  if (!isalertDisabled) {
1263
1345
  this.notifier.notify('success', " " + this.translateService.translate('Common.Widgettext') + " " + widget[0].widgetInfo.widgetTitle + " " + this.translateService.translate('Common.deletedSuccesfully') + " ");
1264
1346
  }
1265
- this.options.compactType = 'compactLeft&Up';
1266
- this.options.api.optionsChanged();
1267
- this.options.compactType = 'none';
1268
- this.options.api.optionsChanged();
1269
1347
  }
1270
1348
  };
1349
+ /**To rearrange widgets position in the dashboard, compactLeft&Up,compactLeft,compactUp,etc*/
1350
+ /**
1351
+ * To rearrange widgets position in the dashboard, compactLeft&Up,compactLeft,compactUp,etc
1352
+ * @return {?}
1353
+ */
1354
+ RADashboardArea.prototype.rearrangeWidgets = /**
1355
+ * To rearrange widgets position in the dashboard, compactLeft&Up,compactLeft,compactUp,etc
1356
+ * @return {?}
1357
+ */
1358
+ function () {
1359
+ this.options.compactType = 'compactUp&Left';
1360
+ this.options.api.optionsChanged();
1361
+ this.options.compactType = 'none';
1362
+ this.options.api.optionsChanged();
1363
+ };
1271
1364
  /**To add widget instance to the database with the next available position and to make changes in
1272
1365
  * dashboard area.
1273
1366
  */
@@ -1318,13 +1411,18 @@
1318
1411
  _this.gridcellHeight = curRowHeight;
1319
1412
  }
1320
1413
  }
1321
- /**To save added widget position in db */
1322
- setTimeout((/**
1323
- * @return {?}
1324
- */
1325
- function () {
1326
- _this.updateWidgets();
1327
- }), 1000);
1414
+ /** @type {?} */
1415
+ var widgetInstanceId = 0;
1416
+ if (widget && widget.widgetInstanceId) {
1417
+ widgetInstanceId = widget.widgetInstanceId;
1418
+ /**To save added widget position in db */
1419
+ setTimeout((/**
1420
+ * @return {?}
1421
+ */
1422
+ function () {
1423
+ _this.updateWidgetPosition(widgetInstanceId);
1424
+ }), 1000);
1425
+ }
1328
1426
  _this.raDashboardEventBus.publish(RAEvent.WidgetAdded, widget);
1329
1427
  }));
1330
1428
  };
@@ -1476,6 +1574,11 @@
1476
1574
  * @private
1477
1575
  */
1478
1576
  RADashboardArea.prototype.conifgAddClick;
1577
+ /**
1578
+ * @type {?}
1579
+ * @private
1580
+ */
1581
+ RADashboardArea.prototype.rearrangeWidgetClick;
1479
1582
  /**
1480
1583
  * @type {?}
1481
1584
  * @private
@@ -1692,12 +1795,13 @@
1692
1795
  */
1693
1796
  function (isHover) {
1694
1797
  if (isHover === void 0) { isHover = true; }
1695
- console.log('in mousehover value');
1696
- console.log(isHover);
1697
1798
  if (this.widgetElement) {
1698
- console.log(1);
1699
- this.widgetElement.hoverStatus(isHover);
1700
- console.log(2);
1799
+ if (typeof this.widgetElement.hoverStatus === "function") {
1800
+ this.widgetElement.hoverStatus(isHover);
1801
+ }
1802
+ else {
1803
+ console.warn('widget framework outdated, please update to version 0.0.96');
1804
+ }
1701
1805
  }
1702
1806
  if (!isHover) {
1703
1807
  this.hideDropDown();
@@ -1902,8 +2006,6 @@
1902
2006
  * @return {?}
1903
2007
  */
1904
2008
  function (e) {
1905
- console.log('in widget default state');
1906
- console.log(e);
1907
2009
  widgetContainer.setEmptyState(e.detail);
1908
2010
  }));
1909
2011
  titleLineEnabled = widgetContainer.widgetElement.titleLineEnabled();
@@ -1981,16 +2083,11 @@
1981
2083
  */
1982
2084
  function (widgetInfo, forceEnable) {
1983
2085
  if (forceEnable === void 0) { forceEnable = false; }
1984
- console.log('in set no configured');
1985
- console.log(widgetInfo);
1986
- console.log(forceEnable);
1987
2086
  if ((widgetInfo.showDefaultState && (widgetInfo.widgetConfigInfo.config == "" || Object.keys(JSON.parse(widgetInfo.widgetConfigInfo.config)).length == 0)) || (forceEnable)) {
1988
- console.log('ininf');
1989
2087
  this.isWidgetStateApplicable = true;
1990
2088
  this.widgetEmptyState = widgetframework.WidgetViewState.emptyConfig.toString();
1991
2089
  }
1992
2090
  else {
1993
- console.log('in else');
1994
2091
  this.widgetEmptyState = '';
1995
2092
  this.isWidgetStateApplicable = false;
1996
2093
  }
@@ -2007,24 +2104,19 @@
2007
2104
  * @return {?}
2008
2105
  */
2009
2106
  function (widgetState) {
2010
- console.log('in wc contanjiner widget state');
2011
- console.log(widgetState);
2012
2107
  this.widgetEmptyState = widgetState;
2013
2108
  if (widgetState != widgetframework.WidgetViewState.normal) {
2014
2109
  this.isWidgetStateApplicable = true;
2015
2110
  this.isDownloadIconVisible = false;
2016
2111
  }
2017
2112
  else {
2018
- console.log('in else case');
2019
2113
  this.isWidgetStateApplicable = false;
2020
2114
  }
2021
2115
  switch (widgetState) {
2022
2116
  case widgetframework.WidgetViewState.emptyConfig:
2023
- console.log('in case emptyconfig');
2024
2117
  this.setNotConfiguredState(this.data.widgetInfo, true);
2025
2118
  break;
2026
2119
  case widgetframework.WidgetViewState.emptyData:
2027
- console.log('in case empty');
2028
2120
  break;
2029
2121
  case widgetframework.WidgetViewState.error:
2030
2122
  break;