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');
}
This diff is collapsed.
......@@ -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))}
/>
</>
) : (
......
......@@ -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