🔨 是否使用脚本执行.
This commit is contained in:
@@ -6,6 +6,7 @@ Authorization: {{token}}
|
||||
{
|
||||
"description": 1,
|
||||
"timeout": 10,
|
||||
"scriptExec": 0,
|
||||
"command": "echo 这是日志@{{ hostAddress }}\nsleep 1\necho @{{ hostName }}",
|
||||
"parameterSchema": "[]",
|
||||
"hostIdList": [1]
|
||||
|
||||
@@ -6,7 +6,8 @@ Authorization: {{token}}
|
||||
{
|
||||
"name": "测试 1",
|
||||
"expression": "0 */3 * * * ?",
|
||||
"timeout": "0",
|
||||
"timeout": 0,
|
||||
"scriptExec": 0,
|
||||
"command": "echo 123",
|
||||
"parameterSchema": "[]",
|
||||
"hostIdList": [1]
|
||||
@@ -22,7 +23,8 @@ Authorization: {{token}}
|
||||
"id": 5,
|
||||
"name": "测试 1",
|
||||
"expression": "0 */10 * * * ?",
|
||||
"timeout": "0",
|
||||
"timeout": 0,
|
||||
"scriptExec": 0,
|
||||
"command": "echo 123",
|
||||
"parameterSchema": "[]",
|
||||
"hostIdList": [
|
||||
|
||||
@@ -6,7 +6,8 @@ Authorization: {{token}}
|
||||
{
|
||||
"name": "",
|
||||
"command": "",
|
||||
"timeout": "",
|
||||
"timeout": 0,
|
||||
"scriptExec": 0,
|
||||
"parameterSchema": ""
|
||||
}
|
||||
|
||||
@@ -20,7 +21,8 @@ Authorization: {{token}}
|
||||
"id": "",
|
||||
"name": "",
|
||||
"command": "",
|
||||
"timeout": "",
|
||||
"timeout": 0,
|
||||
"scriptExec": 0,
|
||||
"parameterSchema": ""
|
||||
}
|
||||
|
||||
@@ -47,7 +49,8 @@ Authorization: {{token}}
|
||||
"id": "",
|
||||
"name": "",
|
||||
"command": "",
|
||||
"timeout": "",
|
||||
"timeout": 0,
|
||||
"scriptExec": 0,
|
||||
"parameterSchema": ""
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,10 @@ public class ExecHostLogDO extends BaseDO {
|
||||
@TableField("log_path")
|
||||
private String logPath;
|
||||
|
||||
@Schema(description = "脚本路径")
|
||||
@TableField("script_path")
|
||||
private String scriptPath;
|
||||
|
||||
@Schema(description = "错误信息")
|
||||
@TableField("error_message")
|
||||
private String errorMessage;
|
||||
|
||||
@@ -46,6 +46,10 @@ public class ExecJobDO extends BaseDO {
|
||||
@TableField("timeout")
|
||||
private Integer timeout;
|
||||
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
@TableField("script_exec")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "执行命令")
|
||||
@TableField("command")
|
||||
private String command;
|
||||
|
||||
@@ -68,6 +68,10 @@ public class ExecLogDO extends BaseDO {
|
||||
@TableField("timeout")
|
||||
private Integer timeout;
|
||||
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
@TableField("script_exec")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "执行状态")
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
@@ -42,6 +42,10 @@ public class ExecTemplateDO extends BaseDO {
|
||||
@TableField("timeout")
|
||||
private Integer timeout;
|
||||
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
@TableField("script_exec")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "参数定义")
|
||||
@TableField("parameter_schema")
|
||||
private String parameterSchema;
|
||||
|
||||
@@ -43,6 +43,9 @@ public class ExecCommandExecRequest {
|
||||
@Schema(description = "超时时间")
|
||||
private Integer timeout;
|
||||
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ public class ExecCommandRequest {
|
||||
@Schema(description = "超时时间")
|
||||
private Integer timeout;
|
||||
|
||||
@NonNull
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.orion.ops.module.asset.entity.request.exec;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@@ -43,6 +40,10 @@ public class ExecJobCreateRequest implements Serializable {
|
||||
@Schema(description = "超时时间")
|
||||
private Integer timeout;
|
||||
|
||||
@NonNull
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.orion.ops.module.asset.entity.request.exec;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@@ -47,6 +44,10 @@ public class ExecJobUpdateRequest implements Serializable {
|
||||
@Schema(description = "超时时间")
|
||||
private Integer timeout;
|
||||
|
||||
@NonNull
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
@@ -40,6 +40,10 @@ public class ExecTemplateCreateRequest implements Serializable {
|
||||
@Schema(description = "超时时间秒 0不超时")
|
||||
private Integer timeout;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "参数定义")
|
||||
private String parameterSchema;
|
||||
|
||||
|
||||
@@ -44,6 +44,10 @@ public class ExecTemplateUpdateRequest implements Serializable {
|
||||
@Schema(description = "超时时间秒 0不超时")
|
||||
private Integer timeout;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "参数定义")
|
||||
private String parameterSchema;
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@ public class ExecJobVO implements Serializable {
|
||||
@Schema(description = "超时时间")
|
||||
private Integer timeout;
|
||||
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ public class ExecLogVO implements Serializable {
|
||||
@Schema(description = "超时时间")
|
||||
private Integer timeout;
|
||||
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "执行状态")
|
||||
private String status;
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@ public class ExecTemplateVO implements Serializable {
|
||||
@Schema(description = "超时时间秒 0不超时")
|
||||
private Integer timeout;
|
||||
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "参数定义")
|
||||
private String parameterSchema;
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ public class ExecCommandDTO {
|
||||
@Schema(description = "超时时间")
|
||||
private Integer timeout;
|
||||
|
||||
@Schema(description = "是否使用脚本执行")
|
||||
private Integer scriptExec;
|
||||
|
||||
@Schema(description = "主机")
|
||||
private List<ExecCommandHostDTO> hosts;
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ public class ExecCommandHostDTO {
|
||||
@Schema(description = "日志文件路径")
|
||||
private String logPath;
|
||||
|
||||
@Schema(description = "脚本路径")
|
||||
private String scriptPath;
|
||||
|
||||
@Schema(description = "执行命令")
|
||||
private String command;
|
||||
|
||||
|
||||
@@ -82,13 +82,14 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
@Resource
|
||||
private AssetAuthorizedDataService assetAuthorizedDataService;
|
||||
|
||||
// TODO 新增 修改 时候先检查 scriptExec, 然后测试一下
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ExecLogVO execCommand(ExecCommandRequest request) {
|
||||
log.info("ExecService.startExecCommand start params: {}", JSON.toJSONString(request));
|
||||
LoginUser user = Objects.requireNonNull(SecurityUtils.getLoginUser());
|
||||
Long userId = user.getId();
|
||||
String command = request.getCommand();
|
||||
List<Long> hostIdList = request.getHostIdList();
|
||||
// 检查主机权限
|
||||
List<Long> authorizedHostIdList = assetAuthorizedDataService.getUserAuthorizedHostId(userId, HostConfigTypeEnum.SSH);
|
||||
@@ -126,6 +127,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
.command(command)
|
||||
.parameterSchema(request.getParameterSchema())
|
||||
.timeout(request.getTimeout())
|
||||
.scriptExec(request.getScriptExec())
|
||||
.status(ExecStatusEnum.WAITING.name())
|
||||
.build();
|
||||
execLogDAO.insert(execLog);
|
||||
@@ -145,6 +147,8 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
.command(FORMATTER.format(command, parameter))
|
||||
.parameter(parameter)
|
||||
.logPath(this.buildLogPath(execId, s.getId()))
|
||||
// FIXME 测试 添加用户名
|
||||
// .scriptPath()
|
||||
.build();
|
||||
}).collect(Collectors.toList());
|
||||
execHostLogDAO.insertBatch(execHostLogs);
|
||||
@@ -176,6 +180,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
ExecCommandRequest request = ExecCommandRequest.builder()
|
||||
.description(execLog.getDescription())
|
||||
.timeout(execLog.getTimeout())
|
||||
.scriptExec(execLog.getScriptExec())
|
||||
.command(execLog.getCommand())
|
||||
.parameterSchema(execLog.getParameterSchema())
|
||||
.hostIdList(hostIdList)
|
||||
@@ -193,6 +198,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
ExecCommandDTO exec = ExecCommandDTO.builder()
|
||||
.logId(execLog.getId())
|
||||
.timeout(execLog.getTimeout())
|
||||
.scriptExec(execLog.getScriptExec())
|
||||
.hosts(execHostLogs.stream()
|
||||
.map(s -> ExecCommandHostDTO.builder()
|
||||
.hostId(s.getHostId())
|
||||
@@ -200,6 +206,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
.command(s.getCommand())
|
||||
.timeout(execLog.getTimeout())
|
||||
.logPath(s.getLogPath())
|
||||
.scriptPath(s.getScriptPath())
|
||||
.build())
|
||||
.collect(Collectors.toList()))
|
||||
.build();
|
||||
@@ -231,6 +238,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
params.put("timestamp", date.getTime() / Dates.SECOND_STAMP);
|
||||
params.put("date", Dates.format(date, Dates.YMD));
|
||||
params.put("datetime", Dates.format(date, Dates.YMD_HMS));
|
||||
// TODO script Exec
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -250,6 +258,8 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
params.put("hostAddress", host.getAddress());
|
||||
params.put("hostUuid", uuid);
|
||||
params.put("hostUuidShort", uuid.replace("-", Strings.EMPTY));
|
||||
// TODO host username
|
||||
// TODO scriptPath
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
.execSeq(execSeq)
|
||||
.description(job.getName())
|
||||
.timeout(job.getTimeout())
|
||||
.scriptExec(job.getScriptExec())
|
||||
.command(job.getCommand())
|
||||
.parameterSchema(job.getParameterSchema())
|
||||
.hostIdList(hostIdList)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<result column="parameter" property="parameter"/>
|
||||
<result column="exit_status" property="exitStatus"/>
|
||||
<result column="log_path" property="logPath"/>
|
||||
<result column="script_path" property="scriptPath"/>
|
||||
<result column="error_message" property="errorMessage"/>
|
||||
<result column="start_time" property="startTime"/>
|
||||
<result column="finish_time" property="finishTime"/>
|
||||
@@ -26,7 +27,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, log_id, host_id, host_name, host_address, status, command, parameter, exit_status, log_path, error_message, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||
id, log_id, host_id, host_name, host_address, status, command, parameter, exit_status, log_path, script_path, error_message, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<result column="exec_seq" property="execSeq"/>
|
||||
<result column="expression" property="expression"/>
|
||||
<result column="timeout" property="timeout"/>
|
||||
<result column="script_exec" property="scriptExec"/>
|
||||
<result column="command" property="command"/>
|
||||
<result column="parameter_schema" property="parameterSchema"/>
|
||||
<result column="status" property="status"/>
|
||||
@@ -22,7 +23,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, name, exec_seq, expression, timeout, command, parameter_schema, status, recent_log_id, create_time, update_time, creator, updater, deleted
|
||||
id, name, exec_seq, expression, timeout, script_exec, command, parameter_schema, status, recent_log_id, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
<update id="incrExecSeq">
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<result column="command" property="command"/>
|
||||
<result column="parameter_schema" property="parameterSchema"/>
|
||||
<result column="timeout" property="timeout"/>
|
||||
<result column="script_exec" property="scriptExec"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="start_time" property="startTime"/>
|
||||
<result column="finish_time" property="finishTime"/>
|
||||
@@ -26,7 +27,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, username, source, source_id, description, exec_seq, command, parameter_schema, timeout, status, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||
id, user_id, username, source, source_id, description, exec_seq, command, parameter_schema, timeout, script_exec, status, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
<select id="getExecHistory" resultMap="BaseResultMap">
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<result column="name" property="name"/>
|
||||
<result column="command" property="command"/>
|
||||
<result column="timeout" property="timeout"/>
|
||||
<result column="script_exec" property="scriptExec"/>
|
||||
<result column="parameter_schema" property="parameterSchema"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, name, command, timeout, parameter_schema, create_time, update_time, creator, updater, deleted
|
||||
id, name, command, timeout, script_exec,parameter_schema, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface ExecCommandRequest {
|
||||
logId?: number;
|
||||
description?: string;
|
||||
timeout?: number;
|
||||
scriptExec?: number;
|
||||
command?: string;
|
||||
parameterSchema?: string;
|
||||
hostIdList?: Array<number>;
|
||||
|
||||
@@ -10,6 +10,7 @@ export interface ExecJobCreateRequest {
|
||||
name?: string;
|
||||
expression?: string;
|
||||
timeout?: number;
|
||||
scriptExec?: number;
|
||||
command?: string;
|
||||
parameterSchema?: string;
|
||||
hostIdList?: Array<number>;
|
||||
@@ -49,6 +50,7 @@ export interface ExecJobQueryResponse extends TableData {
|
||||
name: string;
|
||||
expression: string;
|
||||
timeout: number;
|
||||
scriptExec?: number;
|
||||
command: string;
|
||||
parameterSchema: string;
|
||||
status: number;
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface ExecLogQueryResponse extends TableData, ExecLogQueryExtraRespon
|
||||
command: string;
|
||||
parameterSchema: string;
|
||||
timeout: number;
|
||||
scriptExec?: number;
|
||||
status: string;
|
||||
startTime: number;
|
||||
finishTime: number;
|
||||
|
||||
@@ -9,6 +9,7 @@ export interface ExecTemplateCreateRequest {
|
||||
name?: string;
|
||||
command?: string;
|
||||
timeout?: number;
|
||||
scriptExec?: number;
|
||||
parameterSchema?: string;
|
||||
}
|
||||
|
||||
@@ -36,6 +37,7 @@ export interface ExecTemplateQueryResponse extends TableData {
|
||||
name: string;
|
||||
command: string;
|
||||
timeout: number;
|
||||
scriptExec?: number;
|
||||
parameterSchema: string;
|
||||
createTime: number;
|
||||
updateTime: number;
|
||||
|
||||
@@ -258,6 +258,13 @@ body {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.question-right {
|
||||
font-size: 18px;
|
||||
margin-left: 8px;
|
||||
color: rgb(var(--gray-6));
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.span-blue {
|
||||
color: rgb(var(--arcoblue-6));
|
||||
}
|
||||
|
||||
@@ -12,11 +12,10 @@
|
||||
ref="formRef"
|
||||
class="form-wrapper"
|
||||
label-align="right"
|
||||
:auto-label-width="true"
|
||||
:rules="formRules">
|
||||
<!-- 执行主机 -->
|
||||
<a-form-item field="hostIdList"
|
||||
label="执行主机"
|
||||
label-col-flex="72px">
|
||||
<a-form-item field="hostIdList" label="执行主机">
|
||||
<div class="selected-host">
|
||||
<!-- 已选择数量 -->
|
||||
<span class="usn" v-if="formModel.hostIdList?.length">
|
||||
@@ -28,17 +27,13 @@
|
||||
</div>
|
||||
</a-form-item>
|
||||
<!-- 执行描述 -->
|
||||
<a-form-item field="description"
|
||||
label="执行描述"
|
||||
label-col-flex="72px">
|
||||
<a-form-item field="description" label="执行描述">
|
||||
<a-input v-model="formModel.description"
|
||||
placeholder="请输入执行描述"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 超时时间 -->
|
||||
<a-form-item field="timeout"
|
||||
label="超时时间"
|
||||
label-col-flex="72px">
|
||||
<a-form-item field="timeout" label="超时时间">
|
||||
<a-input-number v-model="formModel.timeout"
|
||||
placeholder="为0则不超时"
|
||||
:min="0"
|
||||
@@ -49,6 +44,20 @@
|
||||
</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
<!-- 脚本执行 -->
|
||||
<a-form-item field="scriptExec" label="脚本执行">
|
||||
<div class="flex-center">
|
||||
<a-switch v-model="formModel.scriptExec"
|
||||
type="round"
|
||||
:checked-value="EnabledStatus.ENABLED"
|
||||
:unchecked-value="EnabledStatus.DISABLED" />
|
||||
<div class="question-right ml8">
|
||||
<a-tooltip content="启用后会将命令写入脚本文件 传输到主机后执行">
|
||||
<icon-question-circle />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</template>
|
||||
<!-- 参数表单 -->
|
||||
@@ -60,7 +69,6 @@
|
||||
:key="item.name"
|
||||
:field="item.name as string"
|
||||
:label="item.name"
|
||||
label-col-flex="72px"
|
||||
required>
|
||||
<a-input v-model="parameterFormModel[item.name as string]"
|
||||
:placeholder="item.desc"
|
||||
@@ -104,6 +112,7 @@
|
||||
import formRules from '../types/form.rules';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { batchExecCommand } from '@/api/exec/exec-command';
|
||||
import { EnabledStatus } from '@/types/const';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||
import AuthorizedHostModal from '@/components/asset/host/authorized-host-modal/index.vue';
|
||||
@@ -116,8 +125,12 @@
|
||||
|
||||
const defaultForm = (): ExecCommandRequest => {
|
||||
return {
|
||||
description: '',
|
||||
command: '',
|
||||
timeout: 0,
|
||||
scriptExec: EnabledStatus.DISABLED,
|
||||
parameterSchema: '[]',
|
||||
hostIdList: [],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -149,6 +162,7 @@
|
||||
command: record.command,
|
||||
description: record.name,
|
||||
timeout: record.timeout,
|
||||
scriptExec: record.scriptExec,
|
||||
};
|
||||
parameterSchema.value = record.parameterSchema ? JSON.parse(record.parameterSchema) : [];
|
||||
if (parameterSchema.value.length) {
|
||||
@@ -168,6 +182,7 @@
|
||||
command: record.command,
|
||||
description: record.description,
|
||||
timeout: record.timeout,
|
||||
scriptExec: record.scriptExec,
|
||||
hostIdList: record.hostIdList
|
||||
};
|
||||
parameterSchema.value = record.parameterSchema ? JSON.parse(record.parameterSchema) : [];
|
||||
|
||||
@@ -25,9 +25,15 @@ export const timeout = [{
|
||||
message: '超时时间需要在 0 - 100000 之间'
|
||||
}] as FieldRule[];
|
||||
|
||||
export const scriptExec = [{
|
||||
required: true,
|
||||
message: '请选择是否使用脚本执行'
|
||||
}] as FieldRule[];
|
||||
|
||||
export default {
|
||||
description,
|
||||
hostIdList,
|
||||
command,
|
||||
timeout,
|
||||
scriptExec,
|
||||
} as Record<string, FieldRule | FieldRule[]>;
|
||||
|
||||
@@ -42,6 +42,14 @@
|
||||
{{ getDictValue(execJobStatusKey, record.status) }}
|
||||
</a-tag>
|
||||
</a-descriptions-item>
|
||||
<!-- 脚本执行 -->
|
||||
<a-descriptions-item label="脚本执行">
|
||||
{{ record.scriptExec === EnabledStatus.ENABLED ? '是' : '否' }}
|
||||
</a-descriptions-item>
|
||||
<!-- 创建时间 -->
|
||||
<a-descriptions-item label="创建时间">
|
||||
{{ dateFormat(new Date(record.createTime)) }}
|
||||
</a-descriptions-item>
|
||||
<!-- 修改时间 -->
|
||||
<a-descriptions-item label="修改时间">
|
||||
{{ dateFormat(new Date(record.updateTime)) }}
|
||||
@@ -86,7 +94,8 @@
|
||||
import { dateFormat } from '@/utils';
|
||||
import { copy } from '@/hooks/copy';
|
||||
import { getExecJob } from '@/api/exec/exec-job';
|
||||
import { execJobStatusKey } from '@/views/exec/exec-job/types/const';
|
||||
import { EnabledStatus } from '@/types/const';
|
||||
import { execJobStatusKey } from '../types/const';
|
||||
|
||||
const { getDictValue, toOptions } = useDictStore();
|
||||
const { visible, setVisible } = useVisible();
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
<a-spin class="full spin-wrapper" :loading="loading">
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
label-align="left"
|
||||
label-align="right"
|
||||
:auto-label-width="true"
|
||||
:rules="formRules">
|
||||
<a-row :gutter="16">
|
||||
<!-- 任务名称 -->
|
||||
<a-col :span="14">
|
||||
<a-col :span="13">
|
||||
<a-form-item field="name" label="任务名称">
|
||||
<a-input v-model="formModel.name"
|
||||
placeholder="请输入任务名称"
|
||||
@@ -24,7 +24,7 @@
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 执行主机 -->
|
||||
<a-col :span="10">
|
||||
<a-col :span="11">
|
||||
<a-form-item field="hostIdList" label="执行主机">
|
||||
<div class="selected-host">
|
||||
<!-- 已选择数量 -->
|
||||
@@ -38,7 +38,7 @@
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- cron -->
|
||||
<a-col :span="14">
|
||||
<a-col :span="13">
|
||||
<a-form-item field="expression" label="cron">
|
||||
<a-input v-model="formModel.expression"
|
||||
placeholder="请输入 cron 表达式"
|
||||
@@ -54,7 +54,7 @@
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 超时时间 -->
|
||||
<a-col :span="10">
|
||||
<a-col :span="6">
|
||||
<a-form-item field="timeout" label="超时时间">
|
||||
<a-input-number v-model="formModel.timeout"
|
||||
placeholder="为0则不超时"
|
||||
@@ -67,6 +67,22 @@
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 脚本执行 -->
|
||||
<a-col :span="5">
|
||||
<a-form-item field="scriptExec" label="脚本执行">
|
||||
<div class="flex-center">
|
||||
<a-switch v-model="formModel.scriptExec"
|
||||
type="round"
|
||||
:checked-value="EnabledStatus.ENABLED"
|
||||
:unchecked-value="EnabledStatus.DISABLED" />
|
||||
<div class="question-right ml8">
|
||||
<a-tooltip position="tr" content="启用后会将命令写入脚本文件 传输到主机后执行">
|
||||
<icon-question-circle />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 执行命令 -->
|
||||
<a-col :span="24">
|
||||
<a-form-item class="command-item"
|
||||
@@ -111,6 +127,7 @@
|
||||
import { jobBuiltinsParams } from '../types/const';
|
||||
import { createExecJob, getExecJob, updateExecJob } from '@/api/exec/exec-job';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { EnabledStatus } from '@/types/const';
|
||||
import { useDictStore } from '@/store';
|
||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||
|
||||
@@ -131,6 +148,7 @@
|
||||
name: undefined,
|
||||
expression: undefined,
|
||||
timeout: 0,
|
||||
scriptExec: EnabledStatus.DISABLED,
|
||||
command: undefined,
|
||||
parameterSchema: '[]',
|
||||
hostIdList: []
|
||||
@@ -169,6 +187,7 @@
|
||||
name: record.name,
|
||||
expression: record.expression,
|
||||
timeout: record.timeout,
|
||||
scriptExec: record.scriptExec,
|
||||
command: record.command,
|
||||
parameterSchema: record.parameterSchema,
|
||||
hostIdList: record.hostIdList,
|
||||
|
||||
@@ -24,6 +24,16 @@ export const expression = [{
|
||||
export const timeout = [{
|
||||
required: true,
|
||||
message: '请输入超时时间'
|
||||
}, {
|
||||
type: 'number',
|
||||
min: 0,
|
||||
max: 100000,
|
||||
message: '超时时间需要在 0 - 100000 之间'
|
||||
}] as FieldRule[];
|
||||
|
||||
export const scriptExec = [{
|
||||
required: true,
|
||||
message: '请选择是否使用脚本执行'
|
||||
}] as FieldRule[];
|
||||
|
||||
export const command = [{
|
||||
@@ -36,5 +46,6 @@ export default {
|
||||
hostIdList,
|
||||
expression,
|
||||
timeout,
|
||||
scriptExec,
|
||||
command,
|
||||
} as Record<string, FieldRule | FieldRule[]>;
|
||||
|
||||
@@ -12,32 +12,18 @@
|
||||
<!-- 命令表单 -->
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
label-align="left"
|
||||
label-align="right"
|
||||
:auto-label-width="true"
|
||||
:rules="formRules">
|
||||
<a-row :gutter="16">
|
||||
<!-- 执行描述 -->
|
||||
<a-col :span="10">
|
||||
<a-col :span="16">
|
||||
<a-form-item field="description" label="执行描述">
|
||||
<a-input v-model="formModel.description"
|
||||
placeholder="请输入执行描述"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 执行主机 -->
|
||||
<a-col :span="7">
|
||||
<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>
|
||||
<!-- 超时时间 -->
|
||||
<a-col :span="7">
|
||||
<a-form-item field="timeout"
|
||||
@@ -53,6 +39,36 @@
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 执行主机 -->
|
||||
<a-col :span="16">
|
||||
<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>
|
||||
<!-- 脚本执行 -->
|
||||
<a-col :span="8">
|
||||
<a-form-item field="scriptExec" label="脚本执行">
|
||||
<div class="flex-center">
|
||||
<a-switch v-model="formModel.scriptExec"
|
||||
type="round"
|
||||
:checked-value="EnabledStatus.ENABLED"
|
||||
:unchecked-value="EnabledStatus.DISABLED" />
|
||||
<div class="question-right ml8">
|
||||
<a-tooltip position="tr" content="启用后会将命令写入脚本文件 传输到主机后执行">
|
||||
<icon-question-circle />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 执行命令 -->
|
||||
<a-col :span="24">
|
||||
<a-form-item field="command"
|
||||
@@ -113,6 +129,7 @@
|
||||
import useVisible from '@/hooks/visible';
|
||||
import formRules from '../../exec-command/types/form.rules';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { EnabledStatus } from '@/types/const';
|
||||
import { batchExecCommand } from '@/api/exec/exec-command';
|
||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||
|
||||
@@ -138,6 +155,7 @@
|
||||
formModel.value = {
|
||||
description: record.name,
|
||||
timeout: record.timeout,
|
||||
scriptExec: record.scriptExec,
|
||||
command: record.command,
|
||||
hostIdList: []
|
||||
};
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
<a-spin class="full modal-form" :loading="loading">
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
label-align="left"
|
||||
label-align="right"
|
||||
:auto-label-width="true"
|
||||
:rules="formRules">
|
||||
<a-row :gutter="16">
|
||||
<!-- 模板名称 -->
|
||||
<a-col :span="14">
|
||||
<a-col :span="12">
|
||||
<a-form-item field="name" label="模板名称">
|
||||
<a-input v-model="formModel.name"
|
||||
placeholder="请输入模板名称"
|
||||
@@ -24,7 +24,7 @@
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 超时时间 -->
|
||||
<a-col :span="10">
|
||||
<a-col :span="7">
|
||||
<a-form-item field="timeout" label="超时时间">
|
||||
<a-input-number v-model="formModel.timeout"
|
||||
placeholder="为0则不超时"
|
||||
@@ -37,6 +37,22 @@
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 脚本执行 -->
|
||||
<a-col :span="5">
|
||||
<a-form-item field="scriptExec" label="脚本执行">
|
||||
<div class="flex-center">
|
||||
<a-switch v-model="formModel.scriptExec"
|
||||
type="round"
|
||||
:checked-value="EnabledStatus.ENABLED"
|
||||
:unchecked-value="EnabledStatus.DISABLED" />
|
||||
<div class="question-right ml8">
|
||||
<a-tooltip position="tr" content="启用后会将命令写入脚本文件 传输到主机后执行">
|
||||
<icon-question-circle />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 模板命令 -->
|
||||
<a-col :span="24">
|
||||
<a-form-item field="command"
|
||||
@@ -115,6 +131,7 @@
|
||||
import formRules from '../types/form.rules';
|
||||
import { createExecTemplate, updateExecTemplate } from '@/api/exec/exec-template';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { EnabledStatus } from '@/types/const';
|
||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
@@ -129,6 +146,7 @@
|
||||
name: undefined,
|
||||
command: undefined,
|
||||
timeout: 0,
|
||||
scriptExec: EnabledStatus.DISABLED,
|
||||
parameterSchema: undefined,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -23,8 +23,14 @@ export const timeout = [{
|
||||
message: '超时时间需要在 0 - 100000 之间'
|
||||
}] as FieldRule[];
|
||||
|
||||
export const scriptExec = [{
|
||||
required: true,
|
||||
message: '请选择是否使用脚本执行'
|
||||
}] as FieldRule[];
|
||||
|
||||
export default {
|
||||
name,
|
||||
command,
|
||||
timeout,
|
||||
scriptExec,
|
||||
} as Record<string, FieldRule | FieldRule[]>;
|
||||
|
||||
Reference in New Issue
Block a user