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
16aa42a8
Commit
16aa42a8
authored
Apr 26, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复授权树列表和资产树列表不同的bug
parent
d5debc37
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
20 deletions
+22
-20
node.py
apps/assets/api/node.py
+6
-5
node.py
apps/assets/models/node.py
+1
-1
node.py
apps/assets/serializers/node.py
+1
-1
asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+14
-13
No files found.
apps/assets/api/node.py
View file @
16aa42a8
...
...
@@ -108,18 +108,18 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
return
node
def
get_queryset
(
self
):
queryset
=
[]
queryset
=
set
()
query_all
=
self
.
request
.
query_params
.
get
(
"all"
)
query_assets
=
self
.
request
.
query_params
.
get
(
'assets'
)
node
=
self
.
get_object
()
if
node
==
Node
.
root
():
queryset
.
a
ppen
d
(
node
)
queryset
.
a
d
d
(
node
)
if
query_all
:
children
=
node
.
get_all_children
()
else
:
children
=
node
.
get_children
()
queryset
.
extend
(
lis
t
(
children
))
queryset
.
update
(
se
t
(
children
))
if
query_assets
:
assets
=
node
.
get_assets
()
for
asset
in
assets
:
...
...
@@ -127,8 +127,9 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
node_fake
.
id
=
asset
.
id
node_fake
.
parent
=
node
node_fake
.
value
=
asset
.
hostname
node_fake
.
is_asset
=
True
queryset
.
append
(
node_fake
)
node_fake
.
is_node
=
False
queryset
.
add
(
node_fake
)
queryset
=
sorted
(
queryset
,
key
=
lambda
x
:
x
.
is_node
,
reverse
=
True
)
return
queryset
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
apps/assets/models/node.py
View file @
16aa42a8
...
...
@@ -16,7 +16,7 @@ class Node(models.Model):
child_mark
=
models
.
IntegerField
(
default
=
0
)
date_create
=
models
.
DateTimeField
(
auto_now_add
=
True
)
is_
asset
=
Fals
e
is_
node
=
Tru
e
def
__str__
(
self
):
return
self
.
full_value
...
...
apps/assets/serializers/node.py
View file @
16aa42a8
...
...
@@ -48,7 +48,7 @@ class NodeSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Node
fields
=
[
'id'
,
'key'
,
'value'
,
'parent'
,
'assets_amount'
,
'is_
asset
'
]
fields
=
[
'id'
,
'key'
,
'value'
,
'parent'
,
'assets_amount'
,
'is_
node
'
]
list_serializer_class
=
BulkListSerializer
@staticmethod
...
...
apps/perms/templates/perms/asset_permission_list.html
View file @
16aa42a8
...
...
@@ -78,12 +78,12 @@ var zTree, table, show = 0;
function
onSelected
(
event
,
treeNode
)
{
setCookie
(
'node_selected'
,
treeNode
.
id
);
var
url
=
table
.
ajax
.
url
();
if
(
treeNode
.
is_asset
)
{
url
=
setUrlParam
(
url
,
'node'
,
""
);
url
=
setUrlParam
(
url
,
'asset'
,
treeNode
.
id
)
}
else
{
if
(
treeNode
.
is_node
)
{
url
=
setUrlParam
(
url
,
'asset'
,
""
);
url
=
setUrlParam
(
url
,
'node'
,
treeNode
.
id
)
}
else
{
url
=
setUrlParam
(
url
,
'node'
,
""
);
url
=
setUrlParam
(
url
,
'asset'
,
treeNode
.
id
)
}
setCookie
(
'node_selected'
,
treeNode
.
id
);
table
.
ajax
.
url
(
url
);
...
...
@@ -113,14 +113,14 @@ function filter(treeId, parentNode, childNodes) {
$
.
each
(
childNodes
,
function
(
index
,
value
)
{
value
[
"pId"
]
=
value
[
"parent"
];
value
[
"name"
]
=
value
[
"value"
];
value
[
"isParent"
]
=
value
[
"
assets_amount"
]
!==
0
;
value
[
"iconSkin"
]
=
value
[
"is_
asset"
]
?
"file"
:
null
;
value
[
"isParent"
]
=
value
[
"
is_node"
]
;
value
[
"iconSkin"
]
=
value
[
"is_
node"
]
?
null
:
'file'
;
});
return
childNodes
;
}
function
beforeAsync
(
treeId
,
treeNode
)
{
return
true
;
return
treeNode
.
is_node
}
function
makeLabel
(
data
)
{
...
...
@@ -226,7 +226,7 @@ function initTree() {
},
async
:
{
enable
:
true
,
url
:
"{% url 'api-assets:node-children-2' %}?assets=1"
,
url
:
"{% url 'api-assets:node-children-2' %}?assets=1
&all=1
"
,
autoParam
:[
"id"
,
"name=n"
,
"level=lv"
],
dataFilter
:
filter
,
type
:
'get'
...
...
@@ -238,12 +238,13 @@ function initTree() {
};
var
zNodes
=
[];
$
.
get
(
"{% url 'api-assets:node-children-2' %}"
,
function
(
data
,
status
){
$
.
get
(
"{% url 'api-assets:node-children-2' %}
?assets=1&all=1
"
,
function
(
data
,
status
){
$
.
each
(
data
,
function
(
index
,
value
)
{
value
[
"pId"
]
=
value
[
"parent"
];
value
[
"isParent"
]
=
value
[
"assets_amount"
]
!==
0
;
value
[
"name"
]
=
value
[
"value"
];
value
[
"open"
]
=
value
[
"key"
]
===
"0"
;
value
[
"isParent"
]
=
value
[
"is_node"
];
value
[
"iconSkin"
]
=
value
[
"is_node"
]
?
null
:
'file'
;
});
zNodes
=
data
;
{
#
$
.
fn
.
zTree
.
init
(
$
(
"#assetTree"
),
setting
);
#
}
...
...
@@ -286,10 +287,10 @@ $(document).ready(function(){
var
_nodes
=
[];
var
_assets
=
[];
$
.
each
(
nodes
,
function
(
id
,
node
)
{
if
(
node
.
is_asset
)
{
_assets
.
push
(
node
.
id
)
}
else
{
if
(
node
.
is_node
)
{
_nodes
.
push
(
node
.
id
)
}
else
{
_assets
.
push
(
node
.
id
)
}
});
url
+=
"?assets="
+
_assets
.
join
(
","
)
+
"&nodes="
+
_nodes
.
join
(
","
);
...
...
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