Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
5b53cfb4
Commit
5b53cfb4
authored
May 29, 2018
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改资产树节点(数量)总显示此节点下的资产总数
parent
3a297302
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
20 deletions
+6
-20
node.py
apps/assets/api/node.py
+1
-8
node.py
apps/assets/serializers/node.py
+1
-7
_asset_list_modal.html
apps/assets/templates/assets/_asset_list_modal.html
+1
-1
asset_list.html
apps/assets/templates/assets/asset_list.html
+3
-4
No files found.
apps/assets/api/node.py
View file @
5b53cfb4
...
...
@@ -42,14 +42,7 @@ __all__ = [
class
NodeViewSet
(
BulkModelViewSet
):
queryset
=
Node
.
objects
.
all
()
permission_classes
=
(
IsSuperUser
,)
# serializer_class = serializers.NodeSerializer
def
get_serializer_class
(
self
):
show_current_asset
=
self
.
request
.
query_params
.
get
(
'show_current_asset'
)
if
show_current_asset
:
return
serializers
.
NodeCurrentSerializer
else
:
return
serializers
.
NodeSerializer
serializer_class
=
serializers
.
NodeSerializer
def
perform_create
(
self
,
serializer
):
child_key
=
Node
.
root
()
.
get_next_child_key
()
...
...
apps/assets/serializers/node.py
View file @
5b53cfb4
...
...
@@ -9,7 +9,7 @@ from .asset import AssetGrantedSerializer
__all__
=
[
'NodeSerializer'
,
"NodeGrantedSerializer"
,
"NodeAddChildrenSerializer"
,
"NodeAssetsSerializer"
,
"NodeCurrentSerializer"
,
"NodeAssetsSerializer"
,
]
...
...
@@ -77,12 +77,6 @@ class NodeSerializer(serializers.ModelSerializer):
return
fields
class
NodeCurrentSerializer
(
NodeSerializer
):
@staticmethod
def
get_assets_amount
(
obj
):
return
obj
.
get_assets
()
.
count
()
class
NodeAssetsSerializer
(
serializers
.
ModelSerializer
):
assets
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
Asset
.
objects
.
all
())
...
...
apps/assets/templates/assets/_asset_list_modal.html
View file @
5b53cfb4
...
...
@@ -95,7 +95,7 @@ function initTree2() {
};
var
zNodes
=
[];
$
.
get
(
"{% url 'api-assets:node-list' %}
?show_current_asset=1
"
,
function
(
data
,
status
){
$
.
get
(
"{% url 'api-assets:node-list' %}"
,
function
(
data
,
status
){
$
.
each
(
data
,
function
(
index
,
value
)
{
value
[
"pId"
]
=
value
[
"parent"
];
{
#
value
[
"open"
]
=
true
;
#
}
...
...
apps/assets/templates/assets/asset_list.html
View file @
5b53cfb4
...
...
@@ -399,8 +399,7 @@ function initTree() {
};
var
zNodes
=
[];
var
query_params
=
{
'show_current_asset'
:
getCookie
(
'show_current_asset'
)};
$
.
get
(
"{% url 'api-assets:node-list' %}"
,
query_params
,
function
(
data
,
status
){
$
.
get
(
"{% url 'api-assets:node-list' %}"
,
function
(
data
,
status
){
$
.
each
(
data
,
function
(
index
,
value
)
{
value
[
"pId"
]
=
value
[
"parent"
];
if
(
value
[
"key"
]
===
"0"
)
{
...
...
@@ -436,7 +435,7 @@ $(document).ready(function(){
initTable
();
initTree
();
if
(
getCookie
(
'show_current_asset'
)
===
'
yes
'
){
if
(
getCookie
(
'show_current_asset'
)
===
'
1
'
){
$
(
'#show_all_asset'
).
css
(
'display'
,
'inline-block'
);
}
else
{
...
...
@@ -564,7 +563,7 @@ $(document).ready(function(){
hideRMenu
();
$
(
this
).
css
(
'display'
,
'none'
);
$
(
'#show_all_asset'
).
css
(
'display'
,
'inline-block'
);
setCookie
(
'show_current_asset'
,
'
yes
'
);
setCookie
(
'show_current_asset'
,
'
1
'
);
location
.
reload
();
})
.
on
(
'click'
,
'.btn-show-all-asset'
,
function
(){
...
...
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