Commit 65f8ba05 authored by godkaikai's avatar godkaikai

session

parent 7ea40843
import { Tabs,Empty } from "antd"; import { Tabs,Empty } from "antd";
import {CodeOutlined, TableOutlined,RadarChartOutlined,CalendarOutlined,FileSearchOutlined,DesktopOutlined} from "@ant-design/icons"; import {CodeOutlined, TableOutlined,RadarChartOutlined,CalendarOutlined,FileSearchOutlined,DesktopOutlined
,FunctionOutlined} from "@ant-design/icons";
import {StateType} from "@/pages/FlinkSqlStudio/model"; import {StateType} from "@/pages/FlinkSqlStudio/model";
import {connect} from "umi"; import {connect} from "umi";
import styles from "./index.less"; import styles from "./index.less";
...@@ -74,6 +75,17 @@ const StudioConsole = (props:any) => { ...@@ -74,6 +75,17 @@ const StudioConsole = (props:any) => {
> >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane> </TabPane>
<TabPane
tab={
<span>
<FunctionOutlined />
函数
</span>
}
key="6"
>
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane>
<TabPane <TabPane
tab={ tab={
<span> <span>
...@@ -81,7 +93,7 @@ const StudioConsole = (props:any) => { ...@@ -81,7 +93,7 @@ const StudioConsole = (props:any) => {
文档 文档
</span> </span>
} }
key="6" key="7"
> >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane> </TabPane>
......
...@@ -40,7 +40,6 @@ const StudioMenu = (props: any) => { ...@@ -40,7 +40,6 @@ const StudioMenu = (props: any) => {
const saveSqlAndSettingToTask = async() => { const saveSqlAndSettingToTask = async() => {
const fieldsValue = await form.validateFields(); const fieldsValue = await form.validateFields();
console.log(fieldsValue);
if(current.task){ if(current.task){
let task = { let task = {
id:current.key, id:current.key,
...@@ -57,7 +56,6 @@ const StudioMenu = (props: any) => { ...@@ -57,7 +56,6 @@ const StudioMenu = (props: any) => {
}else{ }else{
} }
console.log('获取' + current.value);
}; };
const runMenu = ( const runMenu = (
......
import {connect} from "umi"; import {connect} from "umi";
import {StateType} from "@/pages/FlinkSqlStudio/model"; import {StateType} from "@/pages/FlinkSqlStudio/model";
import {Form, InputNumber,Input,Switch,Select,Tag} from "antd"; import {Form, InputNumber,Input,Switch,Select,Tag,Row,Col,Divider} from "antd";
import {InfoCircleOutlined} from "@ant-design/icons"; import {InfoCircleOutlined,PlusOutlined} from "@ant-design/icons";
import styles from "./index.less"; import styles from "./index.less";
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
...@@ -9,8 +9,9 @@ const { Option } = Select; ...@@ -9,8 +9,9 @@ const { Option } = Select;
const StudioSetting = (props: any) => { const StudioSetting = (props: any) => {
const {cluster,current,form,dispatch} = props; const {cluster,current,form,dispatch,tabs,session} = props;
const [clusterOption, setClusterOption] = useState<[]>(); const [clusterOption, setClusterOption] = useState<[]>();
const [newSesstion, setNewSesstion] = useState<string>('');
const getCluster = ()=>{ const getCluster = ()=>{
...@@ -26,44 +27,62 @@ const StudioSetting = (props: any) => { ...@@ -26,44 +27,62 @@ const StudioSetting = (props: any) => {
}); });
}; };
form.setFieldsValue(current.task);
useEffect(() => { useEffect(() => {
getCluster(); getCluster();
}, []); }, []);
const addSession = ()=>{
if(newSesstion!='') {
dispatch && dispatch({
type: "Studio/saveSession",
payload: newSesstion,
});
setNewSesstion('');
}
};
const onValuesChange = (change:any,all:any)=>{
let newTabs = tabs;
for(let i=0;i<newTabs.panes.length;i++){
if(newTabs.panes[i].key==newTabs.activeKey){
newTabs.panes[i].task={
...all
};
break;
}
}
dispatch&&dispatch({
type: "Studio/saveTabs",
payload: newTabs,
});
};
const localOption = (<><Tag color="default">Local</Tag>本地环境</>); const localOption = (<><Tag color="default">Local</Tag>本地环境</>);
return ( return (
<Form <Form
form={form} form={form}
layout="vertical" layout="vertical"
className={styles.form_setting} className={styles.form_setting}
initialValues={current.task} //initialValues={current.task}
onValuesChange={onValuesChange}
> >
<Form.Item label="Flink集群" tooltip="选择Flink集群进行远程提交任务" name="clusterId" <Row>
className={styles.form_item}> <Col span={12}>
<Select
//mode="multiple"
style={{ width: '100%' }}
placeholder="选择Flink集群"
defaultValue={['0']}
optionLabelProp="label"
>
<Option value="0" label={localOption}>
<Tag color="default">Local</Tag>
本地环境
</Option>
{clusterOption}
</Select>
</Form.Item>
<Form.Item label="CheckPoint" tooltip="设置Flink任务的检查点步长,0 代表不启用" name="checkPoint" <Form.Item label="CheckPoint" tooltip="设置Flink任务的检查点步长,0 代表不启用" name="checkPoint"
className={styles.form_item}> className={styles.form_item}>
<InputNumber min={0} max={999999} defaultValue={0}/> <InputNumber min={0} max={999999} defaultValue={0}/>
</Form.Item> </Form.Item>
</Col>
<Col span={12}>
<Form.Item <Form.Item
label="Parallelism" className={styles.form_item} name="parallelism" label="Parallelism" className={styles.form_item} name="parallelism"
tooltip="设置Flink任务的并行度,最小为 1" tooltip="设置Flink任务的并行度,最小为 1"
> >
<InputNumber min={1} max={9999} defaultValue={1}/> <InputNumber min={1} max={9999} defaultValue={1} />
</Form.Item> </Form.Item>
</Col>
</Row>
<Form.Item <Form.Item
label="Fragment" className={styles.form_item} name="fragment" label="Fragment" className={styles.form_item} name="fragment"
tooltip={{ title: '【增强特性】 开启FlinkSql片段机制,使用“:=”进行定义(以“;”结束),“${}”进行调用', icon: <InfoCircleOutlined /> }} tooltip={{ title: '【增强特性】 开启FlinkSql片段机制,使用“:=”进行定义(以“;”结束),“${}”进行调用', icon: <InfoCircleOutlined /> }}
...@@ -78,6 +97,58 @@ const StudioSetting = (props: any) => { ...@@ -78,6 +97,58 @@ const StudioSetting = (props: any) => {
> >
<Input placeholder="hdfs://..." /> <Input placeholder="hdfs://..." />
</Form.Item> </Form.Item>
<Row>
<Col span={11}>
<Form.Item label="Flink集群" tooltip="选择Flink集群进行远程提交任务" name="clusterId"
className={styles.form_item}>
<Select
//mode="multiple"
style={{ width: '100%' }}
placeholder="选择Flink集群"
defaultValue={['0']}
optionLabelProp="label"
>
<Option value="0" label={localOption}>
<Tag color="default">Local</Tag>
本地环境
</Option>
{clusterOption}
</Select>
</Form.Item>
</Col>
<Col span={11} offset={1}>
<Form.Item
label="共享会话" tooltip="选择会话进行 Flink Catalog 的共享" name="session"
className={styles.form_item}>
<Select
placeholder="选择会话"
dropdownRender={menu => (
<div>
{menu}
<Divider style={{ margin: '4px 0' }} />
<div style={{ display: 'flex', flexWrap: 'nowrap', padding: 8 }}>
<Input style={{ flex: 'auto' }}
onChange={(e)=>{
setNewSesstion(e.target.value);
}}
/>
<a
style={{ flex: 'none', padding: '8px', display: 'block', cursor: 'pointer' }}
onClick={addSession}
>
<PlusOutlined />
</a>
</div>
</div>
)}
>
{session.map(item => (
<Option key={item}>{item}</Option>
))}
</Select>
</Form.Item>
</Col>
</Row>
</Form> </Form>
); );
}; };
...@@ -85,4 +156,6 @@ const StudioSetting = (props: any) => { ...@@ -85,4 +156,6 @@ const StudioSetting = (props: any) => {
export default connect(({Studio}: { Studio: StateType }) => ({ export default connect(({Studio}: { Studio: StateType }) => ({
cluster: Studio.cluster, cluster: Studio.cluster,
current: Studio.current, current: Studio.current,
tabs: Studio.tabs,
session: Studio.session,
}))(StudioSetting); }))(StudioSetting);
import { Tabs } from 'antd'; import {message, Tabs } from 'antd';
import React, {useState} from 'react'; import React, {useState} from 'react';
import StudioEdit from "../StudioEdit"; import StudioEdit from "../StudioEdit";
import {connect} from "umi"; import {connect} from "umi";
...@@ -13,8 +13,6 @@ const EditorTabs = (props: any) => { ...@@ -13,8 +13,6 @@ const EditorTabs = (props: any) => {
const [panes, setPanes] = useState<any>(tabs.panes); const [panes, setPanes] = useState<any>(tabs.panes);
const onChange = (activeKey: any) => { const onChange = (activeKey: any) => {
//setActiveKey(activeKey);
console.log(activeKey);
dispatch({ dispatch({
type: "Studio/changeActiveKey", type: "Studio/changeActiveKey",
payload: activeKey, payload: activeKey,
...@@ -22,8 +20,6 @@ const EditorTabs = (props: any) => { ...@@ -22,8 +20,6 @@ const EditorTabs = (props: any) => {
}; };
const onEdit = (targetKey: any, action: any) => { const onEdit = (targetKey: any, action: any) => {
console.log(targetKey)
console.log(action);
if(action=='add'){ if(action=='add'){
add(); add();
}else if(action=='remove'){ }else if(action=='remove'){
...@@ -31,22 +27,14 @@ const EditorTabs = (props: any) => { ...@@ -31,22 +27,14 @@ const EditorTabs = (props: any) => {
} }
}; };
const updateValue = (targetKey: any, val: string)=>{
panes.forEach((pane, i) => {
if (pane.key === targetKey) {
//pane.value = val;
return;
}
});
};
const add = () => { const add = () => {
let index = newTabIndex + 1; message.warn('敬请期待');
/*let index = newTabIndex + 1;
const newPanes = [...panes]; const newPanes = [...panes];
newPanes.push({ title: `未命名${index}`,value:'', key: -index }); newPanes.push({ title: `未命名${index}`,value:'', key: -index });
setPanes(newPanes); setPanes(newPanes);
setActiveKey(-index); setActiveKey(-index);
setNewTabIndex(index); setNewTabIndex(index);*/
}; };
const remove = (targetKey:any) => { const remove = (targetKey:any) => {
......
...@@ -113,10 +113,7 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -113,10 +113,7 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
newTabs.panes.push(newPane); newTabs.panes.push(newPane);
dispatch&&dispatch({ dispatch&&dispatch({
type: "Studio/saveTabs", type: "Studio/saveTabs",
payload: { payload: newTabs,
current:newPane,
tabs:newTabs,
},
}); });
}) })
} }
......
import React, {useEffect, useState} from "react"; import React, {useEffect, useState} from "react";
import {connect} from "umi"; import {connect} from "umi";
import styles from './index.less'; import styles from './index.less';
import {BarsOutlined,SettingOutlined} from "@ant-design/icons"; import {BarsOutlined,SettingOutlined,AuditOutlined,ScheduleOutlined,AppstoreOutlined,GoldOutlined,DashboardOutlined,
FireOutlined} from "@ant-design/icons";
import StudioMenu from "./StudioMenu"; import StudioMenu from "./StudioMenu";
import {Row, Col, Card, Empty, Tabs, Form} from "antd"; import {Row, Col, Card, Empty, Tabs, Form} from "antd";
...@@ -37,6 +38,9 @@ const Studio: React.FC<StudioProps> = ({sql}) => { ...@@ -37,6 +38,9 @@ const Studio: React.FC<StudioProps> = ({sql}) => {
<TabPane tab={<span><BarsOutlined/>目录</span>} key="1" > <TabPane tab={<span><BarsOutlined/>目录</span>} key="1" >
<StudioTree/> <StudioTree/>
</TabPane> </TabPane>
<TabPane tab={<span><AppstoreOutlined />元数据</span>} key="2" >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane>
</Tabs> </Tabs>
</Col> </Col>
<Col span={16}> <Col span={16}>
...@@ -48,6 +52,24 @@ const Studio: React.FC<StudioProps> = ({sql}) => { ...@@ -48,6 +52,24 @@ const Studio: React.FC<StudioProps> = ({sql}) => {
<Tabs defaultActiveKey="1" size="small"> <Tabs defaultActiveKey="1" size="small">
<TabPane tab={<span><SettingOutlined />配置</span>} key="1" > <TabPane tab={<span><SettingOutlined />配置</span>} key="1" >
<StudioSetting form={form} /> <StudioSetting form={form} />
</TabPane>
<TabPane tab={<span><ScheduleOutlined />详情</span>} key="2" >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane>
<TabPane tab={<span><AuditOutlined />审计</span>} key="3" >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane>
</Tabs>
<Tabs defaultActiveKey="1" size="small">
<TabPane tab={<span>&nbsp;<GoldOutlined />Catalogue</span>} key="1" >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane>
<TabPane tab={<span>&nbsp;<DashboardOutlined />Overview</span>} key="2" >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane>
<TabPane tab={<span>&nbsp;<FireOutlined />Jobs</span>} key="3" >
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</TabPane> </TabPane>
</Tabs> </Tabs>
</Col> </Col>
......
...@@ -18,22 +18,23 @@ export type ClusterType = { ...@@ -18,22 +18,23 @@ export type ClusterType = {
} }
export type TaskType = { export type TaskType = {
id: number, id?: number,
catalogueId: number, catalogueId?: number,
name: string, name?: string,
alias: string, alias?: string,
type: string, type?: string,
checkPoint: number, checkPoint?: number,
savePointPath: string, savePointPath?: string,
parallelism: number, parallelism?: number,
fragment: boolean, fragment?: boolean,
clusterId: number, clusterId?: any,
clusterName: string, clusterName?: string,
note: string, note?: string,
enabled: boolean, enabled?: boolean,
createTime: Date, createTime?: Date,
updateTime: Date, updateTime?: Date,
statement: string, statement?: string,
session:string;
}; };
export type TabsItemType = { export type TabsItemType = {
...@@ -55,6 +56,7 @@ export type StateType = { ...@@ -55,6 +56,7 @@ export type StateType = {
sql?: string; sql?: string;
currentPath?: string[]; currentPath?: string[];
tabs:TabsType; tabs:TabsType;
session:string[];
}; };
export type ModelType = { export type ModelType = {
...@@ -69,18 +71,14 @@ export type ModelType = { ...@@ -69,18 +71,14 @@ export type ModelType = {
saveTabs: Reducer<StateType>; saveTabs: Reducer<StateType>;
changeActiveKey: Reducer<StateType>; changeActiveKey: Reducer<StateType>;
saveTaskData: Reducer<StateType>; saveTaskData: Reducer<StateType>;
saveSession: Reducer<StateType>;
}; };
}; };
const getClusters = async () => { const getClusters = async () => {
try { try {
const msg = await postAll('api/cluster/listEnabledAll'); const {datas} = await postAll('api/cluster/listEnabledAll');
let data:any= []; return datas;
msg.then(value=>{
data = value.datas;
});
console.log(data);
return data;
} catch (error) { } catch (error) {
console.error('获取Flink集群失败'); console.error('获取Flink集群失败');
return []; return [];
...@@ -97,6 +95,14 @@ const Model: ModelType = { ...@@ -97,6 +95,14 @@ const Model: ModelType = {
key: 0 , key: 0 ,
value:'', value:'',
closable: false, closable: false,
task:{
checkPoint: 0,
savePointPath: '',
parallelism: 1,
fragment: true,
clusterId: '0',
session:'admin',
},
}, },
sql: '', sql: '',
currentPath: [], currentPath: [],
...@@ -107,8 +113,17 @@ const Model: ModelType = { ...@@ -107,8 +113,17 @@ const Model: ModelType = {
key: 0 , key: 0 ,
value:'', value:'',
closable: false, closable: false,
task:{
checkPoint: 0,
savePointPath: '',
parallelism: 1,
fragment: true,
clusterId: '0',
session:'admin',
},
}], }],
}, },
session:['admin'],
}, },
effects: { effects: {
...@@ -149,19 +164,19 @@ const Model: ModelType = { ...@@ -149,19 +164,19 @@ const Model: ModelType = {
}; };
}, },
saveTabs(state, { payload }) { saveTabs(state, { payload }) {
/*let newCurrent = state.current; let newCurrent = state.current;
for(let i=0;i<payload.tabs.panes.length;i++){ for(let i=0;i<payload.panes.length;i++){
if(payload.tabs.panes[i].key==payload.tabs.activeKey){ if(payload.panes[i].key==payload.activeKey){
newCurrent=payload.tabs.panes[i]; newCurrent=payload.panes[i];
}
} }
}*/
return { return {
...state, ...state,
current:{ current:{
...payload.current, ...newCurrent,
}, },
tabs:{ tabs:{
...payload.tabs, ...payload,
}, },
}; };
}, },
...@@ -188,9 +203,7 @@ const Model: ModelType = { ...@@ -188,9 +203,7 @@ const Model: ModelType = {
let newTabs = state.tabs; let newTabs = state.tabs;
for(let i=0;i<newTabs.panes.length;i++){ for(let i=0;i<newTabs.panes.length;i++){
if(newTabs.panes[i].key==newTabs.activeKey){ if(newTabs.panes[i].key==newTabs.activeKey){
newTabs.panes[i]={ newTabs.panes[i].task=payload;
...payload
};
} }
} }
return { return {
...@@ -200,6 +213,20 @@ const Model: ModelType = { ...@@ -200,6 +213,20 @@ const Model: ModelType = {
}, },
}; };
}, },
saveSession(state, { payload }) {
let newSession = state.session;
for(let i=0;i<newSession.length;i++){
if(newSession[i].key==payload){
return {};
}
}
newSession.push(payload);
console.log(newSession);
return {
...state,
session:newSession,
};
},
}, },
}; };
......
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