From aff4f7bacb02b5e76dca98df11b0aa49394a0af1 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 10 Jun 2024 12:37:24 +0300 Subject: [PATCH 01/30] UI: Fixed colors for neon gauge --- .../home/components/widget/lib/canvas-digital-gauge.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/canvas-digital-gauge.ts b/ui-ngx/src/app/modules/home/components/widget/lib/canvas-digital-gauge.ts index 4a7e019a48..09dba7e9c5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/canvas-digital-gauge.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/canvas-digital-gauge.ts @@ -238,10 +238,10 @@ export class CanvasDigitalGauge extends BaseGauge { } if (options.neonGlowBrightness) { - options.neonColorTitle = tinycolor(options.colorTitle).brighten(options.neonGlowBrightness).toHexString(); - options.neonColorLabel = tinycolor(options.colorLabel).brighten(options.neonGlowBrightness).toHexString(); - options.neonColorValue = tinycolor(options.colorValue).brighten(options.neonGlowBrightness).toHexString(); - options.neonColorMinMax = tinycolor(options.colorMinMax).brighten(options.neonGlowBrightness).toHexString(); + options.neonColorTitle = tinycolor(options.colorTitle).brighten(options.neonGlowBrightness).toRgbString(); + options.neonColorLabel = tinycolor(options.colorLabel).brighten(options.neonGlowBrightness).toRgbString(); + options.neonColorValue = tinycolor(options.colorValue).brighten(options.neonGlowBrightness).toRgbString(); + options.neonColorMinMax = tinycolor(options.colorMinMax).brighten(options.neonGlowBrightness).toRgbString(); } return options; From 02dc49fd3a34e93f8110a2c8a34c92163e6d5186 Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Mon, 10 Jun 2024 13:22:10 +0300 Subject: [PATCH 02/30] Fix tenant not found error for notification rules --- .../rule/cache/DefaultNotificationRulesCache.java | 11 +++++++++-- .../server/dao/tenant/TenantServiceImpl.java | 5 ++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/notification/rule/cache/DefaultNotificationRulesCache.java b/application/src/main/java/org/thingsboard/server/service/notification/rule/cache/DefaultNotificationRulesCache.java index bf2946313d..fdf795e34b 100644 --- a/application/src/main/java/org/thingsboard/server/service/notification/rule/cache/DefaultNotificationRulesCache.java +++ b/application/src/main/java/org/thingsboard/server/service/notification/rule/cache/DefaultNotificationRulesCache.java @@ -17,6 +17,7 @@ package org.thingsboard.server.service.notification.rule.cache; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; +import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -29,7 +30,6 @@ import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent; import org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg; import org.thingsboard.server.dao.notification.NotificationRuleService; -import jakarta.annotation.PostConstruct; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -71,7 +71,14 @@ public class DefaultNotificationRulesCache implements NotificationRulesCache { if (event.getEvent() == ComponentLifecycleEvent.DELETED) { lock.writeLock().lock(); // locking in case rules for tenant are fetched while evicting try { - evict(event.getTenantId()); + for (var triggerType : NotificationRuleTriggerType.values()) { + String key = key(event.getTenantId(), triggerType); + /* + * temporarily putting empty value because right after tenant deletion + * the rules are still in the db, we don't want them to be fetched + * */ + cache.put(key, Collections.emptyList()); + } } finally { lock.writeLock().unlock(); } diff --git a/dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java index b17cef53db..e86abdbb8b 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java @@ -39,8 +39,6 @@ import org.thingsboard.server.dao.entity.AbstractCachedEntityService; import org.thingsboard.server.dao.eventsourcing.DeleteEntityEvent; import org.thingsboard.server.dao.eventsourcing.SaveEntityEvent; import org.thingsboard.server.dao.mobile.MobileAppSettingsService; -import org.thingsboard.server.dao.notification.NotificationRequestService; -import org.thingsboard.server.dao.notification.NotificationRuleService; import org.thingsboard.server.dao.notification.NotificationSettingsService; import org.thingsboard.server.dao.service.PaginatedRemover; import org.thingsboard.server.dao.service.Validator; @@ -168,8 +166,10 @@ public class TenantServiceImpl extends AbstractCachedEntityService Date: Mon, 10 Jun 2024 16:44:54 +0300 Subject: [PATCH 03/30] UI: fixed error on save relation qeury alias with empty relation filter, not option disabled if relation type is empty --- .../home/components/alias/entity-alias-dialog.component.ts | 2 +- .../home/components/relation/relation-filters.component.html | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/alias/entity-alias-dialog.component.ts b/ui-ngx/src/app/modules/home/components/alias/entity-alias-dialog.component.ts index 21d90e0c12..ac25981f6e 100644 --- a/ui-ngx/src/app/modules/home/components/alias/entity-alias-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/alias/entity-alias-dialog.component.ts @@ -145,7 +145,7 @@ export class EntityAliasDialogComponent extends DialogComponent self.findIndex(v => v.relationType === value.relationType && isEqual(v.entityTypes, value.entityTypes)) === index && - (value.relationType || value.entityTypes.length) + (value.relationType || value.entityTypes?.length) ); } if (this.alias.filter.type) { diff --git a/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.html b/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.html index 055b5df22e..1d6fdb7ea1 100644 --- a/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.html +++ b/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.html @@ -27,7 +27,10 @@
- {{ 'relation.not' | translate}} + + {{ 'relation.not' | translate}} + Date: Mon, 10 Jun 2024 17:25:09 +0300 Subject: [PATCH 04/30] UI: set value of not option to false if relation type cleared --- .../relation/relation-filters.component.html | 5 +---- .../relation/relation-filters.component.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.html b/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.html index 1d6fdb7ea1..6973a6a32d 100644 --- a/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.html +++ b/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.html @@ -27,10 +27,7 @@
- - {{ 'relation.not' | translate}} - + {{ 'relation.not' | translate }} { + if (value) { + formGroup.get('negate').enable({emitEvent: false}); + } else { + formGroup.get('negate').setValue(false, {emitEvent:false}); + formGroup.get('negate').disable({emitEvent: false}); + } + }); } return formGroup; } From 473681c343f61a0b10733571dde31db2f4a7229f Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Mon, 10 Jun 2024 17:59:35 +0300 Subject: [PATCH 05/30] Don't unassign deleted user alarms on tenant deletion --- .../server/dao/eventsourcing/ActionCause.java | 20 +++++++++++++++++++ .../dao/eventsourcing/DeleteEntityEvent.java | 4 +++- .../dao/housekeeper/CleanUpService.java | 3 ++- .../server/dao/user/UserServiceImpl.java | 11 ++++++++-- 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 dao/src/main/java/org/thingsboard/server/dao/eventsourcing/ActionCause.java diff --git a/dao/src/main/java/org/thingsboard/server/dao/eventsourcing/ActionCause.java b/dao/src/main/java/org/thingsboard/server/dao/eventsourcing/ActionCause.java new file mode 100644 index 0000000000..6b03173f31 --- /dev/null +++ b/dao/src/main/java/org/thingsboard/server/dao/eventsourcing/ActionCause.java @@ -0,0 +1,20 @@ +/** + * Copyright © 2016-2024 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.dao.eventsourcing; + +public enum ActionCause { + TENANT_DELETION +} diff --git a/dao/src/main/java/org/thingsboard/server/dao/eventsourcing/DeleteEntityEvent.java b/dao/src/main/java/org/thingsboard/server/dao/eventsourcing/DeleteEntityEvent.java index fbae8541e3..016c0dc5ff 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/eventsourcing/DeleteEntityEvent.java +++ b/dao/src/main/java/org/thingsboard/server/dao/eventsourcing/DeleteEntityEvent.java @@ -17,18 +17,20 @@ package org.thingsboard.server.dao.eventsourcing; import lombok.Builder; import lombok.Data; -import org.thingsboard.server.common.data.id.EdgeId; import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.TenantId; @Builder @Data public class DeleteEntityEvent { + private final TenantId tenantId; private final EntityId entityId; private final T entity; private final String body; + private final ActionCause cause; @Builder.Default private final long ts = System.currentTimeMillis(); + } diff --git a/dao/src/main/java/org/thingsboard/server/dao/housekeeper/CleanUpService.java b/dao/src/main/java/org/thingsboard/server/dao/housekeeper/CleanUpService.java index d64e6ea536..27205a74c1 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/housekeeper/CleanUpService.java +++ b/dao/src/main/java/org/thingsboard/server/dao/housekeeper/CleanUpService.java @@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.housekeeper.HousekeeperTask; import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.msg.housekeeper.HousekeeperClient; +import org.thingsboard.server.dao.eventsourcing.ActionCause; import org.thingsboard.server.dao.eventsourcing.DeleteEntityEvent; import org.thingsboard.server.dao.relation.RelationService; @@ -59,7 +60,7 @@ public class CleanUpService { if (!skippedEntities.contains(entityType)) { cleanUpRelatedData(tenantId, entityId); } - if (entityType == EntityType.USER) { + if (entityType == EntityType.USER && event.getCause() != ActionCause.TENANT_DELETION) { submitTask(HousekeeperTask.unassignAlarms((User) event.getEntity())); } } catch (Throwable e) { diff --git a/dao/src/main/java/org/thingsboard/server/dao/user/UserServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/user/UserServiceImpl.java index 61cd9f20dd..34602d81b3 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/user/UserServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/user/UserServiceImpl.java @@ -53,6 +53,7 @@ import org.thingsboard.server.common.data.settings.UserSettings; import org.thingsboard.server.common.data.settings.UserSettingsType; import org.thingsboard.server.dao.entity.AbstractCachedEntityService; import org.thingsboard.server.dao.entity.EntityCountService; +import org.thingsboard.server.dao.eventsourcing.ActionCause; import org.thingsboard.server.dao.eventsourcing.ActionEntityEvent; import org.thingsboard.server.dao.eventsourcing.DeleteEntityEvent; import org.thingsboard.server.dao.eventsourcing.SaveEntityEvent; @@ -293,6 +294,10 @@ public class UserServiceImpl extends AbstractCachedEntityService Date: Tue, 11 Jun 2024 11:36:45 +0300 Subject: [PATCH 06/30] UI: removed negate option set to false on relation types clear of relation filters --- .../home/components/relation/relation-filters.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.ts b/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.ts index 5bbce12bec..66d188248a 100644 --- a/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.ts +++ b/ui-ngx/src/app/modules/home/components/relation/relation-filters.component.ts @@ -135,7 +135,6 @@ export class RelationFiltersComponent extends PageComponent implements ControlVa if (value) { formGroup.get('negate').enable({emitEvent: false}); } else { - formGroup.get('negate').setValue(false, {emitEvent:false}); formGroup.get('negate').disable({emitEvent: false}); } }); From a9a80db4b734ead238c145b993c4519a6a3d338b Mon Sep 17 00:00:00 2001 From: dashevchenko Date: Tue, 11 Jun 2024 12:38:18 +0300 Subject: [PATCH 07/30] implemented entity field "name" for queue stats entity --- .../server/controller/EntityQueryControllerTest.java | 10 +++++++--- .../server/dao/sql/query/EntityKeyMapping.java | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/controller/EntityQueryControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/EntityQueryControllerTest.java index 50c82260eb..eb4f6fa083 100644 --- a/application/src/test/java/org/thingsboard/server/controller/EntityQueryControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/EntityQueryControllerTest.java @@ -691,7 +691,7 @@ public class EntityQueryControllerTest extends AbstractControllerTest { new EntityKey(EntityKeyType.ENTITY_FIELD, "queueName"), EntityDataSortOrder.Direction.ASC ); EntityDataPageLink pageLink = new EntityDataPageLink(10, 0, null, sortOrder); - List entityFields = Arrays.asList(new EntityKey(EntityKeyType.ENTITY_FIELD, "queueName"), + List entityFields = Arrays.asList(new EntityKey(EntityKeyType.ENTITY_FIELD, "name"), new EntityKey(EntityKeyType.ENTITY_FIELD, "queueName"), new EntityKey(EntityKeyType.ENTITY_FIELD, "serviceId")); EntityDataQuery query = new EntityDataQuery(entityTypeFilter, pageLink, entityFields, null, null); @@ -705,8 +705,12 @@ public class EntityQueryControllerTest extends AbstractControllerTest { Assert.assertTrue(data.hasNext()); Assert.assertEquals(10, data.getData().size()); data.getData().forEach(entityData -> { - assertThat(entityData.getLatest().get(EntityKeyType.ENTITY_FIELD).get("queueName")).asString().isNotBlank(); - assertThat(entityData.getLatest().get(EntityKeyType.ENTITY_FIELD).get("serviceId")).asString().isNotBlank(); + String queueName = entityData.getLatest().get(EntityKeyType.ENTITY_FIELD).get("queueName").getValue(); + String serviceId = entityData.getLatest().get(EntityKeyType.ENTITY_FIELD).get("serviceId").getValue(); + assertThat(queueName).isNotBlank(); + assertThat(serviceId).isNotBlank(); + assertThat(entityData.getLatest().get(EntityKeyType.ENTITY_FIELD).get("name").getValue()).isEqualTo(queueName + "_" + serviceId); + }); EntityCountQuery countQuery = new EntityCountQuery(entityTypeFilter); diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/query/EntityKeyMapping.java b/dao/src/main/java/org/thingsboard/server/dao/sql/query/EntityKeyMapping.java index c125639def..599ac3d918 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/query/EntityKeyMapping.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/query/EntityKeyMapping.java @@ -89,10 +89,12 @@ public class EntityKeyMapping { public static final String OWNER_TYPE_SELECT_QUERY = "case when e.customer_id = '" + NULL_UUID + "' " + "then 'TENANT' " + "else 'CUSTOMER' end"; + public static final String QUEUE_STATS_NAME_QUERY = "concat(e.queue_name, '_', e.service_id)"; public static final Map ownerPropertiesFunctions = Map.of( OWNER_NAME, OWNER_NAME_SELECT_QUERY, OWNER_TYPE, OWNER_TYPE_SELECT_QUERY ); + public static final Map queueStatsPropertiesFunctions = Map.of(NAME, QUEUE_STATS_NAME_QUERY); public static final List typedEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, ADDITIONAL_INFO); public static final List widgetEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME); @@ -166,6 +168,7 @@ public class EntityKeyMapping { propertiesFunctions.put(EntityType.ENTITY_VIEW, ownerPropertiesFunctions); propertiesFunctions.put(EntityType.USER, ownerPropertiesFunctions); propertiesFunctions.put(EntityType.DASHBOARD, ownerPropertiesFunctions); + propertiesFunctions.put(EntityType.QUEUE_STATS, queueStatsPropertiesFunctions); Map userEntityAliases = new HashMap<>(); userEntityAliases.put(TITLE, EMAIL); From 796bab6aa9b33939af2f818fb09dcc564124f523 Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Tue, 11 Jun 2024 12:57:16 +0300 Subject: [PATCH 08/30] Fix sysadmin notification being sent with tenant mail sender --- .../service/notification/channels/EmailNotificationChannel.java | 2 +- .../service/notification/channels/SmsNotificationChannel.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/notification/channels/EmailNotificationChannel.java b/application/src/main/java/org/thingsboard/server/service/notification/channels/EmailNotificationChannel.java index c7a3d83d8f..2f01e26424 100644 --- a/application/src/main/java/org/thingsboard/server/service/notification/channels/EmailNotificationChannel.java +++ b/application/src/main/java/org/thingsboard/server/service/notification/channels/EmailNotificationChannel.java @@ -33,7 +33,7 @@ public class EmailNotificationChannel implements NotificationChannel Date: Tue, 11 Jun 2024 15:03:45 +0300 Subject: [PATCH 09/30] fixed request param arrays in swagger --- .../server/controller/AlarmController.java | 13 +++++++------ .../server/controller/AssetController.java | 3 ++- .../controller/ComponentDescriptorController.java | 3 ++- .../server/controller/DashboardController.java | 7 ++++--- .../server/controller/DeviceController.java | 3 ++- .../server/controller/EdgeController.java | 3 ++- .../server/controller/QueueStatsController.java | 3 ++- .../server/controller/TbResourceController.java | 3 ++- .../server/controller/WidgetTypeController.java | 5 +++-- 9 files changed, 26 insertions(+), 17 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/AlarmController.java b/application/src/main/java/org/thingsboard/server/controller/AlarmController.java index e78313f6d8..535700335d 100644 --- a/application/src/main/java/org/thingsboard/server/controller/AlarmController.java +++ b/application/src/main/java/org/thingsboard/server/controller/AlarmController.java @@ -16,6 +16,7 @@ package org.thingsboard.server.controller; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -350,11 +351,11 @@ public class AlarmController extends BaseController { @PathVariable(ENTITY_TYPE) String strEntityType, @Parameter(description = ENTITY_ID_PARAM_DESCRIPTION, required = true) @PathVariable(ENTITY_ID) String strEntityId, - @Parameter(description = ALARM_QUERY_SEARCH_STATUS_ARRAY_DESCRIPTION, schema = @Schema(allowableValues = {"ANY", "ACTIVE", "CLEARED", "ACK", "UNACK"})) + @Parameter(description = ALARM_QUERY_SEARCH_STATUS_ARRAY_DESCRIPTION, array = @ArraySchema(schema = @Schema(type = "string", allowableValues = {"ANY", "ACTIVE", "CLEARED", "ACK", "UNACK"}))) @RequestParam(required = false) String[] statusList, - @Parameter(description = ALARM_QUERY_SEVERITY_ARRAY_DESCRIPTION, schema = @Schema(allowableValues = {"CRITICAL", "MAJOR", "MINOR", "WARNING", "INDETERMINATE"})) + @Parameter(description = ALARM_QUERY_SEVERITY_ARRAY_DESCRIPTION, array = @ArraySchema(schema = @Schema(type = "string", allowableValues = {"CRITICAL", "MAJOR", "MINOR", "WARNING", "INDETERMINATE"}))) @RequestParam(required = false) String[] severityList, - @Parameter(description = ALARM_QUERY_TYPE_ARRAY_DESCRIPTION) + @Parameter(description = ALARM_QUERY_TYPE_ARRAY_DESCRIPTION, array = @ArraySchema(schema = @Schema(type = "string"))) @RequestParam(required = false) String[] typeList, @Parameter(description = ALARM_QUERY_ASSIGNEE_DESCRIPTION) @RequestParam(required = false) String assigneeId, @@ -412,11 +413,11 @@ public class AlarmController extends BaseController { @RequestMapping(value = "/v2/alarms", method = RequestMethod.GET) @ResponseBody public PageData getAllAlarmsV2( - @Parameter(description = ALARM_QUERY_SEARCH_STATUS_ARRAY_DESCRIPTION, schema = @Schema(allowableValues = {"ANY", "ACTIVE", "CLEARED", "ACK", "UNACK"})) + @Parameter(description = ALARM_QUERY_SEARCH_STATUS_ARRAY_DESCRIPTION, array = @ArraySchema(schema = @Schema(type = "string", allowableValues = {"ANY", "ACTIVE", "CLEARED", "ACK", "UNACK"}))) @RequestParam(required = false) String[] statusList, - @Parameter(description = ALARM_QUERY_SEVERITY_ARRAY_DESCRIPTION, schema = @Schema(allowableValues = {"CRITICAL", "MAJOR", "MINOR", "WARNING", "INDETERMINATE"})) + @Parameter(description = ALARM_QUERY_SEVERITY_ARRAY_DESCRIPTION, array = @ArraySchema(schema = @Schema(type = "string", allowableValues = {"CRITICAL", "MAJOR", "MINOR", "WARNING", "INDETERMINATE"}))) @RequestParam(required = false) String[] severityList, - @Parameter(description = ALARM_QUERY_TYPE_ARRAY_DESCRIPTION) + @Parameter(description = ALARM_QUERY_TYPE_ARRAY_DESCRIPTION, array = @ArraySchema(schema = @Schema(type = "string"))) @RequestParam(required = false) String[] typeList, @Parameter(description = ALARM_QUERY_ASSIGNEE_DESCRIPTION) @RequestParam(required = false) String assigneeId, diff --git a/application/src/main/java/org/thingsboard/server/controller/AssetController.java b/application/src/main/java/org/thingsboard/server/controller/AssetController.java index 8c03d34e8e..7b4621db28 100644 --- a/application/src/main/java/org/thingsboard/server/controller/AssetController.java +++ b/application/src/main/java/org/thingsboard/server/controller/AssetController.java @@ -17,6 +17,7 @@ package org.thingsboard.server.controller; import com.google.common.util.concurrent.ListenableFuture; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -354,7 +355,7 @@ public class AssetController extends BaseController { @RequestMapping(value = "/assets", params = {"assetIds"}, method = RequestMethod.GET) @ResponseBody public List getAssetsByIds( - @Parameter(description = "A list of assets ids, separated by comma ','") + @Parameter(description = "A list of assets ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string"))) @RequestParam("assetIds") String[] strAssetIds) throws ThingsboardException, ExecutionException, InterruptedException { checkArrayParameter("assetIds", strAssetIds); SecurityUser user = getCurrentUser(); diff --git a/application/src/main/java/org/thingsboard/server/controller/ComponentDescriptorController.java b/application/src/main/java/org/thingsboard/server/controller/ComponentDescriptorController.java index 58b9296379..eeb67d7ae8 100644 --- a/application/src/main/java/org/thingsboard/server/controller/ComponentDescriptorController.java +++ b/application/src/main/java/org/thingsboard/server/controller/ComponentDescriptorController.java @@ -16,6 +16,7 @@ package org.thingsboard.server.controller; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PathVariable; @@ -83,7 +84,7 @@ public class ComponentDescriptorController extends BaseController { @RequestMapping(value = "/components", params = {"componentTypes"}, method = RequestMethod.GET) @ResponseBody public List getComponentDescriptorsByTypes( - @Parameter(description = "List of types of the Rule Nodes, (ENRICHMENT, FILTER, TRANSFORMATION, ACTION or EXTERNAL)", required = true) + @Parameter(description = "List of types of the Rule Nodes, (ENRICHMENT, FILTER, TRANSFORMATION, ACTION or EXTERNAL)", array = @ArraySchema(schema = @Schema(type = "string")), required = true) @RequestParam("componentTypes") String[] strComponentTypes, @Parameter(description = "Type of the Rule Chain", schema = @Schema(allowableValues = {"CORE", "EDGE"})) @RequestParam(value = "ruleChainType", required = false) String strRuleChainType) throws ThingsboardException { diff --git a/application/src/main/java/org/thingsboard/server/controller/DashboardController.java b/application/src/main/java/org/thingsboard/server/controller/DashboardController.java index 013575361d..37b5b8b3b1 100644 --- a/application/src/main/java/org/thingsboard/server/controller/DashboardController.java +++ b/application/src/main/java/org/thingsboard/server/controller/DashboardController.java @@ -18,6 +18,7 @@ package org.thingsboard.server.controller; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; @@ -249,7 +250,7 @@ public class DashboardController extends BaseController { public Dashboard updateDashboardCustomers( @Parameter(description = DASHBOARD_ID_PARAM_DESCRIPTION) @PathVariable(DASHBOARD_ID) String strDashboardId, - @Parameter(description = "JSON array with the list of customer ids, or empty to remove all customers") + @Parameter(description = "JSON array with the list of customer ids, or empty to remove all customers", array = @ArraySchema(schema = @Schema(type = "string"))) @RequestBody(required = false) String[] strCustomerIds) throws ThingsboardException { checkParameter(DASHBOARD_ID, strDashboardId); DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); @@ -267,7 +268,7 @@ public class DashboardController extends BaseController { public Dashboard addDashboardCustomers( @Parameter(description = DASHBOARD_ID_PARAM_DESCRIPTION) @PathVariable(DASHBOARD_ID) String strDashboardId, - @Parameter(description = "JSON array with the list of customer ids") + @Parameter(description = "JSON array with the list of customer ids", array = @ArraySchema(schema = @Schema(type = "string"))) @RequestBody String[] strCustomerIds) throws ThingsboardException { checkParameter(DASHBOARD_ID, strDashboardId); DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); @@ -285,7 +286,7 @@ public class DashboardController extends BaseController { public Dashboard removeDashboardCustomers( @Parameter(description = DASHBOARD_ID_PARAM_DESCRIPTION) @PathVariable(DASHBOARD_ID) String strDashboardId, - @Parameter(description = "JSON array with the list of customer ids") + @Parameter(description = "JSON array with the list of customer ids", array = @ArraySchema(schema = @Schema(type = "string"))) @RequestBody String[] strCustomerIds) throws ThingsboardException { checkParameter(DASHBOARD_ID, strDashboardId); DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); diff --git a/application/src/main/java/org/thingsboard/server/controller/DeviceController.java b/application/src/main/java/org/thingsboard/server/controller/DeviceController.java index fedbd48503..416991a996 100644 --- a/application/src/main/java/org/thingsboard/server/controller/DeviceController.java +++ b/application/src/main/java/org/thingsboard/server/controller/DeviceController.java @@ -20,6 +20,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -488,7 +489,7 @@ public class DeviceController extends BaseController { @RequestMapping(value = "/devices", params = {"deviceIds"}, method = RequestMethod.GET) @ResponseBody public List getDevicesByIds( - @Parameter(description = "A list of devices ids, separated by comma ','") + @Parameter(description = "A list of devices ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string"))) @RequestParam("deviceIds") String[] strDeviceIds) throws ThingsboardException, ExecutionException, InterruptedException { checkArrayParameter("deviceIds", strDeviceIds); SecurityUser user = getCurrentUser(); diff --git a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java index 3042b8f2a1..030cb902a6 100644 --- a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java +++ b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java @@ -17,6 +17,7 @@ package org.thingsboard.server.controller; import com.google.common.util.concurrent.ListenableFuture; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -426,7 +427,7 @@ public class EdgeController extends BaseController { @RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET) @ResponseBody public List getEdgesByIds( - @Parameter(description = "A list of edges ids, separated by comma ','", required = true) + @Parameter(description = "A list of edges ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true) @RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException, ExecutionException, InterruptedException { checkArrayParameter("edgeIds", strEdgeIds); SecurityUser user = getCurrentUser(); diff --git a/application/src/main/java/org/thingsboard/server/controller/QueueStatsController.java b/application/src/main/java/org/thingsboard/server/controller/QueueStatsController.java index 912a1ca7b2..eee35ee973 100644 --- a/application/src/main/java/org/thingsboard/server/controller/QueueStatsController.java +++ b/application/src/main/java/org/thingsboard/server/controller/QueueStatsController.java @@ -16,6 +16,7 @@ package org.thingsboard.server.controller; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; @@ -89,7 +90,7 @@ public class QueueStatsController extends BaseController { @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") @GetMapping(value = "/queueStats", params = {"queueStatsIds"}) public List getQueueStatsByIds( - @Parameter(description = "A list of queue stats ids, separated by comma ','", required = true) + @Parameter(description = "A list of queue stats ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true) @RequestParam("queueStatsIds") String[] strQueueStatsIds) throws ThingsboardException { checkArrayParameter("queueStatsIds", strQueueStatsIds); List queueStatsIds = new ArrayList<>(); diff --git a/application/src/main/java/org/thingsboard/server/controller/TbResourceController.java b/application/src/main/java/org/thingsboard/server/controller/TbResourceController.java index e646c34e4f..74bc087abf 100644 --- a/application/src/main/java/org/thingsboard/server/controller/TbResourceController.java +++ b/application/src/main/java/org/thingsboard/server/controller/TbResourceController.java @@ -16,6 +16,7 @@ package org.thingsboard.server.controller; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -272,7 +273,7 @@ public class TbResourceController extends BaseController { @RequestParam String sortOrder, @Parameter(description = SORT_PROPERTY_DESCRIPTION, schema = @Schema(allowableValues = {"id", "name"}, requiredMode = Schema.RequiredMode.REQUIRED)) @RequestParam String sortProperty, - @Parameter(description = "LwM2M Object ids.", required = true) + @Parameter(description = "LwM2M Object ids.", array = @ArraySchema(schema = @Schema(type = "string")), required = true) @RequestParam(required = false) String[] objectIds) throws ThingsboardException { return checkNotNull(tbResourceService.findLwM2mObject(getTenantId(), sortOrder, sortProperty, objectIds)); } diff --git a/application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java b/application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java index f2e3f9192f..4c48dbd434 100644 --- a/application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java +++ b/application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java @@ -16,6 +16,7 @@ package org.thingsboard.server.controller; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -185,7 +186,7 @@ public class WidgetTypeController extends AutoCommitController { @RequestParam(required = false) Boolean fullSearch, @Parameter(description = DEPRECATED_FILTER_PARAM_DESCRIPTION, schema = @Schema(allowableValues = {"ALL", "ACTUAL", "DEPRECATED"})) @RequestParam(required = false) String deprecatedFilter, - @Parameter(description = WIDGET_TYPE_ARRAY_DESCRIPTION, schema = @Schema(allowableValues = {"timeseries", "latest", "control", "alarm", "static"})) + @Parameter(description = WIDGET_TYPE_ARRAY_DESCRIPTION, array = @ArraySchema(schema = @Schema(type = "string", allowableValues = {"timeseries", "latest", "control", "alarm", "static"}))) @RequestParam(required = false) String[] widgetTypeList) throws ThingsboardException { PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); List widgetTypes = widgetTypeList != null ? Arrays.asList(widgetTypeList) : Collections.emptyList(); @@ -331,7 +332,7 @@ public class WidgetTypeController extends AutoCommitController { @RequestParam(required = false) Boolean fullSearch, @Parameter(description = DEPRECATED_FILTER_PARAM_DESCRIPTION, schema = @Schema(allowableValues = {"ALL", "ACTUAL", "DEPRECATED"})) @RequestParam(required = false) String deprecatedFilter, - @Parameter(description = WIDGET_TYPE_ARRAY_DESCRIPTION, schema = @Schema(allowableValues = {"timeseries", "latest", "control", "alarm", "static"})) + @Parameter(description = WIDGET_TYPE_ARRAY_DESCRIPTION, array = @ArraySchema(schema = @Schema(allowableValues = {"timeseries", "latest", "control", "alarm", "static"}))) @RequestParam(required = false) String[] widgetTypeList) throws ThingsboardException { WidgetsBundleId widgetsBundleId = new WidgetsBundleId(toUUID(strWidgetsBundleId)); PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); From bfe666398405efccf507488b0747b8731ce50af5 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 11 Jun 2024 15:28:58 +0300 Subject: [PATCH 10/30] UI: Fixed translate typo in api-limit --- ui-ngx/src/app/shared/models/limited-api.models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/shared/models/limited-api.models.ts b/ui-ngx/src/app/shared/models/limited-api.models.ts index 9046d8881f..946d816cfc 100644 --- a/ui-ngx/src/app/shared/models/limited-api.models.ts +++ b/ui-ngx/src/app/shared/models/limited-api.models.ts @@ -46,7 +46,7 @@ export const LimitedApiTranslationMap = new Map( [LimitedApi.TRANSPORT_MESSAGES_PER_TENANT, 'api-limit.transport-messages'], [LimitedApi.TRANSPORT_MESSAGES_PER_DEVICE, 'api-limit.transport-messages-per-device'], [LimitedApi.TRANSPORT_MESSAGES_PER_GATEWAY, 'api-limit.transport-messages-per-gateway'], - [LimitedApi.TRANSPORT_MESSAGES_PER_GATEWAY_DEVICE, 'api-limit.transport-messages-per-gateway_device'], + [LimitedApi.TRANSPORT_MESSAGES_PER_GATEWAY_DEVICE, 'api-limit.transport-messages-per-gateway-device'], [LimitedApi.EDGE_EVENTS, 'api-limit.edge-events'], [LimitedApi.EDGE_EVENTS_PER_EDGE, 'api-limit.edge-events-per-edge'], [LimitedApi.EDGE_UPLINK_MESSAGES, 'api-limit.edge-uplink-messages'], From 03eabdc3dff081d4a006c02fa97f93f6f1169d33 Mon Sep 17 00:00:00 2001 From: dashevchenko Date: Tue, 11 Jun 2024 15:35:55 +0300 Subject: [PATCH 11/30] deleted redundant swagger schema --- .../thingsboard/server/controller/DashboardController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/DashboardController.java b/application/src/main/java/org/thingsboard/server/controller/DashboardController.java index 37b5b8b3b1..f94c1131ed 100644 --- a/application/src/main/java/org/thingsboard/server/controller/DashboardController.java +++ b/application/src/main/java/org/thingsboard/server/controller/DashboardController.java @@ -250,7 +250,7 @@ public class DashboardController extends BaseController { public Dashboard updateDashboardCustomers( @Parameter(description = DASHBOARD_ID_PARAM_DESCRIPTION) @PathVariable(DASHBOARD_ID) String strDashboardId, - @Parameter(description = "JSON array with the list of customer ids, or empty to remove all customers", array = @ArraySchema(schema = @Schema(type = "string"))) + @Parameter(description = "JSON array with the list of customer ids, or empty to remove all customers") @RequestBody(required = false) String[] strCustomerIds) throws ThingsboardException { checkParameter(DASHBOARD_ID, strDashboardId); DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); @@ -268,7 +268,7 @@ public class DashboardController extends BaseController { public Dashboard addDashboardCustomers( @Parameter(description = DASHBOARD_ID_PARAM_DESCRIPTION) @PathVariable(DASHBOARD_ID) String strDashboardId, - @Parameter(description = "JSON array with the list of customer ids", array = @ArraySchema(schema = @Schema(type = "string"))) + @Parameter(description = "JSON array with the list of customer ids") @RequestBody String[] strCustomerIds) throws ThingsboardException { checkParameter(DASHBOARD_ID, strDashboardId); DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); @@ -286,7 +286,7 @@ public class DashboardController extends BaseController { public Dashboard removeDashboardCustomers( @Parameter(description = DASHBOARD_ID_PARAM_DESCRIPTION) @PathVariable(DASHBOARD_ID) String strDashboardId, - @Parameter(description = "JSON array with the list of customer ids", array = @ArraySchema(schema = @Schema(type = "string"))) + @Parameter(description = "JSON array with the list of customer ids") @RequestBody String[] strCustomerIds) throws ThingsboardException { checkParameter(DASHBOARD_ID, strDashboardId); DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); From 8b94a69a0903e4f0ffb15d49a170364a7059b491 Mon Sep 17 00:00:00 2001 From: dashevchenko Date: Tue, 11 Jun 2024 15:38:36 +0300 Subject: [PATCH 12/30] deleted redundant import --- .../org/thingsboard/server/controller/DashboardController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/DashboardController.java b/application/src/main/java/org/thingsboard/server/controller/DashboardController.java index f94c1131ed..013575361d 100644 --- a/application/src/main/java/org/thingsboard/server/controller/DashboardController.java +++ b/application/src/main/java/org/thingsboard/server/controller/DashboardController.java @@ -18,7 +18,6 @@ package org.thingsboard.server.controller; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; From bb532ba1ce06ebfd7000dd6928e878a1fd8275c0 Mon Sep 17 00:00:00 2001 From: dashevchenko Date: Tue, 11 Jun 2024 16:07:24 +0300 Subject: [PATCH 13/30] fixed swagger request params annotation --- .../server/controller/NotificationTargetController.java | 4 +++- .../server/controller/NotificationTemplateController.java | 4 +++- .../server/controller/TenantProfileController.java | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/NotificationTargetController.java b/application/src/main/java/org/thingsboard/server/controller/NotificationTargetController.java index 8436e8fe35..7634819e39 100644 --- a/application/src/main/java/org/thingsboard/server/controller/NotificationTargetController.java +++ b/application/src/main/java/org/thingsboard/server/controller/NotificationTargetController.java @@ -16,6 +16,8 @@ package org.thingsboard.server.controller; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -156,7 +158,7 @@ public class NotificationTargetController extends BaseController { SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH) @GetMapping(value = "/targets", params = {"ids"}) @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") - public List getNotificationTargetsByIds(@Parameter(description = "Comma-separated list of uuids representing targets ids", required = true) + public List getNotificationTargetsByIds(@Parameter(description = "Comma-separated list of uuids representing targets ids", array = @ArraySchema(schema = @Schema(type = "string")), required = true) @RequestParam("ids") UUID[] ids, @AuthenticationPrincipal SecurityUser user) { // PE: generic permission diff --git a/application/src/main/java/org/thingsboard/server/controller/NotificationTemplateController.java b/application/src/main/java/org/thingsboard/server/controller/NotificationTemplateController.java index 6948218531..474a2816b1 100644 --- a/application/src/main/java/org/thingsboard/server/controller/NotificationTemplateController.java +++ b/application/src/main/java/org/thingsboard/server/controller/NotificationTemplateController.java @@ -16,6 +16,8 @@ package org.thingsboard.server.controller; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; @@ -147,7 +149,7 @@ public class NotificationTemplateController extends BaseController { @RequestParam(required = false) String sortProperty, @Parameter(description = SORT_ORDER_DESCRIPTION) @RequestParam(required = false) String sortOrder, - @Parameter(description = "Comma-separated list of notification types to filter the templates") + @Parameter(description = "Comma-separated list of notification types to filter the templates", array = @ArraySchema(schema = @Schema(type = "string"))) @RequestParam(required = false) NotificationType[] notificationTypes, @AuthenticationPrincipal SecurityUser user) throws ThingsboardException { // PE: generic permission diff --git a/application/src/main/java/org/thingsboard/server/controller/TenantProfileController.java b/application/src/main/java/org/thingsboard/server/controller/TenantProfileController.java index 9c42683b00..62c1ecc93a 100644 --- a/application/src/main/java/org/thingsboard/server/controller/TenantProfileController.java +++ b/application/src/main/java/org/thingsboard/server/controller/TenantProfileController.java @@ -251,7 +251,8 @@ public class TenantProfileController extends BaseController { @GetMapping(value = "/tenantProfiles", params = {"ids"}) @PreAuthorize("hasAuthority('SYS_ADMIN')") - public List getTenantProfilesByIds(@RequestParam("ids") UUID[] ids) { + public List getTenantProfilesByIds(@Parameter(description = "Comma-separated list of tenant profile ids") + @RequestParam("ids") UUID[] ids) { return tenantProfileService.findTenantProfilesByIds(TenantId.SYS_TENANT_ID, ids); } From 9d7994ef494b8fff7b8f560b18a67bc45a618d0c Mon Sep 17 00:00:00 2001 From: dashevchenko Date: Tue, 11 Jun 2024 16:36:42 +0300 Subject: [PATCH 14/30] fixed swagger request params annotation --- .../thingsboard/server/controller/TenantProfileController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/TenantProfileController.java b/application/src/main/java/org/thingsboard/server/controller/TenantProfileController.java index 62c1ecc93a..ad1ed7824a 100644 --- a/application/src/main/java/org/thingsboard/server/controller/TenantProfileController.java +++ b/application/src/main/java/org/thingsboard/server/controller/TenantProfileController.java @@ -16,6 +16,7 @@ package org.thingsboard.server.controller; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -251,7 +252,7 @@ public class TenantProfileController extends BaseController { @GetMapping(value = "/tenantProfiles", params = {"ids"}) @PreAuthorize("hasAuthority('SYS_ADMIN')") - public List getTenantProfilesByIds(@Parameter(description = "Comma-separated list of tenant profile ids") + public List getTenantProfilesByIds(@Parameter(description = "Comma-separated list of tenant profile ids", array = @ArraySchema(schema = @Schema(type = "string"))) @RequestParam("ids") UUID[] ids) { return tenantProfileService.findTenantProfilesByIds(TenantId.SYS_TENANT_ID, ids); } From 70a418cfb2257e573f9792b6cc8065261c3b9bb9 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 11 Jun 2024 17:24:39 +0300 Subject: [PATCH 15/30] UI: Fixed notification template control not propagate new init value --- ...cation-template-configuration.component.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts b/ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts index eac2dc5a7e..06dd8d030e 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts @@ -95,9 +95,10 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co branding: false }; - private propagateChange = (v: any) => { }; + private propagateChange = null; private readonly destroy$ = new Subject(); private expendedBlocks: NotificationDeliveryMethod[]; + private propagateChangePending = false; constructor(private fb: FormBuilder, private translate: TranslateService) { @@ -105,7 +106,7 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co this.templateConfigurationForm.valueChanges.pipe( takeUntil(this.destroy$) ).subscribe((value) => { - this.propagateChange(value); + this.updateModel(value); }); } @@ -129,6 +130,12 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co registerOnChange(fn: any): void { this.propagateChange = fn; + if (this.propagateChangePending) { + this.propagateChangePending = false; + Promise.resolve().then(() => { + this.templateConfigurationForm.updateValueAndValidity(); + }); + } } registerOnTouched(fn: any): void { @@ -164,6 +171,14 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co return this.expendedBlocks.includes(name); } + private updateModel(value: Partial) { + if (this.propagateChange) { + this.propagateChange(value); + } else { + this.propagateChangePending = true; + } + } + private updateExpandedForm() { this.expendedBlocks = []; Object.keys(this.templateConfigurationForm.controls).forEach((name: NotificationDeliveryMethod) => { From 8e54329453849cfdfe72cd4c5a1093f0a2967188 Mon Sep 17 00:00:00 2001 From: dashevchenko Date: Tue, 11 Jun 2024 19:07:36 +0300 Subject: [PATCH 16/30] fixed saveEntityTelemetryWithTTL method --- .../org/thingsboard/server/controller/TelemetryController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/TelemetryController.java b/application/src/main/java/org/thingsboard/server/controller/TelemetryController.java index 5f1de4e3e3..6833a7ddfb 100644 --- a/application/src/main/java/org/thingsboard/server/controller/TelemetryController.java +++ b/application/src/main/java/org/thingsboard/server/controller/TelemetryController.java @@ -447,7 +447,7 @@ public class TelemetryController extends BaseController { public DeferredResult saveEntityTelemetryWithTTL( @Parameter(description = ENTITY_TYPE_PARAM_DESCRIPTION, required = true, schema = @Schema(defaultValue = "DEVICE")) @PathVariable("entityType") String entityType, @Parameter(description = ENTITY_ID_PARAM_DESCRIPTION, required = true) @PathVariable("entityId") String entityIdStr, - @Parameter(description = TELEMETRY_SCOPE_DESCRIPTION, required = true, schema = @Schema(allowableValues = "ANY")) @PathVariable("scope")AttributeScope scope, + @Parameter(description = TELEMETRY_SCOPE_DESCRIPTION, required = true, schema = @Schema(allowableValues = "ANY")) @PathVariable("scope")String scope, @Parameter(description = "A long value representing TTL (Time to Live) parameter.", required = true)@PathVariable("ttl")Long ttl, @io.swagger.v3.oas.annotations.parameters.RequestBody(description = TELEMETRY_JSON_REQUEST_DESCRIPTION, required = true)@RequestBody String requestBody) throws ThingsboardException { EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); From 4aa4f0f3e520fee702966ad82023d93cf948870b Mon Sep 17 00:00:00 2001 From: nick Date: Tue, 11 Jun 2024 19:27:46 +0300 Subject: [PATCH 17/30] fix_bug: lwm2m Bootstrap ShortServerId --- .../dao/service/validator/DeviceProfileDataValidator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java b/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java index 0a8d78fb86..0d14dbe7ed 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java +++ b/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java @@ -330,9 +330,7 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator 65534)) { throw new DeviceCredentialsValidationException("LwM2M Server ShortServerId must not be less than 1 and more than 65534!"); } - if (serverConfig.isBootstrapServerIs() && !(serverConfig.getShortServerId() == null || serverConfig.getShortServerId() ==0)) { - throw new DeviceCredentialsValidationException("Bootstrap Server ShortServerId must be null or '0'!"); - } + String server = serverConfig.isBootstrapServerIs() ? "Bootstrap Server" : "LwM2M Server"; if (!shortServerIds.add(serverConfig.getShortServerId())) { throw new DeviceCredentialsValidationException(server + " \"Short server Id\" value = " + serverConfig.getShortServerId() + ". This value must be a unique value for all servers!"); From d5f954d3df6dca19c10793cac55f5fc315829b19 Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 12 Jun 2024 07:45:14 +0300 Subject: [PATCH 18/30] fix_bug: lwm2m Bootstrap ShortServerId must not be less than 0 and more than 65535! --- .../dao/service/validator/DeviceProfileDataValidator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java b/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java index 0d14dbe7ed..a26b419d9c 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java +++ b/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java @@ -331,6 +331,10 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator 65535)) { + throw new DeviceCredentialsValidationException("Bootstrap Server ShortServerId must not be less than 0 and more than 65535!"); + } + String server = serverConfig.isBootstrapServerIs() ? "Bootstrap Server" : "LwM2M Server"; if (!shortServerIds.add(serverConfig.getShortServerId())) { throw new DeviceCredentialsValidationException(server + " \"Short server Id\" value = " + serverConfig.getShortServerId() + ". This value must be a unique value for all servers!"); From 242b0019a2d41f37301987541f3bd3c98bc23238 Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 12 Jun 2024 08:41:22 +0300 Subject: [PATCH 19/30] fix_bug: lwm2m Bootstrap ShortServerId must not be less than 0 and more than 65535! -2 --- .../dao/service/validator/DeviceProfileDataValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java b/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java index a26b419d9c..3095de6bb9 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java +++ b/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java @@ -331,7 +331,7 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator 65535)) { + if (serverConfig.isBootstrapServerIs() && (serverConfig.getShortServerId() < 0 || serverConfig.getShortServerId() > 65535)) { throw new DeviceCredentialsValidationException("Bootstrap Server ShortServerId must not be less than 0 and more than 65535!"); } From 8420de0cb467cc75d6d61a0a67cdd5e3e51fc26d Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 12 Jun 2024 12:53:17 +0300 Subject: [PATCH 20/30] fix_bug: lwm2m Bootstrap ShortServerId must not be less than 0 and more than 65535! add test --- .../validator/DeviceProfileDataValidator.java | 18 ++-- .../DeviceProfileDataValidatorTest.java | 88 +++++++++++++++++++ 2 files changed, 101 insertions(+), 5 deletions(-) diff --git a/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java b/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java index 3095de6bb9..2d2c7bf21c 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java +++ b/dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java @@ -327,12 +327,20 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator 65534)) { - throw new DeviceCredentialsValidationException("LwM2M Server ShortServerId must not be less than 1 and more than 65534!"); - } - if (serverConfig.isBootstrapServerIs() && (serverConfig.getShortServerId() < 0 || serverConfig.getShortServerId() > 65535)) { - throw new DeviceCredentialsValidationException("Bootstrap Server ShortServerId must not be less than 0 and more than 65535!"); + if (serverConfig.getShortServerId() != null) { + if (serverConfig.isBootstrapServerIs()){ + if(serverConfig.getShortServerId() < 0 || serverConfig.getShortServerId() > 65535){ + throw new DeviceCredentialsValidationException("Bootstrap Server ShortServerId must be in range [0 - 65535]!"); + } + } else { + if (serverConfig.getShortServerId() < 1 || serverConfig.getShortServerId() > 65534) { + throw new DeviceCredentialsValidationException("LwM2M Server ShortServerId must be in range [1 - 65534]!"); + } + } + } else { + String serverName = serverConfig.isBootstrapServerIs() ? "Bootstrap Server" : "LwM2M Server"; + throw new DeviceCredentialsValidationException(serverName + " ShortServerId must not be null!"); } String server = serverConfig.isBootstrapServerIs() ? "Bootstrap Server" : "LwM2M Server"; diff --git a/dao/src/test/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidatorTest.java b/dao/src/test/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidatorTest.java index ac0fa2cfe1..2da8a7ff45 100644 --- a/dao/src/test/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidatorTest.java +++ b/dao/src/test/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidatorTest.java @@ -20,11 +20,18 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.SpyBean; +import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.DeviceProfile; import org.thingsboard.server.common.data.DeviceProfileType; import org.thingsboard.server.common.data.DeviceTransportType; import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTransportConfiguration; import org.thingsboard.server.common.data.device.profile.DeviceProfileData; +import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration; +import org.thingsboard.server.common.data.device.profile.lwm2m.OtherConfiguration; +import org.thingsboard.server.common.data.device.profile.lwm2m.TelemetryMappingConfiguration; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.AbstractLwM2MBootstrapServerCredential; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerCredential; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.NoSecLwM2MBootstrapServerCredential; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.dao.dashboard.DashboardService; import org.thingsboard.server.dao.device.DeviceDao; @@ -34,6 +41,8 @@ import org.thingsboard.server.dao.queue.QueueService; import org.thingsboard.server.dao.rule.RuleChainService; import org.thingsboard.server.dao.tenant.TenantService; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import static org.mockito.BDDMockito.willReturn; @@ -42,6 +51,34 @@ import static org.mockito.Mockito.verify; @SpringBootTest(classes = DeviceProfileDataValidator.class) class DeviceProfileDataValidatorTest { + private static final String OBSERVE_ATTRIBUTES_WITHOUT_PARAMS = + " {\n" + + " \"keyName\": {},\n" + + " \"observe\": [],\n" + + " \"attribute\": [],\n" + + " \"telemetry\": [],\n" + + " \"attributeLwm2m\": {}\n" + + " }"; + + public static final String CLIENT_LWM2M_SETTINGS = + " {\n" + + " \"edrxCycle\": null,\n" + + " \"powerMode\": \"DRX\",\n" + + " \"fwUpdateResource\": null,\n" + + " \"fwUpdateStrategy\": 1,\n" + + " \"psmActivityTimer\": null,\n" + + " \"swUpdateResource\": null,\n" + + " \"swUpdateStrategy\": 1,\n" + + " \"pagingTransmissionWindow\": null,\n" + + " \"clientOnlyObserveAfterConnect\": 1\n" + + " }"; + + private static final String host = "localhost"; + private static final String hostBs = "localhost"; + + private static final int port = 5685; + private static final int portBs = 5687; + @MockBean DeviceProfileDao deviceProfileDao; @MockBean @@ -79,5 +116,56 @@ class DeviceProfileDataValidatorTest { validator.validateDataImpl(tenantId, deviceProfile); verify(validator).validateString("Device profile name", deviceProfile.getName()); } + @Test + void testValidateDeviceProfile_Lwm2mBootstrap_ShortServerId_Ok() { + Integer shortServerId = 123; + Integer shortServerIdBs = 0; + Lwm2mDeviceProfileTransportConfiguration transportConfiguration = + getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsNoSec(shortServerId, shortServerIdBs)); + DeviceProfile deviceProfile = getDeviceProfile(transportConfiguration); + + validator.validateDataImpl(tenantId, deviceProfile); + verify(validator).validateString("Device profile name", deviceProfile.getName()); + } + + private DeviceProfile getDeviceProfile(Lwm2mDeviceProfileTransportConfiguration transportConfiguration) { + DeviceProfile deviceProfile = new DeviceProfile(); + deviceProfile.setName("default"); + deviceProfile.setType(DeviceProfileType.DEFAULT); + deviceProfile.setTransportType(DeviceTransportType.LWM2M); + DeviceProfileData data = new DeviceProfileData(); + data.setTransportConfiguration(transportConfiguration); + deviceProfile.setProfileData(data); + deviceProfile.setTenantId(tenantId); + return deviceProfile; + } + + private Lwm2mDeviceProfileTransportConfiguration getTransportConfiguration(String observeAttr, List bootstrapServerCredentials) { + Lwm2mDeviceProfileTransportConfiguration transportConfiguration = new Lwm2mDeviceProfileTransportConfiguration(); + TelemetryMappingConfiguration observeAttrConfiguration = JacksonUtil.fromString(observeAttr, TelemetryMappingConfiguration.class); + OtherConfiguration clientLwM2mSettings = JacksonUtil.fromString(CLIENT_LWM2M_SETTINGS, OtherConfiguration.class); + transportConfiguration.setBootstrapServerUpdateEnable(true); + transportConfiguration.setObserveAttr(observeAttrConfiguration); + transportConfiguration.setClientLwM2mSettings(clientLwM2mSettings); + transportConfiguration.setBootstrap(bootstrapServerCredentials); + return transportConfiguration; + } + + private List getBootstrapServerCredentialsNoSec(Integer shortServerId, Integer shortServerIdBs){ + List bootstrap = new ArrayList<>(); + bootstrap.add(getBootstrapServerCredentialNoSec(false, shortServerId, shortServerIdBs)); + bootstrap.add(getBootstrapServerCredentialNoSec(true, shortServerId, shortServerIdBs)); + return bootstrap; + } + + private AbstractLwM2MBootstrapServerCredential getBootstrapServerCredentialNoSec(boolean isBootstrap, Integer shortServerId, Integer shortServerIdBs) { + AbstractLwM2MBootstrapServerCredential bootstrapServerCredential = new NoSecLwM2MBootstrapServerCredential(); + bootstrapServerCredential.setServerPublicKey(""); + bootstrapServerCredential.setShortServerId(isBootstrap ? shortServerIdBs : shortServerId); + bootstrapServerCredential.setBootstrapServerIs(isBootstrap); + bootstrapServerCredential.setHost(isBootstrap ? hostBs : host); + bootstrapServerCredential.setPort(isBootstrap ? portBs : port); + return bootstrapServerCredential; + } } From bb9e81db1e37a765872fd5f3b1c54cb3be260c0b Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 15:07:50 +0300 Subject: [PATCH 21/30] [PROD-3407] [FIX] fixed gateway dashboard sorting by status --- .../gateway/gateway-connectors.component.ts | 24 ++++++++++++++----- .../src/app/shared/models/page/sort-order.ts | 3 +++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts index 4f1b6b72a9..0ee3a75ca6 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts @@ -35,7 +35,7 @@ import { AttributeData, AttributeScope } from '@shared/models/telemetry/telemetr import { PageComponent } from '@shared/components/page.component'; import { PageLink } from '@shared/models/page/page-link'; import { AttributeDatasource } from '@home/models/datasource/attribute-datasource'; -import { Direction, SortOrder } from '@shared/models/page/sort-order'; +import { Direction, SORT_ASC_PINNED_VALUE, SORT_DESC_PINNED_VALUE, SortOrder } from '@shared/models/page/sort-order'; import { MatSort } from '@angular/material/sort'; import { TelemetryWebsocketService } from '@core/ws/telemetry-websocket.service'; import { MatTableDataSource } from '@angular/material/table'; @@ -238,14 +238,26 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie this.dataSource.sort = this.sort; this.dataSource.sortingDataAccessor = (data: AttributeData, sortHeaderId: string) => { - if (sortHeaderId === 'syncStatus') { - return this.isConnectorSynced(data) ? 1 : 0; - } else if (sortHeaderId === 'enabled') { - return this.activeConnectors.includes(data.key) ? 1 : 0; + switch (sortHeaderId) { + case 'syncStatus': + return this.isConnectorSynced(data) ? 1 : 0; + + case 'enabled': + return this.activeConnectors.includes(data.key) ? 1 : 0; + + case 'errors': + const errors = this.getErrorsCount(data); + if (typeof errors === 'string') { + return this.sort.direction.toUpperCase() === Direction.DESC ? SORT_DESC_PINNED_VALUE : SORT_ASC_PINNED_VALUE; + } + return errors; + + default: + return data[sortHeaderId] || data.value[sortHeaderId]; } - return data[sortHeaderId] || data.value[sortHeaderId]; }; + if (this.device) { if (this.device.id === NULL_UUID) { return; diff --git a/ui-ngx/src/app/shared/models/page/sort-order.ts b/ui-ngx/src/app/shared/models/page/sort-order.ts index 9174b0c970..cece5e73e9 100644 --- a/ui-ngx/src/app/shared/models/page/sort-order.ts +++ b/ui-ngx/src/app/shared/models/page/sort-order.ts @@ -25,6 +25,9 @@ export enum Direction { DESC = 'DESC' } +export const SORT_DESC_PINNED_VALUE = -1; +export const SORT_ASC_PINNED_VALUE = 9999; + export function sortOrderFromString(strSortOrder: string): SortOrder { let property: string; let direction = Direction.ASC; From 66ad0544ec4ad66081f4705cb73bbc9ac884dc0a Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 12 Jun 2024 15:17:31 +0300 Subject: [PATCH 22/30] UI: Fixed validation short server id for bootstrap server in LwM2M transport configuration --- ...wm2m-bootstrap-config-servers.component.html | 1 + .../lwm2m-device-config-server.component.html | 6 +++--- .../lwm2m-device-config-server.component.ts | 17 +++++++++++++++-- .../assets/locale/locale.constant-ar_AE.json | 2 +- .../assets/locale/locale.constant-ca_ES.json | 2 +- .../assets/locale/locale.constant-cs_CZ.json | 2 +- .../assets/locale/locale.constant-en_US.json | 2 +- .../assets/locale/locale.constant-es_ES.json | 2 +- .../assets/locale/locale.constant-lt_LT.json | 2 +- .../assets/locale/locale.constant-nl_BE.json | 2 +- .../assets/locale/locale.constant-pl_PL.json | 2 +- .../assets/locale/locale.constant-tr_TR.json | 2 +- .../assets/locale/locale.constant-zh_CN.json | 2 +- .../assets/locale/locale.constant-zh_TW.json | 2 +- 14 files changed, 30 insertions(+), 16 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.html index 9671d35931..ce07156e2c 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.html @@ -20,6 +20,7 @@
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html index 961af7f808..3f93f2c4ce 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html @@ -32,7 +32,7 @@
- +
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts index dbeb616001..753748bb1b 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts @@ -38,6 +38,7 @@ import { Lwm2mSecurityType, Lwm2mSecurityTypeTranslationMap } from '@shared/models/lwm2m-security-config.models'; +import { coerceBoolean } from '@shared/decorators/coercion'; @Component({ selector: 'tb-profile-lwm2m-device-config-server', @@ -73,6 +74,13 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc currentSecurityMode = null; bootstrapDisabled = false; + shortServerIdMin = 1; + shortServerIdMax = 65534; + + @Input() + @coerceBoolean() + isBootstrap = false; + @Output() removeServer = new EventEmitter(); @@ -86,13 +94,18 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc } ngOnInit(): void { + if (this.isBootstrap) { + this.shortServerIdMin = 0; + this.shortServerIdMax = 65535; + } this.serverFormGroup = this.fb.group({ host: ['', Validators.required], port: ['', [Validators.required, Validators.min(1), Validators.max(65535), Validators.pattern('[0-9]*')]], securityMode: [Lwm2mSecurityType.NO_SEC], serverPublicKey: [''], clientHoldOffTime: ['', [Validators.required, Validators.min(0), Validators.pattern('[0-9]*')]], - shortServerId: ['', [Validators.required, Validators.min(1), Validators.max(65534), Validators.pattern('[0-9]*')]], + shortServerId: ['', + [Validators.required, Validators.min(this.shortServerIdMin), Validators.max(this.shortServerIdMax), Validators.pattern('[0-9]*')]], bootstrapServerAccountTimeout: ['', [Validators.required, Validators.min(0), Validators.pattern('[0-9]*')]], binding: [''], lifetime: [null, [Validators.required, Validators.min(0), Validators.pattern('[0-9]*')]], @@ -199,7 +212,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc if (value !== undefined) { this.propagateChange(value); } - } + }; private getLwm2mBootstrapSecurityInfo(securityMode = Lwm2mSecurityType.NO_SEC): Observable { return this.deviceProfileService.getLwm2mBootstrapSecurityInfoBySecurityType( diff --git a/ui-ngx/src/assets/locale/locale.constant-ar_AE.json b/ui-ngx/src/assets/locale/locale.constant-ar_AE.json index ec00225e6a..19b5113a24 100644 --- a/ui-ngx/src/assets/locale/locale.constant-ar_AE.json +++ b/ui-ngx/src/assets/locale/locale.constant-ar_AE.json @@ -2000,7 +2000,7 @@ "short-id": "معرف الخادم القصير", "short-id-tooltip": "معرف الخادم القصير. يُستخدم كرابط لربط نموذج كائن الخادم.\nهذا المعرف يُميز بشكل فريد كل خادم LwM2M المُعد للعميل LwM2M.\nيجب ضبط المورد عندما يكون مورد الخادم التمهيدي بقيمة 'false'.\nلا يجب استخدام قيم المعرف ID:0 و ID:65535 لتحديد خادم LwM2M.", "short-id-required": "معرف الخادم القصير مطلوب.", - "short-id-range": "يجب أن يكون معرف الخادم القصير ضمن نطاق من 1 إلى 65534.", + "short-id-range": "يجب أن يكون معرف الخادم القصير ضمن نطاق من {{ min }} إلى {{ max }}.", "short-id-pattern": "يجب أن يكون معرف الخادم القصير عددًا صحيحًا موجبًا.", "lifetime": "مدة تسجيل العميل", "lifetime-required": "مدة تسجيل العميل مطلوبة.", diff --git a/ui-ngx/src/assets/locale/locale.constant-ca_ES.json b/ui-ngx/src/assets/locale/locale.constant-ca_ES.json index b2da56974f..e043a60025 100644 --- a/ui-ngx/src/assets/locale/locale.constant-ca_ES.json +++ b/ui-ngx/src/assets/locale/locale.constant-ca_ES.json @@ -1632,7 +1632,7 @@ "short-id": "Identificador curt del servidor", "short-id-tooltip": "Identificador curt del servidor. S'utilitza com a enllaç a la instància d'objecte del servidor associada.\nAquest identificador identifica de manera única cada servidor LwM2M configurat per al client LwM2M.\nEl recurs S'HA d'establir quan el recurs del servidor Bootstrap té un valor 'fals'.\nEls valors ID:0 i ID :65535 NO S'HAN d'utilitzar per identificar el servidor LwM2M.", "short-id-required": "Cal identificador curt del servidor.", - "short-id-range": "L'identificador de servidor curt hauria d'estar entre 1 i 65534.", + "short-id-range": "L'identificador de servidor curt hauria d'estar entre {{ min }} i {{ max }}.", "short-id-pattern": "L'identificador de servidor curt ha de ser un nombre enter positiu.", "lifetime": "Vida útil del registre del client", "lifetime-required": "Cal vida útil del registre del client.", diff --git a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json index f371a19f29..57e19e9faa 100644 --- a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json +++ b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json @@ -1247,7 +1247,7 @@ "mode": "Režim konfigurace bezpečnosti", "short-id": "Krátké ID", "short-id-required": "Krátké ID je povinné.", - "short-id-range": "Krátké ID by mělo být v rozsahu od 1 do 65534.", + "short-id-range": "Krátké ID by mělo být v rozsahu od {{ min }} do {{ max }}.", "short-id-pattern": "Krátké ID musí být kladné celé číslo.", "lifetime": "Doba platnosti registrace klienta", "lifetime-required": "Doba platnosti registrace klienta je povinná.", 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 0fa09da5e4..8615930bb8 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1861,7 +1861,7 @@ "short-id": "Short server ID", "short-id-tooltip": "Server short Id. Used as link to associate server Object Instance.\nThis identifier uniquely identifies each LwM2M Server configured for the LwM2M Client.\nResource MUST be set when the Bootstrap-Server Resource has a value of 'false'.\nThe values ID:0 and ID:65535 values MUST NOT be used for identifying the LwM2M Server.", "short-id-required": "Short server ID is required.", - "short-id-range": "Short server ID should be in a range from 1 to 65534.", + "short-id-range": "Short server ID should be in a range from {{ min }} to {{ max }}.", "short-id-pattern": "Short server ID must be a positive integer.", "lifetime": "Client registration lifetime", "lifetime-required": "Client registration lifetime is required.", diff --git a/ui-ngx/src/assets/locale/locale.constant-es_ES.json b/ui-ngx/src/assets/locale/locale.constant-es_ES.json index 314a70e7fa..f5f62850b2 100644 --- a/ui-ngx/src/assets/locale/locale.constant-es_ES.json +++ b/ui-ngx/src/assets/locale/locale.constant-es_ES.json @@ -1757,7 +1757,7 @@ "short-id": "Short server ID", "short-id-tooltip": "Id corto del servidor. Usado como enlace para asociar las instancias de objetos del servidor.\nEste identificador sirve para identificar únicamente cada servidor LwM2M configurado para el cliente LwM2M.\nLos recursos DEBEN ser ajustados cuando el servidor Bootstrap tenga un valor de 'false'.\nLos valores ID:0 and ID:65535 NO DEBEN ser usados para identificar al servidor LwM2M.", "short-id-required": "Se requiere Short server ID.", - "short-id-range": "Short server ID debe estar en un rango de 1 a 65534.", + "short-id-range": "Short server ID debe estar en un rango de {{ min }} a {{ max }}.", "short-id-pattern": "Short server ID debe ser un número entero positivo.", "lifetime": "Ciclo de vida registro de cliente (Registration Lifetime)", "lifetime-required": "Se requiere ciclo de vida.", diff --git a/ui-ngx/src/assets/locale/locale.constant-lt_LT.json b/ui-ngx/src/assets/locale/locale.constant-lt_LT.json index 5ca808146c..21338bf1f0 100644 --- a/ui-ngx/src/assets/locale/locale.constant-lt_LT.json +++ b/ui-ngx/src/assets/locale/locale.constant-lt_LT.json @@ -1970,7 +1970,7 @@ "short-id": "Short server ID", "short-id-tooltip": "Server short Id. Used as link to associate server Object Instance.\nThis identifier uniquely identifies each LwM2M Server configured for the LwM2M Client.\nResource MUST be set when the Bootstrap-Server Resource has a value of 'false'.\nThe values ID:0 and ID:65535 values MUST NOT be used for identifying the LwM2M Server.", "short-id-required": "Short server ID is required.", - "short-id-range": "Short server ID should be in a range from 1 to 65534.", + "short-id-range": "Short server ID should be in a range from {{ min }} to {{ max }}.", "short-id-pattern": "Short server ID must be a positive integer.", "lifetime": "Client registration lifetime", "lifetime-required": "Client registration lifetime is required.", diff --git a/ui-ngx/src/assets/locale/locale.constant-nl_BE.json b/ui-ngx/src/assets/locale/locale.constant-nl_BE.json index e8e2cb1f7d..fb736931f4 100644 --- a/ui-ngx/src/assets/locale/locale.constant-nl_BE.json +++ b/ui-ngx/src/assets/locale/locale.constant-nl_BE.json @@ -1857,7 +1857,7 @@ "short-id": "Korte server-ID", "short-id-tooltip": "Server-id kort Id. Wordt gebruikt als koppeling naar het Object-exemplaar van de koppeling.\nDeze id identificeert elke LwM2M-server die is geconfigureerd voor de LwM2M-client op unieke wijze.\nResource MOET worden ingesteld wanneer de Bootstrap-Server Resource een waarde van 'false' heeft.\nDe waarden ID:0 en ID:65535 mogen NIET worden gebruikt voor het identificeren van de LwM2M-server.", "short-id-required": "Een korte server-ID is vereist.", - "short-id-range": "Korte server-ID moet tussen 1 en 65534 liggen.", + "short-id-range": "Korte server-ID moet tussen {{ min }} en {{ max }} liggen.", "short-id-pattern": "Korte server-ID moet een positief geheel getal zijn.", "lifetime": "Levensduur klantregistratie", "lifetime-required": "Levenslange registratie van klanten is vereist.", diff --git a/ui-ngx/src/assets/locale/locale.constant-pl_PL.json b/ui-ngx/src/assets/locale/locale.constant-pl_PL.json index b30d4afc38..82cd3639b4 100644 --- a/ui-ngx/src/assets/locale/locale.constant-pl_PL.json +++ b/ui-ngx/src/assets/locale/locale.constant-pl_PL.json @@ -1976,7 +1976,7 @@ "short-id": "Krótki identyfikator serwera", "short-id-tooltip": "Krótki identyfikator serwera. ", "short-id-required": "Krótki identyfikator serwera jest wymagany.", - "short-id-range": "Krótki identyfikator serwera powinien mieścić się w zakresie od 1 do 65534.", + "short-id-range": "Krótki identyfikator serwera powinien mieścić się w zakresie od {{ min }} do {{ max }}.", "short-id-pattern": "Krótki identyfikator serwera musi być dodatnią liczbą całkowitą.", "lifetime": "Okres rejestracji klienta", "lifetime-required": "Okres rejestracji klienta jest wymagany.", diff --git a/ui-ngx/src/assets/locale/locale.constant-tr_TR.json b/ui-ngx/src/assets/locale/locale.constant-tr_TR.json index a8098a7153..d3e63db882 100644 --- a/ui-ngx/src/assets/locale/locale.constant-tr_TR.json +++ b/ui-ngx/src/assets/locale/locale.constant-tr_TR.json @@ -1260,7 +1260,7 @@ "mode": "Güvenlik yapılandırma modu", "short-id": "Kısa ID", "short-id-required": "Kısa ID gerekli.", - "short-id-range": "Kısa ID 1 ile 65534 aralığında olmalıdır.", + "short-id-range": "Kısa ID {{ min }} ile {{ max }} aralığında olmalıdır.", "short-id-pattern": "Kısa ID pozitif bir tam sayı olmalıdır.", "lifetime": "İstemci kayıt ömrü", "lifetime-required": "İstemci kayıt ömrü gerekli.", diff --git a/ui-ngx/src/assets/locale/locale.constant-zh_CN.json b/ui-ngx/src/assets/locale/locale.constant-zh_CN.json index 99b13168c2..4ae424c843 100644 --- a/ui-ngx/src/assets/locale/locale.constant-zh_CN.json +++ b/ui-ngx/src/assets/locale/locale.constant-zh_CN.json @@ -1794,7 +1794,7 @@ "short-id": "服务器ID", "short-id-tooltip": "服务器ID用作关联服务器对象实例的链接。", "short-id-required": "服务器ID必填。", - "short-id-range": "服务器ID应在1到65534范围内。", + "short-id-range": "服务器ID应在{{ min }}到{{ max }}范围内。", "short-id-pattern": "服务器ID必须是一个正整数。", "lifetime": "客户端注册生命周期", "lifetime-required": "客户端注册生命周期必填。", diff --git a/ui-ngx/src/assets/locale/locale.constant-zh_TW.json b/ui-ngx/src/assets/locale/locale.constant-zh_TW.json index 51f02e7855..68df8adcb1 100644 --- a/ui-ngx/src/assets/locale/locale.constant-zh_TW.json +++ b/ui-ngx/src/assets/locale/locale.constant-zh_TW.json @@ -1432,7 +1432,7 @@ "short-id": "短伺服器ID", "short-id-tooltip": "短伺服器ID。用作關聯伺服器物件實例的鏈接。 \n此標識符唯一標識為LwM2M伺服器客戶端配置的每個LwM2M 伺服器。\n當引導伺服器資源的值為'false'時,必須設置資源。\nID:0值和ID:65535值不得用於識別LwM2M伺服器。.", "short-id-required": "短伺服器ID必填", - "short-id-range": "短伺服器ID長度需介於1到65534。", + "short-id-range": "短伺服器ID長度需介於{{ min }}到{{ max }}。", "short-id-pattern": "短伺服器ID需為正整數", "lifetime": "客戶登記使用期限", "lifetime-required": "客戶登記使用期限必填", From d644da842d094016bc954522b1b3825b7e1a7d9a Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 12 Jun 2024 15:30:16 +0300 Subject: [PATCH 23/30] UI: Fixed short server ID help tooltip --- .../device/lwm2m/lwm2m-device-config-server.component.html | 2 +- ui-ngx/src/assets/locale/locale.constant-en_US.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html index 3f93f2c4ce..d5665191ce 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html @@ -57,7 +57,7 @@ {{ 'device-profile.lwm2m.short-id' | translate }} help + matTooltip="{{ (isBootstrap ? 'device-profile.lwm2m.short-id-tooltip-bootstrap': 'device-profile.lwm2m.short-id-tooltip') | translate }}">help {{ 'device-profile.lwm2m.short-id-required' | 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 8615930bb8..51a43fef93 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1860,6 +1860,7 @@ "server": "Server", "short-id": "Short server ID", "short-id-tooltip": "Server short Id. Used as link to associate server Object Instance.\nThis identifier uniquely identifies each LwM2M Server configured for the LwM2M Client.\nResource MUST be set when the Bootstrap-Server Resource has a value of 'false'.\nThe values ID:0 and ID:65535 values MUST NOT be used for identifying the LwM2M Server.", + "short-id-tooltip-bootstrap": "Server short Id. Used as link to associate server Object Instance.\nThis identifier uniquely identifies each LwM2M Server configured for the LwM2M Client.\nResource MUST be set when the Bootstrap-Server Resource has a value of 'false'.", "short-id-required": "Short server ID is required.", "short-id-range": "Short server ID should be in a range from {{ min }} to {{ max }}.", "short-id-pattern": "Short server ID must be a positive integer.", From 9ea7042e92508de78f7062a41e96fc8663986837 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 15:50:39 +0300 Subject: [PATCH 24/30] Revert "[PROD-3407] [FIX] fixed gateway dashboard sorting by status" This reverts commit bb9e81db1e37a765872fd5f3b1c54cb3be260c0b. --- .../gateway/gateway-connectors.component.ts | 24 +++++-------------- .../src/app/shared/models/page/sort-order.ts | 3 --- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts index 0ee3a75ca6..4f1b6b72a9 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts @@ -35,7 +35,7 @@ import { AttributeData, AttributeScope } from '@shared/models/telemetry/telemetr import { PageComponent } from '@shared/components/page.component'; import { PageLink } from '@shared/models/page/page-link'; import { AttributeDatasource } from '@home/models/datasource/attribute-datasource'; -import { Direction, SORT_ASC_PINNED_VALUE, SORT_DESC_PINNED_VALUE, SortOrder } from '@shared/models/page/sort-order'; +import { Direction, SortOrder } from '@shared/models/page/sort-order'; import { MatSort } from '@angular/material/sort'; import { TelemetryWebsocketService } from '@core/ws/telemetry-websocket.service'; import { MatTableDataSource } from '@angular/material/table'; @@ -238,26 +238,14 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie this.dataSource.sort = this.sort; this.dataSource.sortingDataAccessor = (data: AttributeData, sortHeaderId: string) => { - switch (sortHeaderId) { - case 'syncStatus': - return this.isConnectorSynced(data) ? 1 : 0; - - case 'enabled': - return this.activeConnectors.includes(data.key) ? 1 : 0; - - case 'errors': - const errors = this.getErrorsCount(data); - if (typeof errors === 'string') { - return this.sort.direction.toUpperCase() === Direction.DESC ? SORT_DESC_PINNED_VALUE : SORT_ASC_PINNED_VALUE; - } - return errors; - - default: - return data[sortHeaderId] || data.value[sortHeaderId]; + if (sortHeaderId === 'syncStatus') { + return this.isConnectorSynced(data) ? 1 : 0; + } else if (sortHeaderId === 'enabled') { + return this.activeConnectors.includes(data.key) ? 1 : 0; } + return data[sortHeaderId] || data.value[sortHeaderId]; }; - if (this.device) { if (this.device.id === NULL_UUID) { return; diff --git a/ui-ngx/src/app/shared/models/page/sort-order.ts b/ui-ngx/src/app/shared/models/page/sort-order.ts index cece5e73e9..9174b0c970 100644 --- a/ui-ngx/src/app/shared/models/page/sort-order.ts +++ b/ui-ngx/src/app/shared/models/page/sort-order.ts @@ -25,9 +25,6 @@ export enum Direction { DESC = 'DESC' } -export const SORT_DESC_PINNED_VALUE = -1; -export const SORT_ASC_PINNED_VALUE = 9999; - export function sortOrderFromString(strSortOrder: string): SortOrder { let property: string; let direction = Direction.ASC; From 5c91bcc267fb23a6d1b73cbc4d50c67dd6364864 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 15:56:05 +0300 Subject: [PATCH 25/30] [PROD-3481] [FIX] changed docker commands button and pop-up --- .../src/main/data/json/tenant/dashboards/gateways.json | 8 ++++---- ui-ngx/src/assets/locale/locale.constant-en_US.json | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/application/src/main/data/json/tenant/dashboards/gateways.json b/application/src/main/data/json/tenant/dashboards/gateways.json index d98daa3632..42c4f199b5 100644 --- a/application/src/main/data/json/tenant/dashboards/gateways.json +++ b/application/src/main/data/json/tenant/dashboards/gateways.json @@ -181,12 +181,12 @@ "actions": { "actionCellButton": [ { - "name": "Docker commands", + "name": "Launch command", "icon": "terminal", "useShowWidgetActionFunction": null, "showWidgetActionFunction": "return true;", "type": "customPretty", - "customHtml": "
\n \n

Docker commands

\n \n
\n \n
\n \n
\n \n
\n
\n", + "customHtml": "
\n \n

{{ 'gateway.launch-command' | translate }}

\n \n
\n \n
\n \n
\n \n
\n
\n", "customCss": ".container {\n display: grid;\n grid-template-rows: min-content minmax(auto, 1fr) min-content;\n height: 100%;\n max-height: 100vh;\n width: 600px;\n max-width: 100%;\n}", "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\n\nopenCommands();\n\nfunction openCommands() {\n customDialog.customDialog(htmlTemplate, CommandsDialogController, {panelClass: \"test\"}).subscribe();\n}\n\nfunction CommandsDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId.id;\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n}\n", "customResources": [], @@ -1861,7 +1861,7 @@ "padding": "8px", "settings": { "useMarkdownTextFunction": false, - "markdownTextPattern": "
\r\n \r\n
", + "markdownTextPattern": "
\r\n \r\n
", "applyDefaultMarkdownStyle": false, "markdownCss": ".action-buttons-container {\r\n display: flex;\r\n flex-wrap: wrap;\r\n flex-direction: row;\r\n height: 100%;\r\n width: 100%;\r\n align-content: center;\r\n}\r\n\r\nbutton {\r\n flex-grow: 1;\r\n margin: 10px;\r\n min-width: 150px;\r\n height: auto;\r\n}" }, @@ -1887,7 +1887,7 @@ "useShowWidgetActionFunction": null, "showWidgetActionFunction": "return true;", "type": "customPretty", - "customHtml": "
\n \n

Launch command

\n \n
\n \n
\n \n
\n \n
\n
\n", + "customHtml": "
\n \n

{{ 'gateway.launch-command' | translate }}

\n \n
\n \n
\n \n
\n \n
\n
\n", "customCss": ".container {\n display: grid;\n grid-template-rows: min-content minmax(auto, 1fr) min-content;\n height: 100%;\n max-height: 100vh;\n width: 600px;\n max-width: 100%;\n}", "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\n\nopenCommands();\n\nfunction openCommands() {\n customDialog.customDialog(htmlTemplate, CommandsDialogController, {panelClass: \"test\"}).subscribe();\n}\n\nfunction CommandsDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId.id;\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n}\n", "customResources": [], 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 0fa09da5e4..d0270a5c87 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -2835,6 +2835,7 @@ "enable-remote-logging": "Enable remote logging", "ellipsis-chips-text": "+ {{count}} more", "launch-gateway": "Launch gateway", + "launch-command": "Launch command", "launch-docker-compose": "Start the gateway using the following command in the terminal from folder with docker-compose.yml file", "logs-configuration": "Logs configuration", "create-new-gateway": "Create a new gateway", From 55ec80869bc7d6fbd51e76f1ee8c6263b33ef19d Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Wed, 12 Jun 2024 17:25:45 +0300 Subject: [PATCH 26/30] UI: Make min max editable --- .../battery-level-basic-config.component.html | 6 ++++ .../common/color-settings-panel.component.ts | 2 -- .../common/color-settings.component.ts | 8 ++--- .../settings/common/gradient.component.html | 32 +++++++++++-------- .../lib/settings/common/gradient.component.ts | 32 ++++++++++--------- ...ttery-level-widget-settings.component.html | 6 ++++ 6 files changed, 50 insertions(+), 36 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/config/basic/indicator/battery-level-basic-config.component.html b/ui-ngx/src/app/modules/home/components/widget/config/basic/indicator/battery-level-basic-config.component.html index 576b608c2f..f5a5693a63 100644 --- a/ui-ngx/src/app/modules/home/components/widget/config/basic/indicator/battery-level-basic-config.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/config/basic/indicator/battery-level-basic-config.component.html @@ -102,6 +102,8 @@ -
+
widgets.color.gradient-start
-
-
widgets.color.start-value
+
+
widgets.color.start-value
- +
- - + + + +
@@ -94,19 +96,21 @@ add -
+
widgets.color.gradient-end
-
-
widgets.color.end-value
+
+
widgets.color.end-value
- +
- - + + + +
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.ts index 8b78190f5a..a35c5a089a 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.ts @@ -31,7 +31,7 @@ import { takeUntil } from 'rxjs/operators'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { IAliasController } from '@core/api/widget-api.models'; import { DomSanitizer } from '@angular/platform-browser'; -import { coerceBoolean, coerceNumber } from '@shared/decorators/coercion'; +import { coerceBoolean } from '@shared/decorators/coercion'; import { isDefinedAndNotNull } from '@core/utils'; import { DataKeysCallbacks } from '@home/components/widget/config/data-keys.component.models'; import { Datasource } from '@shared/models/widget.models'; @@ -71,11 +71,9 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro datasource: Datasource; @Input() - @coerceNumber() minValue: number; @Input() - @coerceNumber() maxValue: number; @Input() @@ -111,7 +109,9 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro source: [{type: ValueSourceType.constant}], color: ['rgba(255, 0, 0, 1)'] }) - }) + }), + minValue: {value: 0, disabled: isFinite(this.minValue)}, + maxValue: {value: 100, disabled: isFinite(this.maxValue)} }); this.gradientFormGroup.valueChanges.pipe( @@ -141,6 +141,8 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro writeValue(value: ColorGradientSettings): void { if (isDefinedAndNotNull(value)) { this.gradientFormGroup.get('advancedMode').patchValue(value.advancedMode, {emitEvent: false}); + this.gradientFormGroup.get('minValue').patchValue(isFinite(value.minValue) ? value.minValue : this.minValue, {emitEvent: false}); + this.gradientFormGroup.get('maxValue').patchValue(isFinite(value.maxValue) ? value.maxValue : this.maxValue, {emitEvent: false}); if (value?.gradient?.length) { this.gradientFormGroup.get('gradient').get('start').patchValue(value.gradient[0], {emitEvent: false}); this.gradientFormGroup.get('gradient').get('end').patchValue(value.gradient[value.gradient.length - 1], {emitEvent: false}); @@ -165,10 +167,10 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro this.advancedGradientListFormArray.value.map((v, i) => this.pointer(shift * (i + 1), i+1, null, true)).join('') + `
`; } else { - const point = (+this.maxValue - +this.minValue) / (this.gradientListFormArray.value.length + 1); + const min = this.gradientFormGroup.get('minValue').value; + const max = this.gradientFormGroup.get('maxValue').value; + const point = (+max - +min) / (this.gradientListFormArray.value.length + 1); const shift = 100 / (this.gradientListFormArray.value.length + 1); - const min = isDefinedAndNotNull(this.minValue) ? this.minValue : 0; - const max = isDefinedAndNotNull(this.maxValue) ? this.maxValue : 100; return `
${min}
` + this.gradientListFormArray.value.map((v, i) => this.pointer(shift * (i + 1), i+1, point)).join('') + `
${max}
`; @@ -180,7 +182,8 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro return `
`; } else { return `
` + - `
${Math.floor(+this.minValue + (value * index))}
`; + `
` + + `${Math.floor(+this.gradientFormGroup.get('minValue').value + (value * index))}
`; } } @@ -256,15 +259,14 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro } updateModel() { + const gradient = this.gradientFormGroup.getRawValue(); this.propagateChange( { - advancedMode: this.gradientFormGroup.value.advancedMode, - gradient: [this.gradientFormGroup.value.gradient.start, - ...this.gradientFormGroup.value.gradient.gradientList.map(item => item.color), - this.gradientFormGroup.value.gradient.end], - gradientAdvanced: [this.gradientFormGroup.value.gradientAdvanced.start, - ...this.gradientFormGroup.value.gradientAdvanced.gradientList, - this.gradientFormGroup.value.gradientAdvanced.end] + advancedMode: gradient.advancedMode, + gradient: [gradient.gradient.start, ...gradient.gradient.gradientList.map(item => item.color), gradient.gradient.end], + gradientAdvanced: [gradient.gradientAdvanced.start, ...gradient.gradientAdvanced.gradientList, gradient.gradientAdvanced.end], + minValue: gradient.minValue, + maxValue: gradient.maxValue } ); } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/indicator/battery-level-widget-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/indicator/battery-level-widget-settings.component.html index c34b51a36b..572c50c392 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/indicator/battery-level-widget-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/indicator/battery-level-widget-settings.component.html @@ -51,6 +51,8 @@ Date: Wed, 12 Jun 2024 17:30:06 +0300 Subject: [PATCH 27/30] UI: optimize import --- .../lib/settings/common/color-settings-panel.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-settings-panel.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-settings-panel.component.ts index 83ce1aca09..0111e3157b 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-settings-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-settings-panel.component.ts @@ -31,7 +31,7 @@ import { deepClone } from '@core/utils'; import { WidgetService } from '@core/http/widget.service'; import { ColorSettingsComponent } from '@home/components/widget/lib/settings/common/color-settings.component'; import { IAliasController } from '@core/api/widget-api.models'; -import { coerceBoolean, coerceNumber } from '@shared/decorators/coercion'; +import { coerceBoolean } from '@shared/decorators/coercion'; import { DataKeysCallbacks } from '@home/components/widget/config/data-keys.component.models'; import { Datasource } from '@shared/models/widget.models'; From b702718990cc164fa974351dd282d8e4d6224fb9 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Thu, 13 Jun 2024 13:01:28 +0300 Subject: [PATCH 28/30] UI: Hotfix for color settings --- .../lib/settings/common/color-range-list.component.ts | 10 +++++----- .../settings/common/color-settings-panel.component.ts | 2 +- .../widget/lib/settings/common/gradient.component.scss | 6 ++++-- .../widget/lib/settings/common/gradient.component.ts | 10 +++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.ts index c12ba38718..fcfd5f47e5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.ts @@ -111,7 +111,7 @@ export class ColorRangeListComponent implements OnInit, ControlValueAccessor, On ).subscribe(() => this.updateModel()); this.colorRangeListFormGroup.get('advancedMode').valueChanges.pipe( takeUntil(this.destroy$) - ).subscribe(() => Promise.resolve().then(() => this.popover?.updatePosition())); + ).subscribe(() => setTimeout(() => {this.popover?.updatePosition();}, 0)); } ngOnDestroy() { @@ -175,7 +175,7 @@ export class ColorRangeListComponent implements OnInit, ControlValueAccessor, On public removeAdvancedRange(index: number) { (this.colorRangeListFormGroup.get('rangeAdvanced') as UntypedFormArray).removeAt(index); - Promise.resolve().then(() => this.popover?.updatePosition()); + setTimeout(() => {this.popover?.updatePosition();}, 0); } get advancedRangeFormArray(): UntypedFormArray { @@ -189,7 +189,7 @@ export class ColorRangeListComponent implements OnInit, ControlValueAccessor, On removeRange(index: number) { this.rangeListFormArray.removeAt(index); this.colorRangeListFormGroup.markAsDirty(); - Promise.resolve().then(() => this.popover?.updatePosition()); + setTimeout(() => {this.popover?.updatePosition();}, 0); } rangeDrop(event: CdkDragDrop, range: string) { @@ -212,7 +212,7 @@ export class ColorRangeListComponent implements OnInit, ControlValueAccessor, On const advancedRangeColorsArray = this.colorRangeListFormGroup.get('rangeAdvanced') as UntypedFormArray; const advancedRangeColorControl = this.fb.control(advancedRange, [advancedRangeValidator]); advancedRangeColorsArray.push(advancedRangeColorControl); - Promise.resolve().then(() => this.popover?.updatePosition()); + setTimeout(() => {this.popover?.updatePosition();}, 0); } addRange() { @@ -224,7 +224,7 @@ export class ColorRangeListComponent implements OnInit, ControlValueAccessor, On }; this.rangeListFormArray.push(this.colorRangeControl(newRange)); this.colorRangeListFormGroup.markAsDirty(); - Promise.resolve().then(() => this.popover?.updatePosition()); + setTimeout(() => {this.popover?.updatePosition();}, 0); } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-settings-panel.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-settings-panel.component.ts index 0111e3157b..70111a1448 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-settings-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-settings-panel.component.ts @@ -106,7 +106,7 @@ export class ColorSettingsPanelComponent extends PageComponent implements OnInit } ); this.colorSettingsFormGroup.get('type').valueChanges.subscribe(() => { - Promise.resolve().then(() => this.popover?.updatePosition()); + setTimeout(() => {this.popover?.updatePosition();}, 0); }); } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.scss b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.scss index 25e14cb0d5..d5dd0b57e5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.scss +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.scss @@ -23,7 +23,7 @@ .gradient-preview { width: 100%; - padding: 40px 12px 0; + padding: 40px 15px 0; .gradient-background { position: relative; height: 56px; @@ -120,11 +120,13 @@ display: flex; align-items: center; justify-content: center; - width: 33px; + width: 38px; height: 24px; border-radius: 4px; background-color: rgba(0, 0, 0, 0.06); &-text { + text-overflow: ellipsis; + overflow: hidden; font-size: 14px; font-weight: 500; } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.ts index a35c5a089a..0042f3be4b 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.ts @@ -119,7 +119,7 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro ).subscribe(() => this.updateModel()); this.gradientFormGroup.get('advancedMode').valueChanges.pipe( takeUntil(this.destroy$) - ).subscribe(() => Promise.resolve().then(() => this.popover?.updatePosition())); + ).subscribe(() => setTimeout(() => {this.popover?.updatePosition();}, 0)); } ngOnDestroy() { @@ -167,8 +167,8 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro this.advancedGradientListFormArray.value.map((v, i) => this.pointer(shift * (i + 1), i+1, null, true)).join('') + `
`; } else { - const min = this.gradientFormGroup.get('minValue').value; - const max = this.gradientFormGroup.get('maxValue').value; + const min = this.gradientFormGroup.get('minValue').value || 0; + const max = this.gradientFormGroup.get('maxValue').value || 100; const point = (+max - +min) / (this.gradientListFormArray.value.length + 1); const shift = 100 / (this.gradientListFormArray.value.length + 1); return `
${min}
` + @@ -236,7 +236,7 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro this.gradientListFormArray.removeAt(index); } this.gradientFormGroup.markAsDirty(); - Promise.resolve().then(() => this.popover?.updatePosition()); + setTimeout(() => {this.popover?.updatePosition();}, 0); } gradientDrop(event: CdkDragDrop, advanced = false) { @@ -255,7 +255,7 @@ export class GradientComponent implements OnInit, ControlValueAccessor, OnDestro this.gradientListFormArray.push(this.colorGradientControl('rgba(0,0,0,0.87)')); } this.gradientFormGroup.markAsDirty(); - Promise.resolve().then(() => this.popover?.updatePosition()); + setTimeout(() => {this.popover?.updatePosition();}, 0); } updateModel() { From 8c8fca4c27e614e018bb98b62b9a7539fdaa4654 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Thu, 13 Jun 2024 18:18:10 +0300 Subject: [PATCH 29/30] [PROD-3857] [FIX] Fixed templates display on opening SNMP connector --- .../lib/gateway/gateway-service-rpc-connector.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts index 2ea5964b84..15ca9ff7a5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts @@ -387,8 +387,8 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue value = deepClone(value); switch (this.connectorType) { case ConnectorType.SNMP: - this.clearFromArrayByName("oids"); - value.oids.forEach(value => { + this.clearFromArrayByName("oid"); + value.oid.forEach(value => { this.addSNMPoid(value) }) delete value.oids; From a463e0cdc08d3ce8cc721df9cb342fdbdb6d6ddc Mon Sep 17 00:00:00 2001 From: Max Petrov <93397261+maxunbearable@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:25:00 +0300 Subject: [PATCH 30/30] Update ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts suggestion Co-authored-by: Vladyslav Prykhodko --- .../lib/gateway/gateway-service-rpc-connector.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts index 15ca9ff7a5..9838fd2df2 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts @@ -391,7 +391,7 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue value.oid.forEach(value => { this.addSNMPoid(value) }) - delete value.oids; + delete value.oid; break; case ConnectorType.REQUEST: this.clearFromArrayByName("httpHeaders");