Fix gateway extension resource usage in widgets
This commit is contained in:
parent
f1ec5bdace
commit
5998e60565
@ -18,6 +18,7 @@ package org.thingsboard.server.service.entitiy.dashboard;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.server.common.data.ResourceType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -39,6 +40,7 @@ import java.util.stream.Stream;
|
||||
@TbCoreComponent
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@ConditionalOnProperty(value = "transport.gateway.dashboard.sync.enabled", havingValue = "true")
|
||||
public class DashboardSyncService {
|
||||
|
||||
private final GitSyncService gitSyncService;
|
||||
@ -46,8 +48,6 @@ public class DashboardSyncService {
|
||||
private final WidgetsBundleService widgetsBundleService;
|
||||
private final PartitionService partitionService;
|
||||
|
||||
@Value("${transport.gateway.dashboard.sync.enabled:true}")
|
||||
private boolean enabled;
|
||||
@Value("${transport.gateway.dashboard.sync.repository_url:}")
|
||||
private String repoUrl;
|
||||
@Value("${transport.gateway.dashboard.sync.branch:main}")
|
||||
@ -60,9 +60,6 @@ public class DashboardSyncService {
|
||||
|
||||
@AfterStartUp(order = AfterStartUp.REGULAR_SERVICE)
|
||||
public void init() throws Exception {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
gitSyncService.registerSync(REPO_KEY, repoUrl, branch, TimeUnit.HOURS.toMillis(fetchFrequencyHours), this::update);
|
||||
}
|
||||
|
||||
|
||||
@ -247,8 +247,10 @@ public class InstallScripts {
|
||||
dirStream.forEach(
|
||||
path -> {
|
||||
try {
|
||||
JsonNode widgetTypeJson = JacksonUtil.toJsonNode(path.toFile());
|
||||
WidgetTypeDetails widgetTypeDetails = JacksonUtil.treeToValue(widgetTypeJson, WidgetTypeDetails.class);
|
||||
String widgetTypeJson = Files.readString(path);
|
||||
widgetTypeJson = resourceService.checkSystemResourcesUsage(widgetTypeJson, ResourceType.JS_MODULE);
|
||||
|
||||
WidgetTypeDetails widgetTypeDetails = JacksonUtil.fromString(widgetTypeJson, WidgetTypeDetails.class);
|
||||
widgetTypeService.saveWidgetType(widgetTypeDetails);
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to load widget type from json: [{}]", path.toString());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user