Merge branch 'master' into tbel_doc_test

This commit is contained in:
nick 2024-10-24 16:21:15 +03:00
commit a94a125da2
7 changed files with 20 additions and 10 deletions

View File

@ -74,7 +74,7 @@ public class DashboardSyncService {
List<RepoFile> resources = listFiles("resources"); List<RepoFile> resources = listFiles("resources");
for (RepoFile resourceFile : resources) { for (RepoFile resourceFile : resources) {
String data = getFileContent(resourceFile.path()); String data = getFileContent(resourceFile.path());
resourceService.updateSystemResource(ResourceType.JS_MODULE, resourceFile.name(), data); resourceService.createOrUpdateSystemResource(ResourceType.JS_MODULE, resourceFile.name(), data);
} }
Stream<String> widgetsBundles = listFiles("widget_bundles").stream() Stream<String> widgetsBundles = listFiles("widget_bundles").stream()
@ -85,7 +85,7 @@ public class DashboardSyncService {
RepoFile dashboardFile = listFiles("dashboards").get(0); RepoFile dashboardFile = listFiles("dashboards").get(0);
String dashboardJson = getFileContent(dashboardFile.path()); String dashboardJson = getFileContent(dashboardFile.path());
resourceService.updateSystemResource(ResourceType.DASHBOARD, GATEWAYS_DASHBOARD_KEY, dashboardJson); resourceService.createOrUpdateSystemResource(ResourceType.DASHBOARD, GATEWAYS_DASHBOARD_KEY, dashboardJson);
log.info("Gateways dashboard sync completed"); log.info("Gateways dashboard sync completed");
} }

View File

@ -523,7 +523,7 @@ public class InstallScripts {
String resourceKey = resourceFile.getFileName().toString(); String resourceKey = resourceFile.getFileName().toString();
try { try {
String data = getContent(resourceFile); String data = getContent(resourceFile);
TbResource resource = resourceService.updateSystemResource(resourceType, resourceKey, data); TbResource resource = resourceService.createOrUpdateSystemResource(resourceType, resourceKey, data);
log.info("{} resource {}", (resource.getId() == null ? "Created" : "Updated"), resourceKey); log.info("{} resource {}", (resource.getId() == null ? "Created" : "Updated"), resourceKey);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Unable to load system resource " + resourceFile, e); throw new RuntimeException("Unable to load system resource " + resourceFile, e);

View File

@ -70,8 +70,12 @@ public class DefaultGitSyncService implements GitSyncService {
try { try {
log.debug("[{}] Fetching repository", key); log.debug("[{}] Fetching repository", key);
repository.fetch(); boolean updated = repository.fetch();
onUpdate(key); if (updated) {
onUpdate(key);
} else {
log.debug("[{}] No changes in the repository", key);
}
} catch (Throwable e) { } catch (Throwable e) {
log.error("[{}] Failed to fetch repository", key, e); log.error("[{}] Failed to fetch repository", key, e);
} }

View File

@ -64,7 +64,7 @@ public interface ResourceService extends EntityDaoService {
long sumDataSizeByTenantId(TenantId tenantId); long sumDataSizeByTenantId(TenantId tenantId);
TbResource updateSystemResource(ResourceType resourceType, String resourceKey, String data); TbResource createOrUpdateSystemResource(ResourceType resourceType, String resourceKey, String data);
String checkSystemResourcesUsage(String content, ResourceType... usedResourceTypes); String checkSystemResourcesUsage(String content, ResourceType... usedResourceTypes);

View File

@ -68,6 +68,7 @@ import org.thingsboard.server.common.data.page.SortOrder;
import org.thingsboard.server.common.data.sync.vc.BranchInfo; import org.thingsboard.server.common.data.sync.vc.BranchInfo;
import org.thingsboard.server.common.data.sync.vc.RepositoryAuthMethod; import org.thingsboard.server.common.data.sync.vc.RepositoryAuthMethod;
import org.thingsboard.server.common.data.sync.vc.RepositorySettings; import org.thingsboard.server.common.data.sync.vc.RepositorySettings;
import org.thingsboard.server.common.data.util.CollectionsUtil;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -184,9 +185,9 @@ public class GitRepository {
} }
} }
public void fetch() throws GitAPIException { public boolean fetch() throws GitAPIException {
if (settings.isLocalOnly()) { if (settings.isLocalOnly()) {
return; return false;
} }
log.debug("Executing fetch [{}]", settings.getRepositoryUri()); log.debug("Executing fetch [{}]", settings.getRepositoryUri());
FetchResult result = execute(git.fetch() FetchResult result = execute(git.fetch()
@ -195,6 +196,7 @@ public class GitRepository {
if (head != null) { if (head != null) {
this.headId = head.getObjectId(); this.headId = head.getObjectId();
} }
return CollectionsUtil.isNotEmpty(result.getTrackingRefUpdates());
} }
public void deleteLocalBranchIfExists(String branch) throws GitAPIException { public void deleteLocalBranchIfExists(String branch) throws GitAPIException {

View File

@ -240,7 +240,7 @@ public class BaseResourceService extends AbstractCachedEntityService<ResourceInf
} }
@Override @Override
public TbResource updateSystemResource(ResourceType resourceType, String resourceKey, String data) { public TbResource createOrUpdateSystemResource(ResourceType resourceType, String resourceKey, String data) {
if (resourceType == ResourceType.DASHBOARD) { if (resourceType == ResourceType.DASHBOARD) {
data = checkSystemResourcesUsage(data, ResourceType.JS_MODULE); data = checkSystemResourcesUsage(data, ResourceType.JS_MODULE);
} }

View File

@ -167,7 +167,11 @@ module.exports = {
}, },
safelist: [ safelist: [
'lt-md:gap-3', 'lt-md:gap-3',
'md:!hidden' 'md:!hidden',
'gap-6',
'gap-7',
'gap-10',
'gt-md:justify-center'
], ],
corePlugins: { corePlugins: {
preflight: false preflight: false