@schneideress/dashboardframework 0.0.147 → 0.0.148

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.
@@ -5,18 +5,18 @@
5
5
  }(this, (function (exports, core, rxjs, raCommon, operators, ngxUiLoader, angularNotifier, widgetframework, platformBrowser, http, common, userControls, commonControls) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
8
+ Copyright (c) Microsoft Corporation. All rights reserved.
9
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10
+ this file except in compliance with the License. You may obtain a copy of the
11
+ License at http://www.apache.org/licenses/LICENSE-2.0
9
12
 
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
13
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16
+ MERCHANTABLITY OR NON-INFRINGEMENT.
12
17
 
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
18
+ See the Apache Version 2.0 License for specific language governing permissions
19
+ and limitations under the License.
20
20
  ***************************************************************************** */
21
21
  /* global Reflect, Promise */
22
22
 
@@ -109,13 +109,8 @@
109
109
  }
110
110
  }
111
111
 
112
- function __createBinding(o, m, k, k2) {
113
- if (k2 === undefined) k2 = k;
114
- o[k2] = m[k];
115
- }
116
-
117
112
  function __exportStar(m, exports) {
118
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
113
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
119
114
  }
120
115
 
121
116
  function __values(o) {
@@ -898,18 +893,182 @@
898
893
  //itemInitCallback: (item) => this.itemInitCallback(item)
899
894
  };
900
895
 
