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

fix resource & log list bug (#2396)

* Spotless Apply * fix resource && log bug --------- Co-authored-by: 's avatarzhu-mingye <zhu-mingye@users.noreply.github.com>
parent 7ebe8556
......@@ -41,7 +41,7 @@ import lombok.ToString;
public class TreeNodeDTO {
@ApiModelProperty(value = "ID", dataType = "Integer", example = "1", notes = "The ID of the tree node")
private Integer id;
private Object id;
@ApiModelProperty(value = "Name", dataType = "String", example = "Node 1", notes = "The name of the tree node")
private String name;
......@@ -61,7 +61,7 @@ public class TreeNodeDTO {
dataType = "Integer",
example = "0",
notes = "The ID of the parent tree node (0 for root)")
private Integer parentId;
private Object parentId;
@ApiModelProperty(value = "Size", dataType = "Long", example = "1024", notes = "The size of the tree node")
private Long size;
......@@ -101,4 +101,14 @@ public class TreeNodeDTO {
this.children = children;
this.isLeaf = (children == null || children.size() == 0);
}
public TreeNodeDTO(String id, String name, String path, String parentId, String desc, List<TreeNodeDTO> children) {
this.id = id;
this.name = name;
this.path = path;
this.parentId = parentId;
this.desc = desc;
this.children = children;
this.isLeaf = (children == null || children.size() == 0);
}
}
......@@ -1961,6 +1961,6 @@ INSERT INTO dinky_alert_template VALUES (1, 'Default', '
- **Alert Time :** ${time}
- **Start Time :** ${startTime}
- **End Time :** ${endTime}
- **<font color=''red''>${exceptions.rootException.substring(0,20)}</font>**
- **<font color=''red''>${(exceptions.rootException)?substring(0,20)}</font>**
[Go toTask Web](http://${taskUrl})
', 1, null, null);
import { queryDataByParams } from '@/services/BusinessCrud';
export function getConsoleData() {
// return queryDataByParams('api/process/getConsoleByUserId');
}
import {TagAlignLeft} from '@/components/StyledComponents';
import {BtnRoute} from '@/pages/DataStudio/route';
import { TagAlignLeft } from '@/components/StyledComponents';
import { BtnRoute } from '@/pages/DataStudio/route';
import SchemaTree from '@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree';
import {DataSources} from '@/types/RegCenter/data';
import {l} from '@/utils/intl';
import {DatabaseOutlined, TableOutlined} from '@ant-design/icons';
import {Key, ProForm, ProFormSelect} from '@ant-design/pro-components';
import {connect} from '@umijs/max';
import {Spin, Tag} from 'antd';
import React, {useEffect, useState} from 'react';
import {StateType, STUDIO_MODEL} from '../../model';
import {clearMetaDataTable, getDataBase, showMetaDataTable} from './service';
import DataSourceModal from "@/pages/RegCenter/DataSource/components/DataSourceModal";
import {handleTest, saveOrUpdateHandle} from "@/pages/RegCenter/DataSource/service";
import DataSourceModal from '@/pages/RegCenter/DataSource/components/DataSourceModal';
import { handleTest, saveOrUpdateHandle } from '@/pages/RegCenter/DataSource/service';
import { DataSources } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { DatabaseOutlined, TableOutlined } from '@ant-design/icons';
import { Key, ProForm, ProFormSelect } from '@ant-design/pro-components';
import { connect } from '@umijs/max';
import { Spin, Tag } from 'antd';
import { useEffect, useState } from 'react';
import { StateType, STUDIO_MODEL } from '../../model';
import { clearMetaDataTable, getDataBase, showMetaDataTable } from './service';
const MetaData = (props: any) => {
const {
dispatch,
toolContentHeight,
database: { dbData, selectDatabaseId, expandKeys, selectKeys }
} = props;
const [treeData, setTreeData] = useState<[]>([]);
const [isLoadingDatabase, setIsLoadingDatabase] = useState(false);
const [showCreate, setShowCreate] = useState(false);
const selectDb = (dbData as DataSources.DataSource[]).filter((x) => x.id === selectDatabaseId)[0];
/**
* @description: 刷新树数据
* @param {number} databaseId
*/
const onRefreshTreeData = async (databaseId: number) => {
if (!databaseId) {
setIsLoadingDatabase(false);
return;
}
setIsLoadingDatabase(true);
const tables = (await showMetaDataTable(databaseId)) ?? [];
setIsLoadingDatabase(false);
for (let table of tables) {
table.title = table.name;
table.key = table.name;
table.icon = <DatabaseOutlined />;
table.children = table.tables;
for (let child of table.children) {
child.title = child.name;
child.key = table.name + '.' + child.name;
child.icon = <TableOutlined />;
child.isLeaf = true;
child.schema = table.name;
child.table = child.name;
}
}
setTreeData(tables);
};
useEffect(() => {
if (selectDatabaseId) {
onRefreshTreeData(selectDatabaseId);
}
}, []);
/**
* 数据库选择改变时间时 刷新树数据
* @param {number} value
*/
const onChangeDataBase = (value: number) => {
onRefreshTreeData(value);
};
BtnRoute['menu.datastudio.metadata'][0].onClick = () => {
setShowCreate(true);
};
BtnRoute['menu.datastudio.metadata'][1].onClick = () => {
if (!selectDatabaseId) return;
setIsLoadingDatabase(true);
clearMetaDataTable(selectDatabaseId).then(() => {
onChangeDataBase(selectDatabaseId);
});
};
/**
* 构建数据库列表 下拉框
*/
const getDataBaseOptions = () => {
return dbData.map(({ id, name, type, enabled, status }: DataSources.DataSource) => ({
key: id,
value: id,
label: (
<TagAlignLeft>
<Tag key={id} color={enabled ? 'processing' : 'error'}>
{type}
</Tag>
{name}
</TagAlignLeft>
),
disabled: !enabled || !status
}));
};
/**
* 树节点点击事件 添加tab页 并传递参数
* @param keys
* @param info
*/
const handleTreeNodeClick = async (keys: Key[], info: any) => {
// 选中的key
dispatch({
type: STUDIO_MODEL.updateDatabaseSelectKey,
payload: keys
});
const {
dispatch,
toolContentHeight,
database: {dbData, selectDatabaseId, expandKeys, selectKeys}
} = props;
const [treeData, setTreeData] = useState<[]>([]);
const [isLoadingDatabase, setIsLoadingDatabase] = useState(false);
const [showCreate, setShowCreate] = useState(false);
const selectDb = (dbData as DataSources.DataSource[]).filter((x) => x.id === selectDatabaseId)[0];
/**
* @description: 刷新树数据
* @param {number} databaseId
*/
const onRefreshTreeData = async (databaseId: number) => {
if (!databaseId) {
setIsLoadingDatabase(false);
return;
}
setIsLoadingDatabase(true);
const tables = (await showMetaDataTable(databaseId)) ?? [];
setIsLoadingDatabase(false);
for (let table of tables) {
table.title = table.name;
table.key = table.name;
table.icon = <DatabaseOutlined/>;
table.children = table.tables;
for (let child of table.children) {
child.title = child.name;
child.key = table.name + '.' + child.name;
child.icon = <TableOutlined/>;
child.isLeaf = true;
child.schema = table.name;
child.table = child.name;
}
}
setTreeData(tables);
};
useEffect(() => {
if (selectDatabaseId) {
onRefreshTreeData(selectDatabaseId);
}
}, []);
/**
* 数据库选择改变时间时 刷新树数据
* @param {number} value
*/
const onChangeDataBase = (value: number) => {
onRefreshTreeData(value);
};
BtnRoute['menu.datastudio.metadata'][0].onClick = () => {
setShowCreate(true)
};
BtnRoute['menu.datastudio.metadata'][1].onClick = () => {
if (!selectDatabaseId) return;
setIsLoadingDatabase(true);
clearMetaDataTable(selectDatabaseId).then(() => {
onChangeDataBase(selectDatabaseId);
});
};
/**
* 构建数据库列表 下拉框
*/
const getDataBaseOptions = () => {
return dbData.map(({id, name, type, enabled, status}: DataSources.DataSource) => ({
key: id,
value: id,
label: (
<TagAlignLeft>
<Tag key={id} color={enabled ? 'processing' : 'error'}>
{type}
</Tag>
{name}
</TagAlignLeft>
),
disabled: !enabled || !status
}));
};
/**
* 树节点点击事件 添加tab页 并传递参数
* @param keys
* @param info
*/
const handleTreeNodeClick = async (keys: Key[], info: any) => {
// 选中的key
dispatch({
type: STUDIO_MODEL.updateDatabaseSelectKey,
payload: keys
});
const {
node: {isLeaf, parentId: schemaName, name: tableName, fullInfo}
} = info;
if (!isLeaf) {
return;
}
const queryParams = {id: selectDatabaseId, schemaName, tableName};
dispatch({
type: STUDIO_MODEL.addTab,
payload: {
icon: selectDb.type,
id: selectDatabaseId + schemaName + tableName,
breadcrumbLabel: [selectDb.type, selectDb.name].join('/'),
label: schemaName + '.' + tableName,
params: {queryParams: queryParams, tableInfo: fullInfo},
type: 'metadata'
}
});
};
/**
* 数据库选择改变事件
* @param {number} databaseId
*/
const handleSelectDataBaseId = (databaseId: number) => {
dispatch({
type: STUDIO_MODEL.updateSelectDatabaseId,
payload: databaseId
});
onChangeDataBase(databaseId);
};
/**
* 树节点展开事件
* @param {Key[]} expandedKeys
*/
const handleTreeExpand = (expandedKeys: Key[]) => {
dispatch({
type: STUDIO_MODEL.updateDatabaseExpandKey,
payload: expandedKeys
});
};
return (
<Spin spinning={isLoadingDatabase} delay={500}>
<DataSourceModal
values={{}}
visible={showCreate}
onCancel={() => setShowCreate(false)}
onTest={(value) => handleTest(value)}
onSubmit={async (value) => {
await saveOrUpdateHandle(value);
const data = await getDataBase();
dispatch({
type: STUDIO_MODEL.saveDataBase,
payload: data
});
}}
/>
<ProForm
style={{height: 40}}
initialValues={{selectDb: selectDatabaseId}}
submitter={false}
>
<ProFormSelect
style={{paddingInline: 6}}
// width={leftContainer.width }
width={'xl'}
// addonAfter={<ReloadOutlined spin={isLoadingDatabase} title={l('button.refresh')} onClick={() => refreshDataBase()} />}
allowClear={false}
name={'selectDb'}
placeholder={l('pages.metadata.selectDatabase')}
options={getDataBaseOptions()}
fieldProps={{
onSelect: (selectId) => handleSelectDataBaseId(selectId as number)
}}
/>
</ProForm>
<SchemaTree
selectKeys={selectKeys}
expandKeys={expandKeys}
style={{height: toolContentHeight - 64 - 20}}
onNodeClick={handleTreeNodeClick}
treeData={treeData}
onExpand={handleTreeExpand}
/>
</Spin>
);
node: { isLeaf, parentId: schemaName, name: tableName, fullInfo }
} = info;
if (!isLeaf) {
return;
}
const queryParams = { id: selectDatabaseId, schemaName, tableName };
dispatch({
type: STUDIO_MODEL.addTab,
payload: {
icon: selectDb.type,
id: selectDatabaseId + schemaName + tableName,
breadcrumbLabel: [selectDb.type, selectDb.name].join('/'),
label: schemaName + '.' + tableName,
params: { queryParams: queryParams, tableInfo: fullInfo },
type: 'metadata'
}
});
};
/**
* 数据库选择改变事件
* @param {number} databaseId
*/
const handleSelectDataBaseId = (databaseId: number) => {
dispatch({
type: STUDIO_MODEL.updateSelectDatabaseId,
payload: databaseId
});
onChangeDataBase(databaseId);
};
/**
* 树节点展开事件
* @param {Key[]} expandedKeys
*/
const handleTreeExpand = (expandedKeys: Key[]) => {
dispatch({
type: STUDIO_MODEL.updateDatabaseExpandKey,
payload: expandedKeys
});
};
return (
<Spin spinning={isLoadingDatabase} delay={500}>
<DataSourceModal
values={{}}
visible={showCreate}
onCancel={() => setShowCreate(false)}
onTest={(value) => handleTest(value)}
onSubmit={async (value) => {
await saveOrUpdateHandle(value);
const data = await getDataBase();
dispatch({
type: STUDIO_MODEL.saveDataBase,
payload: data
});
}}
/>
<ProForm
style={{ height: 40 }}
initialValues={{ selectDb: selectDatabaseId }}
submitter={false}
>
<ProFormSelect
style={{ paddingInline: 6 }}
// width={leftContainer.width }
width={'xl'}
// addonAfter={<ReloadOutlined spin={isLoadingDatabase} title={l('button.refresh')} onClick={() => refreshDataBase()} />}
allowClear={false}
name={'selectDb'}
placeholder={l('pages.metadata.selectDatabase')}
options={getDataBaseOptions()}
fieldProps={{
onSelect: (selectId) => handleSelectDataBaseId(selectId as number)
}}
/>
</ProForm>
<SchemaTree
selectKeys={selectKeys}
expandKeys={expandKeys}
style={{ height: toolContentHeight - 64 - 20 }}
onNodeClick={handleTreeNodeClick}
treeData={treeData}
onExpand={handleTreeExpand}
/>
</Spin>
);
};
export default connect(({Studio}: {
Studio: StateType
}) => ({
toolContentHeight: Studio.toolContentHeight,
leftContainer: Studio.leftContainer,
database: Studio.database
export default connect(({ Studio }: { Studio: StateType }) => ({
toolContentHeight: Studio.toolContentHeight,
leftContainer: Studio.leftContainer,
database: Studio.database
}))(MetaData);
......@@ -17,294 +17,288 @@
*
*/
import {CircleDataStudioButtonProps} from '@/components/CallBackButton/CircleBtn';
import { CircleDataStudioButtonProps } from '@/components/CallBackButton/CircleBtn';
import Console from '@/pages/DataStudio/BottomContainer/Console';
import Lineage from '@/pages/DataStudio/BottomContainer/Lineage';
import Result from '@/pages/DataStudio/BottomContainer/Result';
import TableData from '@/pages/DataStudio/BottomContainer/TableData';
import {Catalog} from '@/pages/DataStudio/LeftContainer/Catalog';
import { Catalog } from '@/pages/DataStudio/LeftContainer/Catalog';
import MetaData from '@/pages/DataStudio/LeftContainer/MetaData';
import Project from '@/pages/DataStudio/LeftContainer/Project';
import {TabsPageSubType, TabsPageType} from '@/pages/DataStudio/model';
import { TabsPageSubType, TabsPageType } from '@/pages/DataStudio/model';
import ExecuteConfig from '@/pages/DataStudio/RightContainer/ExecuteConfig';
import HistoryVersion from '@/pages/DataStudio/RightContainer/HistoryVersion';
import JobConfig from '@/pages/DataStudio/RightContainer/JobConfig';
import JobInfo from '@/pages/DataStudio/RightContainer/JobInfo';
import SavePoints from '@/pages/DataStudio/RightContainer/SavePoints';
import {l} from '@/utils/intl';
import { l } from '@/utils/intl';
import {
ApartmentOutlined,
ArrowsAltOutlined,
BarChartOutlined,
CalendarOutlined,
ConsoleSqlOutlined,
DatabaseOutlined,
DesktopOutlined,
EnvironmentOutlined,
FolderOutlined,
HistoryOutlined,
InfoCircleOutlined,
MonitorOutlined,
PlayCircleOutlined,
PlusCircleOutlined, PlusOutlined,
ReloadOutlined,
RightSquareOutlined,
SettingOutlined,
ShrinkOutlined,
TableOutlined,
ToolOutlined
ApartmentOutlined,
ArrowsAltOutlined,
BarChartOutlined,
CalendarOutlined,
ConsoleSqlOutlined,
DatabaseOutlined,
DesktopOutlined,
EnvironmentOutlined,
FolderOutlined,
HistoryOutlined,
InfoCircleOutlined,
MonitorOutlined,
PlayCircleOutlined,
PlusCircleOutlined,
PlusOutlined,
ReloadOutlined,
RightSquareOutlined,
SettingOutlined,
ShrinkOutlined,
TableOutlined,
ToolOutlined
} from '@ant-design/icons';
import {DiffEditor} from '@monaco-editor/react';
import {ReactNode} from 'react';
import { DiffEditor } from '@monaco-editor/react';
import { ReactNode } from 'react';
export const LeftSide = [
{
auth: '/datastudio/left/project',
key: 'menu.datastudio.project',
icon: <ConsoleSqlOutlined/>,
label: l('menu.datastudio.project'),
children: <Project/>
},
{
auth: '/datastudio/left/catalog',
key: 'menu.datastudio.catalog',
icon: <TableOutlined/>,
label: l('menu.datastudio.catalog'),
children: <Catalog/>
},
{
auth: '/datastudio/left/metadata',
key: 'menu.datastudio.metadata',
icon: <DatabaseOutlined/>,
label: l('menu.datastudio.metadata'),
children: <MetaData/>
}
{
auth: '/datastudio/left/project',
key: 'menu.datastudio.project',
icon: <ConsoleSqlOutlined />,
label: l('menu.datastudio.project'),
children: <Project />
},
{
auth: '/datastudio/left/catalog',
key: 'menu.datastudio.catalog',
icon: <TableOutlined />,
label: l('menu.datastudio.catalog'),
children: <Catalog />
},
{
auth: '/datastudio/left/metadata',
key: 'menu.datastudio.metadata',
icon: <DatabaseOutlined />,
label: l('menu.datastudio.metadata'),
children: <MetaData />
}
];
export const RightSide: TabProp[] = [
{
auth: '/datastudio/right/jobConfig',
key: 'menu.datastudio.jobConfig',
icon: <SettingOutlined />,
label: l('menu.datastudio.jobConfig'),
children: <JobConfig />,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
},
{
auth: '/datastudio/right/executeConfig',
key: 'menu.datastudio.executeConfig',
icon: <PlayCircleOutlined />,
label: l('menu.datastudio.executeConfig'),
children: <ExecuteConfig />,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
},
{
auth: '/datastudio/right/savePoint',
key: 'menu.datastudio.savePoint',
icon: <FolderOutlined />,
label: l('menu.datastudio.savePoint'),
children: <SavePoints />,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
},
{
auth: '/datastudio/right/historyVision',
key: 'menu.datastudio.historyVision',
icon: <HistoryOutlined />,
label: l('menu.datastudio.historyVision'),
children: <HistoryVersion />,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
},
{
auth: '/datastudio/right/jobInfo',
key: 'menu.datastudio.jobInfo',
icon: <InfoCircleOutlined />,
label: l('menu.datastudio.jobInfo'),
children: <JobInfo />,
isShow: (type) => type !== TabsPageType.None
}
];
export const LeftBottomSide = [
{
auth: '/datastudio/bottom/console',
key: 'menu.datastudio.console',
icon: <RightSquareOutlined />,
label: l('menu.datastudio.console'),
children: <Console />
},
{
auth: '/datastudio/bottom/result',
key: 'menu.datastudio.result',
icon: <MonitorOutlined />,
label: l('menu.datastudio.result'),
children: <Result />
},
{
auth: '/datastudio/bottom/bi',
key: 'menu.datastudio.bi',
icon: <BarChartOutlined />,
label: l('menu.datastudio.bi')
},
{
auth: '/datastudio/bottom/lineage',
key: 'menu.datastudio.lineage',
icon: <ApartmentOutlined />,
label: l('menu.datastudio.lineage'),
children: <Lineage />
},
{
auth: '/datastudio/bottom/process',
key: 'menu.datastudio.process',
icon: <DesktopOutlined />,
label: l('menu.datastudio.process')
},
{
auth: '/datastudio/bottom/history',
key: 'menu.datastudio.history',
icon: <CalendarOutlined />,
label: l('menu.datastudio.history')
},
{
auth: '/datastudio/bottom/table-data',
key: 'menu.datastudio.table-data',
icon: <TableOutlined />,
label: l('menu.datastudio.table-data'),
children: <TableData />
},
{
auth: '/datastudio/bottom/tool',
key: 'menu.datastudio.tool',
icon: <ToolOutlined />,
label: l('menu.datastudio.tool')
}
];
export const LeftBottomMoreTabs: { [c: string]: TabProp[] } = {
'menu.datastudio.tool': [
{
auth: '/datastudio/right/jobConfig',
key: 'menu.datastudio.jobConfig',
icon: <SettingOutlined/>,
label: l('menu.datastudio.jobConfig'),
children: <JobConfig/>,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
},
{
auth: '/datastudio/right/executeConfig',
key: 'menu.datastudio.executeConfig',
icon: <PlayCircleOutlined/>,
label: l('menu.datastudio.executeConfig'),
children: <ExecuteConfig/>,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
key: 'menu.datastudio.tool.text-comparison',
icon: <ToolOutlined />,
label: l('menu.datastudio.tool.text-comparison'),
children: (
<DiffEditor
height={'100%'}
options={{
readOnly: false,
originalEditable: true,
selectOnLineNumbers: true,
lineDecorationsWidth: 20,
mouseWheelZoom: true,
automaticLayout: true,
scrollBeyondLastLine: false,
scrollbar: {
useShadows: false,
verticalScrollbarSize: 8,
horizontalScrollbarSize: 8,
arrowSize: 30
}
}}
language={'text'}
/>
)
},
{
auth: '/datastudio/right/savePoint',
key: 'menu.datastudio.savePoint',
icon: <FolderOutlined/>,
label: l('menu.datastudio.savePoint'),
children: <SavePoints/>,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
},
key: 'menu.datastudio.tool.datax2',
icon: <ToolOutlined />,
label: 'menu.datastudio.tool.datax2',
children: <div>datax2</div>
}
],
'menu.datastudio.tool2': [
{
auth: '/datastudio/right/historyVision',
key: 'menu.datastudio.historyVision',
icon: <HistoryOutlined/>,
label: l('menu.datastudio.historyVision'),
children: <HistoryVersion/>,
isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType
key: 'menu.datastudio.tool.text-comparison',
icon: <ToolOutlined />,
label: 'menu.datastudio.tool.text-comparison',
children: (
<DiffEditor
height={'95%'}
options={{
readOnly: true,
selectOnLineNumbers: true,
lineDecorationsWidth: 20,
mouseWheelZoom: true,
automaticLayout: true
}}
language={'sql'}
original={''}
modified={''}
/>
)
},
{
auth: '/datastudio/right/jobInfo',
key: 'menu.datastudio.jobInfo',
icon: <InfoCircleOutlined/>,
label: l('menu.datastudio.jobInfo'),
children: <JobInfo/>,
isShow: (type) => type !== TabsPageType.None
key: 'menu.datastudio.tool.datax2',
icon: <ToolOutlined />,
label: 'menu.datastudio.tool.datax2',
children: <div>datax2</div>
}
];
]
};
export const LeftBottomSide = [
{
auth: '/datastudio/bottom/console',
key: 'menu.datastudio.console',
icon: <RightSquareOutlined/>,
label: l('menu.datastudio.console'),
children: <Console/>
},
// btn route
export const BtnRoute: { [c: string]: CircleDataStudioButtonProps[] } = {
'menu.datastudio.metadata': [
{
auth: '/datastudio/bottom/result',
key: 'menu.datastudio.result',
icon: <MonitorOutlined/>,
label: l('menu.datastudio.result'),
children: <Result/>
icon: <PlusOutlined />,
title: l('button.create'),
onClick: () => {}
},
{
auth: '/datastudio/bottom/bi',
key: 'menu.datastudio.bi',
icon: <BarChartOutlined/>,
label: l('menu.datastudio.bi')
},
icon: <ReloadOutlined />,
title: l('button.refresh'),
onClick: () => {}
}
],
'menu.datastudio.catalog': [
{
auth: '/datastudio/bottom/lineage',
key: 'menu.datastudio.lineage',
icon: <ApartmentOutlined/>,
label: l('menu.datastudio.lineage'),
children: <Lineage/>
},
icon: <ReloadOutlined />,
title: l('button.refresh'),
onClick: () => {}
}
],
'menu.datastudio.project': [
{
auth: '/datastudio/bottom/process',
key: 'menu.datastudio.process',
icon: <DesktopOutlined/>,
label: l('menu.datastudio.process')
icon: <PlusCircleOutlined />,
title: l('right.menu.createRoot'),
key: 'right.menu.createRoot',
onClick: () => {}
},
{
auth: '/datastudio/bottom/history',
key: 'menu.datastudio.history',
icon: <CalendarOutlined/>,
label: l('menu.datastudio.history')
icon: <ArrowsAltOutlined />,
title: l('button.expand-all'),
key: 'button.expand-all',
onClick: () => {}
},
{
auth: '/datastudio/bottom/table-data',
key: 'menu.datastudio.table-data',
icon: <TableOutlined/>,
label: l('menu.datastudio.table-data'),
children: <TableData/>
icon: <ShrinkOutlined />,
title: l('button.collapse-all'),
key: 'button.collapse-all',
onClick: () => {}
},
{
auth: '/datastudio/bottom/tool',
key: 'menu.datastudio.tool',
icon: <ToolOutlined/>,
label: l('menu.datastudio.tool')
icon: <EnvironmentOutlined />,
title: l('button.position'),
key: 'button.position',
onClick: () => {}
}
];
export const LeftBottomMoreTabs: { [c: string]: TabProp[] } = {
'menu.datastudio.tool': [
{
key: 'menu.datastudio.tool.text-comparison',
icon: <ToolOutlined/>,
label: l('menu.datastudio.tool.text-comparison'),
children: (
<DiffEditor
height={'100%'}
options={{
readOnly: false,
originalEditable: true,
selectOnLineNumbers: true,
lineDecorationsWidth: 20,
mouseWheelZoom: true,
automaticLayout: true,
scrollBeyondLastLine: false,
scrollbar: {
useShadows: false,
verticalScrollbarSize: 8,
horizontalScrollbarSize: 8,
arrowSize: 30
}
}}
language={'text'}
/>
)
},
{
key: 'menu.datastudio.tool.datax2',
icon: <ToolOutlined/>,
label: 'menu.datastudio.tool.datax2',
children: <div>datax2</div>
}
],
'menu.datastudio.tool2': [
{
key: 'menu.datastudio.tool.text-comparison',
icon: <ToolOutlined/>,
label: 'menu.datastudio.tool.text-comparison',
children: (
<DiffEditor
height={'95%'}
options={{
readOnly: true,
selectOnLineNumbers: true,
lineDecorationsWidth: 20,
mouseWheelZoom: true,
automaticLayout: true
}}
language={'sql'}
original={''}
modified={''}
/>
)
},
{
key: 'menu.datastudio.tool.datax2',
icon: <ToolOutlined/>,
label: 'menu.datastudio.tool.datax2',
children: <div>datax2</div>
}
]
};
// btn route
export const BtnRoute: { [c: string]: CircleDataStudioButtonProps[] } = {
'menu.datastudio.metadata': [
{
icon: <PlusOutlined />,
title: l('button.create'),
onClick: () => {
}
},
{
icon: <ReloadOutlined/>,
title: l('button.refresh'),
onClick: () => {
}
}
],
'menu.datastudio.catalog': [
{
icon: <ReloadOutlined/>,
title: l('button.refresh'),
onClick: () => {
}
}
],
'menu.datastudio.project': [
{
icon: <PlusCircleOutlined/>,
title: l('right.menu.createRoot'),
key: 'right.menu.createRoot',
onClick: () => {
}
},
{
icon: <ArrowsAltOutlined/>,
title: l('button.expand-all'),
key: 'button.expand-all',
onClick: () => {
}
},
{
icon: <ShrinkOutlined/>,
title: l('button.collapse-all'),
key: 'button.collapse-all',
onClick: () => {
}
},
{
icon: <EnvironmentOutlined/>,
title: l('button.position'),
key: 'button.position',
onClick: () => {
}
}
]
]
};
export type TabProp = {
key: string;
icon: ReactNode;
label: string;
children: ReactNode;
isShow?: (type: TabsPageType, subType?: TabsPageSubType) => boolean;
auth?: string;
key: string;
icon: ReactNode;
label: string;
children: ReactNode;
isShow?: (type: TabsPageType, subType?: TabsPageSubType) => boolean;
auth?: string;
};
......@@ -21,7 +21,10 @@ const JobList = () => {
const jobListColumns: ProColumns<Jobs.JobInstance>[] = [
{
title: l('devops.jobinfo.config.taskId'),
dataIndex: 'taskId'
dataIndex: 'taskId',
width: '6%',
valueType: 'indexBorder',
fixed: 'left'
},
{
title: l('global.table.jobname'),
......@@ -43,7 +46,8 @@ const JobList = () => {
{
title: l('devops.jobinfo.config.JobId'),
dataIndex: 'jid',
width: '15%'
width: '20%',
copyable: true
},
{
title: l('global.table.createTime'),
......@@ -67,6 +71,8 @@ const JobList = () => {
{
title: l('global.table.operate'),
valueType: 'option',
width: '5%',
fixed: 'right',
render: (text: any, record: Jobs.JobInstance) => [
<Button
className={'options-button'}
......
......@@ -305,7 +305,13 @@ export default () => {
<Badge.Ribbon
className={'card-list-item-wrapper'}
color={item.autoRegisters ? 'green' : 'yellow'}
text={item.autoRegisters ? l('rc.ci.ar') : <span style={{color:"crimson"}}>{l('rc.ci.mr')}</span>}
text={
item.autoRegisters ? (
l('rc.ci.ar')
) : (
<span style={{ color: 'crimson' }}>{l('rc.ci.mr')}</span>
)
}
>
<Card
headStyle={{ minHeight: '10px' }}
......
......@@ -17,14 +17,13 @@
*
*/
import {WebIcon} from '@/components/Icons/CustomIcons';
import {RUN_MODE} from '@/services/constants';
import {Cluster} from '@/types/RegCenter/data';
import {l} from '@/utils/intl';
import {Button, Typography} from 'antd';
import {RuleObject} from 'rc-field-form/es/interface';
import { RUN_MODE } from '@/services/constants';
import { Cluster } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { Typography } from 'antd';
import { RuleObject } from 'rc-field-form/es/interface';
const {Text, Paragraph, Link} = Typography;
const { Text, Paragraph, Link } = Typography;
/**
* validatorJMHAAdderess
......@@ -32,21 +31,21 @@ const {Text, Paragraph, Link} = Typography;
* @param value
*/
export const validatorJMHAAdderess = (rule: RuleObject, value = '') => {
let hostArray = [];
if (value.trim().length === 0) {
return Promise.reject(new Error(l('rc.ci.jmhaPlaceholder')));
} else {
hostArray = value.split(',');
for (let i = 0; i < hostArray.length; i++) {
if (hostArray[i].includes('/')) {
return Promise.reject(new Error(l('rc.ci.jmha.validate.slash')));
}
if (parseInt(hostArray[i].split(':')[1]) >= 65535) {
return Promise.reject(new Error(l('rc.ci.jmha.validate.port')));
}
}
return Promise.resolve();
let hostArray = [];
if (value.trim().length === 0) {
return Promise.reject(new Error(l('rc.ci.jmhaPlaceholder')));
} else {
hostArray = value.split(',');
for (let i = 0; i < hostArray.length; i++) {
if (hostArray[i].includes('/')) {
return Promise.reject(new Error(l('rc.ci.jmha.validate.slash')));
}
if (parseInt(hostArray[i].split(':')[1]) >= 65535) {
return Promise.reject(new Error(l('rc.ci.jmha.validate.port')));
}
}
return Promise.resolve();
}
};
/**
......@@ -54,20 +53,22 @@ export const validatorJMHAAdderess = (rule: RuleObject, value = '') => {
* @param record
*/
export const renderWebUiRedirect = (record: Cluster.Instance) => {
if (
record.status &&
(record.type === RUN_MODE.YARN_SESSION ||
record.type === RUN_MODE.STANDALONE ||
record.type === RUN_MODE.YARN_APPLICATION ||
record.type === RUN_MODE.YARN_PER_JOB)
) {
return (
<Link
href={`/api/flink/${record.jobManagerHost}/#/overview`}
key={`${record.id}_webui`}
target='_blank'
>{record.jobManagerHost}</Link>
);
}
return <Link>{record.hosts}</Link>;
if (
record.status &&
(record.type === RUN_MODE.YARN_SESSION ||
record.type === RUN_MODE.STANDALONE ||
record.type === RUN_MODE.YARN_APPLICATION ||
record.type === RUN_MODE.YARN_PER_JOB)
) {
return (
<Link
href={`/api/flink/${record.jobManagerHost}/#/overview`}
key={`${record.id}_webui`}
target='_blank'
>
{record.jobManagerHost}
</Link>
);
}
return <Link>{record.hosts}</Link>;
};
......@@ -24,6 +24,6 @@ export const enum ClusterType {
KUBERNETES_SESSION = 'kubernetes-session',
KUBERNETES_NATIVE = 'kubernetes-application',
KUBERNETES_OPERATOR = 'kubernetes-application-operator',
YARN_APPLICATION = 'yarn-application',
LOACL= 'local',
YARN_APPLICATION = 'yarn-application',
LOACL = 'local'
}
......@@ -24,9 +24,9 @@ import { Authorized, HasAuthority } from '@/hooks/useAccess';
import { StateType, STUDIO_MODEL } from '@/pages/DataStudio/model';
import DataSourceDetail from '@/pages/RegCenter/DataSource/components/DataSourceDetail';
import { renderDBIcon } from '@/pages/RegCenter/DataSource/components/function';
import { handleTest, saveOrUpdateHandle } from '@/pages/RegCenter/DataSource/service';
import { queryList } from '@/services/api';
import {
handleAddOrUpdate,
handleOption,
handlePutDataByParams,
handleRemoveById,
......@@ -37,7 +37,7 @@ import { API_CONSTANTS } from '@/services/endpoints';
import { DataSources } from '@/types/RegCenter/data.d';
import { l } from '@/utils/intl';
import { WarningMessage } from '@/utils/messages';
import {useNavigate} from '@@/exports';
import { useNavigate } from '@@/exports';
import {
CheckCircleOutlined,
CopyTwoTone,
......@@ -50,7 +50,6 @@ import DescriptionsItem from 'antd/es/descriptions/Item';
import React, { useEffect, useState } from 'react';
import { connect } from 'umi';
import DataSourceModal from '../DataSourceModal';
import {handleTest, saveOrUpdateHandle} from "@/pages/RegCenter/DataSource/service";
const DataSourceTable: React.FC<connect & StateType> = (props) => {
const { dispatch } = props;
......@@ -118,8 +117,6 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
);
};
/**
* handle check heart
* @param item
......@@ -138,8 +135,6 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
);
};
/**
* render sub title
* @param item
......@@ -290,7 +285,7 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
visible={modalVisible}
onCancel={cancelAll}
onTest={(value) => handleTest(value)}
onSubmit={(value) => executeAndCallbackRefresh(async ()=>saveOrUpdateHandle(value))}
onSubmit={(value) => executeAndCallbackRefresh(async () => saveOrUpdateHandle(value))}
/>
</>
) : (
......
......@@ -17,168 +17,164 @@
import CodeEdit from '@/components/CustomEditor/CodeEdit';
import {
AUTO_COMPLETE_TYPE,
DATA_SOURCE_TYPE_OPTIONS,
GROUP_TYPE
AUTO_COMPLETE_TYPE,
DATA_SOURCE_TYPE_OPTIONS,
GROUP_TYPE
} from '@/pages/RegCenter/DataSource/components/constants';
import {DataSources} from '@/types/RegCenter/data.d';
import {l} from '@/utils/intl';
import {
ProForm,
ProFormGroup,
ProFormSelect,
ProFormText
} from '@ant-design/pro-components';
import {AutoComplete, Form} from 'antd';
import {FormInstance} from 'antd/es/form/hooks/useForm';
import {Values} from 'async-validator';
import React, {useState} from 'react';
import TextArea from "antd/es/input/TextArea";
import { DataSources } from '@/types/RegCenter/data.d';
import { l } from '@/utils/intl';
import { ProForm, ProFormGroup, ProFormSelect, ProFormText } from '@ant-design/pro-components';
import { AutoComplete, Form } from 'antd';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import TextArea from 'antd/es/input/TextArea';
import { Values } from 'async-validator';
import React, { useState } from 'react';
type DataSourceProFormProps = {
values: Partial<DataSources.DataSource>;
form: FormInstance<Values>;
flinkConfigChange: (value: string) => void;
flinkTemplateChange: (value: string) => void;
values: Partial<DataSources.DataSource>;
form: FormInstance<Values>;
flinkConfigChange: (value: string) => void;
flinkTemplateChange: (value: string) => void;
};
const CodeEditProps = {
height: '30vh',
width: '22vw',
lineNumbers: 'off',
language: 'sql'
height: '30vh',
width: '22vw',
lineNumbers: 'off',
language: 'sql'
};
const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
const {values, form, flinkTemplateChange, flinkConfigChange} = props;
const [excludeFormItem, setExcludeFormItem] = useState<boolean>(false);
const [dbType, setDbType] = useState<string>(values.type ?? 'MySQL');
const handleTypeChange = (value: any) => {
if (value.type) setDbType(value.type);
if (value.type === 'Hive' || value.type === 'Presto') {
setExcludeFormItem(true);
} else {
setExcludeFormItem(false);
}
};
const { values, form, flinkTemplateChange, flinkConfigChange } = props;
const [excludeFormItem, setExcludeFormItem] = useState<boolean>(false);
const renderDataSourceForm = () => {
return (
<>
<ProForm.Group>
<ProFormText
name='name'
width={'md'}
label={l('rc.ds.name')}
rules={[{required: true, message: l('rc.ds.namePlaceholder')}]}
placeholder={l('rc.ds.namePlaceholder')}
/>
<ProFormSelect
name='groupName'
width={'sm'}
label={l('rc.ds.groupName')}
options={GROUP_TYPE}
placeholder={l('rc.ds.groupNamePlaceholder')}
/>
<ProFormSelect
name='type'
width={'sm'}
label={l('rc.ds.type')}
showSearch
initialValue={dbType}
options={DATA_SOURCE_TYPE_OPTIONS}
rules={[{required: true, message: l('rc.ds.typePlaceholder')}]}
placeholder={l('rc.ds.typePlaceholder')}
/>
const [dbType, setDbType] = useState<string>(values.type ?? 'MySQL');
<ProFormText
name='username'
width={'sm'}
label={l('rc.ds.username')}
rules={[{required: true, message: l('rc.ds.usernamePlaceholder')}]}
placeholder={l('rc.ds.usernamePlaceholder')}
/>
<ProFormText.Password
name='password'
width={'sm'}
label={l('rc.ds.password')}
rules={[
{
required: dbType !== 'Doris',
message: l('rc.ds.passwordPlaceholder')
}
]}
placeholder={l('rc.ds.passwordPlaceholder')}
/>
<ProFormText
name='note'
width={'md'}
label={l('global.table.note')}
placeholder={l('global.table.notePlaceholder')}
/>
</ProForm.Group>
const handleTypeChange = (value: any) => {
if (value.type) setDbType(value.type);
if (value.type === 'Hive' || value.type === 'Presto') {
setExcludeFormItem(true);
} else {
setExcludeFormItem(false);
}
};
<ProForm.Group>
<Form.Item name="url" label={l('rc.ds.url')}
rules={[{required: true, message: l('rc.ds.urlPlaceholder')}]}>
const renderDataSourceForm = () => {
return (
<>
<ProForm.Group>
<ProFormText
name='name'
width={'md'}
label={l('rc.ds.name')}
rules={[{ required: true, message: l('rc.ds.namePlaceholder') }]}
placeholder={l('rc.ds.namePlaceholder')}
/>
<ProFormSelect
name='groupName'
width={'sm'}
label={l('rc.ds.groupName')}
options={GROUP_TYPE}
placeholder={l('rc.ds.groupNamePlaceholder')}
/>
<ProFormSelect
name='type'
width={'sm'}
label={l('rc.ds.type')}
showSearch
initialValue={dbType}
options={DATA_SOURCE_TYPE_OPTIONS}
rules={[{ required: true, message: l('rc.ds.typePlaceholder') }]}
placeholder={l('rc.ds.typePlaceholder')}
/>
<AutoComplete
virtual
placement={'topLeft'}
autoClearSearchValue
options={AUTO_COMPLETE_TYPE}
style={{
width: parent.innerWidth / 2 - 80
}}
filterOption
onSelect={(value) => form && form.setFieldsValue({url: value})}
>
<TextArea placeholder={l('rc.ds.urlPlaceholder')}/>
{/*<ProFormTextArea*/}
{/* name='url'*/}
{/* width={parent.innerWidth / 2 - 80}*/}
{/* label={l('rc.ds.url')}*/}
{/* rules={[{ required: true, message: l('rc.ds.urlPlaceholder') }]}*/}
{/* placeholder={l('rc.ds.urlPlaceholder')}*/}
{/*/>*/}
</AutoComplete>
</Form.Item>
<ProFormText
name='username'
width={'sm'}
label={l('rc.ds.username')}
rules={[{ required: true, message: l('rc.ds.usernamePlaceholder') }]}
placeholder={l('rc.ds.usernamePlaceholder')}
/>
<ProFormText.Password
name='password'
width={'sm'}
label={l('rc.ds.password')}
rules={[
{
required: dbType !== 'Doris',
message: l('rc.ds.passwordPlaceholder')
}
]}
placeholder={l('rc.ds.passwordPlaceholder')}
/>
<ProFormText
name='note'
width={'md'}
label={l('global.table.note')}
placeholder={l('global.table.notePlaceholder')}
/>
</ProForm.Group>
</ProForm.Group>
<ProForm.Group>
<Form.Item
name='url'
label={l('rc.ds.url')}
rules={[{ required: true, message: l('rc.ds.urlPlaceholder') }]}
>
<AutoComplete
virtual
placement={'topLeft'}
autoClearSearchValue
options={AUTO_COMPLETE_TYPE}
style={{
width: parent.innerWidth / 2 - 80
}}
filterOption
onSelect={(value) => form && form.setFieldsValue({ url: value })}
>
<TextArea placeholder={l('rc.ds.urlPlaceholder')} />
{/*<ProFormTextArea*/}
{/* name='url'*/}
{/* width={parent.innerWidth / 2 - 80}*/}
{/* label={l('rc.ds.url')}*/}
{/* rules={[{ required: true, message: l('rc.ds.urlPlaceholder') }]}*/}
{/* placeholder={l('rc.ds.urlPlaceholder')}*/}
{/*/>*/}
</AutoComplete>
</Form.Item>
</ProForm.Group>
{!excludeFormItem && (
<ProFormGroup>
<ProForm.Item
name='flinkConfig'
label={l('rc.ds.flinkConfig')}
tooltip={l('rc.ds.flinkConfigTooltip')}
>
<CodeEdit
{...CodeEditProps}
onChange={(value) => flinkConfigChange(value ?? '')}
code={values.flinkConfig || ''}
/>
</ProForm.Item>
{!excludeFormItem && (
<ProFormGroup>
<ProForm.Item
name='flinkConfig'
label={l('rc.ds.flinkConfig')}
tooltip={l('rc.ds.flinkConfigTooltip')}
>
<CodeEdit
{...CodeEditProps}
onChange={(value) => flinkConfigChange(value ?? '')}
code={values.flinkConfig || ''}
/>
</ProForm.Item>
<ProForm.Item
name='flinkTemplate'
label={l('rc.ds.flinkTemplate')}
tooltip={l('rc.ds.flinkTemplateTooltip')}
>
<CodeEdit
{...CodeEditProps}
onChange={(value) => flinkTemplateChange(value ?? '')}
code={values.flinkTemplate || ''}
/>
</ProForm.Item>
</ProFormGroup>
)}
</>
);
};
<ProForm.Item
name='flinkTemplate'
label={l('rc.ds.flinkTemplate')}
tooltip={l('rc.ds.flinkTemplateTooltip')}
>
<CodeEdit
{...CodeEditProps}
onChange={(value) => flinkTemplateChange(value ?? '')}
code={values.flinkTemplate || ''}
/>
</ProForm.Item>
</ProFormGroup>
)}
</>
);
};
return renderDataSourceForm();
return renderDataSourceForm();
};
export default DataSourceProForm;
......@@ -59,7 +59,7 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
useEffect(() => {
if (!visible) {
form.resetFields();
}else {
} else {
form.setFieldsValue(values);
}
}, [visible, values]);
......
import {DataSources} from "@/types/RegCenter/data";
import {API_CONSTANTS} from "@/services/endpoints";
import {handleAddOrUpdate, handleOption} from "@/services/BusinessCrud";
import {l} from "@/utils/intl";
import { handleAddOrUpdate, handleOption } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';
import { DataSources } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
/**
* handle test
* @param item
*/
export const handleTest = async (item: Partial<DataSources.DataSource>) => {
await handleOption(API_CONSTANTS.DATASOURCE_TEST, l('button.test'), item);
await handleOption(API_CONSTANTS.DATASOURCE_TEST, l('button.test'), item);
};
/**
......@@ -16,5 +16,5 @@ export const handleTest = async (item: Partial<DataSources.DataSource>) => {
* @param item
*/
export const saveOrUpdateHandle = async (item: Partial<DataSources.DataSource>) => {
await handleAddOrUpdate(API_CONSTANTS.DATASOURCE, item);
};
\ No newline at end of file
await handleAddOrUpdate(API_CONSTANTS.DATASOURCE, item);
};
import { Resource } from '@/types/RegCenter/data';
import { renderIcon } from '@/utils/function';
import { l } from '@/utils/intl';
const buildTitleLabel = (item: Resource) => {
return (
<>
{item.fileName}
{!item.isDirectory && (
<span style={{ color: 'gray' }}>
{' '}
&nbsp;&nbsp;{l('global.size', '', { size: item.size })}
</span>
)}
</>
);
};
export const buildResourceTreeData = (data: Resource[]): any =>
data.map((item: Resource) => {
return {
isLeaf: !item.children,
name: item.fileName,
parentId: item.pid,
label: item.fullName + '/' + item.fileName,
icon: item.leaf && renderIcon(item.fileName, '.', item.leaf),
path: item.fullName,
title: buildTitleLabel(item),
fullInfo: item,
key: item.id,
id: item.id,
children: buildResourceTreeData(item.children)
};
});
......@@ -17,7 +17,8 @@
*
*/
import { buildTreeData } from '@/utils/function';
import { buildResourceTreeData } from '@/pages/RegCenter/Resource/components/FileTree/function';
import { Resource } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { UploadOutlined } from '@ant-design/icons';
import { Button, Tree, Typography, Upload } from 'antd';
......@@ -27,7 +28,7 @@ const { DirectoryTree } = Tree;
const { Text } = Typography;
type FileTreeProps = {
treeData: Partial<any>[];
treeData: Resource[];
onNodeClick: (info: any) => void;
onRightClick: (info: any) => void;
selectedKeys: string[];
......@@ -45,7 +46,7 @@ const FileTree: React.FC<FileTreeProps> = (props) => {
selectedKeys={selectedKeys}
onSelect={(_, info) => onNodeClick(info)}
onRightClick={(info) => onRightClick(info)}
treeData={buildTreeData(treeData)}
treeData={buildResourceTreeData(treeData)}
/>
) : (
<>
......
......@@ -26,6 +26,7 @@ import ResourceModal from '@/pages/RegCenter/Resource/components/ResourceModal';
import ResourcesUploadModal from '@/pages/RegCenter/Resource/components/ResourcesUploadModal';
import { handleOption, handleRemoveById, queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';
import { Resource } from '@/types/RegCenter/data';
import { InitResourceState } from '@/types/RegCenter/init.d';
import { ResourceState } from '@/types/RegCenter/state.d';
import { ProCard } from '@ant-design/pro-components';
......@@ -33,13 +34,6 @@ import { MenuInfo } from 'rc-menu/es/interface';
import { Resizable } from 're-resizable';
import React, { useCallback, useEffect, useState } from 'react';
export type Resource = {
id: number;
fileName: string;
description: string;
type?: string;
};
const ResourceOverView: React.FC = () => {
const [resourceState, setResourceState] = useState<ResourceState>(InitResourceState);
......@@ -66,7 +60,7 @@ const ResourceOverView: React.FC = () => {
});
const refreshTreeData = async (path: string) => {
const data = await queryDataByParams<any[]>(API_CONSTANTS.RESOURCE_SHOW_TREE);
const data = await queryDataByParams<Resource[]>(API_CONSTANTS.RESOURCE_SHOW_TREE);
setResourceState((prevState) => ({
...prevState,
treeData: updateTreeData(prevState.treeData, path, data ?? [])
......@@ -74,7 +68,7 @@ const ResourceOverView: React.FC = () => {
};
const refreshTree = async () => {
await queryDataByParams<any[]>(API_CONSTANTS.RESOURCE_SHOW_TREE).then((res) =>
await queryDataByParams<Resource[]>(API_CONSTANTS.RESOURCE_SHOW_TREE).then((res) =>
setResourceState((prevState) => ({ ...prevState, treeData: res ?? [] }))
);
};
......
import { LogInfo } from '@/types/SettingCenter/data';
import { parseByteStr, renderIcon } from '@/utils/function';
import { l } from '@/utils/intl';
const buildTitleLabel = (item: LogInfo) => {
return (
<>
{item.name}
{!item.leaf && (
<span style={{ color: 'gray' }}>
{' '}
&nbsp;&nbsp;{l('global.size', '', { size: parseByteStr(item.size) })}
</span>
)}
</>
);
};
export const buildLogInfoTreeData = (data: LogInfo[]): any =>
data.map((item: LogInfo) => {
return {
isLeaf: !item.leaf,
name: item.name,
parentId: item.parentId,
label: item.path,
icon: item.leaf && renderIcon(item.name, '.', item.leaf),
path: item.path,
title: buildTitleLabel(item),
fullInfo: item,
key: item.id,
id: item.id,
children: buildLogInfoTreeData(item.children)
};
});
......@@ -15,12 +15,13 @@
* limitations under the License.
*/
import { buildTreeData } from '@/utils/function';
import { buildLogInfoTreeData } from '@/pages/SettingCenter/SystemLogs/TagInfo/LogList/LogsTree/function';
import { LogInfo } from '@/types/SettingCenter/data';
import { Empty, Tree } from 'antd';
import React from 'react';
type LogsTreeProps = {
treeData: Partial<any>[];
treeData: LogInfo[];
onNodeClick: (info: any) => void;
};
......@@ -34,7 +35,7 @@ const LogsTree: React.FC<LogsTreeProps> = (props) => {
{treeData.length > 0 ? (
<DirectoryTree
onSelect={(_, info) => onNodeClick(info)}
treeData={buildTreeData(treeData)}
treeData={buildLogInfoTreeData(treeData)}
/>
) : (
<Empty className={'code-content-empty'} />
......
......@@ -19,17 +19,18 @@ import LogsShow from '@/pages/SettingCenter/SystemLogs/TagInfo/LogList/LogsShow'
import LogsTree from '@/pages/SettingCenter/SystemLogs/TagInfo/LogList/LogsTree';
import { queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';
import { LogInfo } from '@/types/SettingCenter/data';
import { ProCard } from '@ant-design/pro-components';
import { useEffect, useState } from 'react';
const LogList = () => {
const [treeData, setTreeData] = useState<Partial<any>[]>([]);
const [treeData, setTreeData] = useState<LogInfo[]>([]);
const [log, setLog] = useState<string>('');
const [clickFileName, setClickFileName] = useState<any>();
const queryLogList = async () => {
await queryDataByParams(API_CONSTANTS.SYSTEM_ROOT_LOG_LIST).then((res) => {
setTreeData(res);
await queryDataByParams<LogInfo[]>(API_CONSTANTS.SYSTEM_ROOT_LOG_LIST).then((res) => {
setTreeData(res ?? []);
});
};
......@@ -37,7 +38,7 @@ const LogList = () => {
await queryDataByParams(API_CONSTANTS.SYSTEM_ROOT_LOG_READ, {
path: fileName
}).then((res) => {
setLog(res);
setLog(res as string);
});
};
......@@ -61,11 +62,12 @@ const LogList = () => {
return (
<>
<ProCard ghost>
<ProCard ghost colSpan={'18%'} className={'siderTree'}>
<ProCard ghost bordered>
<ProCard ghost hoverable bordered colSpan={'18%'} className={'siderTree'}>
<LogsTree treeData={treeData} onNodeClick={(info: any) => handleNodeClick(info)} />
</ProCard>
<ProCard ghost>
<ProCard.Divider type={'vertical'} />
<ProCard ghost hoverable bordered>
<LogsShow code={log} refreshLogCallback={() => refreshLogByClickNode()} />
</ProCard>
</ProCard>
......
......@@ -232,7 +232,7 @@ export const handlePutData = async (url: string, fields: any) => {
}
};
export const handlePutDataJson = async (url: string, fields: any) => {
const tipsTitle = fields.id ? l('app.request.update') : l('app.request.add');
const tipsTitle = fields?.id ? l('app.request.update') : l('app.request.add');
await LoadingMessageAsync(l('app.request.running') + tipsTitle);
try {
const { code, msg } = await putDataJson(url, { ...fields });
......
......@@ -220,3 +220,19 @@ export type UDFTemplate = BaseBeanColumns & {
functionType: string;
templateCode: string;
};
interface Resource {
id: number;
fileName: string;
description: string;
userId: number;
type: number;
size: number;
pid: number;
fullName: string;
isDirectory: boolean;
createTime: string;
updateTime: string;
children: Resource[];
leaf: boolean;
}
......@@ -110,7 +110,7 @@ export interface GlobalVarState extends BaseState {
* resource state
*/
export interface ResourceState {
treeData: any[];
treeData: Resource[];
content: string;
clickedNode: any;
rightClickedNode: any;
......
......@@ -77,3 +77,15 @@ export type BaseConfigProperties = {
frontType: string;
example: string[];
};
export interface LogInfo {
id: number;
name: string;
path: string;
content: string;
parentId: number;
size: number;
desc: string;
children: LogInfo[];
leaf: boolean;
}
......@@ -436,60 +436,6 @@ export function differenceDays(startDateString: any, endDateString: any): number
return Math.floor(daysDifference);
}
/**
* build tree data
* @param data
* @returns {any}
*/
export const buildTreeData = (data: any): any =>
data?.map((item: any) => {
// build key
let buildKey = item.path + folderSeparator() + item.fileName;
const buildTitleLabel = () => {
return (
<>
{item.fileName}
<span style={{ color: 'gray' }}>
{' '}
&nbsp;&nbsp;{l('global.size', '', { size: item.size })}
</span>
</>
);
};
// if has children , recursive build
if (item.children) {
return {
isLeaf: item.leaf,
id: item?.id,
fileName: item.fileName,
parentId: item.path ?? item.pid,
icon: renderIcon(item.fileName, '.', item.leaf),
content: item.content,
path: item.fullName,
fullName: item?.fullName,
title: buildTitleLabel(),
desc: item?.desc ?? item?.description,
key: buildKey,
children: buildTreeData(item.children)
};
}
return {
isLeaf: !item.leaf,
id: item?.id,
name: item.name,
parentId: item.path ?? item.parentId,
icon: renderIcon(item.name, '.', item.leaf),
content: item.content,
path: item.path,
fullName: item?.fullName,
desc: item?.desc ?? item?.description,
title: buildTitleLabel(),
key: buildKey
};
});
/**
* Determine whether the file is supported
* @returns {boolean}
......
......@@ -1381,7 +1381,7 @@ INSERT INTO dinky_alert_template VALUES (1, 'Default', '
- **Alert Time :** ${time}
- **Start Time :** ${startTime}
- **End Time :** ${endTime}
- **<font color=''red''>${exceptions.rootException.substring(0,20)}</font>**
- **<font color=''red''>${(exceptions.rootException)?substring(0,20)}</font>**
[Go toTask Web](http://${taskUrl})
', 1, null, null);
......
......@@ -2437,7 +2437,7 @@ INSERT INTO public.dinky_alert_template VALUES (1, 'Default', '
- **Alert Time :** ${time}
- **Start Time :** ${startTime}
- **End Time :** ${endTime}
- **<font color=''red''>${exceptions.rootException.substring(0,20)}</font>**
- **<font color=''red''>${(exceptions.rootException)?substring(0,20)}</font>**
[Go toTask Web](http://${taskUrl})
', 1, null, null);
......
......@@ -225,7 +225,7 @@ INSERT INTO dinky_alert_template VALUES (1, 'Default', '
- **Alert Time :** ${time}
- **Start Time :** ${startTime}
- **End Time :** ${endTime}
- **<font color=''red''>${exceptions.rootException.substring(0,20)}</font>**
- **<font color=''red''>${(exceptions.rootException)?substring(0,20)}</font>**
[Go toTask Web](http://${taskUrl})
', 1, null, null);
......
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