@schneideress/dashboardframework 0.0.147 → 0.0.149

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.
@@ -898,18 +898,195 @@
898
898
  //itemInitCallback: (item) => this.itemInitCallback(item)
899
899
  };
900
900
 
901
+ /**
902
+ * @fileoverview added by tsickle
903
+ * Generated from: lib/ra.dashboard.responsive.service.ts
904
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
905
+ */
906
+ /** @type {?} */
907
+ var DesktopViewStart = 1367;
908
+ /** @type {?} */
909
+ var GridLockViewEnd = 1024;
910
+ var RADashboardResponsiveService = /** @class */ (function () {
911
+ function RADashboardResponsiveService() {
912
+ var _this = this;
913
+ this.resInfo = [
914
+ { 'start': 0, 'end': 767, 'minCols': 1, 'maxCols': 1 },
915
+ { 'start': 768, 'end': GridLockViewEnd, 'minCols': 1, 'maxCols': 2 },
916
+ { 'start': GridLockViewEnd + 1, 'end': DesktopViewStart - 1, 'minCols': 2, 'maxCols': 6 },
917
+ { 'start': DesktopViewStart, 'end': 9999999999, 'minCols': 2, 'maxCols': 10 }
918
+ ];
919
+ this.setScreenWidth();
920
+ window.addEventListener('resize', (/**
921
+ * @return {?}
922
+ */
923
+ function () {
924
+ _this.setScreenWidth();
925
+ }));
926
+ }
927
+ /**
928
+ * @private
929
+ * @return {?}
930
+ */
931
+ RADashboardResponsiveService.prototype.setScreenWidth = /**
932
+ * @private
933
+ * @return {?}
934
+ */
935
+ function () {
936
+ var _this = this;
937
+ this.screenWidth = screen.width;
938
+ this.currentResInfo = this.resInfo.filter((/**
939
+ * @param {?} item
940
+ * @return {?}
941
+ */
942
+ function (item) {
943
+ return item.end >= _this.screenWidth && item.start <= _this.screenWidth;
944
+ }))[0];
945
+ };
946
+ Object.defineProperty(RADashboardResponsiveService.prototype, "IsDesktopView", {
947
+ get: /**
948
+ * @return {?}
949
+ */
950
+ function () {
951
+ return this.screenWidth >= DesktopViewStart;
952
+ },
953
+ enumerable: true,
954
+ configurable: true
955
+ });
956
+ Object.defineProperty(RADashboardResponsiveService.prototype, "IsGridLocked", {
957
+ get: /**
958
+ * @return {?}
959
+ */
960
+ function () {
961
+ return this.screenWidth <= GridLockViewEnd;
962
+ },
963
+ enumerable: true,
964
+ configurable: true
965
+ });
966
+ Object.defineProperty(RADashboardResponsiveService.prototype, "GridsterConfig", {
967
+ get: /**
968
+ * @return {?}
969
+ */
970
+ function () {
971
+ /** @type {?} */
972
+ var config = GridsterConfigDefaultSettings;
973
+ config.minCols = this.currentResInfo.maxCols;
974
+ config.maxCols = this.currentResInfo.maxCols;
975
+ config.minRows = this.currentResInfo.minCols;
976
+ config.maxItemCols = this.currentResInfo.maxCols;
977
+ config.minItemCols = this.currentResInfo.minCols;
978
+ config.minItemRows = this.currentResInfo.minCols;
979
+ config.minItemArea = this.currentResInfo.minCols * this.currentResInfo.minCols;
980
+ config.defaultItemCols = this.currentResInfo.minCols;
981
+ config.defaultItemRows = this.currentResInfo.minCols;
982
+ if (!this.IsDesktopView) {
983
+ config.resizable.enabled = false;
984
+ config.swap = false;
985
+ config.draggable.enabled = false;
986
+ }
987
+ return config;
988
+ },
989
+ enumerable: true,
990
+ configurable: true
991
+ });
992
+ /**To map IwidgetInfo object to gridsterItem */
993
+ /**
994
+ * To map IwidgetInfo object to gridsterItem
995
+ * @param {?} widget
996
+ * @return {?}
997
+ */
998
+ RADashboardResponsiveService.prototype.getGridsterItem = /**
999
+ * To map IwidgetInfo object to gridsterItem
1000
+ * @param {?} widget
1001
+ * @return {?}
1002
+ */
1003
+ function (widget) {
1004
+ /** @type {?} */
1005
+ var gridsterItem = (/** @type {?} */ ({
1006
+ cols: this.getWidth(widget.width),
1007
+ rows: this.getHeight(widget.height),
1008
+ x: this.IsDesktopView ? widget.position_x : 0,
1009
+ y: this.IsDesktopView ? widget.position_y : 0,
1010
+ isInitialized: widget.isInitialized,
1011
+ widgetInfo: widget
1012
+ }));
1013
+ return gridsterItem;
1014
+ };
1015
+ /**
1016
+ * @private
1017
+ * @param {?} width
1018
+ * @return {?}
1019
+ */
1020
+ RADashboardResponsiveService.prototype.getWidth = /**
1021
+ * @private
1022
+ * @param {?} width
1023
+ * @return {?}
1024
+ */
1025
+ function (width) {
1026
+ if (!this.IsDesktopView) {
1027
+ width = Math.floor(width / 10 * this.currentResInfo.maxCols);
1028
+ if (width < this.currentResInfo.minCols)
1029
+ width = this.currentResInfo.minCols;
1030
+ }
1031
+ return width;
1032
+ };
1033
+ /**
1034
+ * @private
1035
+ * @param {?} height
1036
+ * @return {?}
1037
+ */
1038
+ RADashboardResponsiveService.prototype.getHeight = /**
1039
+ * @private
1040
+ * @param {?} height
1041
+ * @return {?}
1042
+ */
1043
+ function (height) {
1044
+ if (!this.IsDesktopView) {
1045
+ height = Math.floor(height / 10 * this.currentResInfo.maxCols);
1046
+ if (height < this.currentResInfo.minCols)
1047
+ height = this.currentResInfo.minCols;
1048
+ }
1049
+ return height;
1050
+ };
1051
+ RADashboardResponsiveService.decorators = [
1052
+ { type: core.Injectable, args: [{ providedIn: 'root' },] }
1053
+ ];
1054
+ /** @nocollapse */
1055
+ RADashboardResponsiveService.ctorParameters = function () { return []; };
1056
+ /** @nocollapse */ RADashboardResponsiveService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function RADashboardResponsiveService_Factory() { return new RADashboardResponsiveService(); }, token: RADashboardResponsiveService, providedIn: "root" });
1057
+ return RADashboardResponsiveService;
1058
+ }());
1059
+ if (false) {
1060
+ /**
1061
+ * @type {?}
1062
+ * @private
1063
+ */
1064
+ RADashboardResponsiveService.prototype.screenWidth;
1065
+ /**
1066
+ * @type {?}
1067
+ * @private
1068
+ */
1069
+ RADashboardResponsiveService.prototype.resInfo;
1070
+ /**
1071
+ * @type {?}
1072
+ * @private
1073
+ */
1074
+ RADashboardResponsiveService.prototype.currentResInfo;
1075
+ }
1076
+
901
1077
  /**
902
1078
  * @fileoverview added by tsickle
903
1079
  * Generated from: lib/ra-dashboard-area/ra.dashboard.area.ts
904
1080
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
905
1081
  */
906
1082
  var RADashboardArea = /** @class */ (function () {
907
- function RADashboardArea(dashboardService, ngZone, ngxService, translateService, notifier) {
1083
+ function RADashboardArea(dashboardService, ngZone, ngxService, translateService, notifier, responsiveService) {
908
1084
  this.dashboardService = dashboardService;
909
1085
  this.ngZone = ngZone;
910
1086
  this.ngxService = ngxService;
911
1087
  this.translateService = translateService;
912
1088
  this.notifier = notifier;
1089
+ this.responsiveService = responsiveService;
913
1090
  this.widgetList = Array();
914
1091
  this.gridheight = 300;
915
1092
  this.gridcellHeight = 0;
@@ -927,15 +1104,23 @@
927
1104
  * @return {?}
928
1105
  */
929
1106
  function (event) {
930
- /** @type {?} */
931
- var areaContext = this;
1107
+ var _this = this;
1108
+ this.widgetList = [];
932
1109
  setTimeout((/**
933
1110
  * @return {?}
934
1111
  */
935
1112
  function () {
936
- areaContext.setAreaHeight();
937
- areaContext.domResized = !areaContext.domResized;
938
- }), 1000);
1113
+ _this.initiateGridsterConfig();
1114
+ _this.options.api.optionsChanged();
1115
+ if (_this.userWidgets) {
1116
+ _this.widgetList = _this.mapObjectListToGridsterItemList(_this.userWidgets);
1117
+ _this.setAreaHeight();
1118
+ }
1119
+ else {
1120
+ _this.loadWidgets(_this.userDashboardId, _this.areaKey);
1121
+ }
1122
+ _this.domResized = !_this.domResized;
1123
+ }));
939
1124
  };
940
1125
  /**
941
1126
  * @return {?}
@@ -963,46 +1148,44 @@
963
1148
  this.inititateEventBusSubscritions();
964
1149
  }
965
1150
  };
966
- // public invokeResizeEvent() {
967
- // this.widgetContainers.forEach(function(container,i){
968
- // container.invokeWidgetResizedEvent();
969
- // });
970
- // }
971
1151
  /**To set GridsterConfig */
972
- // public invokeResizeEvent() {
973
- // this.widgetContainers.forEach(function(container,i){
974
- // container.invokeWidgetResizedEvent();
975
- // });
976
- // }
977
1152
  /**
978
1153
  * To set GridsterConfig
979
1154
  * @return {?}
980
1155
  */
981
- RADashboardArea.prototype.initiateGridsterConfig =
982
- // public invokeResizeEvent() {
983
- // this.widgetContainers.forEach(function(container,i){
984
- // container.invokeWidgetResizedEvent();
985
- // });
986
- // }
987
- /**
1156
+ RADashboardArea.prototype.initiateGridsterConfig = /**
988
1157
  * To set GridsterConfig
989
1158
  * @return {?}
990
1159
  */
991
1160
  function () {
992
- /** @type {?} */
993
- var areaContext = this;
1161
+ var _this = this;
994
1162
  /**To override default configuration values to the gridster control */
995
- this.options = GridsterConfigDefaultSettings;
1163
+ this.options = this.responsiveService.GridsterConfig;
996
1164
  this.options.itemChangeCallback = (/**
997
1165
  * @param {?} item
998
1166
  * @return {?}
999
1167
  */
1000
1168
  function (item) {
1001
- console.log('in item change clal back');
1002
- if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
1003
- areaContext.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
1169
+ if (item.isInitialized) {
1170
+ if (!_this.responsiveService.IsGridLocked) {
1171
+ if (!_this.responsiveService.IsDesktopView) {
1172
+ _this.updateWidgets();
1173
+ }
1174
+ else {
1175
+ if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
1176
+ _this.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
1177
+ }
1178
+ }
1179
+ }
1180
+ _this.setAreaHeight();
1004
1181
  }
1005
- areaContext.setAreaHeight();
1182
+ });
1183
+ this.options.itemInitCallback = (/**
1184
+ * @param {?} item
1185
+ * @return {?}
1186
+ */
1187
+ function (item) {
1188
+ item.isInitialized = true;
1006
1189
  });
1007
1190
  };
