diff --git a/dinky-admin/src/main/java/org/dinky/aop/TaskOperationPermissionAspect.java b/dinky-admin/src/main/java/org/dinky/aop/TaskOperationPermissionAspect.java index 76411b3851..271d6d7f64 100644 --- a/dinky-admin/src/main/java/org/dinky/aop/TaskOperationPermissionAspect.java +++ b/dinky-admin/src/main/java/org/dinky/aop/TaskOperationPermissionAspect.java @@ -62,7 +62,7 @@ public class TaskOperationPermissionAspect { @Around(value = "@annotation(checkTaskOwner)") public Object processAround(ProceedingJoinPoint joinPoint, CheckTaskOwner checkTaskOwner) throws Throwable { if (!TaskOwnerLockStrategyEnum.ALL.equals( - SystemConfiguration.getInstances().getTaskOwnerLockStrategy()) + SystemConfiguration.getInstances().GetTaskOwnerLockStrategyValue()) && BaseConstant.ADMIN_ID != StpUtil.getLoginIdAsInt()) { Class checkParam = checkTaskOwner.checkParam(); Object param = getParam(joinPoint, checkParam); diff --git a/dinky-admin/src/main/java/org/dinky/controller/SysConfigController.java b/dinky-admin/src/main/java/org/dinky/controller/SysConfigController.java index f3c9e8dfe9..b49e4e780a 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/SysConfigController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/SysConfigController.java @@ -110,4 +110,18 @@ public Result>> getOneTypeByKey(@RequestParam("type") Stri .collect(Collectors.toList()); return Result.succeed(configList); } + + @GetMapping("/getNeededCfg") + @ApiOperation("Get Needed Config") + @SaIgnore + public Result> getNeededCfg() { + return sysConfigService.getNeededCfg(); + } + + @PostMapping("/setInitConfig") + @ApiOperation("Get Needed Config") + @SaIgnore + public Result setInitConfig(@RequestBody Map params) { + return sysConfigService.setInitConfig(params); + } } diff --git a/dinky-admin/src/main/java/org/dinky/service/SysConfigService.java b/dinky-admin/src/main/java/org/dinky/service/SysConfigService.java index 6c2f0203be..ced096202b 100644 --- a/dinky-admin/src/main/java/org/dinky/service/SysConfigService.java +++ b/dinky-admin/src/main/java/org/dinky/service/SysConfigService.java @@ -21,6 +21,7 @@ import org.dinky.data.model.Configuration; import org.dinky.data.model.SysConfig; +import org.dinky.data.result.Result; import org.dinky.mybatis.service.ISuperService; import java.util.List; @@ -64,4 +65,18 @@ public interface SysConfigService extends ISuperService { * @param value The new value of the configuration. */ void updateSysConfigByKv(String key, String value); + + /** + * Get needed configurations. + * + * @return A map of string keys to lists of {@link Configuration} objects. + */ + Result> getNeededCfg(); + + /** + * Set initial configurations. + * + * @param params The parameters for initializing configurations. + */ + Result setInitConfig(Map params); } diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/SysConfigServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/SysConfigServiceImpl.java index 0f538293a2..1e49cfe31d 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/SysConfigServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/SysConfigServiceImpl.java @@ -23,9 +23,13 @@ import org.dinky.data.model.Configuration; import org.dinky.data.model.SysConfig; import org.dinky.data.model.SystemConfiguration; +import org.dinky.data.model.rbac.User; +import org.dinky.data.result.Result; import org.dinky.mapper.SysConfigMapper; import org.dinky.mybatis.service.impl.SuperServiceImpl; import org.dinky.service.SysConfigService; +import org.dinky.service.UserService; +import org.dinky.utils.TextUtil; import java.util.HashMap; import java.util.List; @@ -37,8 +41,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.activerecord.Model; +import cn.dev33.satoken.secure.SaSecureUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; /** @@ -48,8 +54,11 @@ */ @Service @Slf4j +@RequiredArgsConstructor public class SysConfigServiceImpl extends SuperServiceImpl implements SysConfigService { + private final UserService userService; + @Override public Map>> getAll() { return SystemConfiguration.getInstances().getAllConfiguration(); @@ -121,4 +130,59 @@ public void updateSysConfigByKv(String key, String value) { initExpressionVariables(); } } + + @Override + public Result> getNeededCfg() { + Map result = new HashMap<>(); + + SystemConfiguration instances = SystemConfiguration.getInstances(); + + Configuration isFirstSystemIn = instances.getIsFirstSystemIn(); + Configuration ldapEnable = instances.getLdapEnable(); + + result.put(isFirstSystemIn.getKey(), isFirstSystemIn.getValue()); + result.put(ldapEnable.getKey(), ldapEnable.getValue()); + + if (isFirstSystemIn.getValue()) { + result.put( + instances.getDinkyAddr().getKey(), instances.getDinkyAddr().getValue()); + result.put( + instances.getTaskOwnerLockStrategy().getKey(), + instances.getTaskOwnerLockStrategy().getValue()); + result.put( + instances.getJobIdWait().getKey(), instances.getJobIdWait().getValue()); + result.put( + instances.getUseFlinkHistoryServer().getKey(), + instances.getUseFlinkHistoryServer().getValue()); + result.put( + instances.getFlinkHistoryServerPort().getKey(), + instances.getFlinkHistoryServerPort().getValue()); + } + return Result.succeed(result); + } + + @Override + public Result setInitConfig(Map params) { + SystemConfiguration instances = SystemConfiguration.getInstances(); + Configuration isFirstSystemIn = instances.getIsFirstSystemIn(); + + if (!isFirstSystemIn.getValue()) { + return Result.failed("not first init"); + } + + if (params.containsKey("password")) { + String password = params.remove("password").toString(); + if (!TextUtil.isEmpty(password)) { + User admin = userService.getUserByUsername("admin"); + admin.setPassword(SaSecureUtil.md5(password)); + userService.modifyUser(admin); + } + } + + for (Map.Entry entry : params.entrySet()) { + updateSysConfigByKv(entry.getKey(), entry.getValue().toString()); + } + updateSysConfigByKv(instances.getIsFirstSystemIn().getKey(), String.valueOf(false)); + return Result.succeed(); + } } diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java index a87d3a1d69..a99ee03c3e 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java @@ -1088,10 +1088,10 @@ public List getUserTasks(Integer userId) { private Boolean hasTaskOperatePermission(Integer firstLevelOwner, List secondLevelOwners) { boolean isFirstLevelOwner = firstLevelOwner != null && firstLevelOwner == StpUtil.getLoginIdAsInt(); if (TaskOwnerLockStrategyEnum.OWNER.equals( - SystemConfiguration.getInstances().getTaskOwnerLockStrategy())) { + SystemConfiguration.getInstances().GetTaskOwnerLockStrategyValue())) { return isFirstLevelOwner; } else if (TaskOwnerLockStrategyEnum.OWNER_AND_MAINTAINER.equals( - SystemConfiguration.getInstances().getTaskOwnerLockStrategy())) { + SystemConfiguration.getInstances().GetTaskOwnerLockStrategyValue())) { return isFirstLevelOwner || (secondLevelOwners != null && secondLevelOwners.contains(StpUtil.getLoginIdAsInt())); } diff --git a/dinky-common/src/main/java/org/dinky/data/enums/Status.java b/dinky-common/src/main/java/org/dinky/data/enums/Status.java index e047e8db74..24f516a9a9 100644 --- a/dinky-common/src/main/java/org/dinky/data/enums/Status.java +++ b/dinky-common/src/main/java/org/dinky/data/enums/Status.java @@ -332,6 +332,8 @@ public enum Status { /** * system config */ + SYS_GLOBAL_IS_FIRST(99, "sys.global.isFirst"), + SYS_FLINK_SETTINGS_USERESTAPI(100, "sys.flink.settings.useRestAPI"), SYS_FLINK_SETTINGS_USERESTAPI_NOTE(101, "sys.flink.settings.useRestAPI.note"), SYS_FLINK_SETTINGS_JOBIDWAIT(104, "sys.flink.settings.jobIdWait"), diff --git a/dinky-common/src/main/java/org/dinky/data/model/SystemConfiguration.java b/dinky-common/src/main/java/org/dinky/data/model/SystemConfiguration.java index 5ef4aa6c84..85ec79ce52 100644 --- a/dinky-common/src/main/java/org/dinky/data/model/SystemConfiguration.java +++ b/dinky-common/src/main/java/org/dinky/data/model/SystemConfiguration.java @@ -70,6 +70,9 @@ public static Configuration.OptionBuilder key(Status status) { .map(f -> (Configuration) ReflectUtil.getFieldValue(systemConfiguration, f)) .collect(Collectors.toList()); + private final Configuration isFirstSystemIn = + key(Status.SYS_GLOBAL_IS_FIRST).booleanType().defaultValue(true); + private final Configuration useRestAPI = key(Status.SYS_FLINK_SETTINGS_USERESTAPI) .booleanType() .defaultValue(true) @@ -391,7 +394,7 @@ public boolean isUseRestAPI() { return Asserts.isNull(useRestAPI.getValue()) ? useRestAPI.getDefaultValue() : useRestAPI.getValue(); } - public int getJobIdWait() { + public int GetJobIdWaitValue() { return jobIdWait.getValue(); } @@ -428,7 +431,7 @@ public OssProperties getOssProperties() { .build(); } - public TaskOwnerLockStrategyEnum getTaskOwnerLockStrategy() { + public TaskOwnerLockStrategyEnum GetTaskOwnerLockStrategyValue() { return taskOwnerLockStrategy.getValue(); } diff --git a/dinky-common/src/main/java/org/dinky/utils/I18n.java b/dinky-common/src/main/java/org/dinky/utils/I18n.java index fdc268a630..9d6e7a1918 100644 --- a/dinky-common/src/main/java/org/dinky/utils/I18n.java +++ b/dinky-common/src/main/java/org/dinky/utils/I18n.java @@ -56,6 +56,9 @@ public static void setLocale(Locale l) { public static String getMessage(String key) { ResourceBundle bundle = ResourceBundle.getBundle(MESSAGES_BASE); + if (!bundle.containsKey(key)) { + return key; + } String message = bundle.getString(key); if (!JDK_ABOVE_1_8) { message = new String(message.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); diff --git a/dinky-gateway/src/main/java/org/dinky/gateway/kubernetes/KubernetesApplicationGateway.java b/dinky-gateway/src/main/java/org/dinky/gateway/kubernetes/KubernetesApplicationGateway.java index 3e96aa2e50..3132fea281 100644 --- a/dinky-gateway/src/main/java/org/dinky/gateway/kubernetes/KubernetesApplicationGateway.java +++ b/dinky-gateway/src/main/java/org/dinky/gateway/kubernetes/KubernetesApplicationGateway.java @@ -201,7 +201,7 @@ public KubernetesResult waitForJmAndJobStart( KubernetesClient kubernetesClient, Deployment deployment, ClusterClientProvider clusterClient) throws InterruptedException { KubernetesResult result = KubernetesResult.build(getType()); - long waitSends = SystemConfiguration.getInstances().getJobIdWait() * 1000L; + long waitSends = SystemConfiguration.getInstances().GetJobIdWaitValue() * 1000L; long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < waitSends) { @@ -262,7 +262,7 @@ public KubernetesResult waitForJmAndJobStartByIngress( KubernetesClient kubernetesClient, Deployment deployment, ClusterClientProvider clusterClient) throws InterruptedException { KubernetesResult result = KubernetesResult.build(getType()); - long waitSends = SystemConfiguration.getInstances().getJobIdWait() * 1000L; + long waitSends = SystemConfiguration.getInstances().GetJobIdWaitValue() * 1000L; long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < waitSends) { diff --git a/dinky-gateway/src/main/java/org/dinky/gateway/yarn/YarnGateway.java b/dinky-gateway/src/main/java/org/dinky/gateway/yarn/YarnGateway.java index 13d69af6ab..d2d820d3ca 100644 --- a/dinky-gateway/src/main/java/org/dinky/gateway/yarn/YarnGateway.java +++ b/dinky-gateway/src/main/java/org/dinky/gateway/yarn/YarnGateway.java @@ -380,7 +380,7 @@ protected YarnClusterDescriptor createInitYarnClusterDescriptor() { protected String getWebUrl(ClusterClient clusterClient, YarnResult result) throws YarnException, IOException, InterruptedException { String webUrl; - int counts = SystemConfiguration.getInstances().getJobIdWait(); + int counts = SystemConfiguration.getInstances().GetJobIdWaitValue(); while (yarnClient.getApplicationReport(clusterClient.getClusterId()).getYarnApplicationState() == YarnApplicationState.ACCEPTED && counts-- > 0) { diff --git a/dinky-web/config/routes.ts b/dinky-web/config/routes.ts index 9c7b6976bd..c742b829f8 100644 --- a/dinky-web/config/routes.ts +++ b/dinky-web/config/routes.ts @@ -29,6 +29,12 @@ * todo: 如何引入自定义 icon */ export default [ + { + path: '/welcom', + component: './Other/Welcom', + layout: false, + hideInMenu: true + }, { path: '/user', layout: false, diff --git a/dinky-web/src/components/Icons/WelcomIcons.tsx b/dinky-web/src/components/Icons/WelcomIcons.tsx new file mode 100644 index 0000000000..53029e0d14 --- /dev/null +++ b/dinky-web/src/components/Icons/WelcomIcons.tsx @@ -0,0 +1,2445 @@ +/* + * + * 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 Icon from '@ant-design/icons'; + +const defaultSvgSize = '100%'; + +export const Congratulations = (props: { size?: number }) => { + const size = props.size || defaultSvgSize; + return ( + <> + ( + + + + + + + + + + + + + + + + + + + )} + /> + + ); +}; + +export const Magic = (props: { size?: number }) => { + const size = props.size || defaultSvgSize; + return ( + <> + ( + + + + + + + + + + + + + + )} + /> + + ); +}; + +export const WelcomPic1 = (props: { size?: number }) => { + const size = props.size || defaultSvgSize; + return ( + <> + ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + )} + /> + + ); +}; diff --git a/dinky-web/src/locales/en-US.ts b/dinky-web/src/locales/en-US.ts index fec5393c05..e94eb74f5d 100644 --- a/dinky-web/src/locales/en-US.ts +++ b/dinky-web/src/locales/en-US.ts @@ -24,6 +24,7 @@ import pwa from './en-US/pwa'; import request from './en-US/request'; import response from './en-US/response'; import shortcutKey from './en-US/shortcutKey'; +import welcom from '@/locales/en-US/welcom'; export default { 'navBar.lang': 'Languages', @@ -37,5 +38,6 @@ export default { ...pages, ...request, ...response, - ...shortcutKey + ...shortcutKey, + ...welcom }; diff --git a/dinky-web/src/locales/en-US/welcom.ts b/dinky-web/src/locales/en-US/welcom.ts new file mode 100644 index 0000000000..7a22683c79 --- /dev/null +++ b/dinky-web/src/locales/en-US/welcom.ts @@ -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. + * + */ + +export default { + 'welcom.welcom': 'Welcome to Dinky!', + 'welcom.welcom.content': + 'A next-generation real-time computing platform that is deeply customized for Apache Flink, providing agile Flink SQL and Flink Jar job development', + 'welcom.welcom.content.tip1': "This looks like it's your first time logging into Dinky", + 'welcom.welcom.content.tip2': + "Don't worry, we only need a few simple guides to enjoy the Dinky tour!", + 'welcom.welcom.setPwd.tip': 'Set the admin password', + 'welcom.welcom.setPwd': 'Set the password', + 'welcom.welcom.skip': 'Skip this step', + + 'welcom.next': 'Next', + 'welcom.prev': 'Previous', + 'welcom.submit': 'Submit', + 'welcom.finish.title': 'Init Finished!', + 'welcom.finish': 'Start your Dinky journey today!', + + 'welcom.goLogin': 'Go Login!', + 'welcom.base.config.title': 'Base Config', + 'welcom.base.config.dinky.url.title': 'Dinky address:', + 'welcom.base.config.dinky.url': + 'Make sure that the external service address of dinky can be accessed in the k8s or yarn cluster, otherwise the status of the application task may not be monitored', + 'welcom.tips': + "If you are still unsure about how to enter the parameters, don't worry, leave them as default, and you can go to the configuration center at any time to modify them", + 'welcom.base.config.taskowner.title': 'Task owner type:', + 'welcom.base.config.taskowner': + 'When [OWNER] is selected, only the job owner can operate the job, and no other user can operate the modify job,\\n When [OWNER_AND_MAINTAINER] is selected,\\n Both the job owner and the maintainer can operate the modification job, and when [ALL] is selected, everyone can operate the modification job, which is [ALL] by default.', + + 'welcom.flink.config.title': 'Flink Config', + 'welcom.flink.config.jobwait.title': 'Job wait time:', + 'welcom.flink.config.jobwait': + 'The maximum wait time (seconds) to get the Job ID\\n when submitting an Application or PerJob task, and if the job is submitted slowly, you need to increase this value', + 'welcom.flink.config.useHistoryServer.title': 'Use Flink History Server:', + 'welcom.flink.config.useHistoryServer': + 'This feature will have a built-in Flink History Server in Dinky, which is used to query the history of Flink tasks, so that Flink tasks can reduce the UNKNOWN status and input the last status information of Flink tasks', + 'welcom.flink.config.historyPort.title': 'Flink History Server Port:', + 'welcom.flink.config.historyPort': + 'The built-in Flink History Server port, for example, 8082, ensures that the port is not occupied' +}; diff --git a/dinky-web/src/locales/zh-CN.ts b/dinky-web/src/locales/zh-CN.ts index ccfa1c8060..6c915ec32a 100644 --- a/dinky-web/src/locales/zh-CN.ts +++ b/dinky-web/src/locales/zh-CN.ts @@ -24,6 +24,7 @@ import pwa from './zh-CN/pwa'; import request from './zh-CN/request'; import response from './zh-CN/response'; import shortcutKey from './zh-CN/shortcutKey'; +import welcom from '@/locales/zh-CN/welcom'; export default { 'navBar.lang': '语言', @@ -37,5 +38,6 @@ export default { ...pwa, ...request, ...response, - ...shortcutKey + ...shortcutKey, + ...welcom }; diff --git a/dinky-web/src/locales/zh-CN/welcom.ts b/dinky-web/src/locales/zh-CN/welcom.ts new file mode 100644 index 0000000000..9ffe555d58 --- /dev/null +++ b/dinky-web/src/locales/zh-CN/welcom.ts @@ -0,0 +1,55 @@ +/* + * + * 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 { + 'welcom.welcom': '欢迎来到Dinky!', + 'welcom.welcom.content': + '为 Apache Flink 深度定制的新一代实时计算平台,提供敏捷的 Flink SQL, Flink Jar 作业开发、\n 部署及监控能力,助力实时计算高效应用。', + 'welcom.welcom.content.tip1': '这看起来好像是你第一次登入Dinky', + 'welcom.welcom.content.tip2': '别担心,我们只需要几步简单的向导即可畅享Dinky之旅!', + 'welcom.welcom.setPwd.tip': '设置admin密码:', + 'welcom.welcom.setPwd': '设置密码', + 'welcom.welcom.skip': '跳过此步骤', + + 'welcom.next': '下一步', + 'welcom.prev': '上一步', + 'welcom.submit': '提交', + 'welcom.finish.title': '初始化完成!', + 'welcom.finish': '立即开始你的Dinky之旅吧!', + + 'welcom.goLogin': '去登陆!', + 'welcom.base.config.title': '基本配置', + 'welcom.base.config.dinky.url.title': 'Dinky地址:', + 'welcom.base.config.dinky.url': + 'dinky对外服务地址,请确保k8s或yarn集群内可以正常访问此地址,否则对于Application任务可能会无法正常监控状态', + 'welcom.tips': '如果您还不清楚参数如何填写,不要担心,保持默认,后续可以随时前往配置中心进行修改', + 'welcom.base.config.taskowner.title': '作业责任人锁机制:', + 'welcom.base.config.taskowner': + '当选择[OWNER]时,只有作业责任人才能操作作业,其他用户无法操作/修改作业,\n 当选择[OWNER_AND_MAINTAINER]时,\n 作业责任人和维护人都可以操作/修改作业, 当选择[ALL]时,所有人都可以操作/修改作业, 默认为[ALL]', + + 'welcom.flink.config.title': 'Flink配置', + 'welcom.flink.config.jobwait.title': 'Job 提交等待时间:', + 'welcom.flink.config.jobwait': + '提交 Application 或 PerJob 任务时获取 Job ID\n 的最大等待时间(秒),如果作业提交较慢,需要增大此数值', + 'welcom.flink.config.useHistoryServer.title': '使用内置 Flink History Server:', + 'welcom.flink.config.useHistoryServer': + '此功能会在 Dinky 里面内置一个Flink History Server ,作用于 Flink 任务的历史查询,\n 使 Flink 任务减少 UNKNOWN 状态的情况,并打入 Flink 任务最后的状态信息', + 'welcom.flink.config.historyPort.title': 'Flink History Server 端口:', + 'welcom.flink.config.historyPort': '内置Flink History Server 端口,例如:8082,确保端口没有被占用' +}; diff --git a/dinky-web/src/pages/Other/Login/LoginForm/index.tsx b/dinky-web/src/pages/Other/Login/LoginForm/index.tsx index 8b05465ab6..22d73801e4 100644 --- a/dinky-web/src/pages/Other/Login/LoginForm/index.tsx +++ b/dinky-web/src/pages/Other/Login/LoginForm/index.tsx @@ -17,17 +17,19 @@ * */ -import { getData } from '@/services/api'; import { API_CONSTANTS } from '@/services/endpoints'; import { l } from '@/utils/intl'; import { GithubOutlined, LockOutlined, UserOutlined } from '@ant-design/icons'; import { DefaultFooter, ProForm, ProFormCheckbox, ProFormText } from '@ant-design/pro-components'; import { SubmitterProps } from '@ant-design/pro-form/es/components'; import { Col, Flex, Row } from 'antd'; -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import style from '../../../../global.less'; import Lottie from 'react-lottie'; import DataPlatform from '../../../../../public/login_animation.json'; +import { useRequest } from '@@/exports'; +import { history } from '@umijs/max'; +import { GLOBAL_SETTING_KEYS } from '@/types/SettingCenter/data.d'; type LoginFormProps = { onSubmit: (values: any) => Promise; @@ -41,15 +43,15 @@ const LoginForm: React.FC = (props) => { const [submitting, setSubmitting] = useState(false); const [ldapEnabled, setLdapEnabled] = useState(false); - useEffect(() => { - getData(API_CONSTANTS.GET_LDAP_ENABLE).then( - (res) => { - setLdapEnabled(res.data); - form.setFieldValue('ldapLogin', res.data); - }, - (err) => console.error(err) - ); - }, []); + useRequest(API_CONSTANTS.GET_NEEDED_CFG, { + onSuccess: (res) => { + if (res[GLOBAL_SETTING_KEYS.SYS_GLOBAL_ISFIRST]) { + history.push('/welcom'); + } + setLdapEnabled(res[GLOBAL_SETTING_KEYS.SYS_LDAP_SETTINGS_ENABLE]); + form.setFieldValue('ldapLogin', res[GLOBAL_SETTING_KEYS.SYS_LDAP_SETTINGS_ENABLE]); + } + }); const handleClickLogin = async () => { setSubmitting(true); diff --git a/dinky-web/src/pages/Other/Welcom/WelcomItem/BaseConfigItem.tsx b/dinky-web/src/pages/Other/Welcom/WelcomItem/BaseConfigItem.tsx new file mode 100644 index 0000000000..b0975a4c42 --- /dev/null +++ b/dinky-web/src/pages/Other/Welcom/WelcomItem/BaseConfigItem.tsx @@ -0,0 +1,68 @@ +/* + * + * 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 { Button, Flex, Input, Radio, Space, Typography } from 'antd'; + +import { WelcomPic1 } from '@/components/Icons/WelcomIcons'; +import FormItem from 'antd/es/form/FormItem'; +import { WelcomProps } from '@/pages/Other/Welcom'; +import { l } from '@/utils/intl'; + +const { Title, Text, Link } = Typography; + +const BaseConfigItem = (prop: WelcomProps) => { + return ( + +
+ + {l('welcom.base.config.title')} + +
+ {l('welcom.tips')} +
+
+ + + {l('welcom.base.config.dinky.url')} + + + + + + + {l('welcom.base.config.taskowner')} +
+ + + OWNER + OWNER_AND_MAINTAINER + ALL + + +
+ + {l('welcom.prev')} +
+ +
+ ); +}; +export default BaseConfigItem; diff --git a/dinky-web/src/pages/Other/Welcom/WelcomItem/FinishPage.tsx b/dinky-web/src/pages/Other/Welcom/WelcomItem/FinishPage.tsx new file mode 100644 index 0000000000..1514ce8099 --- /dev/null +++ b/dinky-web/src/pages/Other/Welcom/WelcomItem/FinishPage.tsx @@ -0,0 +1,37 @@ +/* + * + * 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 { Button, Result } from 'antd'; +import { l } from '@/utils/intl'; + +const FinishPage = () => { + return ( + (window.location.href = '/login')}> + {l('welcom.goLogin')} + + ]} + /> + ); +}; +export default FinishPage; diff --git a/dinky-web/src/pages/Other/Welcom/WelcomItem/FlinkConfigItem.tsx b/dinky-web/src/pages/Other/Welcom/WelcomItem/FlinkConfigItem.tsx new file mode 100644 index 0000000000..c930ee49ac --- /dev/null +++ b/dinky-web/src/pages/Other/Welcom/WelcomItem/FlinkConfigItem.tsx @@ -0,0 +1,79 @@ +/* + * + * 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 { Flex, Input, Space, Switch, Typography } from 'antd'; + +import { WelcomPic1 } from '@/components/Icons/WelcomIcons'; +import FormItem from 'antd/es/form/FormItem'; +import { WelcomProps } from '@/pages/Other/Welcom'; +import { LoadingBtn } from '@/components/CallBackButton/LoadingBtn'; +import { l } from '@/utils/intl'; + +const { Title, Text, Link } = Typography; + +const FlinkConfigItem = (prop: WelcomProps) => { + return ( + +
+ + {l('welcom.flink.config.title')} + +
+ {l('welcom.tips')} +
+
+ + + {l('welcom.flink.config.jobwait')} + + + + + + + {l('welcom.flink.config.useHistoryServer')} +
+ + + +
+ + + {l('welcom.flink.config.historyPort')} + + + + + + await prop.onSubmit?.()} + /> + + {l('welcom.prev')} +
+ +
+ ); +}; +export default FlinkConfigItem; diff --git a/dinky-web/src/pages/Other/Welcom/WelcomItem/WelcomItem.tsx b/dinky-web/src/pages/Other/Welcom/WelcomItem/WelcomItem.tsx new file mode 100644 index 0000000000..7204e8c853 --- /dev/null +++ b/dinky-web/src/pages/Other/Welcom/WelcomItem/WelcomItem.tsx @@ -0,0 +1,66 @@ +/* + * + * 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 { Button, Flex, Input, Space, Typography } from 'antd'; +import { Congratulations, WelcomPic1 } from '@/components/Icons/WelcomIcons'; +import FormItem from 'antd/es/form/FormItem'; +import { WelcomProps } from '@/pages/Other/Welcom'; +import { l } from '@/utils/intl'; + +const { Title, Text, Link } = Typography; + +const WelcomItem = (prop: WelcomProps) => { + return ( + +
+ + + {l('welcom.welcom')} + +
+ {l('welcom.welcom.content')} +
+
+ {l('welcom.welcom.content.tip1')} +
+ {l('welcom.welcom.content.tip2')} + + {l('welcom.welcom.setPwd.tip')} + + + + + + + prop.onNext()}>{l('welcom.welcom.skip')} + +
+ +
+ ); +}; +export default WelcomItem; diff --git a/dinky-web/src/pages/Other/Welcom/index.tsx b/dinky-web/src/pages/Other/Welcom/index.tsx new file mode 100644 index 0000000000..f0363e34e6 --- /dev/null +++ b/dinky-web/src/pages/Other/Welcom/index.tsx @@ -0,0 +1,90 @@ +/* + * + * 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 { Flex, Form } from 'antd'; +import { useState } from 'react'; +import WelcomItem from '@/pages/Other/Welcom/WelcomItem/WelcomItem'; +import BaseConfigItem from '@/pages/Other/Welcom/WelcomItem/BaseConfigItem'; +import FlinkConfigItem from '@/pages/Other/Welcom/WelcomItem/FlinkConfigItem'; +import FinishPage from '@/pages/Other/Welcom/WelcomItem/FinishPage'; +import { log } from '@antv/g6/lib/utils/scale'; +import { history, useRequest } from '@@/exports'; +import { API_CONSTANTS } from '@/services/endpoints'; +import { GLOBAL_SETTING_KEYS } from '@/types/SettingCenter/data'; +import { postAll } from '@/services/api'; +import { sleep } from '@antfu/utils'; + +const boxStyle: React.CSSProperties = { + width: '100%', + height: '100%', + borderRadius: 6 +}; + +export type WelcomProps = { + onNext: () => void; + onPrev: () => void; + onSubmit?: () => void; +}; + +const Welcom = () => { + const [form] = Form.useForm(); + const [formData, setFormData] = useState({}); + const [current, setCurrent] = useState(0); + + const { data, loading } = useRequest(API_CONSTANTS.GET_NEEDED_CFG); + + const setCfgReq = useRequest((params) => postAll(API_CONSTANTS.SET_INIT_CFG, params), { + manual: true + }); + + const next = () => { + setFormData((prev) => { + return { ...prev, ...form.getFieldsValue() }; + }); + setCurrent(current + 1); + }; + const prev = () => { + setCurrent(current - 1); + }; + + const submit = async () => { + const data = { ...formData, ...form.getFieldsValue() }; + await setCfgReq.run(data); + next(); + }; + + return ( + +
+ {loading ? ( +
loading
+ ) : ( +
+ {current == 0 && } + {current == 1 && } + {current == 2 && } + {current == 3 && } + + )} +
+
+ ); +}; + +export default Welcom; diff --git a/dinky-web/src/services/endpoints.tsx b/dinky-web/src/services/endpoints.tsx index b42731dbd5..33c4d60293 100644 --- a/dinky-web/src/services/endpoints.tsx +++ b/dinky-web/src/services/endpoints.tsx @@ -176,6 +176,9 @@ export enum API_CONSTANTS { /** -------------------------------------------- setting center ------------------------------------------------ */ // ------------------------------------ system settings ------------------------------------ + GET_NEEDED_CFG = '/api/sysConfig/getNeededCfg', + SET_INIT_CFG = '/api/sysConfig/setInitConfig', + SYSTEM_GET_ALL_CONFIG = '/api/sysConfig/getAll', SYSTEM_GET_ONE_TYPE_CONFIG = '/api/sysConfig/getConfigByType', SYSTEM_MODIFY_CONFIG = '/api/sysConfig/modifyConfig', @@ -225,7 +228,6 @@ export enum API_CONSTANTS { ALERT_HISTORY_DELETE = '/api/alertHistory/delete', // ----------------------------------------- ldap ------------------------------------ - GET_LDAP_ENABLE = '/api/ldap/ldapEnableStatus', LDAP_TEST_CONNECT = '/api/ldap/testConnection', LDAP_TEST_LOGIN = '/api/ldap/testLogin', LDAP_LIST_USER = '/api/ldap/listUser', diff --git a/dinky-web/src/types/SettingCenter/data.d.ts b/dinky-web/src/types/SettingCenter/data.d.ts index 634dc55858..5f2f2c7701 100644 --- a/dinky-web/src/types/SettingCenter/data.d.ts +++ b/dinky-web/src/types/SettingCenter/data.d.ts @@ -112,6 +112,7 @@ export enum TaskOwnerLockingStrategy { * 全局配置所有的 key */ export enum GLOBAL_SETTING_KEYS { + SYS_GLOBAL_ISFIRST = 'sys.global.isFirst', SYS_FLINK_SETTINGS_USE_REST_API = 'sys.flink.settings.useRestAPI', SYS_FLINK_SETTINGS_JOB_ID_WAIT = 'sys.flink.settings.jobIdWait', SYS_MAVEN_SETTINGS_SETTINGS_FILE_PATH = 'sys.maven.settings.settingsFilePath',