@schneideress/dashboardframework 0.0.182 → 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.
- package/bundles/schneideress-dashboardframework.umd.js +122 -67
- package/bundles/schneideress-dashboardframework.umd.js.map +1 -1
- package/bundles/schneideress-dashboardframework.umd.min.js +12 -12
- package/bundles/schneideress-dashboardframework.umd.min.js.map +1 -1
- package/esm2015/lib/ra-dashboard-area/ra.dashboard.area.js +51 -38
- package/esm2015/lib/ra-widget-container/ra.widget.container.component.js +3 -3
- package/esm2015/lib/ra.dashboard.responsive.service.js +50 -9
- package/esm5/lib/ra-dashboard-area/ra.dashboard.area.js +53 -43
- package/esm5/lib/ra-widget-container/ra.widget.container.component.js +3 -3
- package/esm5/lib/ra.dashboard.responsive.service.js +60 -9
- package/fesm2015/schneideress-dashboardframework.js +100 -47
- package/fesm2015/schneideress-dashboardframework.js.map +1 -1
- package/fesm5/schneideress-dashboardframework.js +112 -52
- package/fesm5/schneideress-dashboardframework.js.map +1 -1
- package/lib/ra-dashboard-area/ra.dashboard.area.d.ts +0 -1
- package/lib/ra.dashboard.responsive.service.d.ts +5 -0
- package/package.json +1 -1
- package/schneideress-dashboardframework.metadata.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable, Injector, ɵɵdefineInjectable, ɵɵinject, INJECTOR, Component, NgZone, Input, ViewChild,
|
|
1
|
+
import { Injectable, Injector, ɵɵdefineInjectable, ɵɵinject, INJECTOR, Component, NgZone, Input, ViewChild, EventEmitter, Renderer2, Output, ViewEncapsulation, ElementRef, ChangeDetectorRef, Host, NgModule } from '@angular/core';
|
|
2
2
|
import { of, Subject } from 'rxjs';
|
|
3
3
|
import { BaseService, RATranslateService, RAPermissionService, RACommonModule } from '@schneideress/ra-common';
|
|
4
4
|
import { filter, map } from 'rxjs/operators';
|
|
@@ -360,11 +360,13 @@ const GridsterConfigDefaultSettings = {
|
|
|
360
360
|
*/
|
|
361
361
|
class RADashboardResponsiveService {
|
|
362
362
|
constructor() {
|
|
363
|
+
this.resized = new Subject();
|
|
364
|
+
this.maxColsDesktop = 8;
|
|
363
365
|
this.resInfo = [
|
|
364
|
-
{ 'start': 0, 'end': 767, 'minCols': 1, 'maxCols': 1 },
|
|
365
|
-
{ 'start': 768, 'end': 1024, 'minCols': 1, 'maxCols': 2 },
|
|
366
|
-
{ 'start': 1025, 'end': 1366, 'minCols': 1, 'maxCols': 6 },
|
|
367
|
-
{ 'start': 1367, 'end': 9999999999, 'minCols': 1, 'maxCols':
|
|
366
|
+
{ 'id': 1, 'start': 0, 'end': 767, 'minCols': 1, 'maxCols': 1 },
|
|
367
|
+
{ 'id': 2, 'start': 768, 'end': 1024, 'minCols': 1, 'maxCols': 2 },
|
|
368
|
+
{ 'id': 3, 'start': 1025, 'end': 1366, 'minCols': 1, 'maxCols': 6 },
|
|
369
|
+
{ 'id': 4, 'start': 1367, 'end': 9999999999, 'minCols': 1, 'maxCols': this.maxColsDesktop }
|
|
368
370
|
];
|
|
369
371
|
this.setScreenWidth();
|
|
370
372
|
window.addEventListener('resize', (/**
|
|
@@ -384,13 +386,18 @@ class RADashboardResponsiveService {
|
|
|
384
386
|
this.currentResInfo = this.resInfo[3];
|
|
385
387
|
}
|
|
386
388
|
else {
|
|
387
|
-
|
|
389
|
+
/** @type {?} */
|
|
390
|
+
let resInfo = this.resInfo.filter((/**
|
|
388
391
|
* @param {?} item
|
|
389
392
|
* @return {?}
|
|
390
393
|
*/
|
|
391
394
|
(item) => {
|
|
392
395
|
return item.end >= this.screenWidth && item.start <= this.screenWidth;
|
|
393
396
|
}))[0];
|
|
397
|
+
if (!this.currentResInfo || this.currentResInfo.id != resInfo.id) {
|
|
398
|
+
this.currentResInfo = resInfo;
|
|
399
|
+
this.resized.next();
|
|
400
|
+
}
|
|
394
401
|
}
|
|
395
402
|
}
|
|
396
403
|
/**
|
|
@@ -450,13 +457,18 @@ class RADashboardResponsiveService {
|
|
|
450
457
|
* @return {?}
|
|
451
458
|
*/
|
|
452
459
|
getGridsterItem(widget) {
|
|
460
|
+
if (widget.widgetSettings && typeof widget.widgetSettings === 'string') {
|
|
461
|
+
widget.widgetSettings = JSON.parse(widget.widgetSettings);
|
|
462
|
+
}
|
|
453
463
|
/** @type {?} */
|
|
454
464
|
let gridsterItem = (/** @type {?} */ ({
|
|
455
465
|
cols: this.getWidth(widget.width),
|
|
456
466
|
rows: this.getHeight(widget.height),
|
|
457
467
|
x: this.IsDesktopView ? widget.position_x : 0,
|
|
458
468
|
y: this.IsDesktopView ? widget.position_y : 0,
|
|
459
|
-
widgetInfo: widget
|
|
469
|
+
widgetInfo: widget,
|
|
470
|
+
minItemRows: this.getMinItemRows(widget),
|
|
471
|
+
minItemCols: this.getMinItemCols(widget)
|
|
460
472
|
}));
|
|
461
473
|
return gridsterItem;
|
|
462
474
|
}
|
|
@@ -467,12 +479,36 @@ class RADashboardResponsiveService {
|
|
|
467
479
|
*/
|
|
468
480
|
getWidth(width) {
|
|
469
481
|
if (!this.IsDesktopView) {
|
|
470
|
-
width = Math.floor(width /
|
|
482
|
+
width = Math.floor(width / this.maxColsDesktop * this.currentResInfo.maxCols);
|
|
471
483
|
if (width < this.currentResInfo.minCols)
|
|
472
484
|
width = this.currentResInfo.minCols;
|
|
473
485
|
}
|
|
474
486
|
return width;
|
|
475
487
|
}
|
|
488
|
+
/**
|
|
489
|
+
* @private
|
|
490
|
+
* @param {?} widget
|
|
491
|
+
* @return {?}
|
|
492
|
+
*/
|
|
493
|
+
getMinItemRows(widget) {
|
|
494
|
+
if (this.IsDesktopView) {
|
|
495
|
+
if (widget.widgetSettings && widget.widgetSettings.minRows) {
|
|
496
|
+
return widget.widgetSettings.minRows;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* @private
|
|
502
|
+
* @param {?} widget
|
|
503
|
+
* @return {?}
|
|
504
|
+
*/
|
|
505
|
+
getMinItemCols(widget) {
|
|
506
|
+
if (this.IsDesktopView) {
|
|
507
|
+
if (widget.widgetSettings && widget.widgetSettings.minCols) {
|
|
508
|
+
return widget.widgetSettings.minCols;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
476
512
|
/**
|
|
477
513
|
* @private
|
|
478
514
|
* @param {?} height
|
|
@@ -480,7 +516,7 @@ class RADashboardResponsiveService {
|
|
|
480
516
|
*/
|
|
481
517
|
getHeight(height) {
|
|
482
518
|
if (!this.IsDesktopView) {
|
|
483
|
-
height = Math.floor(height /
|
|
519
|
+
height = Math.floor(height / this.maxColsDesktop * this.currentResInfo.maxCols);
|
|
484
520
|
if (height < this.currentResInfo.minCols)
|
|
485
521
|
height = this.currentResInfo.minCols;
|
|
486
522
|
}
|
|
@@ -494,6 +530,10 @@ RADashboardResponsiveService.decorators = [
|
|
|
494
530
|
RADashboardResponsiveService.ctorParameters = () => [];
|
|
495
531
|
/** @nocollapse */ RADashboardResponsiveService.ngInjectableDef = ɵɵdefineInjectable({ factory: function RADashboardResponsiveService_Factory() { return new RADashboardResponsiveService(); }, token: RADashboardResponsiveService, providedIn: "root" });
|
|
496
532
|
if (false) {
|
|
533
|
+
/** @type {?} */
|
|
534
|
+
RADashboardResponsiveService.prototype.resized;
|
|
535
|
+
/** @type {?} */
|
|
536
|
+
RADashboardResponsiveService.prototype.maxColsDesktop;
|
|
497
537
|
/**
|
|
498
538
|
* @type {?}
|
|
499
539
|
* @private
|
|
@@ -541,38 +581,37 @@ class RADashboardArea {
|
|
|
541
581
|
this.widgetWidth = 4;
|
|
542
582
|
}
|
|
543
583
|
/**
|
|
544
|
-
* @param {?} event
|
|
545
584
|
* @return {?}
|
|
546
585
|
*/
|
|
547
|
-
|
|
548
|
-
this.
|
|
549
|
-
|
|
586
|
+
ngOnInit() {
|
|
587
|
+
this.initiateGridsterConfig();
|
|
588
|
+
this.responsiveService.resized.subscribe((/**
|
|
550
589
|
* @return {?}
|
|
551
590
|
*/
|
|
552
591
|
() => {
|
|
553
|
-
this.
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
()
|
|
561
|
-
this.
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
592
|
+
this.widgetList = [];
|
|
593
|
+
setTimeout((/**
|
|
594
|
+
* @return {?}
|
|
595
|
+
*/
|
|
596
|
+
() => {
|
|
597
|
+
this.initiateGridsterConfig();
|
|
598
|
+
this.options.api.optionsChanged();
|
|
599
|
+
if (this.userWidgets) {
|
|
600
|
+
this.widgetList = this.mapObjectListToGridsterItemList(this.userWidgets);
|
|
601
|
+
setTimeout((/**
|
|
602
|
+
* @return {?}
|
|
603
|
+
*/
|
|
604
|
+
() => {
|
|
605
|
+
this.setAreaHeight();
|
|
606
|
+
}));
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
this.loadWidgets(this.userDashboardId, this.areaKey);
|
|
610
|
+
}
|
|
611
|
+
this.domResized = !this.domResized;
|
|
612
|
+
}));
|
|
568
613
|
}));
|
|
569
614
|
}
|
|
570
|
-
/**
|
|
571
|
-
* @return {?}
|
|
572
|
-
*/
|
|
573
|
-
ngOnInit() {
|
|
574
|
-
this.initiateGridsterConfig();
|
|
575
|
-
}
|
|
576
615
|
/**
|
|
577
616
|
* @param {?} changes
|
|
578
617
|
* @return {?}
|
|
@@ -598,11 +637,8 @@ class RADashboardArea {
|
|
|
598
637
|
* @return {?}
|
|
599
638
|
*/
|
|
600
639
|
(gridster) => {
|
|
601
|
-
console.log('grid inititalized');
|
|
602
|
-
console.log(this.options.api);
|
|
603
640
|
if (this.options.api) {
|
|
604
641
|
this.gridcellHeight = this.options.api.getCurrentRowHeight();
|
|
605
|
-
console.log('cell height is' + this.gridcellHeight);
|
|
606
642
|
}
|
|
607
643
|
});
|
|
608
644
|
this.options.itemChangeCallback = (/**
|
|
@@ -908,10 +944,17 @@ class RADashboardArea {
|
|
|
908
944
|
* @return {?}
|
|
909
945
|
*/
|
|
910
946
|
rearrangeWidgets() {
|
|
911
|
-
this.
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
947
|
+
for (let i = 0; i < this.userWidgets.length; i++) {
|
|
948
|
+
this.userWidgets[i].position_x = 0;
|
|
949
|
+
this.userWidgets[i].position_y = 0;
|
|
950
|
+
this.widgetList = this.mapObjectListToGridsterItemList(this.userWidgets);
|
|
951
|
+
setTimeout((/**
|
|
952
|
+
* @return {?}
|
|
953
|
+
*/
|
|
954
|
+
() => {
|
|
955
|
+
this.setAreaHeight();
|
|
956
|
+
}));
|
|
957
|
+
}
|
|
915
958
|
}
|
|
916
959
|
/**
|
|
917
960
|
* To add widget instance to the database with the next available position and to make changes in
|
|
@@ -922,6 +965,17 @@ class RADashboardArea {
|
|
|
922
965
|
addWidget(data) {
|
|
923
966
|
data.height = this.widgetHeight;
|
|
924
967
|
data.width = this.widgetWidth;
|
|
968
|
+
if (data.widgetSettings) {
|
|
969
|
+
if (typeof data.widgetSettings === 'string')
|
|
970
|
+
data.widgetSettings = JSON.parse(data.widgetSettings);
|
|
971
|
+
if (data.widgetSettings.defaultCols) {
|
|
972
|
+
data.width = data.widgetSettings.defaultCols;
|
|
973
|
+
}
|
|
974
|
+
if (data.widgetSettings.defaultRows) {
|
|
975
|
+
data.height = data.widgetSettings.defaultRows;
|
|
976
|
+
}
|
|
977
|
+
data.widgetSettings = null;
|
|
978
|
+
}
|
|
925
979
|
data = this.setPositions(data);
|
|
926
980
|
/** to find the available position in gridster, temp commenting the code-returning higher y value than normal */
|
|
927
981
|
data.dashboardAreaKey = this.areaKey;
|
|
@@ -974,12 +1028,12 @@ class RADashboardArea {
|
|
|
974
1028
|
if (this.userWidgets.length > 0) {
|
|
975
1029
|
/** @type {?} */
|
|
976
1030
|
let widget = this.userWidgets[this.userWidgets.length - 1];
|
|
977
|
-
if (widget.position_x + widget.width >
|
|
1031
|
+
if (widget.position_x + widget.width > (this.responsiveService.maxColsDesktop / 2)) {
|
|
978
1032
|
data.position_y = widget.position_y + 1;
|
|
979
1033
|
}
|
|
980
1034
|
else {
|
|
981
1035
|
data.position_y = widget.position_y;
|
|
982
|
-
data.position_x =
|
|
1036
|
+
data.position_x = this.responsiveService.maxColsDesktop - (widget.position_x + widget.width);
|
|
983
1037
|
}
|
|
984
1038
|
}
|
|
985
1039
|
}
|
|
@@ -1078,8 +1132,7 @@ RADashboardArea.propDecorators = {
|
|
|
1078
1132
|
widgetHeight: [{ type: Input, args: ['widget-height',] }],
|
|
1079
1133
|
widgetWidth: [{ type: Input, args: ['widget-width',] }],
|
|
1080
1134
|
appConfig: [{ type: Input, args: ['app-config',] }],
|
|
1081
|
-
gridWrapper: [{ type: ViewChild, args: ['gridWrapper', { static: false },] }]
|
|
1082
|
-
onResize: [{ type: HostListener, args: ['window:resize', ['$event'],] }]
|
|
1135
|
+
gridWrapper: [{ type: ViewChild, args: ['gridWrapper', { static: false },] }]
|
|
1083
1136
|
};
|
|
1084
1137
|
if (false) {
|
|
1085
1138
|
/** @type {?} */
|
|
@@ -1473,7 +1526,7 @@ class RAWidgetContainer {
|
|
|
1473
1526
|
globalFilter: this.globalFilter,
|
|
1474
1527
|
configChanges: this.getConfigChanges(false)
|
|
1475
1528
|
}));
|
|
1476
|
-
if (widgetInfo.widgetSettings
|
|
1529
|
+
if (widgetInfo.widgetSettings) {
|
|
1477
1530
|
this.widgetSettings = this.getParsedConfig(widgetInfo.widgetSettings);
|
|
1478
1531
|
this.applayWidgetSettings(this.widgetSettings);
|
|
1479
1532
|
}
|
|
@@ -1561,7 +1614,7 @@ class RAWidgetContainer {
|
|
|
1561
1614
|
widgetContainer.isWidgetLoaded = true;
|
|
1562
1615
|
widgetConfigFilter.appConfig = this.appConfig;
|
|
1563
1616
|
widgetConfigFilter.widgetInfo = widgetInfo;
|
|
1564
|
-
|
|
1617
|
+
widgetConfigFilter.configChanges = this.getConfigChanges(false);
|
|
1565
1618
|
widgetConfigFilter.widgetInfo.widgetName = widgetInfo.widgetName;
|
|
1566
1619
|
widgetContainer.widgetElement.loadContent(widgetConfigFilter);
|
|
1567
1620
|
yield widgetContainer.setLock(widgetConfigFilter.config);
|