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
a8ac99f6
Commit
a8ac99f6
authored
Sep 12, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改asset modal table
parent
8ddda8e5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
220 additions
and
139 deletions
+220
-139
_asset_list_modal.html
apps/assets/templates/assets/_asset_list_modal.html
+109
-21
asset_list.html
apps/assets/templates/assets/asset_list.html
+34
-27
domain_create_update.html
apps/assets/templates/assets/domain_create_update.html
+0
-19
label_create_update.html
apps/assets/templates/assets/label_create_update.html
+0
-18
signals_handlers.py
apps/common/signals_handlers.py
+2
-2
settings.py
apps/jumpserver/settings.py
+2
-0
command_execution_list.html
apps/ops/templates/ops/command_execution_list.html
+8
-2
asset_permission.py
apps/perms/api/asset_permission.py
+2
-0
asset_permission.py
apps/perms/forms/asset_permission.py
+10
-0
signals_handler.py
apps/perms/signals_handler.py
+2
-2
asset_permission_asset.html
apps/perms/templates/perms/asset_permission_asset.html
+7
-23
asset_permission_create_update.html
...perms/templates/perms/asset_permission_create_update.html
+29
-3
asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+13
-13
asset_permission.py
apps/perms/views/asset_permission.py
+2
-2
_ldap_list_users_modal.html
apps/settings/templates/settings/_ldap_list_users_modal.html
+0
-7
jumpserver.js
apps/static/js/jumpserver.js
+0
-0
No files found.
apps/assets/templates/assets/_asset_list_modal.html
View file @
a8ac99f6
...
@@ -15,11 +15,11 @@
...
@@ -15,11 +15,11 @@
text-align
:
center
;
text-align
:
center
;
}
}
#asset
Tree2
.ztree
*
{
#asset
_modal_tree
.ztree
*
{
background-color
:
#f8fafb
;
background-color
:
white
;
}
}
#asset
Tree2
.ztree
{
#asset
_modal_tree
.ztree
{
background-color
:
#f8fafb
;
background-color
:
white
;
}
}
</style>
</style>
...
@@ -29,7 +29,8 @@
...
@@ -29,7 +29,8 @@
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-content mailbox-content"
style=
"padding-top: 0;padding-left: 1px"
>
<div
class=
"ibox-content mailbox-content"
style=
"padding-top: 0;padding-left: 1px"
>
<div
class=
"file-manager "
>
<div
class=
"file-manager "
>
<div
id=
"assetTree2"
class=
"ztree"
>
<div
id=
"asset_modal_tree"
class=
"ztree"
>
{% trans 'Loading' %} ...
</div>
</div>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
</div>
</div>
...
@@ -55,12 +56,78 @@
...
@@ -55,12 +56,78 @@
</div>
</div>
<script>
<script>
var
zTree2
,
asset_table2
=
0
;
function
syncTableSelectedAssetToSelect2
(
table
)
{
function
initTable2
()
{
var
assets
=
table
.
selected
;
if
(
asset_table2
){
console
.
log
(
'........................'
,
assets
);
return
var
options
=
[];
var
select2Id
=
assetModalOption
.
select2Id
;
$
(
select2Id
+
' option'
).
each
(
function
(
i
,
v
)
{
options
.
push
(
v
.
value
)
});
table
.
selected_rows
.
forEach
(
function
(
i
)
{
var
name
=
i
.
hostname
+
'('
+
i
.
ip
+
')'
;
var
option
=
new
Option
(
name
,
i
.
id
,
false
,
true
);
if
(
options
.
indexOf
(
i
.
id
)
===
-
1
)
{
$
(
select2Id
).
append
(
option
).
trigger
(
'change'
);
}
});
$
(
select2Id
).
val
(
assets
).
trigger
(
'change'
);
}
// 解决input框中的资产和弹出表格中资产的显示不一致
function
syncSelectedAssetsToModalTable
(
assetModalTable
)
{
var
select2Id
=
assetModalOption
.
select2Id
;
var
inputAssets
=
$
(
select2Id
).
val
();
var
selectedAssets
=
assetModalTable
.
selected
.
concat
();
// input assets无,table assets选中,则取消勾选(再次click)
if
(
selectedAssets
.
length
!==
0
)
{
$
.
each
(
selectedAssets
,
function
(
index
,
assetId
)
{
if
(
$
.
inArray
(
assetId
,
inputAssets
)
===
-
1
)
{
$
(
'#'
+
assetId
).
trigger
(
'click'
);
// 取消勾选
}
});
}
}
// input assets有,table assets没选,则选中(click)
if
(
inputAssets
!==
null
)
{
assetModalTable
.
selected
=
inputAssets
;
$
.
each
(
inputAssets
,
function
(
index
,
assetId
)
{
var
dom
=
document
.
getElementById
(
assetId
);
if
(
dom
!==
null
)
{
var
selected
=
dom
.
parentElement
.
parentElement
.
className
.
indexOf
(
'selected'
)
}
if
(
selected
===
-
1
)
{
$
(
'#'
+
assetId
).
trigger
(
'click'
);
}
});
}
}
defaultOnAssetModalConfirm
=
syncTableSelectedAssetToSelect2
;
defaultOnModalTableDone
=
syncSelectedAssetsToModalTable
;
var
assetModalOption
=
{
selectStyle
:
'multi'
,
select2Id
:
'#id_assets'
,
onModalTableDone
:
defaultOnModalTableDone
,
onModalTreeDone
:
null
,
onModalConfirm
:
defaultOnAssetModalConfirm
,
};
var
assetModalTable
,
assetModalTree
=
null
;
function
initAssetModalTable
()
{
if
(
assetModalTable
){
return
}
if
(
assetModalOption
.
selectStyle
===
'single'
)
{
$
(
'.ipt_check_all'
).
addClass
(
'hidden'
)
}
var
options
=
{
var
options
=
{
ele
:
$
(
'#asset_list_modal_table'
),
ele
:
$
(
'#asset_list_modal_table'
),
ajax_url
:
'{% url "api-assets:asset-list" %}?show_current_asset=1'
,
ajax_url
:
'{% url "api-assets:asset-list" %}?show_current_asset=1'
,
...
@@ -68,22 +135,26 @@ function initTable2() {
...
@@ -68,22 +135,26 @@ function initTable2() {
{
data
:
"id"
},
{
data
:
"hostname"
},
{
data
:
"ip"
}
{
data
:
"id"
},
{
data
:
"hostname"
},
{
data
:
"ip"
}
],
],
lengthMenu
:
[[
10
,
25
,
50
],
[
10
,
25
,
50
]],
lengthMenu
:
[[
10
,
25
,
50
],
[
10
,
25
,
50
]],
pageLength
:
10
pageLength
:
10
,
select_style
:
assetModalOption
.
selectStyle
};
};
asset_table2
=
jumpserver
.
initServerSideDataTable
(
options
);
assetModalTable
=
jumpserver
.
initServerSideDataTable
(
options
);
return
asset_table2
if
(
assetModalOption
.
onModalTableDone
)
{
assetModalOption
.
onModalTableDone
(
assetModalTable
);
}
return
assetModalTable
}
}
function
on
NodeSelected2
(
event
,
treeNode
)
{
function
on
ModalTreeNodeSelected
(
event
,
treeNode
)
{
var
url
=
asset
_table2
.
ajax
.
url
();
var
url
=
asset
ModalTable
.
ajax
.
url
();
url
=
setUrlParam
(
url
,
"node_id"
,
treeNode
.
meta
.
node
.
id
);
url
=
setUrlParam
(
url
,
"node_id"
,
treeNode
.
meta
.
node
.
id
);
url
=
setUrlParam
(
url
,
"show_current_asset"
,
""
);
url
=
setUrlParam
(
url
,
"show_current_asset"
,
""
);
asset
_table2
.
ajax
.
url
(
url
);
asset
ModalTable
.
ajax
.
url
(
url
);
asset
_table2
.
ajax
.
reload
();
asset
ModalTable
.
ajax
.
reload
();
}
}
function
init
Tree2
()
{
function
init
ModalTree
()
{
var
url
=
'{% url '
api
-
assets
:
node
-
children
-
tree
' %}?assets=0'
;
var
url
=
'{% url '
api
-
assets
:
node
-
children
-
tree
' %}?assets=0'
;
var
setting
=
{
var
setting
=
{
view
:
{
view
:
{
...
@@ -102,17 +173,34 @@ function initTree2() {
...
@@ -102,17 +173,34 @@ function initTree2() {
type
:
'get'
type
:
'get'
},
},
callback
:
{
callback
:
{
onSelected
:
on
NodeSelected2
onSelected
:
on
ModalTreeNodeSelected
}
}
};
};
zTree2
=
$
.
fn
.
zTree
.
init
(
$
(
"#assetTree2"
),
setting
);
$
.
get
(
url
,
function
(
data
,
status
){
$
.
fn
.
zTree
.
init
(
$
(
"#asset_modal_tree"
),
setting
);
assetModalTree
=
$
.
fn
.
zTree
.
getZTreeObj
(
"assetTree2"
);
if
(
assetModalOption
.
onModalTreeDone
)
{
assetModalOption
.
onModalTreeDone
(
assetModalTree
);
}
return
assetModalTree
;
});
}
function
setAssetModalOptions
(
options
)
{
assetModalOption
=
options
;
}
}
$
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
}).
on
(
'show.bs.modal'
,
function
()
{
}).
on
(
'show.bs.modal'
,
function
()
{
initTable2
();
initAssetModalTable
();
initTree2
();
initModalTree
();
}).
on
(
'click'
,
'#btn_asset_modal_confirm'
,
function
()
{
if
(
assetModalOption
.
onModalConfirm
)
{
assetModalOption
.
onModalConfirm
(
assetModalTable
,
assetModalTree
);
}
$
(
"#asset_list_modal"
).
modal
(
'hide'
);
})
})
</script>
</script>
{% endblock %}
{% endblock %}
...
...
apps/assets/templates/assets/asset_list.html
View file @
a8ac99f6
...
@@ -226,6 +226,33 @@ function onNodeSelected(event, treeNode) {
...
@@ -226,6 +226,33 @@ function onNodeSelected(event, treeNode) {
asset_table
.
ajax
.
reload
();
asset_table
.
ajax
.
reload
();
}
}
function
onAssetModalConfirmAddAssetToNode
(
table
)
{
var
assets_selected
=
table
.
selected
;
if
(
!
current_node_id
)
{
return
}
var
data
=
{
'assets'
:
assets_selected
};
var
success
=
function
()
{
table
.
selected
=
[];
table
.
ajax
.
reload
()
};
var
url
=
''
;
if
(
update_node_action
===
"move"
)
{
url
=
"{% url 'api-assets:node-replace-assets' pk=DEFAULT_PK %}"
.
replace
(
"{{ DEFAULT_PK }}"
,
current_node_id
);
}
else
{
url
=
"{% url 'api-assets:node-add-assets' pk=DEFAULT_PK %}"
.
replace
(
"{{ DEFAULT_PK }}"
,
current_node_id
);
}
requestApi
({
'url'
:
url
,
'method'
:
'PUT'
,
'body'
:
JSON
.
stringify
(
data
),
'success'
:
success
})
}
$
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
initTable
();
initTable
();
initTree
();
initTree
();
...
@@ -236,6 +263,12 @@ $(document).ready(function(){
...
@@ -236,6 +263,12 @@ $(document).ready(function(){
else
{
else
{
$
(
'#show_current_asset'
).
css
(
'display'
,
'inline-block'
);
$
(
'#show_current_asset'
).
css
(
'display'
,
'inline-block'
);
}
}
var
modalOption
=
{
onModalConfirm
:
onAssetModalConfirmAddAssetToNode
,
onModalTableDone
:
null
};
setAssetModalOptions
(
modalOption
);
})
})
.
on
(
'click'
,
'.labels li'
,
function
()
{
.
on
(
'click'
,
'.labels li'
,
function
()
{
var
val
=
$
(
this
).
text
();
var
val
=
$
(
this
).
text
();
...
@@ -429,7 +462,6 @@ $(document).ready(function(){
...
@@ -429,7 +462,6 @@ $(document).ready(function(){
}
}
function
doRemove
()
{
function
doRemove
()
{
var
nodes
=
zTree
.
getSelectedNodes
();
if
(
!
current_node_id
)
{
if
(
!
current_node_id
)
{
return
return
}
}
...
@@ -472,32 +504,7 @@ $(document).ready(function(){
...
@@ -472,32 +504,7 @@ $(document).ready(function(){
}
}
$
(
".ipt_check_all"
).
prop
(
"checked"
,
false
)
$
(
".ipt_check_all"
).
prop
(
"checked"
,
false
)
})
})
.
on
(
'click'
,
'#btn_asset_modal_confirm'
,
function
()
{
.
on
(
'hidden.bs.modal'
,
'#asset_list_modal'
,
function
()
{
var
assets_selected
=
asset_table2
.
selected
;
if
(
!
current_node_id
)
{
return
}
var
data
=
{
'assets'
:
assets_selected
};
var
success
=
function
()
{
asset_table2
.
selected
=
[];
asset_table2
.
ajax
.
reload
()
};
var
url
=
''
;
if
(
update_node_action
===
"move"
)
{
url
=
"{% url 'api-assets:node-replace-assets' pk=DEFAULT_PK %}"
.
replace
(
"{{ DEFAULT_PK }}"
,
current_node_id
);
}
else
{
url
=
"{% url 'api-assets:node-add-assets' pk=DEFAULT_PK %}"
.
replace
(
"{{ DEFAULT_PK }}"
,
current_node_id
);
}
requestApi
({
'url'
:
url
,
'method'
:
'PUT'
,
'body'
:
JSON
.
stringify
(
data
),
'success'
:
success
})
}).
on
(
'hidden.bs.modal'
,
'#asset_list_modal'
,
function
()
{
window
.
location
.
reload
();
window
.
location
.
reload
();
}).
on
(
'click'
,
'#menu_asset_add'
,
function
()
{
}).
on
(
'click'
,
'#menu_asset_add'
,
function
()
{
update_node_action
=
"add"
update_node_action
=
"add"
...
...
apps/assets/templates/assets/domain_create_update.html
View file @
a8ac99f6
...
@@ -28,25 +28,6 @@ $(document).ready(function () {
...
@@ -28,25 +28,6 @@ $(document).ready(function () {
}).
on
(
'click'
,
'.select2-selection__rendered'
,
function
(
e
)
{
}).
on
(
'click'
,
'.select2-selection__rendered'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
$
(
"#asset_list_modal"
).
modal
();
$
(
"#asset_list_modal"
).
modal
();
initSelectedAssets2Table
();
})
.
on
(
'click'
,
'#btn_asset_modal_confirm'
,
function
()
{
var
assets
=
asset_table2
.
selected
;
var
options
=
[];
$
(
'#id_assets option'
).
each
(
function
(
i
,
v
)
{
options
.
push
(
v
.
value
)
});
asset_table2
.
selected_rows
.
forEach
(
function
(
i
)
{
var
name
=
i
.
hostname
+
'('
+
i
.
ip
+
')'
;
var
option
=
new
Option
(
name
,
i
.
id
,
false
,
true
);
if
(
options
.
indexOf
(
i
.
id
)
===
-
1
)
{
$
(
'#id_assets'
).
append
(
option
).
trigger
(
'change'
);
}
});
$
(
'.select2'
).
val
(
assets
).
trigger
(
'change'
);
$
(
"#asset_list_modal"
).
modal
(
'hide'
);
})
})
.
on
(
"submit"
,
"form"
,
function
(
evt
)
{
.
on
(
"submit"
,
"form"
,
function
(
evt
)
{
evt
.
preventDefault
();
evt
.
preventDefault
();
...
...
apps/assets/templates/assets/label_create_update.html
View file @
a8ac99f6
...
@@ -32,24 +32,6 @@ $(document).ready(function () {
...
@@ -32,24 +32,6 @@ $(document).ready(function () {
}).
on
(
'click'
,
'.select2-selection__rendered'
,
function
(
e
)
{
}).
on
(
'click'
,
'.select2-selection__rendered'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
$
(
"#asset_list_modal"
).
modal
();
$
(
"#asset_list_modal"
).
modal
();
initSelectedAssets2Table
();
})
.
on
(
'click'
,
'#btn_asset_modal_confirm'
,
function
()
{
var
assets
=
asset_table2
.
selected
;
var
options
=
[];
$
(
'#id_assets option'
).
each
(
function
(
i
,
v
)
{
options
.
push
(
v
.
value
)
});
asset_table2
.
selected_rows
.
forEach
(
function
(
i
)
{
var
name
=
i
.
hostname
+
'('
+
i
.
ip
+
')'
;
var
option
=
new
Option
(
name
,
i
.
id
,
false
,
true
);
if
(
options
.
indexOf
(
i
.
id
)
===
-
1
)
{
$
(
'#id_assets'
).
append
(
option
).
trigger
(
'change'
);
}
});
$
(
'#id_assets'
).
val
(
assets
).
trigger
(
'change'
);
$
(
"#asset_list_modal"
).
modal
(
'hide'
);
})
})
.
on
(
"submit"
,
"form"
,
function
(
evt
)
{
.
on
(
"submit"
,
"form"
,
function
(
evt
)
{
evt
.
preventDefault
();
evt
.
preventDefault
();
...
...
apps/common/signals_handlers.py
View file @
a8ac99f6
...
@@ -14,7 +14,7 @@ from .local import thread_local
...
@@ -14,7 +14,7 @@ from .local import thread_local
pattern
=
re
.
compile
(
r'FROM `(\w+)`'
)
pattern
=
re
.
compile
(
r'FROM `(\w+)`'
)
logger
=
get_logger
(
__name__
)
logger
=
get_logger
(
__name__
)
DEBUG_DB
_QUERY
=
os
.
environ
.
get
(
'DEBUG_DB_QUERY
'
,
'0'
)
==
'1'
DEBUG_DB
=
os
.
environ
.
get
(
'DEBUG_DB
'
,
'0'
)
==
'1'
class
Counter
:
class
Counter
:
...
@@ -58,7 +58,7 @@ def on_request_finished_release_local(sender, **kwargs):
...
@@ -58,7 +58,7 @@ def on_request_finished_release_local(sender, **kwargs):
thread_local
.
__release_local__
()
thread_local
.
__release_local__
()
if
settings
.
DEBUG
and
DEBUG_DB
_QUERY
:
if
settings
.
DEBUG
and
DEBUG_DB
:
request_finished
.
connect
(
on_request_finished_logging_db_query
)
request_finished
.
connect
(
on_request_finished_logging_db_query
)
...
...
apps/jumpserver/settings.py
View file @
a8ac99f6
...
@@ -607,8 +607,10 @@ SWAGGER_SETTINGS = {
...
@@ -607,8 +607,10 @@ SWAGGER_SETTINGS = {
'in'
:
'header'
'in'
:
'header'
}
}
},
},
'DEFAULT_API_URL'
:
'http://www.fit2cloud.com'
}
}
# Default email suffix
# Default email suffix
EMAIL_SUFFIX
=
CONFIG
.
EMAIL_SUFFIX
EMAIL_SUFFIX
=
CONFIG
.
EMAIL_SUFFIX
LOGIN_LOG_KEEP_DAYS
=
CONFIG
.
LOGIN_LOG_KEEP_DAYS
LOGIN_LOG_KEEP_DAYS
=
CONFIG
.
LOGIN_LOG_KEEP_DAYS
...
...
apps/ops/templates/ops/command_execution_list.html
View file @
a8ac99f6
...
@@ -110,10 +110,16 @@ $(document).ready(function() {
...
@@ -110,10 +110,16 @@ $(document).ready(function() {
data_list
.
pop
();
data_list
.
pop
();
}
}
var
html
=
createPopover
(
data_list
);
var
html
=
createPopover
(
data_list
);
console
.
log
(
html
);
$
(
this
).
html
(
html
);
$
(
this
).
html
(
html
);
});
});
$
(
'[data-toggle=popover]'
).
popover
({
html
:
true
});
$
(
'[data-toggle="popover"]'
).
popover
({
html
:
true
,
placement
:
'bottom'
,
trigger
:
'click'
,
container
:
'body'
}).
on
(
'click'
,
function
(
e
)
{
$
(
'[data-toggle="popover"]'
).
not
(
this
).
popover
(
'hide'
);
});
})
})
</script>
</script>
{% endblock %}
{% endblock %}
...
...
apps/perms/api/asset_permission.py
View file @
a8ac99f6
...
@@ -97,6 +97,8 @@ class AssetPermissionViewSet(viewsets.ModelViewSet):
...
@@ -97,6 +97,8 @@ class AssetPermissionViewSet(viewsets.ModelViewSet):
inherit_nodes_keys
=
assets
.
all
()
.
values_list
(
'nodes__key'
,
flat
=
True
)
inherit_nodes_keys
=
assets
.
all
()
.
values_list
(
'nodes__key'
,
flat
=
True
)
for
key
in
inherit_nodes_keys
:
for
key
in
inherit_nodes_keys
:
if
key
is
None
:
continue
ancestor_keys
=
Node
.
get_nodes_ancestor_keys_by_key
(
key
,
with_self
=
True
)
ancestor_keys
=
Node
.
get_nodes_ancestor_keys_by_key
(
key
,
with_self
=
True
)
inherit_all_nodes
.
update
(
ancestor_keys
)
inherit_all_nodes
.
update
(
ancestor_keys
)
queryset
=
queryset
.
filter
(
queryset
=
queryset
.
filter
(
...
...
apps/perms/forms/asset_permission.py
View file @
a8ac99f6
...
@@ -53,6 +53,16 @@ class AssetPermissionForm(OrgModelForm):
...
@@ -53,6 +53,16 @@ class AssetPermissionForm(OrgModelForm):
assets_field
.
queryset
=
Asset
.
objects
.
none
()
assets_field
.
queryset
=
Asset
.
objects
.
none
()
nodes_field
.
queryset
=
Node
.
objects
.
none
()
nodes_field
.
queryset
=
Node
.
objects
.
none
()
def
set_nodes_initial
(
self
,
nodes
):
field
=
self
.
fields
[
'nodes'
]
field
.
choices
=
[(
n
.
id
,
n
.
full_value
)
for
n
in
nodes
]
field
.
initial
=
nodes
def
set_assets_initial
(
self
,
assets
):
field
=
self
.
fields
[
'assets'
]
field
.
choices
=
[(
a
.
id
,
a
.
hostname
)
for
a
in
assets
]
field
.
initial
=
assets
class
Meta
:
class
Meta
:
model
=
AssetPermission
model
=
AssetPermission
exclude
=
(
exclude
=
(
...
...
apps/perms/signals_handler.py
View file @
a8ac99f6
...
@@ -47,7 +47,7 @@ def on_permission_nodes_changed(sender, instance=None, action='', **kwargs):
...
@@ -47,7 +47,7 @@ def on_permission_nodes_changed(sender, instance=None, action='', **kwargs):
if
isinstance
(
instance
,
AssetPermission
):
if
isinstance
(
instance
,
AssetPermission
):
logger
.
debug
(
"Asset permission nodes change signal received"
)
logger
.
debug
(
"Asset permission nodes change signal received"
)
nodes
=
kwargs
[
'model'
]
.
objects
.
filter
(
pk__in
=
kwargs
[
'pk_set'
])
nodes
=
kwargs
[
'model'
]
.
objects
.
filter
(
pk__in
=
kwargs
[
'pk_set'
])
system_users
=
instance
.
system_users
.
all
()
.
values_list
(
'id'
,
flat
=
True
)
system_users
=
instance
.
system_users
.
all
()
for
system_user
in
system_users
:
for
system_user
in
system_users
:
system_user
.
nodes
.
add
(
*
tuple
(
nodes
))
system_user
.
nodes
.
add
(
*
tuple
(
nodes
))
...
@@ -59,7 +59,7 @@ def on_permission_assets_changed(sender, instance=None, action='', **kwargs):
...
@@ -59,7 +59,7 @@ def on_permission_assets_changed(sender, instance=None, action='', **kwargs):
if
isinstance
(
instance
,
AssetPermission
):
if
isinstance
(
instance
,
AssetPermission
):
logger
.
debug
(
"Asset permission assets change signal received"
)
logger
.
debug
(
"Asset permission assets change signal received"
)
assets
=
kwargs
[
'model'
]
.
objects
.
filter
(
pk__in
=
kwargs
[
'pk_set'
])
assets
=
kwargs
[
'model'
]
.
objects
.
filter
(
pk__in
=
kwargs
[
'pk_set'
])
system_users
=
instance
.
system_users
.
all
()
.
values_list
(
'id'
,
flat
=
True
)
system_users
=
instance
.
system_users
.
all
()
for
system_user
in
system_users
:
for
system_user
in
system_users
:
system_user
.
assets
.
add
(
*
tuple
(
assets
))
system_user
.
assets
.
add
(
*
tuple
(
assets
))
...
...
apps/perms/templates/perms/asset_permission_asset.html
View file @
a8ac99f6
...
@@ -100,10 +100,7 @@
...
@@ -100,10 +100,7 @@
<form>
<form>
<tr>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<td
colspan=
"2"
class=
"no-borders"
>
<select
data-placeholder=
"{% trans 'Select nodes' %}"
class=
"select2"
id=
"node_select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans 'Select nodes' %}"
class=
"nodes-select2"
id=
"nodes_select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for node in nodes_remain %}
<option
value=
"{{ node.id }}"
id=
"opt_{{ node.id }}"
>
{{ node.full_value }}
</option>
{% endfor %}
</select>
</select>
</td>
</td>
</tr>
</tr>
...
@@ -202,35 +199,22 @@ function initAssetTable() {
...
@@ -202,35 +199,22 @@ function initAssetTable() {
return
table
return
table
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
();
table
=
initAssetTable
();
table
=
initAssetTable
();
var
nodeListUrl
=
"{% url 'api-assets:node-list' %}"
;
nodesSelect2Init
(
".nodes-select2"
,
nodeListUrl
);
$
(
"#asset_select2"
).
parent
().
find
(
".select2-selection"
).
on
(
'click'
,
function
(
e
)
{
$
(
"#asset_select2"
).
parent
().
find
(
".select2-selection"
).
on
(
'click'
,
function
(
e
)
{
if
(
$
(
e
.
target
).
attr
(
'class'
)
!==
'select2-selection__choice__remove'
){
if
(
$
(
e
.
target
).
attr
(
'class'
)
!==
'select2-selection__choice__remove'
){
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
stopPropagation
();
$
(
"#asset_list_modal"
).
modal
();
$
(
"#asset_list_modal"
).
modal
();
initSelectedAssets2Table
(
'#asset_select2'
);
}
}
})
})
})
})
.
on
(
'click'
,
'#btn_asset_modal_confirm'
,
function
()
{
var
assets
=
asset_table2
.
selected
;
var
options
=
[];
$
(
'#asset_select2 option'
).
each
(
function
(
i
,
v
)
{
options
.
push
(
v
.
value
)
});
asset_table2
.
selected_rows
.
forEach
(
function
(
i
)
{
var
name
=
i
.
hostname
+
'('
+
i
.
ip
+
')'
;
var
option
=
new
Option
(
name
,
i
.
id
,
false
,
true
);
if
(
options
.
indexOf
(
i
.
id
)
===
-
1
)
{
$
(
'#asset_select2'
).
append
(
option
).
trigger
(
'change'
);
}
});
$
(
'#asset_select2'
).
val
(
assets
).
trigger
(
'change'
);
$
(
"#asset_list_modal"
).
modal
(
'hide'
);
})
.
on
(
'click'
,
'.btn-add-assets'
,
function
()
{
.
on
(
'click'
,
'.btn-add-assets'
,
function
()
{
var
assets_selected
=
$
(
"#asset_select2 option:selected"
).
map
(
function
()
{
var
assets_selected
=
$
(
"#asset_select2 option:selected"
).
map
(
function
()
{
return
$
(
this
).
attr
(
'value'
);
return
$
(
this
).
attr
(
'value'
);
...
@@ -250,7 +234,7 @@ $(document).ready(function () {
...
@@ -250,7 +234,7 @@ $(document).ready(function () {
})
})
.
on
(
'click'
,
'#btn-add-node'
,
function
()
{
.
on
(
'click'
,
'#btn-add-node'
,
function
()
{
var
nodes_selected
=
{};
var
nodes_selected
=
{};
$
(
"#node_select2 option:selected"
).
each
(
function
(
i
,
data
)
{
$
(
"#node
s
_select2 option:selected"
).
each
(
function
(
i
,
data
)
{
nodes_selected
[
$
(
data
).
attr
(
'value'
)]
=
$
(
data
).
text
();
nodes_selected
[
$
(
data
).
attr
(
'value'
)]
=
$
(
data
).
text
();
});
});
if
(
Object
.
keys
(
nodes_selected
).
length
===
0
)
{
if
(
Object
.
keys
(
nodes_selected
).
length
===
0
)
{
...
...
apps/perms/templates/perms/asset_permission_create_update.html
View file @
a8ac99f6
...
@@ -111,31 +111,57 @@ var dateOptions = {
...
@@ -111,31 +111,57 @@ var dateOptions = {
}
}
};
};
var
api_action
=
"{{ api_action }}"
;
var
api_action
=
"{{ api_action }}"
;
function
onAssetModalConfirm
(
table
)
{
var
assets
=
assetModalTable
.
selected
;
var
options
=
[];
$
(
'#id_assets option'
).
each
(
function
(
i
,
v
)
{
options
.
push
(
v
.
value
)
});
assetModalTable
.
selected_rows
.
forEach
(
function
(
i
)
{
var
name
=
i
.
hostname
+
'('
+
i
.
ip
+
')'
;
var
option
=
new
Option
(
name
,
i
.
id
,
false
,
true
);
if
(
options
.
indexOf
(
i
.
id
)
===
-
1
)
{
$
(
'#id_assets'
).
append
(
option
).
trigger
(
'change'
);
}
});
$
(
'#id_assets'
).
val
(
assets
).
trigger
(
'change'
);
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
({
$
(
'.select2'
).
select2
({
closeOnSelect
:
false
closeOnSelect
:
false
});
});
var
url
=
"{% url 'api-assets:node-list' %}"
;
var
url
=
"{% url 'api-assets:node-list' %}"
;
nodesSelect2Init
(
".nodes-select2"
,
url
);
nodesSelect2Init
(
".nodes-select2"
,
url
);
$
(
'#date_start'
).
daterangepicker
(
dateOptions
);
$
(
'#date_start'
).
daterangepicker
(
dateOptions
);
$
(
'#date_expired'
).
daterangepicker
(
dateOptions
);
$
(
'#date_expired'
).
daterangepicker
(
dateOptions
);
var
modalOption
=
{
onModalConfirm
:
onAssetModalConfirm
,
onAssetTableDone
:
function
(
modalTable
)
{
syncSelectedAssetsToModalTable
(
modalTable
)
},
};
setAssetModalOptions
(
modalOption
);
$
(
"#id_assets"
).
parent
().
find
(
".select2-selection"
).
on
(
'click'
,
function
(
e
)
{
$
(
"#id_assets"
).
parent
().
find
(
".select2-selection"
).
on
(
'click'
,
function
(
e
)
{
if
(
$
(
e
.
target
).
attr
(
'class'
)
!==
'select2-selection__choice__remove'
){
if
(
$
(
e
.
target
).
attr
(
'class'
)
!==
'select2-selection__choice__remove'
){
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
stopPropagation
();
$
(
"#asset_list_modal"
).
modal
();
$
(
"#asset_list_modal"
).
modal
();
initSelectedAssets2Table
();
}
}
})
})
})
})
.
on
(
'click'
,
'#btn_asset_modal_confirm'
,
function
()
{
.
on
(
'click'
,
'#btn_asset_modal_confirm'
,
function
()
{
var
assets
=
asset
_table2
.
selected
;
var
assets
=
asset
ModalTable
.
selected
;
var
options
=
[];
var
options
=
[];
$
(
'#id_assets option'
).
each
(
function
(
i
,
v
)
{
$
(
'#id_assets option'
).
each
(
function
(
i
,
v
)
{
options
.
push
(
v
.
value
)
options
.
push
(
v
.
value
)
});
});
asset
_table2
.
selected_rows
.
forEach
(
function
(
i
)
{
asset
ModalTable
.
selected_rows
.
forEach
(
function
(
i
)
{
var
name
=
i
.
hostname
+
'('
+
i
.
ip
+
')'
;
var
name
=
i
.
hostname
+
'('
+
i
.
ip
+
')'
;
var
option
=
new
Option
(
name
,
i
.
id
,
false
,
true
);
var
option
=
new
Option
(
name
,
i
.
id
,
false
,
true
);
...
...
apps/perms/templates/perms/asset_permission_list.html
View file @
a8ac99f6
...
@@ -227,7 +227,6 @@ function toggle() {
...
@@ -227,7 +227,6 @@ function toggle() {
$
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
initTable
();
initTable
();
initTree
();
initTree
();
})
})
.
on
(
'click'
,
'.btn-del'
,
function
()
{
.
on
(
'click'
,
'.btn-del'
,
function
()
{
var
$this
=
$
(
this
);
var
$this
=
$
(
this
);
...
@@ -247,17 +246,19 @@ $(document).ready(function(){
...
@@ -247,17 +246,19 @@ $(document).ready(function(){
})
})
.
on
(
'click'
,
'.btn-create-permission'
,
function
()
{
.
on
(
'click'
,
'.btn-create-permission'
,
function
()
{
var
url
=
"{% url 'perms:asset-permission-create' %}"
;
var
url
=
"{% url 'perms:asset-permission-create' %}"
;
var
nodes
=
zTree
.
getSelectedNodes
();
if
(
zTree
)
{
var
_nodes
=
[];
var
nodes
=
zTree
.
getSelectedNodes
();
var
_assets
=
[];
var
_nodes
=
[];
$
.
each
(
nodes
,
function
(
id
,
node
)
{
var
_assets
=
[];
if
(
node
.
meta
.
type
===
'node'
)
{
$
.
each
(
nodes
,
function
(
id
,
node
)
{
_nodes
.
push
(
node
.
meta
.
node
.
id
)
if
(
node
.
meta
.
type
===
'node'
)
{
}
else
{
_nodes
.
push
(
node
.
meta
.
node
.
id
)
_assets
.
push
(
node
.
meta
.
asset
.
id
)
}
else
{
}
_assets
.
push
(
node
.
meta
.
asset
.
id
)
});
}
url
+=
"?assets="
+
_assets
.
join
(
","
)
+
"&nodes="
+
_nodes
.
join
(
","
);
});
url
+=
"?assets="
+
_assets
.
join
(
","
)
+
"&nodes="
+
_nodes
.
join
(
","
);
}
window
.
open
(
url
,
'_self'
);
window
.
open
(
url
,
'_self'
);
}).
on
(
'click'
,
'.toggle'
,
function
(
e
)
{
}).
on
(
'click'
,
'.toggle'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
...
@@ -283,7 +284,6 @@ $(document).ready(function(){
...
@@ -283,7 +284,6 @@ $(document).ready(function(){
detailRows
.
push
(
tr
.
attr
(
'id'
));
detailRows
.
push
(
tr
.
attr
(
'id'
));
}
}
}
}
}).
on
(
'click'
,
'#permission_list_table_filter input'
,
function
(
e
)
{
}).
on
(
'click'
,
'#permission_list_table_filter input'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
stopPropagation
();
...
...
apps/perms/views/asset_permission.py
View file @
a8ac99f6
...
@@ -53,11 +53,11 @@ class AssetPermissionCreateView(PermissionsMixin, CreateView):
...
@@ -53,11 +53,11 @@ class AssetPermissionCreateView(PermissionsMixin, CreateView):
nodes_id
=
nodes_id
.
split
(
","
)
nodes_id
=
nodes_id
.
split
(
","
)
nodes
=
Node
.
objects
.
filter
(
id__in
=
nodes_id
)
\
nodes
=
Node
.
objects
.
filter
(
id__in
=
nodes_id
)
\
.
exclude
(
id
=
Node
.
org_root
()
.
id
)
.
exclude
(
id
=
Node
.
org_root
()
.
id
)
form
[
'nodes'
]
.
initial
=
nodes
form
.
set_nodes_initial
(
nodes
)
if
assets_id
:
if
assets_id
:
assets_id
=
assets_id
.
split
(
","
)
assets_id
=
assets_id
.
split
(
","
)
assets
=
Asset
.
objects
.
filter
(
id__in
=
assets_id
)
assets
=
Asset
.
objects
.
filter
(
id__in
=
assets_id
)
form
[
'assets'
]
.
initial
=
assets
form
.
set_assets_initial
(
assets
)
return
form
return
form
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
...
...
apps/settings/templates/settings/_ldap_list_users_modal.html
View file @
a8ac99f6
...
@@ -17,13 +17,6 @@
...
@@ -17,13 +17,6 @@
padding
:
10px
10px
;
padding
:
10px
10px
;
text-align
:
center
;
text-align
:
center
;
}
}
#assetTree2
.ztree
*
{
background-color
:
#f8fafb
;
}
#assetTree2
.ztree
{
background-color
:
#f8fafb
;
}
</style>
</style>
<div
class=
"wrapper wrapper-content"
>
<div
class=
"wrapper wrapper-content"
>
...
...
apps/static/js/jumpserver.js
View file @
a8ac99f6
This diff is collapsed.
Click to expand it.
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