diff --git a/ui-ngx/src/app/core/services/dashboard-utils.service.ts b/ui-ngx/src/app/core/services/dashboard-utils.service.ts index 9f1c94a83e..ef51868fa9 100644 --- a/ui-ngx/src/app/core/services/dashboard-utils.service.ts +++ b/ui-ngx/src/app/core/services/dashboard-utils.service.ts @@ -753,8 +753,46 @@ export class DashboardUtilsService { const widget = layout.widgets[w]; widget.row = Math.round(widget.row * ratio); widget.col = Math.round(widget.col * ratio); - widget.sizeX = Math.round(widget.sizeX * ratio); - widget.sizeY = Math.round(widget.sizeY * ratio); + widget.sizeX = Math.max(1, Math.round(widget.sizeX * ratio)); + widget.sizeY = Math.max(1, Math.round(widget.sizeY * ratio)); + } + for (const w of Object.keys(layout.widgets)) { + const widget = layout.widgets[w]; + for (const w2 of Object.keys(layout.widgets)) { + const widget2 = layout.widgets[w2]; + if (widget !== widget2) { + const left = widget.col; + const right = widget.col + widget.sizeX; + const top = widget.row; + const bottom = widget.row + widget.sizeY; + const left2 = widget2.col; + const right2 = widget2.col + widget2.sizeX; + const top2 = widget2.row; + const bottom2 = widget2.row + widget2.sizeY; + if (left < right2 && right > left2 && + top > bottom2 && bottom < top2 ) { + let horizontalOverlapFixed = false; + if (right - left2 === 1) { + if (widget.sizeX > 1) { + widget.sizeX--; + horizontalOverlapFixed = true; + } else if (widget2.sizeX > 1) { + widget2.col++; + widget2.sizeX--; + horizontalOverlapFixed = true; + } + } + if (!horizontalOverlapFixed && (bottom - top2) === 1) { + if (widget.sizeY > 1) { + widget.sizeY--; + } else if (widget2.sizeY > 1) { + widget2.row++; + widget2.sizeY--; + } + } + } + } + } } }