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
907384a3
Commit
907384a3
authored
Sep 17, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 避免搜索多次
parent
45a66fab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
33 deletions
+39
-33
asset-tree.component.ts
src/app/elements/asset-tree/asset-tree.component.ts
+20
-12
connect.component.ts
src/app/elements/connect/connect.component.ts
+19
-21
No files found.
src/app/elements/asset-tree/asset-tree.component.ts
View file @
907384a3
import
{
Component
,
Input
,
OnInit
,
OnDestroy
,
ElementRef
,
ViewChild
}
from
'@angular/core'
;
import
{
MatDialog
}
from
'@angular/material'
;
import
{
BehaviorSubject
}
from
'rxjs'
;
import
{
BehaviorSubject
,
Subject
}
from
'rxjs'
;
import
{
takeUntil
}
from
'rxjs/operators'
;
import
{
ActivatedRoute
}
from
'@angular/router'
;
import
{
AppService
,
HttpService
,
LogService
,
NavService
,
SettingService
,
TreeFilterService
}
from
'@app/services'
;
...
...
@@ -44,6 +45,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
hasLoginTo
=
false
;
treeFilterSubscription
:
any
;
isLoadTreeAsync
:
boolean
;
filterAssetCancel
$
:
Subject
<
boolean
>
=
new
Subject
();
constructor
(
private
_appSvc
:
AppService
,
private
_treeFilterSvc
:
TreeFilterService
,
...
...
@@ -330,17 +332,23 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
}
return
;
}
this
.
_http
.
getMyGrantedAssets
(
keyword
).
subscribe
(
nodes
=>
{
const
treeNodes
=
this
.
assetsTree
.
getNodes
();
if
(
treeNodes
.
length
!==
0
)
{
this
.
assetsTree
.
hideNode
(
treeNodes
[
0
]);
}
const
newNode
=
{
id
:
'search'
,
name
:
translate
(
'Search'
),
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
;
});
this
.
filterAssetCancel$
.
next
(
true
);
this
.
_http
.
getMyGrantedAssets
(
keyword
)
.
pipe
(
takeUntil
(
this
.
filterAssetCancel$
))
.
subscribe
(
nodes
=>
{
const
treeNodes
=
this
.
assetsTree
.
getNodes
();
if
(
treeNodes
.
length
!==
0
)
{
this
.
assetsTree
.
hideNode
(
treeNodes
[
0
]);
}
let
name
=
translate
(
'Search'
);
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
;
});
return
;
}
...
...
src/app/elements/connect/connect.component.ts
View file @
907384a3
...
...
@@ -40,29 +40,27 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
}
}
});
this
.
activatedRoute
.
queryParams
.
subscribe
(
params
=>
{
const
login_to
=
params
[
'login_to'
];
if
(
login_to
&&
!
this
.
hasLoginTo
)
{
this
.
_http
.
filterMyGrantedAssetsById
(
login_to
).
subscribe
(
nodes
=>
{
if
(
nodes
.
length
===
1
)
{
this
.
hasLoginTo
=
true
;
const
node
=
nodes
[
0
];
this
.
Connect
(
node
);
}
const
loginTo
=
this
.
_appSvc
.
getQueryString
(
'login_to'
);
if
(
loginTo
&&
!
this
.
hasLoginTo
)
{
this
.
_http
.
filterMyGrantedAssetsById
(
loginTo
).
subscribe
(
nodes
=>
{
if
(
nodes
.
length
===
1
)
{
this
.
hasLoginTo
=
true
;
const
node
=
nodes
[
0
];
this
.
Connect
(
node
);
}
);
this
.
_http
.
getMyGrantedRemoteApps
(
login_to
).
subscribe
(
nodes
=>
{
if
(
nodes
.
length
===
1
)
{
this
.
hasLoginTo
=
true
;
const
node
=
nodes
[
0
]
;
this
.
Connect
(
node
)
;
}
}
);
this
.
_http
.
getMyGrantedRemoteApps
(
loginTo
).
subscribe
(
nodes
=>
{
if
(
nodes
.
length
===
1
)
{
this
.
hasLoginTo
=
true
;
const
node
=
nodes
[
0
]
;
this
.
Connect
(
node
);
}
);
}
}
);
}
);
}
}
ngOnDestroy
():
void
{
connectEvt
.
unsubscribe
();
...
...
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