1008
1191
  /** To initiate eventbus subsctiptions */
@@ -1061,7 +1244,6 @@
1061
1244
  * @return {?}
1062
1245
  */
1063
1246
  function () {
1064
- console.log('rearrange event bus triggered');
1065
1247
  _this.rearrangeWidgets();
1066
1248
  }));
1067
1249
  }));
@@ -1075,9 +1257,6 @@
1075
1257
  */
1076
1258
  function () {
1077
1259
  if (widgetList) {
1078
- // widgetList.forEach(widgetInfo => {
1079
- // this.addWidget(widgetInfo);
1080
- // });
1081
1260
  _this.addWidgetListToGridster(widgetList, 0);
1082
1261
  }
1083
1262
  }));
@@ -1154,7 +1333,7 @@
1154
1333
  * @return {?}
1155
1334
  */
1156
1335
  function () {
1157
- this.dashboardService.updateWidgets(this.mapGridsterListToObject(this.widgetList), this.appConfig).subscribe((/**
1336
+ this.dashboardService.updateWidgets(this.formatWidgetDataForPositionDetails(this.mapGridsterListToObject(this.widgetList)), this.appConfig).subscribe((/**
1158
1337
  * @param {?} widgets
1159
1338
  * @return {?}
1160
1339
  */
@@ -1241,21 +1420,36 @@
1241
1420
  function (userDashboarId, areaKey) {
1242
1421
  var _this = this;
1243
1422
  /** @type {?} */
1244
- var areaContext = this;
1245
- /** @type {?} */
1246
1423
  var widgetInfo = (/** @type {?} */ ({
1247
1424
  dashboardId: userDashboarId.toString(),
1248
1425
  dashboardAreaKey: areaKey
1249
1426
  }));
1250
- areaContext.widgetList = [];
1427
+ this.widgetList = [];
1251
1428
  this.dashboardService.getWidgetsByDashboardArea(widgetInfo, this.appConfig).subscribe((/**
1252
1429
  * @param {?} widgets
1253
1430
  * @return {?}
1254
1431
  */
1255
1432
  function (widgets) {
1433
+ //sorting the widgets y, x
1434
+ widgets = widgets.sort((/**
1435
+ * @param {?} a
1436
+ * @param {?} b
1437
+ * @return {?}
1438
+ */
1439
+ function (a, b) {
1440
+ if (a['position_y'] > b['position_y'])
1441
+ return 1;
1442
+ if (a['position_y'] < b['position_y'])
1443
+ return -1;
1444
+ if (a['position_x'] > b['position_x'])
1445
+ return 1;
1446
+ if (a['position_x'] < b['position_x'])
1447
+ return -1;
1448
+ }));
1449
+ _this.userWidgets = widgets;
1256
1450
  if (widgets && widgets.length > 0) {
1257
- areaContext.widgetList = _this.mapObjectListToGridsterItemList(widgets);
1258
- areaContext.setAreaHeight();
1451
+ _this.widgetList = _this.mapObjectListToGridsterItemList(widgets);
1452
+ _this.setAreaHeight();
1259
1453
  }
1260
1454
  }));
1261
1455
  };
@@ -1313,7 +1507,6 @@
1313
1507
  areaHeight = 600;
1314
1508
  }
1315
1509
  this.gridheight = areaHeight;
1316
- console.log('area height adjusted1');
1317
1510
  };
1318
1511
  /** To remove a widget instance from dashboard and to save info in database */
1319
1512
  /**
@@ -1378,20 +1571,12 @@
1378
1571
  */
1379
1572
  function (data) {
1380
1573
  var _this = this;
1381
- /** @type {?} */
1382
- var widgetid = data.widgetId;
1383
1574
  data.height = this.widgetHeight;
1384
1575
  data.width = this.widgetWidth;
1385
1576
  data.position_x = 0;
1386
1577
  data.position_y = 0;
1387
- /** @type {?} */
1388
- var gridsterItem = this.mapObjectsToGridsterItem(data);
1578
+ data.isInitialized = true;
1389
1579
  /** to find the available position in gridster, temp commenting the code-returning higher y value than normal */
1390
- // if (this.options.api) {
1391
- // gridsterItem = this.options.api.getFirstPossiblePosition(gridsterItem);
1392
- // }
1393
- // data.position_x = gridsterItem.x;
1394
- // data.position_y = gridsterItem.y;
1395
1580
  data.dashboardAreaKey = this.areaKey;
1396
1581
  data.dashboardId = this.userDashboardId;
1397
1582
  this.ngxService.start();
@@ -1400,7 +1585,8 @@
1400
1585
  * @return {?}
1401
1586
  */
1402
1587
  function (widget) {
1403
- gridsterItem = _this.mapObjectsToGridsterItem(widget);
1588
+ /** @type {?} */
1589
+ var gridsterItem = _this.responsiveService.getGridsterItem(widget);
1404
1590
  _this.widgetList.push(gridsterItem);
1405
1591
  _this.setAreaHeight();
1406
1592
  if (_this.options.api) {
@@ -1438,39 +1624,14 @@
1438
1624
  * @return {?}
1439
1625
  */
1440
1626
  function (data) {
1627
+ data.position_x = 0;
1628
+ data.position_y = 0;
1629
+ data.isInitialized = true;
1441
1630
  /** @type {?} */
1442
- var gridsterItem = this.mapObjectsToGridsterItem(data);
1443
- if (this.options.api) {
1444
- gridsterItem = this.options.api.getFirstPossiblePosition(gridsterItem);
1445
- }
1446
- data.position_x = gridsterItem.x;
1447
- data.position_y = gridsterItem.y;
1448
- gridsterItem = this.mapObjectsToGridsterItem(data);
1631
+ var gridsterItem = this.responsiveService.getGridsterItem(data);
1449
1632
  this.widgetList.push(gridsterItem);
1450
1633
  this.setAreaHeight();
1451
1634
  };
1452
- /**To map IwidgetInfo object to gridsterItem */
1453
- /**
1454
- * To map IwidgetInfo object to gridsterItem
1455
- * @param {?} widget
1456
- * @return {?}
1457
- */
1458
- RADashboardArea.prototype.mapObjectsToGridsterItem = /**
1459
- * To map IwidgetInfo object to gridsterItem
1460
- * @param {?} widget
1461
- * @return {?}
1462
- */
1463
- function (widget) {
1464
- /** @type {?} */
1465
- var gridsterItem = (/** @type {?} */ ({
1466
- cols: widget.width,
1467
- rows: widget.height,
1468
- x: widget.position_x,
1469
- y: widget.position_y,
1470
- widgetInfo: widget
1471
- }));
1472
- return gridsterItem;
1473
- };
1474
1635
  /**
1475
1636
  * @param {?} widgetList
1476
1637
  * @return {?}
@@ -1488,7 +1649,7 @@
1488
1649
  * @return {?}
1489
1650
  */
1490
1651
  function (widget) {
1491
- widgetArray.push(_this.mapObjectsToGridsterItem(widget));
1652
+ widgetArray.push(_this.responsiveService.getGridsterItem(widget));
1492
1653
  }));
1493
1654
  return widgetArray;
1494
1655
  };
@@ -1545,7 +1706,8 @@
1545
1706
  { type: core.NgZone },
1546
1707
  { type: ngxUiLoader.NgxUiLoaderService },
1547
1708
  { type: raCommon.RATranslateService },
1548
- { type: angularNotifier.NotifierService }
1709
+ { type: angularNotifier.NotifierService },
1710
+ { type: RADashboardResponsiveService }
1549
1711
  ]; };
