Browse Source

[Feature-14863][API] Support to manage what worker groups can be used for a project. (#15600)

3.2.2-prepare
calvin 10 months ago committed by GitHub
parent
commit
5213290262
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 104
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectWorkerGroupController.java
  2. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkerGroupController.java
  3. 9
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
  4. 48
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectWorkerGroupRelationService.java
  5. 233
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectWorkerGroupRelationServiceImpl.java
  6. 161
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectWorkerGroupRelationServiceTest.java
  7. 56
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectWorkerGroup.java
  8. 26
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectWorkerGroupMapper.java
  9. 15
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
  10. 17
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
  11. 19
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
  12. 11
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/mysql/dolphinscheduler_ddl.sql
  13. 14
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/postgresql/dolphinscheduler_ddl.sql
  14. 113
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectWorkerGroupMapperTest.java
  15. 3
      dolphinscheduler-ui/src/locales/en_US/project.ts
  16. 3
      dolphinscheduler-ui/src/locales/zh_CN/project.ts
  17. 39
      dolphinscheduler-ui/src/service/modules/projects-worker-group/index.ts
  18. 34
      dolphinscheduler-ui/src/service/modules/projects-worker-group/types.ts
  19. 77
      dolphinscheduler-ui/src/views/projects/list/components/use-worker-group.ts
  20. 91
      dolphinscheduler-ui/src/views/projects/list/components/worker-group-modal.tsx
  21. 18
      dolphinscheduler-ui/src/views/projects/list/index.tsx
  22. 44
      dolphinscheduler-ui/src/views/projects/list/use-table.ts
  23. 2
      dolphinscheduler-ui/src/views/projects/preference/use-form.ts
  24. 9
      dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-worker-group.ts
  25. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-chunjun.ts
  26. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-conditions.ts
  27. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-data-factory.ts
  28. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-data-quality.ts
  29. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-datasync.ts
  30. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-datax.ts
  31. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dependent.ts
  32. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dinky.ts
  33. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dms.ts
  34. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dvc.ts
  35. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dynamic.ts
  36. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-emr.ts
  37. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-flink-stream.ts
  38. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-flink.ts
  39. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-hive-cli.ts
  40. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-http.ts
  41. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-java.ts
  42. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-jupyter.ts
  43. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-k8s.ts
  44. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-kubeflow.ts
  45. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-linkis.ts
  46. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-mlflow.ts
  47. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-mr.ts
  48. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-openmldb.ts
  49. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-pigeon.ts
  50. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-procedure.ts
  51. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-python.ts
  52. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-pytorch.ts
  53. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-remote-shell.ts
  54. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sagemaker.ts
  55. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sea-tunnel.ts
  56. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-shell.ts
  57. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-spark.ts
  58. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sql.ts
  59. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sqoop.ts
  60. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sub-process.ts
  61. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-switch.ts
  62. 2
      dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-zeppelin.ts
  63. 9
      dolphinscheduler-ui/src/views/projects/workflow/definition/components/use-modal.ts

104
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectWorkerGroupController.java

@ -0,0 +1,104 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.controller;
import static org.apache.dolphinscheduler.api.enums.Status.ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR;
import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.ProjectWorkerGroupRelationService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
/**
* project and worker group controller
*/
@Tag(name = "PROJECT_WORKER_GROUP_TAG")
@RestController
@RequestMapping("projects/{projectCode}/worker-group")
@Slf4j
public class ProjectWorkerGroupController extends BaseController {
@Autowired
private ProjectWorkerGroupRelationService projectWorkerGroupRelationService;
/**
* assign worker groups to the project
*
* @param loginUser login user
* @param projectCode project code
@ @RequestParam(value = "workerGroups", required = false) String workerGroups
* @return create result code
*/
@Operation(summary = "assignWorkerGroups", description = "CREATE_PROCESS_DEFINITION_NOTES")
@Parameters({
@Parameter(name = "projectCode", description = "PROJECT_CODE", schema = @Schema(implementation = long.class, example = "123456")),
@Parameter(name = "workerGroups", description = "WORKER_GROUP_LIST", schema = @Schema(implementation = List.class))
})
@PostMapping()
@ResponseStatus(HttpStatus.CREATED)
@ApiException(ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR)
public Result assignWorkerGroups(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@Parameter(name = "workerGroups") String[] workerGroups) {
List<String> workerGroupList = Arrays.stream(workerGroups).collect(Collectors.toList());
return projectWorkerGroupRelationService.assignWorkerGroupsToProject(loginUser, projectCode, workerGroupList);
}
/**
* query worker groups that assigned to the project
*
* @param projectCode project code
* @return worker group list
*/
@Operation(summary = "queryWorkerGroups", description = "QUERY_WORKER_GROUP_LIST")
@Parameters({
@Parameter(name = "projectCode", description = "PROJECT_CODE", schema = @Schema(implementation = long.class, example = "123456"))
})
@GetMapping()
@ResponseStatus(HttpStatus.OK)
public Map<String, Object> queryWorkerGroups(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode) {
return projectWorkerGroupRelationService.queryWorkerGroupsByProject(loginUser, projectCode);
}
}

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkerGroupController.java

@ -167,5 +167,4 @@ public class WorkerGroupController extends BaseController {
Map<String, Object> result = workerGroupService.getWorkerAddressList(); Map<String, Object> result = workerGroupService.getWorkerAddressList();
return returnDataList(result); return returnDataList(result);
} }
} }

9
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java

