Unverified Commit c56784be authored by gaoyan's avatar gaoyan Committed by GitHub

Add job overview (#2573)

* Optimize the process * add job overview
parent d326ecbc
......@@ -26,9 +26,10 @@ import org.dinky.data.enums.BusinessType;
import org.dinky.data.model.ID;
import org.dinky.data.model.devops.TaskManagerConfiguration;
import org.dinky.data.model.ext.JobInfoDetail;
import org.dinky.data.model.job.JobInstance;
import org.dinky.data.model.home.JobInstanceStatus;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.result.Result;
import org.dinky.data.vo.task.JobInstanceVo;
import org.dinky.explainer.lineage.LineageResult;
import org.dinky.service.JobInstanceService;
import org.dinky.utils.BuildConfiguration;
......@@ -78,7 +79,7 @@ public class JobInstanceController {
paramType = "body",
required = true,
dataTypeClass = JsonNode.class)
public ProTableResult<JobInstance> listJobInstances(@RequestBody JsonNode para) {
public ProTableResult<JobInstanceVo> listJobInstances(@RequestBody JsonNode para) {
return jobInstanceService.listJobInstances(para);
}
......@@ -87,11 +88,8 @@ public class JobInstanceController {
*/
@GetMapping("/getStatusCount")
@ApiOperation("Get status count")
public Result<Dict> getStatusCount() {
Dict result = Dict.create()
.set("history", jobInstanceService.getStatusCount(true))
.set("instance", jobInstanceService.getStatusCount(false));
return Result.succeed(result);
public Result<JobInstanceStatus> getStatusCount() {
return Result.succeed(jobInstanceService.getStatusCount());
}
/**
......
......@@ -25,10 +25,10 @@ import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.MetricsType;
import org.dinky.data.metrics.Jvm;
import org.dinky.data.model.Metrics;
import org.dinky.data.model.job.JobInstance;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.result.Result;
import org.dinky.data.vo.MetricsVO;
import org.dinky.data.vo.task.JobInstanceVo;
import org.dinky.service.JobInstanceService;
import org.dinky.service.MonitorService;
......@@ -93,9 +93,9 @@ public class MonitorController {
ObjectNode para = nodeFactory.objectNode();
para.put("isHistory", false);
para.put("taskId", taskIds);
ProTableResult<JobInstance> jobInstanceProTableResult = jobInstanceService.listJobInstances(para);
ProTableResult<JobInstanceVo> jobInstanceProTableResult = jobInstanceService.listJobInstances(para);
List<String> jids = jobInstanceProTableResult.getData().stream()
.map(JobInstance::getJid)
.map(JobInstanceVo::getJid)
.collect(Collectors.toList());
return Result.succeed(monitorService.getData(
DateUtil.date(startTime),
......
......@@ -21,6 +21,7 @@ package org.dinky.data.model.home;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* JobInstanceStatus
......@@ -28,6 +29,7 @@ import io.swagger.annotations.ApiModelProperty;
* @since 2022/2/28 22:25
*/
@ApiModel(value = "JobInstanceStatus", description = "Job Instance Status Information")
@Data
public class JobInstanceStatus {
@ApiModelProperty(value = "All", dataType = "Integer", example = "10", notes = "Total count of job instances")
......@@ -117,109 +119,6 @@ public class JobInstanceStatus {
notes = "Count of job instances in the Unknown state")
private Integer unknown = 0;
public JobInstanceStatus() {}
public Integer getAll() {
return all;
}
public void setAll(Integer all) {
this.all = all;
}
public Integer getInitializing() {
return initializing;
}
public void setInitializing(Integer initializing) {
this.initializing = initializing;
}
public Integer getRunning() {
return running;
}
public void setRunning(Integer running) {
this.running = running;
}
public Integer getFinished() {
return finished;
}
public void setFinished(Integer finished) {
this.finished = finished;
}
public Integer getFailed() {
return failed;
}
public void setFailed(Integer failed) {
this.failed = failed;
}
public Integer getCanceled() {
return canceled;
}
public void setCanceled(Integer canceled) {
this.canceled = canceled;
}
public Integer getRestarting() {
return restarting;
}
public void setRestarting(Integer restarting) {
this.restarting = restarting;
}
public Integer getCreated() {
return created;
}
public void setCreated(Integer created) {
this.created = created;
}
public Integer getFailing() {
return failing;
}
public void setFailing(Integer failing) {
this.failing = failing;
}
public Integer getCancelling() {
return cancelling;
}
public void setCancelling(Integer cancelling) {
this.cancelling = cancelling;
}
public Integer getSuspended() {
return suspended;
}
public void setSuspended(Integer suspended) {
this.suspended = suspended;
}
public Integer getReconciling() {
return reconciling;
}
public void setReconciling(Integer reconciling) {
this.reconciling = reconciling;
}
public Integer getUnknown() {
return unknown;
}
public void setUnknown(Integer unknown) {
this.unknown = unknown;
}
@ApiModelProperty(value = "modelOverview", dataType = "JobModelOverview", notes = "batch and steamng count")
private JobModelOverview modelOverview;
}
/*
*
* 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.
*
*/
package org.dinky.data.vo.task;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class JobInstanceVo {
@TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(
value = "ID",
dataType = "Integer",
example = "1",
notes = "Unique identifier for the job instance")
private Integer id;
@ApiModelProperty(value = "Name", dataType = "String", notes = "Name of the job instance")
private String name;
@ApiModelProperty(
value = "Task ID",
dataType = "Integer",
example = "1",
notes = "Task ID associated with the job instance")
private Integer taskId;
@ApiModelProperty(value = "Step", dataType = "Integer", example = "1", notes = "Step number of the job instance")
private Integer step;
@ApiModelProperty(value = "JID", dataType = "String", notes = "JID of the job instance")
private String jid;
@ApiModelProperty(value = "Status", dataType = "String", notes = "Status of the job instance")
private String status;
@ApiModelProperty(value = "type", dataType = "String", notes = "run mode type", example = "kubernets-application")
private String type;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(
value = "Create Time",
dataType = "String",
notes = "Timestamp indicating the creation time of the job instance")
private LocalDateTime createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(
value = "Update Time",
dataType = "String",
notes = "Timestamp indicating the last update time of the job instance")
private LocalDateTime updateTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(
value = "Finish Time",
dataType = "String",
notes = "Timestamp indicating the finish time of the job instance")
private LocalDateTime finishTime;
@ApiModelProperty(
value = "Duration",
dataType = "Long",
example = "3600",
notes = "Duration of the job instance in seconds")
private Long duration;
@ApiModelProperty(
value = "Failed Restart Count",
dataType = "Integer",
example = "2",
notes = "Count of failed restarts")
private Integer failedRestartCount;
}
......@@ -20,6 +20,7 @@
package org.dinky.mapper;
import org.dinky.data.model.home.JobInstanceCount;
import org.dinky.data.model.home.JobModelOverview;
import org.dinky.data.model.job.JobInstance;
import org.dinky.mybatis.mapper.SuperMapper;
......@@ -43,7 +44,7 @@ public interface JobInstanceMapper extends SuperMapper<JobInstance> {
List<JobInstanceCount> countStatus();
List<JobInstanceCount> countHistoryStatus();
JobModelOverview getJobStreamingOrBatchModelOverview();
@InterceptorIgnore(tenantLine = "true")
List<JobInstance> listJobInstanceActive();
......
......@@ -36,6 +36,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
*/
public interface SuperMapper<T> extends BaseMapper<T> {
List<T> selectForProTable(
Page<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper, @Param("param") Map<String, Object> param);
<K> List<K> selectForProTable(
Page<K> page, @Param(Constants.WRAPPER) Wrapper<K> queryWrapper, @Param("param") Map<String, Object> param);
}
......@@ -23,6 +23,7 @@ import org.dinky.data.model.ext.JobInfoDetail;
import org.dinky.data.model.home.JobInstanceStatus;
import org.dinky.data.model.job.JobInstance;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.vo.task.JobInstanceVo;
import org.dinky.explainer.lineage.LineageResult;
import org.dinky.mybatis.service.ISuperService;
......@@ -49,10 +50,9 @@ public interface JobInstanceService extends ISuperService<JobInstance> {
/**
* Get the count of job instance statuses.
*
* @param isHistory A boolean indicating whether to get the history status count or not.
* @return An integer representing the count of job instance statuses.
*/
JobInstanceStatus getStatusCount(boolean isHistory);
JobInstanceStatus getStatusCount();
/**
* Get a list of active job instances.
......@@ -123,7 +123,7 @@ public interface JobInstanceService extends ISuperService<JobInstance> {
* @param para A {@link JsonNode} object representing the filter conditions for listing job instances.
* @return A {@link ProTableResult<JobInstance>} object representing the list of job instances.
*/
ProTableResult<JobInstance> listJobInstances(JsonNode para);
ProTableResult<JobInstanceVo> listJobInstances(JsonNode para);
/**
* Initialize the tenant by the given job instance ID.
......
......@@ -33,9 +33,11 @@ import org.dinky.data.model.ClusterInstance;
import org.dinky.data.model.ext.JobInfoDetail;
import org.dinky.data.model.home.JobInstanceCount;
import org.dinky.data.model.home.JobInstanceStatus;
import org.dinky.data.model.home.JobModelOverview;
import org.dinky.data.model.job.History;
import org.dinky.data.model.job.JobInstance;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.vo.task.JobInstanceVo;
import org.dinky.explainer.lineage.LineageBuilder;
import org.dinky.explainer.lineage.LineageResult;
import org.dinky.job.FlinkJobTask;
......@@ -89,14 +91,12 @@ public class JobInstanceServiceImpl extends SuperServiceImpl<JobInstanceMapper,
}
@Override
public JobInstanceStatus getStatusCount(boolean isHistory) {
public JobInstanceStatus getStatusCount() {
List<JobInstanceCount> jobInstanceCounts;
if (isHistory) {
jobInstanceCounts = baseMapper.countHistoryStatus();
} else {
jobInstanceCounts = baseMapper.countStatus();
}
jobInstanceCounts = baseMapper.countStatus();
JobModelOverview modelOverview = baseMapper.getJobStreamingOrBatchModelOverview();
JobInstanceStatus jobInstanceStatus = new JobInstanceStatus();
jobInstanceStatus.setModelOverview(modelOverview);
int total = 0;
for (JobInstanceCount item : jobInstanceCounts) {
Integer counts = Asserts.isNull(item.getCounts()) ? 0 : item.getCounts();
......@@ -252,16 +252,16 @@ public class JobInstanceServiceImpl extends SuperServiceImpl<JobInstanceMapper,
}
@Override
public ProTableResult<JobInstance> listJobInstances(JsonNode para) {
public ProTableResult<JobInstanceVo> listJobInstances(JsonNode para) {
int current = para.has("current") ? para.get("current").asInt() : 1;
int pageSize = para.has("pageSize") ? para.get("pageSize").asInt() : 10;
QueryWrapper<JobInstance> queryWrapper = new QueryWrapper<>();
QueryWrapper<JobInstanceVo> queryWrapper = new QueryWrapper<>();
ProTableUtil.autoQueryDefalut(para, queryWrapper);
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> param = mapper.convertValue(para, Map.class);
Page<JobInstance> page = new Page<>(current, pageSize);
List<JobInstance> list = baseMapper.selectForProTable(page, queryWrapper, param);
return ProTableResult.<JobInstance>builder()
Page<JobInstanceVo> page = new Page<>(current, pageSize);
List<JobInstanceVo> list = baseMapper.selectForProTable(page, queryWrapper, param);
return ProTableResult.<JobInstanceVo>builder()
.success(true)
.data(list)
.total(page.getTotal())
......
......@@ -9,7 +9,7 @@
limit 1
</select>
<select id="selectForProTable" resultType="org.dinky.data.model.job.JobInstance">
<select id="selectForProTable" resultType="org.dinky.data.vo.task.JobInstanceVo">
select
a.*,
dh.type as type,
......@@ -72,11 +72,14 @@
group by status
</select>
<select id="countHistoryStatus" resultType="org.dinky.data.model.home.JobInstanceCount">
select status,
count(1) as counts
from dinky_job_instance
group by status
<select id="getJobStreamingOrBatchModelOverview" resultType="org.dinky.data.model.home.JobModelOverview">
select sum(IF(b.batch, 1, 0)) as batchJobCount,
sum(IF(b.batch, 0, 1)) as streamingJobCount
from (select json_extract(dh.config_json, '$.batchModel') as batch
from (select max(ji.id) as id from dinky_job_instance ji group by ji.task_id) as a
left join dinky_job_instance dji on dji.id = a.id
left join dinky.dinky_history dh on dji.history_id = dh.id) b
group by b.batch
</select>
<select id="listJobInstanceActive" resultType="org.dinky.data.model.job.JobInstance">
......
This diff is collapsed.
......@@ -98,6 +98,13 @@ export default {
* devops
*
* */
'devops.joblist.status.all': 'All',
'devops.joblist.status.running': 'running',
'devops.joblist.status.cancelled': 'Canceled',
'devops.joblist.status.failed': 'Exception job',
'devops.joblist.status.restarting': 'Restarting',
'devops.joblist.status.finished': 'completed',
'devops.joblist.status.unknown': 'unknown job',
'devops.baseinfo.name': 'Job Name',
'devops.baseinfo.parallelism': 'Parallelism',
......
......@@ -93,6 +93,14 @@ export default {
*
* */
'devops.joblist.status.all': '任务总计',
'devops.joblist.status.running': '运行中',
'devops.joblist.status.cancelled': '已取消',
'devops.joblist.status.failed': '异常作业',
'devops.joblist.status.restarting': '重启中',
'devops.joblist.status.finished': '已完成',
'devops.joblist.status.unknown': '未知作业',
'devops.baseinfo.name': '任务名称',
'devops.baseinfo.parallelism': '并行度',
'devops.baseinfo.readbytes': '接收字节',
......
......@@ -25,8 +25,11 @@ import { parseSecondStr } from '@/utils/function';
import { l } from '@/utils/intl';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components';
import { Typography } from 'antd';
import { useRef } from 'react';
const { Link } = Typography;
type HistoryProps = {
taskId: number;
};
......@@ -65,12 +68,9 @@ const JobHistoryList = (props: HistoryProps) => {
title: l('global.table.operate'),
valueType: 'option',
render: (text: any, record: Jobs.JobInstance) => [
<a
key={'history-detail'}
onClick={() => history.push(`/devops/job-detail?id=${record.id}`)}
>
<Link href={`#/devops/job-detail?id=${record.id}`} key={'history-detail'}>
{l('devops.joblist.detail')}
</a>
</Link>
]
}
];
......
/*
*
* 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 { ProCard } from '@ant-design/pro-components';
import { Divider, Space, Typography } from 'antd';
const { Text, Link } = Typography;
type StatisticsCardParams = {
title: string;
value?: string | number;
icon: any;
link?: string;
extra?: any;
divider?: boolean;
atClick?: () => void;
};
const StatisticsCard = (props: StatisticsCardParams) => {
const { title, value, icon, extra = <></>, divider = true, link, atClick } = props;
return (
<>
<ProCard layout={'center'} onClick={() => (atClick ? atClick() : {})} hoverable={true}>
<Space size={20}>
{icon}
<Space direction='vertical'>
<Text>{title}</Text>
<Text style={{ fontSize: 30 }}>{value}</Text>
</Space>
{extra}
</Space>
</ProCard>
{divider ? <Divider type={'vertical'} /> : <></>}
</>
);
};
export default StatisticsCard;
/*
*
* 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 {
AllJobIcons,
BatchIcons,
CancelIcons,
ErrorIcons,
FinishIcons,
RestartIcons,
RunningIcons,
SteamIcons,
UnknownIcons
} from '@/components/Icons/DevopsIcons';
import { DevopContext } from '@/pages/DevOps';
import { JOB_STATUS } from '@/pages/DevOps/constants';
import StatisticsCard from '@/pages/DevOps/JobList/components/Overview/StatisticsCard';
import { getData } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints';
import { StatusCountOverView } from '@/types/Home/data';
import { l } from '@/utils/intl';
import { ProCard } from '@ant-design/pro-components';
import { Button, Col, Row, Space } from 'antd';
import { useContext, useEffect, useState } from 'react';
const JobOverview = (props: any) => {
const [statusCount, setStatusCount] = useState<StatusCountOverView>();
const { statusFilter, setStatusFilter } = useContext<any>(DevopContext);
useEffect(() => {
getData(API_CONSTANTS.GET_STATUS_COUNT)
.then((res) => {
setStatusCount(res.data);
})
.catch(() => {});
}, []);
return (
<Row gutter={[16, 8]}>
<Col span={5}>
<ProCard colSpan={'20%'} boxShadow={true}>
<StatisticsCard
title={l('devops.joblist.status.all')}
value={statusCount?.all}
icon={<AllJobIcons size={60} />}
divider={false}
atClick={() => {
setStatusFilter(undefined);
}}
extra={
<Space direction='vertical'>
<Button type={'text'} icon={<BatchIcons size={20} />}>
{l('home.job.batch')}: {statusCount?.modelOverview?.batchJobCount}
</Button>
<Button type={'text'} icon={<SteamIcons size={20} />}>
{l('home.job.stream')}: {statusCount?.modelOverview?.streamingJobCount}
</Button>
</Space>
}
/>
</ProCard>
</Col>
<Col span={19}>
<ProCard layout='center' boxShadow={true}>
<StatisticsCard
title={l('devops.joblist.status.running')}
value={statusCount?.running}
icon={<RunningIcons size={60} />}
atClick={() => {
setStatusFilter(JOB_STATUS.RUNNING);
}}
/>
<StatisticsCard
title={l('devops.joblist.status.cancelled')}
value={statusCount?.canceled}
icon={<CancelIcons size={60} />}
atClick={() => {
setStatusFilter(JOB_STATUS.CANCELED);
}}
/>
<StatisticsCard
title={l('devops.joblist.status.failed')}
value={statusCount?.failed}
icon={<ErrorIcons size={60} />}
atClick={() => {
setStatusFilter(JOB_STATUS.FAILED);
}}
/>
<StatisticsCard
title={l('devops.joblist.status.restarting')}
value={statusCount?.restarting}
icon={<RestartIcons size={60} />}
atClick={() => {
setStatusFilter(JOB_STATUS.RESTARTING);
}}
/>
<StatisticsCard
title={l('devops.joblist.status.finished')}
value={statusCount?.finished}
icon={<FinishIcons size={60} />}
atClick={() => {
setStatusFilter(JOB_STATUS.FINISHED);
}}
/>
<StatisticsCard
title={l('devops.joblist.status.unknown')}
value={statusCount?.unknown}
icon={<UnknownIcons size={60} />}
divider={false}
atClick={() => {
setStatusFilter(JOB_STATUS.UNKNOWN);
}}
/>
</ProCard>
</Col>
</Row>
);
};
export default JobOverview;
......@@ -19,23 +19,27 @@
import JobLifeCycleTag from '@/components/JobTags/JobLifeCycleTag';
import StatusTag from '@/components/JobTags/StatusTag';
import { JOB_STATUS_FILTER, LIFECYCLE_FILTER } from '@/pages/DevOps/function';
import JobHistoryList from '@/pages/DevOps/JobList/components/JobHistoryList';
import { DevopContext } from '@/pages/DevOps';
import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants';
import JobHistoryList from '@/pages/DevOps/JobList/components/JobHistoryList/JobHistoryList';
import { queryList } from '@/services/api';
import { PROTABLE_OPTIONS_PUBLIC } from '@/services/constants';
import { API_CONSTANTS } from '@/services/endpoints';
import { Jobs } from '@/types/DevOps/data';
import { parseMilliSecondStr } from '@/utils/function';
import { l } from '@/utils/intl';
import { ClockCircleTwoTone, EyeTwoTone } from '@ant-design/icons';
import { ClockCircleTwoTone, EyeTwoTone, RedoOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components';
import { Button, Table } from 'antd';
import { useEffect, useRef } from 'react';
import { ProCard, ProTable } from '@ant-design/pro-components';
import { Button, Radio, Table } from 'antd';
import { useContext, useEffect, useRef, useState } from 'react';
import { history } from 'umi';
const JobList = () => {
const tableRef = useRef<ActionType>();
const { statusFilter, setStatusFilter } = useContext<any>(DevopContext);
const [stepFilter, setStepFilter] = useState<number | undefined>();
const [taskFilter, setTaskFilter] = useState<string | undefined>();
const jobListColumns: ProColumns<Jobs.JobInstance>[] = [
{
......@@ -51,9 +55,6 @@ const JobList = () => {
},
{
title: l('global.table.lifecycle'),
filters: LIFECYCLE_FILTER(),
hideInSearch: true,
filterMultiple: false,
dataIndex: 'step',
render: (_: any, row: { step: number }) => <JobLifeCycleTag status={row.step} />
},
......@@ -80,9 +81,6 @@ const JobList = () => {
},
{
title: l('global.table.status'),
filters: JOB_STATUS_FILTER(),
filterMultiple: false,
hideInSearch: true,
dataIndex: 'status',
render: (_: any, row: Jobs.JobInstance) => <StatusTag status={row.status} />
},
......@@ -109,33 +107,56 @@ const JobList = () => {
}, []);
return (
<ProTable<Jobs.JobInstance>
{...PROTABLE_OPTIONS_PUBLIC}
rowKey={(record) => record.jid}
columns={jobListColumns}
params={{ isHistory: false }}
actionRef={tableRef}
headerTitle={l('devops.joblist.joblist')}
request={async (params, sorter, filter: any) =>
queryList(API_CONSTANTS.GET_JOB_LIST, {
...params,
sorter,
filter
})
}
expandable={{
expandedRowRender: (record) => <JobHistoryList taskId={record.taskId} key={record.jid} />,
expandIcon: ({ expanded, onExpand, record }) => (
<Button
className={'options-button'}
key={`${record.id}_history`}
onClick={(e) => onExpand(record, e)}
title={l('devops.joblist.history')}
icon={<ClockCircleTwoTone twoToneColor={expanded ? '#52c41a' : '#4096ff'} />}
/>
)
}}
/>
<ProCard boxShadow={true} style={{ height: '73vh' }}>
<ProTable<Jobs.JobInstance>
{...PROTABLE_OPTIONS_PUBLIC}
search={false}
loading={{ delay: 1000 }}
rowKey={(record) => record.jid}
columns={jobListColumns}
params={{ isHistory: false, status: statusFilter, step: stepFilter, name: taskFilter }}
actionRef={tableRef}
toolbar={{
settings: false,
search: { onSearch: (value: string) => setTaskFilter(value) },
filter: (
<>
<Radio.Group defaultValue={undefined} onChange={(e) => setStepFilter(e.target.value)}>
<Radio.Button value={undefined} defaultChecked={true}>
{l('global.table.lifecycle.all')}
</Radio.Button>
<Radio.Button value={JOB_LIFE_CYCLE.PUBLISH}>
{l('global.table.lifecycle.publish')}
</Radio.Button>
<Radio.Button value={JOB_LIFE_CYCLE.DEVELOP}>
{l('global.table.lifecycle.dev')}
</Radio.Button>
</Radio.Group>
</>
),
actions: [<Button icon={<RedoOutlined />} onClick={() => tableRef.current?.reload()} />]
}}
request={async (params, sorter, filter: any) =>
queryList(API_CONSTANTS.GET_JOB_LIST, {
...params,
sorter,
filter
})
}
expandable={{
expandedRowRender: (record) => <JobHistoryList taskId={record.taskId} key={record.jid} />,
expandIcon: ({ expanded, onExpand, record }) => (
<Button
className={'options-button'}
key={`${record.id}_history`}
onClick={(e) => onExpand(record, e)}
title={l('devops.joblist.history')}
icon={<ClockCircleTwoTone twoToneColor={expanded ? '#52c41a' : '#4096ff'} />}
/>
)
}}
/>
</ProCard>
);
};
export default JobList;
......@@ -17,42 +17,7 @@
*
*/
import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants';
import { l } from '@/utils/intl';
/**
* Generates an array of options for the life cycle filter.
*
* @returns {Array} - An array of objects representing the life cycle filter options.
*/
export const LIFECYCLE_FILTER = () => {
return [
{ text: l('global.table.lifecycle.dev'), value: JOB_LIFE_CYCLE.DEVELOP },
{ text: l('global.table.lifecycle.online'), value: JOB_LIFE_CYCLE.ONLINE },
{ text: l('global.table.lifecycle.unknown'), value: JOB_LIFE_CYCLE.UNKNOWN }
];
};
/**
* Generates an array of options for the job status filter.
*
* @returns {Array} - An array of objects representing the job status filter options.
*/
export const JOB_STATUS_FILTER = () => {
return [
{ text: JOB_STATUS.FINISHED, value: JOB_STATUS.FINISHED },
{ text: JOB_STATUS.RUNNING, value: JOB_STATUS.RUNNING },
{ text: JOB_STATUS.FAILED, value: JOB_STATUS.FAILED },
{ text: JOB_STATUS.CANCELED, value: JOB_STATUS.CANCELED },
{ text: JOB_STATUS.INITIALIZING, value: JOB_STATUS.INITIALIZING },
{ text: JOB_STATUS.RESTARTING, value: JOB_STATUS.RESTARTING },
{ text: JOB_STATUS.CREATED, value: JOB_STATUS.CREATED },
{ text: JOB_STATUS.FAILING, value: JOB_STATUS.FAILING },
{ text: JOB_STATUS.SUSPENDED, value: JOB_STATUS.SUSPENDED },
{ text: JOB_STATUS.CANCELLING, value: JOB_STATUS.CANCELLING },
{ text: JOB_STATUS.UNKNOWN, value: JOB_STATUS.UNKNOWN }
];
};
import { JOB_STATUS } from '@/pages/DevOps/constants';
/**
* Checks if a job status indicates that the job is done.
......
......@@ -19,16 +19,28 @@
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
import JobList from '@/pages/DevOps/JobList';
import JobOverview from '@/pages/DevOps/JobList/components/Overview';
import { PageContainer } from '@ant-design/pro-layout';
import { Space } from 'antd';
import { createContext, useState } from 'react';
export const DevopContext = createContext({});
export default () => {
const [statusFilter, setStatusFilter] = useState();
/**
* breadcrumb={{style:{display:'none'}}} is used to hide the breadcrumb || 隐藏右上角的路由导航面包屑
*/
return (
<SlowlyAppear>
<PageContainer title={false} breadcrumb={{ style: { display: 'none' } }}>
<JobList />
<DevopContext.Provider value={{ statusFilter, setStatusFilter }}>
<Space direction='vertical' size={16}>
<JobOverview />
<JobList />
</Space>
</DevopContext.Provider>
</PageContainer>
</SlowlyAppear>
);
......
......@@ -31,6 +31,7 @@ export type StatusCountOverView = {
suspended: number;
reconciling: number;
unknown: number;
modelOverview: BatchStreamingOverView;
};
export type PieItem = {
......
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