Commit 3bf91a3f authored by wenmo's avatar wenmo

修复 批量启用禁用集群、关闭tab无法更新位置及无法取消FlinkSQLEnv的bug

parent 983bbecb
...@@ -97,9 +97,9 @@ Dinky(原 Dlink): ...@@ -97,9 +97,9 @@ Dinky(原 Dlink):
### 版本 ### 版本
抢先体验( main 主支):dlink-0.5.0-SNAPSHOT 抢先体验( main 主支):dlink-0.6.0-SNAPSHOT
稳定版本( 0.4.0 分支):dlink-0.4.0 稳定版本( 0.5.0 分支):dlink-0.5.0
### 从安装包开始 ### 从安装包开始
......
...@@ -39,6 +39,15 @@ public class ClusterController { ...@@ -39,6 +39,15 @@ public class ClusterController {
return Result.succeed(Asserts.isNotNull(cluster.getId())?"修改成功":"新增成功"); return Result.succeed(Asserts.isNotNull(cluster.getId())?"修改成功":"新增成功");
} }
/**
* 启用和禁用
*/
@PutMapping("/enable")
public Result enableCluster(@RequestBody Cluster cluster) throws Exception {
clusterService.enableCluster(cluster);
return Result.succeed("修改成功");
}
/** /**
* 动态查询列表 * 动态查询列表
*/ */
......
...@@ -32,5 +32,7 @@ public interface ClusterService extends ISuperService<Cluster> { ...@@ -32,5 +32,7 @@ public interface ClusterService extends ISuperService<Cluster> {
Cluster registersCluster(Cluster cluster); Cluster registersCluster(Cluster cluster);
boolean enableCluster(Cluster cluster);
int clearCluster(); int clearCluster();
} }
...@@ -95,6 +95,14 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster> ...@@ -95,6 +95,14 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
return cluster; return cluster;
} }
@Override
public boolean enableCluster(Cluster cluster) {
Cluster clusterInfo = getById(cluster);
clusterInfo.setEnabled(cluster.getEnabled());
checkHealth(clusterInfo);
return updateById(clusterInfo);
}
@Override @Override
public int clearCluster() { public int clearCluster() {
List<Cluster> clusters = listAutoEnable(); List<Cluster> clusters = listAutoEnable();
......
...@@ -64,7 +64,7 @@ public class StudioServiceImpl implements StudioService { ...@@ -64,7 +64,7 @@ public class StudioServiceImpl implements StudioService {
private TaskService taskService; private TaskService taskService;
private void addFlinkSQLEnv(AbstractStatementDTO statementDTO){ private void addFlinkSQLEnv(AbstractStatementDTO statementDTO){
if(Asserts.isNotNull(statementDTO.getEnvId())){ if(Asserts.isNotNull(statementDTO.getEnvId())&&statementDTO.getEnvId()!=0){
Task task = taskService.getTaskInfoById(statementDTO.getEnvId()); Task task = taskService.getTaskInfoById(statementDTO.getEnvId());
if(Asserts.isNotNull(task)&&Asserts.isNotNullString(task.getStatement())) { if(Asserts.isNotNull(task)&&Asserts.isNotNullString(task.getStatement())) {
statementDTO.setStatement(task.getStatement() + "\r\n" + statementDTO.getStatement()); statementDTO.setStatement(task.getStatement() + "\r\n" + statementDTO.getStatement());
......
...@@ -167,7 +167,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -167,7 +167,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private JobConfig buildJobConfig(Task task){ private JobConfig buildJobConfig(Task task){
boolean isJarTask = isJarTask(task); boolean isJarTask = isJarTask(task);
if(!isJarTask&&Asserts.isNotNull(task.getEnvId())){ if(!isJarTask&&Asserts.isNotNull(task.getEnvId())&&task.getEnvId()!=0){
Task envTask = getTaskInfoById(task.getEnvId()); Task envTask = getTaskInfoById(task.getEnvId());
if(Asserts.isNotNull(envTask)&&Asserts.isNotNullString(envTask.getStatement())) { if(Asserts.isNotNull(envTask)&&Asserts.isNotNullString(envTask.getStatement())) {
task.setStatement(envTask.getStatement() + "\r\n" + task.getStatement()); task.setStatement(envTask.getStatement() + "\r\n" + task.getStatement());
......
...@@ -50,7 +50,9 @@ const StudioSetting = (props: any) => { ...@@ -50,7 +50,9 @@ const StudioSetting = (props: any) => {
}; };
const getEnvOptions = () => { const getEnvOptions = () => {
const itemList = []; const itemList = [<Option key={0} value={0} label='无'>
</Option>];
for (const item of env) { for (const item of env) {
const tag = (<>{item.enabled ? <Badge status="success"/> : <Badge status="error"/>} const tag = (<>{item.enabled ? <Badge status="success"/> : <Badge status="error"/>}
{item.fragment ? <PaperClipOutlined /> : undefined}{item.alias}</>); {item.fragment ? <PaperClipOutlined /> : undefined}{item.alias}</>);
...@@ -188,6 +190,7 @@ const StudioSetting = (props: any) => { ...@@ -188,6 +190,7 @@ const StudioSetting = (props: any) => {
placeholder="选择 FlinkSQL 环境,非必填" placeholder="选择 FlinkSQL 环境,非必填"
allowClear allowClear
optionLabelProp="label" optionLabelProp="label"
defaultValue={0} value={0}
> >
{getEnvOptions()} {getEnvOptions()}
</Select> </Select>
......
...@@ -5,6 +5,7 @@ import {StateType} from '@/pages/FlinkSqlStudio/model'; ...@@ -5,6 +5,7 @@ import {StateType} from '@/pages/FlinkSqlStudio/model';
import styles from './index.less'; import styles from './index.less';
import StudioEdit from '../StudioEdit'; import StudioEdit from '../StudioEdit';
import {DIALECT} from '../conf'; import {DIALECT} from '../conf';
import StudioHome from "@/components/Studio/StudioHome";
const {TabPane} = Tabs; const {TabPane} = Tabs;
...@@ -105,6 +106,8 @@ const EditorTabs = (props: any) => { ...@@ -105,6 +106,8 @@ const EditorTabs = (props: any) => {
); );
return ( return (
<>
{tabs.panes.length === 0?<StudioHome width={width} />:
<Tabs <Tabs
hideAdd hideAdd
type="editable-card" type="editable-card"
...@@ -125,7 +128,8 @@ const EditorTabs = (props: any) => { ...@@ -125,7 +128,8 @@ const EditorTabs = (props: any) => {
/> />
</TabPane> </TabPane>
))} ))}
</Tabs> </Tabs>}
</>
); );
}; };
......
...@@ -126,7 +126,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -126,7 +126,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
setAvailable(true); setAvailable(true);
},200); },200);
if(node?.isLeaf&&node.taskId) { if(node?.isLeaf&&node.taskId) {
// @ts-ignore
for(let item of tabs.panes){ for(let item of tabs.panes){
if(item.key==node.taskId){ if(item.key==node.taskId){
dispatch&&dispatch({ dispatch&&dispatch({
......
...@@ -17,11 +17,10 @@ import { ...@@ -17,11 +17,10 @@ import {
import {loadSettings} from "@/pages/Settings/function"; import {loadSettings} from "@/pages/Settings/function";
import DraggleLayout from "@/components/DraggleLayout"; import DraggleLayout from "@/components/DraggleLayout";
import DraggleVerticalLayout from "@/components/DraggleLayout/DraggleVerticalLayout"; import DraggleVerticalLayout from "@/components/DraggleLayout/DraggleVerticalLayout";
import {Dispatch} from "@@/plugin-dva/connect";
const Studio = (props: any) => { const Studio = (props: any) => {
const {rightClickMenu, toolHeight, toolLeftWidth,toolRightWidth,tabs,current, dispatch} = props; const {rightClickMenu, toolHeight, toolLeftWidth,toolRightWidth,dispatch} = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const VIEW = { const VIEW = {
leftToolWidth: 300, leftToolWidth: 300,
...@@ -51,15 +50,17 @@ const Studio = (props: any) => { ...@@ -51,15 +50,17 @@ const Studio = (props: any) => {
}; };
}, [onResize]); }, [onResize]);
loadSettings(dispatch); useEffect(() => {
getFillAllByVersion('', dispatch); loadSettings(dispatch);
showCluster(dispatch); getFillAllByVersion('', dispatch);
showSessionCluster(dispatch); showCluster(dispatch);
showClusterConfiguration(dispatch); showSessionCluster(dispatch);
showDataBase(dispatch); showClusterConfiguration(dispatch);
listSession(dispatch); showDataBase(dispatch);
showJars(dispatch); listSession(dispatch);
showEnv(dispatch); showJars(dispatch);
showEnv(dispatch);
}, []);
const onClick = () => { const onClick = () => {
if (rightClickMenu) { if (rightClickMenu) {
...@@ -133,7 +134,7 @@ const Studio = (props: any) => { ...@@ -133,7 +134,7 @@ const Studio = (props: any) => {
}}/> }}/>
</Col> </Col>
<Col> <Col>
{tabs.panes.length === 0 ?<StudioHome width={size.width - toolRightWidth - toolLeftWidth} />:<StudioTabs width={size.width - toolRightWidth - toolLeftWidth}/>} <StudioTabs width={size.width - toolRightWidth - toolLeftWidth}/>
</Col> </Col>
</DraggleLayout> </DraggleLayout>
<Col id='StudioRightTool' className={styles["vertical-tabs"]}> <Col id='StudioRightTool' className={styles["vertical-tabs"]}>
...@@ -158,6 +159,4 @@ export default connect(({Studio}: { Studio: StateType }) => ({ ...@@ -158,6 +159,4 @@ export default connect(({Studio}: { Studio: StateType }) => ({
toolHeight: Studio.toolHeight, toolHeight: Studio.toolHeight,
toolLeftWidth: Studio.toolLeftWidth, toolLeftWidth: Studio.toolLeftWidth,
toolRightWidth: Studio.toolRightWidth, toolRightWidth: Studio.toolRightWidth,
tabs: Studio.tabs,
current: Studio.current,
}))(Studio); }))(Studio);
...@@ -367,7 +367,7 @@ const ClusterTableList: React.FC<{}> = (props: any) => { ...@@ -367,7 +367,7 @@ const ClusterTableList: React.FC<{}> = (props: any) => {
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onOk: async () => { onOk: async () => {
await updateEnabled(url, selectedRowsState, true); await updateEnabled(url+'/enable', selectedRowsState, true);
setSelectedRows([]); setSelectedRows([]);
actionRef.current?.reloadAndRest?.(); actionRef.current?.reloadAndRest?.();
} }
...@@ -382,7 +382,7 @@ const ClusterTableList: React.FC<{}> = (props: any) => { ...@@ -382,7 +382,7 @@ const ClusterTableList: React.FC<{}> = (props: any) => {
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onOk: async () => { onOk: async () => {
await updateEnabled(url, selectedRowsState, false); await updateEnabled(url+'/enable', selectedRowsState, false);
setSelectedRows([]); setSelectedRows([]);
actionRef.current?.reloadAndRest?.(); actionRef.current?.reloadAndRest?.();
} }
......
...@@ -317,6 +317,7 @@ const Model: ModelType = { ...@@ -317,6 +317,7 @@ const Model: ModelType = {
tabs: { tabs: {
...payload, ...payload,
}, },
currentPath: ['引导页'],
}; };
} }
return { return {
...@@ -328,6 +329,7 @@ const Model: ModelType = { ...@@ -328,6 +329,7 @@ const Model: ModelType = {
tabs: { tabs: {
...payload, ...payload,
}, },
currentPath: newCurrent.path,
}; };
}, },
deleteTabByKey(state, {payload}) { deleteTabByKey(state, {payload}) {
......
...@@ -559,6 +559,9 @@ export default (): React.ReactNode => { ...@@ -559,6 +559,9 @@ export default (): React.ReactNode => {
<li> <li>
<Link>修改 草稿为引导页</Link> <Link>修改 草稿为引导页</Link>
</li> </li>
<li>
<Link>修复 批量启用禁用集群、关闭tab无法更新位置及无法取消FlinkSQLEnv的bug</Link>
</li>
</ul> </ul>
</Paragraph> </Paragraph>
</Timeline.Item> </Timeline.Item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment