From 84f52eb337828d1d8860a3064e80dc81b732f6dc Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 12 Dec 2018 12:11:12 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/perms/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/perms/api.py b/apps/perms/api.py index 37497e2f1..e07fe17a5 100644 --- a/apps/perms/api.py +++ b/apps/perms/api.py @@ -227,8 +227,9 @@ class UserGrantedNodesWithAssetsAsTreeApi(ListAPIView): @staticmethod def parse_asset_to_tree_node(node, asset, system_users): + system_users_protocol_matched = [s for s in system_users if s.protocol == asset.protocol] system_user_serializer = serializers.GrantedSystemUserSerializer( - system_users, many=True + system_users_protocol_matched, many=True ) asset_serializer = serializers.GrantedAssetSerializer(asset) icon_skin = 'file' From 82af5f8f1612027f828e6809fa0a1987253df277 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 12 Dec 2018 12:28:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[Update]=20=E8=B5=84=E4=BA=A7=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E7=BD=91=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/templates/assets/asset_detail.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/assets/templates/assets/asset_detail.html b/apps/assets/templates/assets/asset_detail.html index 51e5adaf2..c766f583c 100644 --- a/apps/assets/templates/assets/asset_detail.html +++ b/apps/assets/templates/assets/asset_detail.html @@ -77,6 +77,10 @@ {% trans 'Admin user' %}: {{ asset.admin_user }} + + {% trans 'Domain' %}: + {{ asset.domain|default:"" }} + {% trans 'Vendor' %}: {{ asset.vendor|default:"" }} From bcfe82f162503941518a543910e348aa20495b80 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 12 Dec 2018 12:40:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[Update]=20=E4=BC=98=E5=8C=96=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ops/command_execution_create.html | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/ops/templates/ops/command_execution_create.html b/apps/ops/templates/ops/command_execution_create.html index 9a0916153..f49ba0c13 100644 --- a/apps/ops/templates/ops/command_execution_create.html +++ b/apps/ops/templates/ops/command_execution_create.html @@ -171,7 +171,7 @@ function initResultTerminal() { cursorBlink: false, screenKeys: false, fontFamily: '"Monaco", "Consolas", "monospace"', - fontSize: 12, + fontSize: 13, rightClickSelectsWord: true, disableStdin: true, theme: { @@ -182,6 +182,10 @@ function initResultTerminal() { term.write("选择左侧资产, 选择运行的系统用户,批量执行命令\r\n") } +function wrapperError(msg) { + return '\033[31m' + msg + '\033[0m' + '\r\n'; +} + function execute() { if (!term) { initResultTerminal() @@ -192,6 +196,18 @@ function execute() { var hosts = getSelectedAssetsNode().map(function (node) { return node.id; }); + if (hosts.length === 0) { + term.write(wrapperError('没有选中资产')); + return + } + if (!command) { + term.write(wrapperError('没有输入命令')); + return + } + if (!run_as) { + term.write(wrapperError('没有选择运行用户')); + return + } var data = { hosts: hosts, run_as: run_as, From 33b1de0d857c5e95527e9f90abde1681df41aea5 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 12 Dec 2018 15:56:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[Update]=20=E4=BC=98=E5=8C=96=E4=B8=80?= =?UTF-8?q?=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ops/command_execution_create.html | 5 +- .../templates/ops/command_execution_list.html | 68 +++++++++++-------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/apps/ops/templates/ops/command_execution_create.html b/apps/ops/templates/ops/command_execution_create.html index f49ba0c13..a832b7fc9 100644 --- a/apps/ops/templates/ops/command_execution_create.html +++ b/apps/ops/templates/ops/command_execution_create.html @@ -263,7 +263,10 @@ function execute() { var editor; $(document).ready(function(){ systemUserId = $('#system-users-select').val(); - $(".select2").select2().on('select2:select', function(evt) { + $(".select2").select2({ + dropdownAutoWidth : true, + width: 'auto' + }).on('select2:select', function(evt) { var data = evt.params.data; systemUserId = data.id; initTree(); diff --git a/apps/ops/templates/ops/command_execution_list.html b/apps/ops/templates/ops/command_execution_list.html index 10f3c0fe3..4c38aa2d1 100644 --- a/apps/ops/templates/ops/command_execution_list.html +++ b/apps/ops/templates/ops/command_execution_list.html @@ -3,6 +3,18 @@ {% load static %} {% load common_tags %} +{% block custom_head_css_js %} + + + + + +{% endblock %} + {% block content_left_head %} {% endblock %} @@ -39,46 +51,49 @@ {% endblock %} -{% block table_head %} - - {% trans 'Hosts' %} - {% trans 'User' %} - {% trans 'Command' %} - {% trans 'Run as' %} - {% trans 'Output' %} - {% trans 'Finished' %} - {% trans 'Success' %} - {% trans 'Date start' %} - {% trans 'Date finished' %} -{% endblock %} - -{% block table_body %} +{% block table_container %} + + + + + + + + + + + + + {% for object in object_list %} - - - + + + - + - {% endfor %} + +
{% trans 'Hosts' %}{% trans 'User' %}{% trans 'Command' %}{% trans 'Run as' %}{% trans 'Output' %}{% trans 'Finished' %}{% trans 'Success' %}{% trans 'Date start' %}
{{ object.get_hosts_names }}{{ object.user }}{{ forloop.counter }}{{ object.user.name }} {{ object.command| truncatechars:16 }}{{ object.run_as }}{{ object.run_as.username }} 查看 {{ object.is_finished | state_show | safe }} {{ object.is_success | state_show | safe }} {{ object.date_start }}{{ object.date_finished }}
{% endblock %} {% block custom_foot_js %} + {% endblock %}