Browse Source

[Improve][API] Allowed the non-root user to create the task group. (#9523)

* create a new branch from dev

* fix this issue

* merge from dev
3.0.0/version-upgrade
calvin 3 years ago committed by GitHub
parent
commit
adcc43fd7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupQueueServiceImpl.java
  2. 27
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java
  3. 156
      dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/detail.tsx

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupQueueServiceImpl.java

@ -115,9 +115,7 @@ public class TaskGroupQueueServiceImpl extends BaseServiceImpl implements TaskGr
public Map<String, Object> doQuery(User loginUser, int pageNo, int pageSize,
int groupId) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
Page<TaskGroupQueue> page = new Page<>(pageNo, pageSize);
IPage<TaskGroupQueue> taskGroupQueue = taskGroupQueueMapper.queryTaskGroupQueuePaging(page, groupId);

27
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java

@ -73,9 +73,6 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override
public Map<String, Object> createTaskGroup(User loginUser, Long projectCode, String name, String description, int groupSize) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
if (name == null) {
putMsg(result, Status.NAME_NULL);
return result;
@ -116,9 +113,6 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override
public Map<String, Object> updateTaskGroup(User loginUser, int id, String name, String description, int groupSize) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
if (name == null) {
putMsg(result, Status.NAME_NULL);
return result;
@ -127,7 +121,11 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
putMsg(result, Status.TASK_GROUP_SIZE_ERROR);
return result;
}
Integer exists = taskGroupMapper.selectCount(new QueryWrapper<TaskGroup>().lambda().eq(TaskGroup::getName, name).ne(TaskGroup::getId, id));
Integer exists = taskGroupMapper.selectCount(new QueryWrapper<TaskGroup>().lambda()
.eq(TaskGroup::getName, name)
.eq(TaskGroup::getUserId, loginUser.getId())
.ne(TaskGroup::getId, id));
if (exists > 0) {
putMsg(result, Status.TASK_GROUP_NAME_EXSIT);
return result;
@ -262,9 +260,6 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override
public Map<String, Object> closeTaskGroup(User loginUser, int id) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
TaskGroup taskGroup = taskGroupMapper.selectById(id);
if (taskGroup.getStatus() == Flag.NO.getCode()) {
putMsg(result, Status.TASK_GROUP_STATUS_CLOSED);
@ -286,9 +281,7 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override
public Map<String, Object> startTaskGroup(User loginUser, int id) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
TaskGroup taskGroup = taskGroupMapper.selectById(id);
if (taskGroup.getStatus() == Flag.YES.getCode()) {
putMsg(result, Status.TASK_GROUP_STATUS_OPENED);
@ -311,9 +304,7 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override
public Map<String, Object> forceStartTask(User loginUser, int queueId) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
taskGroupQueueService.forceStartTask(queueId, Flag.YES.getCode());
putMsg(result, Status.SUCCESS);
return result;
@ -322,9 +313,7 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override
public Map<String, Object> modifyPriority(User loginUser, Integer queueId, Integer priority) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
taskGroupQueueService.modifyPriority(queueId, priority);
putMsg(result, Status.SUCCESS);
return result;

156
dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/detail.tsx

@ -81,26 +81,26 @@ const DetailModal = defineComponent({
const onChangePlugin = changePlugin
watch(
() => props.show,
async () => {
props.show && props.currentRecord && setDetail(props.currentRecord)
}
() => props.show,
async () => {
props.show && props.currentRecord && setDetail(props.currentRecord)
}
)
watch(
() => state.json,
() => {
if (!state.json?.length) return
state.json.forEach((item) => {
const mergedItem = isFunction(item) ? item() : item
mergedItem.name = t(
'security.alarm_instance' + '.' + mergedItem.field
)
})
const { rules: fieldsRules, elements: fieldsElements } =
getElementByJson(state.json, state.detailForm)
rules.value = fieldsRules
elements.value = fieldsElements
}
() => state.json,
() => {
if (!state.json?.length) return
state.json.forEach((item) => {
const mergedItem = isFunction(item) ? item() : item
mergedItem.name = t(
'security.alarm_instance' + '.' + mergedItem.field
)
})
const { rules: fieldsRules, elements: fieldsElements } =
getElementByJson(state.json, state.detailForm)
rules.value = fieldsRules
elements.value = fieldsElements
}
)
onMounted(() => {
@ -137,66 +137,66 @@ const DetailModal = defineComponent({
} = this
const { currentRecord } = props
return (
<Modal
show={show}
title={t(
currentRecord?.id
? 'security.alarm_instance.edit_alarm_instance'
: 'security.alarm_instance.create_alarm_instance'
)}
onConfirm={onSubmit}
confirmLoading={saving || loading}
onCancel={onCancel}
>
{{
default: () => (
<Form
ref='detailFormRef'
loading={loading || pluginsLoading}
meta={{
...meta,
rules: {
...meta.rules,
...rules
},
elements: [
{
path: 'instanceName',
label: t('security.alarm_instance.alarm_instance_name'),
widget: (
<NInput
v-model={[detailForm.instanceName, 'value']}
placeholder={t(
'security.alarm_instance.alarm_instance_name_tips'
)}
/>
)
},
{
path: 'pluginDefineId',
label: t('security.alarm_instance.select_plugin'),
widget: (
<NSelect
v-model={[detailForm.pluginDefineId, 'value']}
options={uiPlugins}
disabled={!!currentRecord?.id}
placeholder={t(
'security.alarm_instance.select_plugin_tips'
)}
on-update:value={onChangePlugin}
/>
)
},
...elements
]
}}
layout={{
cols: 24
}}
/>
)
}}
</Modal>
<Modal
show={show}
title={t(
currentRecord?.id
? 'security.alarm_instance.edit_alarm_instance'
: 'security.alarm_instance.create_alarm_instance'
)}
onConfirm={onSubmit}
confirmLoading={saving || loading}
onCancel={onCancel}
>
{{
default: () => (
<Form
ref='detailFormRef'
loading={loading || pluginsLoading}
meta={{
...meta,
rules: {
...meta.rules,
...rules
},
elements: [
{
path: 'instanceName',
label: t('security.alarm_instance.alarm_instance_name'),
widget: (
<NInput
v-model={[detailForm.instanceName, 'value']}
placeholder={t(
'security.alarm_instance.alarm_instance_name_tips'
)}
/>
)
},
{
path: 'pluginDefineId',
label: t('security.alarm_instance.select_plugin'),
widget: (
<NSelect
v-model={[detailForm.pluginDefineId, 'value']}
options={uiPlugins}
disabled={!!currentRecord?.id}
placeholder={t(
'security.alarm_instance.select_plugin_tips'
)}
on-update:value={onChangePlugin}
/>
)
},
...elements
]
}}
layout={{
cols: 24
}}
/>
)
}}
</Modal>
)
}
})

Loading…
Cancel
Save