@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.
@@ -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 */
@@ -731,17 +733,7 @@ var RADashboardArea = /** @class */ (function () {
731
733
  * @return {?}
732
734
  */
733
735
  function () {
734
- var _this = this;
735
736
  this.initiateGridsterConfig();
736
- this.widgetRearrangeSubject.subscribe((/**
737
- * @param {?} event
738
- * @return {?}
739
- */
740
- function (event) {
741
- console.log('in subscribe subject & value is');
742
- console.log(event);
743
- _this.rearrangeWidgets();
744
- }));
745
737
  };
746
738
  /**
747
739
  * @param {?} changes
@@ -795,8 +787,11 @@ var RADashboardArea = /** @class */ (function () {
795
787
  * @return {?}
796
788
  */
797
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
+ }
798
794
  areaContext.setAreaHeight();
799
- areaContext.updateWidgets();
800
795
  });
801
796
  };
802
797
  /** To initiate eventbus subsctiptions */
@@ -846,6 +841,19 @@ var RADashboardArea = /** @class */ (function () {
846
841
  _this.addWidget(e);
847
842
  }));
848
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
+ }));
849
857
  this.widgetLibraryDoneClick = this.raDashboardEventBus.subscribe(RAEvent.widgetLibraryDoneClick).subscribe((/**
850
858
  * @param {?} widgetList
851
859
  * @return {?}
@@ -922,8 +930,8 @@ var RADashboardArea = /** @class */ (function () {
922
930
  this.widgetDeleteEvent.unsubscribe();
923
931
  if (this.widgetLibraryDoneClick)
924
932
  this.widgetLibraryDoneClick.unsubscribe();
925
- if (this.widgetRearrangeSubject)
926
- this.widgetRearrangeSubject.unsubscribe();
933
+ if (this.rearrangeWidgetClick)
934
+ this.rearrangeWidgetClick.unsubscribe();
927
935
  };
928
936
  /**To update position/dimention of all widgets in the area */
929
937
  /**
@@ -943,6 +951,69 @@ var RADashboardArea = /** @class */ (function () {
943
951
  }));
944
952
  return true;
945
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
+ };
946
1017
  /** To retrieve widgets based on userDashboardid and area name */
947
1018
  /**
948
1019
  * To retrieve widgets based on userDashboardid and area name
@@ -1074,7 +1145,6 @@ var RADashboardArea = /** @class */ (function () {
1074
1145
  * @return {?}
1075
1146
  */
1076
1147
  function () {
1077
- console.log('in rearrange widgets methd');
1078
1148
  this.options.compactType = 'compactUp&Left';
1079
1149
  this.options.api.optionsChanged();
1080
1150
  this.options.compactType = 'none';
@@ -1130,13 +1200,18 @@ var RADashboardArea = /** @class */ (function () {
1130
1200
  _this.gridcellHeight = curRowHeight;
1131
1201
  }
1132
1202
  }
1133
- /**To save added widget position in db */
1134
- setTimeout((/**
1135
- * @return {?}
1136
- */
1137
- function () {
1138
- _this.updateWidgets();
1139
- }), 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
+ }
1140
1215
  _this.raDashboardEventBus.publish(RAEvent.WidgetAdded, widget);
1141
1216
  }));
1142
1217
  };
@@ -1269,7 +1344,6 @@ var RADashboardArea = /** @class */ (function () {
1269
1344
  widgetHeight: [{ type: Input, args: ['widget-height',] }],
1270
1345
  widgetWidth: [{ type: Input, args: ['widget-width',] }],
1271
1346
  appConfig: [{ type: Input, args: ['app-config',] }],
1272
- widgetRearrangeSubject: [{ type: Input }],
1273
1347
  gridWrapper: [{ type: ViewChild, args: ['gridWrapper', { static: false },] }],
1274
1348
  onResize: [{ type: HostListener, args: ['window:resize', ['$event'],] }]
1275
1349
  };
@@ -1289,6 +1363,11 @@ if (false) {
1289
1363
  * @private
1290
1364
  */
1291
1365
  RADashboardArea.prototype.conifgAddClick;
1366
+ /**
1367
+ * @type {?}
1368
+ * @private
1369
+ */
1370
+ RADashboardArea.prototype.rearrangeWidgetClick;
1292
1371
  /**
1293
1372
  * @type {?}
1294
1373
  * @private
@@ -1326,8 +1405,6 @@ if (false) {
1326
1405
  /** @type {?} */
1327
1406
  RADashboardArea.prototype.appConfig;
1328
1407
  /** @type {?} */
1329
- RADashboardArea.prototype.widgetRearrangeSubject;
1330
- /** @type {?} */
1331
1408
  RADashboardArea.prototype.gridWrapper;
1332
1409
  /**
1333
1410
  * @type {?}
@@ -7409,7 +7486,6 @@ var RaBaseDashboardTemplate = /** @class */ (function () {
7409
7486
  function RaBaseDashboardTemplate(ngZone) {
7410
7487
  var _this = this;
7411
7488
  this.ngZone = ngZone;
7412
- this.widgetRearrangeSubject = new Subject();
7413
7489
  this.initialize = (/**
7414
7490
  * @param {?} eventBus
7415
7491
  * @param {?} userDashboardId
@@ -7427,17 +7503,6 @@ var RaBaseDashboardTemplate = /** @class */ (function () {
7427
7503
  }));
7428
7504
  _this.init();
7429
7505
  });
7430
- this.rearrangeWidgets = (/**
7431
- * @return {?}
7432
- */
7433
- function () {
7434
- _this.ngZone.run((/**
7435
- * @return {?}
7436
- */
7437
- function () {
7438
- _this.widgetRearrangeSubject.next(true);
7439
- }));
7440
- });
7441
7506
  }
7442
7507
  /**
7443
7508
  * @return {?}
@@ -7453,8 +7518,7 @@ var RaBaseDashboardTemplate = /** @class */ (function () {
7453
7518
  RaBaseDashboardTemplate.propDecorators = {
7454
7519
  dashboardId: [{ type: Input, args: ['dashboard-id',] }],
7455
7520
  globalFilter: [{ type: Input, args: ['global-filter',] }],
7456
- initialize: [{ type: Input }],
7457
- rearrangeWidgets: [{ type: Input }]
7521
+ initialize: [{ type: Input }]
7458
7522
  };
7459
7523
  return RaBaseDashboardTemplate;
7460
7524
  }());
@@ -7466,15 +7530,11 @@ if (false) {
7466
7530
  /** @type {?} */
7467
7531
  RaBaseDashboardTemplate.prototype.appConfig;
7468
7532
  /** @type {?} */
7469
- RaBaseDashboardTemplate.prototype.widgetRearrangeSubject;
7470
- /** @type {?} */
7471
7533
  RaBaseDashboardTemplate.prototype.dashboardId;
7472
7534
  /** @type {?} */
7473
7535
  RaBaseDashboardTemplate.prototype.globalFilter;
7474
7536
  /** @type {?} */
7475
7537
  RaBaseDashboardTemplate.prototype.initialize;
7476
- /** @type {?} */
7477
- RaBaseDashboardTemplate.prototype.rearrangeWidgets;
7478
7538
  /**
7479
7539
  * @type {?}
7480
7540
  * @private