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
44062c7d
Commit
44062c7d
authored
May 28, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改树搜索的bug
parent
9be49823
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
20 deletions
+58
-20
asset-tree.component.ts
src/app/elements/asset-tree/asset-tree.component.ts
+54
-16
cleftbar.component.html
src/app/pages/control/cleftbar/cleftbar.component.html
+2
-2
cleftbar.component.ts
src/app/pages/control/cleftbar/cleftbar.component.ts
+2
-2
No files found.
src/app/elements/asset-tree/asset-tree.component.ts
View file @
44062c7d
import
{
Component
,
Input
,
OnInit
,
Inject
,
SimpleChanges
,
OnChanges
}
from
'@angular/core'
;
import
{
Component
,
Input
,
OnInit
,
Inject
,
SimpleChanges
,
OnChanges
,
EventEmitter
}
from
'@angular/core'
;
import
{
NavList
,
View
}
from
'../../pages/control/control/control.component'
;
import
{
NavList
,
View
}
from
'../../pages/control/control/control.component'
;
import
{
AppService
,
LogService
}
from
'../../app.service'
;
import
{
AppService
,
LogService
}
from
'../../app.service'
;
import
{
MAT_DIALOG_DATA
,
MatDialog
,
MatDialogRef
}
from
'@angular/material'
;
import
{
MAT_DIALOG_DATA
,
MatDialog
,
MatDialogRef
}
from
'@angular/material'
;
import
{
FormControl
,
Validators
}
from
'@angular/forms'
;
import
{
FormControl
,
Validators
}
from
'@angular/forms'
;
import
{
BehaviorSubject
}
from
'rxjs/BehaviorSubject'
;
declare
var
$
:
any
;
declare
var
$
:
any
;
...
@@ -14,6 +15,7 @@ declare var $: any;
...
@@ -14,6 +15,7 @@ declare var $: any;
export
class
ElementAssetTreeComponent
implements
OnInit
,
OnChanges
{
export
class
ElementAssetTreeComponent
implements
OnInit
,
OnChanges
{
@
Input
()
Data
:
any
;
@
Input
()
Data
:
any
;
@
Input
()
query
:
string
;
@
Input
()
query
:
string
;
@
Input
()
searchEvt$
:
BehaviorSubject
<
string
>
;
nodes
=
[];
nodes
=
[];
setting
=
{
setting
=
{
view
:
{
view
:
{
...
@@ -43,12 +45,19 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -43,12 +45,19 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
constructor
(
private
_appService
:
AppService
,
constructor
(
private
_appService
:
AppService
,
public
_dialog
:
MatDialog
,
public
_dialog
:
MatDialog
,
public
_logger
:
LogService
)
{
public
_logger
:
LogService
)
{
this
.
searchEvt$
=
new
BehaviorSubject
<
string
>
(
this
.
query
);
}
}
ngOnInit
()
{
ngOnInit
()
{
if
(
this
.
Data
)
{
if
(
this
.
Data
)
{
this
.
draw
();
this
.
draw
();
}
}
this
.
searchEvt$
.
asObservable
()
.
debounceTime
(
300
)
.
distinctUntilChanged
()
.
subscribe
((
n
)
=>
{
this
.
filter
();
});
}
}
ngOnChanges
(
changes
:
SimpleChanges
)
{
ngOnChanges
(
changes
:
SimpleChanges
)
{
...
@@ -56,7 +65,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -56,7 +65,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
this
.
draw
();
this
.
draw
();
}
}
if
(
changes
[
'query'
]
&&
!
changes
[
'query'
].
firstChange
)
{
if
(
changes
[
'query'
]
&&
!
changes
[
'query'
].
firstChange
)
{
this
.
filter
();
this
.
searchEvt$
.
next
(
this
.
query
);
// this.filter();
}
}
}
}
...
@@ -174,25 +184,53 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -174,25 +184,53 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
return
user
;
return
user
;
}
}
filter
()
{
recurseParent
(
node
)
{
const
zTreeObj
=
$
.
fn
.
zTree
.
getZTreeObj
(
'ztree'
);
const
parentNode
=
node
.
getParentNode
();
const
_keywords
=
$
(
'#keyword'
).
val
();
if
(
parentNode
&&
parentNode
.
pId
)
{
zTreeObj
.
showNodes
(
this
.
hiddenNodes
);
return
[
parentNode
,
...
this
.
recurseParent
(
parentNode
)];
}
else
if
(
parentNode
)
{
return
[
parentNode
];
}
else
{
return
[];
}
}
function
filterFunc
(
node
)
{
recurseChildren
(
node
)
{
if
(
node
.
isParent
||
node
.
name
.
indexOf
(
_keywords
)
!==
-
1
)
{
if
(
!
node
.
isParent
)
{
return
false
;
return
[]
;
}
}
return
true
;
const
children
=
node
.
children
;
if
(
!
children
)
{
return
[];
}
children
.
forEach
((
n
)
=>
{
return
[...
children
,
...
this
.
recurseChildren
(
n
)];
});
return
[];
}
}
this
.
hiddenNodes
=
zTreeObj
.
getNodesByFilter
(
filterFunc
);
filter
()
{
zTreeObj
.
hideNodes
(
this
.
hiddenNodes
);
const
zTreeObj
=
$
.
fn
.
zTree
.
getZTreeObj
(
'ztree'
);
if
(
_keywords
)
{
if
(
!
zTreeObj
)
{
zTreeObj
.
expandAll
(
true
);
return
null
;
}
else
{
zTreeObj
.
expandAll
(
false
);
}
}
const
_keywords
=
this
.
query
;
const
nodes
=
zTreeObj
.
transformToArray
(
zTreeObj
.
getNodes
());
if
(
!
_keywords
)
{
zTreeObj
.
showNodes
(
nodes
);
return
null
;
}
let
shouldShow
=
[];
nodes
.
forEach
((
node
)
=>
{
if
(
shouldShow
.
indexOf
(
node
)
===
-
1
&&
node
.
name
.
indexOf
(
_keywords
)
!==
-
1
)
{
const
parents
=
this
.
recurseParent
(
node
);
const
children
=
this
.
recurseChildren
(
node
);
shouldShow
=
[...
shouldShow
,
...
parents
,
...
children
,
node
];
}
});
zTreeObj
.
hideNodes
(
nodes
);
zTreeObj
.
showNodes
(
shouldShow
);
zTreeObj
.
expandAll
(
true
);
}
}
}
}
...
...
src/app/pages/control/cleftbar/cleftbar.component.html
View file @
44062c7d
<div
class=
"sidebar"
fxLayout=
"column"
ngxSplit=
"column"
>
<div
class=
"sidebar"
fxLayout=
"column"
ngxSplit=
"column"
>
<div
fxflex=
"0 0 30px"
class=
"search"
>
<div
fxflex=
"0 0 30px"
class=
"search"
>
<input
id=
"keyword"
class=
"left-search"
placeholder=
" {{'Search'| trans }} ..."
maxlength=
"2048"
name=
"q"
<input
#
keyword
id=
"keyword"
class=
"left-search"
placeholder=
" {{'Search'| trans }} ..."
maxlength=
"2048"
name=
"q"
autocomplete=
"off"
autocomplete=
"off"
title=
"Search"
title=
"Search"
type=
"text"
tabindex=
"1"
spellcheck=
"false"
autofocus
[(
ngModel
)]="
q
"
(
keyup
.
enter
)="
Search
(
q
)
"
>
type=
"text"
tabindex=
"1"
spellcheck=
"false"
[(
ngModel
)]="
q
"
>
</div>
</div>
<div
class=
"overflow ngx-scroll-overlay"
fxflex=
"1 1 90%"
>
<div
class=
"overflow ngx-scroll-overlay"
fxflex=
"1 1 90%"
>
<elements-asset-tree
[
Data
]="
zNodes
"
[
query
]="
q
"
></elements-asset-tree>
<elements-asset-tree
[
Data
]="
zNodes
"
[
query
]="
q
"
></elements-asset-tree>
...
...
src/app/pages/control/cleftbar/cleftbar.component.ts
View file @
44062c7d
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* @author liuzheng <liuzheng712@gmail.com>
* @author liuzheng <liuzheng712@gmail.com>
*/
*/
import
{
Component
,
Inject
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
Inject
,
OnInit
,
ViewChild
,
ElementRef
}
from
'@angular/core'
;
import
{
AppService
,
HttpService
,
LogService
}
from
'../../../app.service'
;
import
{
AppService
,
HttpService
,
LogService
}
from
'../../../app.service'
;
import
{
SearchComponent
}
from
'../search/search.component'
;
import
{
SearchComponent
}
from
'../search/search.component'
;
import
{
DataStore
}
from
'../../../globals'
;
import
{
DataStore
}
from
'../../../globals'
;
...
@@ -17,6 +17,7 @@ import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
...
@@ -17,6 +17,7 @@ import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
import
{
FormControl
,
Validators
}
from
'@angular/forms'
;
import
{
FormControl
,
Validators
}
from
'@angular/forms'
;
import
{
ElementServerMenuComponent
}
from
'../../../elements/server-menu/server-menu.component'
;
import
{
ElementServerMenuComponent
}
from
'../../../elements/server-menu/server-menu.component'
;
import
{
DialogService
}
from
'../../../elements/dialog/dialog.service'
;
import
{
DialogService
}
from
'../../../elements/dialog/dialog.service'
;
import
{
Observable
}
from
'../../../../../node_modules/rxjs'
;
export
interface
HostGroup
{
export
interface
HostGroup
{
name
:
string
;
name
:
string
;
...
@@ -102,7 +103,6 @@ export class CleftbarComponent implements OnInit {
...
@@ -102,7 +103,6 @@ export class CleftbarComponent implements OnInit {
});
});
}
}
Search
(
q
)
{
Search
(
q
)
{
this
.
_search
.
Search
(
q
);
this
.
_search
.
Search
(
q
);
}
}
...
...
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