Browse Source
Conflicts: ui-ngx/src/app/modules/home/components/widget/lib/settings/widget-settings.module.ts ui-ngx/src/app/shared/shared.module.ts ui-ngx/src/assets/locale/locale.constant-en_US.jsonpull/8337/head
1630 changed files with 55165 additions and 12244 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,23 @@ |
|||
-- |
|||
-- Copyright © 2016-2023 The Thingsboard Authors |
|||
-- |
|||
-- Licensed under the Apache License, Version 2.0 (the "License"); |
|||
-- you may not use this file except in compliance with the License. |
|||
-- You may obtain a copy of the License at |
|||
-- |
|||
-- http://www.apache.org/licenses/LICENSE-2.0 |
|||
-- |
|||
-- Unless required by applicable law or agreed to in writing, software |
|||
-- distributed under the License is distributed on an "AS IS" BASIS, |
|||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
-- See the License for the specific language governing permissions and |
|||
-- limitations under the License. |
|||
-- |
|||
|
|||
-- FIX DASHBOARD TEMPLATES AFTER ANGULAR MIGRATION TO VER.15 |
|||
|
|||
UPDATE dashboard SET configuration = REPLACE(configuration, 'mat-button mat-icon-button', 'mat-icon-button') |
|||
WHERE configuration like '%mat-button mat-icon-button%'; |
|||
|
|||
UPDATE widget_type SET descriptor = REPLACE(descriptor, 'mat-button mat-icon-button', 'mat-icon-button') |
|||
WHERE descriptor like '%mat-button mat-icon-button%'; |
|||
@ -0,0 +1,54 @@ |
|||
-- |
|||
-- Copyright © 2016-2023 The Thingsboard Authors |
|||
-- |
|||
-- Licensed under the Apache License, Version 2.0 (the "License"); |
|||
-- you may not use this file except in compliance with the License. |
|||
-- You may obtain a copy of the License at |
|||
-- |
|||
-- http://www.apache.org/licenses/LICENSE-2.0 |
|||
-- |
|||
-- Unless required by applicable law or agreed to in writing, software |
|||
-- distributed under the License is distributed on an "AS IS" BASIS, |
|||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
-- See the License for the specific language governing permissions and |
|||
-- limitations under the License. |
|||
-- |
|||
|
|||
ALTER TABLE notification_rule ADD COLUMN IF NOT EXISTS enabled BOOLEAN NOT NULL DEFAULT true; |
|||
|
|||
-- NOTIFICATION CONFIGS VERSION CONTROL START |
|||
|
|||
ALTER TABLE notification_template |
|||
ADD COLUMN IF NOT EXISTS external_id UUID; |
|||
DO |
|||
$$ |
|||
BEGIN |
|||
IF NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conname = 'uq_notification_template_external_id') THEN |
|||
ALTER TABLE notification_template ADD CONSTRAINT uq_notification_template_external_id UNIQUE (tenant_id, external_id); |
|||
END IF; |
|||
END; |
|||
$$; |
|||
|
|||
ALTER TABLE notification_target |
|||
ADD COLUMN IF NOT EXISTS external_id UUID; |
|||
DO |
|||
$$ |
|||
BEGIN |
|||
IF NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conname = 'uq_notification_target_external_id') THEN |
|||
ALTER TABLE notification_target ADD CONSTRAINT uq_notification_target_external_id UNIQUE (tenant_id, external_id); |
|||
END IF; |
|||
END; |
|||
$$; |
|||
|
|||
ALTER TABLE notification_rule |
|||
ADD COLUMN IF NOT EXISTS external_id UUID; |
|||
DO |
|||
$$ |
|||
BEGIN |
|||
IF NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conname = 'uq_notification_rule_external_id') THEN |
|||
ALTER TABLE notification_rule ADD CONSTRAINT uq_notification_rule_external_id UNIQUE (tenant_id, external_id); |
|||
END IF; |
|||
END; |
|||
$$; |
|||
|
|||
-- NOTIFICATION CONFIGS VERSION CONTROL END |
|||
@ -1,68 +0,0 @@ |
|||
/** |
|||
* Copyright © 2016-2023 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.apiusage.limits; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.thingsboard.server.common.data.StringUtils; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.msg.tools.TbRateLimits; |
|||
import org.thingsboard.server.dao.tenant.TbTenantProfileCache; |
|||
|
|||
import java.util.Map; |
|||
import java.util.concurrent.ConcurrentHashMap; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class DefaultRateLimitService implements RateLimitService { |
|||
|
|||
private final TbTenantProfileCache tenantProfileCache; |
|||
|
|||
private final Map<LimitedApi, Map<TenantId, TbRateLimits>> rateLimits = new ConcurrentHashMap<>(); |
|||
|
|||
@Override |
|||
public boolean checkRateLimit(TenantId tenantId, LimitedApi api) { |
|||
if (tenantId.isSysTenantId()) { |
|||
return true; |
|||
} |
|||
String rateLimitConfig = tenantProfileCache.get(tenantId).getProfileConfiguration() |
|||
.map(api::getLimitConfig).orElse(null); |
|||
|
|||
Map<TenantId, TbRateLimits> rateLimits = this.rateLimits.get(api); |
|||
if (StringUtils.isEmpty(rateLimitConfig)) { |
|||
if (rateLimits != null) { |
|||
rateLimits.remove(tenantId); |
|||
if (rateLimits.isEmpty()) { |
|||
this.rateLimits.remove(api); |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
if (rateLimits == null) { |
|||
rateLimits = new ConcurrentHashMap<>(); |
|||
this.rateLimits.put(api, rateLimits); |
|||
} |
|||
TbRateLimits rateLimit = rateLimits.get(tenantId); |
|||
if (rateLimit == null || !rateLimit.getConfiguration().equals(rateLimitConfig)) { |
|||
rateLimit = new TbRateLimits(rateLimitConfig); |
|||
rateLimits.put(tenantId, rateLimit); |
|||
} |
|||
|
|||
return rateLimit.tryConsume(); |
|||
} |
|||
|
|||
} |
|||
@ -1,36 +0,0 @@ |
|||
/** |
|||
* Copyright © 2016-2023 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.apiusage.limits; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration; |
|||
|
|||
import java.util.function.Function; |
|||
|
|||
@RequiredArgsConstructor |
|||
public enum LimitedApi { |
|||
|
|||
ENTITY_EXPORT(DefaultTenantProfileConfiguration::getTenantEntityExportRateLimit), |
|||
ENTITY_IMPORT(DefaultTenantProfileConfiguration::getTenantEntityImportRateLimit), |
|||
NOTIFICATION_REQUEST(DefaultTenantProfileConfiguration::getTenantNotificationRequestsRateLimit); |
|||
|
|||
private final Function<DefaultTenantProfileConfiguration, String> configExtractor; |
|||
|
|||
public String getLimitConfig(DefaultTenantProfileConfiguration profileConfiguration) { |
|||
return configExtractor.apply(profileConfiguration); |
|||
} |
|||
|
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue