From ddbd3903d276fb79885ecd006d8ac50bdc896217 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 21 Jun 2024 12:31:40 +0300 Subject: [PATCH] UI: Dashboard layout settings improvements. Add test scada widgets bundle. --- .../horizontal-connector-long.svg | 18 +++ .../scada_symbols/horizontal-connector.svg | 16 +++ .../scada_symbols/horizontal-faucet.svg | 85 ++++++++++++ .../horizontal-tank-with-screen.svg | 20 +++ .../left-bottom-angle-connector.svg | 26 ++++ .../left-top-angle-connector.svg | 26 ++++ .../json/system/scada_symbols/pump-left.svg | 127 ++++++++++++++++++ .../data/json/system/scada_symbols/pump.svg | 127 ++++++++++++++++++ .../system/scada_symbols/quadro-connector.svg | 26 ++++ .../right-bottom-angle-connector.svg | 26 ++++ .../right-top-angle-connector.svg | 26 ++++ .../scada_symbols/top-black-counter.svg | 31 +++++ .../scada_symbols/top-white-counter.svg | 31 +++++ .../scada_symbols/vertical-connector-long.svg | 16 +++ .../scada_symbols/vertical-connector.svg | 16 +++ .../vertical-tank-with-level.svg | 24 ++++ .../water-blower-right-connector.svg | 102 ++++++++++++++ .../system/widget_bundles/scada_symbols.json | 4 +- .../scada_water_system_symbols.json | 30 +++++ .../install/ThingsboardInstallService.java | 2 - .../DefaultSystemDataLoaderService.java | 5 - .../service/install/InstallScripts.java | 20 +-- .../install/SystemDataLoaderService.java | 2 - .../dashboard-page.component.ts | 9 +- .../dashboard-page/dashboard-page.models.ts | 1 + .../dashboard-settings-dialog.component.html | 29 ++-- .../dashboard-settings-dialog.component.ts | 26 +++- .../layout/dashboard-layout.component.ts | 21 ++- .../dashboard/dashboard.component.html | 1 + .../dashboard/dashboard.component.ts | 9 ++ .../home/models/dashboard-component.models.ts | 1 + .../src/app/shared/models/dashboard.models.ts | 22 ++- .../assets/locale/locale.constant-en_US.json | 4 +- 33 files changed, 878 insertions(+), 51 deletions(-) create mode 100644 application/src/main/data/json/system/scada_symbols/horizontal-connector-long.svg create mode 100644 application/src/main/data/json/system/scada_symbols/horizontal-connector.svg create mode 100644 application/src/main/data/json/system/scada_symbols/horizontal-faucet.svg create mode 100644 application/src/main/data/json/system/scada_symbols/horizontal-tank-with-screen.svg create mode 100644 application/src/main/data/json/system/scada_symbols/left-bottom-angle-connector.svg create mode 100644 application/src/main/data/json/system/scada_symbols/left-top-angle-connector.svg create mode 100644 application/src/main/data/json/system/scada_symbols/pump-left.svg create mode 100644 application/src/main/data/json/system/scada_symbols/pump.svg create mode 100644 application/src/main/data/json/system/scada_symbols/quadro-connector.svg create mode 100644 application/src/main/data/json/system/scada_symbols/right-bottom-angle-connector.svg create mode 100644 application/src/main/data/json/system/scada_symbols/right-top-angle-connector.svg create mode 100644 application/src/main/data/json/system/scada_symbols/top-black-counter.svg create mode 100644 application/src/main/data/json/system/scada_symbols/top-white-counter.svg create mode 100644 application/src/main/data/json/system/scada_symbols/vertical-connector-long.svg create mode 100644 application/src/main/data/json/system/scada_symbols/vertical-connector.svg create mode 100644 application/src/main/data/json/system/scada_symbols/vertical-tank-with-level.svg create mode 100644 application/src/main/data/json/system/scada_symbols/water-blower-right-connector.svg create mode 100644 application/src/main/data/json/system/widget_bundles/scada_water_system_symbols.json diff --git a/application/src/main/data/json/system/scada_symbols/horizontal-connector-long.svg b/application/src/main/data/json/system/scada_symbols/horizontal-connector-long.svg new file mode 100644 index 0000000000..40b3148fe0 --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/horizontal-connector-long.svg @@ -0,0 +1,18 @@ +{ + "title": "Horizontal connector long", + "widgetSizeX": 2, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/horizontal-connector.svg b/application/src/main/data/json/system/scada_symbols/horizontal-connector.svg new file mode 100644 index 0000000000..7a52cc236a --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/horizontal-connector.svg @@ -0,0 +1,16 @@ + +{ + "title": "Horizontal connector", + "widgetSizeX": 1, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/horizontal-faucet.svg b/application/src/main/data/json/system/scada_symbols/horizontal-faucet.svg new file mode 100644 index 0000000000..0a2510903c --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/horizontal-faucet.svg @@ -0,0 +1,85 @@ + +{ + "title": "Horizontal faucet", + "widgetSizeX": 2, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/horizontal-tank-with-screen.svg b/application/src/main/data/json/system/scada_symbols/horizontal-tank-with-screen.svg new file mode 100644 index 0000000000..bfc7c83976 --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/horizontal-tank-with-screen.svg @@ -0,0 +1,20 @@ + +{ + "title": "Horizontal tank with screen", + "widgetSizeX": 5, + "widgetSizeY": 3, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/left-bottom-angle-connector.svg b/application/src/main/data/json/system/scada_symbols/left-bottom-angle-connector.svg new file mode 100644 index 0000000000..3c85418142 --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/left-bottom-angle-connector.svg @@ -0,0 +1,26 @@ + +{ + "title": "Left bottom angle connector", + "widgetSizeX": 1, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/left-top-angle-connector.svg b/application/src/main/data/json/system/scada_symbols/left-top-angle-connector.svg new file mode 100644 index 0000000000..1d97658ff1 --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/left-top-angle-connector.svg @@ -0,0 +1,26 @@ + +{ + "title": "Left top angle connector", + "widgetSizeX": 1, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/pump-left.svg b/application/src/main/data/json/system/scada_symbols/pump-left.svg new file mode 100644 index 0000000000..835e93b3fc --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/pump-left.svg @@ -0,0 +1,127 @@ + +{ + "title": "Pump left", + "widgetSizeX": 4, + "widgetSizeY": 3, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/pump.svg b/application/src/main/data/json/system/scada_symbols/pump.svg new file mode 100644 index 0000000000..2880c86a6c --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/pump.svg @@ -0,0 +1,127 @@ + +{ + "title": "Pump", + "widgetSizeX": 4, + "widgetSizeY": 3, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/quadro-connector.svg b/application/src/main/data/json/system/scada_symbols/quadro-connector.svg new file mode 100644 index 0000000000..31b2f2accc --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/quadro-connector.svg @@ -0,0 +1,26 @@ + +{ + "title": "Quadro connector", + "widgetSizeX": 1, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/right-bottom-angle-connector.svg b/application/src/main/data/json/system/scada_symbols/right-bottom-angle-connector.svg new file mode 100644 index 0000000000..25118c6956 --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/right-bottom-angle-connector.svg @@ -0,0 +1,26 @@ + +{ + "title": "Right bottom angle connector", + "widgetSizeX": 1, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/right-top-angle-connector.svg b/application/src/main/data/json/system/scada_symbols/right-top-angle-connector.svg new file mode 100644 index 0000000000..3dfb37266d --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/right-top-angle-connector.svg @@ -0,0 +1,26 @@ + +{ + "title": "Right top angle connector", + "widgetSizeX": 1, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/top-black-counter.svg b/application/src/main/data/json/system/scada_symbols/top-black-counter.svg new file mode 100644 index 0000000000..07a73c0b31 --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/top-black-counter.svg @@ -0,0 +1,31 @@ + +{ + "title": "Top black counter", + "widgetSizeX": 2, + "widgetSizeY": 2, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/top-white-counter.svg b/application/src/main/data/json/system/scada_symbols/top-white-counter.svg new file mode 100644 index 0000000000..66bfc9dba1 --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/top-white-counter.svg @@ -0,0 +1,31 @@ + +{ + "title": "Top white counter", + "widgetSizeX": 2, + "widgetSizeY": 2, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/vertical-connector-long.svg b/application/src/main/data/json/system/scada_symbols/vertical-connector-long.svg new file mode 100644 index 0000000000..af1c25d862 --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/vertical-connector-long.svg @@ -0,0 +1,16 @@ + +{ + "title": "Vertical connector long", + "widgetSizeX": 1, + "widgetSizeY": 2, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/vertical-connector.svg b/application/src/main/data/json/system/scada_symbols/vertical-connector.svg new file mode 100644 index 0000000000..53ae6c58dc --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/vertical-connector.svg @@ -0,0 +1,16 @@ + +{ + "title": "Vertical connector", + "widgetSizeX": 1, + "widgetSizeY": 1, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/vertical-tank-with-level.svg b/application/src/main/data/json/system/scada_symbols/vertical-tank-with-level.svg new file mode 100644 index 0000000000..06951fb94e --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/vertical-tank-with-level.svg @@ -0,0 +1,24 @@ + +{ + "title": "Vertical tank with level", + "widgetSizeX": 3, + "widgetSizeY": 5, + "tags": [], + "behavior": [], + "properties": [] +} + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/scada_symbols/water-blower-right-connector.svg b/application/src/main/data/json/system/scada_symbols/water-blower-right-connector.svg new file mode 100644 index 0000000000..88a561f2ea --- /dev/null +++ b/application/src/main/data/json/system/scada_symbols/water-blower-right-connector.svg @@ -0,0 +1,102 @@ + +{ + "title": "Water blower right connector", + "widgetSizeX": 2, + "widgetSizeY": 2, + "tags": [ + { + "tag": "motor", + "stateRenderFunction": "var on = ctx.values.on;\n//debugger;\nvar t = element.timeline();\nif (on) {\n if (!t.active()) {\n if (t.time()) {\n t.play();\n } else {\n ctx.api.animate(element, 2000).ease('-').rotate(360).loop();\n t = element.timeline();\n //var speed = 0.25;\n //speed = Math.max(0, Math.min(1, speed))*2; \n //t.speed(speed);\n }\n }\n} else {\n t.pause();//.stop();\n}", + "actions": null + } + ], + "behavior": [ + { + "id": "on", + "name": "On/Off state", + "hint": null, + "type": "value", + "valueType": "BOOLEAN", + "defaultValue": false, + "trueLabel": "{i18n:widgets.rpc-state.on}", + "falseLabel": "{i18n:widgets.rpc-state.off}", + "stateLabel": "{i18n:widgets.rpc-state.on}", + "valueToDataType": "CONSTANT", + "constantValue": false, + "valueToDataFunction": "" + } + ], + "properties": [] +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/src/main/data/json/system/widget_bundles/scada_symbols.json b/application/src/main/data/json/system/widget_bundles/scada_symbols.json index 8a933b18f8..47615e6137 100644 --- a/application/src/main/data/json/system/widget_bundles/scada_symbols.json +++ b/application/src/main/data/json/system/widget_bundles/scada_symbols.json @@ -7,5 +7,7 @@ "order": 9200, "name": "SCADA symbols" }, - "widgetTypeFqns": [] + "widgetTypeFqns": [ + "scada_symbol" + ] } \ No newline at end of file diff --git a/application/src/main/data/json/system/widget_bundles/scada_water_system_symbols.json b/application/src/main/data/json/system/widget_bundles/scada_water_system_symbols.json new file mode 100644 index 0000000000..153afd0335 --- /dev/null +++ b/application/src/main/data/json/system/widget_bundles/scada_water_system_symbols.json @@ -0,0 +1,30 @@ +{ + "widgetsBundle": { + "alias": "scada_water_system_symbols", + "title": "SCADA water system symbols", + "image": null, + "description": "Bundle with SCADA symbols for water system", + "order": 9300, + "name": "SCADA water system symbols" + }, + "widgetTypeFqns": [ + "level_and_fan", + "vertical_connector_long", + "horizontal_tank_with_screen", + "quadro_connector", + "horizontal_faucet", + "top_white_counter", + "right_top_angle_connector", + "left_top_angle_connector", + "water_blower_right_connector", + "vertical_tank_with_level", + "left_bottom_angle_connector", + "horizontal_connector_long", + "top_black_counter", + "right_bottom_angle_connector", + "vertical_connector", + "horizontal_connector", + "pump_left", + "pump" + ] +} \ No newline at end of file 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 839aa61975..75ac97881c 100644 --- a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java +++ b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java @@ -150,7 +150,6 @@ public class ThingsboardInstallService { log.info("Updating system data..."); dataUpdateService.upgradeRuleNodes(); systemDataLoaderService.loadSystemWidgets(); - systemDataLoaderService.loadSystemScadaSymbols(); installScripts.loadSystemLwm2mResources(); installScripts.loadSystemImages(); if (installScripts.isUpdateImages()) { @@ -191,7 +190,6 @@ public class ThingsboardInstallService { systemDataLoaderService.createAdminSettings(); systemDataLoaderService.createRandomJwtSettings(); systemDataLoaderService.loadSystemWidgets(); - systemDataLoaderService.loadSystemScadaSymbols(); systemDataLoaderService.createOAuth2Templates(); systemDataLoaderService.createQueues(); systemDataLoaderService.createDefaultNotificationConfigs(); diff --git a/application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java b/application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java index 6a150a918b..7588726a73 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java @@ -526,11 +526,6 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService { installScripts.loadSystemWidgets(); } - @Override - public void loadSystemScadaSymbols() throws Exception { - installScripts.loadSystemScadaSymbols(); - } - private User createUser(Authority authority, TenantId tenantId, CustomerId customerId, diff --git a/application/src/main/java/org/thingsboard/server/service/install/InstallScripts.java b/application/src/main/java/org/thingsboard/server/service/install/InstallScripts.java index e3c8c209c4..5aeff25fe9 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/InstallScripts.java +++ b/application/src/main/java/org/thingsboard/server/service/install/InstallScripts.java @@ -265,6 +265,7 @@ public class InstallScripts { ); } } + this.loadSystemScadaSymbols(); for (var widgetsBundleDescriptorEntry : widgetsBundlesMap.entrySet()) { Path path = widgetsBundleDescriptorEntry.getKey(); try { @@ -302,12 +303,11 @@ public class InstallScripts { } } - public void loadSystemScadaSymbols() throws Exception { + private void loadSystemScadaSymbols() throws Exception { log.info("Loading system SCADA symbols"); Path scadaSymbolsDir = Paths.get(getDataDir(), JSON_DIR, SYSTEM_DIR, SCADA_SYMBOLS_DIR); if (Files.exists(scadaSymbolsDir)) { - WidgetTypeDetails widgetTypeDetailsTemplate = widgetTypeService.findWidgetTypeDetailsByTenantIdAndFqn(TenantId.SYS_TENANT_ID, "scada_symbol"); - List widgetTypeFqns = new ArrayList<>(); + WidgetTypeDetails scadaSymbolWidgetTemplate = widgetTypeService.findWidgetTypeDetailsByTenantIdAndFqn(TenantId.SYS_TENANT_ID, "scada_symbol"); try (DirectoryStream dirStream = Files.newDirectoryStream(scadaSymbolsDir, path -> path.toString().endsWith(SVG_EXT))) { dirStream.forEach( path -> { @@ -316,8 +316,8 @@ public class InstallScripts { var scadaSymbolData = Files.readAllBytes(path); var metadata = ImageUtils.processScadaSymbolMetadata(fileName, scadaSymbolData); TbResourceInfo savedScadaSymbol = saveScadaSymbol(metadata, fileName, scadaSymbolData); - if (widgetTypeDetailsTemplate != null) { - widgetTypeFqns.add(saveScadaSymbolWidget(widgetTypeDetailsTemplate, savedScadaSymbol, metadata)); + if (scadaSymbolWidgetTemplate != null) { + saveScadaSymbolWidget(scadaSymbolWidgetTemplate, savedScadaSymbol, metadata); } } catch (Exception e) { log.error("Unable to load SCADA symbol from file: [{}]", path.toString()); @@ -326,11 +326,6 @@ public class InstallScripts { } ); } - var scadaSymbolsBundle = widgetsBundleService.findWidgetsBundleByTenantIdAndAlias(TenantId.SYS_TENANT_ID, "scada_symbols"); - if (scadaSymbolsBundle != null) { - widgetTypeFqns.add("scada_symbol"); - widgetTypeService.updateWidgetsBundleWidgetFqns(TenantId.SYS_TENANT_ID, scadaSymbolsBundle.getId(), widgetTypeFqns); - } } } @@ -355,7 +350,7 @@ public class InstallScripts { } } - private String saveScadaSymbolWidget(WidgetTypeDetails template, TbResourceInfo scadaSymbol, + private WidgetTypeDetails saveScadaSymbolWidget(WidgetTypeDetails template, TbResourceInfo scadaSymbol, ImageUtils.ScadaSymbolMetadataInfo metadata) { String symbolUrl = DataConstants.TB_IMAGE_PREFIX + scadaSymbol.getLink(); WidgetTypeDetails scadaSymbolWidget = new WidgetTypeDetails(); @@ -388,8 +383,7 @@ public class InstallScripts { controllerScript = controllerScript.replaceAll("previewWidth: '\\d*px'", "previewWidth: '" + (metadata.getWidgetSizeX() * 100) + "px'"); controllerScript = controllerScript.replaceAll("previewHeight: '\\d*px'", "previewHeight: '" + (metadata.getWidgetSizeY() * 100 + 20) + "px'"); ((ObjectNode)descriptor).put("controllerScript", controllerScript); - var savedWidget = widgetTypeService.saveWidgetType(scadaSymbolWidget); - return savedWidget.getFqn(); + return widgetTypeService.saveWidgetType(scadaSymbolWidget); } private void deleteSystemWidgetBundle(String bundleAlias) { diff --git a/application/src/main/java/org/thingsboard/server/service/install/SystemDataLoaderService.java b/application/src/main/java/org/thingsboard/server/service/install/SystemDataLoaderService.java index 6711bfa142..2f4b5fa885 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/SystemDataLoaderService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/SystemDataLoaderService.java @@ -31,8 +31,6 @@ public interface SystemDataLoaderService { void loadSystemWidgets() throws Exception; - void loadSystemScadaSymbols() throws Exception; - void loadDemoData() throws Exception; void createQueues(); diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts index 0ea553b508..ff2d6eab59 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts @@ -51,6 +51,7 @@ import { DashboardStateLayouts, GridSettings, LayoutDimension, + LayoutType, WidgetLayout } from '@app/shared/models/dashboard.models'; import { WINDOW } from '@core/services/window.service'; @@ -1199,7 +1200,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC } else { layoutIds = Object.keys(layouts) as DashboardLayoutId[]; } - return layoutIds.every(id => layouts[id].gridSettings.isScada); + return layoutIds.every(id => layouts[id].gridSettings.layoutType === LayoutType.scada); } private selectTargetLayout(): Observable { @@ -1397,6 +1398,12 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC this.importExport.exportWidget(this.dashboard, this.dashboardCtx.state, layoutCtx.id, widget, widgetTitle); } + dashboardMouseDown($event: Event, layoutCtx: DashboardPageLayoutContext) { + if (this.isEdit && !this.isEditingWidget) { + layoutCtx.ctrl.resetHighlight(); + } + } + widgetClicked($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget) { if (this.isEditingWidget) { this.editWidget($event, layoutCtx, widget); diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts index 94dfaf635e..0c43be1e91 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts @@ -53,6 +53,7 @@ export interface IDashboardController { exportWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget, widgetTitle: string); removeWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget); widgetMouseDown($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget); + dashboardMouseDown($event: Event, layoutCtx: DashboardPageLayoutContext); widgetClicked($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget); prepareDashboardContextMenu(layoutCtx: DashboardPageLayoutContext): Array; prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget): Array; diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.html index 50460e808c..d15512b561 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.html @@ -105,16 +105,21 @@
-
- - {{ 'dashboard.scada-layout' | translate }} - +
+
dashboard.layout
+ + + + {{ layoutTypeTranslations.get(type) | translate }} + + +
dashboard.layout-settings
dashboard.columns-count
- - @@ -156,7 +161,7 @@ dashboard.columns-suffix
-
+
dashboard.widgets-margins
-
+
{{ 'dashboard.apply-outer-margin' | translate }}
-
+
{{ 'dashboard.autofill-height' | translate }} @@ -207,19 +212,19 @@
-
+
dashboard.mobile-layout
{{ 'dashboard.display-first-in-mobile-view' | translate }}
-
+
{{ 'dashboard.autofill-height' | translate }}
-
+
dashboard.mobile-row-height
implements OnInit, ErrorStateMatcher { + layoutTypes = layoutTypes; + + layoutTypeTranslations = layoutTypeTranslationMap; + settings: DashboardSettings; gridSettings: GridSettings; isRightLayout = false; @@ -164,7 +174,7 @@ export class DashboardSettingsDialogComponent extends DialogComponent { this.updateGridSettingsFormState(); @@ -199,6 +209,14 @@ export class DashboardSettingsDialogComponent extends DialogComponent
void; onRemoveWidget?: ($event: Event, widget: Widget) => void; onWidgetMouseDown?: ($event: Event, widget: Widget) => void; + onDashboardMouseDown?: ($event: Event) => void; onWidgetClicked?: ($event: Event, widget: Widget) => void; prepareDashboardContextMenu?: ($event: Event) => Array; prepareWidgetContextMenu?: ($event: Event, widget: Widget) => Array; diff --git a/ui-ngx/src/app/shared/models/dashboard.models.ts b/ui-ngx/src/app/shared/models/dashboard.models.ts index 282f87ade3..cb7bf891b1 100644 --- a/ui-ngx/src/app/shared/models/dashboard.models.ts +++ b/ui-ngx/src/app/shared/models/dashboard.models.ts @@ -18,7 +18,7 @@ import { BaseData, ExportableEntity } from '@shared/models/base-data'; import { DashboardId } from '@shared/models/id/dashboard-id'; import { TenantId } from '@shared/models/id/tenant-id'; import { ShortCustomerInfo } from '@shared/models/customer.model'; -import { Widget } from './widget.models'; +import { LegendPosition, Widget } from './widget.models'; import { Timewindow } from '@shared/models/time/time.models'; import { EntityAliases } from './alias.models'; import { Filters } from '@shared/models/query/query.models'; @@ -49,7 +49,22 @@ export interface WidgetLayouts { [id: string]: WidgetLayout; } +export enum LayoutType { + default = 'default', + scada = 'scada' +} + +export const layoutTypes = Object.keys(LayoutType) as LayoutType[]; + +export const layoutTypeTranslationMap = new Map( + [ + [ LayoutType.default, 'dashboard.layout-type-default' ], + [ LayoutType.scada, 'dashboard.layout-type-scada' ] + ] +); + export interface GridSettings { + layoutType?: LayoutType; backgroundColor?: string; columns?: number; minColumns?: number; @@ -62,7 +77,6 @@ export interface GridSettings { mobileRowHeight?: number; mobileDisplayLayoutFirst?: boolean; layoutDimension?: LayoutDimension; - isScada?: boolean; [key: string]: any; } @@ -78,7 +92,7 @@ export interface DashboardLayoutInfo { } export interface LayoutDimension { - type?: LayoutType; + type?: LayoutDimensionType; fixedWidth?: number; fixedLayout?: DashboardLayoutId; leftWidthPercentage?: number; @@ -86,7 +100,7 @@ export interface LayoutDimension { export declare type DashboardLayoutId = 'main' | 'right'; -export declare type LayoutType = 'percentage' | 'fixed'; +export declare type LayoutDimensionType = 'percentage' | 'fixed'; export declare type DashboardStateLayouts = {[key in DashboardLayoutId]?: DashboardLayout}; diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 097931232a..19c05bcc65 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1167,7 +1167,9 @@ "move-by": "Move by", "cols": "cols", "rows": "rows", - "scada-layout": "SCADA layout", + "layout": "Layout", + "layout-type-default": "Default", + "layout-type-scada": "SCADA", "layout-settings": "Layout settings", "columns-count": "Columns count", "columns-count-required": "Columns count is required.",