Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
16aa42a8
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
16aa42a8
编写于
4月 26, 2018
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Bugfix] 修复授权树列表和资产树列表不同的bug
上级
d5debc37
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
20 deletion
+22
-20
apps/assets/api/node.py
apps/assets/api/node.py
+6
-5
apps/assets/models/node.py
apps/assets/models/node.py
+1
-1
apps/assets/serializers/node.py
apps/assets/serializers/node.py
+1
-1
apps/perms/templates/perms/asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+14
-13
未找到文件。
apps/assets/api/node.py
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
(
"
,
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录