@ -585,6 +585,15 @@ public enum Status {
WORKER_GROUP_DEPENDENT_ENVIRONMENT_EXISTS(1401002, WORKER_GROUP_DEPENDENT_ENVIRONMENT_EXISTS(1401002,
"You can not modify or remove this worker group, cause it has [{0}] dependent environments.", "You can not modify or remove this worker group, cause it has [{0}] dependent environments.",
"不能修改或删除该Worker组,有 [{0}] 个环境配置正在使用"), "不能修改或删除该Worker组,有 [{0}] 个环境配置正在使用"),
WORKER_GROUP_NOT_EXIST(1402001, "The Worker group [{0}] not exists", "Worker组[{0}]不存在."),
ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR(1402002, "Failed to assign these worker groups to the project",
"给项目分配工作组失败"),
WORKER_GROUP_TO_PROJECT_IS_EMPTY(1402003, "Need to assign at least one worker group to the project",
"需要给项目至少分配一个Worker组"),
USED_WORKER_GROUP_EXISTS(1402004,
"You can not reassign worker groups to the project, cause these worker groups {0} are already used.",
"Worker组{0}被项目中任务或定时引用,无法重新分配"),
; ;
private final int code; private final int code;
private final String enMsg; private final String enMsg;

48
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectWorkerGroupRelationService.java

@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.List;
import java.util.Map;
/**
* the service of project and worker group
*/
public interface ProjectWorkerGroupRelationService {
/**
* assign worker groups to a project
*
* @param loginUser the login user
* @param projectCode the project code
* @param workerGroups assigned worker group names
*/
Result assignWorkerGroupsToProject(User loginUser, Long projectCode, List<String> workerGroups);
/**
* query worker groups that assigned to the project
*
* @param loginUser the login user
* @param projectCode project code
*/
Map<String, Object> queryWorkerGroupsByProject(User loginUser, Long projectCode);
}

233
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectWorkerGroupRelationServiceImpl.java

@ -0,0 +1,233 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service.impl;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.ProjectWorkerGroupRelationService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.ProjectWorkerGroup;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectWorkerGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.SetUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
/**
* task definition service impl
*/
@Service
@Slf4j
public class ProjectWorkerGroupRelationServiceImpl extends BaseServiceImpl
implements
ProjectWorkerGroupRelationService {
@Autowired
private ProjectWorkerGroupMapper projectWorkerGroupMapper;
@Autowired
private ProjectMapper projectMapper;
@Autowired
private WorkerGroupMapper workerGroupMapper;
@Autowired
private TaskDefinitionMapper taskDefinitionMapper;
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired
private ProjectService projectService;
/**
* assign worker groups to a project
*
* @param loginUser the login user
* @param projectCode the project code
* @param workerGroups assigned worker group names
*/
@Override
public Result assignWorkerGroupsToProject(User loginUser, Long projectCode, List<String> workerGroups) {
Result result = new Result();
if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (Objects.isNull(projectCode)) {
putMsg(result, Status.PROJECT_NOT_EXIST);
return result;
}
if (CollectionUtils.isEmpty(workerGroups)) {
putMsg(result, Status.WORKER_GROUP_TO_PROJECT_IS_EMPTY);
return result;
}
Project project = projectMapper.queryByCode(projectCode);
if (Objects.isNull(project)) {
putMsg(result, Status.PROJECT_NOT_EXIST);
return result;
}
Set<String> workerGroupNames =
workerGroupMapper.queryAllWorkerGroup().stream().map(item -> item.getName()).collect(
Collectors.toSet());
workerGroupNames.add(Constants.DEFAULT_WORKER_GROUP);
Set<String> assignedWorkerGroupNames = workerGroups.stream().collect(Collectors.toSet());
Set<String> difference = SetUtils.difference(assignedWorkerGroupNames, workerGroupNames);
if (difference.size() > 0) {
putMsg(result, Status.WORKER_GROUP_NOT_EXIST, difference.toString());
return result;
}
Set<String> projectWorkerGroupNames = projectWorkerGroupMapper.selectList(new QueryWrapper<ProjectWorkerGroup>()
.lambda()
.eq(ProjectWorkerGroup::getProjectCode, projectCode)).stream().map(item -> item.getWorkerGroup())
.collect(Collectors.toSet());
difference = SetUtils.difference(projectWorkerGroupNames, assignedWorkerGroupNames);
if (CollectionUtils.isNotEmpty(difference)) {
Set<String> usedWorkerGroups = getAllUsedWorkerGroups(project);
if (CollectionUtils.isNotEmpty(usedWorkerGroups) && usedWorkerGroups.containsAll(difference)) {
throw new ServiceException(Status.USED_WORKER_GROUP_EXISTS,
SetUtils.intersection(usedWorkerGroups, difference).toSet());
}
int deleted = projectWorkerGroupMapper.delete(
new QueryWrapper<ProjectWorkerGroup>().lambda().eq(ProjectWorkerGroup::getProjectCode, projectCode)
.in(ProjectWorkerGroup::getWorkerGroup, difference));
if (deleted > 0) {
log.info("Success to delete worker groups [{}] for the project [{}] .", difference, project.getName());
} else {
log.error("Failed to delete worker groups [{}] for the project [{}].", difference, project.getName());
throw new ServiceException(Status.ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR);
}
}
difference = SetUtils.difference(assignedWorkerGroupNames, projectWorkerGroupNames);
Date now = new Date();
if (CollectionUtils.isNotEmpty(difference)) {
difference.stream().forEach(workerGroupName -> {
ProjectWorkerGroup projectWorkerGroup = new ProjectWorkerGroup();
projectWorkerGroup.setProjectCode(projectCode);
projectWorkerGroup.setWorkerGroup(workerGroupName);
projectWorkerGroup.setCreateTime(now);
projectWorkerGroup.setUpdateTime(now);
int create = projectWorkerGroupMapper.insert(projectWorkerGroup);
if (create > 0) {
log.info("Success to add worker group [{}] for the project [{}] .", workerGroupName,
project.getName());
} else {
log.error("Failed to add worker group [{}] for the project [{}].", workerGroupName,
project.getName());
throw new ServiceException(Status.ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR);
}
});
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query worker groups that assigned to the project
*
* @param projectCode project code
*/
@Override
public Map<String, Object> queryWorkerGroupsByProject(User loginUser, Long projectCode) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByCode(projectCode);
// check project auth
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result, null);
if (!hasProjectAndPerm) {
return result;
}
Set<String> assignedWorkerGroups = getAllUsedWorkerGroups(project);
projectWorkerGroupMapper.selectList(
new QueryWrapper<ProjectWorkerGroup>().lambda().eq(ProjectWorkerGroup::getProjectCode, projectCode))
.stream().forEach(projectWorkerGroup -> assignedWorkerGroups.add(projectWorkerGroup.getWorkerGroup()));
List<ProjectWorkerGroup> projectWorkerGroups = assignedWorkerGroups.stream().map(workerGroup -> {
ProjectWorkerGroup projectWorkerGroup = new ProjectWorkerGroup();
projectWorkerGroup.setProjectCode(projectCode);
projectWorkerGroup.setWorkerGroup(workerGroup);
return projectWorkerGroup;
}).collect(Collectors.toList());
result.put(Constants.DATA_LIST, projectWorkerGroups);
putMsg(result, Status.SUCCESS);
return result;
}
private Set<String> getAllUsedWorkerGroups(Project project) {
Set<String> usedWorkerGroups = new TreeSet<>();
// query all worker groups that tasks depend on
taskDefinitionMapper.queryAllDefinitionList(project.getCode()).stream().forEach(taskDefinition -> {
if (StringUtils.isNotEmpty(taskDefinition.getWorkerGroup())) {
usedWorkerGroups.add(taskDefinition.getWorkerGroup());
}
});
// query all worker groups that timings depend on
scheduleMapper.querySchedulerListByProjectName(project.getName())
.stream()
.filter(schedule -> StringUtils.isNotEmpty(schedule.getWorkerGroup()))
.forEach(schedule -> usedWorkerGroups.add(schedule.getWorkerGroup()));
return usedWorkerGroups;
}
}

161
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectWorkerGroupRelationServiceTest.java

@ -0,0 +1,161 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.impl.ProjectWorkerGroupRelationServiceImpl;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.ProjectWorkerGroup;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectWorkerGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import com.google.common.collect.Lists;
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class ProjectWorkerGroupRelationServiceTest {
@InjectMocks
private ProjectWorkerGroupRelationServiceImpl projectWorkerGroupRelationService;
@Mock
private ProjectMapper projectMapper;
@Mock
private ProjectWorkerGroupMapper projectWorkerGroupMapper;
@Mock
private WorkerGroupMapper workerGroupMapper;
@Mock
private ProjectService projectService;
@Mock
private TaskDefinitionMapper taskDefinitionMapper;
@Mock
private ScheduleMapper scheduleMapper;
protected final static long projectCode = 1L;
@Test
public void testAssignWorkerGroupsToProject() {
User loginUser = getAdminUser();
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(null);
Result result = projectWorkerGroupRelationService.assignWorkerGroupsToProject(loginUser, projectCode,
getWorkerGroups());
Assertions.assertEquals(Status.PROJECT_NOT_EXIST.getCode(), result.getCode());
WorkerGroup workerGroup = new WorkerGroup();
workerGroup.setName("test");
Mockito.when(projectMapper.queryByCode(Mockito.anyLong())).thenReturn(getProject());
Mockito.when(workerGroupMapper.queryAllWorkerGroup()).thenReturn(Lists.newArrayList(workerGroup));
Mockito.when(projectWorkerGroupMapper.insert(Mockito.any())).thenReturn(1);
result = projectWorkerGroupRelationService.assignWorkerGroupsToProject(loginUser, projectCode,
getWorkerGroups());
Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode());
}
@Test
public void testQueryWorkerGroupsByProject() {
Mockito.when(projectService.hasProjectAndPerm(Mockito.any(), Mockito.any(), Mockito.anyMap(), Mockito.any()))
.thenReturn(true);
Mockito.when(projectMapper.queryByCode(projectCode))
.thenReturn(getProject());
Mockito.when(projectWorkerGroupMapper.selectList(Mockito.any()))
.thenReturn(Lists.newArrayList(getProjectWorkerGroup()));
Mockito.when(taskDefinitionMapper.queryAllDefinitionList(Mockito.anyLong()))
.thenReturn(new ArrayList<>());
Mockito.when(scheduleMapper.querySchedulerListByProjectName(Mockito.any()))
.thenReturn(Lists.newArrayList());
Map<String, Object> result =
projectWorkerGroupRelationService.queryWorkerGroupsByProject(getGeneralUser(), projectCode);
ProjectWorkerGroup[] actualValue =
((List<ProjectWorkerGroup>) result.get(Constants.DATA_LIST)).toArray(new ProjectWorkerGroup[0]);
Assertions.assertEquals(actualValue[0].getWorkerGroup(), getProjectWorkerGroup().getWorkerGroup());
}
private List<String> getWorkerGroups() {
return Lists.newArrayList("default");
}
private User getGeneralUser() {
User loginUser = new User();
loginUser.setUserType(UserType.GENERAL_USER);
loginUser.setUserName("userName");
loginUser.setId(1);
return loginUser;
}
private User getAdminUser() {
User loginUser = new User();
loginUser.setUserType(UserType.ADMIN_USER);
loginUser.setUserName("userName");
loginUser.setId(1);
return loginUser;
}
private Project getProject() {
Project project = new Project();
project.setCode(projectCode);
project.setId(1);
project.setName("test");
project.setUserId(1);
return project;
}
private ProjectWorkerGroup getProjectWorkerGroup() {
ProjectWorkerGroup projectWorkerGroup = new ProjectWorkerGroup();
projectWorkerGroup.setId(1);
projectWorkerGroup.setProjectCode(projectCode);
projectWorkerGroup.setWorkerGroup("default");
return projectWorkerGroup;
}
}

