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, public Map<String, Object> doQuery(User loginUser, int pageNo, int pageSize,
int groupId) { int groupId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
Page<TaskGroupQueue> page = new Page<>(pageNo, pageSize); Page<TaskGroupQueue> page = new Page<>(pageNo, pageSize);
IPage<TaskGroupQueue> taskGroupQueue = taskGroupQueueMapper.queryTaskGroupQueuePaging(page, groupId); 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 @Override
public Map<String, Object> createTaskGroup(User loginUser, Long projectCode, String name, String description, int groupSize) { public Map<String, Object> createTaskGroup(User loginUser, Long projectCode, String name, String description, int groupSize) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
if (name == null) { if (name == null) {
putMsg(result, Status.NAME_NULL); putMsg(result, Status.NAME_NULL);
return result; return result;
@ -116,9 +113,6 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override @Override
public Map<String, Object> updateTaskGroup(User loginUser, int id, String name, String description, int groupSize) { public Map<String, Object> updateTaskGroup(User loginUser, int id, String name, String description, int groupSize) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
if (name == null) { if (name == null) {
putMsg(result, Status.NAME_NULL); putMsg(result, Status.NAME_NULL);
return result; return result;
@ -127,7 +121,11 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
putMsg(result, Status.TASK_GROUP_SIZE_ERROR); putMsg(result, Status.TASK_GROUP_SIZE_ERROR);
return result; 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) { if (exists > 0) {
putMsg(result, Status.TASK_GROUP_NAME_EXSIT); putMsg(result, Status.TASK_GROUP_NAME_EXSIT);
return result; return result;
@ -262,9 +260,6 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override @Override
public Map<String, Object> closeTaskGroup(User loginUser, int id) { public Map<String, Object> closeTaskGroup(User loginUser, int id) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
TaskGroup taskGroup = taskGroupMapper.selectById(id); TaskGroup taskGroup = taskGroupMapper.selectById(id);
if (taskGroup.getStatus() == Flag.NO.getCode()) { if (taskGroup.getStatus() == Flag.NO.getCode()) {
putMsg(result, Status.TASK_GROUP_STATUS_CLOSED); putMsg(result, Status.TASK_GROUP_STATUS_CLOSED);
@ -286,9 +281,7 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override @Override
public Map<String, Object> startTaskGroup(User loginUser, int id) { public Map<String, Object> startTaskGroup(User loginUser, int id) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
TaskGroup taskGroup = taskGroupMapper.selectById(id); TaskGroup taskGroup = taskGroupMapper.selectById(id);
if (taskGroup.getStatus() == Flag.YES.getCode()) { if (taskGroup.getStatus() == Flag.YES.getCode()) {
putMsg(result, Status.TASK_GROUP_STATUS_OPENED); putMsg(result, Status.TASK_GROUP_STATUS_OPENED);
@ -311,9 +304,7 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override @Override
public Map<String, Object> forceStartTask(User loginUser, int queueId) { public Map<String, Object> forceStartTask(User loginUser, int queueId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
taskGroupQueueService.forceStartTask(queueId, Flag.YES.getCode()); taskGroupQueueService.forceStartTask(queueId, Flag.YES.getCode());
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
@ -322,9 +313,7 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
@Override @Override
public Map<String, Object> modifyPriority(User loginUser, Integer queueId, Integer priority) { public Map<String, Object> modifyPriority(User loginUser, Integer queueId, Integer priority) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
return result;
}
taskGroupQueueService.modifyPriority(queueId, priority); taskGroupQueueService.modifyPriority(queueId, priority);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;

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

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

Loading…
Cancel
Save