Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
luna
Project
Project
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
ops
luna
Commits
76e97f41
Commit
76e97f41
authored
Oct 22, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改tree search 带上组织
parent
ff8c1436
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
5 deletions
+26
-5
asset-tree.component.ts
src/app/elements/asset-tree/asset-tree.component.ts
+15
-5
common.ts
src/app/utils/common.ts
+11
-0
No files found.
src/app/elements/asset-tree/asset-tree.component.ts
View file @
76e97f41
...
...
@@ -4,6 +4,7 @@ import {BehaviorSubject, Subject} from 'rxjs';
import
{
takeUntil
}
from
'rxjs/operators'
;
import
{
ActivatedRoute
}
from
'@angular/router'
;
import
{
groupBy
}
from
'@app/utils/common'
;
import
{
AppService
,
HttpService
,
LogService
,
NavService
,
SettingService
,
TreeFilterService
}
from
'@app/services'
;
import
{
connectEvt
,
translate
}
from
'@app/globals'
;
import
{
TreeNode
,
ConnectEvt
}
from
'@app/model'
;
...
...
@@ -323,7 +324,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
if
(
!
this
.
assetsTree
)
{
return
;
}
cons
t
searchNode
=
this
.
assetsTree
.
getNodesByFilter
((
node
)
=>
node
.
id
===
'search'
);
le
t
searchNode
=
this
.
assetsTree
.
getNodesByFilter
((
node
)
=>
node
.
id
===
'search'
);
if
(
searchNode
)
{
this
.
assetsTree
.
removeChildNodes
(
searchNode
[
0
]);
this
.
assetsTree
.
removeNode
(
searchNode
[
0
]);
...
...
@@ -348,10 +349,19 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
const
assetsAmount
=
nodes
.
length
;
name
=
`
${
name
}
(
${
assetsAmount
}
)`
;
const
newNode
=
{
id
:
'search'
,
name
:
name
,
isParent
:
true
,
open
:
true
,
zAsync
:
true
};
const
parentNode
=
this
.
assetsTree
.
addNodes
(
null
,
newNode
)[
0
];
parentNode
.
zAsync
=
true
;
this
.
assetsTree
.
addNodes
(
parentNode
,
nodes
);
parentNode
.
open
=
true
;
searchNode
=
this
.
assetsTree
.
addNodes
(
null
,
newNode
)[
0
];
searchNode
.
zAsync
=
true
;
const
nodesGroupByOrg
=
groupBy
(
nodes
,
(
node
)
=>
{
return
node
.
meta
.
asset
.
org_name
;
});
nodesGroupByOrg
.
forEach
((
item
)
=>
{
const
orgName
=
item
[
0
].
meta
.
asset
.
org_name
;
const
orgNodeData
=
{
id
:
orgName
,
name
:
orgName
,
isParent
:
true
,
open
:
true
,
zAsync
:
true
};
const
orgNode
=
this
.
assetsTree
.
addNodes
(
searchNode
,
orgNodeData
)[
0
];
orgNode
.
zAsync
=
true
;
this
.
assetsTree
.
addNodes
(
orgNode
,
item
);
});
searchNode
.
open
=
true
;
});
return
;
}
...
...
src/app/utils/common.ts
0 → 100644
View file @
76e97f41
export
function
groupBy
(
array
,
f
)
{
const
groups
=
{};
array
.
forEach
(
function
(
o
)
{
const
group
=
JSON
.
stringify
(
f
(
o
)
);
groups
[
group
]
=
groups
[
group
]
||
[];
groups
[
group
].
push
(
o
);
});
return
Object
.
keys
(
groups
).
map
(
function
(
group
)
{
return
groups
[
group
];
});
}
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