@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.
@@ -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 */
@@ -942,17 +944,7 @@
942
944
  * @return {?}
943
945
  */
944
946
  function () {
945
- var _this = this;
946
947
  this.initiateGridsterConfig();
947
- this.widgetRearrangeSubject.subscribe((/**
948
- * @param {?} event
949
- * @return {?}
950
- */
951
- function (event) {
952
- console.log('in subscribe subject & value is');
953
- console.log(event);
954
- _this.rearrangeWidgets();
955
- }));
956
948
  };
957
949
  /**
958
950
  * @param {?} changes
@@ -1006,8 +998,11 @@
1006
998
  * @return {?}
1007
999
  */
1008
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
+ }
1009
1005
  areaContext.setAreaHeight();
1010
- areaContext.updateWidgets();
1011
1006
  });
1012
1007
  };
1013
1008
  /** To initiate eventbus subsctiptions */
@@ -1057,6 +1052,19 @@
1057
1052
  _this.addWidget(e);
1058
1053
  }));
1059
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
+ }));
1060
1068
  this.widgetLibraryDoneClick = this.raDashboardEventBus.subscribe(RAEvent.widgetLibraryDoneClick).subscribe((/**
1061
1069
  * @param {?} widgetList
1062
1070
  * @return {?}
@@ -1133,8 +1141,8 @@
1133
1141
  this.widgetDeleteEvent.unsubscribe();
1134
1142
  if (this.widgetLibraryDoneClick)
1135
1143
  this.widgetLibraryDoneClick.unsubscribe();
1136
- if (this.widgetRearrangeSubject)
1137
- this.widgetRearrangeSubject.unsubscribe();
1144
+ if (this.rearrangeWidgetClick)
1145
+ this.rearrangeWidgetClick.unsubscribe();
1138
1146
  };
1139
1147
  /**To update position/dimention of all widgets in the area */
1140
1148
  /**
@@ -1154,6 +1162,69 @@
1154
1162
  }));
1155
1163
  return true;
1156
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
+ };
1157
1228
  /** To retrieve widgets based on userDashboardid and area name */
1158
1229
  /**
1159
1230
  * To retrieve widgets based on userDashboardid and area name
@@ -1285,7 +1356,6 @@
1285
1356
  * @return {?}
1286
1357
  */
1287
1358
  function () {
1288
- console.log('in rearrange widgets methd');
1289
1359
  this.options.compactType = 'compactUp&Left';
1290
1360
  this.options.api.optionsChanged();
1291
1361
  this.options.compactType = 'none';
@@ -1341,13 +1411,18 @@
1341
1411
  _this.gridcellHeight = curRowHeight;
1342
1412
  }
1343
1413
  }
1344
- /**To save added widget position in db */
1345
- setTimeout((/**
1346
- * @return {?}
1347
- */
1348
- function () {
1349
- _this.updateWidgets();
1350
- }), 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
+ }
1351
1426
  _this.raDashboardEventBus.publish(RAEvent.WidgetAdded, widget);
1352
1427
  }));
1353
1428
  };
@@ -1480,7 +1555,6 @@
1480
1555
  widgetHeight: [{ type: core.Input, args: ['widget-height',] }],
1481
1556
  widgetWidth: [{ type: core.Input, args: ['widget-width',] }],
1482
1557
  appConfig: [{ type: core.Input, args: ['app-config',] }],
1483
- widgetRearrangeSubject: [{ type: core.Input }],
1484
1558
  gridWrapper: [{ type: core.ViewChild, args: ['gridWrapper', { static: false },] }],
1485
1559
  onResize: [{ type: core.HostListener, args: ['window:resize', ['$event'],] }]
1486
1560
  };
@@ -1500,6 +1574,11 @@
1500
1574
  * @private
1501
1575
  */
1502
1576
  RADashboardArea.prototype.conifgAddClick;
1577
+ /**
1578
+ * @type {?}
1579
+ * @private
1580
+ */
1581
+ RADashboardArea.prototype.rearrangeWidgetClick;
1503
1582
  /**
1504
1583
  * @type {?}
1505
1584
  * @private
@@ -1537,8 +1616,6 @@
1537
1616
  /** @type {?} */
1538
1617
  RADashboardArea.prototype.appConfig;
1539
1618
  /** @type {?} */
1540
- RADashboardArea.prototype.widgetRearrangeSubject;
1541
- /** @type {?} */
1542
1619
  RADashboardArea.prototype.gridWrapper;
1543
1620
  /**
1544
1621
  * @type {?}
@@ -7620,7 +7697,6 @@
7620
7697
  function RaBaseDashboardTemplate(ngZone) {
7621
7698
  var _this = this;
7622
7699
  this.ngZone = ngZone;
7623
- this.widgetRearrangeSubject = new rxjs.Subject();
7624
7700
  this.initialize = (/**
7625
7701
  * @param {?} eventBus
7626
7702
  * @param {?} userDashboardId
@@ -7638,17 +7714,6 @@
7638
7714
  }));
7639
7715
  _this.init();
7640
7716
  });
7641
- this.rearrangeWidgets = (/**
7642
- * @return {?}
7643
- */
7644
- function () {
7645
- _this.ngZone.run((/**
7646
- * @return {?}
7647
- */
7648
- function () {
7649
- _this.widgetRearrangeSubject.next(true);
7650
- }));
7651
- });
7652
7717
  }
7653
7718
  /**
7654
7719
  * @return {?}
@@ -7664,8 +7729,7 @@
7664
7729
  RaBaseDashboardTemplate.propDecorators = {
7665
7730
  dashboardId: [{ type: core.Input, args: ['dashboard-id',] }],
7666
7731
  globalFilter: [{ type: core.Input, args: ['global-filter',] }],
7667
- initialize: [{ type: core.Input }],
7668
- rearrangeWidgets: [{ type: core.Input }]
7732
+ initialize: [{ type: core.Input }]
7669
7733
  };
7670
7734
  return RaBaseDashboardTemplate;
7671
7735
  }());
@@ -7677,15 +7741,11 @@
7677
7741
  /** @type {?} */
7678
7742
  RaBaseDashboardTemplate.prototype.appConfig;
7679
7743
  /** @type {?} */
7680
- RaBaseDashboardTemplate.prototype.widgetRearrangeSubject;
7681
- /** @type {?} */
7682
7744
  RaBaseDashboardTemplate.prototype.dashboardId;
7683
7745
  /** @type {?} */
7684
7746
  RaBaseDashboardTemplate.prototype.globalFilter;
7685
7747
  /** @type {?} */
7686
7748
  RaBaseDashboardTemplate.prototype.initialize;
7687
- /** @type {?} */
7688
- RaBaseDashboardTemplate.prototype.rearrangeWidgets;
7689
7749
  /**
7690
7750
  * @type {?}
7691
7751
  * @private