896
+ /**
897
+ * @fileoverview added by tsickle
898
+ * Generated from: lib/ra.dashboard.responsive.service.ts
899
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
900
+ */
901
+ /** @type {?} */
902
+ var DesktopViewStart = 1367;
903
+ var RADashboardResponsiveService = /** @class */ (function () {
904
+ function RADashboardResponsiveService() {
905
+ var _this = this;
906
+ this.resInfo = [
907
+ { 'start': 0, 'end': 767, 'minCols': 1, 'maxCols': 1 },
908
+ { 'start': 768, 'end': 1024, 'minCols': 1, 'maxCols': 2 },
909
+ { 'start': 1025, 'end': DesktopViewStart - 1, 'minCols': 2, 'maxCols': 6 },
910
+ { 'start': DesktopViewStart, 'end': 9999999999, 'minCols': 2, 'maxCols': 10 }
911
+ ];
912
+ this.setScreenWidth();
913
+ window.addEventListener('resize', (/**
914
+ * @return {?}
915
+ */
916
+ function () {
917
+ _this.setScreenWidth();
918
+ }));
919
+ }
920
+ /**
921
+ * @private
922
+ * @return {?}
923
+ */
924
+ RADashboardResponsiveService.prototype.setScreenWidth = /**
925
+ * @private
926
+ * @return {?}
927
+ */
928
+ function () {
929
+ var _this = this;
930
+ this.screenWidth = screen.width;
931
+ this.currentResInfo = this.resInfo.filter((/**
932
+ * @param {?} item
933
+ * @return {?}
934
+ */
935
+ function (item) {
936
+ return item.end >= _this.screenWidth && item.start <= _this.screenWidth;
937
+ }))[0];
938
+ };
939
+ Object.defineProperty(RADashboardResponsiveService.prototype, "IsDesktopView", {
940
+ get: /**
941
+ * @return {?}
942
+ */
943
+ function () {
944
+ return this.screenWidth >= DesktopViewStart;
945
+ },
946
+ enumerable: true,
947
+ configurable: true
948
+ });
949
+ Object.defineProperty(RADashboardResponsiveService.prototype, "GridsterConfig", {
950
+ get: /**
951
+ * @return {?}
952
+ */
953
+ function () {
954
+ /** @type {?} */
955
+ var config = GridsterConfigDefaultSettings;
956
+ config.minCols = this.currentResInfo.maxCols;
957
+ config.maxCols = this.currentResInfo.maxCols;
958
+ config.minRows = this.currentResInfo.minCols;
959
+ config.maxItemCols = this.currentResInfo.maxCols;
960
+ config.minItemCols = this.currentResInfo.minCols;
961
+ config.minItemRows = this.currentResInfo.minCols;
962
+ config.minItemArea = this.currentResInfo.minCols * this.currentResInfo.minCols;
963
+ config.defaultItemCols = this.currentResInfo.minCols;
964
+ config.defaultItemRows = this.currentResInfo.minCols;
965
+ if (!this.IsDesktopView) {
966
+ config.resizable.enabled = false;
967
+ config.swap = false;
968
+ config.draggable.enabled = false;
969
+ }
970
+ return config;
971
+ },
972
+ enumerable: true,
973
+ configurable: true
974
+ });
975
+ /**To map IwidgetInfo object to gridsterItem */
976
+ /**
977
+ * To map IwidgetInfo object to gridsterItem
978
+ * @param {?} widget
979
+ * @return {?}
980
+ */
981
+ RADashboardResponsiveService.prototype.getGridsterItem = /**
982
+ * To map IwidgetInfo object to gridsterItem
983
+ * @param {?} widget
984
+ * @return {?}
985
+ */
986
+ function (widget) {
987
+ /** @type {?} */
988
+ var gridsterItem = (/** @type {?} */ ({
989
+ cols: this.getWidth(widget.width),
990
+ rows: this.getHeight(widget.height),
991
+ x: this.IsDesktopView ? widget.position_x : 0,
992
+ y: this.IsDesktopView ? widget.position_y : 0,
993
+ widgetInfo: widget
994
+ }));
995
+ return gridsterItem;
996
+ };
997
+ /**
998
+ * @private
999
+ * @param {?} width
1000
+ * @return {?}
1001
+ */
1002
+ RADashboardResponsiveService.prototype.getWidth = /**
1003
+ * @private
1004
+ * @param {?} width
1005
+ * @return {?}
1006
+ */
1007
+ function (width) {
1008
+ if (!this.IsDesktopView) {
1009
+ width = Math.floor(width / 10 * this.currentResInfo.maxCols);
1010
+ if (width < this.currentResInfo.minCols)
1011
+ width = this.currentResInfo.minCols;
1012
+ }
1013
+ return width;
1014
+ };
1015
+ /**
1016
+ * @private
1017
+ * @param {?} height
1018
+ * @return {?}
1019
+ */
1020
+ RADashboardResponsiveService.prototype.getHeight = /**
1021
+ * @private
1022
+ * @param {?} height
1023
+ * @return {?}
1024
+ */
1025
+ function (height) {
1026
+ if (!this.IsDesktopView) {
1027
+ height = Math.floor(height / 10 * this.currentResInfo.maxCols);
1028
+ if (height < this.currentResInfo.minCols)
1029
+ height = this.currentResInfo.minCols;
1030
+ }
1031
+ return height;
1032
+ };
1033
+ RADashboardResponsiveService.decorators = [
1034
+ { type: core.Injectable, args: [{ providedIn: 'root' },] }
1035
+ ];
1036
+ /** @nocollapse */
1037
+ RADashboardResponsiveService.ctorParameters = function () { return []; };
1038
+ /** @nocollapse */ RADashboardResponsiveService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function RADashboardResponsiveService_Factory() { return new RADashboardResponsiveService(); }, token: RADashboardResponsiveService, providedIn: "root" });
1039
+ return RADashboardResponsiveService;
1040
+ }());
1041
+ if (false) {
1042
+ /**
1043
+ * @type {?}
1044
+ * @private
1045
+ */
1046
+ RADashboardResponsiveService.prototype.screenWidth;
1047
+ /**
1048
+ * @type {?}
1049
+ * @private
1050
+ */
1051
+ RADashboardResponsiveService.prototype.resInfo;
1052
+ /**
1053
+ * @type {?}
1054
+ * @private
1055
+ */
1056
+ RADashboardResponsiveService.prototype.currentResInfo;
1057
+ }
1058
+
901
1059
  /**
902
1060
  * @fileoverview added by tsickle
903
1061
  * Generated from: lib/ra-dashboard-area/ra.dashboard.area.ts
904
1062
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
905
1063
  */
906
1064
  var RADashboardArea = /** @class */ (function () {
907
- function RADashboardArea(dashboardService, ngZone, ngxService, translateService, notifier) {
1065
+ function RADashboardArea(dashboardService, ngZone, ngxService, translateService, notifier, responsiveService) {
908
1066
  this.dashboardService = dashboardService;
909
1067
  this.ngZone = ngZone;
910
1068
  this.ngxService = ngxService;
911
1069
  this.translateService = translateService;
912
1070
  this.notifier = notifier;
1071
+ this.responsiveService = responsiveService;
913
1072
  this.widgetList = Array();
914
1073
  this.gridheight = 300;
915
1074
  this.gridcellHeight = 0;
@@ -927,15 +1086,23 @@
927
1086
  * @return {?}
928
1087
  */
929
1088
  function (event) {
930
- /** @type {?} */
931
- var areaContext = this;
1089
+ var _this = this;
1090
+ this.widgetList = [];
932
1091
  setTimeout((/**
933
1092
  * @return {?}
934
1093
  */
935
1094
  function () {
936
- areaContext.setAreaHeight();
937
- areaContext.domResized = !areaContext.domResized;
938
- }), 1000);
1095
+ _this.initiateGridsterConfig();
1096
+ _this.options.api.optionsChanged();
1097
+ if (_this.userWidgets) {
1098
+ _this.widgetList = _this.mapObjectListToGridsterItemList(_this.userWidgets);
1099
+ _this.setAreaHeight();
1100
+ }
1101
+ else {
1102
+ _this.loadWidgets(_this.userDashboardId, _this.areaKey);
1103
+ }
1104
+ _this.domResized = !_this.domResized;
1105
+ }));
939
1106
  };
940
1107
  /**
941
1108
  * @return {?}
@@ -963,46 +1130,30 @@
963
1130
  this.inititateEventBusSubscritions();
964
1131
  }
965
1132
  };
966
- // public invokeResizeEvent() {
967
- // this.widgetContainers.forEach(function(container,i){
968
- // container.invokeWidgetResizedEvent();
969
- // });
970
- // }
971
1133
  /**To set GridsterConfig */
972
- // public invokeResizeEvent() {
973
- // this.widgetContainers.forEach(function(container,i){
974
- // container.invokeWidgetResizedEvent();
975
- // });
976
- // }
977
1134
  /**
978
1135
  * To set GridsterConfig
979
1136
  * @return {?}
980
1137
  */
981
- RADashboardArea.prototype.initiateGridsterConfig =
982
- // public invokeResizeEvent() {
983
- // this.widgetContainers.forEach(function(container,i){
984
- // container.invokeWidgetResizedEvent();
985
- // });
986
- // }
987
- /**
1138
+ RADashboardArea.prototype.initiateGridsterConfig = /**
988
1139
  * To set GridsterConfig
989
1140
  * @return {?}
990
1141
  */
991
1142
  function () {
992
- /** @type {?} */
993
- var areaContext = this;
1143
+ var _this = this;
994
1144
  /**To override default configuration values to the gridster control */
995
- this.options = GridsterConfigDefaultSettings;
1145
+ this.options = this.responsiveService.GridsterConfig;
996
1146
  this.options.itemChangeCallback = (/**
997
1147
  * @param {?} item
998
1148
  * @return {?}
999
1149
  */
1000
1150
  function (item) {
1001
- console.log('in item change clal back');
1002
- if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
1003
- areaContext.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
1151
+ if (_this.responsiveService.IsDesktopView) {
1152
+ if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
1153
+ _this.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
1154
+ }
1004
1155
  }
1005
- areaContext.setAreaHeight();
1156
+ _this.setAreaHeight();
1006
1157
  });
1007
1158
  };
1008
1159
  /** To initiate eventbus subsctiptions */
@@ -1061,7 +1212,6 @@
1061
1212
  * @return {?}
1062
1213
  */
1063
1214
  function () {
1064
- console.log('rearrange event bus triggered');
1065
1215
  _this.rearrangeWidgets();
1066
1216
  }));
1067
1217
  }));
@@ -1075,9 +1225,6 @@
1075
1225
  */
1076
1226
  function () {
1077
1227
  if (widgetList) {
1078
- // widgetList.forEach(widgetInfo => {
1079
- // this.addWidget(widgetInfo);
1080
- // });
1081
1228
  _this.addWidgetListToGridster(widgetList, 0);
1082
1229
  }
1083
1230
  }));
@@ -1241,21 +1388,36 @@
1241
1388
  function (userDashboarId, areaKey) {
1242
1389
  var _this = this;
1243
1390
  /** @type {?} */
1244
- var areaContext = this;
1245
- /** @type {?} */
1246
1391
  var widgetInfo = (/** @type {?} */ ({
1247
1392
  dashboardId: userDashboarId.toString(),
1248
1393
  dashboardAreaKey: areaKey
1249
1394
  }));
1250
- areaContext.widgetList = [];
1395
+ this.widgetList = [];
1251
1396
  this.dashboardService.getWidgetsByDashboardArea(widgetInfo, this.appConfig).subscribe((/**
1252
1397
  * @param {?} widgets
1253
1398
  * @return {?}
1254
1399
  */
1255
1400
  function (widgets) {
1401
+ //sorting the widgets y, x
1402
+ widgets = widgets.sort((/**
1403
+ * @param {?} a
1404
+ * @param {?} b
1405
+ * @return {?}
1406
+ */
1407
+ function (a, b) {
1408
+ if (a['position_y'] > b['position_y'])
1409
+ return 1;
1410
+ if (a['position_y'] < b['position_y'])
1411
+ return -1;
1412
+ if (a['position_x'] > b['position_x'])
1413
+ return 1;
1414
+ if (a['position_x'] < b['position_x'])
1415
+ return -1;
1416
+ }));
1417
+ _this.userWidgets = widgets;
1256
1418
  if (widgets && widgets.length > 0) {
1257
- areaContext.widgetList = _this.mapObjectListToGridsterItemList(widgets);
1258
- areaContext.setAreaHeight();
1419
+ _this.widgetList = _this.mapObjectListToGridsterItemList(widgets);
1420
+ _this.setAreaHeight();
1259
1421
  }
1260
1422
  }));
1261
1423
  };
