@schneideress/dashboardframework 0.0.183 → 0.0.184

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) {
@@ -686,11 +681,13 @@
686
681
  var RADashboardResponsiveService = /** @class */ (function () {
687
682
  function RADashboardResponsiveService() {
688
683
  var _this = this;
684
+ this.resized = new rxjs.Subject();
685
+ this.maxColsDesktop = 8;
689
686
  this.resInfo = [
690
- { 'start': 0, 'end': 767, 'minCols': 1, 'maxCols': 1 },
691
- { 'start': 768, 'end': 1024, 'minCols': 1, 'maxCols': 2 },
692
- { 'start': 1025, 'end': 1366, 'minCols': 1, 'maxCols': 6 },
693
- { 'start': 1367, 'end': 9999999999, 'minCols': 1, 'maxCols': 8 }
687
+ { 'id': 1, 'start': 0, 'end': 767, 'minCols': 1, 'maxCols': 1 },
688
+ { 'id': 2, 'start': 768, 'end': 1024, 'minCols': 1, 'maxCols': 2 },
689
+ { 'id': 3, 'start': 1025, 'end': 1366, 'minCols': 1, 'maxCols': 6 },
690
+ { 'id': 4, 'start': 1367, 'end': 9999999999, 'minCols': 1, 'maxCols': this.maxColsDesktop }
694
691
  ];
695
692
  this.setScreenWidth();
696
693
  window.addEventListener('resize', (/**
@@ -715,13 +712,18 @@
715
712
  this.currentResInfo = this.resInfo[3];
716
713
  }
717
714
  else {
718
- this.currentResInfo = this.resInfo.filter((/**
715
+ /** @type {?} */
716
+ var resInfo = this.resInfo.filter((/**
719
717
  * @param {?} item
720
718
  * @return {?}
721
719
  */
722
720
  function (item) {
723
721
  return item.end >= _this.screenWidth && item.start <= _this.screenWidth;
724
722
  }))[0];
723
+ if (!this.currentResInfo || this.currentResInfo.id != resInfo.id) {
724
+ this.currentResInfo = resInfo;
725
+ this.resized.next();
726
+ }
725
727
  }
726
728
  };
727
729
  Object.defineProperty(RADashboardResponsiveService.prototype, "IsDesktopView", {
@@ -799,13 +801,18 @@
799
801
  * @return {?}
800
802
  */
801
803
  function (widget) {
804
+ if (widget.widgetSettings && typeof widget.widgetSettings === 'string') {
805
+ widget.widgetSettings = JSON.parse(widget.widgetSettings);
806
+ }
802
807
  /** @type {?} */
803
808
  var gridsterItem = (/** @type {?} */ ({
804
809
  cols: this.getWidth(widget.width),
805
810
  rows: this.getHeight(widget.height),
806
811
  x: this.IsDesktopView ? widget.position_x : 0,
807
812
  y: this.IsDesktopView ? widget.position_y : 0,
808
- widgetInfo: widget
813
+ widgetInfo: widget,
814
+ minItemRows: this.getMinItemRows(widget),
815
+ minItemCols: this.getMinItemCols(widget)
809
816
  }));
810
817
  return gridsterItem;
811
818
  };
@@ -821,12 +828,46 @@
821
828
  */
822
829
  function (width) {
823
830
  if (!this.IsDesktopView) {
824
- width = Math.floor(width / 10 * this.currentResInfo.maxCols);
831
+ width = Math.floor(width / this.maxColsDesktop * this.currentResInfo.maxCols);
825
832
  if (width < this.currentResInfo.minCols)
826
833
  width = this.currentResInfo.minCols;
827
834
  }
828
835
  return width;
829
836
  };
837
+ /**
838
+ * @private
839
+ * @param {?} widget
840
+ * @return {?}
841
+ */
842
+ RADashboardResponsiveService.prototype.getMinItemRows = /**
843
+ * @private
844
+ * @param {?} widget
845
+ * @return {?}
846
+ */
847
+ function (widget) {
848
+ if (this.IsDesktopView) {
849
+ if (widget.widgetSettings && widget.widgetSettings.minRows) {
850
+ return widget.widgetSettings.minRows;
851
+ }
852
+ }
853
+ };
854
+ /**
855
+ * @private
856
+ * @param {?} widget
857
+ * @return {?}
858
+ */
859
+ RADashboardResponsiveService.prototype.getMinItemCols = /**
860
+ * @private
861
+ * @param {?} widget
862
+ * @return {?}
863
+ */
864
+ function (widget) {
865
+ if (this.IsDesktopView) {
866
+ if (widget.widgetSettings && widget.widgetSettings.minCols) {
867
+ return widget.widgetSettings.minCols;
868
+ }
869
+ }
870
+ };
830
871
  /**
831
872
  * @private
832
873
  * @param {?} height
@@ -839,7 +880,7 @@
839
880
  */
840
881
  function (height) {
841
882
  if (!this.IsDesktopView) {
842
- height = Math.floor(height / 10 * this.currentResInfo.maxCols);
883
+ height = Math.floor(height / this.maxColsDesktop * this.currentResInfo.maxCols);
843
884
  if (height < this.currentResInfo.minCols)
844
885
  height = this.currentResInfo.minCols;
845
886
  }
@@ -854,6 +895,10 @@
854
895
  return RADashboardResponsiveService;
855
896
  }());
856
897
  if (false) {
898
+ /** @type {?} */
899
+ RADashboardResponsiveService.prototype.resized;
900
+ /** @type {?} */
901
+ RADashboardResponsiveService.prototype.maxColsDesktop;
857
902
  /**
858
903
  * @type {?}
859
904
  * @private
@@ -893,46 +938,41 @@
893
938
  this.widgetWidth = 4;
894
939
  }
895
940
  /**
896
- * @param {?} event
897
941
  * @return {?}
898
942
  */
899
- RADashboardArea.prototype.onResize = /**
900
- * @param {?} event
943
+ RADashboardArea.prototype.ngOnInit = /**
901
944
  * @return {?}
902
945
  */
903
- function (event) {
946
+ function () {
904
947
  var _this = this;
905
- this.widgetList = [];
906
- setTimeout((/**
948
+ this.initiateGridsterConfig();
949
+ this.responsiveService.resized.subscribe((/**
907
950
  * @return {?}
908
951
  */
909
952
  function () {
910
- _this.initiateGridsterConfig();
911
- _this.options.api.optionsChanged();
912
- if (_this.userWidgets) {
913
- _this.widgetList = _this.mapObjectListToGridsterItemList(_this.userWidgets);
914
- setTimeout((/**
915
- * @return {?}
916
- */
917
- function () {
918
- _this.setAreaHeight();
919
- }));
920
- }
921
- else {
922
- _this.loadWidgets(_this.userDashboardId, _this.areaKey);
923
- }
924
- _this.domResized = !_this.domResized;
953
+ _this.widgetList = [];
954
+ setTimeout((/**
955
+ * @return {?}
956
+ */
957
+ function () {
958
+ _this.initiateGridsterConfig();
959
+ _this.options.api.optionsChanged();
960
+ if (_this.userWidgets) {
961
+ _this.widgetList = _this.mapObjectListToGridsterItemList(_this.userWidgets);
962
+ setTimeout((/**
963
+ * @return {?}
964
+ */
965
+ function () {
966
+ _this.setAreaHeight();
967
+ }));
968
+ }
969
+ else {
970
+ _this.loadWidgets(_this.userDashboardId, _this.areaKey);
971
+ }
972
+ _this.domResized = !_this.domResized;
973
+ }));
925
974
  }));
926
975
  };
927
- /**
928
- * @return {?}
929
- */
930
- RADashboardArea.prototype.ngOnInit = /**
931
- * @return {?}
932
- */
933
- function () {
934
- this.initiateGridsterConfig();
935
- };
936
976
  /**
937
977
  * @param {?} changes
938
978
  * @return {?}
@@ -968,11 +1008,8 @@
968
1008
  * @return {?}
969
1009
  */
970
1010
  function (gridster) {
971
- console.log('grid inititalized');
972
- console.log(_this.options.api);
973
1011
  if (_this.options.api) {
974
1012
  _this.gridcellHeight = _this.options.api.getCurrentRowHeight();
975
- console.log('cell height is' + _this.gridcellHeight);
976
1013
  }
977
1014
  });
978
1015
  this.options.itemChangeCallback = (/**
@@ -1344,10 +1381,18 @@
1344
1381
  * @return {?}
1345
1382
  */
1346
1383
  function () {
1347
- this.options.compactType = 'compactUp&Left';
1348
- this.options.api.optionsChanged();
1349
- this.options.compactType = 'none';
1350
- this.options.api.optionsChanged();
1384
+ var _this = this;
1385
+ for (var i = 0; i < this.userWidgets.length; i++) {
1386
+ this.userWidgets[i].position_x = 0;
1387
+ this.userWidgets[i].position_y = 0;
1388
+ this.widgetList = this.mapObjectListToGridsterItemList(this.userWidgets);
1389
+ setTimeout((/**
1390
+ * @return {?}
1391
+ */
1392
+ function () {
1393
+ _this.setAreaHeight();
1394
+ }));
1395
+ }
1351
1396
  };
1352
1397
  /**To add widget instance to the database with the next available position and to make changes in
1353
1398
  * dashboard area.
@@ -1368,6 +1413,17 @@
1368
1413
  var _this = this;
1369
1414
  data.height = this.widgetHeight;
1370
1415
  data.width = this.widgetWidth;
1416
+ if (data.widgetSettings) {
1417
+ if (typeof data.widgetSettings === 'string')
1418
+ data.widgetSettings = JSON.parse(data.widgetSettings);
1419
+ if (data.widgetSettings.defaultCols) {
1420
+ data.width = data.widgetSettings.defaultCols;
1421
+ }
1422
+ if (data.widgetSettings.defaultRows) {
1423
+ data.height = data.widgetSettings.defaultRows;
1424
+ }
1425
+ data.widgetSettings = null;
1426
+ }
1371
1427
  data = this.setPositions(data);
1372
1428
  /** to find the available position in gridster, temp commenting the code-returning higher y value than normal */
1373
1429
  data.dashboardAreaKey = this.areaKey;
@@ -1425,12 +1481,12 @@
1425
1481
  if (this.userWidgets.length > 0) {
1426
1482
  /** @type {?} */
1427
1483
  var widget = this.userWidgets[this.userWidgets.length - 1];
1428
- if (widget.position_x + widget.width > 5) {
1484
+ if (widget.position_x + widget.width > (this.responsiveService.maxColsDesktop / 2)) {
1429
1485
  data.position_y = widget.position_y + 1;
1430
1486
  }
1431
1487
  else {
1432
1488
  data.position_y = widget.position_y;
1433
- data.position_x = 10 - (widget.position_x + widget.width);
1489
+ data.position_x = this.responsiveService.maxColsDesktop - (widget.position_x + widget.width);
1434
1490
  }
1435
1491
  }
1436
1492
  }
@@ -1548,8 +1604,7 @@
1548
1604
  widgetHeight: [{ type: core.Input, args: ['widget-height',] }],
1549
1605
  widgetWidth: [{ type: core.Input, args: ['widget-width',] }],
1550
1606
  appConfig: [{ type: core.Input, args: ['app-config',] }],
1551
- gridWrapper: [{ type: core.ViewChild, args: ['gridWrapper', { static: false },] }],
1552
- onResize: [{ type: core.HostListener, args: ['window:resize', ['$event'],] }]
1607
+ gridWrapper: [{ type: core.ViewChild, args: ['gridWrapper', { static: false },] }]
1553
1608
  };
1554
1609
  return RADashboardArea;
1555
1610
  }());
@@ -2010,7 +2065,7 @@
2010
2065
  globalFilter: this.globalFilter,
2011
2066
  configChanges: this.getConfigChanges(false)
2012
2067
  }));
2013
- if (widgetInfo.widgetSettings && widgetInfo.widgetSettings.length > 0) {
2068
+ if (widgetInfo.widgetSettings) {
2014
2069
  this.widgetSettings = this.getParsedConfig(widgetInfo.widgetSettings);
2015
2070
  this.applayWidgetSettings(this.widgetSettings);
2016
2071
  }
@@ -2104,7 +2159,6 @@
2104
2159
  widgetConfigFilter.widgetInfo = widgetInfo;
2105
2160
  widgetConfigFilter.configChanges = this.getConfigChanges(false);
2106
2161
  widgetConfigFilter.widgetInfo.widgetName = widgetInfo.widgetName;
2107
- console.log(widgetConfigFilter);
2108
2162
  widgetContainer.widgetElement.loadContent(widgetConfigFilter);
2109
2163
  return [4 /*yield*/, widgetContainer.setLock(widgetConfigFilter.config)];
2110
2164
  case 1: