@schneideress/dashboardframework 20.0.16 → 20.0.17
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.
|
@@ -5087,6 +5087,9 @@ class RADashboardArea {
|
|
|
5087
5087
|
let _the = this;
|
|
5088
5088
|
this.isSiteDetailDashboard = this.dashboardInfo?.templateName === 'Site Detail';
|
|
5089
5089
|
this.dashboardService.getWidgetsByDashboardArea(widgetInfo, this.appConfig).subscribe(widgets => {
|
|
5090
|
+
if (this.isSiteDetailDashboard) {
|
|
5091
|
+
widgets = this.arrangeWidgetsInTwoColumnGrid(widgets);
|
|
5092
|
+
}
|
|
5090
5093
|
_the.widgetList = [];
|
|
5091
5094
|
this.userWidgets = widgets;
|
|
5092
5095
|
this.PAMWidgets = [];
|
|
@@ -5125,6 +5128,38 @@ class RADashboardArea {
|
|
|
5125
5128
|
this.raDashboardEventBus.publish(RAEvent.UpdateWidgetCount, this.userWidgets.length);
|
|
5126
5129
|
});
|
|
5127
5130
|
}
|
|
5131
|
+
/**
|
|
5132
|
+
* Arranges widgets in a 2-column grid layout for Site Detail dashboard
|
|
5133
|
+
* @param widgets - Array of widget objects to be arranged
|
|
5134
|
+
* @returns Modified widgets array with updated positions and dimensions. If more widgets exist than maxWidgetCount, only the last N widgets are positioned in the grid.
|
|
5135
|
+
*
|
|
5136
|
+
* Layout pattern (for last N widgets in 2-column layout):
|
|
5137
|
+
* - Widget n-3: x=0, y=0 (top-left)
|
|
5138
|
+
* - Widget n-2: x=4, y=0 (top-right)
|
|
5139
|
+
* - Widget n-1: x=0, y=2 (second row-left)
|
|
5140
|
+
* - Widget n: x=4, y=2 (second row-right)
|
|
5141
|
+
*
|
|
5142
|
+
* Additional widgets beyond maxWidgetCount are removed from the beginning of the array.
|
|
5143
|
+
*/
|
|
5144
|
+
arrangeWidgetsInTwoColumnGrid(widgets) {
|
|
5145
|
+
const colWidth = 4;
|
|
5146
|
+
const rowHeight = 2;
|
|
5147
|
+
const maxWidgets = this.templateConfig?.maxWidgetCount || 4;
|
|
5148
|
+
// If more widgets than allowed, keep only the last N widgets
|
|
5149
|
+
if (widgets.length > maxWidgets) {
|
|
5150
|
+
widgets = widgets.slice(-maxWidgets);
|
|
5151
|
+
}
|
|
5152
|
+
widgets.forEach((widget, index) => {
|
|
5153
|
+
const row = Math.floor(index / 2);
|
|
5154
|
+
const col = index % 2;
|
|
5155
|
+
widget.position_x = col * colWidth; // 0 for left column, 4 for right column
|
|
5156
|
+
widget.position_y = row * rowHeight; // 0, 2, 4, etc.
|
|
5157
|
+
widget.width = colWidth;
|
|
5158
|
+
widget.height = rowHeight;
|
|
5159
|
+
});
|
|
5160
|
+
console.log('Arranged Widgets:', widgets);
|
|
5161
|
+
return widgets;
|
|
5162
|
+
}
|
|
5128
5163
|
/** To set Area(Gridster) height dynamically as widgets are added/removed */
|
|
5129
5164
|
setAreaHeight() {
|
|
5130
5165
|
setTimeout(() => {
|