Skip to content

Commit

Permalink
Merge pull request #3422 from hLinx/feature_3.11
Browse files Browse the repository at this point in the history
Feature 3.11
  • Loading branch information
hLinx authored Feb 13, 2025
2 parents 41148e2 + dd9ac06 commit e31d925
Show file tree
Hide file tree
Showing 20 changed files with 149 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/frontend/language.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const recur = async (target) => {
const { message, namespace } = data.default;
const znData = {};
const enData = {};
console.log('data = ', data);
Object.keys(message).forEach((key) => {
if (typeof message[key] === 'string') {
znData[key] = key;
Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/components/ace-editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@
fetchAiConfig() {
AiService.fetchConfig()
.then((data) => {
console.log('data = ', data);
this.isAiEnable = data.enabled;
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@
formData: {
handler(formData) {
this.validatorExpr(formData[this.exprField]);
this.showTips();
setTimeout(() => {
this.showTips();
});
},
immediate: true,
deep: true,
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/components/task-step/script/item-factory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import ScriptParam from './strategy/script-param';
import ScriptSourceOfExecution from './strategy/script-source-of-execution';
import ScriptSourceOfTemplate from './strategy/script-source-of-template';
import WindowsInterpreter from './strategy/window-interpreter.vue';

export default {
name: 'ExecuteScriptItemFactory',
Expand All @@ -68,6 +69,7 @@
executeTargetOfTemplate: ExecuteTargetOfTemplate,
executeTargetOfExecution: ExecuteTargetOfExecution,
rolling: Rolling,
windowsInterpreter: WindowsInterpreter,
};
if (!Object.prototype.hasOwnProperty.call(comMap, this.name)) {
return 'div';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<bk-form-item
class="form-item-content"
error-display-type="normal"
:label="t('解释器')"
:property="field"
:required="isCustom"
:rules="rules">
<bk-checkbox
v-model="isCustom"
@change="handleCustomChange">
<span
v-bk-tooltips="t('使用目标机器指定路径下的解释器运行本脚本(仅对Windows有效)')"
class="tips">
{{ t('自定义windows解释器路径') }}
</span>
</bk-checkbox>
<div
v-if="isCustom"
style="margin-top: 8px">
<bk-input
class="form-item-content"
:placeholder="t('输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。')"
:value="formData[field]"
@change="handleChange" />
</div>
</bk-form-item>
</template>
<script setup>
import { ref, watch } from 'vue';
import { useI18n } from '@/i18n';
const props = defineProps({
field: {
type: String,
required: true,
},
formData: {
type: Object,
required: true,
},
});
const emits = defineEmits(['on-change']);
const { t } = useI18n();
const isCustom = ref(false);
const rules = [
{
validator: (value) => {
if (!isCustom.value) {
return true;
}
return /^[a-zA-Z]:\\(?:[^<>:"/\\|?*\r\n]+\\)*[^<>:"/\\|?*\r\n]*$/.test(value) && /\.exe$/.test(value);
},
message: t('解释器路径有误,需为合法的文件路径、且以 .exe 结尾。'),
trigger: 'blur',
},
];
watch(() => props.formData, () => {
if (props.formData[props.field] !== undefined) {
isCustom.value = true;
}
}, {
immediate: true,
});
const handleCustomChange = (custom) => {
emits('on-change', props.field, custom ? '' : undefined);
};
const handleChange = (value) => {
emits('on-change', props.field, value);
};
</script>

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default class TaskInstanceDetailStepScript {
this.account = payload.account;
this.status = payload.status;
this.rollingEnabled = Boolean(payload.rollingEnabled);
this.windowsInterpreter = payload.windowsInterpreter;

this.executeTarget = new ExecuteTargetModel(payload.executeTarget || {});
this.rollingConfig = this.initRollingConfig(payload.rollingConfig);
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/domain/model/task/task-script-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default class TaskScriptStep {
this.account = payload.account;
this.status = payload.status;
this.executeTarget = new ExecuteTargetModel(payload.executeTarget || {});
this.windowsInterpreter = payload.windowsInterpreter;
}

get isReferPublicScript() {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const setLocale = (locale) => {
export default i18n;

export const useI18n = () => ({
t: i18n._t, // eslint-disable-line no-underscore-dangle
t: key => i18n.t(key), // eslint-disable-line no-underscore-dangle
locale: i18n.locale,
});

Expand Down
7 changes: 6 additions & 1 deletion src/frontend/src/i18n/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -562,5 +562,10 @@
"注意!为了回答更准确,大模型可能将你提供的信息作为训练材料,如果内容带有敏感信息,请酌情使用!": "Attention! The AI model may use the information you provide as training material. If the content contains sensitive information, please use it cautiously!",
"小鲸": "AI-assistant",
"开源社区": "Open Source",
"脚本参数最大输入为 64KB": "The maximum script parameter size is 64KB"
"脚本参数最大输入为 64KB": "The maximum script parameter size is 64KB",
"解释器": "Interpreter",
"使用目标机器指定路径下的解释器运行本脚本(仅对Windows有效)": "Run this script using the interpreter in the specified path on the target hosts (Only for Windows)",
"自定义windows解释器路径": "Customize the Interpreter Path in Windows",
"输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。": "Enter the path of the custom interpreter software on the target machine, such as: D:\\Software\\python3\\python.exe",
"解释器路径有误,需为合法的文件路径、且以 .exe 结尾。": "Interpreter path is invalid; it must be a valid file path ending with .exe."
}
7 changes: 6 additions & 1 deletion src/frontend/src/i18n/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -562,5 +562,10 @@
"注意!为了回答更准确,大模型可能将你提供的信息作为训练材料,如果内容带有敏感信息,请酌情使用!": "注意!为了回答更准确,大模型可能将你提供的信息作为训练材料,如果内容带有敏感信息,请酌情使用!",
"小鲸": "小鲸",
"开源社区": "开源社区",
"脚本参数最大输入为 64KB": "脚本参数最大输入为 64KB"
"脚本参数最大输入为 64KB": "脚本参数最大输入为 64KB",
"解释器": "解释器",
"使用目标机器指定路径下的解释器运行本脚本(仅对Windows有效)": "使用目标机器指定路径下的解释器运行本脚本(仅对Windows有效)",
"自定义windows解释器路径": "自定义windows解释器路径",
"输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。": "输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。",
"解释器路径有误,需为合法的文件路径、且以 .exe 结尾。": "解释器路径有误,需为合法的文件路径、且以 .exe 结尾。"
}
3 changes: 2 additions & 1 deletion src/frontend/src/views/executive-history/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,6 @@
"日志文本过长,超出 AI 解析范围,请框选部分日志,再次出发点小鲸分析。": "The length of log text exceeds the scope of AI analysis, please manually select some key logs and resubmit.",
"报错日志看不懂?来提问小鲸吧~": "Find out with AI",
"管控区域_ID_IPv4": "BK-Net ID:IPv4",
"管控区域_ID_IPv6": "BK-Net ID:IPv6"
"管控区域_ID_IPv6": "BK-Net ID:IPv6",
"解释器:": "Interpreter:"
}
3 changes: 2 additions & 1 deletion src/frontend/src/views/executive-history/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,6 @@
"节点IP": "节点 IP",
"节点主机ID": "节点主机 ID",
"管控区域_ID_IPv4": "管控区域 ID:IPv4",
"管控区域_ID_IPv6": "管控区域 ID:IPv6"
"管控区域_ID_IPv6": "管控区域 ID:IPv6",
"解释器:": "解释器:"
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
readonly
:value="stepInfo.scriptParamText || '--'" />
</detail-item>
<detail-item
v-if="stepInfo.windowsInterpreter"
:label="$t('template.解释器:')">
{{ stepInfo.windowsInterpreter }}
</detail-item>
<detail-item :label="$t('template.超时时长:')">
{{ stepInfo.timeout }}(s)
</detail-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@
id: payload.stepInstanceId,
executeCount: payload.executeCount || 0,
};
this.currentGroup = {
resultType: '',
tag: '',
};
this.taskInstanceId = payload.taskInstanceId;
this.isTask = payload.isTask;
this.taskStepList = Object.freeze(payload.taskStepList);
Expand Down
11 changes: 11 additions & 0 deletions src/frontend/src/views/fast-execution/exec-script/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
param-field="scriptParam"
secure-field="secureParam"
@on-change="handleChange" />
<item-factory
field="windowsInterpreter"
:form-data="formData"
name="windowsInterpreter"
@on-change="handleChange" />
<item-factory
field="timeout"
:form-data="formData"
Expand Down Expand Up @@ -183,6 +188,8 @@
scriptParam: '',
// 敏感参数 0-关闭 1-开启
secureParam: 0,
// windows解释器 (undefined : 不采用自定义, other: 采用自定义)
windowsInterpreter: undefined,
// 超时
timeout: 300,
// 账号
Expand Down Expand Up @@ -259,6 +266,7 @@
scriptId,
scriptLanguage,
scriptParam,
windowsInterpreter,
scriptSource,
scriptVersionId,
secureParam,
Expand All @@ -275,6 +283,7 @@
scriptId,
scriptLanguage,
scriptParam,
windowsInterpreter,
scriptSource,
scriptVersionId,
secureParam,
Expand Down Expand Up @@ -413,6 +422,7 @@
scriptLanguage,
content,
scriptParam,
windowsInterpreter,
secureParam,
timeout,
account,
Expand All @@ -430,6 +440,7 @@
scriptLanguage,
content,
scriptParam,
windowsInterpreter,
secureParam,
timeout,
account,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
readonly
:value="stepInfo.scriptParamText || '--'" />
</detail-item>
<detail-item
v-if="stepInfo.windowsInterpreter"
:label="$t('template.解释器:')">
{{ stepInfo.windowsInterpreter }}
</detail-item>
<detail-item :label="$t('template.超时时长:')">
{{ stepInfo.timeout }}(s)
</detail-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
param-field="scriptParam"
secure-field="secureParam"
@on-change="handleChange" />
<item-factory
field="windowsInterpreter"
:form-data="formData"
name="windowsInterpreter"
@on-change="handleChange" />
<item-factory
field="timeout"
:form-data="formData"
Expand Down Expand Up @@ -120,6 +125,8 @@
content: '',
// 脚本参数
scriptParam: '',
// windows解释器 (undefined : 不采用自定义, other: 采用自定义)
windowsInterpreter: undefined,
// 超时时间
timeout: 300,
// 敏感参数 (0-关闭 1-开启)
Expand Down Expand Up @@ -197,6 +204,7 @@
id,
ignoreError,
scriptParam,
windowsInterpreter,
timeout,
secureParam,
scriptSource,
Expand All @@ -217,6 +225,7 @@
scriptStepInfo: {
ignoreError,
scriptParam,
windowsInterpreter,
timeout,
scriptSource,
scriptId,
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/views/task-manage/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,5 +473,6 @@
"作业导入任务出错,原因详见下列日志,请稍后再试。": "Import task encountered an error. please refer to the log details and try again later.",
"作业导入完成(部分失败),请根据日志提示调整后重新选择导入。": "Job import completed (some failed), please adjust according to the log prompt and re-select to import again.",
"填入上一次执行参数": "Load in previous execution parameters",
"复用当前登录用户的最近一次通过页面执行的入参": "Reuse the parameters of current user's last execution"
"复用当前登录用户的最近一次通过页面执行的入参": "Reuse the parameters of current user's last execution",
"解释器:": "Interpreter:"
}
3 changes: 2 additions & 1 deletion src/frontend/src/views/task-manage/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,5 +473,6 @@
"作业导入任务出错,原因详见下列日志,请稍后再试。": "作业导入任务出错,原因详见下列日志,请稍后再试。",
"作业导入完成(部分失败),请根据日志提示调整后重新选择导入。": "作业导入完成(部分失败),请根据日志提示调整后重新选择导入。",
"填入上一次执行参数": "填入上一次执行参数",
"复用当前登录用户的最近一次通过页面执行的入参": "复用当前登录用户的最近一次通过页面执行的入参"
"复用当前登录用户的最近一次通过页面执行的入参": "复用当前登录用户的最近一次通过页面执行的入参",
"解释器:": "解释器:"
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<span class="label">{{ $t('template.脚本参数:') }}</span>
<span class="value">{{ data.scriptParamText || '-' }}</span>
</div>
<div
class="row"
:class="diff.windowsInterpreter">
<span class="label">{{ $t('template.解释器:') }}</span>
<span class="value">{{ data.windowsInterpreter || '-' }}</span>
</div>
<div
class="row"
:class="diff.timeout">
Expand Down

0 comments on commit e31d925

Please sign in to comment.