Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
9cf34768
Commit
9cf34768
authored
Feb 22, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产浏览
parent
920fa8c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
129 deletions
+148
-129
Relation.jsx
src/view/Manage/AssetBrowse/Component/Relation.jsx
+44
-26
RelationContainer.jsx
src/view/Manage/AssetBrowse/Component/RelationContainer.jsx
+95
-100
index.jsx
src/view/Manage/AssetBrowse/index.jsx
+9
-3
No files found.
src/view/Manage/AssetBrowse/Component/Relation.jsx
View file @
9cf34768
...
@@ -19,7 +19,7 @@ class Relation extends React.Component {
...
@@ -19,7 +19,7 @@ class Relation extends React.Component {
// }
// }
componentDidUpdate
(
prevProps
,
prevState
)
{
componentDidUpdate
(
prevProps
,
prevState
)
{
const
{
data
,
onClick
}
=
this
.
props
;
const
{
data
,
onC
enterClick
,
onExpandC
lick
}
=
this
.
props
;
if
(
data
)
{
if
(
data
)
{
...
@@ -27,7 +27,7 @@ class Relation extends React.Component {
...
@@ -27,7 +27,7 @@ class Relation extends React.Component {
const
newData
=
JSON
.
parse
(
JSON
.
stringify
(
data
));
const
newData
=
JSON
.
parse
(
JSON
.
stringify
(
data
));
this
.
graph
?.
destroy
();
this
.
graph
?.
destroy
();
this
.
graph
=
init
(
this
)(
this
.
elem
,
newData
,
onClick
);
this
.
graph
=
init
(
this
)(
this
.
elem
,
newData
,
onC
enterClick
,
onExpandC
lick
);
}
}
}
}
...
@@ -45,7 +45,7 @@ class Relation extends React.Component {
...
@@ -45,7 +45,7 @@ class Relation extends React.Component {
export
default
Relation
;
export
default
Relation
;
const
init
=
(
ctx
)
=>
function
(
container
,
data
,
onClick
)
{
const
init
=
(
ctx
)
=>
function
(
container
,
data
,
onC
enterClick
,
onExpandC
lick
)
{
const
width
=
container
.
scrollWidth
;
const
width
=
container
.
scrollWidth
;
const
height
=
container
.
scrollHeight
;
const
height
=
container
.
scrollHeight
;
...
@@ -70,7 +70,12 @@ const init = (ctx) => function (container, data, onClick) {
...
@@ -70,7 +70,12 @@ const init = (ctx) => function (container, data, onClick) {
y
:
0
,
y
:
0
,
});
});
view
.
data
([]);
const
data
=
[
{
type
:
'expand'
,
value
:
50
},
{
type
:
'center'
,
value
:
50
}
];
view
.
data
(
data
);
view
.
coordinate
(
'theta'
,
{
view
.
coordinate
(
'theta'
,
{
radius
:
1.0
,
radius
:
1.0
,
...
@@ -92,7 +97,12 @@ const init = (ctx) => function (container, data, onClick) {
...
@@ -92,7 +97,12 @@ const init = (ctx) => function (container, data, onClick) {
view
.
on
(
'element:click'
,
evt
=>
{
view
.
on
(
'element:click'
,
evt
=>
{
const
{
data
}
=
evt
;
const
{
data
}
=
evt
;
onClick
&&
onClick
(
data
?.
data
?.
type
,
cfg
.
id
);
if
(
data
?.
data
?.
type
===
'center'
)
{
onCenterClick
&&
onCenterClick
(
cfg
.
id
);
}
else
if
(
data
?.
data
?.
type
===
'expand'
)
{
onExpandClick
&&
onExpandClick
(
cfg
.
id
);
}
})
})
view
.
render
();
view
.
render
();
...
@@ -120,7 +130,7 @@ const init = (ctx) => function (container, data, onClick) {
...
@@ -120,7 +130,7 @@ const init = (ctx) => function (container, data, onClick) {
cursor
:
'pointer'
,
cursor
:
'pointer'
,
img
:
actionImg
,
img
:
actionImg
,
},
},
name
:
'
next
-icon'
,
name
:
'
expand
-icon'
,
});
});
imageShape1
.
hide
();
imageShape1
.
hide
();
...
@@ -153,36 +163,46 @@ const init = (ctx) => function (container, data, onClick) {
...
@@ -153,36 +163,46 @@ const init = (ctx) => function (container, data, onClick) {
fill
:
"#fff"
,
fill
:
"#fff"
,
cursor
:
'pointer'
,
cursor
:
'pointer'
,
},
},
name
:
'text'
,
draggable
:
true
draggable
:
true
});
});
return
keyShape
;
return
keyShape
;
},
},
afterDraw
:
(
cfg
,
group
)
=>
{
const
pathShape1
=
group
.
get
(
'children'
)[
1
];
const
pathShape2
=
group
.
get
(
'children'
)[
2
];
const
pathShape3
=
group
.
get
(
'children'
)[
3
];
pathShape1
?.
hide
();
pathShape2
?.
hide
();
pathShape3
?.
hide
();
},
setState
(
name
,
value
,
item
)
{
setState
(
name
,
value
,
item
)
{
const
group
=
item
.
getContainer
();
const
group
=
item
.
getContainer
();
const
keyShape
=
group
.
get
(
'children'
)[
0
];
const
keyShape
=
group
.
get
(
'children'
)[
0
];
const
pathShape1
=
group
.
get
(
'children'
)[
1
];
const
pathShape2
=
group
.
get
(
'children'
)[
2
];
const
pathShape3
=
group
.
get
(
'children'
)[
3
];
const
imageShape1
=
group
.
get
(
'children'
)[
4
];
const
imageShape1
=
group
.
get
(
'children'
)[
4
];
const
imageShape2
=
group
.
get
(
'children'
)[
5
];
const
imageShape2
=
group
.
get
(
'children'
)[
5
];
if
(
name
===
'active'
)
{
if
(
name
===
'active'
)
{
if
(
value
)
{
if
(
value
)
{
keyShape
?.
attr
(
'fill'
,
'#fff'
);
keyShape
?.
attr
(
'fill'
,
'#fff'
);
const
view
=
keyShape
.
get
(
'intervalView'
);
const
data
=
[
{
type
:
'center'
,
value
:
50
},
{
type
:
'next'
,
value
:
50
}
];
view
?.
changeData
(
data
);
pathShape1
?.
show
();
pathShape2
?.
show
();
pathShape3
?.
show
();
imageShape1
?.
show
();
imageShape1
?.
show
();
imageShape2
?.
show
();
imageShape2
?.
show
();
}
else
{
}
else
{
keyShape
?.
attr
(
'fill'
,
null
);
keyShape
?.
attr
(
'fill'
,
null
);
const
view
=
keyShape
?.
get
(
'intervalView'
);
view
?.
changeData
([]);
pathShape1
?.
hide
();
pathShape2
?.
hide
();
pathShape3
?.
hide
();
imageShape1
?.
hide
();
imageShape1
?.
hide
();
imageShape2
?.
hide
();
imageShape2
?.
hide
();
}
}
...
@@ -245,7 +265,7 @@ const init = (ctx) => function (container, data, onClick) {
...
@@ -245,7 +265,7 @@ const init = (ctx) => function (container, data, onClick) {
graph
.
node
(
function
(
node
)
{
graph
.
node
(
function
(
node
)
{
return
{
return
{
label
:
fittingString
(
node
.
id
||
''
,
innerRaduis
*
2
-
4.0
,
textFontSize
),
label
:
fittingString
(
node
.
text
||
''
,
innerRaduis
*
2
-
4.0
,
textFontSize
),
};
};
});
});
...
@@ -273,17 +293,15 @@ const init = (ctx) => function (container, data, onClick) {
...
@@ -273,17 +293,15 @@ const init = (ctx) => function (container, data, onClick) {
});
});
graph
.
on
(
'node:click'
,
function
(
e
)
{
graph
.
on
(
'node:click'
,
function
(
e
)
{
const
item
=
e
.
item
;
const
model
=
item
?.
getModel
();
console
.
log
(
'e.target?.cfg?.name'
,
e
.
target
?.
cfg
?.
name
);
if
(
e
.
target
?.
cfg
?.
name
===
'center-icon'
)
{
if
(
e
.
target
?.
cfg
?.
name
===
'center-icon'
)
{
onCenterClick
&&
onCenterClick
(
model
?.
id
);
}
else
{
}
else
if
(
e
.
target
?.
cfg
?.
name
===
'expand-icon'
||
e
.
target
?.
cfg
?.
name
===
'innnerCircle'
||
e
.
target
?.
cfg
?.
name
===
'text'
)
{
onExpandClick
&&
onExpandClick
(
model
?.
id
);
}
}
// const item = e.item;
// const model = item.getModel();
// onClick && onClick(model);
})
})
function
clearAllStats
()
{
function
clearAllStats
()
{
...
...
src/view/Manage/AssetBrowse/Component/RelationContainer.jsx
View file @
9cf34768
import
{
useEffect
,
useState
}
from
'react'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
dispatch
}
from
'../../../../model'
;
import
Relation
from
'./Relation'
;
import
Relation
from
'./Relation'
;
const
data
=
{
const
RelationContainer
=
(
props
)
=>
{
"id"
:
"Modeling Methods"
,
"children"
:
[
{
"id"
:
"Classification"
,
"children"
:
[
{
"id"
:
"Logistic regression"
},
{
"id"
:
"Linear discriminant analysis"
},
{
"id"
:
"Rules"
},
{
"id"
:
"Decision trees"
},
{
"id"
:
"Naive Bayes"
},
{
"id"
:
"K nearest neighbor"
},
{
"id"
:
"Probabilistic neural network"
},
{
"id"
:
"Support vector machine"
}
]
},
{
"id"
:
"Consensus"
,
"children"
:
[
{
"id"
:
"Models diversity"
,
"children"
:
[
{
"id"
:
"Different initializations"
},
{
"id"
:
"Different parameter choices"
},
{
"id"
:
"Different architectures"
},
{
"id"
:
"Different modeling methods"
},
{
"id"
:
"Different training sets"
},
{
"id"
:
"Different feature sets"
}
]
},
{
"id"
:
"Methods"
,
"children"
:
[
{
"id"
:
"Classifier selection"
},
{
"id"
:
"Classifier fusion"
}
]
},
{
"id"
:
"Common"
,
"children"
:
[
{
"id"
:
"Bagging"
},
{
"id"
:
"Boosting"
},
{
"id"
:
"AdaBoost"
}
]
}
]
},
{
"id"
:
"Regression"
,
"children"
:
[
{
"id"
:
"Multiple linear regression"
},
{
"id"
:
"Partial least squares"
},
{
"id"
:
"Multi-layer feedforward neural network"
},
{
"id"
:
"General regression neural network"
},
{
"id"
:
"Support vector regression"
}
]
}
]
};
function
App
()
{
const
{
nodeParams
,
onChange
}
=
props
;
const
[
dirs
,
setDirs
]
=
useState
([]);
const
[
nodes
,
setNodes
]
=
useState
([]);
const
[
nodes
,
setNodes
]
=
useState
([]);
const
[
relationData
,
setRelationData
]
=
useState
(
null
);
useEffect
(()
=>
{
getDirectoryData
();
},
[])
const
[
relationParams
,
setRelationParams
]
=
useState
({
relationData
:
{},
reload
:
false
});
useEffect
(()
=>
{
const
{
relationData
,
reload
}
=
relationParams
;
generateNodes
();
},
[
dirs
])
useEffect
(()
=>
{
useEffect
(()
=>
{
let
newNodes
=
[{
id
:
data
.
id
,
pid
:
''
,
levelId
:
'0'
,
simple
:
false
,
show
:
true
}];
generateRelationData
();
},
[
nodeParams
])
function
recursion
(
subData
,
parentId
,
parentLevelId
)
{
// if (parentLevelId.split('-').length > 2) return;
const
getDirectoryData
=
()
=>
{
dispatch
({
type
:
'assetmanage.queryAllDirectoryAsTree'
,
callback
:
data
=>
{
let
newDirs
=
[...
data
];
newDirs
=
(
newDirs
||
[]).
filter
(
item
=>
item
.
type
!==
'custom'
);
setDirs
(
newDirs
);
}
});
}
(
subData
||
[]).
forEach
((
item
,
index
)
=>
{
const
generateNodes
=
()
=>
{
let
currentLevelId
=
`
${
parentLevelId
}
-
${
index
}
`
;
let
newNodes
=
[];
newNodes
.
push
({
id
:
item
.
id
,
pid
:
parentId
,
levelId
:
currentLevelId
,
simple
:
(
currentLevelId
.
split
(
'-'
).
length
>=
3
)?
true
:
false
,
show
:
(
currentLevelId
.
split
(
'-'
).
length
>
3
)?
false
:
true
});
function
recursion
(
data
,
parentId
,
parentLevelId
)
{
(
data
||
[]).
forEach
((
item
,
index
)
=>
{
let
currentLevelId
=
(
parentLevelId
)?
`
${
parentLevelId
}
-
${
index
}
`
:
`
${
index
}
`
;
newNodes
.
push
({
id
:
item
.
nodeId
,
pid
:
parentId
,
levelId
:
currentLevelId
,
simple
:
(
currentLevelId
.
split
(
'-'
).
length
>=
3
)?
true
:
false
,
show
:
(
currentLevelId
.
split
(
'-'
).
length
>
3
)?
false
:
true
,
text
:
item
.
text
});
recursion
(
item
.
children
,
item
.
i
d
,
currentLevelId
);
recursion
(
item
.
children
,
item
.
nodeI
d
,
currentLevelId
);
})
})
}
}
recursion
(
d
ata
.
children
,
data
.
id
,
'0'
);
recursion
(
d
irs
,
null
,
null
);
setNodes
(
newNodes
);
setNodes
(
newNodes
);
generateRelationData
(
newNodes
);
generateRelationData
(
newNodes
);
},
[])
}
const
generateRelationData
=
(
data
=
nodes
)
=>
{
if
((
nodeParams
?.
expandId
||
''
)
!==
''
)
{
generateExpandNodeRelationData
(
data
);
}
else
if
((
nodeParams
?.
centerId
||
''
)
!==
''
)
{
generateCenterNodeRelationData
(
data
);
}
else
{
setRelationData
(
null
);
}
}
const
generateCenterNodeRelationData
=
(
data
=
nodes
)
=>
{
if
((
data
||
[]).
length
===
0
)
{
setRelationData
(
null
);
return
;
}
const
generateRelationData
=
(
nodes
,
reload
=
true
)
=>
{
const
index
=
(
data
||
[]).
findIndex
(
node
=>
node
.
id
===
nodeParams
?.
centerId
);
const
rootNode
=
nodes
[
0
];
if
(
index
!==
-
1
)
{
let
newRelationData
=
{...
rootNode
,
children
:
[]};
const
rootNode
=
data
[
index
];
let
newRelationData
=
{...
rootNode
,
children
:
[]};
function
recursion
(
subData
,
parentId
)
{
function
recursion
(
subData
,
parentId
)
{
(
nodes
||
[]).
forEach
(
node
=>
{
if
(
!
node
.
show
)
return
;
if
(
node
.
pid
===
parentId
)
{
(
data
||
[]).
forEach
(
node
=>
{
if
(
!
node
.
show
)
return
;
let
newNode
=
{
...
node
,
children
:
[]
};
if
(
node
.
pid
===
parentId
)
{
(
subData
||
[]).
push
(
newNode
);
let
newNode
=
{
...
node
,
children
:
[]
};
recursion
(
newNode
.
children
,
newNode
.
id
);
}
})
}
recursion
(
newRelationData
.
children
,
rootNode
.
id
);
(
subData
||
[]).
push
(
newNode
);
recursion
(
newNode
.
children
,
newNode
.
id
);
}
})
}
recursion
(
newRelationData
.
children
,
rootNode
.
id
);
setRelationParams
({
relationData
:
newRelationData
,
reload
});
setRelationData
(
newRelationData
);
}
}
}
const
onClick
=
(
type
,
id
)
=>
{
const
generateExpandNodeRelationData
=
(
data
=
nodes
)
=>
{
// console.log('type', type);
if
((
data
||
[]).
length
===
0
)
{
// console.log('id', id);
setRelationData
(
null
);
return
;
}
const
index
=
(
nodes
||
[]).
findIndex
((
node
)
=>
node
.
id
===
i
d
);
const
index
=
(
data
||
[]).
findIndex
((
node
)
=>
node
.
id
===
nodeParams
?.
expandI
d
);
if
(
index
!==
-
1
)
{
if
(
index
!==
-
1
)
{
const
currentNode
=
nodes
[
index
];
const
currentNode
=
data
[
index
];
(
nodes
||
[]).
forEach
(
node
=>
{
(
data
||
[]).
forEach
(
node
=>
{
if
(((
node
.
levelId
.
split
(
'-'
).
length
===
currentNode
.
levelId
.
split
(
'-'
).
length
+
1
)
||
(
node
.
levelId
.
split
(
'-'
).
length
===
currentNode
.
levelId
.
split
(
'-'
).
length
+
2
))
&&
node
.
levelId
.
slice
(
0
,
currentNode
.
levelId
.
length
)
===
currentNode
.
levelId
)
{
if
(((
node
.
levelId
.
split
(
'-'
).
length
===
currentNode
.
levelId
.
split
(
'-'
).
length
+
1
)
||
(
node
.
levelId
.
split
(
'-'
).
length
===
currentNode
.
levelId
.
split
(
'-'
).
length
+
2
))
&&
node
.
levelId
.
slice
(
0
,
currentNode
.
levelId
.
length
)
===
currentNode
.
levelId
)
{
node
.
show
=
true
;
node
.
show
=
true
;
}
}
if
(
node
.
levelId
.
split
(
'-'
).
length
>
2
)
{
if
(
node
.
levelId
.
split
(
'-'
).
length
>
2
)
{
if
(
node
.
levelId
.
split
(
'-'
).
length
<=
currentNode
.
levelId
.
split
(
'-'
).
length
)
{
if
(
node
.
levelId
.
split
(
'-'
).
length
<=
currentNode
.
levelId
.
split
(
'-'
).
length
)
{
node
.
simple
=
!
(
currentNode
.
levelId
.
slice
(
0
,
node
.
levelId
.
length
)
=
==
node
.
levelId
);
node
.
simple
=
(
currentNode
.
levelId
.
slice
(
0
,
node
.
levelId
.
length
)
!
==
node
.
levelId
);
}
else
if
(
node
.
levelId
.
split
(
'-'
).
length
===
currentNode
.
levelId
.
split
(
'-'
).
length
+
1
)
{
}
else
if
(
node
.
levelId
.
split
(
'-'
).
length
===
currentNode
.
levelId
.
split
(
'-'
).
length
+
1
)
{
node
.
simple
=
!
(
node
.
levelId
.
slice
(
0
,
currentNode
.
levelId
.
length
)
=
==
currentNode
.
levelId
);
node
.
simple
=
(
node
.
levelId
.
slice
(
0
,
currentNode
.
levelId
.
length
)
!
==
currentNode
.
levelId
);
}
else
if
(
node
.
levelId
.
slice
(
0
,
currentNode
.
levelId
.
length
)
!==
currentNode
.
levelId
)
{
}
else
if
(
node
.
levelId
.
slice
(
0
,
currentNode
.
levelId
.
length
)
!==
currentNode
.
levelId
)
{
node
.
simple
=
true
;
node
.
simple
=
true
;
}
}
}
}
})
})
setNodes
(
nodes
);
setNodes
(
data
);
generate
RelationData
(
nodes
,
false
);
generate
CenterNodeRelationData
(
data
);
}
}
}
}
const
onCenterClick
=
(
id
)
=>
{
onChange
&&
onChange
({
centerId
:
id
,
expandId
:
''
});
}
const
onExpandClick
=
(
id
)
=>
{
onChange
&&
onChange
({...
nodeParams
,
expandId
:
id
});
}
return
(
return
(
<
div
style=
{
{
width
:
'100%'
,
height
:
'100%'
}
}
>
<
div
style=
{
{
width
:
'100%'
,
height
:
'100%'
}
}
>
<
Relation
data=
{
relationData
}
reload=
{
reload
}
onClick=
{
on
Click
}
/>
<
Relation
data=
{
relationData
}
onCenterClick=
{
onCenterClick
}
onExpandClick=
{
onExpand
Click
}
/>
</
div
>
</
div
>
);
);
}
}
export
default
App
;
export
default
RelationContainer
;
src/view/Manage/AssetBrowse/index.jsx
View file @
9cf34768
...
@@ -13,17 +13,23 @@ import './index.less';
...
@@ -13,17 +13,23 @@ import './index.less';
const
AssetBrowse
=
(
props
)
=>
{
const
AssetBrowse
=
(
props
)
=>
{
const
[
node
Id
,
setNodeId
]
=
useState
(
''
);
const
[
node
Params
,
setNodeParams
]
=
useState
({
centerId
:
''
,
expandId
:
''
});
const
[
expandTree
,
setExpandTree
]
=
useState
(
true
);
const
[
expandTree
,
setExpandTree
]
=
useState
(
true
);
const
{
nodeId
,
expandId
}
=
nodeParams
;
const
onTreeSelect
=
(
value
,
type
)
=>
{
const
onTreeSelect
=
(
value
,
type
)
=>
{
setNode
Id
(
value
||
''
);
setNode
Params
({
centerId
:
value
||
''
,
expandId
:
''
}
);
}
}
const
treeToggleClick
=
()
=>
{
const
treeToggleClick
=
()
=>
{
setExpandTree
(
!
expandTree
);
setExpandTree
(
!
expandTree
);
}
}
const
onRelationChange
=
(
data
)
=>
{
setNodeParams
(
data
);
}
const
classes
=
classNames
(
'asset-browse'
,
{
const
classes
=
classNames
(
'asset-browse'
,
{
'asset-browse-collapse'
:
!
expandTree
'asset-browse-collapse'
:
!
expandTree
});
});
...
@@ -41,7 +47,7 @@ const AssetBrowse = (props) => {
...
@@ -41,7 +47,7 @@ const AssetBrowse = (props) => {
<
div
className=
'right'
>
<
div
className=
'right'
>
<
Row
>
<
Row
>
<
Col
span=
{
12
}
>
<
Col
span=
{
12
}
>
<
RelationContainer
/>
<
RelationContainer
nodeParams=
{
nodeParams
}
onChange=
{
onRelationChange
}
/>
</
Col
>
</
Col
>
<
Col
span=
{
12
}
>
<
Col
span=
{
12
}
>
<
AssetTable
nodeId=
{
nodeId
}
reference=
{
AssetBrowseReference
}
{
...
props
}
/>
<
AssetTable
nodeId=
{
nodeId
}
reference=
{
AssetBrowseReference
}
{
...
props
}
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment