@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.
@@ -687,18 +687,195 @@ 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
+ /** @type {?} */
698
+ var GridLockViewEnd = 1024;
699
+ var RADashboardResponsiveService = /** @class */ (function () {
700
+ function RADashboardResponsiveService() {
701
+ var _this = this;
702
+ this.resInfo = [
703
+ { 'start': 0, 'end': 767, 'minCols': 1, 'maxCols': 1 },
704
+ { 'start': 768, 'end': GridLockViewEnd, 'minCols': 1, 'maxCols': 2 },
705
+ { 'start': GridLockViewEnd + 1, 'end': DesktopViewStart - 1, 'minCols': 2, 'maxCols': 6 },
706
+ { 'start': DesktopViewStart, 'end': 9999999999, 'minCols': 2, 'maxCols': 10 }
707
+ ];
708
+ this.setScreenWidth();
709
+ window.addEventListener('resize', (/**
710
+ * @return {?}
711
+ */
712
+ function () {
713
+ _this.setScreenWidth();
714
+ }));
715
+ }
716
+ /**
717
+ * @private
718
+ * @return {?}
719
+ */
720
+ RADashboardResponsiveService.prototype.setScreenWidth = /**
721
+ * @private
722
+ * @return {?}
723
+ */
724
+ function () {
725
+ var _this = this;
726
+ this.screenWidth = screen.width;
727
+ this.currentResInfo = this.resInfo.filter((/**
728
+ * @param {?} item
729
+ * @return {?}
730
+ */
731
+ function (item) {
732
+ return item.end >= _this.screenWidth && item.start <= _this.screenWidth;
733
+ }))[0];
734
+ };
735
+ Object.defineProperty(RADashboardResponsiveService.prototype, "IsDesktopView", {
736
+ get: /**
737
+ * @return {?}
738
+ */
739
+ function () {
740
+ return this.screenWidth >= DesktopViewStart;
741
+ },
742
+ enumerable: true,
743
+ configurable: true
744
+ });
745
+ Object.defineProperty(RADashboardResponsiveService.prototype, "IsGridLocked", {
746
+ get: /**
747
+ * @return {?}
748
+ */
749
+ function () {
750
+ return this.screenWidth <= GridLockViewEnd;
751
+ },
752
+ enumerable: true,
753
+ configurable: true
754
+ });
755
+ Object.defineProperty(RADashboardResponsiveService.prototype, "GridsterConfig", {
756
+ get: /**
757
+ * @return {?}
758
+ */
759
+ function () {
760
+ /** @type {?} */
761
+ var config = GridsterConfigDefaultSettings;
762
+ config.minCols = this.currentResInfo.maxCols;
763
+ config.maxCols = this.currentResInfo.maxCols;
764
+ config.minRows = this.currentResInfo.minCols;
765
+ config.maxItemCols = this.currentResInfo.maxCols;
766
+ config.minItemCols = this.currentResInfo.minCols;
767
+ config.minItemRows = this.currentResInfo.minCols;
768
+ config.minItemArea = this.currentResInfo.minCols * this.currentResInfo.minCols;
769
+ config.defaultItemCols = this.currentResInfo.minCols;
770
+ config.defaultItemRows = this.currentResInfo.minCols;
771
+ if (!this.IsDesktopView) {
772
+ config.resizable.enabled = false;
773
+ config.swap = false;
774
+ config.draggable.enabled = false;
775
+ }
776
+ return config;
777
+ },
778
+ enumerable: true,
779
+ configurable: true
780
+ });
781
+ /**To map IwidgetInfo object to gridsterItem */
782
+ /**
783
+ * To map IwidgetInfo object to gridsterItem
784
+ * @param {?} widget
785
+ * @return {?}
786
+ */
787
+ RADashboardResponsiveService.prototype.getGridsterItem = /**
788
+ * To map IwidgetInfo object to gridsterItem
789
+ * @param {?} widget
790
+ * @return {?}
791
+ */
792
+ function (widget) {
793
+ /** @type {?} */
794
+ var gridsterItem = (/** @type {?} */ ({
795
+ cols: this.getWidth(widget.width),
796
+ rows: this.getHeight(widget.height),
797
+ x: this.IsDesktopView ? widget.position_x : 0,
798
+ y: this.IsDesktopView ? widget.position_y : 0,
799
+ isInitialized: widget.isInitialized,
800
+ widgetInfo: widget
801
+ }));
802
+ return gridsterItem;
803
+ };
804
+ /**
805
+ * @private
806
+ * @param {?} width
807
+ * @return {?}
808
+ */
809
+ RADashboardResponsiveService.prototype.getWidth = /**
810
+ * @private
811
+ * @param {?} width
812
+ * @return {?}
813
+ */
814
+ function (width) {
815
+ if (!this.IsDesktopView) {
816
+ width = Math.floor(width / 10 * this.currentResInfo.maxCols);
817
+ if (width < this.currentResInfo.minCols)
818
+ width = this.currentResInfo.minCols;
819
+ }
820
+ return width;
821
+ };
822
+ /**
823
+ * @private
824
+ * @param {?} height
825
+ * @return {?}
826
+ */
827
+ RADashboardResponsiveService.prototype.getHeight = /**
828
+ * @private
829
+ * @param {?} height
830
+ * @return {?}
831
+ */
832
+ function (height) {
833
+ if (!this.IsDesktopView) {
834
+ height = Math.floor(height / 10 * this.currentResInfo.maxCols);
835
+ if (height < this.currentResInfo.minCols)
836
+ height = this.currentResInfo.minCols;
837
+ }
838
+ return height;
839
+ };
840
+ RADashboardResponsiveService.decorators = [
841
+ { type: Injectable, args: [{ providedIn: 'root' },] }
842
+ ];
843
+ /** @nocollapse */
844
+ RADashboardResponsiveService.ctorParameters = function () { return []; };
845
+ /** @nocollapse */ RADashboardResponsiveService.ngInjectableDef = ɵɵdefineInjectable({ factory: function RADashboardResponsiveService_Factory() { return new RADashboardResponsiveService(); }, token: RADashboardResponsiveService, providedIn: "root" });
846
+ return RADashboardResponsiveService;
847
+ }());
848
+ if (false) {
849
+ /**
850
+ * @type {?}
851
+ * @private
852
+ */
853
+ RADashboardResponsiveService.prototype.screenWidth;
854
+ /**
855
+ * @type {?}
856
+ * @private
857
+ */
858
+ RADashboardResponsiveService.prototype.resInfo;
859
+ /**
860
+ * @type {?}
861
+ * @private
862
+ */
863
+ RADashboardResponsiveService.prototype.currentResInfo;
864
+ }
865
+
690
866
  /**
691
867
  * @fileoverview added by tsickle
692
868
  * Generated from: lib/ra-dashboard-area/ra.dashboard.area.ts
693
869
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
694
870
  */
695
871
  var RADashboardArea = /** @class */ (function () {
696
- function RADashboardArea(dashboardService, ngZone, ngxService, translateService, notifier) {
872
+ function RADashboardArea(dashboardService, ngZone, ngxService, translateService, notifier, responsiveService) {
697
873
  this.dashboardService = dashboardService;
698
874
  this.ngZone = ngZone;
699
875
  this.ngxService = ngxService;
700
876
  this.translateService = translateService;
701
877
  this.notifier = notifier;
878
+ this.responsiveService = responsiveService;
702
879
  this.widgetList = Array();
703
880
  this.gridheight = 300;
704
881
  this.gridcellHeight = 0;
@@ -716,15 +893,23 @@ var RADashboardArea = /** @class */ (function () {
716
893
  * @return {?}
717
894
  */
718
895
  function (event) {
719
- /** @type {?} */
720
- var areaContext = this;
896
+ var _this = this;
897
+ this.widgetList = [];
721
898
  setTimeout((/**
722
899
  * @return {?}
723
900
  */
724
901
  function () {
725
- areaContext.setAreaHeight();
726
- areaContext.domResized = !areaContext.domResized;
727
- }), 1000);
902
+ _this.initiateGridsterConfig();
903
+ _this.options.api.optionsChanged();
904
+ if (_this.userWidgets) {
905
+ _this.widgetList = _this.mapObjectListToGridsterItemList(_this.userWidgets);
906
+ _this.setAreaHeight();
907
+ }
908
+ else {
909
+ _this.loadWidgets(_this.userDashboardId, _this.areaKey);
910
+ }
911
+ _this.domResized = !_this.domResized;
912
+ }));
728
913
  };
729
914
  /**
730
915
  * @return {?}
@@ -752,46 +937,44 @@ var RADashboardArea = /** @class */ (function () {
752
937
  this.inititateEventBusSubscritions();
753
938
  }
754
939
  };
755
- // public invokeResizeEvent() {
756
- // this.widgetContainers.forEach(function(container,i){
757
- // container.invokeWidgetResizedEvent();
758
- // });
759
- // }
760
940
  /**To set GridsterConfig */
761
- // public invokeResizeEvent() {
762
- // this.widgetContainers.forEach(function(container,i){
763
- // container.invokeWidgetResizedEvent();
764
- // });
765
- // }
766
941
  /**
767
942
  * To set GridsterConfig
768
943
  * @return {?}
769
944
  */
770
- RADashboardArea.prototype.initiateGridsterConfig =
771
- // public invokeResizeEvent() {
772
- // this.widgetContainers.forEach(function(container,i){
773
- // container.invokeWidgetResizedEvent();
774
- // });
775
- // }
776
- /**
945
+ RADashboardArea.prototype.initiateGridsterConfig = /**
777
946
  * To set GridsterConfig
778
947
  * @return {?}
779
948
  */
780
949
  function () {
781
- /** @type {?} */
782
- var areaContext = this;
950
+ var _this = this;
783
951
  /**To override default configuration values to the gridster control */
784
- this.options = GridsterConfigDefaultSettings;
952
+ this.options = this.responsiveService.GridsterConfig;
785
953
  this.options.itemChangeCallback = (/**
786
954
  * @param {?} item
787
955
  * @return {?}
788
956
  */
789
957
  function (item) {
790
- console.log('in item change clal back');
791
- if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
792
- areaContext.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
958
+ if (item.isInitialized) {
959
+ if (!_this.responsiveService.IsGridLocked) {
960
+ if (!_this.responsiveService.IsDesktopView) {
961
+ _this.updateWidgets();
962
+ }
963
+ else {
964
+ if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
965
+ _this.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
966
+ }
967
+ }
968
+ }
969
+ _this.setAreaHeight();
793
970
  }
794
- areaContext.setAreaHeight();
971
+ });
972
+ this.options.itemInitCallback = (/**
973
+ * @param {?} item
974
+ * @return {?}
975
+ */
976
+ function (item) {
977
+ item.isInitialized = true;
795
978
  });
796
979
  };
797
980
  /** To initiate eventbus subsctiptions */
@@ -850,7 +1033,6 @@ var RADashboardArea = /** @class */ (function () {
850
1033
  * @return {?}
851
1034
  */
852
1035
  function () {
853
- console.log('rearrange event bus triggered');
854
1036
  _this.rearrangeWidgets();
855
1037
  }));
856
1038
  }));
@@ -864,9 +1046,6 @@ var RADashboardArea = /** @class */ (function () {
864
1046
  */
865
1047
  function () {
866
1048
  if (widgetList) {
867
- // widgetList.forEach(widgetInfo => {
868
- // this.addWidget(widgetInfo);
869
- // });
870
1049
  _this.addWidgetListToGridster(widgetList, 0);
871
1050
  }
872
1051
  }));
@@ -943,7 +1122,7 @@ var RADashboardArea = /** @class */ (function () {
943
1122
  * @return {?}
944
1123
  */
945
1124
  function () {
946
- this.dashboardService.updateWidgets(this.mapGridsterListToObject(this.widgetList), this.appConfig).subscribe((/**
1125
+ this.dashboardService.updateWidgets(this.formatWidgetDataForPositionDetails(this.mapGridsterListToObject(this.widgetList)), this.appConfig).subscribe((/**
947
1126
  * @param {?} widgets
948
1127
  * @return {?}
949
1128
  */
@@ -1030,21 +1209,36 @@ var RADashboardArea = /** @class */ (function () {
1030
1209
  function (userDashboarId, areaKey) {
1031
1210
  var _this = this;
1032
1211
  /** @type {?} */
1033
- var areaContext = this;
1034
- /** @type {?} */
1035
1212
  var widgetInfo = (/** @type {?} */ ({
1036
1213
  dashboardId: userDashboarId.toString(),
1037
1214
  dashboardAreaKey: areaKey
1038
1215
  }));
1039
- areaContext.widgetList = [];
1216
+ this.widgetList = [];
1040
1217
  this.dashboardService.getWidgetsByDashboardArea(widgetInfo, this.appConfig).subscribe((/**
1041
1218
  * @param {?} widgets
1042
1219
  * @return {?}
1043
1220
  */
1044
1221
  function (widgets) {
1222
+ //sorting the widgets y, x
1223
+ widgets = widgets.sort((/**
1224
+ * @param {?} a
1225
+ * @param {?} b
1226
+ * @return {?}
1227
+ */
1228
+ function (a, b) {
1229
+ if (a['position_y'] > b['position_y'])
1230
+ return 1;
1231
+ if (a['position_y'] < b['position_y'])
1232
+ return -1;
1233
+ if (a['position_x'] > b['position_x'])
1234
+ return 1;
1235
+ if (a['position_x'] < b['position_x'])
1236
+ return -1;
1237
+ }));
1238
+ _this.userWidgets = widgets;
1045
1239
  if (widgets && widgets.length > 0) {
1046
- areaContext.widgetList = _this.mapObjectListToGridsterItemList(widgets);
1047
- areaContext.setAreaHeight();
1240
+ _this.widgetList = _this.mapObjectListToGridsterItemList(widgets);
1241
+ _this.setAreaHeight();
1048
1242
  }
1049
1243
  }));
1050
1244
  };
@@ -1102,7 +1296,6 @@ var RADashboardArea = /** @class */ (function () {
1102
1296
  areaHeight = 600;
1103
1297
  }
1104
1298
  this.gridheight = areaHeight;
1105
- console.log('area height adjusted1');
1106
1299
  };
1107
1300
  /** To remove a widget instance from dashboard and to save info in database */
1108
1301
  /**
@@ -1167,20 +1360,12 @@ var RADashboardArea = /** @class */ (function () {
1167
1360
  */
1168
1361
  function (data) {
1169
1362
  var _this = this;
1170
- /** @type {?} */
1171
- var widgetid = data.widgetId;
1172
1363
  data.height = this.widgetHeight;
1173
1364
  data.width = this.widgetWidth;
1174
1365
  data.position_x = 0;
1175
1366
  data.position_y = 0;
1176
- /** @type {?} */
1177
- var gridsterItem = this.mapObjectsToGridsterItem(data);
1367
+ data.isInitialized = true;
1178
1368
  /** 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
1369
  data.dashboardAreaKey = this.areaKey;
1185
1370
  data.dashboardId = this.userDashboardId;
1186
1371
  this.ngxService.start();
@@ -1189,7 +1374,8 @@ var RADashboardArea = /** @class */ (function () {
1189
1374
  * @return {?}
1190
1375
  */
1191
1376
  function (widget) {
1192
- gridsterItem = _this.mapObjectsToGridsterItem(widget);
1377
+ /** @type {?} */
1378
+ var gridsterItem = _this.responsiveService.getGridsterItem(widget);
1193
1379
  _this.widgetList.push(gridsterItem);
1194
1380
  _this.setAreaHeight();
1195
1381
  if (_this.options.api) {
@@ -1227,39 +1413,14 @@ var RADashboardArea = /** @class */ (function () {
1227
1413
  * @return {?}
1228
1414
  */
1229
1415
  function (data) {
1416
+ data.position_x = 0;
1417
+ data.position_y = 0;
1418
+ data.isInitialized = true;
1230
1419
  /** @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);
1420
+ var gridsterItem = this.responsiveService.getGridsterItem(data);
1238
1421
  this.widgetList.push(gridsterItem);
1239
1422
  this.setAreaHeight();
1240
1423
  };
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
1424
  /**
1264
1425
  * @param {?} widgetList
1265
1426
  * @return {?}
@@ -1277,7 +1438,7 @@ var RADashboardArea = /** @class */ (function () {
1277
1438
  * @return {?}
1278
1439
  */
1279
1440
  function (widget) {
1280
- widgetArray.push(_this.mapObjectsToGridsterItem(widget));
1441
+ widgetArray.push(_this.responsiveService.getGridsterItem(widget));
1281
1442
  }));
1282
1443
  return widgetArray;
1283
1444
  };
@@ -1334,7 +1495,8 @@ var RADashboardArea = /** @class */ (function () {
1334
1495
  { type: NgZone },
1335
1496
  { type: NgxUiLoaderService },
1336
1497
  { type: RATranslateService },
1337
- { type: NotifierService }
1498
+ { type: NotifierService },
1499
+ { type: RADashboardResponsiveService }
1338
1500
  ]; };
1339
1501
  RADashboardArea.propDecorators = {
1340
1502
  userDashboardId: [{ type: Input, args: ['user-dashboard-id',] }],
@@ -1358,6 +1520,11 @@ if (false) {
1358
1520
  RADashboardArea.prototype.gridheight;
1359
1521
  /** @type {?} */
1360
1522
  RADashboardArea.prototype.gridcellHeight;
1523
+ /**
1524
+ * @type {?}
1525
+ * @private
1526
+ */
1527
+ RADashboardArea.prototype.userWidgets;
1361
1528
  /**
1362
1529
  * @type {?}
1363
1530
  * @private
@@ -1431,6 +1598,11 @@ if (false) {
1431
1598
  * @private
1432
1599
  */
1433
1600
  RADashboardArea.prototype.notifier;
1601
+ /**
1602
+ * @type {?}
1603
+ * @private
1604
+ */
1605
+ RADashboardArea.prototype.responsiveService;
1434
1606
  }
1435
1607
 
1436
1608
  /**
@@ -7653,5 +7825,5 @@ if (false) {
7653
7825
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7654
7826
  */
7655
7827
 
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 };
7828
+ 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
7829
  //# sourceMappingURL=schneideress-dashboardframework.js.map