From b6e56d7a74dff9775bd2f274e61e0450910ca2b1 Mon Sep 17 00:00:00 2001 From: Mr-Mime <37423773+Mr-Mime@users.noreply.github.com> Date: Mon, 22 May 2023 11:07:40 +0200 Subject: [PATCH 01/12] Fix api documentation --- .../java/org/thingsboard/server/controller/UserController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/UserController.java b/application/src/main/java/org/thingsboard/server/controller/UserController.java index f79f5ee782..d49b2b04df 100644 --- a/application/src/main/java/org/thingsboard/server/controller/UserController.java +++ b/application/src/main/java/org/thingsboard/server/controller/UserController.java @@ -406,7 +406,7 @@ public class UserController extends BaseController { public void setUserCredentialsEnabled( @ApiParam(value = USER_ID_PARAM_DESCRIPTION) @PathVariable(USER_ID) String strUserId, - @ApiParam(value = "Disable (\"true\") or enable (\"false\") the credentials.", defaultValue = "true") + @ApiParam(value = "Enable (\"true\") or disable (\"false\") the credentials.", defaultValue = "true") @RequestParam(required = false, defaultValue = "true") boolean userCredentialsEnabled) throws ThingsboardException { checkParameter(USER_ID, strUserId); UserId userId = new UserId(toUUID(strUserId)); From b671c7671b0702223bd94f71fc30f42bafeabc42 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 22 May 2023 12:40:41 +0300 Subject: [PATCH 02/12] UI: Fixed tenant profile form --- .../components/entity/add-entity-dialog.component.html | 2 +- .../home/components/profile/tenant-profile.component.scss | 8 +++++++- .../home/components/queue/queue-form.component.html | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.html b/ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.html index 4abf910c1a..66dbbba2e3 100644 --- a/ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> -
+

{{ translations.add }}

diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.scss b/ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.scss index bd5dfa99ae..d052c97385 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.scss +++ b/ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.scss @@ -14,10 +14,16 @@ * limitations under the License. */ :host ::ng-deep { - .mat-mdc-form-field-infix { + .mat-mdc-floating-label { width: 100% !important; } + .mat-mdc-form-field-error { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + .mat-mdc-checkbox{ &.hinted-checkbox { .mdc-checkbox { diff --git a/ui-ngx/src/app/modules/home/components/queue/queue-form.component.html b/ui-ngx/src/app/modules/home/components/queue/queue-form.component.html index 8f8f509e94..9fee72fef4 100644 --- a/ui-ngx/src/app/modules/home/components/queue/queue-form.component.html +++ b/ui-ngx/src/app/modules/home/components/queue/queue-form.component.html @@ -40,7 +40,7 @@
- + {{ queueSubmitStrategyTypesMap.get(queueSubmitStrategyTypes[strategy]).label | translate }}
- + {{ queueProcessingStrategyTypesMap.get(queueProcessingStrategyTypes[strategy]).label | translate }} Date: Tue, 23 May 2023 18:31:02 +0300 Subject: [PATCH 03/12] UI: Refactoring tenant profile --- .../profile/tenant-profile.component.scss | 8 +-- ...enant-profile-configuration.component.html | 60 ++++++++++++------- .../assets/locale/locale.constant-en_US.json | 4 +- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.scss b/ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.scss index d052c97385..bd5dfa99ae 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.scss +++ b/ui-ngx/src/app/modules/home/components/profile/tenant-profile.component.scss @@ -14,16 +14,10 @@ * limitations under the License. */ :host ::ng-deep { - .mat-mdc-floating-label { + .mat-mdc-form-field-infix { width: 100% !important; } - .mat-mdc-form-field-error { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - .mat-mdc-checkbox{ &.hinted-checkbox { .mdc-checkbox { diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html index 0bbb6a5926..4e287a888c 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html @@ -21,7 +21,7 @@ {{ 'tenant-profile.entities' | translate }} tenant-profile.unlimited
- + tenant-profile.maximum-devices {{ 'tenant-profile.maximum-devices-range' | translate}} + - + tenant-profile.maximum-dashboards {{ 'tenant-profile.maximum-dashboards-range' | translate}} +
- + tenant-profile.maximum-assets {{ 'tenant-profile.maximum-assets-range' | translate}} + - + tenant-profile.maximum-users {{ 'tenant-profile.maximum-users-range' | translate}} +
@@ -80,7 +84,7 @@
- + tenant-profile.maximum-customers {{ 'tenant-profile.maximum-customers-range' | translate}} + - + tenant-profile.maximum-rule-chains {{ 'tenant-profile.maximum-rule-chains-range' | translate}} +
@@ -114,7 +120,7 @@ {{ 'tenant-profile.rule-engine' | translate }} tenant-profile.unlimited
- + tenant-profile.max-r-e-executions {{ 'tenant-profile.max-r-e-executions-range' | translate}} + - + tenant-profile.max-transport-messages {{ 'tenant-profile.max-transport-messages-required' | translate}} +
@@ -147,7 +155,7 @@
- + tenant-profile.max-j-s-executions {{ 'tenant-profile.max-j-s-executions-range' | translate}} + - + tenant-profile.max-transport-data-points {{ 'tenant-profile.max-transport-data-points-range' | translate}} +
- + tenant-profile.max-rule-node-executions-per-message {{ 'tenant-profile.max-rule-node-executions-per-message-range' | translate}} +
@@ -196,7 +207,7 @@ {{ 'tenant-profile.time-to-live' | translate }} tenant-profile.unlimited
- + tenant-profile.max-d-p-storage-days {{ 'tenant-profile.max-d-p-storage-days-range' | translate}} + - + tenant-profile.alarms-ttl-days {{ 'tenant-profile.alarms-ttl-days-days-range' | translate}} +
- + tenant-profile.default-storage-ttl-days {{ 'tenant-profile.default-storage-ttl-days-range' | translate}} + - + tenant-profile.rpc-ttl-days {{ 'tenant-profile.rpc-ttl-days-days-range' | translate}} +
@@ -254,7 +269,7 @@ {{ 'tenant-profile.alarms-and-notifications' | translate }} tenant-profile.unlimited
- + tenant-profile.max-emails {{ 'tenant-profile.max-emails-range' | translate}} + - + tenant-profile.max-created-alarms {{ 'tenant-profile.max-created-alarms-range' | translate}} +
- + tenant-profile.max-sms {{ 'tenant-profile.max-sms-range' | translate}} +
@@ -301,7 +319,7 @@ {{ 'tenant-profile.ota-files-in-bytes' | translate }} tenant-profile.unlimited
- + tenant-profile.maximum-resources-sum-data-size {{ 'tenant-profile.maximum-resources-sum-data-size-range' | translate}} + - + tenant-profile.maximum-ota-packages-sum-data-size {{ 'tenant-profile.maximum-ota-packages-sum-data-size-range' | translate}} +
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 bcaa4a183f..933462b06b 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3600,8 +3600,8 @@ "maximum-resources-sum-data-size-required": "Resource files sum size is required.", "maximum-resources-sum-data-size-range": "Resource files sum size can`t be negative", "maximum-ota-packages-sum-data-size": "OTA package files sum size", - "maximum-ota-package-sum-data-size-required": "OTA package files sum size is required.", - "maximum-ota-package-sum-data-size-range": "OTA package files sum size can`t be negative", + "maximum-ota-packages-sum-data-size-required": "OTA package files sum size is required.", + "maximum-ota-packages-sum-data-size-range": "OTA package files sum size can`t be negative", "rest-requests-for-tenant": "REST requests for tenant", "transport-tenant-telemetry-msg-rate-limit": "Transport tenant telemetry messages", "transport-tenant-telemetry-data-points-rate-limit": "Transport tenant telemetry data points", From a75cb391e1113956ed1950e02b4a9ec56c98266a Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Fri, 26 May 2023 09:46:04 +0300 Subject: [PATCH 04/12] UI: Fixed legend expantion panel --- .../lib/settings/chart/flot-widget-settings.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html index 4c83594e44..fd68f51a14 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html @@ -290,7 +290,7 @@
widgets.chart.custom-legend-settings - + From 41a3e6c22ebddaaa83161219c64a6f1eff93f5f0 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Fri, 26 May 2023 12:21:32 +0300 Subject: [PATCH 05/12] UI: Refactoring --- .../profile/queue/tenant-profile-queues.component.ts | 6 +++--- .../default-tenant-profile-configuration.component.html | 4 ++-- .../modules/home/components/queue/queue-form.component.html | 4 ++-- ui-ngx/src/assets/locale/locale.constant-en_US.json | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/profile/queue/tenant-profile-queues.component.ts b/ui-ngx/src/app/modules/home/components/profile/queue/tenant-profile-queues.component.ts index c3ff3ccc4c..8f510cfbda 100644 --- a/ui-ngx/src/app/modules/home/components/profile/queue/tenant-profile-queues.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/queue/tenant-profile-queues.component.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { Component, forwardRef, Input, OnDestroy } from '@angular/core'; +import { Component, forwardRef, Input, OnDestroy, OnInit } from '@angular/core'; import { AbstractControl, ControlValueAccessor, @@ -53,7 +53,7 @@ import { takeUntil } from 'rxjs/operators'; } ] }) -export class TenantProfileQueuesComponent implements ControlValueAccessor, Validator, OnDestroy { +export class TenantProfileQueuesComponent implements ControlValueAccessor, Validator, OnInit, OnDestroy { tenantProfileQueuesFormGroup: UntypedFormGroup; newQueue = false; @@ -115,7 +115,7 @@ export class TenantProfileQueuesComponent implements ControlValueAccessor, Valid } writeValue(queues: Array | null): void { - if (queues.length === this.queuesFormArray.length) { + if (queues?.length === this.queuesFormArray.length) { this.queuesFormArray.patchValue(queues, {emitEvent: false}); } else { const queuesControls: Array = []; diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html index 4e287a888c..0edb1b4b47 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html @@ -338,10 +338,10 @@ formControlName="maxOtaPackagesInBytes" type="number"> - {{ 'tenant-profile.maximum-ota-packages-sum-data-size-required' | translate}} + {{ 'tenant-profile.maximum-ota-package-sum-data-size-required' | translate}} - {{ 'tenant-profile.maximum-ota-packages-sum-data-size-range' | translate}} + {{ 'tenant-profile.maximum-ota-package-sum-data-size-range' | translate}} diff --git a/ui-ngx/src/app/modules/home/components/queue/queue-form.component.html b/ui-ngx/src/app/modules/home/components/queue/queue-form.component.html index 9fee72fef4..56b20d8aa8 100644 --- a/ui-ngx/src/app/modules/home/components/queue/queue-form.component.html +++ b/ui-ngx/src/app/modules/home/components/queue/queue-form.component.html @@ -37,7 +37,7 @@ -
+
@@ -75,7 +75,7 @@ -
+
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 933462b06b..bcaa4a183f 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3600,8 +3600,8 @@ "maximum-resources-sum-data-size-required": "Resource files sum size is required.", "maximum-resources-sum-data-size-range": "Resource files sum size can`t be negative", "maximum-ota-packages-sum-data-size": "OTA package files sum size", - "maximum-ota-packages-sum-data-size-required": "OTA package files sum size is required.", - "maximum-ota-packages-sum-data-size-range": "OTA package files sum size can`t be negative", + "maximum-ota-package-sum-data-size-required": "OTA package files sum size is required.", + "maximum-ota-package-sum-data-size-range": "OTA package files sum size can`t be negative", "rest-requests-for-tenant": "REST requests for tenant", "transport-tenant-telemetry-msg-rate-limit": "Transport tenant telemetry messages", "transport-tenant-telemetry-data-points-rate-limit": "Transport tenant telemetry data points", From 74897eea81e1c8a6ad210390d49a7b705915a2f3 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Fri, 26 May 2023 15:11:03 +0300 Subject: [PATCH 06/12] UI: Added help link for JWT security settings --- .../modules/home/pages/admin/security-settings.component.html | 2 ++ ui-ngx/src/app/shared/models/constants.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html b/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html index 130a1b2df0..ef29248767 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html +++ b/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html @@ -164,6 +164,8 @@ admin.jwt.security-settings + +
diff --git a/ui-ngx/src/app/shared/models/constants.ts b/ui-ngx/src/app/shared/models/constants.ts index 5d55717c07..8648973c72 100644 --- a/ui-ngx/src/app/shared/models/constants.ts +++ b/ui-ngx/src/app/shared/models/constants.ts @@ -166,6 +166,7 @@ export const HelpLinks = { templateNotifications: helpBaseUrl + '/docs/user-guide/notifications/#templates', recipientNotifications: helpBaseUrl + '/docs/user-guide/notifications/#recipients', ruleNotifications: helpBaseUrl + '/docs/user-guide/notifications/#rules', + jwtSecuritySettings: helpBaseUrl + '/docs/user-guide/ui/jwt-security-settings/', } }; From 4ec990ca8a1154a2743de4d469408f54cc8ffde5 Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Mon, 29 May 2023 17:49:07 +0300 Subject: [PATCH 07/12] Fix duplicates in device view --- dao/src/main/resources/sql/schema-views-and-functions.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dao/src/main/resources/sql/schema-views-and-functions.sql b/dao/src/main/resources/sql/schema-views-and-functions.sql index eaa09d78cc..3cd20ac0c4 100644 --- a/dao/src/main/resources/sql/schema-views-and-functions.sql +++ b/dao/src/main/resources/sql/schema-views-and-functions.sql @@ -23,7 +23,7 @@ SELECT d.* , COALESCE(da.bool_v, FALSE) as active FROM device d LEFT JOIN customer c ON c.id = d.customer_id - LEFT JOIN attribute_kv da ON da.entity_id = d.id and da.attribute_key = 'active'; + LEFT JOIN attribute_kv da ON da.entity_type = 'DEVICE' AND da.entity_id = d.id AND da.attribute_type = 'SERVER_SCOPE' AND da.attribute_key = 'active'; DROP VIEW IF EXISTS device_info_active_ts_view CASCADE; CREATE OR REPLACE VIEW device_info_active_ts_view AS From c863cf6c153d6a969fbfbe9520b1237d1934aab2 Mon Sep 17 00:00:00 2001 From: AndriiD Date: Fri, 26 May 2023 03:01:52 +0300 Subject: [PATCH 08/12] \changed ServiceType.valueOf to ServiceType.of --- .../server/controller/QueueController.java | 4 +- .../controller/BaseQueueControllerTest.java | 96 +++++++++++++++++++ .../queue/discovery/HashPartitionService.java | 4 +- 3 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 application/src/test/java/org/thingsboard/server/controller/BaseQueueControllerTest.java diff --git a/application/src/main/java/org/thingsboard/server/controller/QueueController.java b/application/src/main/java/org/thingsboard/server/controller/QueueController.java index 3ba1df8c2a..0e79ae7955 100644 --- a/application/src/main/java/org/thingsboard/server/controller/QueueController.java +++ b/application/src/main/java/org/thingsboard/server/controller/QueueController.java @@ -83,7 +83,7 @@ public class QueueController extends BaseController { @RequestParam(required = false) String sortOrder) throws ThingsboardException { checkParameter("serviceType", serviceType); PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); - ServiceType type = ServiceType.valueOf(serviceType); + ServiceType type = ServiceType.of(serviceType); switch (type) { case TB_RULE_ENGINE: return queueService.findQueuesByTenantId(getTenantId(), pageLink); @@ -136,7 +136,7 @@ public class QueueController extends BaseController { checkEntity(queue.getId(), queue, Resource.QUEUE); - ServiceType type = ServiceType.valueOf(serviceType); + ServiceType type = ServiceType.of(serviceType); switch (type) { case TB_RULE_ENGINE: queue.setTenantId(getTenantId()); diff --git a/application/src/test/java/org/thingsboard/server/controller/BaseQueueControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/BaseQueueControllerTest.java new file mode 100644 index 0000000000..465ec37bb9 --- /dev/null +++ b/application/src/test/java/org/thingsboard/server/controller/BaseQueueControllerTest.java @@ -0,0 +1,96 @@ +/** + * Copyright © 2016-2023 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.server.controller; + +import com.fasterxml.jackson.core.type.TypeReference; +import org.junit.Assert; +import org.junit.Test; +import org.thingsboard.server.common.data.id.TenantId; +import org.thingsboard.server.common.data.page.PageData; +import org.thingsboard.server.common.data.page.PageLink; +import org.thingsboard.server.common.data.queue.ProcessingStrategy; +import org.thingsboard.server.common.data.queue.ProcessingStrategyType; +import org.thingsboard.server.common.data.queue.Queue; +import org.thingsboard.server.common.data.queue.SubmitStrategy; +import org.thingsboard.server.common.data.queue.SubmitStrategyType; +import org.thingsboard.server.dao.service.DaoSqlTest; + +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@DaoSqlTest +public class BaseQueueControllerTest extends AbstractControllerTest { + + @Test + public void testQueueWithServiceTypeRE() throws Exception { + loginSysAdmin(); + + // create queue + Queue queue = new Queue(); + queue.setName("qwerty"); + queue.setTopic("tb_rule_engine.qwerty"); + queue.setPollInterval(25); + queue.setPartitions(10); + queue.setTenantId(TenantId.SYS_TENANT_ID); + queue.setConsumerPerPartition(false); + queue.setPackProcessingTimeout(2000); + SubmitStrategy submitStrategy = new SubmitStrategy(); + submitStrategy.setType(SubmitStrategyType.SEQUENTIAL_BY_ORIGINATOR); + queue.setSubmitStrategy(submitStrategy); + ProcessingStrategy processingStrategy = new ProcessingStrategy(); + processingStrategy.setType(ProcessingStrategyType.RETRY_ALL); + processingStrategy.setRetries(3); + processingStrategy.setFailurePercentage(0.7); + processingStrategy.setPauseBetweenRetries(3); + processingStrategy.setMaxPauseBetweenRetries(5); + queue.setProcessingStrategy(processingStrategy); + + // create queue + Queue queue2 = new Queue(); + queue2.setName("qwerty2"); + queue2.setTopic("tb_rule_engine.qwerty2"); + queue2.setPollInterval(25); + queue2.setPartitions(10); + queue2.setTenantId(TenantId.SYS_TENANT_ID); + queue2.setConsumerPerPartition(false); + queue2.setPackProcessingTimeout(2000); + submitStrategy.setType(SubmitStrategyType.SEQUENTIAL_BY_ORIGINATOR); + queue2.setSubmitStrategy(submitStrategy); + processingStrategy.setType(ProcessingStrategyType.RETRY_ALL); + processingStrategy.setRetries(3); + processingStrategy.setFailurePercentage(0.7); + processingStrategy.setPauseBetweenRetries(3); + processingStrategy.setMaxPauseBetweenRetries(5); + queue2.setProcessingStrategy(processingStrategy); + + Queue savedQueue = doPost("/api/queues?serviceType=" + "TB-RULE-ENGINE", queue, Queue.class); + Queue savedQueue2 = doPost("/api/queues?serviceType=" + "TB_RULE_ENGINE", queue2, Queue.class); + + PageLink pageLink = new PageLink(10); + PageData pageData; + pageData = doGetTypedWithPageLink("/api/queues?serviceType=TB-RULE-ENGINE&", new TypeReference<>() { + }, pageLink); + Assert.assertFalse(pageData.getData().isEmpty()); + doDelete("/api/queues/" + savedQueue.getUuidId()) + .andExpect(status().isOk()); + + pageData = doGetTypedWithPageLink("/api/queues?serviceType=TB_RULE_ENGINE&", new TypeReference<>() { + }, pageLink); + Assert.assertFalse(pageData.getData().isEmpty()); + doDelete("/api/queues/" + savedQueue2.getUuidId()) + .andExpect(status().isOk()); + } + +} diff --git a/common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java b/common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java index 08f2e849f8..14fb0369ee 100644 --- a/common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java +++ b/common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java @@ -326,7 +326,7 @@ public class HashPartitionService implements PartitionService { final Map> currentMap = new HashMap<>(); services.forEach(serviceInfo -> { for (String serviceTypeStr : serviceInfo.getServiceTypesList()) { - ServiceType serviceType = ServiceType.valueOf(serviceTypeStr.toUpperCase()); + ServiceType serviceType = ServiceType.of(serviceTypeStr); if (ServiceType.TB_RULE_ENGINE.equals(serviceType)) { partitionTopicsMap.keySet().forEach(queueKey -> currentMap.computeIfAbsent(queueKey, key -> new ArrayList<>()).add(serviceInfo)); @@ -389,7 +389,7 @@ public class HashPartitionService implements PartitionService { private void addNode(Map> queueServiceList, ServiceInfo instance) { for (String serviceTypeStr : instance.getServiceTypesList()) { - ServiceType serviceType = ServiceType.valueOf(serviceTypeStr.toUpperCase()); + ServiceType serviceType = ServiceType.of(serviceTypeStr); if (ServiceType.TB_RULE_ENGINE.equals(serviceType)) { partitionTopicsMap.keySet().forEach(key -> { if (key.getType().equals(ServiceType.TB_RULE_ENGINE)) { From b37a708f40c8fb4e3ede8856dd9bbe102b728a44 Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Tue, 30 May 2023 12:01:32 +0300 Subject: [PATCH 09/12] Fix invalid return code for legacy 3.x MQTT clients --- .../server/transport/mqtt/util/ReturnCodeResolver.java | 1 - 1 file changed, 1 deletion(-) diff --git a/common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/util/ReturnCodeResolver.java b/common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/util/ReturnCodeResolver.java index 5c97286a2d..e4b8e8fc2f 100644 --- a/common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/util/ReturnCodeResolver.java +++ b/common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/util/ReturnCodeResolver.java @@ -27,7 +27,6 @@ public class ReturnCodeResolver { if (!MqttVersion.MQTT_5.equals(mqttVersion) && !ReturnCode.SUCCESS.equals(returnCode)) { switch (returnCode) { case BAD_USERNAME_OR_PASSWORD: - return MqttConnectReturnCode.CONNECTION_REFUSED_BAD_USER_NAME_OR_PASSWORD; case NOT_AUTHORIZED_5: return MqttConnectReturnCode.CONNECTION_REFUSED_NOT_AUTHORIZED; case SERVER_UNAVAILABLE_5: From a8efae06c50ebede125c268b13be774b3f282985 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Tue, 30 May 2023 13:00:08 +0300 Subject: [PATCH 10/12] UI: Fixed infinite loading alarm table --- .../src/app/modules/home/components/alarm/alarm-table-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/alarm/alarm-table-config.ts b/ui-ngx/src/app/modules/home/components/alarm/alarm-table-config.ts index 41468d096f..6f46d3b1bb 100644 --- a/ui-ngx/src/app/modules/home/components/alarm/alarm-table-config.ts +++ b/ui-ngx/src/app/modules/home/components/alarm/alarm-table-config.ts @@ -86,7 +86,7 @@ export class AlarmTableConfig extends EntityTableConfig private utilsService: UtilsService, pageMode = false) { super(); - this.loadDataOnInit = false; + this.loadDataOnInit = true; this.tableTitle = ''; this.useTimePageLink = true; this.forAllTimeEnabled = true; From 79e3b4351a88af649257d17fa36345ea992be5f0 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Tue, 30 May 2023 13:31:56 +0300 Subject: [PATCH 11/12] UI: Refactoring --- .../src/app/modules/home/components/alarm/alarm-table-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/alarm/alarm-table-config.ts b/ui-ngx/src/app/modules/home/components/alarm/alarm-table-config.ts index 6f46d3b1bb..28e64738a8 100644 --- a/ui-ngx/src/app/modules/home/components/alarm/alarm-table-config.ts +++ b/ui-ngx/src/app/modules/home/components/alarm/alarm-table-config.ts @@ -86,7 +86,7 @@ export class AlarmTableConfig extends EntityTableConfig private utilsService: UtilsService, pageMode = false) { super(); - this.loadDataOnInit = true; + this.loadDataOnInit = pageMode; this.tableTitle = ''; this.useTimePageLink = true; this.forAllTimeEnabled = true; From 29602c208e82064588970e5b04d7b9e89d1392f3 Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Tue, 30 May 2023 14:51:54 +0300 Subject: [PATCH 12/12] Fix MQTT connection tests according to specification --- .../mqtt/mqttv3/client/AbstractMqttClientConnectionTest.java | 2 +- .../mqtt/mqttv3/credentials/BasicMqttCredentialsTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/client/AbstractMqttClientConnectionTest.java b/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/client/AbstractMqttClientConnectionTest.java index 116459e5e6..8c567e402c 100644 --- a/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/client/AbstractMqttClientConnectionTest.java +++ b/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/client/AbstractMqttClientConnectionTest.java @@ -34,7 +34,7 @@ public abstract class AbstractMqttClientConnectionTest extends AbstractMqttInteg try { client.connectAndWait("wrongAccessToken"); } catch (MqttException e) { - Assert.assertEquals(MqttException.REASON_CODE_FAILED_AUTHENTICATION, e.getReasonCode()); + Assert.assertEquals(MqttException.REASON_CODE_NOT_AUTHORIZED, e.getReasonCode()); } } diff --git a/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/credentials/BasicMqttCredentialsTest.java b/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/credentials/BasicMqttCredentialsTest.java index 87337545fc..8f0dc24d7c 100644 --- a/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/credentials/BasicMqttCredentialsTest.java +++ b/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/credentials/BasicMqttCredentialsTest.java @@ -124,7 +124,7 @@ public class BasicMqttCredentialsTest extends AbstractMqttIntegrationTest { mqttTestClient.connectAndWait(USER_NAME3, "WRONG PASSWORD"); Assert.fail(); // This should not happens, because we have a wrong password } catch (MqttException e) { - Assert.assertEquals(4, e.getReasonCode()); // 4 - Reason code for bad username or password in MQTT v3 + Assert.assertEquals(5, e.getReasonCode()); // 4 - Reason code not authorized in MQTT v3 } Assertions.assertThrows(MqttException.class, () -> { testTelemetryIsNotDelivered(clientIdAndUserNameAndPasswordDevice3, mqttTestClient);