Browse Source

Merge branch 'feature/propagation-cf' of github.com:ShvaykaD/thingsboard into feature/propagation-cf

pull/14208/head
dshvaika 10 months ago
parent
commit
77cc08f705
  1. 7
      application/src/main/java/org/thingsboard/server/service/cf/AlarmCalculatedFieldResult.java
  2. 6
      application/src/main/java/org/thingsboard/server/service/cf/ctx/state/alarm/AlarmCalculatedFieldState.java
  3. 3
      common/data/src/main/java/org/thingsboard/server/common/data/msg/TbMsgType.java
  4. 2
      common/data/src/test/java/org/thingsboard/server/common/data/msg/TbMsgTypeTest.java
  5. 1
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestRestClient.java
  6. 2
      ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-panel.component.html
  7. 216
      ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html
  8. 216
      ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts
  9. 11
      ui-ngx/src/app/shared/models/tenant.model.ts
  10. 4
      ui-ngx/src/assets/locale/locale.constant-en_US.json

7
application/src/main/java/org/thingsboard/server/service/cf/AlarmCalculatedFieldResult.java

@ -38,15 +38,20 @@ public class AlarmCalculatedFieldResult implements CalculatedFieldResult {
@Override
public TbMsg toTbMsg(EntityId entityId, List<CalculatedFieldId> cfIds) {
TbMsgType msgType;
TbMsgMetaData metaData = new TbMsgMetaData();
if (alarmResult.isCreated()) {
msgType = TbMsgType.ALARM_CREATED;
metaData.putValue(DataConstants.IS_NEW_ALARM, Boolean.TRUE.toString());
} else if (alarmResult.isUpdated()) {
msgType = TbMsgType.ALARM_UPDATED;
metaData.putValue(DataConstants.IS_EXISTING_ALARM, Boolean.TRUE.toString());
} else if (alarmResult.isSeverityUpdated()) {
msgType = TbMsgType.ALARM_SEVERITY_UPDATED;
metaData.putValue(DataConstants.IS_EXISTING_ALARM, Boolean.TRUE.toString());
metaData.putValue(DataConstants.IS_SEVERITY_UPDATED_ALARM, Boolean.TRUE.toString());
} else {
msgType = TbMsgType.ALARM_CLEAR;
metaData.putValue(DataConstants.IS_CLEARED_ALARM, Boolean.TRUE.toString());
}
if (alarmResult.getConditionRepeats() != null) {
@ -57,7 +62,7 @@ public class AlarmCalculatedFieldResult implements CalculatedFieldResult {
}
return TbMsg.newMsg()
.type(TbMsgType.ALARM)
.type(msgType)
.originator(entityId)
.data(JacksonUtil.toString(alarmResult.getAlarm()))
.metaData(metaData)

6
application/src/main/java/org/thingsboard/server/service/cf/ctx/state/alarm/AlarmCalculatedFieldState.java

@ -223,6 +223,9 @@ public class AlarmCalculatedFieldState extends BaseCalculatedFieldState {
private void processAlarmClear(Alarm alarm) {
currentAlarm = null;
createRuleStates.values().forEach(AlarmRuleState::clear);
createRuleStates.clear();
clearState(clearRuleState);
clearRuleState = null;
}
private void processAlarmAck(Alarm alarm) {
@ -231,8 +234,7 @@ public class AlarmCalculatedFieldState extends BaseCalculatedFieldState {
}
private void processAlarmDelete(Alarm alarm) {
currentAlarm = null;
createRuleStates.values().forEach(AlarmRuleState::clear);
processAlarmClear(alarm);
}
private TbAlarmResult createOrClearAlarms(Function<AlarmRuleState, AlarmEvalResult> evalFunction,

3
common/data/src/main/java/org/thingsboard/server/common/data/msg/TbMsgType.java

@ -39,6 +39,9 @@ public enum TbMsgType {
ATTRIBUTES_UPDATED("Attributes Updated"),
ATTRIBUTES_DELETED("Attributes Deleted"),
ALARM("Alarm"),
ALARM_CREATED("Alarm Created"),
ALARM_UPDATED("Alarm Updated"),
ALARM_SEVERITY_UPDATED("Alarm Severity Updated"),
ALARM_ACK("Alarm Acknowledged"),
ALARM_CLEAR("Alarm Cleared"),
ALARM_DELETE,

2
common/data/src/test/java/org/thingsboard/server/common/data/msg/TbMsgTypeTest.java

@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.thingsboard.server.common.data.msg.TbMsgType.ALARM;
import static org.thingsboard.server.common.data.msg.TbMsgType.ALARM_DELETE;
import static org.thingsboard.server.common.data.msg.TbMsgType.DEDUPLICATION_TIMEOUT_SELF_MSG;
import static org.thingsboard.server.common.data.msg.TbMsgType.DELAY_TIMEOUT_SELF_MSG;
@ -39,7 +38,6 @@ import static org.thingsboard.server.common.data.msg.TbMsgType.SEND_EMAIL;
class TbMsgTypeTest {
private static final List<TbMsgType> typesWithNullRuleNodeConnection = List.of(
ALARM,
ALARM_DELETE,
ENTITY_ASSIGNED_TO_EDGE,
ENTITY_UNASSIGNED_FROM_EDGE,

1
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestRestClient.java

@ -415,7 +415,6 @@ public class TestRestClient {
queryParams.put("toType", toId.getEntityType().name());
return given().spec(requestSpec)
.queryParams(queryParams)
//.delete("/api/v2/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&toId={toId}&toType={toType}")
.delete("/api/v2/relation")
.then()
.statusCode(HTTP_OK)

2
ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-panel.component.html

@ -176,7 +176,7 @@
</div>
</ng-container>
<ng-container>
@if (entityFilter.singleEntity.id) {
@if (entityFilter.singleEntity?.id) {
<div class="tb-form-row">
<div class="fixed-title-width tb-required" tb-hint-tooltip-icon="{{'calculated-fields.hint.perimeter-attribute-key' | translate}}">
{{ 'calculated-fields.perimeter-attribute-key' | translate }}

216
ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html

@ -15,7 +15,7 @@
limitations under the License.
-->
<section [formGroup]="defaultTenantProfileConfigurationFormGroup" class="flex flex-col">
<section [formGroup]="tenantProfileConfigurationForm" class="flex flex-col">
<fieldset class="fields-group">
<legend class="group-title">
{{ 'tenant-profile.entities' | translate }} <span translate>tenant-profile.unlimited</span>
@ -26,10 +26,10 @@
<input matInput required min="0" step="1"
formControlName="maxDevices"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDevices').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDevices').hasError('required')">
{{ 'tenant-profile.maximum-devices-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDevices').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDevices').hasError('min')">
{{ 'tenant-profile.maximum-devices-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -39,10 +39,10 @@
<input matInput required min="0" step="1"
formControlName="maxDashboards"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDashboards').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDashboards').hasError('required')">
{{ 'tenant-profile.maximum-dashboards-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDashboards').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDashboards').hasError('min')">
{{ 'tenant-profile.maximum-dashboards-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -54,10 +54,10 @@
<input matInput required min="0" step="1"
formControlName="maxAssets"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxAssets').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxAssets').hasError('required')">
{{ 'tenant-profile.maximum-assets-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxAssets').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxAssets').hasError('min')">
{{ 'tenant-profile.maximum-assets-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -67,10 +67,10 @@
<input matInput required min="0" step="1"
formControlName="maxUsers"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxUsers').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxUsers').hasError('required')">
{{ 'tenant-profile.maximum-users-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxUsers').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxUsers').hasError('min')">
{{ 'tenant-profile.maximum-users-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -89,10 +89,10 @@
<input matInput required min="0" step="1"
formControlName="maxCustomers"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxCustomers').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxCustomers').hasError('required')">
{{ 'tenant-profile.maximum-customers-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxCustomers').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxCustomers').hasError('min')">
{{ 'tenant-profile.maximum-customers-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -102,10 +102,10 @@
<input matInput required min="0" step="1"
formControlName="maxRuleChains"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxRuleChains').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxRuleChains').hasError('required')">
{{ 'tenant-profile.maximum-rule-chains-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxRuleChains').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxRuleChains').hasError('min')">
{{ 'tenant-profile.maximum-rule-chains-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -117,10 +117,10 @@
<input matInput required min="0" step="1"
formControlName="maxEdges"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxEdges').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxEdges').hasError('required')">
{{ 'tenant-profile.maximum-edges-required' | translate }}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxEdges').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxEdges').hasError('min')">
{{ 'tenant-profile.maximum-edges-range' | translate }}
</mat-error>
<mat-hint></mat-hint>
@ -141,10 +141,10 @@
<input matInput required min="0" step="1"
formControlName="maxREExecutions"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxREExecutions').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxREExecutions').hasError('required')">
{{ 'tenant-profile.max-r-e-executions-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxREExecutions').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxREExecutions').hasError('min')">
{{ 'tenant-profile.max-r-e-executions-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -154,10 +154,10 @@
<input matInput required min="0" step="1"
formControlName="maxTransportMessages"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTransportMessages').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxTransportMessages').hasError('required')">
{{ 'tenant-profile.max-transport-messages-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTransportMessages').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxTransportMessages').hasError('min')">
{{ 'tenant-profile.max-transport-messages-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -176,10 +176,10 @@
<input matInput required min="0" step="1"
formControlName="maxJSExecutions"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxJSExecutions').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxJSExecutions').hasError('required')">
{{ 'tenant-profile.max-j-s-executions-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxJSExecutions').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxJSExecutions').hasError('min')">
{{ 'tenant-profile.max-j-s-executions-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -189,10 +189,10 @@
<input matInput required min="0" step="1"
formControlName="maxTbelExecutions"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTbelExecutions').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxTbelExecutions').hasError('required')">
{{ 'tenant-profile.max-tbel-executions-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTbelExecutions').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxTbelExecutions').hasError('min')">
{{ 'tenant-profile.max-tbel-executions-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -204,10 +204,10 @@
<input matInput required min="0" step="1"
formControlName="maxRuleNodeExecutionsPerMessage"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxRuleNodeExecutionsPerMessage').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxRuleNodeExecutionsPerMessage').hasError('required')">
{{ 'tenant-profile.max-rule-node-executions-per-message-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxRuleNodeExecutionsPerMessage').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxRuleNodeExecutionsPerMessage').hasError('min')">
{{ 'tenant-profile.max-rule-node-executions-per-message-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -217,10 +217,10 @@
<input matInput required min="0" step="1"
formControlName="maxTransportDataPoints"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTransportDataPoints').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxTransportDataPoints').hasError('required')">
{{ 'tenant-profile.max-transport-data-points-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxTransportDataPoints').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxTransportDataPoints').hasError('min')">
{{ 'tenant-profile.max-transport-data-points-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -239,10 +239,10 @@
<input matInput required min="0" step="1"
formControlName="maxCalculatedFieldsPerEntity"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxCalculatedFieldsPerEntity').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxCalculatedFieldsPerEntity').hasError('required')">
{{ 'tenant-profile.max-calculated-fields-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxCalculatedFieldsPerEntity').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxCalculatedFieldsPerEntity').hasError('min')">
{{ 'tenant-profile.max-calculated-fields-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -252,10 +252,10 @@
<input matInput required min="0" step="1"
formControlName="maxDataPointsPerRollingArg"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDataPointsPerRollingArg').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDataPointsPerRollingArg').hasError('required')">
{{ 'tenant-profile.max-data-points-per-rolling-arg-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDataPointsPerRollingArg').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDataPointsPerRollingArg').hasError('min')">
{{ 'tenant-profile.max-data-points-per-rolling-arg-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -267,42 +267,14 @@
<input matInput required min="0" step="1"
formControlName="maxArgumentsPerCF"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxArgumentsPerCF').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxArgumentsPerCF').hasError('required')">
{{ 'tenant-profile.max-arguments-per-cf-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxArgumentsPerCF').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxArgumentsPerCF').hasError('min')">
{{ 'tenant-profile.max-arguments-per-cf-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
</mat-form-field>
<mat-form-field class="mat-block flex-1" appearance="fill" subscriptSizing="dynamic">
<mat-label translate>tenant-profile.max-related-level-per-argument</mat-label>
<input matInput required min="1" step="1"
formControlName="maxRelationLevelPerCfArgument"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxRelationLevelPerCfArgument').hasError('required')">
{{ 'tenant-profile.max-related-level-per-argument-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxRelationLevelPerCfArgument').hasError('min')">
{{ 'tenant-profile.max-related-level-per-argument-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
</mat-form-field>
</div>
<div class="flex flex-1 flex-row xs:flex-col gt-xs:gap-4">
<mat-form-field class="mat-block flex-1" appearance="fill" subscriptSizing="dynamic">
<mat-label translate>tenant-profile.min-allowed-scheduled-update-interval</mat-label>
<input matInput required min="0" step="1"
formControlName="minAllowedScheduledUpdateIntervalInSecForCF"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('minAllowedScheduledUpdateIntervalInSecForCF').hasError('required')">
{{ 'tenant-profile.min-allowed-scheduled-update-interval-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('minAllowedScheduledUpdateIntervalInSecForCF').hasError('min')">
{{ 'tenant-profile.min-allowed-scheduled-update-interval-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
</mat-form-field>
<div class="flex-1"></div>
</div>
<mat-expansion-panel class="configuration-panel">
@ -318,10 +290,10 @@
<input matInput required min="0" step="1"
formControlName="maxStateSizeInKBytes"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxStateSizeInKBytes').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxStateSizeInKBytes').hasError('required')">
{{ 'tenant-profile.max-state-size-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxStateSizeInKBytes').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxStateSizeInKBytes').hasError('min')">
{{ 'tenant-profile.max-state-size-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -331,15 +303,59 @@
<input matInput required min="0" step="1"
formControlName="maxSingleValueArgumentSizeInKBytes"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxSingleValueArgumentSizeInKBytes').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxSingleValueArgumentSizeInKBytes').hasError('required')">
{{ 'tenant-profile.max-value-argument-size-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxSingleValueArgumentSizeInKBytes').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxSingleValueArgumentSizeInKBytes').hasError('min')">
{{ 'tenant-profile.max-value-argument-size-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
</mat-form-field>
</div>
<div class="flex flex-1 flex-row xs:flex-col gt-xs:gap-4">
<mat-form-field class="mat-block flex-1" appearance="fill" subscriptSizing="dynamic">
<mat-label translate>tenant-profile.max-related-level-per-argument</mat-label>
<input matInput required min="1" step="1"
formControlName="maxRelationLevelPerCfArgument"
type="number">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxRelationLevelPerCfArgument').hasError('required')">
{{ 'tenant-profile.max-related-level-per-argument-required' | translate}}
</mat-error>
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxRelationLevelPerCfArgument').hasError('min')">
{{ 'tenant-profile.max-related-level-per-argument-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
</mat-form-field>
<mat-form-field class="mat-block flex-1" appearance="fill" subscriptSizing="dynamic">
<mat-label translate>tenant-profile.min-allowed-scheduled-update-interval</mat-label>
<input matInput required min="0" step="1"
formControlName="minAllowedScheduledUpdateIntervalInSecForCF"
type="number">
<mat-error *ngIf="tenantProfileConfigurationForm.get('minAllowedScheduledUpdateIntervalInSecForCF').hasError('required')">
{{ 'tenant-profile.min-allowed-scheduled-update-interval-required' | translate}}
</mat-error>
<mat-error *ngIf="tenantProfileConfigurationForm.get('minAllowedScheduledUpdateIntervalInSecForCF').hasError('min')">
{{ 'tenant-profile.min-allowed-scheduled-update-interval-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
</mat-form-field>
</div>
<div class="flex flex-1 flex-row xs:flex-col gt-xs:gap-4">
<mat-form-field class="mat-block flex-1" appearance="fill" subscriptSizing="dynamic">
<mat-label translate>tenant-profile.relation-search-entity-limit</mat-label>
<input matInput required min="1" step="1"
formControlName="maxRelatedEntitiesToReturnPerCfArgument"
type="number">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxRelatedEntitiesToReturnPerCfArgument').hasError('required')">
{{ 'tenant-profile.relation-search-entity-limit-required' | translate}}
</mat-error>
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxRelatedEntitiesToReturnPerCfArgument').hasError('min')">
{{ 'tenant-profile.relation-search-entity-limit-range' | translate}}
</mat-error>
<mat-hint translate>tenant-profile.relation-search-entity-limit-hint</mat-hint>
</mat-form-field>
<div class="flex-1"></div>
</div>
</ng-template>
</mat-expansion-panel>
</fieldset>
@ -354,10 +370,10 @@
<input matInput required min="0" step="1"
formControlName="maxDPStorageDays"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDPStorageDays').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDPStorageDays').hasError('required')">
{{ 'tenant-profile.max-d-p-storage-days-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDPStorageDays').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDPStorageDays').hasError('min')">
{{ 'tenant-profile.max-d-p-storage-days-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -367,10 +383,10 @@
<input matInput required min="0" step="1"
formControlName="alarmsTtlDays"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('alarmsTtlDays').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('alarmsTtlDays').hasError('required')">
{{ 'tenant-profile.alarms-ttl-days-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('alarmsTtlDays').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('alarmsTtlDays').hasError('min')">
{{ 'tenant-profile.alarms-ttl-days-days-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -382,10 +398,10 @@
<input matInput required min="0" step="1"
formControlName="defaultStorageTtlDays"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('defaultStorageTtlDays').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('defaultStorageTtlDays').hasError('required')">
{{ 'tenant-profile.default-storage-ttl-days-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('defaultStorageTtlDays').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('defaultStorageTtlDays').hasError('min')">
{{ 'tenant-profile.default-storage-ttl-days-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -395,10 +411,10 @@
<input matInput required min="0" step="1"
formControlName="rpcTtlDays"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('rpcTtlDays').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('rpcTtlDays').hasError('required')">
{{ 'tenant-profile.rpc-ttl-days-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('rpcTtlDays').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('rpcTtlDays').hasError('min')">
{{ 'tenant-profile.rpc-ttl-days-days-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -410,10 +426,10 @@
<input matInput required min="0" step="1"
formControlName="queueStatsTtlDays"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('queueStatsTtlDays').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('queueStatsTtlDays').hasError('required')">
{{ 'tenant-profile.queue-stats-ttl-days-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('queueStatsTtlDays').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('queueStatsTtlDays').hasError('min')">
{{ 'tenant-profile.queue-stats-ttl-days-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -423,10 +439,10 @@
<input matInput required min="0" step="1"
formControlName="ruleEngineExceptionsTtlDays"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('ruleEngineExceptionsTtlDays').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('ruleEngineExceptionsTtlDays').hasError('required')">
{{ 'tenant-profile.rule-engine-exceptions-ttl-days-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('ruleEngineExceptionsTtlDays').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('ruleEngineExceptionsTtlDays').hasError('min')">
{{ 'tenant-profile.rule-engine-exceptions-ttl-days-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -441,16 +457,16 @@
<mat-slide-toggle class="slide-toggle-element flex-1" formControlName="smsEnabled">
{{ 'tenant-profile.sms-enabled' | translate }}
</mat-slide-toggle>
<mat-form-field *ngIf="defaultTenantProfileConfigurationFormGroup.get('smsEnabled').value" class="mat-block flex-1"
<mat-form-field *ngIf="tenantProfileConfigurationForm.get('smsEnabled').value" class="mat-block flex-1"
appearance="fill" subscriptSizing="dynamic">
<mat-label translate>tenant-profile.max-sms</mat-label>
<input matInput required min="0" step="1"
formControlName="maxSms"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxSms').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxSms').hasError('required')">
{{ 'tenant-profile.max-sms-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxSms').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxSms').hasError('min')">
{{ 'tenant-profile.max-sms-range' | translate}}
</mat-error>
</mat-form-field>
@ -460,10 +476,10 @@
<input matInput required min="0" step="1"
formControlName="maxEmails"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxEmails').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxEmails').hasError('required')">
{{ 'tenant-profile.max-emails-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxEmails').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxEmails').hasError('min')">
{{ 'tenant-profile.max-emails-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -473,10 +489,10 @@
<input matInput required min="0" step="1"
formControlName="maxCreatedAlarms"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxCreatedAlarms').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxCreatedAlarms').hasError('required')">
{{ 'tenant-profile.max-created-alarms-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxCreatedAlarms').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxCreatedAlarms').hasError('min')">
{{ 'tenant-profile.max-created-alarms-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -494,7 +510,7 @@
<input matInput min="0" step="1"
formControlName="maxDebugModeDurationMinutes"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxDebugModeDurationMinutes').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxDebugModeDurationMinutes').hasError('min')">
{{ 'tenant-profile.maximum-debug-duration-min-range' | translate }}
</mat-error>
<mat-hint></mat-hint>
@ -513,10 +529,10 @@
<input matInput required min="0" step="1"
formControlName="maxResourcesInBytes"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxResourcesInBytes').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxResourcesInBytes').hasError('required')">
{{ 'tenant-profile.maximum-resources-sum-data-size-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxResourcesInBytes').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxResourcesInBytes').hasError('min')">
{{ 'tenant-profile.maximum-resources-sum-data-size-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -526,10 +542,10 @@
<input matInput required min="0" step="1"
formControlName="maxOtaPackagesInBytes"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxOtaPackagesInBytes').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxOtaPackagesInBytes').hasError('required')">
{{ 'tenant-profile.maximum-ota-package-sum-data-size-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxOtaPackagesInBytes').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxOtaPackagesInBytes').hasError('min')">
{{ 'tenant-profile.maximum-ota-package-sum-data-size-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -541,10 +557,10 @@
<input matInput required min="0" step="1"
formControlName="maxResourceSize"
type="number">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxResourceSize').hasError('required')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxResourceSize').hasError('required')">
{{ 'tenant-profile.maximum-resource-size-required' | translate}}
</mat-error>
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxResourceSize').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxResourceSize').hasError('min')">
{{ 'tenant-profile.maximum-resource-size-range' | translate}}
</mat-error>
<mat-hint></mat-hint>
@ -561,14 +577,14 @@
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-max-sessions-per-tenant</mat-label>
<input matInput type="number" formControlName="maxWsSessionsPerTenant">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxWsSessionsPerTenant').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxWsSessionsPerTenant').hasError('min')">
{{ 'tenant-profile.too-small-value-zero' | translate}}
</mat-error>
</mat-form-field>
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-max-subscriptions-per-tenant</mat-label>
<input matInput type="number" formControlName="maxWsSubscriptionsPerTenant">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxWsSubscriptionsPerTenant').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxWsSubscriptionsPerTenant').hasError('min')">
{{ 'tenant-profile.too-small-value-zero' | translate}}
</mat-error>
</mat-form-field>
@ -577,14 +593,14 @@
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-max-sessions-per-customer</mat-label>
<input matInput type="number" formControlName="maxWsSessionsPerCustomer">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxWsSessionsPerCustomer').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxWsSessionsPerCustomer').hasError('min')">
{{ 'tenant-profile.too-small-value-zero' | translate}}
</mat-error>
</mat-form-field>
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-max-subscriptions-per-customer</mat-label>
<input matInput type="number" formControlName="maxWsSubscriptionsPerCustomer">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxWsSubscriptionsPerCustomer').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxWsSubscriptionsPerCustomer').hasError('min')">
{{ 'tenant-profile.too-small-value-zero' | translate}}
</mat-error>
</mat-form-field>
@ -600,14 +616,14 @@
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-max-sessions-per-public-user</mat-label>
<input matInput type="number" formControlName="maxWsSessionsPerPublicUser">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxWsSessionsPerPublicUser').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxWsSessionsPerPublicUser').hasError('min')">
{{ 'tenant-profile.too-small-value-zero' | translate}}
</mat-error>
</mat-form-field>
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-max-subscriptions-per-public-user</mat-label>
<input matInput type="number" formControlName="maxWsSubscriptionsPerPublicUser">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxWsSubscriptionsPerPublicUser').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxWsSubscriptionsPerPublicUser').hasError('min')">
{{ 'tenant-profile.too-small-value-zero' | translate}}
</mat-error>
</mat-form-field>
@ -616,14 +632,14 @@
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-max-sessions-per-regular-user</mat-label>
<input matInput type="number" formControlName="maxWsSessionsPerRegularUser">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxWsSessionsPerRegularUser').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxWsSessionsPerRegularUser').hasError('min')">
{{ 'tenant-profile.too-small-value-zero' | translate}}
</mat-error>
</mat-form-field>
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-max-subscriptions-per-regular-user</mat-label>
<input matInput type="number" formControlName="maxWsSubscriptionsPerRegularUser">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('maxWsSubscriptionsPerRegularUser').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('maxWsSubscriptionsPerRegularUser').hasError('min')">
{{ 'tenant-profile.too-small-value-zero' | translate}}
</mat-error>
</mat-form-field>
@ -632,7 +648,7 @@
<mat-form-field class="mat-block flex-1" appearance="fill">
<mat-label translate>tenant-profile.ws-limit-queue-per-session</mat-label>
<input matInput type="number" formControlName="wsMsgQueueLimitPerSession">
<mat-error *ngIf="defaultTenantProfileConfigurationFormGroup.get('wsMsgQueueLimitPerSession').hasError('min')">
<mat-error *ngIf="tenantProfileConfigurationForm.get('wsMsgQueueLimitPerSession').hasError('min')">
{{ 'tenant-profile.too-small-value-one' | translate}}
</mat-error>
<mat-hint>

216
ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts

@ -14,16 +14,13 @@
/// limitations under the License.
///
import { Component, forwardRef, Input, OnDestroy, OnInit } from '@angular/core';
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import { Store } from '@ngrx/store';
import { AppState } from '@app/core/core.state';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { DefaultTenantProfileConfiguration, TenantProfileConfiguration } from '@shared/models/tenant.model';
import { Component, forwardRef, Input } from '@angular/core';
import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import { DefaultTenantProfileConfiguration, FormControlsFrom } from '@shared/models/tenant.model';
import { isDefinedAndNotNull } from '@core/utils';
import { RateLimitsType } from './rate-limits/rate-limits.models';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { coerceBoolean } from '@shared/decorators/coercion';
@Component({
selector: 'tb-default-tenant-profile-configuration',
@ -35,112 +32,107 @@ import { Subject } from 'rxjs';
multi: true
}]
})
export class DefaultTenantProfileConfigurationComponent implements ControlValueAccessor, OnInit, OnDestroy {
export class DefaultTenantProfileConfigurationComponent implements ControlValueAccessor {
defaultTenantProfileConfigurationFormGroup: UntypedFormGroup;
tenantProfileConfigurationForm: FormGroup<FormControlsFrom<DefaultTenantProfileConfiguration>>;
private requiredValue: boolean;
private destroy$ = new Subject<void>();
get required(): boolean {
return this.requiredValue;
}
@Input()
set required(value: boolean) {
this.requiredValue = coerceBooleanProperty(value);
}
@coerceBoolean()
required: boolean;
@Input()
@coerceBoolean()
disabled: boolean;
rateLimitsType = RateLimitsType;
private propagateChange = (v: any) => { };
constructor(private store: Store<AppState>,
private fb: UntypedFormBuilder) {
this.defaultTenantProfileConfigurationFormGroup = this.fb.group({
maxDevices: [null, [Validators.required, Validators.min(0)]],
maxAssets: [null, [Validators.required, Validators.min(0)]],
maxCustomers: [null, [Validators.required, Validators.min(0)]],
maxUsers: [null, [Validators.required, Validators.min(0)]],
maxDashboards: [null, [Validators.required, Validators.min(0)]],
maxRuleChains: [null, [Validators.required, Validators.min(0)]],
maxEdges: [null, [Validators.required, Validators.min(0)]],
maxResourcesInBytes: [null, [Validators.required, Validators.min(0)]],
maxOtaPackagesInBytes: [null, [Validators.required, Validators.min(0)]],
maxResourceSize: [null, [Validators.required, Validators.min(0)]],
transportTenantMsgRateLimit: [null, []],
transportTenantTelemetryMsgRateLimit: [null, []],
transportTenantTelemetryDataPointsRateLimit: [null, []],
transportDeviceMsgRateLimit: [null, []],
transportDeviceTelemetryMsgRateLimit: [null, []],
transportDeviceTelemetryDataPointsRateLimit: [null, []],
transportGatewayMsgRateLimit: [null, []],
transportGatewayTelemetryMsgRateLimit: [null, []],
transportGatewayTelemetryDataPointsRateLimit: [null, []],
transportGatewayDeviceMsgRateLimit: [null, []],
transportGatewayDeviceTelemetryMsgRateLimit: [null, []],
transportGatewayDeviceTelemetryDataPointsRateLimit: [null, []],
tenantEntityExportRateLimit: [null, []],
tenantEntityImportRateLimit: [null, []],
tenantNotificationRequestsRateLimit: [null, []],
tenantNotificationRequestsPerRuleRateLimit: [null, []],
maxTransportMessages: [null, [Validators.required, Validators.min(0)]],
maxTransportDataPoints: [null, [Validators.required, Validators.min(0)]],
maxREExecutions: [null, [Validators.required, Validators.min(0)]],
maxJSExecutions: [null, [Validators.required, Validators.min(0)]],
maxTbelExecutions: [null, [Validators.required, Validators.min(0)]],
maxDPStorageDays: [null, [Validators.required, Validators.min(0)]],
maxRuleNodeExecutionsPerMessage: [null, [Validators.required, Validators.min(0)]],
maxEmails: [null, [Validators.required, Validators.min(0)]],
maxSms: [null, []],
smsEnabled: [null, []],
maxCreatedAlarms: [null, [Validators.required, Validators.min(0)]],
maxDebugModeDurationMinutes: [null, [Validators.min(0)]],
defaultStorageTtlDays: [null, [Validators.required, Validators.min(0)]],
alarmsTtlDays: [null, [Validators.required, Validators.min(0)]],
rpcTtlDays: [null, [Validators.required, Validators.min(0)]],
queueStatsTtlDays: [null, [Validators.required, Validators.min(0)]],
ruleEngineExceptionsTtlDays: [null, [Validators.required, Validators.min(0)]],
tenantServerRestLimitsConfiguration: [null, []],
customerServerRestLimitsConfiguration: [null, []],
maxWsSessionsPerTenant: [null, [Validators.min(0)]],
maxWsSessionsPerCustomer: [null, [Validators.min(0)]],
maxWsSessionsPerRegularUser: [null, [Validators.min(0)]],
maxWsSessionsPerPublicUser: [null, [Validators.min(0)]],
wsMsgQueueLimitPerSession: [null, [Validators.min(0)]],
maxWsSubscriptionsPerTenant: [null, [Validators.min(0)]],
maxWsSubscriptionsPerCustomer: [null, [Validators.min(0)]],
maxWsSubscriptionsPerRegularUser: [null, [Validators.min(0)]],
maxWsSubscriptionsPerPublicUser: [null, [Validators.min(0)]],
wsUpdatesPerSessionRateLimit: [null, []],
cassandraWriteQueryTenantCoreRateLimits: [null, []],
cassandraReadQueryTenantCoreRateLimits: [null, []],
cassandraWriteQueryTenantRuleEngineRateLimits: [null, []],
cassandraReadQueryTenantRuleEngineRateLimits: [null, []],
edgeEventRateLimits: [null, []],
edgeEventRateLimitsPerEdge: [null, []],
edgeUplinkMessagesRateLimits: [null, []],
edgeUplinkMessagesRateLimitsPerEdge: [null, []],
maxCalculatedFieldsPerEntity: [null, [Validators.required, Validators.min(0)]],
maxArgumentsPerCF: [null, [Validators.required, Validators.min(0)]],
maxRelationLevelPerCfArgument: [null, [Validators.required, Validators.min(1)]],
minAllowedScheduledUpdateIntervalInSecForCF: [null, [Validators.required, Validators.min(0)]],
maxDataPointsPerRollingArg: [null, [Validators.required, Validators.min(0)]],
maxStateSizeInKBytes: [null, [Validators.required, Validators.min(0)]],
calculatedFieldDebugEventsRateLimit: [null, []],
maxSingleValueArgumentSizeInKBytes: [null, [Validators.required, Validators.min(0)]],
private propagateChange = (_v: any) => { };
constructor(private fb: FormBuilder) {
this.tenantProfileConfigurationForm = this.fb.group({
maxDevices: [0, [Validators.required, Validators.min(0)]],
maxAssets: [0, [Validators.required, Validators.min(0)]],
maxCustomers: [0, [Validators.required, Validators.min(0)]],
maxUsers: [0, [Validators.required, Validators.min(0)]],
maxDashboards: [0, [Validators.required, Validators.min(0)]],
maxRuleChains: [0, [Validators.required, Validators.min(0)]],
maxEdges: [0, [Validators.required, Validators.min(0)]],
maxResourcesInBytes: [0, [Validators.required, Validators.min(0)]],
maxOtaPackagesInBytes: [0, [Validators.required, Validators.min(0)]],
maxResourceSize: [0, [Validators.required, Validators.min(0)]],
transportTenantMsgRateLimit: [''],
transportTenantTelemetryMsgRateLimit: [''],
transportTenantTelemetryDataPointsRateLimit: [''],
transportDeviceMsgRateLimit: [''],
transportDeviceTelemetryMsgRateLimit: [''],
transportDeviceTelemetryDataPointsRateLimit: [''],
transportGatewayMsgRateLimit: [''],
transportGatewayTelemetryMsgRateLimit: [''],
transportGatewayTelemetryDataPointsRateLimit: [''],
transportGatewayDeviceMsgRateLimit: [''],
transportGatewayDeviceTelemetryMsgRateLimit: [''],
transportGatewayDeviceTelemetryDataPointsRateLimit: [''],
tenantEntityExportRateLimit: [''],
tenantEntityImportRateLimit: [''],
tenantNotificationRequestsRateLimit: [''],
tenantNotificationRequestsPerRuleRateLimit: [''],
maxTransportMessages: [0, [Validators.required, Validators.min(0)]],
maxTransportDataPoints: [0, [Validators.required, Validators.min(0)]],
maxREExecutions: [0, [Validators.required, Validators.min(0)]],
maxJSExecutions: [0, [Validators.required, Validators.min(0)]],
maxTbelExecutions: [0, [Validators.required, Validators.min(0)]],
maxDPStorageDays: [0, [Validators.required, Validators.min(0)]],
maxRuleNodeExecutionsPerMessage: [0, [Validators.required, Validators.min(0)]],
maxEmails: [0, [Validators.required, Validators.min(0)]],
maxSms: [0],
smsEnabled: [false],
maxCreatedAlarms: [0, [Validators.required, Validators.min(0)]],
maxDebugModeDurationMinutes: [0, [Validators.min(0)]],
defaultStorageTtlDays: [0, [Validators.required, Validators.min(0)]],
alarmsTtlDays: [0, [Validators.required, Validators.min(0)]],
rpcTtlDays: [0, [Validators.required, Validators.min(0)]],
queueStatsTtlDays: [0, [Validators.required, Validators.min(0)]],
ruleEngineExceptionsTtlDays: [0, [Validators.required, Validators.min(0)]],
tenantServerRestLimitsConfiguration: [''],
customerServerRestLimitsConfiguration: [''],
maxWsSessionsPerTenant: [0, [Validators.min(0)]],
maxWsSessionsPerCustomer: [0, [Validators.min(0)]],
maxWsSessionsPerRegularUser: [0, [Validators.min(0)]],
maxWsSessionsPerPublicUser: [0, [Validators.min(0)]],
wsMsgQueueLimitPerSession: [0, [Validators.min(0)]],
maxWsSubscriptionsPerTenant: [0, [Validators.min(0)]],
maxWsSubscriptionsPerCustomer: [0, [Validators.min(0)]],
maxWsSubscriptionsPerRegularUser: [0, [Validators.min(0)]],
maxWsSubscriptionsPerPublicUser: [0, [Validators.min(0)]],
wsUpdatesPerSessionRateLimit: [''],
cassandraWriteQueryTenantCoreRateLimits: [''],
cassandraReadQueryTenantCoreRateLimits: [''],
cassandraWriteQueryTenantRuleEngineRateLimits: [''],
cassandraReadQueryTenantRuleEngineRateLimits: [''],
edgeEventRateLimits: [''],
edgeEventRateLimitsPerEdge: [''],
edgeUplinkMessagesRateLimits: [''],
edgeUplinkMessagesRateLimitsPerEdge: [''],
maxCalculatedFieldsPerEntity: [0, [Validators.required, Validators.min(0)]],
maxArgumentsPerCF: [0, [Validators.required, Validators.min(0)]],
maxRelationLevelPerCfArgument: [1, [Validators.required, Validators.min(1)]],
maxRelatedEntitiesToReturnPerCfArgument: [1, [Validators.required, Validators.min(1)]],
minAllowedScheduledUpdateIntervalInSecForCF: [0, [Validators.required, Validators.min(0)]],
maxDataPointsPerRollingArg: [0, [Validators.required, Validators.min(0)]],
maxStateSizeInKBytes: [0, [Validators.required, Validators.min(0)]],
calculatedFieldDebugEventsRateLimit: [''],
maxSingleValueArgumentSizeInKBytes: [0, [Validators.required, Validators.min(0)]],
});
this.defaultTenantProfileConfigurationFormGroup.get('smsEnabled').valueChanges.pipe(
takeUntil(this.destroy$)
this.tenantProfileConfigurationForm.get('smsEnabled').valueChanges.pipe(
takeUntilDestroyed()
).subscribe((value: boolean) => {
this.maxSmsValidation(value);
}
);
this.defaultTenantProfileConfigurationFormGroup.valueChanges.pipe(
takeUntil(this.destroy$)
this.tenantProfileConfigurationForm.valueChanges.pipe(
takeUntilDestroyed()
).subscribe(() => {
this.updateModel();
});
@ -148,48 +140,40 @@ export class DefaultTenantProfileConfigurationComponent implements ControlValueA
private maxSmsValidation(smsEnabled: boolean) {
if (smsEnabled) {
this.defaultTenantProfileConfigurationFormGroup.get('maxSms').addValidators([Validators.required, Validators.min(0)]);
this.tenantProfileConfigurationForm.get('maxSms').addValidators([Validators.required, Validators.min(0)]);
} else {
this.defaultTenantProfileConfigurationFormGroup.get('maxSms').clearValidators();
this.tenantProfileConfigurationForm.get('maxSms').clearValidators();
}
this.defaultTenantProfileConfigurationFormGroup.get('maxSms').updateValueAndValidity({emitEvent: false});
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
this.tenantProfileConfigurationForm.get('maxSms').updateValueAndValidity({emitEvent: false});
}
registerOnChange(fn: any): void {
this.propagateChange = fn;
}
registerOnTouched(fn: any): void {
}
ngOnInit() {
registerOnTouched(_fn: any): void {
}
setDisabledState(isDisabled: boolean): void {
this.disabled = isDisabled;
if (this.disabled) {
this.defaultTenantProfileConfigurationFormGroup.disable({emitEvent: false});
this.tenantProfileConfigurationForm.disable({emitEvent: false});
} else {
this.defaultTenantProfileConfigurationFormGroup.enable({emitEvent: false});
this.tenantProfileConfigurationForm.enable({emitEvent: false});
}
}
writeValue(value: DefaultTenantProfileConfiguration | null): void {
if (isDefinedAndNotNull(value)) {
this.maxSmsValidation(value.smsEnabled);
this.defaultTenantProfileConfigurationFormGroup.patchValue(value, {emitEvent: false});
this.tenantProfileConfigurationForm.patchValue(value, {emitEvent: false});
}
}
private updateModel() {
let configuration: TenantProfileConfiguration = null;
if (this.defaultTenantProfileConfigurationFormGroup.valid) {
configuration = this.defaultTenantProfileConfigurationFormGroup.getRawValue();
let configuration: DefaultTenantProfileConfiguration = null;
if (this.tenantProfileConfigurationForm.valid) {
configuration = this.tenantProfileConfigurationForm.getRawValue();
}
this.propagateChange(configuration);
}

11
ui-ngx/src/app/shared/models/tenant.model.ts

@ -19,6 +19,11 @@ import { TenantId } from './id/tenant-id';
import { TenantProfileId } from '@shared/models/id/tenant-profile-id';
import { BaseData, ExportableEntity } from '@shared/models/base-data';
import { QueueInfo } from '@shared/models/queue.models';
import { FormControl } from '@angular/forms';
export type FormControlsFrom<T> = {
[K in keyof T]-?: FormControl<T[K] | null>;
};
export enum TenantProfileType {
DEFAULT = 'DEFAULT'
@ -101,6 +106,9 @@ export interface DefaultTenantProfileConfiguration {
maxCalculatedFieldsPerEntity: number;
maxArgumentsPerCF: number;
maxRelationLevelPerCfArgument: number;
maxRelatedEntitiesToReturnPerCfArgument: number;
minAllowedScheduledUpdateIntervalInSecForCF: number;
maxDataPointsPerRollingArg: number;
maxStateSizeInKBytes: number;
maxSingleValueArgumentSizeInKBytes: number;
@ -165,6 +173,9 @@ export function createTenantProfileConfiguration(type: TenantProfileType): Tenan
maxCalculatedFieldsPerEntity: 5,
maxArgumentsPerCF: 10,
maxDataPointsPerRollingArg: 1000,
maxRelationLevelPerCfArgument: 10,
maxRelatedEntitiesToReturnPerCfArgument: 100,
minAllowedScheduledUpdateIntervalInSecForCF: 0,
maxStateSizeInKBytes: 32,
maxSingleValueArgumentSizeInKBytes: 2,
calculatedFieldDebugEventsRateLimit: ''

4
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -5952,6 +5952,10 @@
"ws-limit-max-subscriptions-per-regular-user": "Subscriptions per regular user maximum number",
"ws-limit-max-subscriptions-per-public-user": "Subscriptions per public user maximum number",
"ws-limit-updates-per-session": "WS updates per session",
"relation-search-entity-limit": "Relation search entity limit",
"relation-search-entity-limit-hint": "Limits the number of entities resolved at the last level of the relation path. Applies to 'Related entities' arguments and Propagation fields.",
"relation-search-entity-limit-required": "Relation search entity limit",
"relation-search-entity-limit-range": "Relation search entity limit can't be less than '1'",
"rate-limits": {
"add-limit": "Add limit",
"and-also-less-than": "and also less than",

Loading…
Cancel
Save