diff --git a/apps/assets/api/node.py b/apps/assets/api/node.py index bc78e408a..b0e974f5c 100644 --- a/apps/assets/api/node.py +++ b/apps/assets/api/node.py @@ -184,8 +184,9 @@ class NodeAddChildrenApi(generics.UpdateAPIView): for node in children: if not node: continue - node.parent = instance - node.save() + # node.parent = instance + # node.save() + node.set_parent(instance) return Response("OK") diff --git a/apps/assets/models/node.py b/apps/assets/models/node.py index 14ac775fc..5ee97af9b 100644 --- a/apps/assets/models/node.py +++ b/apps/assets/models/node.py @@ -2,7 +2,7 @@ # import uuid -from django.db import models +from django.db import models, transaction from django.utils.translation import ugettext_lazy as _ @@ -39,6 +39,16 @@ class Node(models.Model): def level(self): return len(self.key.split(':')) + def set_parent(self, instance): + children = self.get_all_children() + old_key = self.key + with transaction.atomic(): + self.parent = instance + for child in children: + child.key = child.key.replace(old_key, self.key, 1) + child.save() + self.save() + def get_next_child_key(self): mark = self.child_mark self.child_mark += 1 diff --git a/apps/assets/templates/assets/_system_user.html b/apps/assets/templates/assets/_system_user.html index 528e271e6..314967d22 100644 --- a/apps/assets/templates/assets/_system_user.html +++ b/apps/assets/templates/assets/_system_user.html @@ -55,7 +55,7 @@ {% bootstrap_field form.private_key_file layout="horizontal" %}
- +
{{ form.auto_push}}
@@ -79,43 +79,50 @@
{% endblock %} {% block custom_foot_js %} - +$(document).ready(function () { + $('.select2').select2(); + authFieldsDisplay(); + protocolChange(); +}) +.on('change', protocol_id, function(){ + protocolChange(); +}) +.on('change', auto_generate_key, function(){ + authFieldsDisplay(); +}); + + {% endblock %} \ No newline at end of file diff --git a/apps/assets/templates/assets/domain_gateway_list.html b/apps/assets/templates/assets/domain_gateway_list.html index 581f6c08a..c2d5528ee 100644 --- a/apps/assets/templates/assets/domain_gateway_list.html +++ b/apps/assets/templates/assets/domain_gateway_list.html @@ -85,6 +85,9 @@ function initTable() { var update_btn = '{% trans "Update" %}'.replace('{{ DEFAULT_PK }}', cellData); var del_btn = '{% trans "Delete" %}'.replace('{{ DEFAULT_PK }}', cellData); var test_btn = '{% trans "Test connection" %}'.replace('{{ DEFAULT_PK }}', cellData); + if(rowData.protocol === 'rdp'){ + test_btn = '{% trans "Test connection" %}'.replace('{{ DEFAULT_PK }}', cellData); + } $(td).html(update_btn + test_btn + del_btn) }} ], @@ -120,7 +123,6 @@ $(document).ready(function(){ success_message: "可连接", fail_message: "连接失败" }) - -}) +}); {% endblock %} diff --git a/apps/assets/templates/assets/gateway_create_update.html b/apps/assets/templates/assets/gateway_create_update.html index 7d6800c41..e0b10ba73 100644 --- a/apps/assets/templates/assets/gateway_create_update.html +++ b/apps/assets/templates/assets/gateway_create_update.html @@ -66,3 +66,28 @@ {% endblock %} + +{% block custom_foot_js %} + +{% endblock %} \ No newline at end of file diff --git a/apps/assets/templates/assets/system_user_detail.html b/apps/assets/templates/assets/system_user_detail.html index 1e180f0ab..cc686a62b 100644 --- a/apps/assets/templates/assets/system_user_detail.html +++ b/apps/assets/templates/assets/system_user_detail.html @@ -64,14 +64,14 @@ {% trans 'Protocol' %}: - {{ system_user.protocol }} + {{ system_user.protocol }} - + {% trans 'Sudo' %}: {{ system_user.sudo }} {% if system_user.shell %} - + {% trans 'Shell' %}: {{ system_user.shell }} @@ -107,7 +107,7 @@
-
+
{% trans 'Quick update' %}
@@ -236,6 +236,9 @@ function updateSystemUserNode(nodes) { } jumpserver.nodes_selected = {}; $(document).ready(function () { + if($('#id_protocol_type').text() === 'rdp'){ + $('.only-ssh').addClass('hidden') + } $('.select2').select2() .on('select2:select', function(evt) { var data = evt.params.data; diff --git a/apps/assets/templates/assets/system_user_update.html b/apps/assets/templates/assets/system_user_update.html index 46ef8d6a3..7e1590db5 100644 --- a/apps/assets/templates/assets/system_user_update.html +++ b/apps/assets/templates/assets/system_user_update.html @@ -15,10 +15,3 @@
{% endblock %} -{% block custom_foot_js %} - -{% endblock %} \ No newline at end of file diff --git a/apps/perms/templates/perms/asset_permission_list.html b/apps/perms/templates/perms/asset_permission_list.html index fa1154716..c18f12224 100644 --- a/apps/perms/templates/perms/asset_permission_list.html +++ b/apps/perms/templates/perms/asset_permission_list.html @@ -226,7 +226,7 @@ function initTree() { }, async: { enable: true, - url: "{% url 'api-assets:node-children-2' %}?assets=1&all=1", + url: "{% url 'api-assets:node-children-2' %}?assets=1&all=", autoParam:["id", "name=n", "level=lv"], dataFilter: filter, type: 'get' @@ -238,7 +238,7 @@ function initTree() { }; var zNodes = []; - $.get("{% url 'api-assets:node-children-2' %}?assets=1&all=1", function(data, status){ + $.get("{% url 'api-assets:node-children-2' %}?assets=1&all=", function(data, status){ $.each(data, function (index, value) { value["pId"] = value["parent"]; value["name"] = value["value"]; @@ -304,6 +304,7 @@ $(document).ready(function(){ if (row.child.isShown()) { tr.removeClass('details'); + $(this).children('i:first-child').removeClass('fa-angle-down').addClass('fa-angle-right'); row.child.hide(); // Remove from the 'open' array @@ -311,7 +312,7 @@ $(document).ready(function(){ } else { tr.addClass('details'); - $('.toggle i').removeClass('fa-angle-right').addClass('fa-angle-down'); + $(this).children('i:first-child').removeClass('fa-angle-right').addClass('fa-angle-down'); row.child(format(row.data())).show(); // Add to the 'open' array if ( idx === -1 ) { diff --git a/apps/perms/views.py b/apps/perms/views.py index 17b8637cc..9afbc6ffe 100644 --- a/apps/perms/views.py +++ b/apps/perms/views.py @@ -42,7 +42,7 @@ class AssetPermissionCreateView(AdminUserRequiredMixin, CreateView): if nodes_id: nodes_id = nodes_id.split(",") - nodes = Node.objects.filter(id__in=nodes_id) + nodes = Node.objects.filter(id__in=nodes_id).exclude(id=Node.root().id) form['nodes'].initial = nodes if assets_id: assets_id = assets_id.split(",") diff --git a/apps/terminal/templates/terminal/session_list.html b/apps/terminal/templates/terminal/session_list.html index eaaa89ce1..8cea8e217 100644 --- a/apps/terminal/templates/terminal/session_list.html +++ b/apps/terminal/templates/terminal/session_list.html @@ -102,7 +102,11 @@ {% trans "Replay" %} {% else %} - {% trans "Terminate" %} + {% if session.protocol == 'rdp' %} + {% trans "Terminate" %} + {% else %} + {% trans "Terminate" %} + {% endif %} {% endif %}