fix i18n、ssh 脚本保持判断关联节点

This commit is contained in:
bwcx_jzy 2024-05-30 22:31:10 +08:00
parent 8cb60c756c
commit 4fbe9888cc
5 changed files with 31 additions and 6 deletions

View File

@ -9,6 +9,7 @@
*/
package org.dromara.jpom.controller.ssh;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.keepbx.jpom.IJsonMessage;
@ -23,6 +24,7 @@ import org.dromara.jpom.common.validator.ValidatorRule;
import org.dromara.jpom.model.PageResultDto;
import org.dromara.jpom.model.data.CommandExecLogModel;
import org.dromara.jpom.model.data.CommandModel;
import org.dromara.jpom.model.data.SshModel;
import org.dromara.jpom.model.user.UserModel;
import org.dromara.jpom.permission.ClassFeature;
import org.dromara.jpom.permission.Feature;
@ -31,6 +33,7 @@ import org.dromara.jpom.permission.SystemPermission;
import org.dromara.jpom.script.CommandParam;
import org.dromara.jpom.service.node.ssh.CommandExecLogService;
import org.dromara.jpom.service.node.ssh.SshCommandService;
import org.dromara.jpom.service.node.ssh.SshService;
import org.dromara.jpom.service.user.TriggerTokenLogServer;
import org.dromara.jpom.util.CommandUtil;
import org.springframework.http.MediaType;
@ -41,6 +44,7 @@ import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -57,13 +61,16 @@ public class CommandInfoController extends BaseServerController {
private final SshCommandService sshCommandService;
private final CommandExecLogService commandExecLogService;
private final TriggerTokenLogServer triggerTokenLogServer;
private final SshService sshService;
public CommandInfoController(SshCommandService sshCommandService,
CommandExecLogService commandExecLogService,
TriggerTokenLogServer triggerTokenLogServer) {
TriggerTokenLogServer triggerTokenLogServer,
SshService sshService) {
this.sshCommandService = sshCommandService;
this.commandExecLogService = commandExecLogService;
this.triggerTokenLogServer = triggerTokenLogServer;
this.sshService = sshService;
}
/**
@ -110,7 +117,13 @@ public class CommandInfoController extends BaseServerController {
commandModel.setName(name);
commandModel.setCommand(command);
commandModel.setDesc(desc);
commandModel.setSshIds(data.getString("sshIds"));
String sshIds = data.getString("sshIds");
List<String> sshIdList = StrUtil.split(sshIds, StrUtil.COMMA, true, true);
if (CollUtil.isNotEmpty(sshIdList)) {
List<SshModel> commandModels = sshService.getByKey(sshIdList, request);
Assert.state(CollUtil.size(sshIdList) == CollUtil.size(commandModels), "关联 SSH 节点包含不存在的节点");
}
commandModel.setSshIds(sshIds);
commandModel.setAutoExecCron(autoExecCron);
//
commandModel.setDefParams(CommandParam.checkStr(defParams));

View File

@ -89,6 +89,18 @@ public abstract class BaseWorkspaceService<T extends BaseWorkspaceModel> extends
return super.getByKey(keyValue, true, entity -> entity.set("workspaceId", workspace));
}
/**
* 根据主键ID + 请信息查询
*
* @param keyValue ID
* @param request 请求
* @return data
*/
public List<T> getByKey(Collection<String> keyValue, HttpServletRequest request) {
String workspace = this.getCheckUserWorkspace(request);
return super.getByKey(keyValue, true, entity -> entity.set("workspaceId", workspace));
}
/**
* 根据主键ID + 请信息查询
*

View File

@ -38,10 +38,10 @@ export default {
canReferenceWorkspaceEnv: "可以引用工作空间的环境变量 变量占位符 {'${xxxx}'} xxxx 为变量名称",
selectSshNode: '请选择SSH节点',
defaultParam: '默认参数',
paramDescription: '参数{index}描述`',
paramDescription: '参数{index}描述',
paramDescriptionNoEffect: '参数描述没有实际作用',
paramDescriptionHint: ',,仅是用于提示参数的含义',
paramValue: '参数{index}值`',
paramValue: '参数{index}值',
addNewDefaultParamNote: ',新增默认参数后在手动执行脚本时需要填写参数值',
autoExec: '自动执行',
cronExpression:

View File

@ -105,7 +105,7 @@
:mask-closable="false"
@ok="handleEditOk"
>
<a-form ref="editForm" :rules="rules" :model="temp" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
<a-form ref="editForm" :rules="rules" :model="temp" :label-col="{ span: 5 }" :wrapper-col="{ span: 18 }">
<a-form-item :label="$tl('p.clusterName')" name="name">
<a-input v-model:value="temp.name" :placeholder="$tl('p.containerName')" />
</a-form-item>

View File

@ -171,7 +171,7 @@
<a-input
v-model:value="item.desc"
:addon-before="$tl('p.paramDescription', { index: index + 1 })"
placeholder="参数描述,{{$tl('p.paramDescriptionNoEffect')}},仅是用于提示参数的含义"
:placeholder="`参数描述,${$tl('p.paramDescriptionNoEffect')},仅是用于提示参数的含义`"
/>
<a-input
v-model:value="item.value"