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

[Refactor][web] refactor process table list (#1970)

* refactor process table list * added view modal title i18n * added sub step i18n * format code * fix i18n
parent 2b3d0b65
......@@ -46,17 +46,33 @@ public class ProcessController {
private final ProcessService processService;
/**
* List all process
*
* @param active true: list active process, false: list inactive process {@link Boolean}
* @return {@link ProTableResult}<{@link ProcessEntity}>
*/
@GetMapping("/listAllProcess")
public ProTableResult<ProcessEntity> listAllProcess(@RequestParam boolean active) {
List<ProcessEntity> processEntities = processService.listAllProcess(active);
return ProTableResult.<ProcessEntity>builder().success(true).data(processEntities).build();
}
/**
* get process by user id
*
* @return {@link ProTableResult} <{@link String} >
*/
@GetMapping("/getConsoleByUserId")
public Result<String> getConsoleByUserId() {
return Result.data(processService.getConsoleByUserId(StpUtil.getLoginIdAsInt()));
}
/**
* clear console by user id
*
* @return {@link Result} <{@link String}>
*/
@GetMapping("/clearConsole")
public Result<String> clearConsole() {
processService.clearConsoleByUserId(StpUtil.getLoginIdAsInt());
......
......@@ -23,16 +23,29 @@ import org.dinky.process.model.ProcessEntity;
import java.util.List;
/**
* ProcessService
*
* @since 2022/10/16 22:05
*/
/** ProcessService */
public interface ProcessService {
/**
* List all process
*
* @param active true: list active process, false: list inactive process {@link Boolean}
* @return {@link List}<{@link ProcessEntity}>
*/
List<ProcessEntity> listAllProcess(boolean active);
/**
* get log by user id
*
* @param userId user id {@link Integer}
* @return {@link String}
*/
String getConsoleByUserId(Integer userId);
/**
* clear log by user id
*
* @param userId user id {@link Integer}
*/
void clearConsoleByUserId(Integer userId);
}
......@@ -225,7 +225,7 @@ export default [
path: '/settings/process',
name: 'process',
icon: 'ReconciliationOutlined',
// component: './SettingCenter/ProcessList',
component: './SettingCenter/Process',
},
{
path: '/settings/services',
......
......@@ -786,13 +786,18 @@ export default {
'sys.process.id':'Process ID',
'sys.process.name': 'Process Name',
'sys.process.jobid':'Job ID',
'sys.process.taskId':'Job ID',
'sys.process.type': 'Type',
'sys.process.status': 'Status',
'sys.process.starttime': 'Start Time',
'sys.process.endtime': 'End Time',
'sys.process.startTime': 'Start Time',
'sys.process.endTime': 'End Time',
'sys.process.duration': 'Duration',
'sys.process.operator': 'Operator',
'sys.process.viewInfoLog':'View Info Level Log',
'sys.process.viewErrorLog':'View Error Level Log',
'sys.process.subStep.status':'Step Status',
'sys.process.subStep.info':'Step Info',
'sys.process.subStep.error':'Step Error',
'sys.info.logList.tips': 'Click left log file to viewing',
'devops.jobinfo.alert.title': 'Title',
......
......@@ -780,13 +780,18 @@ export default {
'sys.process.id':'进程ID',
'sys.process.name':'进程名',
'sys.process.jobid':'任务ID',
'sys.process.taskId':'任务ID',
'sys.process.type':'类型',
'sys.process.status':'状态',
'sys.process.starttime':'开始时间',
'sys.process.endtime':'结束时间',
'sys.process.startTime':'开始时间',
'sys.process.endTime':'结束时间',
'sys.process.duration':'耗时',
'sys.process.operator':'操作人',
'sys.process.viewInfoLog':'查看 Info 级别日志',
'sys.process.viewErrorLog':'查看 Error 级别日志',
'sys.process.subStep.status':'步骤状态',
'sys.process.subStep.info':'步骤 Info 日志',
'sys.process.subStep.error':'步骤 Error 日志',
'sys.info.logList.tips': '点击左侧日志文件查看',
'devops.jobinfo.alert.title':'标题',
......
/*
* 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 React from "react";
import {Modal} from "antd";
import CodeShow from "@/components/CustomEditor/CodeShow";
import {NORMAL_MODAL_OPTIONS} from "@/services/constants";
type ShowLogProps = {
type: string;
log: string;
visibleViewLog: boolean;
cancelViewLog: () => void;
}
/**
* code edit props
*/
const CodeEditProps = {
height: "70vh",
width: "60vw",
lineNumbers: "on",
language: "java",
};
const ShowLog: React.FC<ShowLogProps> = (props) => {
const {type, log, visibleViewLog, cancelViewLog} = props;
return <>
<Modal
{...NORMAL_MODAL_OPTIONS}
title={type}
open={visibleViewLog}
onCancel={cancelViewLog}
okButtonProps={{style: {display: "none"}}}
>
<CodeShow {...CodeEditProps} code={log} showFloatButton/>
</Modal>
</>;
};
export default ShowLog;
/*
* 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 React from "react";
import {ProcessSteps} from "@/types/SettingCenter/data";
import {ProColumns} from "@ant-design/pro-table";
import {ProTable} from "@ant-design/pro-components";
import ShowLog from "@/pages/SettingCenter/Process/components/ProcessList/SubStepsTable/ShowLog";
import {ShowLogBtn} from "@/components/CallBackButton/ShowLogBtn";
import {MatchProcessStatus} from "@/pages/SettingCenter/Process/components/ProcessList/function";
import {l} from "@/utils/intl";
type SubStepsTableProps = {
steps: ProcessSteps[];
}
type ShowLogProps = {
type: string;
log: string;
}
const SubStepsTable: React.FC<SubStepsTableProps> = (props) => {
const {steps} = props;
const [visibleViewLog, setVisibleViewLog] = React.useState<boolean>(false);
const [viewLogProp, setViewLogProp] = React.useState<ShowLogProps>({
type: "",
log: "",
});
const handleViewLog = (type: string, log: string) => {
setViewLogProp({type, log});
setVisibleViewLog(true);
};
const cancelViewLog = () => {
setViewLogProp({type: "", log: ""});
setVisibleViewLog(false);
};
const renderLog = () => {
return <ShowLog cancelViewLog={cancelViewLog} visibleViewLog={visibleViewLog} {...viewLogProp}/>;
};
const stepsColumns: ProColumns<ProcessSteps>[] = [
{
dataIndex: "index",
valueType: "indexBorder",
width: 48,
},
{
title: l('sys.process.subStep.status'),
dataIndex: "stepStatus",
render: (_, record) => {
return MatchProcessStatus(record.stepStatus);
}
},
{
title: l('sys.process.subStep.info'),
dataIndex: "info",
align: "center",
render: (_, record) => {
return <ShowLogBtn onClick={() => handleViewLog(l("sys.process.viewInfoLog"), record.info)}/>;
}
},
{
title: l('sys.process.subStep.error'),
dataIndex: "error",
align: "center",
render: (_, record) => {
return <ShowLogBtn onClick={() => handleViewLog(l("sys.process.viewErrorLog"), record.error)}/>;
}
},
{
title: l('sys.process.startTime'),
dataIndex: "startTime",
valueType: "dateTime",
},
{
title: l('sys.process.endTime'),
dataIndex: "endTime",
valueType: "dateTime",
},
{
title: l('sys.process.duration'),
dataIndex: "time",
}
];
return <>
<ProTable<ProcessSteps>
headerTitle={false}
toolBarRender={false}
search={false}
columns={stepsColumns}
dataSource={steps}
pagination={false}
/>
{visibleViewLog && renderLog()}
</>;
};
export default SubStepsTable;
/*
* 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.
*/
export enum ProcessType {
FLINK_EXPLAIN = "FLINK_EXPLAIN",
FLINK_EXECUTE = "FLINK_EXECUTE",
FLINK_SUBMIT = "FLINK_SUBMIT",
SQL_EXPLAIN = "SQL_EXPLAIN",
SQL_EXECUTE = "SQL_EXECUTE",
SQL_SUBMIT = "SQL_SUBMIT",
LINEAGE = "LINEAGE",
UNKNOWN = "UNKNOWN",
}
export enum ProcessStatus {
INIT = "INITIALIZING",
RUNNING = "RUNNING",
FAILED = "FAILED",
CANCELED = "CANCELED",
FINISHED = "FINISHED",
UNKNOWN = "UNKNOWN",
}
/*
* 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 {Tag} from "antd";
import {ProcessStatus, ProcessType} from "@/pages/SettingCenter/Process/components/ProcessList/constants";
export const MatchProcessType = (type: string) => {
switch (type) {
case ProcessType.FLINK_EXPLAIN:
return <Tag color={"blue"}>Flink Explain</Tag>;
case ProcessType.FLINK_EXECUTE:
return <Tag color={"pink"}>Flink Execute</Tag>;
case ProcessType.FLINK_SUBMIT:
return <Tag color={"purple"}>Flink Submit</Tag>;
case ProcessType.SQL_EXPLAIN:
return <Tag color={"cyan"}>SQL Explain</Tag>;
case ProcessType.SQL_EXECUTE:
return <Tag color={"orange"}>SQL Execute</Tag>;
case ProcessType.SQL_SUBMIT:
return <Tag color={"green"}>SQL Submit</Tag>;
case ProcessType.LINEAGE:
return <Tag color={"magenta"}>Lineage</Tag>;
case ProcessType.UNKNOWN:
return <Tag color={"default"}>UNKNOWN</Tag>;
}
};
export const MatchProcessStatus = (status: string) => {
switch (status) {
case ProcessStatus.INIT:
return <Tag color={"default"}>INITIALIZING</Tag>;
case ProcessStatus.RUNNING:
return <Tag color={"processing"}>RUNNING</Tag>;
case ProcessStatus.FAILED:
return <Tag color={"error"}>FAILED</Tag>;
case ProcessStatus.CANCELED:
return <Tag color={"warning"}>CANCELED</Tag>;
case ProcessStatus.FINISHED:
return <Tag color={"success"}>FINISHED</Tag>;
case ProcessStatus.UNKNOWN:
return <Tag color={"default"}>UNKNOWN</Tag>;
}
};
/*
* 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 React from "react";
import {API_CONSTANTS, PROTABLE_OPTIONS_PUBLIC} from "@/services/constants";
import {getData} from "@/services/api";
import {ProTable} from "@ant-design/pro-components";
import {Process} from "@/types/SettingCenter/data";
import {ProColumns} from "@ant-design/pro-table";
import SubStepsTable from "@/pages/SettingCenter/Process/components/ProcessList/SubStepsTable";
import {l} from "@/utils/intl";
import {MatchProcessStatus, MatchProcessType} from "@/pages/SettingCenter/Process/components/ProcessList/function";
const ProcessList: React.FC = () => {
const processColumns: ProColumns<Process>[] = [
{
title: l("sys.process.id"),
dataIndex: "pid",
},
{
title: l("sys.process.name"),
dataIndex: "name",
},
{
title: l("sys.process.taskId"),
dataIndex: "taskId",
},
{
title: l("sys.process.type"),
dataIndex: "type",
render: (_, record) => {
return MatchProcessType(record.type);
}
},
{
title: l("sys.process.status"),
dataIndex: "status",
render: (_, record) => {
return MatchProcessStatus(record.status);
}
},
{
title: l("sys.process.startTime"),
dataIndex: "startTime",
valueType: "dateTime",
},
{
title: l("sys.process.endTime"),
dataIndex: "endTime",
valueType: "dateTime",
},
{
title: l("sys.process.duration"),
dataIndex: "time",
},
{
title: l("sys.process.operator"),
dataIndex: "userId",
}
];
return <>
<ProTable<Process>
headerTitle={false}
{...PROTABLE_OPTIONS_PUBLIC}
rowKey="pid"
size={"small"}
search={false}
columns={processColumns}
request={() => getData(API_CONSTANTS.PROCESS_LIST, {active: false})}
expandable={{
expandRowByClick: true,
expandedRowRender: record => <SubStepsTable steps={record.steps}/>
}}
/>
</>;
};
export default ProcessList;
/*
* 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 {PageContainer} from "@ant-design/pro-components";
import ProcessList from "./components/ProcessList";
export default ()=> {
return <PageContainer title={false}>
<ProcessList />
</PageContainer>
}
......@@ -135,6 +135,9 @@ export const API_CONSTANTS = {
// -- READ LOG file
SYSTEM_ROOT_LOG_READ: "/api/system/readFile",
// process list
PROCESS_LIST: "/api/process/listAllProcess",
};
......
/*
* 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.
*/
export type ProcessSteps = {
stepStatus: string;
info: string;
error: string;
startTime: Date;
endTime: Date;
time: string;
}
export type Process = {
pid: string;
name: string;
taskId: number;
taskName: string;
type: string;
status: string;
startTime: Date;
endTime: Date;
time: string;
nullProcess: boolean;
stepIndex: number;
steps: ProcessSteps[];
userId: number;
}
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