Default system images
This commit is contained in:
parent
cca7f47abc
commit
7f5a2df7dc
@ -324,6 +324,7 @@ public class ThingsboardInstallService {
|
||||
// systemDataLoaderService.loadSystemPlugins();
|
||||
// systemDataLoaderService.loadSystemRules();
|
||||
installScripts.loadSystemLwm2mResources();
|
||||
installScripts.createSystemImages();
|
||||
|
||||
if (loadDemo) {
|
||||
log.info("Loading demo data...");
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
package org.thingsboard.server.service.install;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -57,6 +58,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.thingsboard.server.utils.LwM2mObjectModelUtils.toLwm2mResource;
|
||||
|
||||
@ -302,11 +304,28 @@ public class InstallScripts {
|
||||
public void updateImages() {
|
||||
imagesUpdater.updateWidgetsBundlesImages();
|
||||
imagesUpdater.updateWidgetTypesImages();
|
||||
createSystemImages();
|
||||
|
||||
imagesUpdater.updateDashboardsImages();
|
||||
imagesUpdater.updateDeviceProfilesImages();
|
||||
imagesUpdater.updateAssetProfilesImages();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void createSystemImages() {
|
||||
Stream<Path> dashboardsFiles = Files.list(Paths.get(getDataDir(), JSON_DIR, DEMO_DIR, DASHBOARDS_DIR));
|
||||
try (dashboardsFiles) {
|
||||
dashboardsFiles.forEach(file -> {
|
||||
try {
|
||||
Dashboard dashboard = JacksonUtil.OBJECT_MAPPER.readValue(file.toFile(), Dashboard.class);
|
||||
imagesUpdater.createSystemImages(dashboard);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to create system images for default dashboard {}", file.getFileName(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void loadDashboards(TenantId tenantId, CustomerId customerId) throws Exception {
|
||||
Path dashboardsDir = Paths.get(getDataDir(), JSON_DIR, DEMO_DIR, DASHBOARDS_DIR);
|
||||
loadDashboardsFromDir(tenantId, customerId, dashboardsDir);
|
||||
|
||||
@ -18,6 +18,7 @@ package org.thingsboard.server.service.install.update;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.Dashboard;
|
||||
import org.thingsboard.server.common.data.HasImage;
|
||||
import org.thingsboard.server.common.data.id.EntityId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -62,6 +63,14 @@ public class ImagesUpdater {
|
||||
updateImages(dashboardsIds, "dashboard", imageService::replaceBase64WithImageUrl, dashboardDao);
|
||||
}
|
||||
|
||||
public void createSystemImages(Dashboard defaultDashboard) {
|
||||
defaultDashboard.setTenantId(TenantId.SYS_TENANT_ID);
|
||||
boolean created = imageService.replaceBase64WithImageUrl(defaultDashboard);
|
||||
if (created) {
|
||||
log.info("Created system images for default dashboard '{}'", defaultDashboard.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDeviceProfilesImages() {
|
||||
log.info("Updating device profiles images...");
|
||||
var deviceProfiles = new PageDataIterable<>(deviceProfileDao::findAll, 256);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user