@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.
@@ -687,18 +687,182 @@ var GridsterConfigDefaultSettings = {
687
687
  //itemInitCallback: (item) => this.itemInitCallback(item)
688
688
  };
689
689
 
690
+ /**
691
+ * @fileoverview added by tsickle
692
+ * Generated from: lib/ra.dashboard.responsive.service.ts
693
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
694
+ */
695
+ /** @type {?} */
696
+ var DesktopViewStart = 1367;
697
+ var RADashboardResponsiveService = /** @class */ (function () {
698
+ function RADashboardResponsiveService() {
699
+ var _this = this;
700
+ this.resInfo = [
701
+ { 'start': 0, 'end': 767, 'minCols': 1, 'maxCols': 1 },
702
+ { 'start': 768, 'end': 1024, 'minCols': 1, 'maxCols': 2 },
703
+ { 'start': 1025, 'end': DesktopViewStart - 1, 'minCols': 2, 'maxCols': 6 },
704
+ { 'start': DesktopViewStart, 'end': 9999999999, 'minCols': 2, 'maxCols': 10 }
705
+ ];
706
+ this.setScreenWidth();
707
+ window.addEventListener('resize', (/**
708
+ * @return {?}
709
+ */
710
+ function () {
711
+ _this.setScreenWidth();
712
+ }));
713
+ }
714
+ /**
715
+ * @private
716
+ * @return {?}
717
+ */
718
+ RADashboardResponsiveService.prototype.setScreenWidth = /**
719
+ * @private
720
+ * @return {?}
721
+ */
722
+ function () {
723
+ var _this = this;
724
+ this.screenWidth = screen.width;
725
+ this.currentResInfo = this.resInfo.filter((/**
726
+ * @param {?} item
727
+ * @return {?}
728
+ */
729
+ function (item) {
730
+ return item.end >= _this.screenWidth && item.start <= _this.screenWidth;
731
+ }))[0];
732
+ };
733
+ Object.defineProperty(RADashboardResponsiveService.prototype, "IsDesktopView", {
734
+ get: /**
735
+ * @return {?}
736
+ */
737
+ function () {
738
+ return this.screenWidth >= DesktopViewStart;
739
+ },
740
+ enumerable: true,
741
+ configurable: true
742
+ });
743
+ Object.defineProperty(RADashboardResponsiveService.prototype, "GridsterConfig", {
744
+ get: /**
745
+ * @return {?}
746
+ */
747
+ function () {
748
+ /** @type {?} */
749
+ var config = GridsterConfigDefaultSettings;
750
+ config.minCols = this.currentResInfo.maxCols;
751
+ config.maxCols = this.currentResInfo.maxCols;
752
+ config.minRows = this.currentResInfo.minCols;
753
+ config.maxItemCols = this.currentResInfo.maxCols;
754
+ config.minItemCols = this.currentResInfo.minCols;
755
+ config.minItemRows = this.currentResInfo.minCols;
756
+ config.minItemArea = this.currentResInfo.minCols * this.currentResInfo.minCols;
757
+ config.defaultItemCols = this.currentResInfo.minCols;
758
+ config.defaultItemRows = this.currentResInfo.minCols;
759
+ if (!this.IsDesktopView) {
760
+ config.resizable.enabled = false;
761
+ config.swap = false;
762
+ config.draggable.enabled = false;
763
+ }
764
+ return config;
765
+ },
766
+ enumerable: true,
767
+ configurable: true
768
+ });
769
+ /**To map IwidgetInfo object to gridsterItem */
770
+ /**
771
+ * To map IwidgetInfo object to gridsterItem
772
+ * @param {?} widget
773
+ * @return {?}
774
+ */
775
+ RADashboardResponsiveService.prototype.getGridsterItem = /**
776
+ * To map IwidgetInfo object to gridsterItem
777
+ * @param {?} widget
778
+ * @return {?}
779
+ */
780
+ function (widget) {
781
+ /** @type {?} */
782
+ var gridsterItem = (/** @type {?} */ ({
783
+ cols: this.getWidth(widget.width),
784
+ rows: this.getHeight(widget.height),
785
+ x: this.IsDesktopView ? widget.position_x : 0,
786
+ y: this.IsDesktopView ? widget.position_y : 0,
787
+ widgetInfo: widget
788
+ }));
789
+ return gridsterItem;
790
+ };
791
+ /**
792
+ * @private
793
+ * @param {?} width
794
+ * @return {?}
795
+ */
796
+ RADashboardResponsiveService.prototype.getWidth = /**
797
+ * @private
798
+ * @param {?} width
799
+ * @return {?}
800
+ */
801
+ function (width) {
802
+ if (!this.IsDesktopView) {
803
+ width = Math.floor(width / 10 * this.currentResInfo.maxCols);
804
+ if (width < this.currentResInfo.minCols)
805
+ width = this.currentResInfo.minCols;
806
+ }
807
+ return width;
808
+ };
809
+ /**
810
+ * @private
811
+ * @param {?} height
812
+ * @return {?}
813
+ */
814
+ RADashboardResponsiveService.prototype.getHeight = /**
815
+ * @private
816
+ * @param {?} height
817
+ * @return {?}
818
+ */
819
+ function (height) {
820
+ if (!this.IsDesktopView) {
821
+ height = Math.floor(height / 10 * this.currentResInfo.maxCols);
822
+ if (height < this.currentResInfo.minCols)
823
+ height = this.currentResInfo.minCols;
824
+ }
825
+ return height;
826
+ };
827
+ RADashboardResponsiveService.decorators = [
828
+ { type: Injectable, args: [{ providedIn: 'root' },] }
829
+ ];
830
+ /** @nocollapse */
831
+ RADashboardResponsiveService.ctorParameters = function () { return []; };
832
+ /** @nocollapse */ RADashboardResponsiveService.ngInjectableDef = ɵɵdefineInjectable({ factory: function RADashboardResponsiveService_Factory() { return new RADashboardResponsiveService(); }, token: RADashboardResponsiveService, providedIn: "root" });
833
+ return RADashboardResponsiveService;
834
+ }());
835
+ if (false) {
836
+ /**
837
+ * @type {?}
838
+ * @private
839
+ */
840
+ RADashboardResponsiveService.prototype.screenWidth;
841
+ /**
842
+ * @type {?}
843
+ * @private
844
+ */
845
+ RADashboardResponsiveService.prototype.resInfo;
846
+ /**
847
+ * @type {?}
848
+ * @private
849
+ */
850
+ RADashboardResponsiveService.prototype.currentResInfo;
851
+ }
852
+
690
853
  /**
691
854
  * @fileoverview added by tsickle
692
855
  * Generated from: lib/ra-dashboard-area/ra.dashboard.area.ts
693
856
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
694
857
  */
