Browse Source

init

master
xueyinfei 1 month ago
parent
commit
c6043b106f
  1. 22
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
  2. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
  3. 29
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
  4. 101
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
  5. 232
      dolphinscheduler-ui/pnpm-lock.yaml
  6. 11
      dolphinscheduler-ui/src/layouts/content/use-dataList.ts
  7. 3
      dolphinscheduler-ui/src/locales/en_US/menu.ts
  8. 3
      dolphinscheduler-ui/src/locales/zh_CN/menu.ts
  9. 2
      dolphinscheduler-ui/src/locales/zh_CN/project.ts
  10. 6
      dolphinscheduler-ui/src/router/index.ts
  11. 3
      dolphinscheduler-ui/src/store/user/types.ts
  12. 9
      dolphinscheduler-ui/src/store/user/user.ts
  13. 10
      dolphinscheduler-ui/src/views/projects/list/components/project-modal.tsx
  14. 2
      dolphinscheduler-ui/src/views/projects/list/use-table.ts
  15. 23
      dolphinscheduler-ui/src/views/security/user-manage/index.tsx
  16. 221
      dolphinscheduler-ui/src/views/security/user-manage/use-columns.ts

22
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java

@ -199,6 +199,28 @@ public class DataSourceController extends BaseController {
return dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
}
@ApiOperation(value = "queryDataSourceListWithPasswordPaging", notes = "QUERY_DATA_SOURCE_LIST_WITH_PASSWORD_PAGING_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataTypeClass = String.class),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataTypeClass = int.class, example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataTypeClass = int.class, example = "20")
})
@GetMapping("/withpwdlist")
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_DATASOURCE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryDataSourceListWithPasswordPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Result result = checkPageParams(pageNo, pageSize);
if (!result.checkResult()) {
return result;
}
searchVal = ParameterUtils.handleEscapes(searchVal);
return dataSourceService.queryDataSourceListWithPasswordPaging(loginUser, searchVal, pageNo, pageSize);
}
/**
* connect datasource
*

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java

@ -68,6 +68,8 @@ public interface DataSourceService {
*/
Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
Result queryDataSourceListWithPasswordPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
/**
* query data resource list
*

29
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java

@ -284,6 +284,35 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
return result;
}
@Override
public Result queryDataSourceListWithPasswordPaging(User loginUser, String searchVal, Integer pageNo,
Integer pageSize) {
Result result = new Result();
IPage<DataSource> dataSourceList = null;
Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize);
PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize);
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {
dataSourceList = dataSourceMapper.selectPaging(dataSourcePage,
UserType.ADMIN_USER.equals(loginUser.getUserType()) ? 0 : loginUser.getId(), searchVal);
} else {
Set<Integer> ids = resourcePermissionCheckService
.userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), logger);
if (ids.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
dataSourceList = dataSourceMapper.selectPagingByIds(dataSourcePage, new ArrayList<>(ids), searchVal);
}
List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>();
pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L));
pageInfo.setTotalList(dataSources);
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* handle datasource connection password for safety
*/

101
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java