@@ -1313,7 +1475,6 @@
1313
1475
  areaHeight = 600;
1314
1476
  }
1315
1477
  this.gridheight = areaHeight;
1316
- console.log('area height adjusted1');
1317
1478
  };
1318
1479
  /** To remove a widget instance from dashboard and to save info in database */
1319
1480
  /**
@@ -1378,20 +1539,11 @@
1378
1539
  */
1379
1540
  function (data) {
1380
1541
  var _this = this;
1381
- /** @type {?} */
1382
- var widgetid = data.widgetId;
1383
1542
  data.height = this.widgetHeight;
1384
1543
  data.width = this.widgetWidth;
1385
1544
  data.position_x = 0;
1386
1545
  data.position_y = 0;
1387
- /** @type {?} */
1388
- var gridsterItem = this.mapObjectsToGridsterItem(data);
1389
1546
  /** 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
1547
  data.dashboardAreaKey = this.areaKey;
1396
1548
  data.dashboardId = this.userDashboardId;
1397
1549
  this.ngxService.start();
@@ -1400,7 +1552,8 @@
1400
1552
  * @return {?}
1401
1553
  */
1402
1554
  function (widget) {
1403
- gridsterItem = _this.mapObjectsToGridsterItem(widget);
1555
+ /** @type {?} */
1556
+ var gridsterItem = _this.responsiveService.getGridsterItem(widget);
1404
1557
  _this.widgetList.push(gridsterItem);
1405
1558
  _this.setAreaHeight();
1406
1559
  if (_this.options.api) {
@@ -1438,39 +1591,13 @@
1438
1591
  * @return {?}
1439
1592
  */
1440
1593
  function (data) {
1594
+ data.position_x = 0;
1595
+ data.position_y = 0;
1441
1596
  /** @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);
1597
+ var gridsterItem = this.responsiveService.getGridsterItem(data);
1449
1598
  this.widgetList.push(gridsterItem);
1450
1599
  this.setAreaHeight();
1451
1600
  };
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
1601
  /**
1475
1602
  * @param {?} widgetList
1476
1603
  * @return {?}
@@ -1488,7 +1615,7 @@
1488
1615
  * @return {?}
1489
1616
  */
1490
1617
  function (widget) {
1491
- widgetArray.push(_this.mapObjectsToGridsterItem(widget));
1618
+ widgetArray.push(_this.responsiveService.getGridsterItem(widget));
1492
1619
  }));
1493
1620
  return widgetArray;
1494
1621
  };
@@ -1545,7 +1672,8 @@
1545
1672
  { type: core.NgZone },
1546
1673
  { type: ngxUiLoader.NgxUiLoaderService },
1547
1674
  { type: raCommon.RATranslateService },
1548
- { type: angularNotifier.NotifierService }
1675
+ { type: angularNotifier.NotifierService },
1676
+ { type: RADashboardResponsiveService }
1549
1677
  ]; };
1550
1678
  RADashboardArea.propDecorators = {
1551
1679
  userDashboardId: [{ type: core.Input, args: ['user-dashboard-id',] }],
@@ -1569,6 +1697,11 @@
1569
1697
  RADashboardArea.prototype.gridheight;
1570
1698
  /** @type {?} */
1571
1699
  RADashboardArea.prototype.gridcellHeight;
1700
+ /**
1701
+ * @type {?}
1702
+ * @private
1703
+ */
1704
+ RADashboardArea.prototype.userWidgets;
1572
1705
  /**
1573
1706
  * @type {?}
1574
1707
  * @private
@@ -1642,6 +1775,11 @@
1642
1775
  * @private
1643
1776
  */
1644
1777
  RADashboardArea.prototype.notifier;
1778
+ /**
1779
+ * @type {?}
1780
+ * @private
1781
+ */
1782
+ RADashboardArea.prototype.responsiveService;
1645
1783
  }
1646
1784
 
1647
1785
  /**
@@ -7855,6 +7993,7 @@
7855
7993
  exports.DashboardFrameworkModule = DashboardFrameworkModule;
7856
7994
  exports.RADashboardArea = RADashboardArea;
7857
7995
  exports.RADashboardEventBus = RADashboardEventBus;
7996
+ exports.RADashboardResponsiveService = RADashboardResponsiveService;
7858
7997
  exports.RAEvent = RAEvent;
7859
7998
  exports.RAEventKey = RAEventKey;
7860
7999
  exports.RAWidgetContainer = RAWidgetContainer;