🔨 定时执行配置.
This commit is contained in:
@@ -44,18 +44,18 @@ public class CodeGenerators {
|
||||
// .color("blue", "gray", "red", "green", "white")
|
||||
// .valueUseFields()
|
||||
// .build(),
|
||||
Template.create("exec_job", "计划任务", "exec")
|
||||
Template.create("exec_job", "计划执行", "exec")
|
||||
.disableUnitTest()
|
||||
.vue("exec", "exec-job")
|
||||
.enableDrawerForm()
|
||||
.dict("execJobStatus", "status")
|
||||
.comment("计划任务状态")
|
||||
.comment("计划执行状态")
|
||||
.field("execJobStatus")
|
||||
.fields("DISABLED", "ENABLED")
|
||||
.labels("禁用", "启用")
|
||||
.values(0, 1)
|
||||
.build(),
|
||||
Template.create("exec_job_host", "计划任务主机", "exec")
|
||||
Template.create("exec_job_host", "计划执行主机", "exec")
|
||||
.disableUnitTest()
|
||||
.vue("exec", "exec-job-host")
|
||||
.build(),
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#if($dictMap.entrySet().size() > 0)
|
||||
#foreach($enumEntity in $dictMap.entrySet())
|
||||
/**
|
||||
* $enumEntity.value.comment
|
||||
*/
|
||||
// $enumEntity.value.comment
|
||||
// FIXME 检查这里的类型
|
||||
export const $enumEntity.value.field = {
|
||||
#set($count = $enumEntity.value.fields.size() - 1)
|
||||
@@ -10,7 +8,7 @@ export const $enumEntity.value.field = {
|
||||
// $enumEntity.value.labels.get($index)
|
||||
$enumEntity.value.fields.get($index): '$enumEntity.value.values.get($index)',
|
||||
#end
|
||||
}
|
||||
};
|
||||
|
||||
#end
|
||||
#foreach($enumEntity in $dictMap.entrySet())
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ExecJobController {
|
||||
|
||||
@OperatorLog(ExecJobOperatorType.TRIGGER)
|
||||
@PostMapping("/trigger")
|
||||
@Operation(summary = "手动触发计划任务")
|
||||
@Operation(summary = "手动触发计划执行任务")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job:trigger')")
|
||||
public HttpWrapper<?> triggerExecJob(@Validated @RequestBody ExecJobTriggerRequest request) {
|
||||
execJobService.manualTriggerExecJob(request.getId());
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
### 查询计划任务日志
|
||||
### 查询计划执行任务日志
|
||||
GET {{baseUrl}}/asset/exec-job-log/get?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
### 分页查询计划任务日志
|
||||
### 分页查询计划执行任务日志
|
||||
POST {{baseUrl}}/asset/exec-job-log/query
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
@@ -20,12 +20,12 @@ Authorization: {{token}}
|
||||
}
|
||||
|
||||
|
||||
### 删除计划任务日志
|
||||
### 删除计划执行任务日志
|
||||
DELETE {{baseUrl}}/asset/exec-job-log/delete?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
### 批量删除计划任务日志
|
||||
### 批量删除计划执行任务日志
|
||||
DELETE {{baseUrl}}/asset/exec-job-log/batch-delete?idList=1,2,3
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 计划任务日志 api
|
||||
* 计划执行任务日志 api
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 11:31
|
||||
*/
|
||||
@Tag(name = "asset - 计划任务日志服务")
|
||||
@Tag(name = "asset - 计划执行任务日志服务")
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RestWrapper
|
||||
@@ -53,7 +53,7 @@ public class ExecJobLogController {
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PostMapping("/query")
|
||||
@Operation(summary = "分页查询计划任务日志")
|
||||
@Operation(summary = "分页查询计划执行任务日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:query')")
|
||||
public DataGrid<ExecLogVO> getExecJobLogPage(@Validated(Page.class) @RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
@@ -62,7 +62,7 @@ public class ExecJobLogController {
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "查询计划任务日志")
|
||||
@Operation(summary = "查询计划执行任务日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:query')")
|
||||
public ExecLogVO getExecJobLog(@RequestParam("id") Long id) {
|
||||
return execLogService.getExecLog(id, SOURCE);
|
||||
@@ -87,7 +87,7 @@ public class ExecJobLogController {
|
||||
|
||||
@OperatorLog(ExecJobLogOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除计划任务日志")
|
||||
@Operation(summary = "删除计划执行任务日志")
|
||||
@Parameter(name = "id", description = "id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:delete')")
|
||||
public Integer deleteExecJobLog(@RequestParam("id") Long id) {
|
||||
@@ -96,7 +96,7 @@ public class ExecJobLogController {
|
||||
|
||||
@OperatorLog(ExecJobLogOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "删除计划任务日志")
|
||||
@Operation(summary = "删除计划执行任务日志")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:delete')")
|
||||
public Integer batchDeleteExecJobLog(@RequestParam("idList") List<Long> idList) {
|
||||
@@ -113,7 +113,7 @@ public class ExecJobLogController {
|
||||
}
|
||||
|
||||
@PostMapping("/query-count")
|
||||
@Operation(summary = "查询计划任务日志数量")
|
||||
@Operation(summary = "查询计划执行任务日志数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:management:clear')")
|
||||
public Long getExecJobLogCount(@RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
@@ -122,7 +122,7 @@ public class ExecJobLogController {
|
||||
|
||||
@OperatorLog(ExecJobLogOperatorType.CLEAR)
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空计划任务日志")
|
||||
@Operation(summary = "清空计划执行任务日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:management:clear')")
|
||||
public Integer clearExecJobLog(@RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
@@ -130,7 +130,7 @@ public class ExecJobLogController {
|
||||
}
|
||||
|
||||
@PostMapping("/tail")
|
||||
@Operation(summary = "查看计划任务日志")
|
||||
@Operation(summary = "查看计划执行任务日志")
|
||||
@PreAuthorize("@ss.hasAnyPermission('asset:exec-job-log:query', 'asset:exec-job:exec')")
|
||||
public String getExecJobLogTailToken(@Validated @RequestBody ExecLogTailRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
@@ -139,7 +139,7 @@ public class ExecJobLogController {
|
||||
|
||||
@OperatorLog(ExecJobLogOperatorType.DOWNLOAD)
|
||||
@GetMapping("/download")
|
||||
@Operation(summary = "下载计划任务日志")
|
||||
@Operation(summary = "下载计划执行任务日志")
|
||||
@PreAuthorize("@ss.hasAnyPermission('asset:exec-job-log:query', 'asset:exec-job:exec')")
|
||||
public void downloadExecJobLogFile(@RequestParam("id") Long id, HttpServletResponse response) {
|
||||
execLogService.downloadLogFile(id, SOURCE, response);
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.orion.ops.module.asset.entity.vo.HostVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 主机 内部对象转换器
|
||||
*
|
||||
@@ -33,4 +35,6 @@ public interface HostConvert {
|
||||
|
||||
HostCacheDTO toCache(HostDO domain);
|
||||
|
||||
List<HostVO> toList(List<HostDO> domain);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ExecCommandLogOperatorType extends InitializingOperatorTypes {
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(H, DELETE, "删除批量执行日志 <sb>${count}</sb> 条"),
|
||||
new OperatorType(H, DELETE_HOST, "删除批量主机执行日志 <sb>${logId}</sb> <sb>${hostName}</sb>"),
|
||||
new OperatorType(H, DELETE_HOST, "删除批量执行主机日志 <sb>${logId}</sb> <sb>${hostName}</sb>"),
|
||||
new OperatorType(H, CLEAR, "清理批量执行日志 <sb>${count}</sb> 条"),
|
||||
new OperatorType(L, DOWNLOAD, "下载主机执行日志 <sb>${logId}</sb> <sb>${hostName}</sb>"),
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLe
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.L;
|
||||
|
||||
/**
|
||||
* 计划任务日志 操作记录类型
|
||||
* 计划执行日志 操作记录类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
@@ -28,9 +28,9 @@ public class ExecJobLogOperatorType extends InitializingOperatorTypes {
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(H, DELETE, "删除计划任务日志 <sb>${count}</sb> 条"),
|
||||
new OperatorType(H, DELETE_HOST, "删除批量主机执行日志 <sb>${logId}</sb> <sb>${hostName}</sb>"),
|
||||
new OperatorType(H, CLEAR, "清理计划任务日志 <sb>${count}</sb> 条"),
|
||||
new OperatorType(H, DELETE, "删除计划执行日志 <sb>${count}</sb> 条"),
|
||||
new OperatorType(H, DELETE_HOST, "删除计划执行主机日志 <sb>${logId}</sb> <sb>${hostName}</sb>"),
|
||||
new OperatorType(H, CLEAR, "清理计划执行日志 <sb>${count}</sb> 条"),
|
||||
new OperatorType(L, DOWNLOAD, "下载主机执行日志 <sb>${logId}</sb> <sb>${hostName}</sb>"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ public class ExecJobOperatorType extends InitializingOperatorTypes {
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(L, CREATE, "创建计划任务 <sb>${name}</sb>"),
|
||||
new OperatorType(M, UPDATE, "更新计划任务 <sb>${before}</sb>"),
|
||||
new OperatorType(M, UPDATE_STATUS, "<sb>${statusName}</sb>计划任务 <sb>${name}</sb>"),
|
||||
new OperatorType(M, TRIGGER, "手动触发计划任务 <sb>${name}</sb>"),
|
||||
new OperatorType(H, DELETE, "删除计划任务 <sb>${name}</sb>"),
|
||||
new OperatorType(L, CREATE, "创建计划执行任务 <sb>${name}</sb>"),
|
||||
new OperatorType(M, UPDATE, "更新计划执行任务 <sb>${before}</sb>"),
|
||||
new OperatorType(M, UPDATE_STATUS, "<sb>${statusName}</sb>计划执行任务 <sb>${name}</sb>"),
|
||||
new OperatorType(M, TRIGGER, "手动触发计划执行任务 <sb>${name}</sb>"),
|
||||
new OperatorType(H, DELETE, "删除计划执行任务 <sb>${name}</sb>"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ExecJobDO extends BaseDO {
|
||||
@TableField("parameter_schema")
|
||||
private String parameterSchema;
|
||||
|
||||
@Schema(description = "启用状态 0禁用 1启用")
|
||||
@Schema(description = "任务状态")
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ExecJobQueryRequest extends PageRequest {
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
@Schema(description = "启用状态 0禁用 1启用")
|
||||
@Schema(description = "任务状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否查询最近执行任务")
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ExecJobUpdateStatusRequest implements Serializable {
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "启用状态 0禁用 1启用")
|
||||
@Schema(description = "任务状态")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
@@ -44,17 +44,17 @@ public class ExecJobVO implements Serializable {
|
||||
@Schema(description = "命令参数")
|
||||
private String parameterSchema;
|
||||
|
||||
@Schema(description = "启用状态 0禁用 1启用")
|
||||
@Schema(description = "任务状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "最近执行id")
|
||||
private Long recentLogId;
|
||||
|
||||
@Schema(description = "最近执行状态")
|
||||
private String recentExecStatus;
|
||||
private String recentLogStatus;
|
||||
|
||||
@Schema(description = "最近执行时间")
|
||||
private Date recentExecTime;
|
||||
private Date recentLogTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
@@ -65,4 +65,7 @@ public class ExecJobVO implements Serializable {
|
||||
@Schema(description = "执行主机")
|
||||
private List<Long> hostIdList;
|
||||
|
||||
@Schema(description = "执行主机")
|
||||
private List<HostVO> hostList;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public enum ExecSourceEnum {
|
||||
BATCH,
|
||||
|
||||
/**
|
||||
* 计划任务
|
||||
* 计划执行
|
||||
*/
|
||||
JOB,
|
||||
|
||||
|
||||
@@ -221,7 +221,6 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
// 添加内置参数
|
||||
params.put("userId", request.getUserId());
|
||||
params.put("username", request.getUsername());
|
||||
params.put("source", request.getSource());
|
||||
params.put("sourceId", request.getSourceId());
|
||||
params.put("seq", request.getExecSeq());
|
||||
params.put("execId", execId);
|
||||
|
||||
@@ -12,10 +12,13 @@ import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.job.core.utils.QuartzUtils;
|
||||
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.ops.module.asset.convert.ExecJobConvert;
|
||||
import com.orion.ops.module.asset.convert.HostConvert;
|
||||
import com.orion.ops.module.asset.dao.ExecJobDAO;
|
||||
import com.orion.ops.module.asset.dao.ExecLogDAO;
|
||||
import com.orion.ops.module.asset.dao.HostDAO;
|
||||
import com.orion.ops.module.asset.entity.domain.ExecJobDO;
|
||||
import com.orion.ops.module.asset.entity.domain.ExecLogDO;
|
||||
import com.orion.ops.module.asset.entity.domain.HostDO;
|
||||
import com.orion.ops.module.asset.entity.request.exec.*;
|
||||
import com.orion.ops.module.asset.entity.vo.ExecJobVO;
|
||||
import com.orion.ops.module.asset.entity.vo.ExecLogVO;
|
||||
@@ -24,9 +27,9 @@ import com.orion.ops.module.asset.enums.ExecSourceEnum;
|
||||
import com.orion.ops.module.asset.enums.HostConfigTypeEnum;
|
||||
import com.orion.ops.module.asset.handler.host.exec.job.ExecCommandJob;
|
||||
import com.orion.ops.module.asset.service.AssetAuthorizedDataService;
|
||||
import com.orion.ops.module.asset.service.ExecCommandService;
|
||||
import com.orion.ops.module.asset.service.ExecJobHostService;
|
||||
import com.orion.ops.module.asset.service.ExecJobService;
|
||||
import com.orion.ops.module.asset.service.ExecCommandService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -58,6 +61,9 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
@Resource
|
||||
private ExecLogDAO execLogDAO;
|
||||
|
||||
@Resource
|
||||
private HostDAO hostDAO;
|
||||
|
||||
@Resource
|
||||
private ExecJobHostService execJobHostService;
|
||||
|
||||
@@ -80,7 +86,7 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
// 查询主机是否有权限
|
||||
this.checkHostPermission(request.getHostIdList());
|
||||
// 插入任务
|
||||
record.setStatus(ExecJobStatusEnum.ENABLED.getStatus());
|
||||
record.setStatus(ExecJobStatusEnum.DISABLED.getStatus());
|
||||
int effect = execJobDAO.insert(record);
|
||||
Long id = record.getId();
|
||||
// 设置任务主机
|
||||
@@ -152,6 +158,9 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
// 查询任务主机
|
||||
List<Long> hostIdList = execJobHostService.getHostIdByJobId(id);
|
||||
vo.setHostIdList(hostIdList);
|
||||
// 查询主机列表
|
||||
List<HostDO> hostList = hostDAO.selectBatchIds(hostIdList);
|
||||
vo.setHostList(HostConvert.MAPPER.toList(hostList));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -175,6 +184,7 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
List<ExecLogDO> logList = execLogDAO.selectBatchIds(logIdList);
|
||||
Map<Long, ExecLogDO> logMap = logList.stream()
|
||||
.collect(Collectors.toMap(ExecLogDO::getId, Function.identity()));
|
||||
// 设置任务状态
|
||||
dataGrid.forEach(s -> {
|
||||
Long logId = s.getRecentLogId();
|
||||
if (logId == null) {
|
||||
@@ -184,8 +194,8 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
if (execLog == null) {
|
||||
return;
|
||||
}
|
||||
s.setRecentExecTime(execLog.getStartTime());
|
||||
s.setRecentExecStatus(execLog.getStatus());
|
||||
s.setRecentLogTime(execLog.getStartTime());
|
||||
s.setRecentLogStatus(execLog.getStatus());
|
||||
});
|
||||
}
|
||||
return dataGrid;
|
||||
@@ -305,8 +315,8 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
private LambdaQueryWrapper<ExecJobDO> buildQueryWrapper(ExecJobQueryRequest request) {
|
||||
return execJobDAO.wrapper()
|
||||
.eq(ExecJobDO::getId, request.getId())
|
||||
.eq(ExecJobDO::getName, request.getName())
|
||||
.eq(ExecJobDO::getCommand, request.getCommand())
|
||||
.like(ExecJobDO::getName, request.getName())
|
||||
.like(ExecJobDO::getCommand, request.getCommand())
|
||||
.eq(ExecJobDO::getStatus, request.getStatus())
|
||||
.orderByDesc(ExecJobDO::getId);
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -37,9 +36,9 @@ import java.util.stream.Collectors;
|
||||
public class ExpressionController {
|
||||
|
||||
@PermitAll
|
||||
@PostMapping("/cron-next")
|
||||
@GetMapping("/cron-next")
|
||||
@Operation(summary = "获取 cron 下次执行时间")
|
||||
public CronNextVO getCronNextTime(@Validated @RequestBody CronNextRequest request) {
|
||||
public CronNextVO getCronNextTime(@Validated CronNextRequest request) {
|
||||
CronNextVO next = new CronNextVO();
|
||||
try {
|
||||
Cron cron = Cron.of(request.getExpression());
|
||||
|
||||
@@ -4,7 +4,7 @@ import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
/**
|
||||
* 执行记录查询请求
|
||||
* 批量执行日志查询请求
|
||||
*/
|
||||
export interface ExecCommandLogQueryRequest extends Pagination {
|
||||
id?: number;
|
||||
@@ -16,7 +16,7 @@ export interface ExecCommandLogQueryRequest extends Pagination {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行记录查询响应
|
||||
* 批量执行日志查询响应
|
||||
*/
|
||||
export interface ExecCommandLogQueryResponse extends TableData, ExecCommandLogQueryExtraResponse {
|
||||
id: number;
|
||||
@@ -34,14 +34,14 @@ export interface ExecCommandLogQueryResponse extends TableData, ExecCommandLogQu
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行记录查询响应 拓展
|
||||
* 批量执行日志查询响应 拓展
|
||||
*/
|
||||
export interface ExecCommandLogQueryExtraResponse {
|
||||
hosts: Array<ExecCommandHostLogQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主机执行记录查询响应
|
||||
* 主机批量执行日志查询响应
|
||||
*/
|
||||
export interface ExecCommandHostLogQueryResponse extends TableData {
|
||||
id: number;
|
||||
@@ -59,7 +59,7 @@ export interface ExecCommandHostLogQueryResponse extends TableData {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行状态查询响应
|
||||
* 批量执行状态查询响应
|
||||
*/
|
||||
export interface ExecCommandLogStatusResponse {
|
||||
logList: Array<ExecCommandLogQueryResponse>;
|
||||
@@ -67,7 +67,7 @@ export interface ExecCommandLogStatusResponse {
|
||||
}
|
||||
|
||||
/**
|
||||
* 中断命令请求
|
||||
* 批量执行日志 tail 请求
|
||||
*/
|
||||
export interface ExecCommandLogTailRequest {
|
||||
execId?: number;
|
||||
@@ -75,21 +75,21 @@ export interface ExecCommandLogTailRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询执行记录
|
||||
* 分页查询批量执行日志
|
||||
*/
|
||||
export function getExecCommandLogPage(request: ExecCommandLogQueryRequest) {
|
||||
return axios.post<DataGrid<ExecCommandLogQueryResponse>>('/asset/exec-command-log/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询执行记录
|
||||
* 查询批量执行日志
|
||||
*/
|
||||
export function getExecCommandLog(id: number) {
|
||||
return axios.get<ExecCommandLogQueryResponse>('/asset/exec-command-log/get', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询主机执行记录
|
||||
* 查询主机批量执行日志
|
||||
*/
|
||||
export function getExecCommandHostLogList(logId: number) {
|
||||
return axios.get<Array<ExecCommandHostLogQueryResponse>>('/asset/exec-command-log/host-list', { params: { logId } });
|
||||
@@ -108,21 +108,21 @@ export function getExecCommandLogStatus(idList: Array<number>) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询历史执行记录
|
||||
* 查询历史批量执行日志
|
||||
*/
|
||||
export function getExecCommandLogHistory(limit: number) {
|
||||
return axios.get<Array<ExecCommandLogQueryResponse>>('/asset/exec-command-log/history', { params: { page: 1, limit } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除执行记录
|
||||
* 删除批量执行日志
|
||||
*/
|
||||
export function deleteExecCommandLog(id: number) {
|
||||
return axios.delete('/asset/exec-command-log/delete', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除执行记录
|
||||
* 批量删除批量执行日志
|
||||
*/
|
||||
export function batchDeleteExecCommandLog(idList: Array<number>) {
|
||||
return axios.delete('/asset/exec-command-log/batch-delete', {
|
||||
@@ -134,35 +134,35 @@ export function batchDeleteExecCommandLog(idList: Array<number>) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除主机执行记录
|
||||
* 删除主机批量执行日志
|
||||
*/
|
||||
export function deleteExecCommandHostLog(id: number) {
|
||||
return axios.delete('/asset/exec-command-log/delete-host', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询操作日志数量
|
||||
* 查询批量执行日志数量
|
||||
*/
|
||||
export function getExecCommandLogCount(request: ExecCommandLogQueryRequest) {
|
||||
return axios.post<number>('/asset/exec-command-log/query-count', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空操作日志
|
||||
* 清空批量执行日志
|
||||
*/
|
||||
export function clearExecCommandLog(request: ExecCommandLogQueryRequest) {
|
||||
return axios.post<number>('/asset/exec-command-log/clear', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看执行日志
|
||||
* 查看批量执行日志
|
||||
*/
|
||||
export function getExecCommandLogTailToken(request: ExecCommandLogTailRequest) {
|
||||
return axios.post<string>('/asset/exec-command-log/tail', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载执行日志文件
|
||||
* 下载批量执行日志文件
|
||||
*/
|
||||
export function downloadExecCommandLogFile(id: number) {
|
||||
return axios.get('/asset/exec-command-log/download', { unwrap: true, params: { id } });
|
||||
|
||||
162
orion-ops-ui/src/api/exec/exec-job-log.ts
Normal file
162
orion-ops-ui/src/api/exec/exec-job-log.ts
Normal file
@@ -0,0 +1,162 @@
|
||||
import type { DataGrid, Pagination } from '@/types/global';
|
||||
import type { TableData } from '@arco-design/web-vue/es/table/interface';
|
||||
import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
/**
|
||||
* 计划执行日志查询请求
|
||||
*/
|
||||
export interface ExecJobLogQueryRequest extends Pagination {
|
||||
id?: number;
|
||||
userId?: number;
|
||||
description?: string;
|
||||
command?: string;
|
||||
status?: string;
|
||||
startTimeRange?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划执行日志查询响应
|
||||
*/
|
||||
export interface ExecJobLogQueryResponse extends TableData, ExecJobLogQueryExtraResponse {
|
||||
id: number;
|
||||
userId: number;
|
||||
username: string;
|
||||
description: string;
|
||||
command: string;
|
||||
parameterSchema: string;
|
||||
timeout: number;
|
||||
status: string;
|
||||
startTime: number;
|
||||
finishTime: number;
|
||||
hostIdList: Array<number>;
|
||||
hosts: Array<ExecJobHostLogQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划执行日志查询响应 拓展
|
||||
*/
|
||||
export interface ExecJobLogQueryExtraResponse {
|
||||
hosts: Array<ExecJobHostLogQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主机计划执行日志查询响应
|
||||
*/
|
||||
export interface ExecJobHostLogQueryResponse extends TableData {
|
||||
id: number;
|
||||
logId: number;
|
||||
hostId: number;
|
||||
hostName: string;
|
||||
hostAddress: string;
|
||||
status: string;
|
||||
command: string;
|
||||
parameter: string;
|
||||
exitStatus: number;
|
||||
errorMessage: string;
|
||||
startTime: number;
|
||||
finishTime: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划执行状态查询响应
|
||||
*/
|
||||
export interface ExecJobLogStatusResponse {
|
||||
logList: Array<ExecJobLogQueryResponse>;
|
||||
hostList: Array<ExecJobHostLogQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划执行日志 tail 请求
|
||||
*/
|
||||
export interface ExecJobLogTailRequest {
|
||||
execId?: number;
|
||||
hostExecIdList?: Array<number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询计划执行日志
|
||||
*/
|
||||
export function getExecJobLogPage(request: ExecJobLogQueryRequest) {
|
||||
return axios.post<DataGrid<ExecJobLogQueryResponse>>('/asset/exec-job-log/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询计划执行日志
|
||||
*/
|
||||
export function getExecJobLog(id: number) {
|
||||
return axios.get<ExecJobLogQueryResponse>('/asset/exec-job-log/get', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询主机计划执行日志
|
||||
*/
|
||||
export function getExecJobHostLogList(logId: number) {
|
||||
return axios.get<Array<ExecJobHostLogQueryResponse>>('/asset/exec-job-log/host-list', { params: { logId } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询命令执行状态
|
||||
*/
|
||||
export function getExecJobLogStatus(idList: Array<number>) {
|
||||
return axios.get<ExecJobLogStatusResponse>('/asset/exec-job-log/status', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除计划执行日志
|
||||
*/
|
||||
export function deleteExecJobLog(id: number) {
|
||||
return axios.delete('/asset/exec-job-log/delete', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除计划执行日志
|
||||
*/
|
||||
export function batchDeleteExecJobLog(idList: Array<number>) {
|
||||
return axios.delete('/asset/exec-job-log/batch-delete', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除主机计划执行日志
|
||||
*/
|
||||
export function deleteExecJobHostLog(id: number) {
|
||||
return axios.delete('/asset/exec-job-log/delete-host', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询计划执行日志数量
|
||||
*/
|
||||
export function getExecJobLogCount(request: ExecJobLogQueryRequest) {
|
||||
return axios.post<number>('/asset/exec-job-log/query-count', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空计划执行日志
|
||||
*/
|
||||
export function clearExecJobLog(request: ExecJobLogQueryRequest) {
|
||||
return axios.post<number>('/asset/exec-job-log/clear', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看计划执行日志
|
||||
*/
|
||||
export function getExecJobLogTailToken(request: ExecJobLogTailRequest) {
|
||||
return axios.post<string>('/asset/exec-job-log/tail', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载计划执行日志文件
|
||||
*/
|
||||
export function downloadExecJobLogFile(id: number) {
|
||||
return axios.get('/asset/exec-job-log/download', { unwrap: true, params: { id } });
|
||||
}
|
||||
111
orion-ops-ui/src/api/exec/exec-job.ts
Normal file
111
orion-ops-ui/src/api/exec/exec-job.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import type { DataGrid, Pagination } from '@/types/global';
|
||||
import type { TableData } from '@arco-design/web-vue/es/table/interface';
|
||||
import type { HostQueryResponse } from '@/api/asset/host';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 计划执行创建请求
|
||||
*/
|
||||
export interface ExecJobCreateRequest {
|
||||
name?: string;
|
||||
expression?: string;
|
||||
timeout?: number;
|
||||
command?: string;
|
||||
parameterSchema?: string;
|
||||
hostIdList?: Array<number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划执行更新请求
|
||||
*/
|
||||
export interface ExecJobUpdateRequest extends ExecJobCreateRequest {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划执行状态更新请求
|
||||
*/
|
||||
export interface ExecJobUpdateStatusRequest {
|
||||
id: number;
|
||||
status: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划执行查询请求
|
||||
*/
|
||||
export interface ExecJobQueryRequest extends Pagination {
|
||||
id?: number;
|
||||
name?: string;
|
||||
command?: string;
|
||||
status?: number;
|
||||
queryRecentLog?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划执行查询响应
|
||||
*/
|
||||
export interface ExecJobQueryResponse extends TableData {
|
||||
id: number;
|
||||
name: string;
|
||||
expression: string;
|
||||
timeout: number;
|
||||
command: string;
|
||||
parameterSchema: string;
|
||||
status: number;
|
||||
recentLogId: number;
|
||||
recentLogStatus: string;
|
||||
recentLogTime: number;
|
||||
createTime: number;
|
||||
updateTime: number;
|
||||
hostIdList: Array<number>;
|
||||
hostList: Array<HostQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建计划执行
|
||||
*/
|
||||
export function createExecJob(request: ExecJobCreateRequest) {
|
||||
return axios.post('/asset/exec-job/create', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新计划执行
|
||||
*/
|
||||
export function updateExecJob(request: ExecJobUpdateRequest) {
|
||||
return axios.put('/asset/exec-job/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新计划执行状态
|
||||
*/
|
||||
export function updateExecJobStatus(request: ExecJobUpdateStatusRequest) {
|
||||
return axios.put('/asset/exec-job/update-status', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询计划执行
|
||||
*/
|
||||
export function getExecJob(id: number) {
|
||||
return axios.get<ExecJobQueryResponse>('/asset/exec-job/get', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询计划执行
|
||||
*/
|
||||
export function getExecJobPage(request: ExecJobQueryRequest) {
|
||||
return axios.post<DataGrid<ExecJobQueryResponse>>('/asset/exec-job/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除计划执行
|
||||
*/
|
||||
export function deleteExecJob(id: number) {
|
||||
return axios.delete('/asset/exec-job/delete', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动触发计划执行任务
|
||||
*/
|
||||
export function triggerExecJob(id: number) {
|
||||
return axios.post('/asset/exec-job/trigger', { id });
|
||||
}
|
||||
24
orion-ops-ui/src/api/meta/expression.ts
Normal file
24
orion-ops-ui/src/api/meta/expression.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* cron 下次执行时间请求对象
|
||||
*/
|
||||
export interface CronNextRequest {
|
||||
expression: number;
|
||||
times: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* cron 下次执行时间响应对象
|
||||
*/
|
||||
export interface CronNextResponse {
|
||||
valid: boolean;
|
||||
next: Array<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 cron 下次执行时间
|
||||
*/
|
||||
export function getCronNextTime(request: CronNextRequest) {
|
||||
return axios.get<CronNextResponse>('/infra/expression/cron-next', { params: request });
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<a-modal v-model:visible="visible"
|
||||
title-align="start"
|
||||
:top="120"
|
||||
:width="298"
|
||||
:body-style="{ padding: '16px' }"
|
||||
:align-center="false"
|
||||
:mask-closable="true"
|
||||
:unmount-on-close="true"
|
||||
:footer="false"
|
||||
@close="handleClose">
|
||||
<!-- title -->
|
||||
<template #title>
|
||||
<span class="modal-title">
|
||||
未来 <span class="span-blue times">{{ request?.times }}</span> 次执行时间
|
||||
</span>
|
||||
</template>
|
||||
<a-spin class="full container" :loading="loading">
|
||||
<!-- cron 表达式 -->
|
||||
<div class="cron-value span-blue">
|
||||
{{ request?.expression }}
|
||||
</div>
|
||||
<!-- 执行时间 -->
|
||||
<div v-for="time in next"
|
||||
:key="time"
|
||||
class="next-time">
|
||||
{{ time }}
|
||||
</div>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'nextCronModal'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { CronNextRequest } from '@/api/meta/expression';
|
||||
import { ref } from 'vue';
|
||||
import { getCronNextTime } from '@/api/meta/expression';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { loading, setLoading } = useLoading();
|
||||
|
||||
const request = ref<CronNextRequest>();
|
||||
const next = ref<Array<string>>([]);
|
||||
|
||||
// 打开
|
||||
const open = async (record: CronNextRequest) => {
|
||||
request.value = record;
|
||||
try {
|
||||
// 获取执行时间
|
||||
setLoading(true);
|
||||
const { data } = await getCronNextTime(request.value);
|
||||
if (data.valid) {
|
||||
// 表达式正确
|
||||
next.value = data.next;
|
||||
setVisible(true);
|
||||
|
||||
} else {
|
||||
// 表达式错误
|
||||
setVisible(false);
|
||||
Message.error('cron 表达式错误');
|
||||
}
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
defineExpose({ open });
|
||||
|
||||
// 关闭回调
|
||||
const handleClose = () => {
|
||||
handleClear();
|
||||
};
|
||||
|
||||
// 清空
|
||||
const handleClear = () => {
|
||||
setLoading(false);
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.modal-title {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.times {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.cron-value {
|
||||
margin-bottom: 8px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.next-time {
|
||||
margin-bottom: 4px;
|
||||
color: var(--color-text-2);
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -62,7 +62,7 @@
|
||||
}
|
||||
suggestions.push({
|
||||
label: triggerPrefix + s.name,
|
||||
kind: monaco.languages.CompletionItemKind.Field,
|
||||
kind: monaco.languages.CompletionItemKind.Variable,
|
||||
insertText: templatePrefix + s.name + templateSuffix,
|
||||
detail: s.desc || '',
|
||||
documentation: s.desc || '',
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
type="round"
|
||||
:checked-value="1"
|
||||
:unchecked-value="0"
|
||||
:beforeChange="s => updateStatus(s as number)" />
|
||||
:before-change="s => updateStatus(s as number)" />
|
||||
</div>
|
||||
</template>
|
||||
<a-spin v-show="config.status" :loading="loading" class="config-form-wrapper">
|
||||
@@ -223,7 +223,7 @@
|
||||
}] as FieldRule[];
|
||||
|
||||
// 修改状态
|
||||
const updateStatus = (e: number) => {
|
||||
const updateStatus = async (e: number) => {
|
||||
setLoading(true);
|
||||
return updateHostConfigStatus({
|
||||
hostId: props?.hostId,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<a-modal v-model:visible="visible"
|
||||
body-class="modal-form"
|
||||
title-align="start"
|
||||
title="清空执行记录"
|
||||
title="清空批量执行日志"
|
||||
:align-center="false"
|
||||
:draggable="true"
|
||||
:mask-closable="false"
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<div class="table-left-bar-handle">
|
||||
<!-- 标题 -->
|
||||
<div class="table-title">
|
||||
执行记录列表
|
||||
批量执行日志列表
|
||||
</div>
|
||||
</div>
|
||||
<!-- 右侧操作 -->
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<div v-else-if="!historyLogs.length" class="flex-center mt16">
|
||||
<a-empty description="无执行记录" />
|
||||
</div>
|
||||
<!-- 执行记录 -->
|
||||
<!-- 批量执行日志 -->
|
||||
<div v-else class="exec-history-rows">
|
||||
<div v-for="record in historyLogs"
|
||||
:key="record.id"
|
||||
@@ -84,7 +84,7 @@
|
||||
|
||||
defineExpose({ add });
|
||||
|
||||
// 加载执行记录
|
||||
// 加载批量执行日志
|
||||
const fetchExecHistory = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
@@ -96,7 +96,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 加载执行记录
|
||||
// 加载批量执行日志
|
||||
onMounted(fetchExecHistory);
|
||||
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="visible"
|
||||
:title="title"
|
||||
:width="470"
|
||||
:mask-closable="false"
|
||||
:unmount-on-close="true"
|
||||
:ok-button-props="{ disabled: loading }"
|
||||
:cancel-button-props="{ disabled: loading }"
|
||||
:on-before-ok="handlerOk"
|
||||
@cancel="handleClose">
|
||||
<a-spin class="full modal-form" :loading="loading">
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
label-align="right"
|
||||
:label-col-props="{ span: 5 }"
|
||||
:wrapper-col-props="{ span: 18 }"
|
||||
:rules="formRules">
|
||||
<!-- 任务名称 -->
|
||||
<a-form-item field="name" label="任务名称">
|
||||
<a-input v-model="formModel.name"
|
||||
placeholder="请输入任务名称"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 执行序列 -->
|
||||
<a-form-item field="execSeq" label="执行序列">
|
||||
<a-input-number v-model="formModel.execSeq"
|
||||
placeholder="请输入执行序列"
|
||||
hide-button />
|
||||
</a-form-item>
|
||||
<!-- cron 表达式 -->
|
||||
<a-form-item field="expression" label="cron 表达式">
|
||||
<a-input v-model="formModel.expression"
|
||||
placeholder="请输入cron 表达式"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 超时时间 -->
|
||||
<a-form-item field="timeout" label="超时时间">
|
||||
<a-input-number v-model="formModel.timeout"
|
||||
placeholder="请输入超时时间"
|
||||
hide-button />
|
||||
</a-form-item>
|
||||
<!-- 执行命令 -->
|
||||
<a-form-item field="command" label="执行命令">
|
||||
<a-input v-model="formModel.command"
|
||||
placeholder="请输入执行命令"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 命令参数 -->
|
||||
<a-form-item field="parameterSchema" label="命令参数">
|
||||
<a-input v-model="formModel.parameterSchema"
|
||||
placeholder="请输入命令参数"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 任务状态 -->
|
||||
<a-form-item field="status" label="任务状态">
|
||||
<a-select v-model="formModel.status"
|
||||
:options="toOptions(execJobStatusKey)"
|
||||
placeholder="任务状态" />
|
||||
</a-form-item>
|
||||
<!-- 最近执行id -->
|
||||
<a-form-item field="recentLogId" label="最近执行id">
|
||||
<a-input-number v-model="formModel.recentLogId"
|
||||
placeholder="请输入最近执行id"
|
||||
hide-button />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'execJobDetailDrawer'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecJobUpdateRequest } from '@/api/exec/exec-job';
|
||||
import { ref } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import formRules from '../types/form.rules';
|
||||
import { execJobStatusKey } from '../types/const';
|
||||
import { createExecJob, updateExecJob } from '@/api/exec/exec-job';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { useDictStore } from '@/store';
|
||||
|
||||
const emits = defineEmits(['added', 'updated']);
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { toOptions } = useDictStore();
|
||||
|
||||
const title = ref<string>();
|
||||
const isAddHandle = ref<boolean>(true);
|
||||
const formRef = ref<any>();
|
||||
const formModel = ref<ExecJobUpdateRequest>({});
|
||||
|
||||
const defaultForm = (): ExecJobUpdateRequest => {
|
||||
return {
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
execSeq: undefined,
|
||||
expression: undefined,
|
||||
timeout: undefined,
|
||||
command: undefined,
|
||||
parameterSchema: undefined,
|
||||
status: undefined,
|
||||
recentLogId: undefined,
|
||||
};
|
||||
};
|
||||
|
||||
// 打开新增
|
||||
const openAdd = () => {
|
||||
title.value = '添加计划执行';
|
||||
isAddHandle.value = true;
|
||||
renderForm({ ...defaultForm() });
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
// 打开修改
|
||||
const openUpdate = (record: any) => {
|
||||
title.value = '修改计划执行';
|
||||
isAddHandle.value = false;
|
||||
renderForm({ ...defaultForm(), ...record });
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
// 渲染表单
|
||||
const renderForm = (record: any) => {
|
||||
formModel.value = Object.assign({}, record);
|
||||
};
|
||||
|
||||
defineExpose({ openAdd, openUpdate });
|
||||
|
||||
// 确定
|
||||
const handlerOk = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
// 验证参数
|
||||
const error = await formRef.value.validate();
|
||||
if (error) {
|
||||
return false;
|
||||
}
|
||||
if (isAddHandle.value) {
|
||||
// 新增
|
||||
await createExecJob(formModel.value);
|
||||
Message.success('创建成功');
|
||||
emits('added');
|
||||
} else {
|
||||
// 修改
|
||||
await updateExecJob(formModel.value);
|
||||
Message.success('修改成功');
|
||||
emits('updated');
|
||||
}
|
||||
// 清空
|
||||
handlerClear();
|
||||
} catch (e) {
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 关闭
|
||||
const handleClose = () => {
|
||||
handlerClear();
|
||||
};
|
||||
|
||||
// 清空
|
||||
const handlerClear = () => {
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,255 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="visible"
|
||||
:title="title"
|
||||
width="70%"
|
||||
:mask-closable="false"
|
||||
:unmount-on-close="true"
|
||||
:ok-button-props="{ disabled: loading }"
|
||||
:cancel-button-props="{ disabled: loading }"
|
||||
:on-before-ok="handlerOk"
|
||||
@cancel="handleClose">
|
||||
<a-spin class="full spin-wrapper" :loading="loading">
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
layout="vertical"
|
||||
:rules="formRules">
|
||||
<a-row :gutter="16">
|
||||
<!-- 任务名称 -->
|
||||
<a-col :span="14">
|
||||
<a-form-item field="name" label="任务名称">
|
||||
<a-input v-model="formModel.name"
|
||||
placeholder="请输入任务名称"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 执行主机 -->
|
||||
<a-col :span="10">
|
||||
<a-form-item field="hostIdList" label="执行主机">
|
||||
<div class="selected-host">
|
||||
<!-- 已选择数量 -->
|
||||
<span class="usn" v-if="formModel.hostIdList?.length">
|
||||
已选择<span class="selected-host-count span-blue">{{ formModel.hostIdList?.length }}</span>台主机
|
||||
</span>
|
||||
<span class="usn pointer span-blue" @click="openSelectHost">
|
||||
{{ formModel.hostIdList?.length ? '重新选择' : '选择主机' }}
|
||||
</span>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- cron -->
|
||||
<a-col :span="14">
|
||||
<a-form-item field="expression" label="cron">
|
||||
<a-input v-model="formModel.expression"
|
||||
placeholder="请输入 cron 表达式"
|
||||
allow-clear>
|
||||
<template #append>
|
||||
<span class="span-blue pointer usn"
|
||||
title="获取 cron 下次执行时间"
|
||||
@click="emits('testCron', formModel.expression)">
|
||||
测试
|
||||
</span>
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 超时时间 -->
|
||||
<a-col :span="10">
|
||||
<a-form-item field="timeout" label="超时时间">
|
||||
<a-input-number v-model="formModel.timeout"
|
||||
placeholder="为0则不超时"
|
||||
:min="0"
|
||||
:max="100000"
|
||||
hide-button>
|
||||
<template #suffix>
|
||||
秒
|
||||
</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 执行命令 -->
|
||||
<a-col :span="24">
|
||||
<a-form-item field="command"
|
||||
label="执行命令"
|
||||
:hide-label="true"
|
||||
:wrapper-col-props="{ span: 24 }"
|
||||
:help="'使用 @{{ xxx }} 来替换参数, 输入_可以获取全部变量'">
|
||||
<exec-editor v-model="formModel.command"
|
||||
containerClass="command-editor"
|
||||
theme="vs-dark"
|
||||
:parameter="jobBuiltinsParams" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'execJobFormDrawer'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecJobUpdateRequest } from '@/api/exec/exec-job';
|
||||
import { onUnmounted, ref } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import formRules from '../types/form.rules';
|
||||
import { jobBuiltinsParams } from '../types/const';
|
||||
import { createExecJob, getExecJob, updateExecJob } from '@/api/exec/exec-job';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||
|
||||
const emits = defineEmits(['added', 'updated', 'openHost', 'testCron']);
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { toOptions } = useDictStore();
|
||||
|
||||
const title = ref<string>();
|
||||
const isAddHandle = ref<boolean>(true);
|
||||
const formRef = ref<any>();
|
||||
const formModel = ref<ExecJobUpdateRequest>({});
|
||||
|
||||
const defaultForm = (): ExecJobUpdateRequest => {
|
||||
return {
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
expression: undefined,
|
||||
timeout: 0,
|
||||
command: undefined,
|
||||
parameterSchema: '[]',
|
||||
hostIdList: []
|
||||
};
|
||||
};
|
||||
|
||||
// 打开新增
|
||||
const openAdd = () => {
|
||||
title.value = '添加计划执行';
|
||||
isAddHandle.value = true;
|
||||
renderForm({ ...defaultForm() });
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
// 打开修改
|
||||
const openUpdate = async (id: any) => {
|
||||
title.value = '修改计划执行';
|
||||
isAddHandle.value = false;
|
||||
renderForm({});
|
||||
setVisible(true);
|
||||
// 查询计划任务
|
||||
try {
|
||||
setLoading(true);
|
||||
const { data } = await getExecJob(id);
|
||||
renderForm({ ...defaultForm(), ...data });
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染表单
|
||||
const renderForm = (record: ExecJobUpdateRequest) => {
|
||||
formModel.value = {
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
expression: record.expression,
|
||||
timeout: record.timeout,
|
||||
command: record.command,
|
||||
parameterSchema: record.parameterSchema,
|
||||
hostIdList: record.hostIdList,
|
||||
};
|
||||
};
|
||||
|
||||
// 设置选中主机
|
||||
const setSelectedHost = (hosts: Array<number>) => {
|
||||
formModel.value.hostIdList = hosts;
|
||||
};
|
||||
|
||||
defineExpose({ openAdd, openUpdate, setSelectedHost });
|
||||
|
||||
// 打开选择主机
|
||||
const openSelectHost = () => {
|
||||
emits('openHost', formModel.value.hostIdList);
|
||||
};
|
||||
|
||||
// 确定
|
||||
const handlerOk = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
// 验证参数
|
||||
const error = await formRef.value.validate();
|
||||
if (error) {
|
||||
return false;
|
||||
}
|
||||
if (isAddHandle.value) {
|
||||
// 新增
|
||||
await createExecJob(formModel.value);
|
||||
Message.success('创建成功');
|
||||
emits('added');
|
||||
} else {
|
||||
// 修改
|
||||
await updateExecJob(formModel.value);
|
||||
Message.success('修改成功');
|
||||
emits('updated');
|
||||
}
|
||||
// 清空
|
||||
handlerClear();
|
||||
} catch (e) {
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 关闭
|
||||
const handleClose = () => {
|
||||
handlerClear();
|
||||
};
|
||||
|
||||
// 清空
|
||||
const handlerClear = () => {
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
// 卸载关闭
|
||||
onUnmounted(handlerClear);
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.spin-wrapper {
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
.selected-host {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
padding: 0 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: var(--color-fill-2);
|
||||
transition: all 0.3s;
|
||||
|
||||
&-count {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
display: inline-block;
|
||||
margin: 0 6px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--color-fill-3);
|
||||
}
|
||||
}
|
||||
|
||||
.command-editor {
|
||||
width: 100%;
|
||||
height: 48vh;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,287 @@
|
||||
<template>
|
||||
<!-- 搜索 -->
|
||||
<a-card class="general-card table-search-card">
|
||||
<query-header :model="formModel"
|
||||
label-align="left"
|
||||
@submit="fetchTableData"
|
||||
@reset="fetchTableData"
|
||||
@keyup.enter="() => fetchTableData()">
|
||||
<!-- id -->
|
||||
<a-form-item field="id" label="id">
|
||||
<a-input-number v-model="formModel.id"
|
||||
placeholder="请输入id"
|
||||
allow-clear
|
||||
hide-button />
|
||||
</a-form-item>
|
||||
<!-- 任务名称 -->
|
||||
<a-form-item field="name" label="任务名称">
|
||||
<a-input v-model="formModel.name"
|
||||
placeholder="请输入任务名称"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 执行命令 -->
|
||||
<a-form-item field="command" label="执行命令">
|
||||
<a-input v-model="formModel.command"
|
||||
placeholder="请输入执行命令"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 任务状态 -->
|
||||
<a-form-item field="status" label="任务状态">
|
||||
<a-select v-model="formModel.status"
|
||||
:options="toOptions(execJobStatusKey)"
|
||||
placeholder="请选择状态"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</query-header>
|
||||
</a-card>
|
||||
<!-- 表格 -->
|
||||
<a-card class="general-card table-card">
|
||||
<template #title>
|
||||
<!-- 左侧操作 -->
|
||||
<div class="table-left-bar-handle">
|
||||
<!-- 标题 -->
|
||||
<div class="table-title">
|
||||
计划执行列表
|
||||
</div>
|
||||
</div>
|
||||
<!-- 右侧操作 -->
|
||||
<div class="table-right-bar-handle">
|
||||
<a-space>
|
||||
<!-- 新增 -->
|
||||
<a-button v-permission="['asset:exec-job:create']"
|
||||
type="primary"
|
||||
@click="emits('openAdd')">
|
||||
新增
|
||||
<template #icon>
|
||||
<icon-plus />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
<!-- table -->
|
||||
<a-table row-key="id"
|
||||
ref="tableRef"
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="tableRenderData"
|
||||
:pagination="pagination"
|
||||
:bordered="false"
|
||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||
@page-size-change="(size) => fetchTableData(1, size)">
|
||||
<!-- cron -->
|
||||
<template #expression="{ record }">
|
||||
<span class="copy-left"
|
||||
title="复制"
|
||||
@click="copy(record.expression, '已复制')">
|
||||
<icon-copy />
|
||||
</span>
|
||||
<span class="text-copy span-blue"
|
||||
title="查看下次执行时间"
|
||||
@click="emits('testCron', record.expression)">
|
||||
{{ record.expression }}
|
||||
</span>
|
||||
</template>
|
||||
<!-- 命令 -->
|
||||
<template #command="{ record }">
|
||||
<span class="copy-left"
|
||||
title="复制"
|
||||
@click="copy(record.command, '已复制')">
|
||||
<icon-copy />
|
||||
</span>
|
||||
<span>{{ record.command }}</span>
|
||||
</template>
|
||||
<!-- 任务状态 -->
|
||||
<template #status="{ record }">
|
||||
<!-- 状态开关 可编辑 -->
|
||||
<a-switch v-if="hasPermission('asset:exec-job:update-status')"
|
||||
type="round"
|
||||
:default-checked="record.status === ExecJobStatus.ENABLED"
|
||||
:checked-text="getDictValue(execJobStatusKey, ExecJobStatus.ENABLED)"
|
||||
:unchecked-text="getDictValue(execJobStatusKey, ExecJobStatus.DISABLED)"
|
||||
:checked-value="ExecJobStatus.ENABLED"
|
||||
:unchecked-value="ExecJobStatus.DISABLED"
|
||||
:before-change="s => updateStatus(record.id, s as number)" />
|
||||
<!-- 状态 不可编辑 -->
|
||||
<a-tag v-else :color="getDictValue(execJobStatusKey, record.status, 'color')">
|
||||
{{ getDictValue(execJobStatusKey, record.status) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<!-- 最近任务状态 -->
|
||||
<template #recentLogStatus="{ record }">
|
||||
<!-- 最近任务 -->
|
||||
<div class="flex-center" v-if="record.recentLogId">
|
||||
<!-- 执行状态 -->
|
||||
<a-tag class="mr8" :color="getDictValue(execStatusKey, record.recentLogStatus, 'color')">
|
||||
{{ getDictValue(execStatusKey, record.recentLogStatus) }}
|
||||
</a-tag>
|
||||
<!-- 执行时间 -->
|
||||
{{ dateFormat(new Date(record.recentLogTime), 'MM-dd HH:mm') }}
|
||||
</div>
|
||||
<!-- 无任务 -->
|
||||
<div v-else class="mx8">-</div>
|
||||
</template>
|
||||
<!-- 操作 -->
|
||||
<template #handle="{ record }">
|
||||
<div class="table-handle-wrapper">
|
||||
<!-- 详情 -->
|
||||
<a-button type="text"
|
||||
size="mini"
|
||||
@click="emits('openDetail', record.id)">
|
||||
详情
|
||||
</a-button>
|
||||
<!-- 修改 -->
|
||||
<a-button v-permission="['asset:exec-job:update']"
|
||||
type="text"
|
||||
size="mini"
|
||||
@click="emits('openUpdate', record.id)">
|
||||
修改
|
||||
</a-button>
|
||||
<!-- 手动触发 -->
|
||||
<a-popconfirm content="确认要手动触发吗?"
|
||||
position="left"
|
||||
type="warning"
|
||||
@ok="triggerJob(record.id)">
|
||||
<a-button v-permission="['asset:exec-job:trigger']"
|
||||
type="text"
|
||||
size="mini">
|
||||
手动触发
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
<!-- 删除 -->
|
||||
<a-popconfirm content="确认删除这条记录吗?"
|
||||
position="left"
|
||||
type="warning"
|
||||
@ok="deleteRow(record)">
|
||||
<a-button v-permission="['asset:exec-job:delete']"
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger">
|
||||
删除
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'execJobTable'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecJobQueryRequest, ExecJobQueryResponse } from '@/api/exec/exec-job';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { deleteExecJob, getExecJobPage, triggerExecJob, updateExecJobStatus } from '@/api/exec/exec-job';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import usePermission from '@/hooks/permission';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { ExecJobStatus, execJobStatusKey, execStatusKey } from '../types/const';
|
||||
import { usePagination } from '@/types/table';
|
||||
import { useDictStore } from '@/store';
|
||||
import { copy } from '@/hooks/copy';
|
||||
import { dateFormat } from '@/utils';
|
||||
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openDetail', 'testCron']);
|
||||
|
||||
const pagination = usePagination();
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { hasPermission } = usePermission();
|
||||
const { toOptions, getDictValue } = useDictStore();
|
||||
|
||||
const tableRenderData = ref<ExecJobQueryResponse[]>([]);
|
||||
const formModel = reactive<ExecJobQueryRequest>({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
command: undefined,
|
||||
status: undefined,
|
||||
queryRecentLog: true
|
||||
});
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
}) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteExecJob(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 添加后回调
|
||||
const addedCallback = () => {
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
// 更新后回调
|
||||
const updatedCallback = () => {
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
addedCallback, updatedCallback
|
||||
});
|
||||
|
||||
// 修改状态
|
||||
const updateStatus = async (id: number, status: number) => {
|
||||
return updateExecJobStatus({
|
||||
id,
|
||||
status
|
||||
}).then(() => {
|
||||
return true;
|
||||
}).catch(() => {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
// 手动触发任务
|
||||
const triggerJob = async (id: number) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await triggerExecJob(id);
|
||||
Message.success('已触发');
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: ExecJobQueryRequest) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const { data } = await getExecJobPage(request);
|
||||
tableRenderData.value = data.rows;
|
||||
pagination.total = data.total;
|
||||
pagination.current = request.page;
|
||||
pagination.pageSize = request.limit;
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 切换页码
|
||||
const fetchTableData = (page = 1, limit = pagination.pageSize, form = formModel) => {
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchTableData();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
73
orion-ops-ui/src/views/exec/exec-job/index.vue
Normal file
73
orion-ops-ui/src/views/exec/exec-job/index.vue
Normal file
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<div class="layout-container" v-if="render">
|
||||
<!-- 列表-表格 -->
|
||||
<exec-job-table ref="table"
|
||||
@open-add="() => drawer.openAdd()"
|
||||
@open-update="(e) => drawer.openUpdate(e)"
|
||||
@open-detail="(e) => detail.open(e)"
|
||||
@test-cron="openNextCron" />
|
||||
<!-- 添加修改模态框 -->
|
||||
<exec-job-form-drawer ref="drawer"
|
||||
@added="modalAddCallback"
|
||||
@updated="modalUpdateCallback"
|
||||
@open-host="(e) => hostModal.open(e)"
|
||||
@test-cron="openNextCron" />
|
||||
<!-- 详情模态框 -->
|
||||
<exec-job-detail-drawer ref="detail" />
|
||||
<!-- cron 执行时间模态框 -->
|
||||
<next-cron-modal ref="nextCron" />
|
||||
<!-- 主机模态框 -->
|
||||
<authorized-host-modal ref="hostModal"
|
||||
@selected="(e) => drawer.setSelectedHost(e)" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'execJob'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { CronNextTimes, dictKeys } from './types/const';
|
||||
import ExecJobTable from './components/exec-job-table.vue';
|
||||
import ExecJobFormDrawer from './components/exec-job-form-drawer.vue';
|
||||
import ExecJobDetailDrawer from './components/exec-job-detail-drawer.vue';
|
||||
import AuthorizedHostModal from '@/components/asset/host/authorized-host-modal/index.vue';
|
||||
import NextCronModal from '@/components/meta/expression/next-cron-modal/index.vue';
|
||||
|
||||
const render = ref(false);
|
||||
const table = ref();
|
||||
const drawer = ref();
|
||||
const detail = ref();
|
||||
const nextCron = ref();
|
||||
const hostModal = ref();
|
||||
|
||||
// 添加回调
|
||||
const modalAddCallback = () => {
|
||||
table.value.addedCallback();
|
||||
};
|
||||
|
||||
// 修改回调
|
||||
const modalUpdateCallback = () => {
|
||||
table.value.updatedCallback();
|
||||
};
|
||||
|
||||
// 打开下次执行时间
|
||||
const openNextCron = (cron: string) => {
|
||||
nextCron.value.open({ expression: cron, times: CronNextTimes });
|
||||
};
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const dictStore = useDictStore();
|
||||
await dictStore.loadKeys(dictKeys);
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
</style>
|
||||
32
orion-ops-ui/src/views/exec/exec-job/types/const.ts
Normal file
32
orion-ops-ui/src/views/exec/exec-job/types/const.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { TemplateParam } from '@/components/view/exec-editor/const';
|
||||
|
||||
// cron 下次执行次数
|
||||
export const CronNextTimes = 5;
|
||||
|
||||
// 计划执行状态
|
||||
export const ExecJobStatus = {
|
||||
// 禁用
|
||||
DISABLED: 0,
|
||||
// 启用
|
||||
ENABLED: 1,
|
||||
};
|
||||
|
||||
// 任务内置参数
|
||||
export const jobBuiltinsParams: Array<TemplateParam> = [
|
||||
{
|
||||
name: 'sourceId',
|
||||
desc: '计划任务id'
|
||||
}, {
|
||||
name: 'seq',
|
||||
desc: '执行序列'
|
||||
},
|
||||
];
|
||||
|
||||
// 计划执行状态 字典项
|
||||
export const execJobStatusKey = 'execJobStatus';
|
||||
|
||||
// 执行状态 字典项
|
||||
export const execStatusKey = 'execStatus';
|
||||
|
||||
// 加载的字典值
|
||||
export const dictKeys = [execJobStatusKey, execStatusKey];
|
||||
40
orion-ops-ui/src/views/exec/exec-job/types/form.rules.ts
Normal file
40
orion-ops-ui/src/views/exec/exec-job/types/form.rules.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { FieldRule } from '@arco-design/web-vue';
|
||||
|
||||
export const name = [{
|
||||
required: true,
|
||||
message: '请输入任务名称'
|
||||
}, {
|
||||
maxLength: 64,
|
||||
message: '任务名称长度不能大于64位'
|
||||
}] as FieldRule[];
|
||||
|
||||
export const hostIdList = [{
|
||||
required: true,
|
||||
message: '请选择执行主机'
|
||||
}] as FieldRule[];
|
||||
|
||||
export const expression = [{
|
||||
required: true,
|
||||
message: '请输入 cron 表达式'
|
||||
}, {
|
||||
maxLength: 512,
|
||||
message: 'cron 表达式长度不能大于512位'
|
||||
}] as FieldRule[];
|
||||
|
||||
export const timeout = [{
|
||||
required: true,
|
||||
message: '请输入超时时间'
|
||||
}] as FieldRule[];
|
||||
|
||||
export const command = [{
|
||||
required: true,
|
||||
message: '请输入执行命令'
|
||||
}] as FieldRule[];
|
||||
|
||||
export default {
|
||||
name,
|
||||
hostIdList,
|
||||
expression,
|
||||
timeout,
|
||||
command,
|
||||
} as Record<string, FieldRule | FieldRule[]>;
|
||||
64
orion-ops-ui/src/views/exec/exec-job/types/table.columns.ts
Normal file
64
orion-ops-ui/src/views/exec/exec-job/types/table.columns.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
|
||||
import { dateFormat } from '@/utils';
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: 'id',
|
||||
dataIndex: 'id',
|
||||
slotName: 'id',
|
||||
width: 70,
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
}, {
|
||||
title: '任务名称',
|
||||
dataIndex: 'name',
|
||||
slotName: 'name',
|
||||
align: 'left',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
}, {
|
||||
title: 'cron',
|
||||
dataIndex: 'expression',
|
||||
slotName: 'expression',
|
||||
align: 'left',
|
||||
width: 168,
|
||||
ellipsis: true,
|
||||
tooltip: true,
|
||||
}, {
|
||||
title: '执行命令',
|
||||
dataIndex: 'command',
|
||||
slotName: 'command',
|
||||
align: 'left',
|
||||
ellipsis: true,
|
||||
tooltip: true,
|
||||
}, {
|
||||
title: '任务状态',
|
||||
dataIndex: 'status',
|
||||
slotName: 'status',
|
||||
align: 'center',
|
||||
width: 112,
|
||||
}, {
|
||||
title: '最近任务状态',
|
||||
dataIndex: 'recentLogStatus',
|
||||
slotName: 'recentLogStatus',
|
||||
align: 'left',
|
||||
width: 184,
|
||||
}, {
|
||||
title: '修改时间',
|
||||
dataIndex: 'updateTime',
|
||||
slotName: 'updateTime',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
render: ({ record }) => {
|
||||
return dateFormat(new Date(record.updateTime));
|
||||
},
|
||||
}, {
|
||||
title: '操作',
|
||||
slotName: 'handle',
|
||||
width: 228,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
},
|
||||
] as TableColumnData[];
|
||||
|
||||
export default columns;
|
||||
@@ -47,6 +47,7 @@
|
||||
<!-- 执行命令 -->
|
||||
<a-form-item field="command"
|
||||
label="执行命令"
|
||||
:hide-label="true"
|
||||
:wrapper-col-props="{ span: 24 }"
|
||||
:help="'使用 @{{ xxx }} 来替换参数, 输入_可以获取全部变量'">
|
||||
<exec-editor v-model="formModel.command"
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<!-- 模板命令 -->
|
||||
<a-form-item field="command"
|
||||
label="模板命令"
|
||||
:hide-label="true"
|
||||
:wrapper-col-props="{ span: 24 }"
|
||||
:help="'使用 @{{ xxx }} 来替换参数, 输入_可以获取全部变量'">
|
||||
<exec-editor v-model="formModel.command"
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
<exec-template-form-drawer ref="drawer"
|
||||
@added="modalAddCallback"
|
||||
@updated="modalUpdateCallback" />
|
||||
<!-- 主机模态框 -->
|
||||
<authorized-host-modal ref="hostModal"
|
||||
@selected="(e) => execModal.setSelectedHost(e)" />
|
||||
<!-- 执行模态框 -->
|
||||
<exec-template-exec-drawer ref="execModal"
|
||||
@open-host="(e) => hostModal.open(e)" />
|
||||
<!-- 主机模态框 -->
|
||||
<authorized-host-modal ref="hostModal"
|
||||
@selected="(e) => execModal.setSelectedHost(e)" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const columns = [
|
||||
title: '操作模块',
|
||||
dataIndex: 'module',
|
||||
slotName: 'module',
|
||||
width: 214,
|
||||
width: 234,
|
||||
}, {
|
||||
title: '风险等级',
|
||||
dataIndex: 'riskLevel',
|
||||
|
||||
Reference in New Issue
Block a user