Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 3.9.x #3251

Merged
merged 13 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ public CronJobInfoDTO createCronJobInfo(String username, CronJobInfoDTO cronJobI
checkCronJobPlanOrScript(cronJobInfo);
saveSnapShotForHostVaiableValue(cronJobInfo);

// 有执行方案运行权限,才能用该执行方案创建定时任务
authExecuteTask(cronJobInfo);
cronJobInfo.setCreateTime(DateUtils.currentTimeSeconds());
cronJobInfo.setEnable(false);

Expand Down Expand Up @@ -253,23 +255,11 @@ public CronJobInfoDTO updateCronJobInfo(String username, CronJobInfoDTO cronJobI
processCronJobVariableValueMask(cronJobInfo);

if (cronJobInfo.getEnable()) {
try {
List<ServiceTaskVariable> taskVariables = null;
if (CollectionUtils.isNotEmpty(cronJobInfo.getVariableValue())) {
taskVariables =
cronJobInfo.getVariableValue().parallelStream()
.map(CronJobVariableDTO::toServiceTaskVariable).collect(Collectors.toList());
}
executeTaskService.authExecuteTask(cronJobInfo.getAppId(), cronJobInfo.getTaskPlanId(),
cronJobInfo.getId(), cronJobInfo.getName(), taskVariables, cronJobInfo.getLastModifyUser());
if (cronJobDAO.updateCronJobById(cronJobInfo)) {
informAllToAddJobToQuartz(cronJobInfo.getAppId(), cronJobInfo.getId());
} else {
throw new InternalException(ErrorCode.UPDATE_CRON_JOB_FAILED);
}
} catch (TaskExecuteAuthFailedException e) {
log.error("Error while pre auth cron execute!", e);
throw e;
authExecuteTask(cronJobInfo);
if (cronJobDAO.updateCronJobById(cronJobInfo)) {
informAllToAddJobToQuartz(cronJobInfo.getAppId(), cronJobInfo.getId());
} else {
throw new InternalException(ErrorCode.UPDATE_CRON_JOB_FAILED);
}
} else {
if (cronJobDAO.updateCronJobById(cronJobInfo)) {
Expand All @@ -289,6 +279,22 @@ public CronJobInfoDTO updateCronJobInfo(String username, CronJobInfoDTO cronJobI
return updateCron;
}

private void authExecuteTask(CronJobInfoDTO cronJobInfo){
try {
List<ServiceTaskVariable> taskVariables = null;
if (CollectionUtils.isNotEmpty(cronJobInfo.getVariableValue())) {
taskVariables =
cronJobInfo.getVariableValue().parallelStream()
.map(CronJobVariableDTO::toServiceTaskVariable).collect(Collectors.toList());
}
executeTaskService.authExecuteTask(cronJobInfo.getAppId(), cronJobInfo.getTaskPlanId(),
cronJobInfo.getId(), cronJobInfo.getName(), taskVariables, cronJobInfo.getLastModifyUser());
} catch (TaskExecuteAuthFailedException e) {
log.error("Error while pre auth cron execute!", e);
throw e;
}
}

/**
* 保存定时任务主机变量中的IP等快照信息
*
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/jb-ai/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
transition: all .1s ease-in-out;

&.active{
transform: translateX(29px);
transform: translateX(39px);
}

&:hover{
Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/components/site-frame/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
const resizeHandler = _.throttle(this.init, 100);
window.addEventListener('resize', resizeHandler);


this.$once('hook:beforeDestroy', () => {
window.removeEventListener('resize', resizeHandler);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,14 @@
},
mounted() {
this.initEditor();
const handleHideAiExtendTool = () => {
this.aiExtendToolStyle = {};
};
document.body.addEventListener('mousedown', handleHideAiExtendTool);
this.$once('hook:beforeDestroy', () => {
document.body.removeEventListener('mousedown', handleHideAiExtendTool);
});
this.initAiHelper();
},
methods: {
/**
* @desc 获取脚本日志
*/
fetchLogContent() {
console.log('taskExecuteDetail = ', this.taskExecuteDetail);
if (!this.taskExecuteDetail.executeObject) {
this.isLoading = false;
if (this.editor) {
Expand All @@ -234,9 +229,6 @@
this.$nextTick(() => {
this.editor.setValue(logContent);
this.editor.clearSelection();
setTimeout(() => {
document.body.querySelector('.ace_layer.ace_text-layer').appendChild(this.$refs.aiExtendTool);
}, 1000);
});
// 当前主机执行结束
if (!finished) {
Expand All @@ -250,7 +242,7 @@
fetchAiConfig() {
AiService.fetchConfig()
.then((data) => {
this.isAiEnable = data.enable;
this.isAiEnable = data.enabled;
});
},
initEditor() {
Expand Down Expand Up @@ -280,13 +272,23 @@
} = editor.renderer.layerConfig;
this.isWillAutoScroll = height + scrollTop + 30 >= maxHeight;
});
this.editor = editor;

this.editor = editor;
this.$once('hook:beforeDestroy', () => {
editor.destroy();
editor.container.remove();
});
},
initAiHelper() {
const handleHideAiExtendTool = () => {
this.aiExtendToolStyle = {};
};

document.body.addEventListener('mousedown', handleHideAiExtendTool);
this.$once('hook:beforeDestroy', () => {
document.body.removeEventListener('mousedown', handleHideAiExtendTool);
});
},
/**
* @desc 外部调用
*/
Expand Down Expand Up @@ -320,6 +322,7 @@
autoScrollTimeout() {
if (this.isWillAutoScroll && !this.isLoading) {
this.handleScrollBottom();
return;
}
setTimeout(() => {
this.autoScrollTimer = this.autoScrollTimeout();
Expand Down Expand Up @@ -347,17 +350,15 @@
this.aiExtendToolStyle = {};
return;
}
const containerEle = document.body.querySelector('.ace_layer.ace_text-layer');
const {
left: contentBoxLeft,
top: contentBoxTop,
} = getOffset(containerEle);
} = getOffset(this.$refs.contentBox);

const [transformY] = containerEle.style.transform.match(/([\d]+)[^\d]+$/);
const { pageX, pageY } = event;
this.aiExtendToolStyle = {
display: 'flex',
top: `${Math.max(pageY - 40 - contentBoxTop + parseInt(transformY, 10), 8)}px`,
top: `${Math.max(pageY - 40 - contentBoxTop, 8)}px`,
left: `${Math.max(pageX + 4 - contentBoxLeft, 8)}px`,
};
});
Expand Down Expand Up @@ -515,7 +516,7 @@
}

.ai-extend-tool{
position: fixed;
position: absolute;
z-index: 1000;
display: none;
width: 32px;
Expand Down
Loading