56
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectWorkerGroup.java

@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.entity;
import java.util.Date;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@Data
@TableName("t_ds_relation_project_worker_group")
public class ProjectWorkerGroup {
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* project code
*/
private Long projectCode;
/**
* worker group
*/
private String workerGroup;
/**
* create time
*/
private Date createTime;
/**
* update time
*/
private Date updateTime;
}

26
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectWorkerGroupMapper.java

@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.entity.ProjectWorkerGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface ProjectWorkerGroupMapper extends BaseMapper<ProjectWorkerGroup> {
}

15
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql

@ -1038,6 +1038,21 @@ CREATE TABLE t_ds_worker_group
-- Records of t_ds_worker_group -- Records of t_ds_worker_group
-- ---------------------------- -- ----------------------------
-- ----------------------------
-- Table structure for t_ds_relation_project_worker_group
-- ----------------------------
DROP TABLE IF EXISTS t_ds_relation_project_worker_group CASCADE;
CREATE TABLE t_ds_relation_project_worker_group
(
id int(11) NOT NULL AUTO_INCREMENT,
project_code bigint(20) NOT NULL,
worker_group varchar(255) DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_time datetime DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY unique_project_worker_group(project_code,worker_group)
);
-- ---------------------------- -- ----------------------------
-- Table structure for t_ds_version -- Table structure for t_ds_version
-- ---------------------------- -- ----------------------------