@ -56,6 +56,7 @@ import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.apache.dolphinscheduler.service.storage.StorageOperate;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -161,10 +162,10 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
return result;
}
if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
// if (!isAdmin(loginUser)) {
// putMsg(result, Status.USER_NO_OPERATION_PERM);
// return result;
// }
if (!StringUtils.isEmpty(msg)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg);
@ -387,9 +388,9 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
if (check(result, !canOperator(loginUser, userId), Status.USER_NO_OPERATION_PERM)) {
return result;
}
// if (check(result, !canOperator(loginUser, userId), Status.USER_NO_OPERATION_PERM)) {
// return result;
// }
User user;
if (userId == -1) {
user = userMapper.selectByUserName(userName);
@ -402,23 +403,23 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
}
// non-admin should not modify tenantId and queue
if (!isAdmin(loginUser)) {
if (tenantId != -1){
if (user.getTenantId() != tenantId) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
}
}
if (StringUtils.isNotEmpty(queue) && !StringUtils.equals(queue, user.getQueue())) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
}
}
// if (!isAdmin(loginUser)) {
// if (tenantId != -1){
// if (user.getTenantId() != tenantId) {
// throw new ServiceException(Status.USER_NO_OPERATION_PERM);
// }
// }
// if (StringUtils.isNotEmpty(queue) && !StringUtils.equals(queue, user.getQueue())) {
// throw new ServiceException(Status.USER_NO_OPERATION_PERM);
// }
// }
if (StringUtils.isNotEmpty(userName)) {
if (!CheckUtils.checkUserName(userName)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName);
return result;
}
// if (!CheckUtils.checkUserName(userName)) {
// putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName);
// return result;
// }
if (userId != -1) {
User tempUser = userMapper.queryByUserNameAccurately(userName);
if (tempUser != null && tempUser.getId() != userId) {
@ -430,25 +431,25 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
}
if (StringUtils.isNotEmpty(userPassword)) {
if (!CheckUtils.checkPasswordLength(userPassword)) {
putMsg(result, Status.USER_PASSWORD_LENGTH_ERROR);
return result;
}
// if (!CheckUtils.checkPasswordLength(userPassword)) {
// putMsg(result, Status.USER_PASSWORD_LENGTH_ERROR);
// return result;
// }
user.setUserPassword(EncryptionUtils.getMd5(userPassword));
}
if (StringUtils.isNotEmpty(email)) {
if (!CheckUtils.checkEmail(email)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, email);
return result;
}
// if (!CheckUtils.checkEmail(email)) {
// putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, email);
// return result;
// }
user.setEmail(email);
}
if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone);
return result;
}
// if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) {
// putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone);
// return result;
// }
if (state == 0 && user.getState() != state && Objects.equals(loginUser.getId(), user.getId())) {
putMsg(result, Status.NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT);
@ -492,10 +493,10 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
return result;
}
// only admin can operate
if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM, id);
return result;
}
// if (!isAdmin(loginUser)) {
// putMsg(result, Status.USER_NO_OPERATION_PERM, id);
// return result;
// }
if (id != -1) {
User tempUser = userMapper.selectById(id);
// check exist
@ -1111,19 +1112,19 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
private String checkUserParams(String userName, String password, String email, String phone) {
String msg = null;
if (!CheckUtils.checkUserName(userName)) {
msg = userName;
} else if (!CheckUtils.checkPassword(password)) {
msg = password;
} else if (!CheckUtils.checkEmail(email)) {
msg = email;
} else if (!CheckUtils.checkPhone(phone)) {
msg = phone;
}
// if (!CheckUtils.checkUserName(userName)) {
//
// msg = userName;
// } else if (!CheckUtils.checkPassword(password)) {
//
// msg = password;
// } else if (!CheckUtils.checkEmail(email)) {
//
// msg = email;
// } else if (!CheckUtils.checkPhone(phone)) {
//
// msg = phone;
// }
return msg;
}

232
dolphinscheduler-ui/pnpm-lock.yaml

File diff suppressed because it is too large

11
dolphinscheduler-ui/src/layouts/content/use-dataList.ts

@ -89,6 +89,8 @@ export function useDataList() {
const changeMenuOption = (state: any) => {
const projectCode = route.params.projectCode || ''
const hideReturnToProject = userStore.getHideReturnToProject
state.menuOptions = [
{
label: () => h(NEllipsis, null, { default: () => t('menu.home') }),
@ -317,6 +319,15 @@ export function useDataList() {
// ]
}
]
if (!hideReturnToProject){
state.menuOptions[1].children.push(
{
label: t('menu.return_to_parent'),
key: `/projects/list`,
icon: renderIcon(FundProjectionScreenOutlined)
}
)
}
}
const changeHeaderMenuOptions = (state: any) => {

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

@ -56,5 +56,6 @@ export default {
task_group_queue: 'Task Group Queue',
data_quality: 'Data Quality',
task_result: 'Task Result',
rule: 'Rule management'
rule: 'Rule management',
return_to_parent:'Return To Parent'
}

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

@ -56,5 +56,6 @@ export default {
task_group_queue: '任务组队列',
data_quality: '数据质量',
task_result: '任务结果',
rule: '规则管理'
rule: '规则管理',
return_to_parent: '返回上层',
}

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

@ -312,7 +312,7 @@ export default {
online: '已上线'
},
node: {
return_back: '返回上一节点',
return_back: '返回上一',
current_node_settings: '当前节点设置',
instructions: '使用说明',
view_history: '查看历史',

6
dolphinscheduler-ui/src/router/index.ts

@ -66,10 +66,16 @@ router.beforeEach(
if (to.query && to.query.userName && to.query.password){
const userName = to.query.userName
const password = to.query.password
const hideReturnToProject = to.query.hideReturnToProject
if (userName !== null && userName !== '' && password !== null && password !== ''){
userStore.setDashUserName(userName.toString())
userStore.setDashPassword(password.toString())
userStore.setIsShowTop(false)
if (hideReturnToProject){
userStore.setHideReturnToProject(true)
}else {
userStore.setHideReturnToProject(false)
}
}
}
}

3
dolphinscheduler-ui/src/store/user/types.ts

@ -23,7 +23,8 @@ interface UserState {
userInfo: UserInfoRes | {}
isShowTop: boolean,
dashUserName: string,
dashPassword: string
dashPassword: string,
hideReturnToProject: boolean
}
export { UserState }

9
dolphinscheduler-ui/src/store/user/user.ts

@ -27,10 +27,14 @@ export const useUserStore = defineStore({
userInfo: {},
isShowTop: true,
dashUserName: '',
dashPassword: ''
dashPassword: '',
hideReturnToProject: false
}),
persist: true,
getters: {
getHideReturnToProject(): boolean {
return this.hideReturnToProject
},
getDashUserName(): string {
return this.dashUserName
},
@ -51,6 +55,9 @@ export const useUserStore = defineStore({
}
},
actions: {
setHideReturnToProject(bool: boolean): void {
this.hideReturnToProject = bool
},
setDashUserName(dashUserName: string): void {
this.dashUserName = dashUserName
},

10
dolphinscheduler-ui/src/views/projects/list/components/project-modal.tsx

@ -35,7 +35,7 @@ const props = {
},
statusRef: {
type: Number as PropType<number>,
default: 0
default: -1
},
row: {
type: Object as PropType<any>,
@ -75,9 +75,11 @@ const ProjectModal = defineComponent({
() => {
if (props.statusRef === 0) {
variables.model.projectName = ''
variables.model.userName = (
userStore.getUserInfo as UserInfoRes
).userName
let userName = (userStore.getUserInfo as UserInfoRes).userName
if (userName == null || userName == ''){
userName = userStore.getDashUserName
}
variables.model.userName = userName
variables.model.description = ''
} else {
variables.model.projectName = props.row.name

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

@ -216,7 +216,7 @@ export function useTable() {
searchVal: ref(null),
totalPage: ref(1),
showModalRef: ref(false),
statusRef: ref(0),
statusRef: ref(-1),
row: {},
loadingRef: ref(false)
})

23
dolphinscheduler-ui/src/views/security/user-manage/index.tsx

@ -22,7 +22,7 @@ import {
NIcon,
NSpace,
NDataTable,
NPagination
NPagination, NLayoutHeader
} from 'naive-ui'
import { useI18n } from 'vue-i18n'
import { SearchOutlined } from '@vicons/antd'
@ -31,6 +31,8 @@ import { useTable } from './use-table'
import UserDetailModal from './components/user-detail-modal'
import AuthorizeModal from './components/authorize-modal'
import Card from '@/components/card'
import NavBar from "@/layouts/content/components/navbar";
import {useUserStore} from "@/store/user/user";
const UsersManage = defineComponent({
name: 'user-manage',
@ -66,18 +68,21 @@ const UsersManage = defineComponent({
}
},
render() {
const userStore = useUserStore()
return (
<NSpace vertical>
<Card>
<NSpace justify='space-between'>
<NButton
onClick={this.onAddUser}
type='primary'
class='btn-create-user'
size='small'
>
{this.t('security.user.create_user')}
</NButton>
{/*{userStore.getIsShowTop &&( <NButton*/}
{/* onClick={this.onAddUser}*/}
{/* type='primary'*/}
{/* class='btn-create-user'*/}
{/* size='small'*/}
{/* >*/}
{/* {this.t('security.user.create_user')}*/}
{/* </NButton>*/}
{/*)}*/}
<NSpace>
<NInput
allowInput={this.trim}

221
dolphinscheduler-ui/src/views/security/user-manage/use-columns.ts

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { h, ref, watch, onMounted } from 'vue'
import { h, ref, watch, onMounted, RendererElement, RendererNode, VNode} from 'vue'
import {useI18n} from 'vue-i18n'
import {
NSpace,
@ -33,8 +33,10 @@ import {
DefaultTableWidth
} from '@/common/column-width-config'
import type {TableColumns, InternalRowData} from './types'
import {useUserStore} from "@/store/user/user";
export function useColumns(onCallback: Function) {
const {t} = useI18n()
const columnsRef = ref({
@ -118,8 +120,8 @@ export function useColumns(onCallback: Function) {
key: 'operation',
...COLUMN_WIDTH_CONFIG['operation'](3),
render: (rowData: any, unused: number) => {
return h(NSpace, null, {
default: () => [
const userStore = useUserStore()
let operateArr: VNode<RendererNode, RendererElement, { [key: string]: any }>[] = [
h(
NDropdown,
{
@ -170,59 +172,168 @@ export function useColumns(onCallback: Function) {
}
)
),
h(
NTooltip,
{ trigger: 'hover' },
{
trigger: () =>
h(
NButton,
{
circle: true,
type: 'info',
size: 'small',
class: 'edit',
onClick: () => void onCallback({ rowData }, 'edit')
},
() => h(NIcon, null, () => h(EditOutlined))
),
default: () => t('security.user.edit')
}
),
h(
NPopconfirm,
{
onPositiveClick: () => void onCallback({ rowData }, 'delete')
},
{
trigger: () =>
h(
NTooltip,
{},
{
trigger: () =>
h(
NButton,
{
circle: true,
type: 'error',
size: 'small',
class: 'delete'
},
{
icon: () =>
h(NIcon, null, {
default: () => h(DeleteOutlined)
})
}
),
default: () => t('security.user.delete')
}
),
default: () => t('security.user.delete_confirm')
}
)
]
// if (userStore.getIsShowTop){
// operateArr = [
// h(
// NDropdown,
// {
// trigger: 'click',
// options: [
// {
// label: t('security.user.project'),
// key: 'authorize_project'
// },
// {
// label: t('security.user.resource'),
// key: 'authorize_resource'
// },
// {
// label: t('security.user.datasource'),
// key: 'authorize_datasource'
// },
// { label: t('security.user.udf'), key: 'authorize_udf' },
// {
// label: t('security.user.namespace'),
// key: 'authorize_namespace'
// }
// ],
// onSelect: (key) =>
// void onCallback({ rowData, key }, 'authorize')
// },
// () =>
// h(
// NTooltip,
// {
// trigger: 'hover'
// },
// {
// trigger: () =>
// h(
// NButton,
// {
// circle: true,
// type: 'warning',
// size: 'small',
// class: 'authorize'
// },
// {
// icon: () => h(NIcon, null, () => h(UserOutlined))
// }
// ),
// default: () => t('security.user.authorize')
// }
// )
// ),
// h(
// NTooltip,
// { trigger: 'hover' },
// {
// trigger: () =>
// h(
// NButton,
// {
// circle: true,
// type: 'info',
// size: 'small',
// class: 'edit',
// onClick: () => void onCallback({ rowData }, 'edit')
// },
// () => h(NIcon, null, () => h(EditOutlined))
// ),
// default: () => t('security.user.edit')
// }
// ),
// h(
// NPopconfirm,
// {
// onPositiveClick: () => void onCallback({ rowData }, 'delete')
// },
// {
// trigger: () =>
// h(
// NTooltip,
// {},
// {
// trigger: () =>
// h(
// NButton,
// {
// circle: true,
// type: 'error',
// size: 'small',
// class: 'delete'
// },
// {
// icon: () =>
// h(NIcon, null, {
// default: () => h(DeleteOutlined)
// })
// }
// ),
// default: () => t('security.user.delete')
// }
// ),
// default: () => t('security.user.delete_confirm')
// }
// )
// ]
// }else {
// operateArr = [
// h(
// NDropdown,
// {
// trigger: 'click',
// options: [
// {
// label: t('security.user.project'),
// key: 'authorize_project'
// },
// {
// label: t('security.user.resource'),
// key: 'authorize_resource'
// },
// {
// label: t('security.user.datasource'),
// key: 'authorize_datasource'
// },
// { label: t('security.user.udf'), key: 'authorize_udf' },
// {
// label: t('security.user.namespace'),
// key: 'authorize_namespace'
// }
// ],
// onSelect: (key) =>
// void onCallback({ rowData, key }, 'authorize')
// },
// () =>
// h(
// NTooltip,
// {
// trigger: 'hover'
// },
// {
// trigger: () =>
// h(
// NButton,
// {
// circle: true,
// type: 'warning',
// size: 'small',
// class: 'authorize'
// },
// {
// icon: () => h(NIcon, null, () => h(UserOutlined))
// }
// ),
// default: () => t('security.user.authorize')
// }
// )
// ),
// ]
// }
return h(NSpace, null, {
default: () => operateArr
})
}
}

Loading…
Cancel
Save