1550
1712
  RADashboardArea.propDecorators = {
1551
1713
  userDashboardId: [{ type: core.Input, args: ['user-dashboard-id',] }],
@@ -1569,6 +1731,11 @@
1569
1731
  RADashboardArea.prototype.gridheight;
1570
1732
  /** @type {?} */
1571
1733
  RADashboardArea.prototype.gridcellHeight;
1734
+ /**
1735
+ * @type {?}
1736
+ * @private
1737
+ */
1738
+ RADashboardArea.prototype.userWidgets;
1572
1739
  /**
1573
1740
  * @type {?}
1574
1741
  * @private
@@ -1642,6 +1809,11 @@
1642
1809
  * @private
1643
1810
  */
1644
1811
  RADashboardArea.prototype.notifier;
1812
+ /**
1813
+ * @type {?}
1814
+ * @private
1815
+ */
1816
+ RADashboardArea.prototype.responsiveService;
1645
1817
  }
1646
1818
 
1647
1819
  /**
@@ -7855,6 +8027,7 @@
7855
8027
  exports.DashboardFrameworkModule = DashboardFrameworkModule;
7856
8028
  exports.RADashboardArea = RADashboardArea;
7857
8029
  exports.RADashboardEventBus = RADashboardEventBus;
8030
+ exports.RADashboardResponsiveService = RADashboardResponsiveService;
7858
8031
  exports.RAEvent = RAEvent;
7859
8032
  exports.RAEventKey = RAEventKey;
7860
8033
  exports.RAWidgetContainer = RAWidgetContainer;