17
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql

@ -1095,6 +1095,22 @@ CREATE TABLE `t_ds_alert_plugin_instance` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE = utf8_bin; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE = utf8_bin;
-- ----------------------------
-- Table structure for t_ds_relation_project_worker_group
-- ----------------------------
DROP TABLE IF EXISTS `t_ds_relation_project_worker_group`;
CREATE TABLE `t_ds_relation_project_worker_group` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
`project_code` bigint(20) NOT NULL COMMENT 'project code',
`worker_group` varchar(255) DEFAULT NULL COMMENT 'worker group',
`create_time` datetime DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL COMMENT 'update time',
PRIMARY KEY (`id`),
UNIQUE KEY unique_project_worker_group(project_code,worker_group)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE = utf8_bin;
-- --
-- Table structure for table `t_ds_dq_comparison_type` -- Table structure for table `t_ds_dq_comparison_type`
-- --
@ -1111,6 +1127,7 @@ CREATE TABLE `t_ds_dq_comparison_type` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE = utf8_bin; )ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE = utf8_bin;
INSERT IGNORE INTO `t_ds_dq_comparison_type` INSERT IGNORE INTO `t_ds_dq_comparison_type`
(`id`, `type`, `execute_sql`, `output_table`, `name`, `create_time`, `update_time`, `is_inner_source`) (`id`, `type`, `execute_sql`, `output_table`, `name`, `create_time`, `update_time`, `is_inner_source`)
VALUES(1, 'FixValue', NULL, NULL, NULL, current_timestamp, current_timestamp, false); VALUES(1, 'FixValue', NULL, NULL, NULL, current_timestamp, current_timestamp, false);

19
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql

@ -927,6 +927,21 @@ CREATE TABLE t_ds_worker_group (
CONSTRAINT name_unique UNIQUE (name) CONSTRAINT name_unique UNIQUE (name)
) ; ) ;
--
-- Table structure for table t_ds_relation_project_worker_group
--
DROP TABLE IF EXISTS t_ds_relation_project_worker_group;
CREATE TABLE t_ds_relation_project_worker_group (
id int NOT NULL ,
project_code bigint DEFAULT NULL ,
worker_group varchar(255) NOT NULL,
create_time timestamp DEFAULT NULL,
update_time timestamp DEFAULT NULL,
PRIMARY KEY (id),
CONSTRAINT t_ds_relation_project_worker_group_un UNIQUE (project_code, worker_group)
);
DROP SEQUENCE IF EXISTS t_ds_access_token_id_sequence; DROP SEQUENCE IF EXISTS t_ds_access_token_id_sequence;
CREATE SEQUENCE t_ds_access_token_id_sequence; CREATE SEQUENCE t_ds_access_token_id_sequence;
ALTER TABLE t_ds_access_token ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_access_token_id_sequence'); ALTER TABLE t_ds_access_token ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_access_token_id_sequence');
@ -1024,6 +1039,10 @@ DROP SEQUENCE IF EXISTS t_ds_project_preference_id_sequence;
CREATE SEQUENCE t_ds_project_preference_id_sequence; CREATE SEQUENCE t_ds_project_preference_id_sequence;
ALTER TABLE t_ds_project_preference ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_project_preference_id_sequence'); ALTER TABLE t_ds_project_preference ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_project_preference_id_sequence');
DROP SEQUENCE IF EXISTS t_ds_relation_project_worker_group_sequence;
CREATE SEQUENCE t_ds_relation_project_worker_group_sequence;
ALTER TABLE t_ds_relation_project_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_project_worker_group_sequence');
-- Records of t_ds_user?user : admin , password : dolphinscheduler123 -- Records of t_ds_user?user : admin , password : dolphinscheduler123
INSERT INTO t_ds_user(user_name, user_password, user_type, email, phone, tenant_id, state, create_time, update_time, time_zone) INSERT INTO t_ds_user(user_name, user_password, user_type, email, phone, tenant_id, state, create_time, update_time, time_zone)
VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '-1', 1, '2018-03-27 15:48:50', '2018-10-24 17:40:22', null); VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '-1', 1, '2018-03-27 15:48:50', '2018-10-24 17:40:22', null);

11
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/mysql/dolphinscheduler_ddl.sql

@ -14,3 +14,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
DROP TABLE IF EXISTS `t_ds_relation_project_worker_group`;
CREATE TABLE `t_ds_relation_project_worker_group` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
`project_code` bigint(20) NOT NULL COMMENT 'project code',
`worker_group` varchar(255) DEFAULT NULL COMMENT 'worker group',
`create_time` datetime DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL COMMENT 'update time',
PRIMARY KEY (`id`),
UNIQUE KEY unique_project_worker_group(project_code,worker_group)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE = utf8_bin;

14
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/postgresql/dolphinscheduler_ddl.sql

@ -14,3 +14,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
DROP TABLE IF EXISTS t_ds_relation_project_worker_group;
CREATE TABLE t_ds_relation_project_worker_group (
id int NOT NULL ,
project_code bigint DEFAULT NULL ,
worker_group varchar(255) NOT NULL,
create_time timestamp DEFAULT NULL,
update_time timestamp DEFAULT NULL,
PRIMARY KEY (id),
CONSTRAINT t_ds_relation_project_worker_group_un UNIQUE (project_code, worker_group)
);
DROP SEQUENCE IF EXISTS t_ds_relation_project_worker_group_sequence;
CREATE SEQUENCE t_ds_relation_project_worker_group_sequence;
ALTER TABLE t_ds_relation_project_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_project_worker_group_sequence');

113
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectWorkerGroupMapperTest.java

@ -0,0 +1,113 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.ProjectWorkerGroup;
import java.util.Date;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
public class ProjectWorkerGroupMapperTest extends BaseDaoTest {
@Autowired
private ProjectWorkerGroupMapper projectWorkerGroupMapper;
/**
* insert
*
* @return ProjectWorkerGroup
*/
private ProjectWorkerGroup insertOne() {
// insertOne
ProjectWorkerGroup projectWorkerGroup = new ProjectWorkerGroup();
projectWorkerGroup.setProjectCode(1L);
projectWorkerGroup.setWorkerGroup("WorkerGroup1");;
projectWorkerGroupMapper.insert(projectWorkerGroup);
return projectWorkerGroup;
}
/**
* test update
*/
@Test
public void testUpdate() {
// insertOne
ProjectWorkerGroup projectWorkerGroup = insertOne();
projectWorkerGroup.setCreateTime(new Date());
// update
int update = projectWorkerGroupMapper.updateById(projectWorkerGroup);
Assertions.assertEquals(update, 1);
}
/**
* test delete
*/
@Test
public void testDelete() {
ProjectWorkerGroup projectWorkerGroup = insertOne();
int delete = projectWorkerGroupMapper.deleteById(projectWorkerGroup.getId());
Assertions.assertEquals(delete, 1);
}
/**
* test query
*/
@Test
public void testQuery() {
ProjectWorkerGroup projectWorkerGroup = insertOne();
// query
List<ProjectWorkerGroup> projectUsers = projectWorkerGroupMapper.selectList(null);
Assertions.assertNotEquals(0, projectUsers.size());
}
/**
* test delete the relation of project and worker group
*/
@Test
public void testDeleteProjectWorkerGroupRelation() {
ProjectWorkerGroup projectWorkerGroup = insertOne();
int delete = projectWorkerGroupMapper.delete(new QueryWrapper<ProjectWorkerGroup>()
.lambda()
.eq(ProjectWorkerGroup::getProjectCode, projectWorkerGroup.getProjectCode())
.eq(ProjectWorkerGroup::getWorkerGroup, projectWorkerGroup.getWorkerGroup()));
Assertions.assertTrue(delete >= 1);
}
/**
* test query the relation of project and worker group
*/
@Test
public void testQueryProjectWorkerGroupRelation() {
ProjectWorkerGroup projectWorkerGroup = insertOne();
projectWorkerGroup = projectWorkerGroupMapper.selectOne(new QueryWrapper<ProjectWorkerGroup>()
.lambda()
.eq(ProjectWorkerGroup::getProjectCode, projectWorkerGroup.getProjectCode())
.eq(ProjectWorkerGroup::getWorkerGroup, projectWorkerGroup.getWorkerGroup()));
Assertions.assertNotEquals(null, projectWorkerGroup);
}
}

3
dolphinscheduler-ui/src/locales/en_US/project.ts

@ -40,7 +40,8 @@ export default {
authorize_level: 'Authorize Level', authorize_level: 'Authorize Level',
no_permission: 'No Permission', no_permission: 'No Permission',
read_permission: 'Read Permission', read_permission: 'Read Permission',
all_permission: 'All Permission' all_permission: 'All Permission',
assign_worker_group: 'Worker Group',
}, },
workflow: { workflow: {
on_line: 'Online', on_line: 'Online',

3
dolphinscheduler-ui/src/locales/zh_CN/project.ts

@ -40,7 +40,8 @@ export default {
authorize_level: '权限等级', authorize_level: '权限等级',
no_permission: '无权限', no_permission: '无权限',
read_permission: '读权限', read_permission: '读权限',
all_permission: '所有权限' all_permission: '所有权限',
assign_worker_group: '分配WorkerGroup',
}, },
workflow: { workflow: {
on_line: '线上', on_line: '线上',

39
dolphinscheduler-ui/src/service/modules/projects-worker-group/index.ts

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { axios } from '@/service/service'
import { UpdateProjectWorkerGroupsReq } from "@/service/modules/projects-worker-group/types";
export function queryWorkerGroupsByProjectCode(
projectCode: number
): any {
return axios({
url: `/projects/${projectCode}/worker-group`,
method: 'get'
})
}
export function assignWorkerGroups(
data: UpdateProjectWorkerGroupsReq,
projectCode: number
): any {
return axios({
url: `/projects/${projectCode}/worker-group`,
method: 'post',
data
})
}

34
dolphinscheduler-ui/src/service/modules/projects-worker-group/types.ts

@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface ProjectWorkerGroup {
id: number
projectCode: number
workerGroup: string
createTime: string
updateTime: string
}
interface UpdateProjectWorkerGroupsReq {
workerGroups: string
}
export {
ProjectWorkerGroup,
UpdateProjectWorkerGroupsReq
}

77
dolphinscheduler-ui/src/views/projects/list/components/use-worker-group.ts

@ -0,0 +1,77 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useI18n } from 'vue-i18n'
import { reactive, ref, SetupContext } from 'vue'
import { useUserStore } from '@/store/user/user'
import { Option } from "naive-ui/es/transfer/src/interface"
import { queryAllWorkerGroups } from "@/service/modules/worker-groups"
import { queryWorkerGroupsByProjectCode, assignWorkerGroups } from "@/service/modules/projects-worker-group"
import { UpdateProjectWorkerGroupsReq } from "@/service/modules/projects-worker-group/types"
export function useWorkerGroup(
props: any,
ctx: SetupContext<('cancelModal' | 'confirmModal')[]>
) {
const { t } = useI18n()
const userStore = useUserStore()
const variables = reactive({
model: {
workerGroupOptions: [] as Option[],
assignedWorkerGroups: ref([] as any)
}
})
const initOptions = () => {
variables.model.workerGroupOptions = []
queryAllWorkerGroups().then((res: any) => {
for (const workerGroup of res) {
variables.model.workerGroupOptions.push({label: workerGroup, value: workerGroup, disabled: workerGroup==='default'})
}
})
}
const initAssignedWorkerGroups = (projectCode: number) => {
variables.model.assignedWorkerGroups = ref([] as any)
queryWorkerGroupsByProjectCode(projectCode).then((res: any) =>{
res.data.forEach((item: any) => {
variables.model.assignedWorkerGroups.push(item.workerGroup)
})
})
}
initOptions()
const handleValidate = () => {
if (variables.model?.assignedWorkerGroups.length>0) {
submitModal()
ctx.emit('confirmModal', props.showModalRef)
}
}
const submitModal = async () => {
if (props.row.code) {
let data: UpdateProjectWorkerGroupsReq = {
workerGroups: variables.model.assignedWorkerGroups.length>0? variables.model.assignedWorkerGroups.join(','):''
}
assignWorkerGroups(data, props.row.code)
}
}
return { variables, t, handleValidate, initAssignedWorkerGroups }
}

91
dolphinscheduler-ui/src/views/projects/list/components/worker-group-modal.tsx

@ -0,0 +1,91 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
defineComponent,
getCurrentInstance,
PropType,
toRefs,
watch
} from 'vue'
import { NTransfer} from 'naive-ui'
import Modal from '@/components/modal'
import styles from "@/views/security/user-manage/index.module.scss";
import {useWorkerGroup} from "@/views/projects/list/components/use-worker-group";
const props = {
showModalRef: {
type: Boolean as PropType<boolean>,
default: false
},
row: {
type: Object as PropType<any>,
default: {}
}
}
const WorkerGroupModal = defineComponent({
name: 'WorkerGroupModal',
props,
emits: ['cancelModal', 'confirmModal'],
setup(props, ctx) {
const { variables, t, handleValidate, initAssignedWorkerGroups } = useWorkerGroup(props, ctx)
const cancelModal = () => {
ctx.emit('cancelModal', props.showModalRef)
}
const trim = getCurrentInstance()?.appContext.config.globalProperties.trim
const confirmModal = () => {
handleValidate()
}
watch(
() => props.showModalRef,
() => {
if (props.showModalRef) {
initAssignedWorkerGroups(props.row.code)
}
}
)
return { ...toRefs(variables), t, cancelModal, confirmModal, trim }
},
render() {
const { t } = this
return (
<Modal
title={t('project.list.assign_worker_group')}
show={this.showModalRef}
onConfirm={this.confirmModal}
onCancel={this.cancelModal}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
>
<NTransfer
virtualScroll
class={styles.transfer}
options={this.model.workerGroupOptions}
v-model:value={this.model.assignedWorkerGroups}
/>
</Modal>
)
}
})
export default WorkerGroupModal

18
dolphinscheduler-ui/src/views/projects/list/index.tsx

@ -29,6 +29,7 @@ import { useTable } from './use-table'
import Card from '@/components/card' import Card from '@/components/card'
import Search from '@/components/input-search' import Search from '@/components/input-search'
import ProjectModal from './components/project-modal' import ProjectModal from './components/project-modal'
import WorkerGroupModal from "@/views/projects/list/components/worker-group-modal";
const list = defineComponent({ const list = defineComponent({
name: 'list', name: 'list',
@ -71,6 +72,15 @@ const list = defineComponent({
requestData() requestData()
} }
const onCancelWorkerGroupModal = () => {
variables.showWorkerGroupModalRef = false
}
const onConfirmWorkerGroupModal = () => {
variables.showWorkerGroupModalRef = false
requestData()
}
const handleChangePageSize = () => { const handleChangePageSize = () => {
variables.page = 1 variables.page = 1
requestData() requestData()
@ -95,6 +105,8 @@ const list = defineComponent({
handleSearch, handleSearch,
onCancelModal, onCancelModal,
onConfirmModal, onConfirmModal,
onCancelWorkerGroupModal,
onConfirmWorkerGroupModal,
onClearSearch, onClearSearch,
handleChangePageSize, handleChangePageSize,
trim trim
@ -160,6 +172,12 @@ const list = defineComponent({
onCancelModal={this.onCancelModal} onCancelModal={this.onCancelModal}
onConfirmModal={this.onConfirmModal} onConfirmModal={this.onConfirmModal}
/> />
<WorkerGroupModal
showModalRef={this.showWorkerGroupModalRef}
row={this.row}
onCancelModal={this.onCancelWorkerGroupModal}
onConfirmModal={this.onConfirmWorkerGroupModal}
/>
</NSpace> </NSpace>
) )
} }

44
dolphinscheduler-ui/src/views/projects/list/use-table.ts

@ -25,7 +25,7 @@ import { deleteProject } from '@/service/modules/projects'
import { format } from 'date-fns' import { format } from 'date-fns'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { import {
NButton, NButton, NDropdown,
NEllipsis, NEllipsis,
NIcon, NIcon,
NPopconfirm, NPopconfirm,
@ -39,18 +39,29 @@ import {
} from '@/common/column-width-config' } from '@/common/column-width-config'
import type { Router } from 'vue-router' import type { Router } from 'vue-router'
import type { ProjectRes } from '@/service/modules/projects/types' import type { ProjectRes } from '@/service/modules/projects/types'
import { DeleteOutlined, EditOutlined } from '@vicons/antd' import {ControlOutlined, DeleteOutlined, EditOutlined, UserOutlined} from '@vicons/antd'
import {useUserStore} from "@/store/user/user";
import {UserInfoRes} from "@/service/modules/users/types";
export function useTable() { export function useTable() {
const { t } = useI18n() const { t } = useI18n()
const router: Router = useRouter() const router: Router = useRouter()
const userStore = useUserStore()
const userInfo = userStore.getUserInfo as UserInfoRes
const IS_ADMIN = userInfo.userType === 'ADMIN_USER'
const handleEdit = (row: any) => { const handleEdit = (row: any) => {
variables.showModalRef = true variables.showModalRef = true
variables.statusRef = 1 variables.statusRef = 1
variables.row = row variables.row = row
} }
const handleAssign = (row: any) => {
variables.showWorkerGroupModalRef = true
variables.row = row
}
const handleDelete = (row: any) => { const handleDelete = (row: any) => {
deleteProject(row.code).then(() => { deleteProject(row.code).then(() => {
getTableData({ getTableData({
@ -137,7 +148,7 @@ export function useTable() {
{ {
title: t('project.list.operation'), title: t('project.list.operation'),
key: 'actions', key: 'actions',
...COLUMN_WIDTH_CONFIG['operation'](2), ...COLUMN_WIDTH_CONFIG['operation'](3),
render(row: any) { render(row: any) {
return h(NSpace, null, { return h(NSpace, null, {
default: () => [ default: () => [
@ -165,6 +176,32 @@ export function useTable() {
default: () => t('project.list.edit') default: () => t('project.list.edit')
} }
), ),
IS_ADMIN &&
h(
NTooltip,
{
trigger: 'hover'
},
{
trigger: () =>
h(
NButton,
{
circle: true,
type: 'info',
size: 'small',
class: 'edit',
onClick: () => {
handleAssign(row)
}
},
{
icon: () => h(NIcon, null, () => h(ControlOutlined))
}
),
default: () => t('project.list.assign_worker_group')
}
),
h( h(
NPopconfirm, NPopconfirm,
{ {
@ -219,6 +256,7 @@ export function useTable() {
searchVal: ref(''), searchVal: ref(''),
totalPage: ref(1), totalPage: ref(1),
showModalRef: ref(false), showModalRef: ref(false),
showWorkerGroupModalRef: ref(false),
statusRef: ref(0), statusRef: ref(0),
row: {}, row: {},
loadingRef: ref(false) loadingRef: ref(false)

2
dolphinscheduler-ui/src/views/projects/preference/use-form.ts

@ -111,7 +111,7 @@ export function useForm() {
const preferencesItems: IJsonItem[] = [ const preferencesItems: IJsonItem[] = [
Fields.useTaskPriority(), Fields.useTaskPriority(),
useTenant(), useTenant(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(data.model, true), Fields.useEnvironmentName(data.model, true),
...Fields.useFailed(), ...Fields.useFailed(),
useWarningType(), useWarningType(),

9
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-worker-group.ts

@ -17,10 +17,10 @@
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { queryAllWorkerGroups } from '@/service/modules/worker-groups' import { queryWorkerGroupsByProjectCode } from '@/service/modules/projects-worker-group'
import type { IJsonItem } from '../types' import type { IJsonItem } from '../types'
export function useWorkerGroup(): IJsonItem { export function useWorkerGroup(projectCode: number): IJsonItem {
const { t } = useI18n() const { t } = useI18n()
const options = ref([] as { label: string; value: string }[]) const options = ref([] as { label: string; value: string }[])
@ -29,8 +29,9 @@ export function useWorkerGroup(): IJsonItem {
const getWorkerGroups = async () => { const getWorkerGroups = async () => {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true
const res = await queryAllWorkerGroups() await queryWorkerGroupsByProjectCode(projectCode).then((res: any) => {
options.value = res.map((item: string) => ({ label: item, value: item })) options.value = res.data.map((item: any) =>({label: item.workerGroup, value: item.workerGroup }))
})
loading.value = false loading.value = false
} }

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-chunjun.ts

@ -59,7 +59,7 @@ export function useChunjun({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-conditions.ts

@ -57,7 +57,7 @@ export function useConditions({
Fields.useRunFlag(), Fields.useRunFlag(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-data-factory.ts

@ -58,7 +58,7 @@ export function useDataFactory({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-data-quality.ts

@ -69,7 +69,7 @@ export function useDataQuality({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-datasync.ts

@ -68,7 +68,7 @@ export function useDatasync({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-datax.ts

@ -62,7 +62,7 @@ export function useDataX({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dependent.ts

@ -60,7 +60,7 @@ export function useDependent({
Fields.useRunFlag(), Fields.useRunFlag(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dinky.ts

@ -54,7 +54,7 @@ export function useDinky({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dms.ts

@ -69,7 +69,7 @@ export function useDms({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dvc.ts

@ -55,7 +55,7 @@ export function useDvc({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dynamic.ts

@ -64,7 +64,7 @@ export function useDynamic({
Fields.useRunFlag(), Fields.useRunFlag(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-emr.ts

@ -56,7 +56,7 @@ export function useEmr({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-flink-stream.ts

@ -65,7 +65,7 @@ export function useFlinkStream({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
Fields.useDelayTime(model), Fields.useDelayTime(model),
...Fields.useFlink(model), ...Fields.useFlink(model),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-flink.ts

@ -65,7 +65,7 @@ export function useFlink({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-hive-cli.ts

@ -68,7 +68,7 @@ export function useHiveCli({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-http.ts

@ -62,7 +62,7 @@ export function useHttp({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-java.ts

@ -76,7 +76,7 @@ export function useJava({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-jupyter.ts

@ -56,7 +56,7 @@ export function useJupyter({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-k8s.ts

@ -61,7 +61,7 @@ export function useK8s({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-kubeflow.ts

@ -54,7 +54,7 @@ export function useKubeflow({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-linkis.ts

@ -65,7 +65,7 @@ export function useLinkis({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-mlflow.ts

@ -62,7 +62,7 @@ export function useMlflow({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-mr.ts

@ -56,7 +56,7 @@ export function useMr({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-openmldb.ts

@ -58,7 +58,7 @@ export function useOpenmldb({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-pigeon.ts

@ -54,7 +54,7 @@ export function usePigeon({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-procedure.ts

@ -58,7 +58,7 @@ export function useProcedure({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-python.ts

@ -58,7 +58,7 @@ export function usePython({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-pytorch.ts

@ -73,7 +73,7 @@ export function usePytorch({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-remote-shell.ts

@ -56,7 +56,7 @@ export function useRemoteShell({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sagemaker.ts

@ -59,7 +59,7 @@ export function userSagemaker({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sea-tunnel.ts

@ -89,7 +89,7 @@ export function useSeaTunnel({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-shell.ts

@ -57,7 +57,7 @@ export function useShell({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-spark.ts

@ -64,7 +64,7 @@ export function useSpark({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sql.ts

@ -62,7 +62,7 @@ export function useSql({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sqoop.ts

@ -77,7 +77,7 @@ export function useSqoop({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sub-process.ts

@ -56,7 +56,7 @@ export function useSubProcess({
Fields.useRunFlag(), Fields.useRunFlag(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useTimeoutAlarm(model), ...Fields.useTimeoutAlarm(model),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-switch.ts

@ -57,7 +57,7 @@ export function useSwitch({
Fields.useRunFlag(), Fields.useRunFlag(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

2
dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-zeppelin.ts

@ -59,7 +59,7 @@ export function useZeppelin({
Fields.useCache(), Fields.useCache(),
Fields.useDescription(), Fields.useDescription(),
Fields.useTaskPriority(), Fields.useTaskPriority(),
Fields.useWorkerGroup(), Fields.useWorkerGroup(projectCode),
Fields.useEnvironmentName(model, !data?.id), Fields.useEnvironmentName(model, !data?.id),
...Fields.useTaskGroup(model, projectCode), ...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(), ...Fields.useFailed(),

9
dolphinscheduler-ui/src/views/projects/workflow/definition/components/use-modal.ts

@ -26,7 +26,6 @@ import {
importProcessDefinition, importProcessDefinition,
queryProcessDefinitionByCode queryProcessDefinitionByCode
} from '@/service/modules/process-definition' } from '@/service/modules/process-definition'
import { queryAllWorkerGroups } from '@/service/modules/worker-groups'
import { queryAllEnvironmentList } from '@/service/modules/environment' import { queryAllEnvironmentList } from '@/service/modules/environment'
import { listNormalAlertGroupById } from '@/service/modules/alert-group' import { listNormalAlertGroupById } from '@/service/modules/alert-group'
import { startProcessInstance } from '@/service/modules/executors' import { startProcessInstance } from '@/service/modules/executors'
@ -39,6 +38,7 @@ import { parseTime } from '@/common/common'
import { EnvironmentItem } from '@/service/modules/environment/types' import { EnvironmentItem } from '@/service/modules/environment/types'
import { ITimingState, ProcessInstanceReq } from './types' import { ITimingState, ProcessInstanceReq } from './types'
import { queryTenantList } from '@/service/modules/tenants' import { queryTenantList } from '@/service/modules/tenants'
import { queryWorkerGroupsByProjectCode } from '@/service/modules/projects-worker-group'
export function useModal( export function useModal(
state: any, state: any,
@ -228,11 +228,8 @@ export function useModal(
} }
const getWorkerGroups = () => { const getWorkerGroups = () => {
queryAllWorkerGroups().then((res: any) => { queryWorkerGroupsByProjectCode(variables.projectCode).then((res: any) => {
variables.workerGroups = res.map((item: string) => ({ variables.workerGroups = res.data.map((item: any) =>({label: item.workerGroup, value: item.workerGroup }))
label: item,
value: item
}))
}) })
} }

Loading…
Cancel
Save