From c14e12f173d7e762eb3bff96677feb2b68fc4a40 Mon Sep 17 00:00:00 2001 From: Kent Dong Date: Thu, 2 Jan 2025 09:45:43 +0800 Subject: [PATCH] fix: Use a better way to determine whether we have a built-in dashboard (#394) --- backend/console/pom.xml | 3 +++ .../higress/console/controller/SystemController.java | 6 +----- .../alibaba/higress/console/service/DashboardService.java | 2 ++ .../higress/console/service/DashboardServiceImpl.java | 8 ++++---- backend/pom.xml | 3 --- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/backend/console/pom.xml b/backend/console/pom.xml index e9d68ab7..2d695318 100644 --- a/backend/console/pom.xml +++ b/backend/console/pom.xml @@ -15,6 +15,9 @@ 16.19.0 + + 2.0.0 + true diff --git a/backend/console/src/main/java/com/alibaba/higress/console/controller/SystemController.java b/backend/console/src/main/java/com/alibaba/higress/console/controller/SystemController.java index b2de6e69..62e3c591 100644 --- a/backend/console/src/main/java/com/alibaba/higress/console/controller/SystemController.java +++ b/backend/console/src/main/java/com/alibaba/higress/console/controller/SystemController.java @@ -32,8 +32,6 @@ import org.springframework.web.bind.annotation.RestController; import com.alibaba.higress.console.constant.UserConfigKey; -import com.alibaba.higress.console.controller.dto.DashboardInfo; -import com.alibaba.higress.console.controller.dto.DashboardType; import com.alibaba.higress.console.controller.dto.Response; import com.alibaba.higress.console.controller.dto.SystemInfo; import com.alibaba.higress.console.controller.dto.SystemInitRequest; @@ -81,9 +79,7 @@ public void setSystemService(SystemService systemService) { @PostConstruct public void syncSystemState() { configService.setConfig(UserConfigKey.SYSTEM_INITIALIZED, sessionService.isAdminInitialized()); - DashboardInfo dashboardInfo = dashboardService.getDashboardInfo(DashboardType.MAIN); - configService.setConfig(UserConfigKey.DASHBOARD_BUILTIN, - dashboardInfo != null && Boolean.TRUE.equals(dashboardInfo.getBuiltIn())); + configService.setConfig(UserConfigKey.DASHBOARD_BUILTIN, dashboardService.isBuiltIn()); } @PostMapping("/init") diff --git a/backend/console/src/main/java/com/alibaba/higress/console/service/DashboardService.java b/backend/console/src/main/java/com/alibaba/higress/console/service/DashboardService.java index f318fa1c..5f42b087 100644 --- a/backend/console/src/main/java/com/alibaba/higress/console/service/DashboardService.java +++ b/backend/console/src/main/java/com/alibaba/higress/console/service/DashboardService.java @@ -25,6 +25,8 @@ */ public interface DashboardService { + boolean isBuiltIn(); + @Deprecated DashboardInfo getDashboardInfo(); diff --git a/backend/console/src/main/java/com/alibaba/higress/console/service/DashboardServiceImpl.java b/backend/console/src/main/java/com/alibaba/higress/console/service/DashboardServiceImpl.java index d24a79b4..742814d1 100644 --- a/backend/console/src/main/java/com/alibaba/higress/console/service/DashboardServiceImpl.java +++ b/backend/console/src/main/java/com/alibaba/higress/console/service/DashboardServiceImpl.java @@ -175,6 +175,10 @@ public void initialize() { } } + public boolean isBuiltIn() { + return StringUtils.isNoneBlank(apiBaseUrl, promDatasourceUrl, lokiDatasourceUrl); + } + @Override public DashboardInfo getDashboardInfo() { return getDashboardInfo(DashboardType.MAIN); @@ -377,10 +381,6 @@ private DashboardInfo getConfiguredDashboardInfo(DashboardType type) { return new DashboardInfo(false, null, url); } - private boolean isBuiltIn() { - return StringUtils.isNoneBlank(apiBaseUrl, promDatasourceUrl, lokiDatasourceUrl); - } - private String buildConfigData(String dashboardConfiguration, String datasourceUid) { return dashboardConfiguration.replace(DATASOURCE_UID_PLACEHOLDER, datasourceUid); } diff --git a/backend/pom.xml b/backend/pom.xml index 9b09df27..6a7e53ed 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -75,9 +75,6 @@ ${project.build.sourceEncoding} ${project.build.sourceEncoding} - 1.2.1 - true - ${project.basedir}/target/delombok-sources