Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart
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
wangqinghua
smart
Commits
90972e43
Commit
90972e43
authored
Feb 20, 2019
by
wangqinghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directive
parent
e1ff90e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
61 deletions
+44
-61
b-config.component.html
...main/webapp/app/business/b-config/b-config.component.html
+5
-27
b-config.component.ts
src/main/webapp/app/business/b-config/b-config.component.ts
+38
-31
basic.component.ts
src/main/webapp/app/overAll/basic/basic.component.ts
+1
-3
No files found.
src/main/webapp/app/business/b-config/b-config.component.html
View file @
90972e43
...
...
@@ -43,35 +43,13 @@
</thead>
<tbody>
<ng-template
ngFor
let-data
[
ngForOf
]="
nzTable
.
data
"
>
<ng-template
ngFor
let-item
[
ngForOf
]="
expandDataCache
[
data
.
host
]"
>
<ng-template
ngFor
let-item
[
ngForOf
]="
expandDataCache
[
data
.
serviceid
]"
>
<tr
*
ngIf=
"(item.parent&&item.parent.expand)||!(item.parent)"
>
<td
[
nzIndentSize
]="
item
.
level
*
20
"
nzShowExpand
[
nzExpand
]='
item
.
expand
'
(
nzExpandChange
)="
getChildren
(
item
)"
>
<span
(
click
)="
showEditModal
(
item
)"
class=
"main-color cursor"
>
{{item.name}}
</span>
</td>
<td
class=
"round-tag tag-form"
>
<ng-container
*
ngIf=
"item.status == 0"
>
<nz-tag
class=
"tag-green"
[
nzColor
]="
color
.
green
"
></nz-tag>
</ng-container>
<ng-container
*
ngIf=
"item.status == 2 || item.status == 3"
>
<nz-tag
class=
"tag-yellow"
[
nzColor
]="
color
.
yellow
"
></nz-tag>
</ng-container>
<ng-container
*
ngIf=
"item.status == 4 || item.status == 5"
>
<nz-tag
class=
"tag-red"
[
nzColor
]="
color
.
red
"
></nz-tag>
</ng-container>
</td>
<td
class=
"cursor"
>
<span
(
click
)="
goTOInventory
(
item
?.
inventory
?.
id
)"
>
{{item?.inventory?.name}}
</span>
</td>
<td
class=
"handle main-color"
>
<span
(
click
)="
showBasicEditModal
(
item
)"
>
添加子节点
</span>
<ng-container
*
ngIf=
"!item.level"
>
<span
(
click
)="
showBasicEditModal
(
item
)"
>
配置告警推送
</span>
</ng-container>
<ng-container
*
ngIf=
"item.level"
>
<span
(
click
)="
editBasicModal
(
item
)"
>
编辑
</span>
<span
(
click
)="
showDeleteConfirm
(
item
)"
>
移除
</span>
</ng-container>
<td
[
nzIndentSize
]="
item
.
level
*
20
"
[
nzShowExpand
]="!!
item
.
children
"
[(
nzExpand
)]="
item
.
expand
"
(
nzExpandChange
)="
getChildren
(
item
)"
>
{{item.name}}
</td>
<td>
{{item.age}}
</td>
<td>
{{item.address}}
</td>
</tr>
</ng-template>
</ng-template>
...
...
src/main/webapp/app/business/b-config/b-config.component.ts
View file @
90972e43
...
...
@@ -18,46 +18,59 @@ export class BConfigComponent implements OnInit {
allChecked
=
false
;
isLoading
=
false
;
//加载中
dataSet
;
//数据list
expandDataCache
=
{};
constructor
(
private
busineSer
:
BusinessService
,
private
message
:
NzMessageService
)
{
}
convertTreeToList
(
root
:
any
,
serviceid
:
string
,
index
):
TreeNodeInterface
[]
{
dataSet
:
any
[];
expandDataCache
=
{};
collapse
(
array
:
TreeNodeInterface
[],
data
:
TreeNodeInterface
,
$event
:
boolean
):
void
{
if
(
$event
===
false
)
{
if
(
data
.
children
)
{
data
.
children
.
forEach
(
d
=>
{
const
target
=
array
.
find
(
a
=>
a
.
serviceid
===
d
.
serviceid
);
target
.
expand
=
false
;
this
.
collapse
(
array
,
target
,
false
);
});
}
else
{
return
;
}
}
}
convertTreeToList
(
root
:
object
):
TreeNodeInterface
[]
{
const
stack
=
[];
const
array
=
[];
const
hashMap
=
{};
if
(
root
.
host
==
index
)
{
stack
.
push
({...
root
,
level
:
0
,
expand
:
true
});
}
else
{
stack
.
push
({...
root
,
level
:
0
,
expand
:
false
});
}
stack
.
push
({
...
root
,
level
:
0
,
expand
:
true
});
while
(
stack
.
length
!==
0
)
{
const
node
=
stack
.
pop
();
this
.
visitNode
(
node
,
hashMap
,
array
);
if
(
node
.
list
)
{
for
(
let
i
=
node
.
list
.
length
-
1
;
i
>=
0
;
i
--
)
{
stack
.
push
({
...
node
.
list
[
i
],
level
:
node
.
level
+
1
,
expand
:
true
,
serviceid
:
serviceid
,
parent
:
node
,
checked
:
false
});
if
(
node
.
children
)
{
for
(
let
i
=
node
.
children
.
length
-
1
;
i
>=
0
;
i
--
)
{
stack
.
push
({
...
node
.
children
[
i
],
level
:
node
.
level
+
1
,
expand
:
false
,
parent
:
node
});
}
}
}
// console.log(array);
return
array
;
}
visitNode
(
node
:
TreeNodeInterface
,
hashMap
:
object
,
array
:
TreeNodeInterface
[]):
void
{
if
(
!
hashMap
[
node
.
host
])
{
hashMap
[
node
.
host
]
=
true
;
console
.
log
(
hashMap
);
if
(
!
hashMap
[
node
.
serviceid
])
{
hashMap
[
node
.
serviceid
]
=
true
;
array
.
push
(
node
);
}
}
toTree
(
index
)
{
this
.
dataSet
.
forEach
(
item
=>
{
this
.
expandDataCache
[
item
.
host
]
=
this
.
convertTreeToList
(
item
,
item
.
serviceid
,
index
);
this
.
dataSet
.
forEach
(
(
item
,
i
)
=>
{
this
.
expandDataCache
[
item
.
serviceid
]
=
this
.
convertTreeToList
(
item
);
});
console
.
log
(
this
.
expandDataCache
);
}
ngOnInit
()
{
...
...
@@ -76,9 +89,9 @@ export class BConfigComponent implements OnInit {
if
(
res
.
errCode
==
10000
){
this
.
dataSet
=
res
.
data
;
this
.
dataSet
.
forEach
((
e
,
index
)
=>
{
e
.
host
=
index
;
e
.
checked
=
false
;
})
e
.
children
=
[];
});
this
.
toTree
(
null
);
}
else
{
this
.
message
.
error
(
res
.
errMsg
);
...
...
@@ -89,14 +102,6 @@ export class BConfigComponent implements OnInit {
//
getChildren
(
item
){
if
(
item
.
list
)
{
if
(
item
.
expand
)
{
item
.
expand
=
false
;
}
else
{
item
.
expand
=
true
;
}
return
false
;
}
this
.
isLoading
=
true
;
const
data
=
{
"sid"
:
item
.
serviceid
,
...
...
@@ -104,11 +109,13 @@ export class BConfigComponent implements OnInit {
this
.
busineSer
.
findChild
(
data
).
subscribe
(
(
res
)
=>
{
if
(
res
.
data
)
{
this
.
dataSet
[
item
.
host
].
list
=
res
.
data
;
this
.
toTree
(
item
.
host
);
this
.
dataSet
.
forEach
(
e
=>
{
if
(
e
.
serviceid
==
item
.
serviceid
){
e
.
children
=
res
.
data
;
}
});
this
.
toTree
(
item
.
service
);
}
else
{
this
.
dataSet
[
item
.
host
].
list
=
[];
this
.
toTree
(
item
.
host
);
this
.
message
.
info
(
'该分组下无资源'
);
}
this
.
isLoading
=
false
;
...
...
src/main/webapp/app/overAll/basic/basic.component.ts
View file @
90972e43
...
...
@@ -18,11 +18,10 @@ import {JhiMainComponent} from '../../layouts';
export
interface
TreeNodeInterface
{
host
:
any
;
serviceid
:
any
;
name
:
string
;
age
:
number
;
level
:
number
;
expand
:
boolean
;
address
:
string
;
children
?:
TreeNodeInterface
[];
}
...
...
@@ -120,7 +119,6 @@ export class BasicComponent implements OnInit {
}
}
}
return
array
;
}
...
...
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