-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: 自定义菜单渲染 * fix: 调整布局 * fix: 调试分配权限接口 * fix: 调试角色分配用户 * feat: The role assigned to a user is added * feat:Added a resource configuration role * [Bug][scaleph-security] fix web resource child routes error (#637) fix: child routes error * [Bug][docker] fix scaleph-seatunnel image error (#638) * feature: add doris operator * feature: add web-resource and role relation table * feature: add web-resource and role relation mapper * feature: add web-resource and role relation mapper * fix: seatunnel base image * [Bug][docker] fix scaleph-seatunnel image error (#639) fix: seatunnel base image * [Bug][docker] fix scaleph-seatunnel image error (#640) fix: seatunnel base image * [Bug][docker] fix scaleph-seatunnel image error (#641) fix: seatunnel base image * [Bug][docker] fix scaleph-seatunnel image error (#642) * fix: seatunnel base image * fix: seatunnel base image * [Feature][scaleph-security] add security web resource and role relation api (#644) * fix: seatunnel base image * feature: add resource-web and role relation api * [Feature][scaleph-security] add user and role relation api (#645) * feature: add user and role relation api * feature: add user and role relation api * [Feature][scaleph-engine-doris] add selectdb doris-operator crd (#646) * feature: doris operator crd definition * fix: resource-web and role relation error * [Bug][scaleph-security] fix umi route icon error (#647) * fix: resource-web and role relation error * fix: route icon error * [Feature][scaleph-ui-react] add doris template web under project (#648) * feature: add doris template mapper * feature: add doris template service * feature: add doris template service * feature: add doris template web route * feature: add doris template web * [Feature][scaleph-engine-doris] add doris template steps form (#649) * feature: upgrade flink kubernetes operator to 1.7.0 * feature: add doris template detail web * feature: add doris template detail web * feature: add doris template steps * feature: add doris template steps * feature: add doris template steps route * feature: add doris template component step * fix: knife4j error * fix: knife4j error * fix: knife4j error * fix: knife4j error * [Feature][scaleph-engine-doris] add doris template detail web (#650) * fix: doris template step form item error * feature: add doris template yaml step * feature: add doris template yaml step * feature: add createStatus for doris template * feature: add yaml step for doris template steps * feature: add yaml step for doris template steps * feature: add yaml step for doris template steps * feature: remove doris template createStatus field * feature: refactor doris template step model * feature: add yaml area for doris template detail web * feature: add yaml area for doris template detail web * [Feature][scaleph-engine-doris] add doris instance service (#651) * feature: add doris instance service * feature: add doris instance controller * feature: add doris instance controller * feature: add doris instance web * feature: add doris instance steps * feature: add doris instance steps * feature: add doris instance steps * fix: system nav bar error * [Feature][scaleph-engine-doris] add doris instance steps form web (#652) * fix: user resource * fix: user resource * feature: add doris instance steps form * [Feature][scaleph-engine-doris] add doris instance detail web (#653) * feature: add doris instance detail web * feature: add doris instance detail web * feature: add doris instance detail web * [Release] release 2.0.0-SNAPSHOT --------- Co-authored-by: bailongsen <[email protected]> Co-authored-by: kalencaya <[email protected]>
- Loading branch information
1 parent
6690fff
commit 37601ab
Showing
12 changed files
with
1,121 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useLayoutEffect, useState } from "react"; | ||
import { throttle } from "lodash"; | ||
|
||
export default (mainCl = ".ant-pro-basicLayout-content") => { | ||
const [container, setContainer] = useState<{ height: number; width: number }>({ | ||
width: 100, | ||
height: 100 | ||
}); | ||
// const mainCl = '.ant-pro-basicLayout-content'; | ||
useLayoutEffect(() => { | ||
const handler = throttle(() => { | ||
const rt = document.querySelector(mainCl)?.getBoundingClientRect(); | ||
setContainer({ | ||
height: rt?.height, | ||
width: rt?.width | ||
}); | ||
}, 100); | ||
handler(); | ||
window.addEventListener("resize", handler, false); | ||
return () => { | ||
window.removeEventListener("resize", handler, false); | ||
}; | ||
}, []); | ||
|
||
return container; | ||
}; |
56 changes: 56 additions & 0 deletions
56
scaleph-ui-react/src/pages/Admin/Resource/Web/components/TransferTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Table, Transfer } from 'antd'; | ||
import { difference } from 'lodash'; // 注意这里改为大写的Difference | ||
import React from 'react'; | ||
|
||
// 定义组件的Props类型 | ||
interface Props { | ||
leftColumns: any[]; // 左侧表格列配置数组 | ||
rightColumns: any[]; // 右侧表格列配置数组 | ||
containerHeight: number; // 容器高度 | ||
} | ||
|
||
// 使用React.FC声明函数组件,并传入Props类型 | ||
const TableTransfer: React.FC<Props> = ({ leftColumns, rightColumns, ...restProps }) => ( | ||
<Transfer {...restProps}> | ||
{({ | ||
direction, | ||
filteredItems, | ||
onItemSelectAll, | ||
onItemSelect, | ||
selectedKeys: listSelectedKeys, | ||
disabled: listDisabled, | ||
}) => { | ||
const columns = direction === 'left' ? leftColumns : rightColumns; | ||
// 表格行选择配置 | ||
const rowSelection = { | ||
onSelectAll(selected: boolean, selectedRows: any[]) { | ||
const treeSelectedKeys = selectedRows.map(({ key }) => key); | ||
const diffKeys = selected | ||
? difference(treeSelectedKeys, listSelectedKeys) | ||
: difference(listSelectedKeys, treeSelectedKeys); | ||
onItemSelectAll(diffKeys, selected); | ||
}, | ||
onSelect: ({ id }: { id: string }, selected: boolean) => { | ||
onItemSelect(id, selected); | ||
}, | ||
selectedRowKeys: listSelectedKeys, | ||
}; | ||
|
||
return ( | ||
<Table | ||
scroll={{ y: restProps.containerHeight - 380 }} | ||
rowSelection={rowSelection} | ||
columns={columns} | ||
dataSource={filteredItems} | ||
size="small" | ||
rowKey="id" | ||
pagination={{ | ||
defaultPageSize: 20, | ||
}} | ||
style={{ pointerEvents: listDisabled ? 'none' : null }} | ||
/> | ||
); | ||
}} | ||
</Transfer> | ||
); | ||
export default React.memo(TableTransfer); |
170 changes: 170 additions & 0 deletions
170
scaleph-ui-react/src/pages/Admin/Resource/Web/components/WebAssugnRoles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
import mainHeight from '@/models/useMainSize'; | ||
import { SecResourceWeb } from '@/services/admin/typings'; | ||
import { AuthService } from '@/services/auth'; | ||
import { Button, Card, Form, message, Modal, Space } from 'antd'; | ||
import React, { useCallback, useEffect, useMemo, useState } from 'react'; | ||
import { useIntl } from 'umi'; | ||
import TableTransfer from './TransferTable'; | ||
|
||
// 定义组件 Props 类型 | ||
interface ModalFormParentProps<T> { | ||
data: T; | ||
visible: boolean; | ||
onVisibleChange?: (visible: boolean) => void; | ||
onCancel: () => void; | ||
onOK?: (values: any) => void; | ||
} | ||
|
||
const WebResourceForm: React.FC<ModalFormParentProps<SecResourceWeb>> = ({ | ||
data, | ||
visible, | ||
onVisibleChange, | ||
onCancel, | ||
}) => { | ||
const intl = useIntl(); | ||
const [form] = Form.useForm(); | ||
const containerInfo = mainHeight('.ant-layout-content'); | ||
const [roleLists, setRoleLists] = useState<Role[]>([]); | ||
|
||
// 角色表格列配置 | ||
const tableColumns = [ | ||
{ | ||
dataIndex: 'name', | ||
title: '角色名称', | ||
width: 300, | ||
}, | ||
{ | ||
dataIndex: 'desc', | ||
title: '描述', | ||
width: 300, | ||
}, | ||
]; | ||
|
||
// 角色类型定义 | ||
interface Role { | ||
id: string; | ||
name: string; | ||
resourceAuthorized: number; | ||
checkOut?: number; | ||
} | ||
|
||
// 合并数组 | ||
function mergeArrays(array1: Role[], array2: Role[]): Role[] { | ||
array1.forEach((obj, index) => { | ||
obj.checkOut = 0; | ||
}); | ||
array2.forEach((obj, index) => { | ||
obj.checkOut = 1; | ||
}); | ||
return [...array1, ...array2]; | ||
} | ||
|
||
// 异步获取数据 | ||
const fetchData = useCallback(async () => { | ||
try { | ||
const res1 = await AuthService.unauthorizedRoles({ resourceWebId: data?.id }); | ||
const res2 = await AuthService.authorizedRoles({ resourceWebId: data?.id }); | ||
if (res1?.records && res2?.records) { | ||
const mergedArray = mergeArrays(res1.records, res2.records); | ||
setRoleLists(mergedArray); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}, [data]); | ||
|
||
useEffect(() => { | ||
if (data) { | ||
fetchData(); | ||
} | ||
}, [data, fetchData]); | ||
|
||
// 页面标题 | ||
const returnTitle = useMemo(() => { | ||
return ( | ||
<Space direction="vertical"> | ||
<span>{` ${intl.formatMessage({ id: `menu.${data?.name}` })}-资源分配详情`}</span> | ||
</Space> | ||
); | ||
}, [data, intl]); | ||
|
||
// 获取选中角色的 id 数组 | ||
const originTargetKeys = useMemo(() => { | ||
return roleLists?.filter((item) => item.checkOut === 1).map((item) => item.id); | ||
}, [roleLists]); | ||
|
||
// 过滤方法 | ||
const handleFilter = useCallback((inputValue, item) => { | ||
return item?.name.indexOf(inputValue) !== -1; | ||
}, []); | ||
|
||
// 角色转移事件处理 | ||
const handleChange = useCallback( | ||
async (targetKeys, direction, moveKeys) => { | ||
const roleIds = moveKeys.map((item: string | number) => +item); | ||
const params = { | ||
resourceWebId: data?.id, | ||
roleIds: roleIds, | ||
}; | ||
if (direction === 'right') { | ||
// 绑定角色资源 | ||
await AuthService.resourceWebRoles(params).then((res) => { | ||
if (res?.success) { | ||
message.success(intl.formatMessage({ id: 'app.common.operate.edit.success' }), 2); | ||
} | ||
}); | ||
} else { | ||
// 删除绑定的角色资源 | ||
await AuthService.resourceWebRolesDelete(params).then((res) => { | ||
message.success(intl.formatMessage({ id: 'app.common.operate.edit.success' }), 2); | ||
}); | ||
} | ||
fetchData(); | ||
}, | ||
[data, fetchData, intl], | ||
); | ||
|
||
return ( | ||
<Modal | ||
open={visible} | ||
title={data.id ? intl.formatMessage({ id: 'app.common.operate.new.roles' }) : ''} | ||
width={1100} | ||
destroyOnClose={true} | ||
onCancel={onCancel} | ||
cancelText={intl.formatMessage({ id: 'app.common.operate.close.label' })} | ||
centered | ||
footer={[ | ||
<Button type="primary" onClick={onCancel}> | ||
{intl.formatMessage({ id: 'app.common.operate.close.label' })} | ||
</Button>, | ||
]} | ||
> | ||
<div> | ||
<Card | ||
bodyStyle={{ | ||
minHeight: `${containerInfo.height - 200}px`, | ||
}} | ||
title={returnTitle} | ||
> | ||
<TableTransfer | ||
containerHeight={containerInfo.height} | ||
titles={[intl.formatMessage({ id: 'app.common.operate.new.notAccreditRoles' }), intl.formatMessage({ id: 'app.common.operate.new.accreditRoles' })]} | ||
dataSource={roleLists} | ||
targetKeys={originTargetKeys} | ||
showSearch={true} | ||
rowKey={(record: { id: any }) => record.id} | ||
onChange={handleChange} | ||
filterOption={handleFilter} | ||
listStyle={{ | ||
width: 500, | ||
}} | ||
leftColumns={tableColumns} | ||
rightColumns={tableColumns} | ||
/> | ||
</Card> | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default WebResourceForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.