Unverified Commit 21772f10 authored by ZackYoung's avatar ZackYoung Committed by GitHub

add_common_sql_config (#2400)

parent 9f994585
......@@ -353,6 +353,8 @@ export default {
'pages.datastudio.label.execConfig.changelog': 'Print ChangeLog',
'pages.datastudio.label.execConfig.changelog.tip':
'Open the print stream, it will run synchronously and return the ChangeLog containing op information, it is not enabled by default and returns the final result Table',
'pages.datastudio.label.execConfig.selectDatabase': 'Select Database',
'pages.datastudio.label.execConfig.selectDatabase.tip': 'Select the database to be used',
'pages.datastudio.label.execConfig.maxrow': 'Maximum number of rows',
'pages.datastudio.label.execConfig.maxrow.tip': 'The maximum number of rows of preview data',
'pages.datastudio.label.execConfig.preview.result': 'Preview Result',
......
......@@ -341,6 +341,8 @@ export default {
'pages.datastudio.label.execConfig.changelog': '打印流',
'pages.datastudio.label.execConfig.changelog.tip':
'开启打印流,将同步运行并返回含有 op 信息的 ChangeLog,默认不开启且返回最终结果 Table',
'pages.datastudio.label.execConfig.selectDatabase': '选择数据源',
'pages.datastudio.label.execConfig.selectDatabase.tip': '选择 Sql 语句执行的数据源',
'pages.datastudio.label.execConfig.maxrow': '最大行数',
'pages.datastudio.label.execConfig.maxrow.tip': '预览数据的最大行数',
'pages.datastudio.label.execConfig.preview.result': '预览结果',
......
/*
*
* 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 {getCurrentData} from '@/pages/DataStudio/function';
import {StateType, STUDIO_MODEL} from '@/pages/DataStudio/model';
import {SWITCH_OPTIONS} from '@/services/constants';
import {l} from '@/utils/intl';
import {InfoCircleOutlined} from '@ant-design/icons';
import {ProForm, ProFormDigit, ProFormGroup, ProFormSelect, ProFormSwitch} from '@ant-design/pro-components';
import {useForm} from 'antd/es/form/Form';
import {connect} from 'umi';
import {DataSources} from "@/types/RegCenter/data";
import {TagAlignLeft} from "@/components/StyledComponents";
import {Tag} from "antd";
import React from "react";
const ExecuteConfigCommonSql = (props: any) => {
const {
dispatch,
tabs: {panes, activeKey},
databaseData
} = props;
const [form] = useForm();
const current = getCurrentData(panes, activeKey);
const data: Record<number, React.ReactNode> = {};
const databaseDataList = databaseData as DataSources.DataSource[];
databaseDataList.filter(x => x.type.toLowerCase() === current?.dialect.toLowerCase()).forEach((item: DataSources.DataSource) => {
data[item.id] = (
<TagAlignLeft><Tag key={item.id} color={item.enabled ? 'processing' : 'error'}>{item.type}</Tag>{item.name}
</TagAlignLeft>
)
});
form.setFieldsValue({...current, databaseId: String(current?.databaseId ?? "")});
const onValuesChange = (change: any, all: any) => {
for (let i = 0; i < panes.length; i++) {
if (panes[i].key === activeKey) {
for (const key in change) {
if (key === 'databaseId') {
panes[i].params.taskData[key] = Number(all[key]);
continue;
}
panes[i].params.taskData[key] = all[key];
}
break;
}
}
dispatch({
type: STUDIO_MODEL.saveTabs,
payload: {...props.tabs}
});
};
return (
<>
<ProForm
initialValues={{
maxRowNum: 100
}}
style={{padding: '10px'}}
form={form}
submitter={false}
layout='vertical'
onValuesChange={onValuesChange}
>
<ProFormGroup>
<ProFormSelect
width={'lg'}
name={'databaseId'}
label={l('pages.datastudio.label.execConfig.selectDatabase')}
valueEnum={data}
initialValue={1}
placeholder="Please select a country"
rules={[{required: true, message: 'Please select your country!'}]}
/>
</ProFormGroup>
<ProFormGroup>
<ProFormDigit
width={'xs'}
label={l('pages.datastudio.label.execConfig.maxrow')}
name='maxRowNum'
tooltip={l('pages.datastudio.label.execConfig.maxrow.tip')}
min={1}
max={9999}
/>
</ProFormGroup>
</ProForm>
</>
);
};
export default connect(({Studio}: { Studio: StateType }) => ({
tabs: Studio.tabs,
databaseData: Studio.database.dbData
}))(ExecuteConfigCommonSql);
/*
*
* 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 { getCurrentData } from '@/pages/DataStudio/function';
import { StateType, STUDIO_MODEL } from '@/pages/DataStudio/model';
import { SWITCH_OPTIONS } from '@/services/constants';
import { l } from '@/utils/intl';
import { InfoCircleOutlined } from '@ant-design/icons';
import { ProForm, ProFormDigit, ProFormGroup, ProFormSwitch } from '@ant-design/pro-components';
import { useForm } from 'antd/es/form/Form';
import { connect } from 'umi';
const ExecuteConfigFlinkSql = (props: any) => {
const {
dispatch,
tabs: { panes, activeKey }
} = props;
const [form] = useForm();
const current = getCurrentData(panes, activeKey);
form.setFieldsValue(current);
const onValuesChange = (change: any, all: any) => {
for (let i = 0; i < panes.length; i++) {
if (panes[i].key === activeKey) {
for (const key in change) {
panes[i].params.taskData[key] = all[key];
}
break;
}
}
dispatch({
type: STUDIO_MODEL.saveTabs,
payload: { ...props.tabs }
});
};
return (
<>
<ProForm
initialValues={{
maxRowNum: 100
}}
style={{ padding: '10px' }}
form={form}
submitter={false}
layout='vertical'
onValuesChange={onValuesChange}
>
<ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.preview.result')}
name='useResult'
tooltip={{
title: l('pages.datastudio.label.execConfig.preview.result.tip'),
icon: <InfoCircleOutlined />
}}
{...SWITCH_OPTIONS()}
/>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.changelog')}
name='useChangeLog'
tooltip={{
title: l('pages.datastudio.label.execConfig.changelog.tip'),
icon: <InfoCircleOutlined />
}}
{...SWITCH_OPTIONS()}
/>
</ProFormGroup>
<ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.autostop')}
name='useAutoCancel'
tooltip={{
title: l('pages.datastudio.label.execConfig.autostop.tip'),
icon: <InfoCircleOutlined />
}}
{...SWITCH_OPTIONS()}
/>
<ProFormDigit
width={'xs'}
label={l('pages.datastudio.label.execConfig.maxrow')}
name='maxRowNum'
tooltip={l('pages.datastudio.label.execConfig.maxrow.tip')}
min={1}
max={9999}
/>
</ProFormGroup>
</ProForm>
</>
);
};
export default connect(({ Studio }: { Studio: StateType }) => ({
tabs: Studio.tabs
}))(ExecuteConfigFlinkSql);
......@@ -17,96 +17,28 @@
*
*/
import { getCurrentData } from '@/pages/DataStudio/function';
import { StateType, STUDIO_MODEL } from '@/pages/DataStudio/model';
import { SWITCH_OPTIONS } from '@/services/constants';
import { l } from '@/utils/intl';
import { InfoCircleOutlined } from '@ant-design/icons';
import { ProForm, ProFormDigit, ProFormGroup, ProFormSwitch } from '@ant-design/pro-components';
import { useForm } from 'antd/es/form/Form';
import { connect } from 'umi';
import {getCurrentTab} from '@/pages/DataStudio/function';
import {StateType, TabsPageSubType} from '@/pages/DataStudio/model';
import {connect} from 'umi';
import ExecuteConfigFlinkSql from "@/pages/DataStudio/RightContainer/ExecuteConfig/FlinkSql";
import ExecuteConfigCommonSql from "@/pages/DataStudio/RightContainer/ExecuteConfig/CommonSql";
const ExecuteConfig = (props: any) => {
const {
dispatch,
tabs: { panes, activeKey }
} = props;
const [form] = useForm();
const current = getCurrentData(panes, activeKey);
form.setFieldsValue(current);
const onValuesChange = (change: any, all: any) => {
for (let i = 0; i < panes.length; i++) {
if (panes[i].key === activeKey) {
for (const key in change) {
panes[i].params.taskData[key] = all[key];
const {
tabs: {panes, activeKey}
} = props;
const current = getCurrentTab(panes, activeKey);
{
if (current?.subType === TabsPageSubType.flinkSql) {
return <ExecuteConfigFlinkSql/>;
} else {
return <ExecuteConfigCommonSql/>;
}
break;
}
}
dispatch({
type: STUDIO_MODEL.saveTabs,
payload: { ...props.tabs }
});
};
return (
<>
<ProForm
initialValues={{
maxRowNum: 100
}}
style={{ padding: '10px' }}
form={form}
submitter={false}
layout='vertical'
onValuesChange={onValuesChange}
>
<ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.preview.result')}
name='useResult'
tooltip={{
title: l('pages.datastudio.label.execConfig.preview.result.tip'),
icon: <InfoCircleOutlined />
}}
{...SWITCH_OPTIONS()}
/>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.changelog')}
name='useChangeLog'
tooltip={{
title: l('pages.datastudio.label.execConfig.changelog.tip'),
icon: <InfoCircleOutlined />
}}
{...SWITCH_OPTIONS()}
/>
</ProFormGroup>
<ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.autostop')}
name='useAutoCancel'
tooltip={{
title: l('pages.datastudio.label.execConfig.autostop.tip'),
icon: <InfoCircleOutlined />
}}
{...SWITCH_OPTIONS()}
/>
<ProFormDigit
width={'xs'}
label={l('pages.datastudio.label.execConfig.maxrow')}
name='maxRowNum'
tooltip={l('pages.datastudio.label.execConfig.maxrow.tip')}
min={1}
max={9999}
/>
</ProFormGroup>
</ProForm>
</>
);
};
}
export default connect(({ Studio }: { Studio: StateType }) => ({
tabs: Studio.tabs
export default connect(({Studio}: {
Studio: StateType
}) => ({
tabs: Studio.tabs
}))(ExecuteConfig);
......@@ -103,7 +103,10 @@ export type TaskDataBaseType = {
id: number;
name: string;
statement: string;
dialect: string;
step: number;
// Only common sql has(只有普通sql才有)
databaseId?: number;
};
export type TaskDataType = TaskDataBaseType & Record<string, any>;
......
......@@ -57,6 +57,7 @@ import {
} from '@ant-design/icons';
import { DiffEditor } from '@monaco-editor/react';
import { ReactNode } from 'react';
import {isSql} from "@/pages/DataStudio/HeaderContainer/service";
export const LeftSide = [
{
......@@ -97,7 +98,7 @@ export const RightSide: TabProp[] = [
icon: <PlayCircleOutlined />,
label: l('menu.datastudio.executeConfig'),
children: <ExecuteConfig />,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType || isSql(subType ?? "")
},
{
auth: '/datastudio/right/savePoint',
......@@ -301,4 +302,4 @@ export type TabProp = {
children: ReactNode;
isShow?: (type: TabsPageType, subType?: TabsPageSubType) => boolean;
auth?: string;
};
};
\ No newline at end of file
......@@ -15,8 +15,8 @@
* limitations under the License.
*/
import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants';
import { l } from '@/utils/intl';
import {JOB_LIFE_CYCLE, JOB_STATUS} from '@/pages/DevOps/constants';
import {l} from '@/utils/intl';
/**
* Generates an array of options for the life cycle filter.
......@@ -24,18 +24,11 @@ import { l } from '@/utils/intl';
* @returns {Array} - An array of objects representing the life cycle filter options.
*/
export const LIFECYCLE_FILTER = () => {
return [
{ text: l('global.table.lifecycle.dev'), value: JOB_LIFE_CYCLE.DEVELOP },
{
text: l('global.table.lifecycle.publish'),
value: JOB_LIFE_CYCLE.RELEASE
},
{ text: l('global.table.lifecycle.online'), value: JOB_LIFE_CYCLE.ONLINE },
{
text: l('global.table.lifecycle.unknown'),
value: JOB_LIFE_CYCLE.UNKNOWN
}
];
return [
{text: l('global.table.lifecycle.dev'), value: JOB_LIFE_CYCLE.DEVELOP},
{text: l('global.table.lifecycle.online'), value: JOB_LIFE_CYCLE.ONLINE},
{text: l('global.table.lifecycle.unknown'), value: JOB_LIFE_CYCLE.UNKNOWN}
];
};
/**
......@@ -44,19 +37,19 @@ export const LIFECYCLE_FILTER = () => {
* @returns {Array} - An array of objects representing the job status filter options.
*/
export const JOB_STATUS_FILTER = () => {
return [
{ text: JOB_STATUS.FINISHED, value: JOB_STATUS.FINISHED },
{ text: JOB_STATUS.RUNNING, value: JOB_STATUS.RUNNING },
{ text: JOB_STATUS.FAILED, value: JOB_STATUS.FAILED },
{ text: JOB_STATUS.CANCELED, value: JOB_STATUS.CANCELED },
{ text: JOB_STATUS.INITIALIZING, value: JOB_STATUS.INITIALIZING },
{ text: JOB_STATUS.RESTARTING, value: JOB_STATUS.RESTARTING },
{ text: JOB_STATUS.CREATED, value: JOB_STATUS.CREATED },
{ text: JOB_STATUS.FAILING, value: JOB_STATUS.FAILING },
{ text: JOB_STATUS.SUSPENDED, value: JOB_STATUS.SUSPENDED },
{ text: JOB_STATUS.CANCELLING, value: JOB_STATUS.CANCELLING },
{ text: JOB_STATUS.UNKNOWN, value: JOB_STATUS.UNKNOWN }
];
return [
{text: JOB_STATUS.FINISHED, value: JOB_STATUS.FINISHED},
{text: JOB_STATUS.RUNNING, value: JOB_STATUS.RUNNING},
{text: JOB_STATUS.FAILED, value: JOB_STATUS.FAILED},
{text: JOB_STATUS.CANCELED, value: JOB_STATUS.CANCELED},
{text: JOB_STATUS.INITIALIZING, value: JOB_STATUS.INITIALIZING},
{text: JOB_STATUS.RESTARTING, value: JOB_STATUS.RESTARTING},
{text: JOB_STATUS.CREATED, value: JOB_STATUS.CREATED},
{text: JOB_STATUS.FAILING, value: JOB_STATUS.FAILING},
{text: JOB_STATUS.SUSPENDED, value: JOB_STATUS.SUSPENDED},
{text: JOB_STATUS.CANCELLING, value: JOB_STATUS.CANCELLING},
{text: JOB_STATUS.UNKNOWN, value: JOB_STATUS.UNKNOWN}
];
};
/**
......@@ -66,16 +59,16 @@ export const JOB_STATUS_FILTER = () => {
* @returns {boolean} - True if the job status indicates that the job is done, false otherwise.
*/
export function isStatusDone(type: string) {
if (!type) {
return true;
}
switch (type) {
case JOB_STATUS.FAILED:
case JOB_STATUS.CANCELED:
case JOB_STATUS.FINISHED:
case JOB_STATUS.UNKNOWN:
return true;
default:
return false;
}
if (!type) {
return true;
}
switch (type) {
case JOB_STATUS.FAILED:
case JOB_STATUS.CANCELED:
case JOB_STATUS.FINISHED:
case JOB_STATUS.UNKNOWN:
return true;
default:
return false;
}
}
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