100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
UI updates: Fix for scrollbar not working when switching dashboards (#1355)
Martin Peeters65b2da4f48c9
diff --git a/ui/component/or-dashboard-builder/src/or-dashboard-preview.ts b/ui/component/or-dashboard-builder/src/or-dashboard-preview.tsindex a07a35931..1e25b8ff1 100644--- a/ui/component/or-dashboard-builder/src/or-dashboard-preview.ts+++ b/ui/component/or-dashboard-builder/src/or-dashboard-preview.ts@@ -139,6 +139,7 @@ export class OrDashboardPreview extends LitElement {// If there is no value yet, do initial setup:} else if(newValue != undefined) {+ console.debug("Creating a new Dashboard grid...");this._template = newValue;this.setupGrid(false, false);}@@ -305,6 +306,7 @@ export class OrDashboardPreview extends LitElement {// Switching edit/view mode needs recreation of Gridif(changedProperties.has("editMode")) {if(changedProperties.get('editMode') != undefined) {+ console.debug(`Edit mode is now ${this.editMode}. Force recreating grid...`);this.setupGrid(true, true);}}@@ -429,6 +431,7 @@ export class OrDashboardPreview extends LitElement {/* ------------------------------- */public refreshPreview() {+ console.debug("Refreshing dashboard preview!");this.setupGrid(true, true);}@@ -651,6 +654,7 @@ export class OrDashboardPreview extends LitElement {}protected _onGridResize() {+ console.debug("Grid resize detected. Recreating the grid...");this.setupGrid(true, false);}@@ -665,25 +669,35 @@ export class OrDashboardPreview extends LitElement {let gridElement = this.shadowRoot?.getElementById("gridElement");gridElement!.style.backgroundSize = "" + this.grid.cellWidth() + "px " + this.grid.getCellHeight() + "px";gridElement!.style.height = maingrid!.scrollHeight + 'px';+ console.debug("Amount of columns has been changed! Recreating grid...");this.setupGrid(true, false);}// If multiple properties changed, just force rerender all of it.else if(changes.changedKeys.length > 1) {+ console.debug("Multiple changes detected. Force recreating grid...");this.setupGrid(true, true);}// On widgets change, check whether they are programmatically added to GridStack. If not, adding them.else if(changes.changedKeys.includes('widgets')) {if(this.grid?.el != null) {+ let amountAdded = 0;this.grid.getGridItems().forEach((gridElement) => {if(!gridElement.classList.contains('ui-draggable')) {this.grid?.makeWidget(gridElement);+ amountAdded++;}- })+ });+ // If a widget is added, update the grid. (for example to update dashboard height)+ if(amountAdded > 0) {+ console.debug(`Created ${amountAdded} widgets. Updating the grid...`);+ this.setupGrid(false, false);+ }}}else if(changes.changedKeys.includes('screenPresets')) {+ console.debug("New template has a different screen preset! Force recreating grid...");this.setupGrid(true, true);}}diff --git a/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts b/ui/component/or-dashboard-builder/src/or-dashboard-tree.tsindex 9093cd12c..b3de43604 100644--- a/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts+++ b/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts@@ -156,7 +156,10 @@ export class OrDashboardTree extends LitElement {protected _doDuplicateDashboard(dashboard: Dashboard) {const newDashboard = JSON.parse(JSON.stringify(dashboard)) as Dashboard;- newDashboard.displayName = (newDashboard.displayName + ' copy');+ newDashboard.displayName = (newDashboard.displayName + " copy");+ if(newDashboard.template) {+ newDashboard.template.id = Math.random().toString(36).slice(2, (String(newDashboard.template.id).length + 2)); // generate a new ID+ }DashboardService.create(newDashboard, undefined, this.realm).then(d => {if (!this.dashboards) {this.dashboards = [d] as Dashboard[];