Browse Source

(*)最新元数据权限控制

master
peng.peng 2 years ago
parent
commit
136c938340
  1. 67
      web/client/src/sections/metadataManagement/containers/databasesTable.js
  2. 68
      web/client/src/sections/metadataManagement/containers/filesTable.js
  3. 4
      web/client/src/sections/metadataManagement/containers/latestMetadata.js
  4. 50
      web/client/src/sections/metadataManagement/containers/restapisTable.js

67
web/client/src/sections/metadataManagement/containers/databasesTable.js

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Spin, Table, Popconfirm, Button, Input } from 'antd'; import { Spin, Table, Popconfirm, Button, Input, Row, Col } from 'antd';
import { ButtonGroup } from '$components'; import { ButtonGroup } from '$components';
import moment from 'moment'; import moment from 'moment';
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
@ -173,13 +173,18 @@ const DatabaseTable = (props) => {
ra.applyBy == user.id && ra.resourceName === record.name); ra.applyBy == user.id && ra.resourceName === record.name);
return <ButtonGroup> return <ButtonGroup>
<a onClick={() => onView(record)}>查看</a> <a onClick={() => onView(record)}>查看</a>
<a style={{ marginLeft: 10 }} onClick={() => onEdit(record)}>编辑</a> {user.role == '数据消费者' ? null :
<Popconfirm <>
title="是否确认删除该元数据?" <a style={{ marginLeft: 10 }} onClick={() => onEdit(record)}>编辑</a>
onConfirm={() => confirmDelete(record.id)} <Popconfirm
> <a style={{ marginLeft: 10 }}>删除</a></Popconfirm> title="是否确认删除该元数据?"
{record.type === '表' ? <a style={{ marginLeft: 10 }} onClick={() => marking(record.id)}>打标</a> : null} onConfirm={() => confirmDelete(record.id)}
{user.role == '系统管理员' ? '' : record.type === '表' ? resourceApplicationsRecords.length === 0 ? > <a style={{ marginLeft: 10 }}>删除</a></Popconfirm>
{record.type === '表' ? <a style={{ marginLeft: 10 }} onClick={() => marking(record.id)}>打标</a> : null}
</>
}
{user.role !== '数据消费者' ? null : record.type === '表' ? resourceApplicationsRecords.length === 0 ?
<a style={{ marginLeft: 10 }} onClick={() => applyResources(record)}>申请资源</a> : <a style={{ marginLeft: 10 }} onClick={() => applyResources(record)}>申请资源</a> :
<span style={{ marginLeft: 10, color: "#c0c0c0" }} title='已存在资源申请'>申请资源</span> : null} <span style={{ marginLeft: 10, color: "#c0c0c0" }} title='已存在资源申请'>申请资源</span> : null}
</ButtonGroup> </ButtonGroup>
@ -252,27 +257,33 @@ const DatabaseTable = (props) => {
} }
} }
return <Spin spinning={isRequesting}> return <Spin spinning={isRequesting}>
<div style={{ marginBottom: 16 }}> <Row style={{ marginBottom: 16 }}>
<Button type='primary' onClick={() => { <Col span={12}>
dispatch(metadataManagement.getMetadataModels({ modelTypes: ModelTypes.join(',') })).then(res => { {user.role == '数据消费者' ? null : <>
if (res.success) { <Button type='primary' onClick={() => {
setEditData({ add: true, title: '新建库表元数据', record: { path: '/' + resourceCatalogPath.join('/'), type: '目录' } }); dispatch(metadataManagement.getMetadataModels({ modelTypes: ModelTypes.join(',') })).then(res => {
setModalVisible(true); if (res.success) {
setEditData({ add: true, title: '新建库表元数据', record: { path: '/' + resourceCatalogPath.join('/'), type: '目录' } });
setModalVisible(true);
}
})
}}>新建</Button>
{
tableDataCount == 0 ? <Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }} onClick={() => handleExport()}>导出</Button> :
selectedRowKeys && selectedRowKeys.length ?
<Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }} onClick={() => handleExport()}>导出</Button>
: <Popconfirm title={'是否导出全部?'} onConfirm={() => handleExport(true)} okText="确定" cancelText="取消">
<Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }}> 导出</Button>
</Popconfirm>
} }
}) </>}
}}>新建</Button> </Col>
{ <Col span={12} style={{ display: 'flex', justifyContent: 'flex-end' }}>
tableDataCount == 0 ? <Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }} onClick={() => handleExport()}>导出</Button> : <Input style={{ width: 220 }} placeholder="名称/代码/类型"
selectedRowKeys && selectedRowKeys.length ? allowClear onPressEnter={onSearch} onChange={e => setKeywords(e.target.value || '')} />
<Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }} onClick={() => handleExport()}>导出</Button> <Button type='primary' style={{ marginLeft: 16 }} onClick={onSearch}>查询</Button>
: <Popconfirm title={'是否导出全部?'} onConfirm={() => handleExport(true)} okText="确定" cancelText="取消"> </Col>
<Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }}> 导出</Button> </Row >
</Popconfirm>
}
<Button type='primary' style={{ marginLeft: 16, float: 'right' }} onClick={onSearch}>查询</Button>
<Input style={{ width: 220, float: 'right' }} placeholder="名称/代码/类型"
allowClear onPressEnter={onSearch} onChange={e => setKeywords(e.target.value || '')} />
</div >
<Table <Table
scroll={{ y: clientHeight - 320 }} scroll={{ y: clientHeight - 320 }}
rowKey='id' rowKey='id'

68
web/client/src/sections/metadataManagement/containers/filesTable.js

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Spin, Table, Popconfirm, Button, Input } from 'antd'; import { Spin, Table, Popconfirm, Button, Input, Row, Col } from 'antd';
import { ButtonGroup } from '$components'; import { ButtonGroup } from '$components';
import moment from 'moment'; import moment from 'moment';
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
@ -207,12 +207,17 @@ const FilesTable = (props) => {
let resourceApplicationsRecords = metadataResourceApplications.filter(ra => let resourceApplicationsRecords = metadataResourceApplications.filter(ra =>
ra.applyBy == user.id && ra.resourceName === record.name); ra.applyBy == user.id && ra.resourceName === record.name);
return <ButtonGroup> return <ButtonGroup>
<a style={{ marginLeft: 10 }} onClick={() => onEdit(record)}>编辑</a> {user.role == '数据消费者' ? null :
<Popconfirm <>
title="是否确认删除该元数据?" <a style={{ marginLeft: 10 }} onClick={() => onEdit(record)}>编辑</a>
onConfirm={() => confirmDelete(record)} <Popconfirm
> <a style={{ marginLeft: 10 }}>删除</a></Popconfirm> title="是否确认删除该元数据?"
<a style={{ marginLeft: 10 }} onClick={() => marking(record.id)}>打标</a> onConfirm={() => confirmDelete(record)}
><a style={{ marginLeft: 10 }}>删除</a></Popconfirm>
<a style={{ marginLeft: 10 }} onClick={() => marking(record.id)}>打标</a>
</>
}
{user.role == '系统管理员' ? '' : resourceApplicationsRecords.length === 0 ? {user.role == '系统管理员' ? '' : resourceApplicationsRecords.length === 0 ?
<a style={{ marginLeft: 10 }} onClick={() => applyResources(record)}>申请资源</a> : <a style={{ marginLeft: 10 }} onClick={() => applyResources(record)}>申请资源</a> :
<span style={{ marginLeft: 10, color: "#c0c0c0" }} title='已存在资源申请'>申请资源</span>} <span style={{ marginLeft: 10, color: "#c0c0c0" }} title='已存在资源申请'>申请资源</span>}
@ -298,27 +303,34 @@ const FilesTable = (props) => {
} }
} }
return <Spin spinning={isRequesting}> return <Spin spinning={isRequesting}>
<div style={{ marginBottom: 16 }}> <Row style={{ marginBottom: 16 }}>
<Button type='primary' onClick={() => { <Col span={12}>
dispatch(metadataManagement.getMetadataModels({ modelTypes: '文件' })).then(res => { {user.role == '数据消费者' ? null : <>
if (res.success) { <Button type='primary' onClick={() => {
setEditData({ add: true, title: '新建文件元数据', record: {} }); dispatch(metadataManagement.getMetadataModels({ modelTypes: '文件' })).then(res => {
setModalVisible(true); if (res.success) {
} setEditData({ add: true, title: '新建文件元数据', record: {} });
}) setModalVisible(true);
}}>新建</Button> }
{ })
tableDataCount == 0 ? <Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }} onClick={() => handleExport()}>导出</Button> : }}>新建</Button>
selectedRowKeys && selectedRowKeys.length ? {
<Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }} onClick={() => handleExport()}>导出</Button> tableDataCount == 0 ? <Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }} onClick={() => handleExport()}>导出</Button> :
: <Popconfirm title={'是否导出全部?'} onConfirm={() => handleExport(true)} okText="确定" cancelText="取消"> selectedRowKeys && selectedRowKeys.length ?
<Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }}> 导出</Button> <Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }} onClick={() => handleExport()}>导出</Button>
</Popconfirm> : <Popconfirm title={'是否导出全部?'} onConfirm={() => handleExport(true)} okText="确定" cancelText="取消">
} <Button disabled={tableDataCount == 0} style={{ marginLeft: 16 }}> 导出</Button>
<Button type='primary' style={{ marginLeft: 16, float: 'right' }} onClick={onSearch}>查询</Button> </Popconfirm>
<Input style={{ width: 220, float: 'right' }} placeholder="名称/类型" }</>}
allowClear onPressEnter={onSearch} onChange={e => setKeywords(e.target.value || '')} /> </Col>
</div > <Col span={12} style={{ display: 'flex', justifyContent: 'flex-end' }}>
<Input style={{ width: 220 }} placeholder="名称/类型"
allowClear onPressEnter={onSearch} onChange={e => setKeywords(e.target.value || '')} />
<Button type='primary' style={{ marginLeft: 16 }} onClick={onSearch}>查询</Button>
</Col>
</Row>
<Table <Table
scroll={{ y: clientHeight - 320 }} scroll={{ y: clientHeight - 320 }}
rowKey='id' rowKey='id'

