Commit 65b166ad by zhaochengxiang

资产全文检索

parent b0579fa4
...@@ -28,6 +28,8 @@ export default class App extends React.Component { ...@@ -28,6 +28,8 @@ export default class App extends React.Component {
id = params.id||''; id = params.id||'';
} }
console.log('params', params);
if (message === 'showDataModelDetail') { if (message === 'showDataModelDetail') {
return ( return (
<ImportModal <ImportModal
......
...@@ -94,3 +94,7 @@ export function* loadDataAssets(payload) { ...@@ -94,3 +94,7 @@ export function* loadDataAssets(payload) {
export function* unloadDataAssets(payload) { export function* unloadDataAssets(payload) {
return yield call(service.unloadDataAssets, payload); return yield call(service.unloadDataAssets, payload);
} }
export function* getDataAssetLocation(payload) {
return yield call(service.getDataAssetLocation, payload);
}
\ No newline at end of file
...@@ -9,7 +9,7 @@ export const routes = [ ...@@ -9,7 +9,7 @@ export const routes = [
{ {
name: 'manage', name: 'manage',
text: '数据管理', text: '数据管理',
redirect: 'map', redirect: 'asset-map',
children: [ children: [
{ {
name: 'datasource-manage', name: 'datasource-manage',
......
...@@ -60,6 +60,10 @@ export function unloadDataAssets(payload) { ...@@ -60,6 +60,10 @@ export function unloadDataAssets(payload) {
return PostJSON("/dataassetmanager/dataAssetApi/unloadDataAssets", payload); return PostJSON("/dataassetmanager/dataAssetApi/unloadDataAssets", payload);
} }
export function getDataAssetLocation(payload) {
return GetJSON("/dataassetmanager/dataAssetApi/locateDataAssetById", payload);
}
export function addOrUpdateDirectory(payload) { export function addOrUpdateDirectory(payload) {
return PostJSON("/dataassetmanager/directoryApi/addOrUpdateDirectory", payload); return PostJSON("/dataassetmanager/directoryApi/addOrUpdateDirectory", payload);
} }
......
export const AnchorId = 'id'; export const AnchorId = 'id';
export const AnchorTimestamp = 'timestamp'; export const AnchorTimestamp = 'timestamp';
export const AnchorDid = 'did';
export const AnchorLocation = 'location';
\ No newline at end of file
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Modal, Typography } from "antd"; import { Modal, Typography, Spin } from "antd";
import AssetItem from './AssetItem'; import AssetDetailItem from './AssetDetailItem';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
const AssetDetail = (props)=>{ const AssetDetail = (props)=>{
...@@ -9,6 +9,7 @@ const AssetDetail = (props)=>{ ...@@ -9,6 +9,7 @@ const AssetDetail = (props)=>{
const { onCancel, visible, id, reference=null } = props; const { onCancel, visible, id, reference=null } = props;
const [ asset, setAsset ] = useState(''); const [ asset, setAsset ] = useState('');
const [ assetName, setAssetName ] = useState(''); const [ assetName, setAssetName ] = useState('');
const [ loading, setLoading ] = useState(false);
useEffect(() => { useEffect(() => {
...@@ -16,17 +17,22 @@ const AssetDetail = (props)=>{ ...@@ -16,17 +17,22 @@ const AssetDetail = (props)=>{
getAssetThenGetAssetName(); getAssetThenGetAssetName();
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ visible ]) }, [ visible, id ])
const getAssetThenGetAssetName = () => { const getAssetThenGetAssetName = () => {
setLoading(true);
dispatch({ dispatch({
type: 'assetmanage.getDataAssetDetail', type: 'assetmanage.getDataAssetDetail',
payload: { payload: {
dataAssetId: id dataAssetId: id
}, },
callback: data => { callback: data => {
setLoading(false);
setAsset(data); setAsset(data);
getAssetName(data); getAssetName(data);
},
error: () => {
setLoading(false);
} }
}) })
} }
...@@ -57,11 +63,15 @@ const AssetDetail = (props)=>{ ...@@ -57,11 +63,15 @@ const AssetDetail = (props)=>{
onCancel={()=>{ onCancel && onCancel()}} onCancel={()=>{ onCancel && onCancel()}}
footer={null} footer={null}
> >
<AssetItem data={asset} /> <Spin spinning={loading}>
<AssetDetailItem data={asset} />
</Spin>
</Modal> </Modal>
} }
{ {
reference && <AssetItem data={asset} /> reference && <Spin spinning={loading}>
<AssetDetailItem data={asset} />
</Spin>
} }
</> </>
) )
......
import React, { useEffect, useState } from 'react';
import { Avatar, Row, Col, Typography, Divider } from 'antd';
import './AssetItem.less';
const colors = [
'#BDD2FD',
'#C2C8D5',
'#FBE5A2',
'#F6C3B7',
'#B6E3F5',
'#D3C6EA',
'#FFD8B8',
'#AAD8D8',
'#FFD6E7',
];
const AssetItem = (props) => {
const { data } = props;
const [ typesOfElements, setTypesOfElements ] = useState([]);
useEffect(() => {
if (data) {
convertData();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ data ]);
const convertData = () => {
const _typesOfElements = [];
const _types = [];
data && (data.elements||[]).forEach(element => {
if (_types.indexOf(element.type||'') === -1) {
_types.push(element.type||'');
const _elements = (data.elements||[]).filter(_element => (_element.type||'') === (element.type||''));
_typesOfElements.push({ type: element.type||'', elements: _elements||[] });
}
})
setTypesOfElements(_typesOfElements);
}
return (
<div className='asset-item'>
{
(typesOfElements||[]).map((typeOfElements, index) => {
const _type = typeOfElements.type||'';
return (
<div key={index} className='d-flex' style={{ alignItems: 'center' }}>
<Avatar
className='mr-3'
title={_type}
style={{
backgroundColor: colors[index%colors.length]
}}
>
{ _type==='' ? '无' : _type.slice(0, 2) }
</Avatar>
<div className='textOverflow' style={{ flex: 1 }}>
<Row className='mb-3'>
{
typeOfElements && typeOfElements.elements && typeOfElements.elements.map((element, _index) => {
return (
<Col className='mt-3' key={_index} md={8}>
<Typography.Paragraph title={ `${element.name||''}: ${element.value||''}` } ellipsis>
{ `${element.name||''}: ${element.value||''}` }
</Typography.Paragraph>
</Col>
);
})
}
</Row>
{ index !== ((typesOfElements||[]).length-1) && <Divider /> }
</div>
</div>
)
})
}
</div>
);
}
export default AssetItem;
...@@ -12,7 +12,7 @@ import AssetDetail from "./AssetDetail" ...@@ -12,7 +12,7 @@ import AssetDetail from "./AssetDetail"
import AssetItem from './AssetItem'; import AssetItem from './AssetItem';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { showMessage, showNotifaction, getQueryParam } from '../../../../util'; import { showMessage, showNotifaction, getQueryParam } from '../../../../util';
import { AnchorId, AnchorLocation } from '../../../../util/constant'; import { AnchorId, AnchorTimestamp } from '../../../../util/constant';
import "./AssetTable.less"; import "./AssetTable.less";
...@@ -40,7 +40,7 @@ const AssetTable = (props) => { ...@@ -40,7 +40,7 @@ const AssetTable = (props) => {
const [ modal, contextHolder ] = Modal.useModal(); const [ modal, contextHolder ] = Modal.useModal();
const anchorId = getQueryParam(AnchorId, props.location.search); const anchorId = getQueryParam(AnchorId, props.location.search);
const anchorLocation = Number(getQueryParam(AnchorLocation, props.location.search)); const timestamp = getQueryParam(AnchorTimestamp, props.location.search);
const shouldScrollRef = useRef(false); const shouldScrollRef = useRef(false);
...@@ -49,8 +49,7 @@ const AssetTable = (props) => { ...@@ -49,8 +49,7 @@ const AssetTable = (props) => {
if (shouldScrollRef.current === true) { if (shouldScrollRef.current === true) {
const _pageNum = parseInt(anchorLocation/pageSize + ((anchorLocation%pageSize===0)?0:1)); getDataAssetLocation();
setPagination({ ...pagination, pageNum: _pageNum });
} else { } else {
...@@ -72,8 +71,7 @@ const AssetTable = (props) => { ...@@ -72,8 +71,7 @@ const AssetTable = (props) => {
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [anchorId]) }, [timestamp])
useEffect(() => { useEffect(() => {
if ((nodeId||'') !== '' ) { if ((nodeId||'') !== '' ) {
...@@ -105,6 +103,24 @@ const AssetTable = (props) => { ...@@ -105,6 +103,24 @@ const AssetTable = (props) => {
} }
}) })
const getDataAssetLocation = () => {
setLoading(true);
dispatch({
type: 'assetmanage.getDataAssetLocation',
payload: {
dataAssetId: anchorId
},
callback: data => {
const anchorLocation = data.offset;
const _pageNum = parseInt(anchorLocation/pageSize + ((anchorLocation%pageSize===0)?0:1));
setPagination({ ...pagination, pageNum: _pageNum });
},
error: () => {
setLoading(false);
}
});
}
const changeCurrent = (page,size) => { const changeCurrent = (page,size) => {
setCheckAllValue(false); setCheckAllValue(false);
setSelectedKeys([]); setSelectedKeys([]);
......
...@@ -8,12 +8,12 @@ import ImportDirectory from './ImportDirectory'; ...@@ -8,12 +8,12 @@ import ImportDirectory from './ImportDirectory';
import UpdateDirectoryModal from './UpdateDirectoryModal'; import UpdateDirectoryModal from './UpdateDirectoryModal';
import CustomDirectoryModal from './CustomDirectoryModal'; import CustomDirectoryModal from './CustomDirectoryModal';
import { showMessage, getQueryParam } from '../../../../util'; import { showMessage, getQueryParam } from '../../../../util';
import { AnchorDid } from '../../../../util/constant'; import { AnchorTimestamp, AnchorId } from '../../../../util/constant';
import './AssetTree.less'; import './AssetTree.less';
const AssetTree = (props) => { const AssetTree = (props) => {
const { readOnly = false, onSelect, className, ...restProps } = props; const { readOnly = false, onSelect, className } = props;
const [ keyword, setKeyword ] = useState(''); const [ keyword, setKeyword ] = useState('');
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
const [ treeData, setTreeData ] = useState([]); const [ treeData, setTreeData ] = useState([]);
...@@ -30,12 +30,33 @@ const AssetTree = (props) => { ...@@ -30,12 +30,33 @@ const AssetTree = (props) => {
const [modal, contextHolder] = Modal.useModal(); const [modal, contextHolder] = Modal.useModal();
const did = getQueryParam(AnchorDid, props.location.search); const timestamp = getQueryParam(AnchorTimestamp, props.location.search);
const id = getQueryParam(AnchorId, props.location.search);
useEffect(() => { useEffect(() => {
getAllDirectoryAsTree(true, did); if ((id||'') !== '') {
getDataAssetLocationThenGetTreeData();
} else {
getAllDirectoryAsTree(true);
}
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [did]) }, [timestamp])
const getDataAssetLocationThenGetTreeData = () => {
setLoading(true);
dispatch({
type: 'assetmanage.getDataAssetLocation',
payload: {
dataAssetId: id
},
callback: data => {
getAllDirectoryAsTree(true, data.dirId||'');
},
error: () => {
setLoading(false);
}
});
}
const getAllDirectoryAsTree = (resetCurrentDirId=true, defaultSelectedId='') => { const getAllDirectoryAsTree = (resetCurrentDirId=true, defaultSelectedId='') => {
setLoading(true); setLoading(true);
...@@ -365,7 +386,6 @@ const AssetTree = (props) => { ...@@ -365,7 +386,6 @@ const AssetTree = (props) => {
bodyStyle={{ padding:10 }} bodyStyle={{ padding:10 }}
headStyle={{ padding:10 }} headStyle={{ padding:10 }}
style={{ width: '100%' }} style={{ width: '100%' }}
{...restProps}
> >
<Spin spinning={loading}> <Spin spinning={loading}>
<Input <Input
......
...@@ -31,14 +31,14 @@ const ModelTree = (props) => { ...@@ -31,14 +31,14 @@ const ModelTree = (props) => {
useEffect(() => { useEffect(() => {
if ((id||'') !== '') { if ((id||'') !== '') {
getDataModelLocation(); getDataModelLocationThenGetTreeData();
} else { } else {
getTreeData(); getTreeData();
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [timestamp]) }, [timestamp])
const getDataModelLocation = () => { const getDataModelLocationThenGetTreeData = () => {
setLoading(true); setLoading(true);
dispatch({ dispatch({
type: 'datamodel.getDataModelLocation', type: 'datamodel.getDataModelLocation',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment