Unverified Commit 65ea93a7 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[fix] fix some bug #2182

parent 6b4dd627
......@@ -1522,7 +1522,7 @@ CREATE TABLE `dinky_user` (
) ENGINE = InnoDB ROW_FORMAT = Dynamic;
INSERT INTO `dinky_user`
VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Admin', NULL,0
, NULL, NULL, 1, 0, '2022-12-13 05:27:19'
, NULL, NULL, 1,1, 0, '2022-12-13 05:27:19'
, '2022-12-13 05:27:19');
DROP TABLE IF EXISTS `dinky_user_role`;
CREATE TABLE `dinky_user_role` (
......@@ -1544,7 +1544,7 @@ CREATE TABLE `dinky_user_tenant` (
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time'
) ENGINE = InnoDB ROW_FORMAT = Dynamic;
INSERT INTO `dinky_user_tenant` (`id`, `user_id`, `tenant_id`, `create_time`, `update_time`)
VALUES (1, 1, 1, current_time, current_time);
VALUES (1, 1, 1,1, current_time, current_time);
DROP TABLE IF EXISTS `metadata_column`;
CREATE TABLE `metadata_column` (
`column_name` varchar(255) NOT NULL COMMENT 'column name',
......
/*
*
* 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 {Col, Modal, Progress, Row, Space} from "antd";
import React from "react";
import {JobRunningMsgType} from "@/pages/DataStudio/model";
import {StopTwoTone} from "@ant-design/icons";
type JobRunningModalProps = {
visible: boolean;
onCancel: () => void;
onOk: () => void;
value: JobRunningMsgType;
}
const JobRunningModal :React.FC<JobRunningModalProps> =(props) => {
const {visible, onCancel, onOk, value} = props;
return <>
<Modal
title={`Job ${value?.jobName} is running`}
open={visible}
onOk={onOk}
width={'50%'}
centered
onCancel={onCancel}
footer={null}
>
<Space direction="vertical" style={{width: '100%'}}>
<Row gutter={[12,12]}>
<Col span={23}>
<Progress showInfo strokeLinecap={'round'} percent={100} status="active" strokeColor={{ from: '#108ee9', to: '#87d068' }} />
</Col>
<Col span={1}>
<StopTwoTone />
</Col>
</Row>
</Space>
</Modal>
</>
}
export default JobRunningModal;
\ No newline at end of file
......@@ -4,101 +4,127 @@ import {Button, GlobalToken, Space} from "antd";
import {connect} from "@@/exports";
import {getCurrentTab} from "@/pages/DataStudio/function";
import {getSseData} from "@/services/api";
import {API_CONSTANTS} from "@/services/constants";
import {l} from "@/utils/intl";
import JobRunningModal from "@/pages/DataStudio/FooterContainer/JobRunningModal";
export type FooterContainerProps = {
token: GlobalToken
token: GlobalToken
}
type ButtonRoute = {
text: React.ReactNode,
title: string,
onClick?: () => void,
isShow?: (type?: TabsPageType, subType?: string, data?: any) => boolean;
text: React.ReactNode,
title: string,
onClick?: () => void,
isShow?: (type?: TabsPageType, subType?: string, data?: any) => boolean;
}
const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => {
const {footContainer, token, tabs} = props;
const eventSource = getSseData("/api/sse/getJvmInfo");
const [memDetails, setMemDetails] = useState(footContainer.memDetails);
useEffect(() => {
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
setMemDetails(Number(data["heapUsed"] / 1024 / 1024).toFixed(0) + "/" + Number(data["total"] / 1024 / 1024).toFixed(0) + "M")
}
return () => {
eventSource.close()
}
}, [])
const {footContainer: {
memDetails,
codeType,
lineSeparator,
codeEncoding,
space,
codePosition,
jobRunningMsg,
}, token, tabs} = props;
const [viewJobRunning , setViewJobRunning] = useState(false);
const eventSource = getSseData("/api/sse/getJvmInfo");
const [memDetailInfo, setMemDetailInfo] = useState(memDetails);
useEffect(() => {
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
setMemDetailInfo(Number(data["heapUsed"] / 1024 / 1024).toFixed(0) + "/" + Number(data["total"] / 1024 / 1024).toFixed(0) + "M")
}
return () => {
eventSource.close()
}
}, []);
const currentTab = getCurrentTab(tabs.panes, tabs.activeKey);
const route: ButtonRoute[] = [
{
text: <span
style={{backgroundColor: token.colorBgBase}}>{memDetails}</span>,
title: l("pages.datastudio.footer.memDetails", "", {
max: memDetails.split("/")[1],
used: memDetails.split("/")[0]
}),
isShow: () => true
},
{
text: footContainer.codeType,
title: l("pages.datastudio.footer.codeType") + footContainer.codeType,
isShow: (type) => TabsPageType.project === type
},
{
text: footContainer.lineSeparator,
title: l("pages.datastudio.footer.lineSeparator") + footContainer.lineSeparator,
isShow: (type) => TabsPageType.project === type
},
{
text: footContainer.codeEncoding,
title: l("pages.datastudio.footer.codeEncoding") + footContainer.codeEncoding,
isShow: (type) => TabsPageType.project === type
},
{
text: "Space: " + footContainer.space,
title: "Space: " + footContainer.space,
isShow: (type) => TabsPageType.project === type
},
{
text: footContainer.codePosition[0] + ":" + footContainer.codePosition[1],
title: l("pages.datastudio.footer.codePosition", "", {
Ln: footContainer.codePosition[0],
Col: footContainer.codePosition[1]
}),
isShow: (type) => TabsPageType.project === type
},
]
return (
<div style={{
backgroundColor: token.colorFill,
height: VIEW.footerHeight,
width: "100%",
display: "flex",
paddingInline: 10
}}>
<Space style={{direction: "ltr", width: "50%"}}>
<Button size={"small"} type={"text"} block style={{paddingInline: 4}}>Welcome to Dinky !</Button>
</Space>
<Space style={{direction: "rtl", width: "50%"}} size={4} direction={"horizontal"}>
{route.filter(x => {
if (x.isShow) {
return x.isShow(currentTab?.type, currentTab?.subType, currentTab?.params);
}
return false
const currentTab = getCurrentTab(tabs.panes, tabs.activeKey);
const route: ButtonRoute[] = [
{
text: <span style={{backgroundColor: token.colorBgBase}}>{memDetailInfo}</span>,
title: l("pages.datastudio.footer.memDetails", "", {
max: memDetailInfo.split("/")[1],
used: memDetailInfo.split("/")[0]
}),
isShow: () => true
},
{
text: codeType,
title: l("pages.datastudio.footer.codeType") + codeType,
isShow: (type) => TabsPageType.project === type
},
{
text: lineSeparator,
title: l("pages.datastudio.footer.lineSeparator") + lineSeparator,
isShow: (type) => TabsPageType.project === type
},
{
text: codeEncoding,
title: l("pages.datastudio.footer.codeEncoding") + codeEncoding,
isShow: (type) => TabsPageType.project === type
},
{
text: "Space: " + space,
title: "Space: " + space,
isShow: (type) => TabsPageType.project === type
},
{
text: codePosition[0] + ":" + codePosition[1],
title: l("pages.datastudio.footer.codePosition", "", {
Ln: codePosition[0],
Col: codePosition[1]
}),
isShow: (type) => TabsPageType.project === type
},
];
/**
* render footer right info
* @param {ButtonRoute[]} routes
* @returns {JSX.Element[]}
*/
const renderFooterRightInfo = (routes: ButtonRoute[]) => {
return routes.filter(x => {
if (x.isShow) {
return x.isShow(currentTab?.type, currentTab?.subType, currentTab?.params);
}
return false
})
.map((item, index) => {
return <Button size={"small"} type={"text"} block style={{paddingInline: 4}} key={index}
onClick={item.onClick} title={item.title}>{item.text}</Button>
})}
</Space>
</div>
)
.map((item, index) => (
<Button size={"small"} type={"text"} block style={{paddingInline: 4}} key={index}
onClick={item.onClick} title={item.title}>{item.text}</Button>
))
}
return <>
<div style={{
backgroundColor: token.colorFill,
height: VIEW.footerHeight,
width: "100%",
display: "flex",
paddingInline: 10
}}>
<Space style={{direction: "ltr", width: "30%%"}}>
<Button size={"small"} type={"text"} block style={{paddingInline: 4}}>Welcome to Dinky !</Button>
</Space>
<Space onClick={()=>setViewJobRunning(true)} style={{direction: 'rtl', width: "30%"}}>
{jobRunningMsg.jobName} - {jobRunningMsg.runningLog}
</Space>
<Space style={{direction: "rtl", width: "70%"}} size={4}
direction={"horizontal"}>{renderFooterRightInfo(route)}</Space>
</div>
<JobRunningModal value={jobRunningMsg} visible={viewJobRunning} onCancel={()=>setViewJobRunning(false)} onOk={()=>setViewJobRunning(false)} />
</>
}
export default connect(({Studio}: { Studio: StateType }) => ({
footContainer: Studio.footContainer,
tabs: Studio.tabs
footContainer: Studio.footContainer,
tabs: Studio.tabs
}))(FooterContainer);
......@@ -20,7 +20,6 @@ import React, {useState} from "react";
import {connect} from "@@/exports";
import {DataStudioParams, MetadataParams, StateType, TabsItemType, TabsPageType} from "@/pages/DataStudio/model";
import RightTagsRouter from "@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter";
import {renderDBIcon} from "@/pages/RegCenter/DataSource/components/function";
import KeyBoard from "@/pages/DataStudio/MiddleContainer/KeyBoard";
import {MenuInfo} from "rc-menu/es/interface";
import {STUDIO_TAG_RIGHT_CONTEXT_MENU} from "@/pages/DataStudio/constants";
......@@ -29,8 +28,7 @@ import ContentScroll from "@/components/Scroll/ContentScroll";
import useThemeValue from "@/hooks/useThemeValue";
import Editor from "@/pages/DataStudio/MiddleContainer/Editor";
import {getTabIcon} from "@/pages/DataStudio/MiddleContainer/function";
import {getCurrentData, getCurrentTab} from "@/pages/DataStudio/function";
import {RightSide, TabProp} from "@/pages/DataStudio/route";
import {RightSide} from "@/pages/DataStudio/route";
type TargetKey = React.MouseEvent | React.KeyboardEvent | string;
......@@ -211,7 +209,8 @@ const MiddleContainer = (props: any) => {
const renderContent = () => {
switch (item.type) {
case TabsPageType.metadata:
const params = item.params as MetadataParams
let params: MetadataParams;
params = item.params as MetadataParams;
return <RightTagsRouter tableInfo={params.tableInfo} queryParams={params.queryParams}/>
case TabsPageType.project:
if (parseInt(activeKey) < 0) {
......@@ -225,12 +224,17 @@ const MiddleContainer = (props: any) => {
}
return {
key: item.key,
label: <Space size={0} onContextMenu={(e) => handleRightClick(e, item)}
key={item.key}>{getTabIcon(item.icon, 16)}{item.label}</Space>,
children:
label: <>
<Space
onClick={()=> updateActiveKey(item.key, {target: {innerText: item.label}})}
size={0} onContextMenu={(e) => handleRightClick(e, item)}
key={item.key}>{getTabIcon(item.icon, 16)}{item.label}</Space>
</>,
children:<>
<ContentScroll height={activeKey === item.key ? props.centerContentHeight - 35 : 0}>
{renderContent()}
</ContentScroll>
</>
}
})
......
......@@ -19,9 +19,8 @@
import {Dispatch} from "@@/plugin-dva/types";
import {DataSources} from "@/types/RegCenter/data";
import {ClusterConfigurationType, ClusterType, DataStudioParams, EnvType, TabsItemType} from "@/pages/DataStudio/model";
import {RightSide} from "@/pages/DataStudio/route";
import {Cluster, DataSources} from "@/types/RegCenter/data";
import {DataStudioParams, EnvType, JobRunningMsgType, TabsItemType} from "@/pages/DataStudio/model";
export const mapDispatchToProps = (dispatch: Dispatch) => ({
updateToolContentHeight: (key: number) => dispatch({
......@@ -69,7 +68,7 @@ export const mapDispatchToProps = (dispatch: Dispatch) => ({
type: "Studio/updateBottomConsole",
payload: data,
}),
saveSession: (data: ClusterType[]) => dispatch({
saveSession: (data: Cluster.Instance[]) => dispatch({
type: "Studio/saveSession",
payload: data,
}),
......@@ -81,20 +80,25 @@ export const mapDispatchToProps = (dispatch: Dispatch) => ({
type: "Studio/saveTabs",
payload: data,
}),
saveClusterConfiguration: (data: ClusterConfigurationType[]) => dispatch({
saveClusterConfiguration: (data: Cluster.Config[]) => dispatch({
type: "Studio/saveClusterConfiguration",
payload: data,
}),
updateJobRunningMsg: (data: JobRunningMsgType) => dispatch({
type: "Studio/updateJobRunningMsg",
payload: data,
}),
});
export const getCurrentTab = (panes: any, activeKey: string) => {
return (panes as TabsItemType[]).find(item => item.key === activeKey)
}
export const getCurrentData = (panes: any, activeKey: string) => {
return (getCurrentTab(panes,activeKey)?.params as DataStudioParams)?.taskData
}
export const getCurrentTab = (panes: any, activeKey: string) => {
return (panes as TabsItemType[]).find(item => item.key === activeKey)
}
export const getFooterValue = (panes: any, activeKey: string)=>{
......
import {Reducer} from "@@/plugin-dva/types";
import React from "react";
import {DataSources} from "@/types/RegCenter/data";
import {Cluster, DataSources} from "@/types/RegCenter/data";
import {QueryParams} from "@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data";
import {l} from "@/utils/intl";
import {getCurrentTab, getFooterValue} from "@/pages/DataStudio/function";
import {getFooterValue} from "@/pages/DataStudio/function";
/**
* 初始化布局宽高度
......@@ -154,17 +154,7 @@ export type MetaStoreColumnType = {
name: string;
type: string;
}
export type ClusterConfigurationType = {
id: number,
name: string,
type: string,
config: any,
available: boolean,
note: string,
enabled: boolean,
createTime: Date,
updateTime: Date,
}
export type Container = {
selectKey: string;
selectSubKey: { [c: string]: string };
......@@ -187,18 +177,20 @@ export type SessionType = {
createTime?: string;
connectors: ConnectorType[];
}
export type ClusterType = {
id: number,
name: string,
type: string,
hosts: string,
jobManagerHost: string,
status: number,
note: string,
enabled: boolean,
createTime: Date,
updateTime: Date,
}
/**
* job running type msg
*/
export type JobRunningMsgType = {
taskId: number | null ,
jobName: string ,
jobState: string ,
runningLog: string ,
};
/**
* footer
*/
type FooterType = {
codePosition: [number, number],
space: number,
......@@ -206,7 +198,12 @@ type FooterType = {
lineSeparator: string,
codeType: string,
memDetails: string,
jobRunningMsg: JobRunningMsgType,
}
/**
* state type overview
*/
export type StateType = {
isFullScreen: boolean;
toolContentHeight: number;
......@@ -226,8 +223,8 @@ export type StateType = {
expandKeys: [];
selectKey: [];
};
sessionCluster: ClusterType[];
clusterConfiguration: ClusterConfigurationType[];
sessionCluster: Cluster.Instance[];
clusterConfiguration: Cluster.Config[];
env: EnvType[];
tabs: TabsType;
bottomContainerContent: BottomContainerContent;
......@@ -263,6 +260,7 @@ export type ModelType = {
saveClusterConfiguration: Reducer<StateType>;
saveEnv: Reducer<StateType>;
saveFooterValue: Reducer<StateType>;
updateJobRunningMsg: Reducer<StateType>;
};
};
const Model: ModelType = {
......@@ -319,6 +317,12 @@ const Model: ModelType = {
lineSeparator: "LF",
codeType: "",
memDetails: "100/500M",
jobRunningMsg: {
taskId: null,
jobName: '',
jobState: '',
runningLog: '',
},
}
},
effects: {},
......@@ -712,7 +716,16 @@ const Model: ModelType = {
...state,
footContainer: payload,
}
}
},
updateJobRunningMsg(state, {payload}) {
return {
...state,
footContainer: {
...state.footContainer,
jobRunningMsg: payload
},
}
},
}
}
......
......@@ -882,7 +882,7 @@ CREATE TABLE `dinky_user` (
-- ----------------------------
-- Records of dinky_user
-- ----------------------------
INSERT INTO `dinky_user` VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Admin', NULL,0, NULL, NULL, 1, 0, '2022-12-13 05:27:19', '2022-12-13 05:27:19');
INSERT INTO `dinky_user` VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Admin', NULL,0, NULL, NULL, 1,1, 0, '2022-12-13 05:27:19', '2022-12-13 05:27:19');
-- ----------------------------
-- Table structure for dinky_user_role
......@@ -911,7 +911,7 @@ CREATE TABLE `dinky_user_tenant` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`user_id` int(11) NOT NULL COMMENT 'user id',
`tenant_id` int(11) NOT NULL COMMENT 'tenant id',
`tenant_admin_flag` tinyint DEFAULT '0' COMMENT 'tenant admin flag(0:false,1:true)',
`tenant_admin_flag` tinyint DEFAULT '0' COMMENT 'tenant admin flag(0:false,1:true)',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
......@@ -921,7 +921,7 @@ CREATE TABLE `dinky_user_tenant` (
-- ----------------------------
-- Records of dinky_user_tenant
-- ----------------------------
INSERT INTO `dinky_user_tenant`(`id`, `user_id`, `tenant_id`, `create_time`, `update_time`) VALUES (1, 1, 1, current_time, current_time);
INSERT INTO `dinky_user_tenant`(`id`, `user_id`, `tenant_id`, `create_time`, `update_time`) VALUES (1, 1, 1,1, current_time, current_time);
-- ----------------------------
-- Table structure for metadata_column
......
......@@ -1500,7 +1500,7 @@ COMMENT ON TABLE "public"."dinky_user" IS 'user';
-- ----------------------------
-- Records of dinky_user
-- ----------------------------
INSERT INTO "public"."dinky_user" VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Admin', NULL,0, NULL, NULL, 1, 0, '2022-12-13 05:27:19', '2022-12-13 05:27:19');
INSERT INTO "public"."dinky_user" VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Admin', NULL,0, NULL, NULL, 1,1, 0, '2022-12-13 05:27:19', '2022-12-13 05:27:19');
-- ----------------------------
-- Table structure for dinky_user_role
......@@ -1550,7 +1550,7 @@ COMMENT ON TABLE "public"."dinky_user_tenant" IS 'Relationship between users and
-- ----------------------------
-- Records of dinky_user_tenant
-- ----------------------------
INSERT INTO "public"."dinky_user_tenant" VALUES (1, 1, 1, '2023-05-29 21:25:42', '2023-05-29 21:25:42');
INSERT INTO "public"."dinky_user_tenant" VALUES (1, 1, 1,1, '2023-05-29 21:25:42', '2023-05-29 21:25:42');
-- ----------------------------
-- Table structure for metadata_column
......
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