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
3ccd5468
Commit
3ccd5468
authored
Apr 14, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修改授权详情快速Node更改失效的bug
parent
071d14c6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
62 deletions
+47
-62
system_user_detail.html
apps/assets/templates/assets/system_user_detail.html
+2
-2
urls.py
apps/jumpserver/urls.py
+2
-4
asset_permission_asset.html
apps/perms/templates/perms/asset_permission_asset.html
+38
-51
asset_permission_detail.html
apps/perms/templates/perms/asset_permission_detail.html
+2
-2
asset_permission_user.html
apps/perms/templates/perms/asset_permission_user.html
+3
-3
No files found.
apps/assets/templates/assets/system_user_detail.html
View file @
3ccd5468
...
...
@@ -173,7 +173,7 @@
<td
colspan=
"2"
class=
"no-borders"
>
<select
data-placeholder=
"{% trans 'Add to node' %}"
id=
"node_selected"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for node in nodes_remain %}
<option
value=
"{{ node.id }}"
id=
"opt_{{ node.id }}"
>
{{ node
.name
}}
</option>
<option
value=
"{{ node.id }}"
id=
"opt_{{ node.id }}"
>
{{ node }}
</option>
{% endfor %}
</select>
</td>
...
...
@@ -187,7 +187,7 @@
{% for node in system_user.nodes.all %}
<tr>
<td
><b
class=
"bdg_node"
data-gid=
{{
node
.
id
}}
>
{{ node
.name
}}
</b></td>
<td
><b
class=
"bdg_node"
data-gid=
{{
node
.
id
}}
>
{{ node }}
</b></td>
<td>
<button
class=
"btn btn-danger pull-right btn-xs btn-remove-from-node"
type=
"button"
><i
class=
"fa fa-minus"
></i></button>
</td>
...
...
apps/jumpserver/urls.py
View file @
3ccd5468
...
...
@@ -36,12 +36,10 @@ urlpatterns = [
url
(
r'^captcha/'
,
include
(
'captcha.urls'
)),
]
urlpatterns
+=
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
urlpatterns
+=
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
\
+
static
(
settings
.
STATIC_URL
,
document_root
=
settings
.
STATIC_ROOT
)
if
settings
.
DEBUG
:
urlpatterns
+=
[
url
(
r'^docs/'
,
schema_view
,
name
=
"docs"
),
]
if
not
settings
.
DEBUG
:
urlpatterns
+=
static
(
settings
.
STATIC_URL
,
document_root
=
settings
.
STATIC_ROOT
)
apps/perms/templates/perms/asset_permission_asset.html
View file @
3ccd5468
...
...
@@ -85,9 +85,9 @@
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select assets' %}"
class=
"select2
asset
"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans 'Select assets' %}"
class=
"select2
"
id=
"asset_select2
"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset in assets_remain %}
<option
value=
"{{ asset.id }}"
>
{{ asset
.hostname
}}
</option>
<option
value=
"{{ asset.id }}"
>
{{ asset }}
</option>
{% endfor %}
</select>
</td>
...
...
@@ -113,9 +113,9 @@
<form>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<select
data-placeholder=
"{% trans 'Select nodes' %}"
class=
"select2
group
"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans 'Select nodes' %}"
class=
"select2
"
id=
"node_select2
"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for node in nodes_remain %}
<option
value=
"{{ node.id }}"
id=
"opt_{{ node.id }}"
>
{{ node
.value
}}
</option>
<option
value=
"{{ node.id }}"
id=
"opt_{{ node.id }}"
>
{{ node }}
</option>
{% endfor %}
</select>
</td>
...
...
@@ -129,9 +129,9 @@
{% for node in asset_permission.nodes.all %}
<tr>
<td
><b
class=
"bdg_
user_group"
data-gid=
{{
node
.
id
}}
>
{{ node.valu
e }}
</b></td>
<td
><b
class=
"bdg_
group"
data-gid=
{{
node
.
id
}}
>
{{ nod
e }}
</b></td>
<td>
<button
class=
"btn btn-danger btn-xs btn-remove-node"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
<button
class=
"btn btn-danger btn-xs btn-remove-node"
type=
"button"
data-gid=
"{{ node.id }}"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
{% endfor %}
...
...
@@ -179,49 +179,30 @@ function removeAssets(assets) {
});
}
function
updateNodes
(
nodes
)
{
function
updateNodes
(
nodes
,
success
)
{
var
the_url
=
"{% url 'api-perms:asset-permission-detail' pk=asset_permission.id %}"
;
var
body
=
{
nodes
:
nodes
};
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
(
body
)
body
:
JSON
.
stringify
(
body
),
success
:
success
});
}
jumpserver
.
assets_selected
=
{};
jumpserver
.
nodes_selected
=
{};
$
(
document
).
ready
(
function
()
{
$
(
'.select2.asset'
).
select2
()
.
on
(
'select2:select'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
assets_selected
[
data
.
id
]
=
data
.
text
;
})
.
on
(
'select2:unselect'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
delete
jumpserver
.
assets_selected
[
data
.
id
]
});
$
(
'.select2.group'
).
select2
()
.
on
(
'select2:select'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
nodes_selected
[
data
.
id
]
=
data
.
text
;
})
.
on
(
'select2:unselect'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
delete
jumpserver
.
nodes_selected
[
data
.
id
]
})
$
(
'.select2'
).
select2
();
})
.
on
(
'click'
,
'.btn-add-assets'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
assets_selected
).
length
===
0
)
{
var
assets_selected
=
$
(
"#asset_select2 option:selected"
).
map
(
function
()
{
return
$
(
this
).
attr
(
'value'
);
}).
get
();
if
(
assets_selected
.
length
===
0
)
{
return
false
;
}
var
assets
=
[];
$
.
map
(
jumpserver
.
assets_selected
,
function
(
value
,
index
)
{
assets
.
push
(
index
);
});
addAssets
(
assets
);
addAssets
(
assets_selected
);
})
.
on
(
'click'
,
'.btn-remove-asset'
,
function
()
{
var
asset_id
=
$
(
this
).
data
(
"gid"
);
...
...
@@ -232,26 +213,30 @@ $(document).ready(function () {
removeAssets
(
assets
)
})
.
on
(
'click'
,
'#btn-add-node'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
nodes_selected
).
length
===
0
)
{
var
nodes_selected
=
{};
$
(
"#node_select2 option:selected"
).
each
(
function
(
i
,
data
)
{
nodes_selected
[
$
(
data
).
attr
(
'value'
)]
=
$
(
data
).
text
();
});
if
(
Object
.
keys
(
nodes_selected
).
length
===
0
)
{
return
false
;
}
var
nodes
=
$
(
'.bdg_group'
).
map
(
function
()
{
var
nodes_origin
=
$
(
'.bdg_group'
).
map
(
function
()
{
return
$
(
this
).
data
(
'gid'
);
}).
get
();
$
.
map
(
jumpserver
.
nodes_selected
,
function
(
group_name
,
index
)
{
nodes
.
push
(
index
);
$
(
'#opt_'
+
index
).
remove
();
$
(
'.group_edit tbody'
).
append
(
'<tr>'
+
'<td><b class="bdg_group" data-gid="'
+
index
+
'">'
+
group_name
+
'</b></td>'
+
'<td><button class="btn btn-danger btn-xs pull-right btn-leave-group" type="button"><i class="fa fa-minus"></i></button></td>'
+
'</tr>'
)
});
updateNodes
(
nodes
);
var
nodes
=
nodes_origin
.
concat
(
Object
.
keys
(
nodes_selected
));
var
success
=
function
()
{
$
.
map
(
nodes_selected
,
function
(
name
,
id
)
{
$
(
'#opt_'
+
id
).
remove
();
$
(
'.group_edit tbody'
).
append
(
'<tr>'
+
'<td><b class="bdg_group" data-gid="'
+
id
+
'">'
+
name
+
'</b></td>'
+
'<td><button class="btn btn-danger btn-xs pull-right btn-leave-group" type="button"><i class="fa fa-minus"></i></button></td>'
+
'</tr>'
)
});
};
updateNodes
(
nodes
,
success
);
})
.
on
(
'click'
,
'.btn-remove-node'
,
function
()
{
var
$this
=
$
(
this
);
...
...
@@ -261,8 +246,10 @@ $(document).ready(function () {
return
$
(
this
).
data
(
'gid'
);
}
}).
get
();
updateNodes
(
nodes
);
$tr
.
remove
()
var
success
=
function
()
{
$tr
.
remove
()
};
updateNodes
(
nodes
,
success
);
})
</script>
{% endblock %}
apps/perms/templates/perms/asset_permission_detail.html
View file @
3ccd5468
...
...
@@ -147,7 +147,7 @@
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select system users' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for system_user in system_users_remain %}
<option
value=
"{{ system_user.id }}"
id=
"opt_{{ system_user.id }}"
>
{{ system_user
.name
}}
</option>
<option
value=
"{{ system_user.id }}"
id=
"opt_{{ system_user.id }}"
>
{{ system_user }}
</option>
{% endfor %}
</select>
</td>
...
...
@@ -161,7 +161,7 @@
{% for system_user in object.system_users.all %}
<tr
{%
if
forloop
.
counter =
=
1
%}
class=
"no-borders-tr"
{%
endif
%}
>
<td
><b
class=
"bdg-system-user"
data-uid=
{{
system_user
.
id
}}
>
{{ system_user
.name
}}
</b></td>
<td
><b
class=
"bdg-system-user"
data-uid=
{{
system_user
.
id
}}
>
{{ system_user }}
</b></td>
<td>
<button
class=
"btn btn-danger btn-xs btn-remove-user"
data-uid=
"{{ system_user.id }}"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
...
...
apps/perms/templates/perms/asset_permission_user.html
View file @
3ccd5468
...
...
@@ -87,7 +87,7 @@
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select user' %}"
class=
"select2 user"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for user in users_remain %}
<option
value=
"{{ user.id }}"
>
{{ user
.name
}}
</option>
<option
value=
"{{ user.id }}"
>
{{ user }}
</option>
{% endfor %}
</select>
</td>
...
...
@@ -115,7 +115,7 @@
<td
colspan=
"2"
class=
"no-borders"
>
<select
data-placeholder=
"{% trans 'Select user groups' %}"
class=
"select2 user-group"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for user_group in user_groups_remain %}
<option
value=
"{{ user_group.id }}"
id=
"opt_{{ user_group.id }}"
>
{{ user_group
.name
}}
</option>
<option
value=
"{{ user_group.id }}"
id=
"opt_{{ user_group.id }}"
>
{{ user_group }}
</option>
{% endfor %}
</select>
</td>
...
...
@@ -129,7 +129,7 @@
{% for user_group in asset_permission.user_groups.all %}
<tr>
<td
><b
class=
"bdg_group"
data-gid=
{{
user_group
.
id
}}
>
{{ user_group
.name
}}
</b></td>
<td
><b
class=
"bdg_group"
data-gid=
{{
user_group
.
id
}}
>
{{ user_group }}
</b></td>
<td>
<button
class=
"btn btn-danger btn-xs btn-remove-group"
type=
"button"
data-gid=
"{{ user_group.id }}"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
...
...
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