4
web/client/src/sections/metadataManagement/containers/latestMetadata.js

@ -183,10 +183,10 @@ const LatestMetadata = (props) => {
<Input style={{ width: 220, marginBottom: 8 }} placeholder="输入资源目录关键字搜索" <Input style={{ width: 220, marginBottom: 8 }} placeholder="输入资源目录关键字搜索"
allowClear onChange={onChangeSearch} allowClear onChange={onChangeSearch}
onKeyPress={onChangeSearch} /> onKeyPress={onChangeSearch} />
<Button type='primary' style={{ marginBottom: 16 }} onClick={() => { {user?.role == '系统管理员' && <Button type='primary' style={{ marginBottom: 16 }} onClick={() => {
setEditData({ title: '新建资源目录', add: true }); setEditData({ title: '新建资源目录', add: true });
setModalVisible(true); setModalVisible(true);
}}>新建资源目录</Button> }}>新建资源目录</Button>}
<Tree <Tree
// showLine // showLine
height={clientHeight - 180} height={clientHeight - 180}

50
web/client/src/sections/metadataManagement/containers/restapisTable.js

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Spin, Table, Popconfirm, Button, Input } from 'antd'; import { Spin, Table, Popconfirm, Button, Input, Row, Col } from 'antd';
import { ButtonGroup } from '$components'; import { ButtonGroup } from '$components';
import MetadataRestapiModal from '../components/metadataRestapiModal'; import MetadataRestapiModal from '../components/metadataRestapiModal';
import MetadataTagModal from '../components/metadataTagModal'; import MetadataTagModal from '../components/metadataTagModal';
@ -143,12 +143,17 @@ const RestapisTable = (props) => {
let resourceApplicationsRecords = metadataResourceApplications.filter(ra => let resourceApplicationsRecords = metadataResourceApplications.filter(ra =>
ra.applyBy == user.id && ra.resourceName === record.name); ra.applyBy == user.id && ra.resourceName === record.name);
return <ButtonGroup> return <ButtonGroup>
<a style={{ marginLeft: 10 }} onClick={() => onEdit(record)}>编辑</a> {user.role == '数据消费者' ? null :
<Popconfirm <>
title="是否确认删除该元数据?" <a style={{ marginLeft: 10 }} onClick={() => onEdit(record)}>编辑</a>
onConfirm={() => confirmDelete(record.id)} <Popconfirm
> <a style={{ marginLeft: 10 }}>删除</a></Popconfirm> title="是否确认删除该元数据?"
<a style={{ marginLeft: 10 }} onClick={() => marking(record.id)}>打标</a> onConfirm={() => confirmDelete(record.id)}
> <a style={{ marginLeft: 10 }}>删除</a></Popconfirm>
<a style={{ marginLeft: 10 }} onClick={() => marking(record.id)}>打标</a>
</>
}
{user.role == '系统管理员' ? '' : resourceApplicationsRecords.length === 0 ? {user.role == '系统管理员' ? '' : resourceApplicationsRecords.length === 0 ?
<a style={{ marginLeft: 10 }} onClick={() => applyResources(record)}>申请资源</a> : <a style={{ marginLeft: 10 }} onClick={() => applyResources(record)}>申请资源</a> :
<span style={{ marginLeft: 10, color: "#c0c0c0" }} title='已存在资源申请'>申请资源</span>} <span style={{ marginLeft: 10, color: "#c0c0c0" }} title='已存在资源申请'>申请资源</span>}
@ -180,19 +185,24 @@ const RestapisTable = (props) => {
} }
} }
return <Spin spinning={isRequesting}> return <Spin spinning={isRequesting}>
<div style={{ marginBottom: 16 }}> <Row style={{ marginBottom: 16 }}>
<Button type='primary' onClick={() => { <Col span={12}>
dispatch(metadataManagement.getMetadataModels({ modelTypes: '接口' })).then(res => { {user.role == '数据消费者' ? null : <> <Button type='primary' onClick={() => {
if (res.success) { dispatch(metadataManagement.getMetadataModels({ modelTypes: '接口' })).then(res => {
setEditData({ add: true, title: '新建接口元数据', record: {} }); if (res.success) {
setModalVisible(true); setEditData({ add: true, title: '新建接口元数据', record: {} });
} setModalVisible(true);
}) }
}}>新建</Button> })
<Button type='primary' style={{ marginLeft: 16, float: 'right' }} onClick={onSearch}>查询</Button> }}>新建</Button></>}
<Input style={{ width: 220, float: 'right' }} placeholder="名称" </Col>
allowClear onPressEnter={onSearch} onChange={e => setKeywords(e.target.value || '')} /> <Col span={12} style={{ display: 'flex', justifyContent: 'flex-end' }}>
</div > <Input style={{ width: 220 }} placeholder="名称"
allowClear onPressEnter={onSearch} onChange={e => setKeywords(e.target.value || '')} />
<Button type='primary' style={{ marginLeft: 16 }} onClick={onSearch}>查询</Button>
</Col>
</Row>
<Table <Table
scroll={{ y: clientHeight - 320 }} scroll={{ y: clientHeight - 320 }}
rowKey='id' rowKey='id'

Loading…
Cancel
Save