diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UiPluginController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UiPluginController.java index 462db26253..b0c14174e8 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UiPluginController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UiPluginController.java @@ -18,7 +18,9 @@ package org.apache.dolphinscheduler.api.controller; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PLUGINS_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.VERSION_INFO_STATE_ERROR; +import org.apache.dolphinscheduler.api.dto.ProductInfoDto; import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.UiPluginService; import org.apache.dolphinscheduler.api.utils.Result; @@ -85,4 +87,13 @@ public class UiPluginController extends BaseController { Map result = uiPluginService.queryUiPluginDetailById(pluginId); return returnDataList(result); } + + @Operation(summary = "queryProductInfo", description = "QUERY_PRODUCT_INFO") + @GetMapping(value = "/query-product-info") + @ResponseStatus(HttpStatus.OK) + @ApiException(VERSION_INFO_STATE_ERROR) + public Result queryProductInfo() { + ProductInfoDto result = uiPluginService.queryProductInfo(); + return Result.success(result); + } } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/ProductInfoDto.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/ProductInfoDto.java new file mode 100644 index 0000000000..e79d721e92 --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/ProductInfoDto.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.dolphinscheduler.api.dto; + +import lombok.Data; + +/** + * ProductInfoDto + */ +@Data +public class ProductInfoDto { + + private String version; +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java index 243b554aaf..a2208b602b 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java @@ -288,7 +288,7 @@ public enum Status { UPDATE_PROJECT_PREFERENCE_ERROR(10301, "update project preference error", "更新项目偏好设置错误"), QUERY_PROJECT_PREFERENCE_ERROR(10302, "query project preference error", "查询项目偏好设置错误"), UPDATE_PROJECT_PREFERENCE_STATE_ERROR(10303, "Failed to update the state of the project preference", "更新项目偏好设置错误"), - + VERSION_INFO_STATE_ERROR(10304, "Failed to obtain project version and address", "获取版本信息错误"), RESOURCE_NOT_EXIST(20004, "resource not exist", "资源不存在"), RESOURCE_EXIST(20005, "resource already exists", "资源已存在"), RESOURCE_SUFFIX_NOT_SUPPORT_VIEW(20006, "resource suffix do not support online viewing", "资源文件后缀不支持查看"), diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UiPluginService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UiPluginService.java index 325f1672c4..c959de5ec1 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UiPluginService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UiPluginService.java @@ -17,6 +17,7 @@ package org.apache.dolphinscheduler.api.service; +import org.apache.dolphinscheduler.api.dto.ProductInfoDto; import org.apache.dolphinscheduler.common.enums.PluginType; import java.util.Map; @@ -30,4 +31,6 @@ public interface UiPluginService { Map queryUiPluginDetailById(int id); + ProductInfoDto queryProductInfo(); + } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UiPluginServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UiPluginServiceImpl.java index a444d11c99..6cd7526cfe 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UiPluginServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UiPluginServiceImpl.java @@ -17,12 +17,15 @@ package org.apache.dolphinscheduler.api.service.impl; +import org.apache.dolphinscheduler.api.dto.ProductInfoDto; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.UiPluginService; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.PluginType; +import org.apache.dolphinscheduler.dao.entity.DsVersion; import org.apache.dolphinscheduler.dao.entity.PluginDefine; import org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper; +import org.apache.dolphinscheduler.dao.repository.DsVersionDao; import org.apache.commons.collections4.CollectionUtils; @@ -30,6 +33,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.PostConstruct; + import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -45,6 +50,16 @@ public class UiPluginServiceImpl extends BaseServiceImpl implements UiPluginServ @Autowired PluginDefineMapper pluginDefineMapper; + @Autowired + private DsVersionDao dsVersionDao; + + private String dsVersion; + + @PostConstruct + private void init() { + dsVersion = dsVersionDao.selectVersion().map(DsVersion::getVersion).orElse("unknown"); + } + @Override public Map queryUiPluginsByType(PluginType pluginType) { Map result = new HashMap<>(); @@ -82,4 +97,11 @@ public class UiPluginServiceImpl extends BaseServiceImpl implements UiPluginServ return result; } + @Override + public ProductInfoDto queryProductInfo() { + ProductInfoDto result = new ProductInfoDto(); + result.setVersion(dsVersion); + return result; + } + } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UiPluginControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UiPluginControllerTest.java index 2e3c36f5cd..47f9db9955 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UiPluginControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UiPluginControllerTest.java @@ -25,6 +25,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import org.apache.dolphinscheduler.api.dto.ProductInfoDto; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.UiPluginService; import org.apache.dolphinscheduler.api.utils.Result; @@ -32,7 +33,9 @@ import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.PluginType; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MvcResult; @@ -91,4 +94,23 @@ public class UiPluginControllerTest extends AbstractControllerTest { JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); assertThat(actualResponseContent.toString()).isEqualTo(expectResponseContent.toString()); } + + @Test + public void testQueryProductInfo() throws Exception { + ProductInfoDto mockResult = new ProductInfoDto(); + Mockito.when(uiPluginService.queryProductInfo()).thenReturn(mockResult); + + MultiValueMap paramsMap = new LinkedMultiValueMap<>(); + paramsMap.add("userId", "1"); + + MvcResult mvcResult = mockMvc.perform(get("/ui-plugins/query-product-info") + .header(SESSION_ID, sessionId) + .params(paramsMap)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); + + Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); + Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); + } } diff --git a/dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts b/dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts index 5dd3030509..82f0b7642f 100644 --- a/dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts +++ b/dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts @@ -31,6 +31,8 @@ export function useDropDown() { useLogout() } else if (key === 'password') { router.push({ path: '/password' }) + } else if (key === 'about') { + router.push({ path: '/about' }) } else if (key === 'profile') { router.push({ path: '/profile' }) } diff --git a/dolphinscheduler-ui/src/layouts/content/use-dataList.ts b/dolphinscheduler-ui/src/layouts/content/use-dataList.ts index 6742559f99..aee434d4ce 100644 --- a/dolphinscheduler-ui/src/layouts/content/use-dataList.ts +++ b/dolphinscheduler-ui/src/layouts/content/use-dataList.ts @@ -26,6 +26,7 @@ import { DesktopOutlined, SafetyCertificateOutlined, UserOutlined, + SelectOutlined, LogoutOutlined, FundProjectionScreenOutlined, PartitionOutlined, @@ -360,6 +361,11 @@ export function useDataList() { icon: renderIcon(KeyOutlined), disabled: userStore.getSecurityConfigType !== 'PASSWORD' }, + { + label: t('user_dropdown.about'), + key: 'about', + icon: renderIcon(SelectOutlined), + }, { label: t('user_dropdown.logout'), key: 'logout', diff --git a/dolphinscheduler-ui/src/locales/en_US/about.ts b/dolphinscheduler-ui/src/locales/en_US/about.ts new file mode 100644 index 0000000000..4d8a8569e0 --- /dev/null +++ b/dolphinscheduler-ui/src/locales/en_US/about.ts @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +export default { + about: 'About', + about_version: 'Product Version' +} \ No newline at end of file diff --git a/dolphinscheduler-ui/src/locales/en_US/index.ts b/dolphinscheduler-ui/src/locales/en_US/index.ts index 096fb87566..f6296d4274 100644 --- a/dolphinscheduler-ui/src/locales/en_US/index.ts +++ b/dolphinscheduler-ui/src/locales/en_US/index.ts @@ -32,6 +32,7 @@ import security from '@/locales/en_US/security' import theme from '@/locales/en_US/theme' import user_dropdown from '@/locales/en_US/user-dropdown' import ui_setting from '@/locales/en_US/ui_setting' +import about from "@/locales/en_US/about"; export default { login, @@ -41,6 +42,7 @@ export default { menu, home, password, + about, profile, monitor, resource, diff --git a/dolphinscheduler-ui/src/locales/en_US/user-dropdown.ts b/dolphinscheduler-ui/src/locales/en_US/user-dropdown.ts index c356b7f5de..5ee8ed91c3 100644 --- a/dolphinscheduler-ui/src/locales/en_US/user-dropdown.ts +++ b/dolphinscheduler-ui/src/locales/en_US/user-dropdown.ts @@ -18,5 +18,6 @@ export default { profile: 'Profile', password: 'Password', + about: 'About', logout: 'Logout' } diff --git a/dolphinscheduler-ui/src/locales/zh_CN/about.ts b/dolphinscheduler-ui/src/locales/zh_CN/about.ts new file mode 100644 index 0000000000..8db2472168 --- /dev/null +++ b/dolphinscheduler-ui/src/locales/zh_CN/about.ts @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +export default { + about: '关于产品', + about_version: '产品版本' +} diff --git a/dolphinscheduler-ui/src/locales/zh_CN/index.ts b/dolphinscheduler-ui/src/locales/zh_CN/index.ts index 52224a1022..55209876b0 100644 --- a/dolphinscheduler-ui/src/locales/zh_CN/index.ts +++ b/dolphinscheduler-ui/src/locales/zh_CN/index.ts @@ -32,6 +32,7 @@ import security from '@/locales/zh_CN/security' import theme from '@/locales/zh_CN/theme' import user_dropdown from '@/locales/zh_CN/user-dropdown' import ui_setting from '@/locales/zh_CN/ui_setting' +import about from "@/locales/zh_CN/about"; export default { login, @@ -41,6 +42,7 @@ export default { menu, home, password, + about, profile, monitor, resource, diff --git a/dolphinscheduler-ui/src/locales/zh_CN/user-dropdown.ts b/dolphinscheduler-ui/src/locales/zh_CN/user-dropdown.ts index 778d3f008e..75688eb84a 100644 --- a/dolphinscheduler-ui/src/locales/zh_CN/user-dropdown.ts +++ b/dolphinscheduler-ui/src/locales/zh_CN/user-dropdown.ts @@ -18,5 +18,6 @@ export default { profile: '用户信息', password: '密码管理', + about: '产品信息', logout: '退出登录' } diff --git a/dolphinscheduler-ui/src/router/routes.ts b/dolphinscheduler-ui/src/router/routes.ts index 9d91c74afa..e17c7e1b93 100644 --- a/dolphinscheduler-ui/src/router/routes.ts +++ b/dolphinscheduler-ui/src/router/routes.ts @@ -68,6 +68,15 @@ const basePage: RouteRecordRaw[] = [ title: '用户信息', auth: [] } + }, + { + path: '/about', + name: 'about', + component: components['about'], + meta: { + title: '产品信息', + auth: [] + } } ] }, diff --git a/dolphinscheduler-ui/src/service/modules/ui-plugins/index.ts b/dolphinscheduler-ui/src/service/modules/ui-plugins/index.ts index 1a9e99ae52..7f27b427bc 100644 --- a/dolphinscheduler-ui/src/service/modules/ui-plugins/index.ts +++ b/dolphinscheduler-ui/src/service/modules/ui-plugins/index.ts @@ -32,3 +32,10 @@ export function queryUiPluginDetailById(id: IPluginId): any { method: 'get' }) } + +export function queryProductInfo(): any { + return axios({ + url: '/ui-plugins/query-product-info', + method: 'get' + }) +} diff --git a/dolphinscheduler-ui/src/views/about/index.tsx b/dolphinscheduler-ui/src/views/about/index.tsx new file mode 100644 index 0000000000..0bdc598236 --- /dev/null +++ b/dolphinscheduler-ui/src/views/about/index.tsx @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +import { useI18n } from 'vue-i18n' +import { defineComponent, onMounted, ref} from 'vue' +import Card from '@/components/card' +import { NSpace } from 'naive-ui' +import { queryProductInfo } from '@/service/modules/ui-plugins' + +const about = defineComponent({ + name: 'about', + setup() { + const info: any = ref('') + const queryProduct = async () => { + const productInfo = await queryProductInfo() + if (!productInfo) throw Error() + info.value = productInfo.version + } + onMounted( () => { + queryProduct() + }) + + return { queryProduct, info } + }, + render() { + const { t } = useI18n() + const { info } = this + return ( +
+ + + + {t('about.about_version')} +
{ info }
+
+
+
+
+ ) + } +}) +export default about