695
858
  var RADashboardArea = /** @class */ (function () {
696
- function RADashboardArea(dashboardService, ngZone, ngxService, translateService, notifier) {
859
+ function RADashboardArea(dashboardService, ngZone, ngxService, translateService, notifier, responsiveService) {
697
860
  this.dashboardService = dashboardService;
698
861
  this.ngZone = ngZone;
699
862
  this.ngxService = ngxService;
700
863
  this.translateService = translateService;
701
864
  this.notifier = notifier;
865
+ this.responsiveService = responsiveService;
702
866
  this.widgetList = Array();
703
867
  this.gridheight = 300;
704
868
  this.gridcellHeight = 0;
@@ -716,15 +880,23 @@ var RADashboardArea = /** @class */ (function () {
716
880
  * @return {?}
717
881
  */
718
882
  function (event) {
719
- /** @type {?} */
720
- var areaContext = this;
883
+ var _this = this;
884
+ this.widgetList = [];
721
885
  setTimeout((/**
722
886
  * @return {?}
723
887
  */
724
888
  function () {
725
- areaContext.setAreaHeight();
726
- areaContext.domResized = !areaContext.domResized;
727
- }), 1000);
889
+ _this.initiateGridsterConfig();
890
+ _this.options.api.optionsChanged();
891
+ if (_this.userWidgets) {
892
+ _this.widgetList = _this.mapObjectListToGridsterItemList(_this.userWidgets);
893
+ _this.setAreaHeight();
894
+ }
895
+ else {
896
+ _this.loadWidgets(_this.userDashboardId, _this.areaKey);
897
+ }
898
+ _this.domResized = !_this.domResized;
899
+ }));
728
900
  };
729
901
  /**
730
902
  * @return {?}
@@ -752,46 +924,30 @@ var RADashboardArea = /** @class */ (function () {
752
924
  this.inititateEventBusSubscritions();
753
925
  }
754
926
  };
755
- // public invokeResizeEvent() {
756
- // this.widgetContainers.forEach(function(container,i){
757
- // container.invokeWidgetResizedEvent();
758
- // });
759
- // }
760
927
  /**To set GridsterConfig */
761
- // public invokeResizeEvent() {
762
- // this.widgetContainers.forEach(function(container,i){
763
- // container.invokeWidgetResizedEvent();
764
- // });
765
- // }
766
928
  /**
767
929
  * To set GridsterConfig
768
930
  * @return {?}
769
931
  */
770
- RADashboardArea.prototype.initiateGridsterConfig =
771
- // public invokeResizeEvent() {
772
- // this.widgetContainers.forEach(function(container,i){
773
- // container.invokeWidgetResizedEvent();
774
- // });
775
- // }
776
- /**
932
+ RADashboardArea.prototype.initiateGridsterConfig = /**
777
933
  * To set GridsterConfig
778
934
  * @return {?}
779
935
  */
780
936
  function () {
781
- /** @type {?} */
782
- var areaContext = this;
937
+ var _this = this;
783
938
  /**To override default configuration values to the gridster control */
784
- this.options = GridsterConfigDefaultSettings;
939
+ this.options = this.responsiveService.GridsterConfig;
785
940
  this.options.itemChangeCallback = (/**
786
941
  * @param {?} item
787
942
  * @return {?}
788
943
  */
789
944
  function (item) {
790
- console.log('in item change clal back');
791
- if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
792
- areaContext.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
945
+ if (_this.responsiveService.IsDesktopView) {
946
+ if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
947
+ _this.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
948
+ }
793
949
  }
794
- areaContext.setAreaHeight();
950
+ _this.setAreaHeight();
795
951
  });
796
952
  };
797
953
  /** To initiate eventbus subsctiptions */
@@ -850,7 +1006,6 @@ var RADashboardArea = /** @class */ (function () {
850
1006
  * @return {?}
851
1007
  */
852
1008
  function () {
853
- console.log('rearrange event bus triggered');
854
1009
  _this.rearrangeWidgets();
855
1010
  }));
856
1011
  }));
@@ -864,9 +1019,6 @@ var RADashboardArea = /** @class */ (function () {
864
1019
  */
865
1020
  function () {
866
1021
  if (widgetList) {
867
- // widgetList.forEach(widgetInfo => {
868
- // this.addWidget(widgetInfo);
869
- // });
870
1022
  _this.addWidgetListToGridster(widgetList, 0);
871
1023
  }
872
1024
  }));
@@ -1030,21 +1182,36 @@ var RADashboardArea = /** @class */ (function () {
1030
1182
  function (userDashboarId, areaKey) {
1031
1183
  var _this = this;
1032
1184
  /** @type {?} */
1033
- var areaContext = this;
1034
- /** @type {?} */
1035
1185
  var widgetInfo = (/** @type {?} */ ({
1036
1186
  dashboardId: userDashboarId.toString(),
1037
1187
  dashboardAreaKey: areaKey
1038
1188
  }));
1039
- areaContext.widgetList = [];
1189
+ this.widgetList = [];
1040
1190
  this.dashboardService.getWidgetsByDashboardArea(widgetInfo, this.appConfig).subscribe((/**
1041
1191
  * @param {?} widgets
1042
1192
  * @return {?}
1043
1193
  */
1044
1194
  function (widgets) {
1195
+ //sorting the widgets y, x
1196
+ widgets = widgets.sort((/**
1197
+ * @param {?} a
1198
+ * @param {?} b
1199
+ * @return {?}
1200
+ */
1201
+ function (a, b) {
1202
+ if (a['position_y'] > b['position_y'])
1203
+ return 1;
1204
+ if (a['position_y'] < b['position_y'])
1205
+ return -1;
1206
+ if (a['position_x'] > b['position_x'])
1207
+ return 1;
1208
+ if (a['position_x'] < b['position_x'])
1209
+ return -1;
1210
+ }));
1211
+ _this.userWidgets = widgets;
1045
1212
  if (widgets && widgets.length > 0) {
1046
- areaContext.widgetList = _this.mapObjectListToGridsterItemList(widgets);
1047
- areaContext.setAreaHeight();
1213
+ _this.widgetList = _this.mapObjectListToGridsterItemList(widgets);
1214
+ _this.setAreaHeight();
1048
1215
  }
1049
1216
  }));
1050
1217
  };
@@ -1102,7 +1269,6 @@ var RADashboardArea = /** @class */ (function () {
1102
1269
  areaHeight = 600;
1103
1270
  }
1104
1271
  this.gridheight = areaHeight;
1105
- console.log('area height adjusted1');
1106
1272
  };
1107
1273
  /** To remove a widget instance from dashboard and to save info in database */
1108
1274
  /**
@@ -1167,20 +1333,11 @@ var RADashboardArea = /** @class */ (function () {
1167
1333
  */
1168
1334
  function (data) {
1169
1335
  var _this = this;
1170
- /** @type {?} */
1171
- var widgetid = data.widgetId;
1172
1336
  data.height = this.widgetHeight;
1173
1337
  data.width = this.widgetWidth;
1174
1338
  data.position_x = 0;
1175
1339
  data.position_y = 0;
1176
- /** @type {?} */
1177
- var gridsterItem = this.mapObjectsToGridsterItem(data);
1178
1340
  /** to find the available position in gridster, temp commenting the code-returning higher y value than normal */
1179
- // if (this.options.api) {
1180
- // gridsterItem = this.options.api.getFirstPossiblePosition(gridsterItem);
1181
- // }
1182
- // data.position_x = gridsterItem.x;
1183
- // data.position_y = gridsterItem.y;
1184
1341
  data.dashboardAreaKey = this.areaKey;
1185
1342
  data.dashboardId = this.userDashboardId;
1186
1343
  this.ngxService.start();
@@ -1189,7 +1346,8 @@ var RADashboardArea = /** @class */ (function () {
1189
1346
  * @return {?}
1190
1347
  */
1191
1348
  function (widget) {
1192
- gridsterItem = _this.mapObjectsToGridsterItem(widget);
1349
+ /** @type {?} */
1350
+ var gridsterItem = _this.responsiveService.getGridsterItem(widget);
1193
1351
  _this.widgetList.push(gridsterItem);
1194
1352
  _this.setAreaHeight();
1195
1353
  if (_this.options.api) {
@@ -1227,39 +1385,13 @@ var RADashboardArea = /** @class */ (function () {
1227
1385
  * @return {?}
1228
1386
  */
1229
1387
  function (data) {
1388
+ data.position_x = 0;
1389
+ data.position_y = 0;
1230
1390
  /** @type {?} */
1231
- var gridsterItem = this.mapObjectsToGridsterItem(data);
1232
- if (this.options.api) {
1233
- gridsterItem = this.options.api.getFirstPossiblePosition(gridsterItem);
1234
- }
1235
- data.position_x = gridsterItem.x;
1236
- data.position_y = gridsterItem.y;
1237
- gridsterItem = this.mapObjectsToGridsterItem(data);
1391
+ var gridsterItem = this.responsiveService.getGridsterItem(data);
1238
1392
  this.widgetList.push(gridsterItem);
1239
1393
  this.setAreaHeight();
1240
1394
  };
1241
- /**To map IwidgetInfo object to gridsterItem */
1242
- /**
1243
- * To map IwidgetInfo object to gridsterItem
1244
- * @param {?} widget
1245
- * @return {?}
1246
- */
1247
- RADashboardArea.prototype.mapObjectsToGridsterItem = /**
1248
- * To map IwidgetInfo object to gridsterItem
1249
- * @param {?} widget
1250
- * @return {?}
1251
- */
1252
- function (widget) {
1253
- /** @type {?} */
1254
- var gridsterItem = (/** @type {?} */ ({
1255
- cols: widget.width,
1256
- rows: widget.height,
1257
- x: widget.position_x,
1258
- y: widget.position_y,
1259
- widgetInfo: widget
1260
- }));
1261
- return gridsterItem;
1262
- };
1263
1395
  /**
1264
1396
  * @param {?} widgetList
1265
1397
  * @return {?}
@@ -1277,7 +1409,7 @@ var RADashboardArea = /** @class */ (function () {
1277
1409
  * @return {?}
1278
1410
  */
1279
1411
  function (widget) {
1280
- widgetArray.push(_this.mapObjectsToGridsterItem(widget));
1412
+ widgetArray.push(_this.responsiveService.getGridsterItem(widget));
1281
1413
  }));
1282
1414
  return widgetArray;
1283
1415
  };
@@ -1334,7 +1466,8 @@ var RADashboardArea = /** @class */ (function () {
1334
1466
  { type: NgZone },
1335
1467
  { type: NgxUiLoaderService },
1336
1468
  { type: RATranslateService },
1337
- { type: NotifierService }
1469
+ { type: NotifierService },
1470
+ { type: RADashboardResponsiveService }
1338
1471
  ]; };
1339
1472
  RADashboardArea.propDecorators = {
1340
1473
  userDashboardId: [{ type: Input, args: ['user-dashboard-id',] }],
@@ -1358,6 +1491,11 @@ if (false) {
1358
1491
  RADashboardArea.prototype.gridheight;
1359
1492
  /** @type {?} */
1360
1493
  RADashboardArea.prototype.gridcellHeight;
1494
+ /**
1495
+ * @type {?}
1496
+ * @private
1497
+ */
1498
+ RADashboardArea.prototype.userWidgets;
1361
1499
  /**
1362
1500
  * @type {?}
1363
1501
  * @private
@@ -1431,6 +1569,11 @@ if (false) {
1431
1569
  * @private
1432
1570
  */
1433
1571
  RADashboardArea.prototype.notifier;
1572
+ /**
1573
+ * @type {?}
1574
+ * @private
1575
+ */
1576
+ RADashboardArea.prototype.responsiveService;
1434
1577
  }
1435
1578
 
1436
1579
  /**
@@ -7653,5 +7796,5 @@ if (false) {
7653
7796
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7654
7797
  */
7655
7798
 
7656
- export { DashboardFrameworkModule, RADashboardArea, RADashboardEventBus, RAEvent, RAEventKey, RAWidgetContainer, RaBaseDashboardFilter, RaBaseDashboardTemplate, RaDashboardService, GridsterModule as ɵa, GridsterComponent as ɵb, GridsterItemComponent as ɵc, GridsterPreviewComponent as ɵd, customNotifierOptions as ɵe };
7799
+ export { DashboardFrameworkModule, RADashboardArea, RADashboardEventBus, RADashboardResponsiveService, RAEvent, RAEventKey, RAWidgetContainer, RaBaseDashboardFilter, RaBaseDashboardTemplate, RaDashboardService, GridsterModule as ɵa, GridsterComponent as ɵb, GridsterItemComponent as ɵc, GridsterPreviewComponent as ɵd, customNotifierOptions as ɵe };
7657
7800
  //# sourceMappingURL=schneideress-dashboardframework.js.map