diff --git a/application/src/main/data/upgrade/3.8.0/schema_update.sql b/application/src/main/data/upgrade/3.8.1/schema_update.sql similarity index 100% rename from application/src/main/data/upgrade/3.8.0/schema_update.sql rename to application/src/main/data/upgrade/3.8.1/schema_update.sql diff --git a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java index 33e55b090d..029a27f510 100644 --- a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java +++ b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java @@ -141,8 +141,10 @@ public class ThingsboardInstallService { log.info("Upgrading ThingsBoard from version 3.7.0 to 3.8.0 ..."); databaseEntitiesUpgradeService.upgradeDatabase("3.7.0"); case "3.8.0": - log.info("Upgrading ThingsBoard from version 3.8.0 to 3.9.0 ..."); - databaseEntitiesUpgradeService.upgradeDatabase("3.8.0"); + log.info("Upgrading ThingsBoard from version 3.8.0 to 3.8.1 ..."); + case "3.8.1": + log.info("Upgrading ThingsBoard from version 3.8.1 to 3.9.0 ..."); + databaseEntitiesUpgradeService.upgradeDatabase("3.8.1"); //TODO DON'T FORGET to update switch statement in the CacheCleanupService if you need to clear the cache break; default: diff --git a/application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java b/application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java index 0bcd9d0014..86d03d65f5 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java @@ -106,7 +106,7 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService log.warn("Failed to execute update script for device profile rule nodes due to: ", e); } } - case "3.8.0" -> updateSchema("3.8.0", 3008000, "3.9.0", 3009000); + case "3.8.1" -> updateSchema("3.8.1", 3008001, "3.9.0", 3009000); default -> throw new RuntimeException("Unsupported fromVersion '" + fromVersion + "'"); } } 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..f0341410bc 100644 --- a/ui-ngx/src/app/core/services/dashboard-utils.service.ts +++ b/ui-ngx/src/app/core/services/dashboard-utils.service.ts @@ -749,12 +749,57 @@ export class DashboardUtilsService { widget.sizeY = 1; } } + const widgets: WidgetLayout[] = []; for (const w of Object.keys(layout.widgets)) { 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)); + widgets.push(widget); + } + widgets.sort((w1, w2) => { + let res = w1.col - w2.col; + if (res === 0) { + res = w1.row - w2.row; + } + return res; + }); + for (const widget of widgets) { + for (const widget2 of widgets) { + 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--; + } + } + } + } + } } }