mirror of https://github.com/jumpserver/jumpserver
[Bugfix] 修改授权详情快速Node更改失效的bug
parent
071d14c639
commit
3ccd54680e
|
@ -173,7 +173,7 @@
|
||||||
<td colspan="2" class="no-borders">
|
<td colspan="2" class="no-borders">
|
||||||
<select data-placeholder="{% trans 'Add to node' %}" id="node_selected" class="select2" style="width: 100%" multiple="" tabindex="4">
|
<select data-placeholder="{% trans 'Add to node' %}" id="node_selected" class="select2" style="width: 100%" multiple="" tabindex="4">
|
||||||
{% for node in nodes_remain %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
@ -187,7 +187,7 @@
|
||||||
|
|
||||||
{% for node in system_user.nodes.all %}
|
{% for node in system_user.nodes.all %}
|
||||||
<tr>
|
<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>
|
<td>
|
||||||
<button class="btn btn-danger pull-right btn-xs btn-remove-from-node" type="button"><i class="fa fa-minus"></i></button>
|
<button class="btn btn-danger pull-right btn-xs btn-remove-from-node" type="button"><i class="fa fa-minus"></i></button>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -36,12 +36,10 @@ urlpatterns = [
|
||||||
url(r'^captcha/', include('captcha.urls')),
|
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:
|
if settings.DEBUG:
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
url(r'^docs/', schema_view, name="docs"),
|
url(r'^docs/', schema_view, name="docs"),
|
||||||
]
|
]
|
||||||
|
|
||||||
if not settings.DEBUG:
|
|
||||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
|
||||||
|
|
|
@ -85,9 +85,9 @@
|
||||||
<form>
|
<form>
|
||||||
<tr class="no-borders-tr">
|
<tr class="no-borders-tr">
|
||||||
<td colspan="2">
|
<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 %}
|
{% for asset in assets_remain %}
|
||||||
<option value="{{ asset.id }}">{{ asset.hostname }}</option>
|
<option value="{{ asset.id }}">{{ asset }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
@ -113,9 +113,9 @@
|
||||||
<form>
|
<form>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" class="no-borders">
|
<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 %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
@ -129,9 +129,9 @@
|
||||||
|
|
||||||
{% for node in asset_permission.nodes.all %}
|
{% for node in asset_permission.nodes.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td ><b class="bdg_user_group" data-gid={{ node.id }}>{{ node.value }}</b></td>
|
<td ><b class="bdg_group" data-gid={{ node.id }}>{{ node }}</b></td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% 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 the_url = "{% url 'api-perms:asset-permission-detail' pk=asset_permission.id %}";
|
||||||
var body = {
|
var body = {
|
||||||
nodes: nodes
|
nodes: nodes
|
||||||
};
|
};
|
||||||
APIUpdateAttr({
|
APIUpdateAttr({
|
||||||
url: the_url,
|
url: the_url,
|
||||||
body: JSON.stringify(body)
|
body: JSON.stringify(body),
|
||||||
|
success: success
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
jumpserver.assets_selected = {};
|
|
||||||
jumpserver.nodes_selected = {};
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('.select2.asset').select2()
|
$('.select2').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]
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.on('click', '.btn-add-assets', function () {
|
.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;
|
return false;
|
||||||
}
|
}
|
||||||
var assets = [];
|
addAssets(assets_selected);
|
||||||
$.map(jumpserver.assets_selected, function(value, index) {
|
|
||||||
assets.push(index);
|
|
||||||
});
|
|
||||||
addAssets(assets);
|
|
||||||
})
|
})
|
||||||
.on('click', '.btn-remove-asset', function () {
|
.on('click', '.btn-remove-asset', function () {
|
||||||
var asset_id = $(this).data("gid");
|
var asset_id = $(this).data("gid");
|
||||||
|
@ -232,26 +213,30 @@ $(document).ready(function () {
|
||||||
removeAssets(assets)
|
removeAssets(assets)
|
||||||
})
|
})
|
||||||
.on('click', '#btn-add-node', function () {
|
.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;
|
return false;
|
||||||
}
|
}
|
||||||
|
var nodes_origin = $('.bdg_group').map(function() {
|
||||||
var nodes = $('.bdg_group').map(function() {
|
|
||||||
return $(this).data('gid');
|
return $(this).data('gid');
|
||||||
}).get();
|
}).get();
|
||||||
|
|
||||||
$.map(jumpserver.nodes_selected, function(group_name, index) {
|
var nodes = nodes_origin.concat(Object.keys(nodes_selected));
|
||||||
nodes.push(index);
|
var success = function () {
|
||||||
$('#opt_' + index).remove();
|
$.map(nodes_selected, function(name, id) {
|
||||||
|
$('#opt_' + id).remove();
|
||||||
$('.group_edit tbody').append(
|
$('.group_edit tbody').append(
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<td><b class="bdg_group" data-gid="' + index + '">' + group_name + '</b></td>' +
|
'<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>' +
|
'<td><button class="btn btn-danger btn-xs pull-right btn-leave-group" type="button"><i class="fa fa-minus"></i></button></td>' +
|
||||||
'</tr>'
|
'</tr>'
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
};
|
||||||
updateNodes(nodes);
|
updateNodes(nodes, success);
|
||||||
})
|
})
|
||||||
.on('click', '.btn-remove-node', function () {
|
.on('click', '.btn-remove-node', function () {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
|
@ -261,8 +246,10 @@ $(document).ready(function () {
|
||||||
return $(this).data('gid');
|
return $(this).data('gid');
|
||||||
}
|
}
|
||||||
}).get();
|
}).get();
|
||||||
updateNodes(nodes);
|
var success = function () {
|
||||||
$tr.remove()
|
$tr.remove()
|
||||||
|
};
|
||||||
|
updateNodes(nodes, success);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -147,7 +147,7 @@
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<select data-placeholder="{% trans 'Select system users' %}" class="select2" style="width: 100%" multiple="" tabindex="4">
|
<select data-placeholder="{% trans 'Select system users' %}" class="select2" style="width: 100%" multiple="" tabindex="4">
|
||||||
{% for system_user in system_users_remain %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
|
|
||||||
{% for system_user in object.system_users.all %}
|
{% for system_user in object.system_users.all %}
|
||||||
<tr {% if forloop.counter == 1 %} class="no-borders-tr" {% endif %} >
|
<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>
|
<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>
|
<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>
|
</td>
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<select data-placeholder="{% trans 'Select user' %}" class="select2 user" style="width: 100%" multiple="" tabindex="4">
|
<select data-placeholder="{% trans 'Select user' %}" class="select2 user" style="width: 100%" multiple="" tabindex="4">
|
||||||
{% for user in users_remain %}
|
{% for user in users_remain %}
|
||||||
<option value="{{ user.id }}">{{ user.name }}</option>
|
<option value="{{ user.id }}">{{ user }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
<td colspan="2" class="no-borders">
|
<td colspan="2" class="no-borders">
|
||||||
<select data-placeholder="{% trans 'Select user groups' %}" class="select2 user-group" style="width: 100%" multiple="" tabindex="4">
|
<select data-placeholder="{% trans 'Select user groups' %}" class="select2 user-group" style="width: 100%" multiple="" tabindex="4">
|
||||||
{% for user_group in user_groups_remain %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
|
|
||||||
{% for user_group in asset_permission.user_groups.all %}
|
{% for user_group in asset_permission.user_groups.all %}
|
||||||
<tr>
|
<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>
|
<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>
|
<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>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue