From d2b0aba620d480db3b5ba2b53b48f42c4651de36 Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 7 May 2018 19:28:01 +0800 Subject: [PATCH 01/15] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9replay=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/api.py | 50 ++++++++++++---------------------- apps/terminal/views/session.py | 3 +- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/apps/terminal/api.py b/apps/terminal/api.py index a964e9729..eb4b6400a 100644 --- a/apps/terminal/api.py +++ b/apps/terminal/api.py @@ -304,40 +304,24 @@ class SessionReplayViewSet(viewsets.ViewSet): return HttpResponseNotFound() -class SessionReplayV2ViewSet(viewsets.ViewSet): +class SessionReplayV2ViewSet(SessionReplayViewSet): serializer_class = ReplaySerializer permission_classes = (IsSuperUserOrAppUser,) session = None - def gen_session_path(self): - date = self.session.date_start.strftime('%Y-%m-%d') - replay = { - "id": self.session.id, - # "width": 100, - # "heith": 100 - } - if self.session.protocol == "ssh": - replay['type'] = "json" - replay['path'] = os.path.join(date, str(self.session.id) + '.gz') - return replay - elif self.session.protocol == "rdp": - replay['type'] = "mp4" - replay['path'] = os.path.join(date, str(self.session.id) + '.mp4') - return replay - else: - return replay - def retrieve(self, request, *args, **kwargs): session_id = kwargs.get('pk') self.session = get_object_or_404(Session, id=session_id) - replay = self.gen_session_path() + path = self.gen_session_path() + data = { + 'type': 'guacamole' if self.session.protocol == 'rdp' else 'json', + 'src': '', + } - if replay.get("path", "") == "": - return HttpResponseNotFound() - - if default_storage.exists(replay["path"]): - replay["src"] = default_storage.url(replay["path"]) - return Response(replay) + if default_storage.exists(path): + url = default_storage.url(path) + data['src'] = url + return Response(data) else: configs = settings.TERMINAL_REPLAY_STORAGE.items() if not configs: @@ -345,13 +329,15 @@ class SessionReplayV2ViewSet(viewsets.ViewSet): for name, config in configs: client = jms_storage.init(config) + date = self.session.date_start.strftime('%Y-%m-%d') + file_path = os.path.join(date, str(self.session.id) + '.replay.gz') + target_path = default_storage.base_location + '/' + path - target_path = default_storage.base_location + '/' + replay["path"] - - if client and client.has_file(replay["path"]) and \ - client.download_file(replay["path"], target_path): - replay["src"] = default_storage.url(replay["path"]) - return Response(replay) + if client and client.has_file(file_path) and \ + client.download_file(file_path, target_path): + url = default_storage.url(path) + data['src'] = url + return Response(data) return HttpResponseNotFound() diff --git a/apps/terminal/views/session.py b/apps/terminal/views/session.py index 24e323647..3b66baff7 100644 --- a/apps/terminal/views/session.py +++ b/apps/terminal/views/session.py @@ -47,8 +47,7 @@ class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView): filter_kwargs['system_user'] = self.system_user if filter_kwargs: self.queryset = self.queryset.filter(**filter_kwargs) - # Todo: 暂时隐藏rdp - return self.queryset.filter(protocol='ssh') + return self.queryset def get_context_data(self, **kwargs): context = { From 0a9af9872996eb565b3448331f11ed194a406c11 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 8 May 2018 10:13:33 +0800 Subject: [PATCH 02/15] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8Dldap?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=94=B9=E9=94=99=E5=BC=95=E8=B5=B7=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jumpserver/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index b75b73ec9..af72292f7 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -330,7 +330,7 @@ AUTH_LDAP_GROUP_SEARCH = LDAPSearch( AUTH_LDAP_GROUP_SEARCH_OU, ldap.SCOPE_SUBTREE, AUTH_LDAP_GROUP_SEARCH_FILTER ) AUTH_LDAP_CONNECTION_OPTIONS = { - ldap.TIMEOUT: 5 + ldap.OPT_TIMEOUT: 5 } AUTH_LDAP_ALWAYS_UPDATE_USER = True AUTH_LDAP_BACKEND = 'django_auth_ldap.backend.LDAPBackend' From 3af01d6a31656c0f74106ab67319083c0eda549b Mon Sep 17 00:00:00 2001 From: BaiJiangjie Date: Tue, 8 May 2018 18:02:19 +0800 Subject: [PATCH 03/15] =?UTF-8?q?[Update]=20=E6=B7=BB=E5=8A=A0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=E8=B5=84=E4=BA=A7=E6=A0=91=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=85=A8=E9=83=A8/=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E8=8A=82=E7=82=B9=E4=B8=8B=E7=9A=84=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=EF=BC=9B=E4=BF=AE=E5=A4=8D=E8=B5=84=E4=BA=A7=E6=A0=91=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E4=B8=BB=E6=9C=BA=E6=95=B0=E4=B8=8E=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/asset.py | 6 +- apps/assets/api/node.py | 10 ++- apps/assets/models/node.py | 5 ++ apps/assets/serializers/node.py | 8 +- apps/assets/templates/assets/asset_list.html | 62 +++++++++++--- apps/i18n/zh/LC_MESSAGES/django.mo | Bin 33090 -> 33242 bytes apps/i18n/zh/LC_MESSAGES/django.po | 85 ++++++++++--------- 7 files changed, 120 insertions(+), 56 deletions(-) diff --git a/apps/assets/api/asset.py b/apps/assets/api/asset.py index 50c037df9..b3855eba1 100644 --- a/apps/assets/api/asset.py +++ b/apps/assets/api/asset.py @@ -43,6 +43,7 @@ class AssetViewSet(IDInFilterMixin, LabelFilter, BulkModelViewSet): queryset = super().get_queryset() admin_user_id = self.request.query_params.get('admin_user_id') node_id = self.request.query_params.get("node_id") + show_current_asset = self.request.query_params.get("show_current_asset") if admin_user_id: admin_user = get_object_or_404(AdminUser, id=admin_user_id) @@ -51,8 +52,11 @@ class AssetViewSet(IDInFilterMixin, LabelFilter, BulkModelViewSet): node = get_object_or_404(Node, id=node_id) if not node.is_root(): queryset = queryset.filter( - nodes__key__regex='{}(:[0-9]+)*$'.format(node.key), + nodes__key__regex='^{}(:[0-9]+)*$'.format(node.key), ).distinct() + if show_current_asset and node_id: + queryset = queryset.filter(nodes=node_id).distinct() + return queryset diff --git a/apps/assets/api/node.py b/apps/assets/api/node.py index cc940757f..939444ccc 100644 --- a/apps/assets/api/node.py +++ b/apps/assets/api/node.py @@ -41,7 +41,15 @@ __all__ = [ class NodeViewSet(BulkModelViewSet): queryset = Node.objects.all() permission_classes = (IsSuperUser,) - serializer_class = serializers.NodeSerializer + # serializer_class = serializers.NodeSerializer + + def get_serializer_class(self): + show_current_asset = self.request.query_params.get('show_current_asset') + print(show_current_asset) + if show_current_asset: + return serializers.NodeCurrentSerializer + else: + return serializers.NodeSerializer def perform_create(self, serializer): child_key = Node.root().get_next_child_key() diff --git a/apps/assets/models/node.py b/apps/assets/models/node.py index 7939ad1e9..89e4a6b70 100644 --- a/apps/assets/models/node.py +++ b/apps/assets/models/node.py @@ -75,6 +75,11 @@ class Node(models.Model): assets = Asset.objects.filter(nodes__in=nodes).distinct() return assets + def get_current_assets(self): + from .asset import Asset + assets = Asset.objects.filter(nodes=self).distinct() + return assets + def has_assets(self): return self.get_all_assets() diff --git a/apps/assets/serializers/node.py b/apps/assets/serializers/node.py index 5b58ff241..225d5655a 100644 --- a/apps/assets/serializers/node.py +++ b/apps/assets/serializers/node.py @@ -9,7 +9,7 @@ from .asset import AssetGrantedSerializer __all__ = [ 'NodeSerializer', "NodeGrantedSerializer", "NodeAddChildrenSerializer", - "NodeAssetsSerializer", + "NodeAssetsSerializer", "NodeCurrentSerializer", ] @@ -66,6 +66,12 @@ class NodeSerializer(serializers.ModelSerializer): return fields +class NodeCurrentSerializer(NodeSerializer): + @staticmethod + def get_assets_amount(obj): + return obj.get_current_assets().count() + + class NodeAssetsSerializer(serializers.ModelSerializer): assets = serializers.PrimaryKeyRelatedField(many=True, queryset=Asset.objects.all()) diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html index 04ba11e57..98679694f 100644 --- a/apps/assets/templates/assets/asset_list.html +++ b/apps/assets/templates/assets/asset_list.html @@ -47,7 +47,6 @@
-
@@ -87,7 +86,7 @@ {% trans 'IP' %} {% trans 'Hardware' %} {% trans 'Active' %} - {% trans 'Reachable' %} +{# {% trans 'Reachable' %}#} {% trans 'Action' %} @@ -127,6 +126,9 @@
  • +
  • + + @@ -157,26 +159,35 @@ function initTable() { $(td).html('') } }}, - {targets: 5, createdCell: function (td, cellData) { - if (cellData === 'Unknown'){ - $(td).html('') - } else if (!cellData) { - $(td).html('') - } else { - $(td).html('') - } - }}, - {targets: 6, createdCell: function (td, cellData, rowData) { + + {#{targets: 5, createdCell: function (td, cellData) {#} + {# if (cellData === 'Unknown'){#} + {# $(td).html('')#} + {# } else if (!cellData) {#} + {# $(td).html('')#} + {# } else {#} + {# $(td).html('')#} + {# }#} + {# }},#} + + {targets: 5, createdCell: function (td, cellData, rowData) { var update_btn = '{% trans "Update" %}'.replace("{{ DEFAULT_PK }}", cellData); var del_btn = '{% trans "Delete" %}'.replace('{{ DEFAULT_PK }}', cellData); $(td).html(update_btn + del_btn) }} ], ajax_url: '{% url "api-assets:asset-list" %}', + + {#columns: [#} + {# {data: "id"}, {data: "hostname" }, {data: "ip" },#} + {# {data: "cpu_cores"}, {data: "is_active", orderable: false },#} + {# {data: "is_connective", orderable: false}, {data: "id", orderable: false }#} + {#],#} + columns: [ {data: "id"}, {data: "hostname" }, {data: "ip" }, {data: "cpu_cores"}, {data: "is_active", orderable: false }, - {data: "is_connective", orderable: false}, {data: "id", orderable: false } + {data: "id", orderable: false } ], op_html: $('#actions').html() }; @@ -290,6 +301,7 @@ function onRename(event, treeId, treeNode, isCancel){ function onSelected(event, treeNode) { var url = asset_table.ajax.url(); url = setUrlParam(url, "node_id", treeNode.id); + url = setUrlParam(url, "show_current_asset", getCookie('show_current_asset')); setCookie('node_selected', treeNode.id); asset_table.ajax.url(url); asset_table.ajax.reload(); @@ -382,7 +394,8 @@ function initTree() { }; var zNodes = []; - $.get("{% url 'api-assets:node-list' %}", function(data, status){ + var query_params = {'show_current_asset': getCookie('show_current_asset')}; + $.get("{% url 'api-assets:node-list' %}", query_params, function(data, status){ $.each(data, function (index, value) { value["pId"] = value["parent"]; {#if (value["key"] === "0") {#} @@ -417,6 +430,13 @@ function toggle() { $(document).ready(function(){ initTable(); initTree(); + + if(getCookie('show_current_asset') === 'yes'){ + $('#show_all_asset').css('display', 'inline-block'); + } + else{ + $('#show_current_asset').css('display', 'inline-block'); + } }) .on('click', '.labels li', function () { var val = $(this).text(); @@ -535,6 +555,20 @@ $(document).ready(function(){ flash_message: false }); }) +.on('click', '.btn-show-current-asset', function(){ + hideRMenu(); + $(this).css('display', 'none'); + $('#show_all_asset').css('display', 'inline-block'); + setCookie('show_current_asset', 'yes'); + location.reload(); +}) +.on('click', '.btn-show-all-asset', function(){ + hideRMenu(); + $(this).css('display', 'none'); + $('#show_current_asset').css('display', 'inline-block'); + setCookie('show_current_asset', ''); + location.reload(); +}) .on('click', '.btn_asset_delete', function () { var $this = $(this); var $data_table = $("#asset_list_table").DataTable(); diff --git a/apps/i18n/zh/LC_MESSAGES/django.mo b/apps/i18n/zh/LC_MESSAGES/django.mo index 038e65f4355f956a2eb1f56ba8ab8fae46912d00..36220e3219e13e2f33a24be9281b1ef120ef808e 100644 GIT binary patch delta 11480 zcmZwN37k*W|Htt=V`eZIGh<(3X6&+zbu1BOjD6pi?8DS#hCwEcYp)@t29-#bMvO{? z2!$k+ttdj4u_a5^Z27<5-}~|Sd;A~&`{?6&&gYza&bjB_`~80T{kBc=KRVgp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wG6 zbQL9^3$tJzB9ZbhIFr!T9iQSB;%%ZTp(`KpHEorMpM4p=+pkgip2}7tjdC%3h+|M! w5^;w(LM|^RZ+g8vKP)xs4kR\n" "Language-Team: Jumpserver team\n" @@ -17,15 +17,15 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: assets/api/node.py:88 +#: assets/api/node.py:96 msgid "New node {}" msgstr "新节点 {}" -#: assets/api/node.py:217 +#: assets/api/node.py:225 msgid "更新节点资产硬件信息: {}" msgstr "" -#: assets/api/node.py:230 +#: assets/api/node.py:238 msgid "测试节点下资产是否可连接: {}" msgstr "" @@ -46,7 +46,7 @@ msgstr "管理用户" #: assets/forms/asset.py:30 assets/forms/asset.py:69 assets/forms/asset.py:125 #: assets/templates/assets/asset_create.html:35 #: assets/templates/assets/asset_create.html:37 -#: assets/templates/assets/asset_list.html:75 +#: assets/templates/assets/asset_list.html:74 #: assets/templates/assets/asset_update.html:40 #: assets/templates/assets/asset_update.html:42 #: assets/templates/assets/user_asset_list.html:34 @@ -206,7 +206,7 @@ msgstr "高优先级的系统用户将会作为默认登录用户" #: assets/templates/assets/_asset_list_modal.html:46 #: assets/templates/assets/admin_user_assets.html:52 #: assets/templates/assets/asset_detail.html:61 -#: assets/templates/assets/asset_list.html:87 +#: assets/templates/assets/asset_list.html:86 #: assets/templates/assets/domain_gateway_list.html:57 #: assets/templates/assets/system_user_asset.html:50 #: assets/templates/assets/user_asset_list.html:46 common/forms.py:144 @@ -220,7 +220,7 @@ msgstr "IP" #: assets/models/asset.py:62 assets/templates/assets/_asset_list_modal.html:45 #: assets/templates/assets/admin_user_assets.html:51 #: assets/templates/assets/asset_detail.html:57 -#: assets/templates/assets/asset_list.html:86 +#: assets/templates/assets/asset_list.html:85 #: assets/templates/assets/system_user_asset.html:49 #: assets/templates/assets/user_asset_list.html:45 common/forms.py:143 #: perms/templates/perms/asset_permission_asset.html:54 @@ -650,7 +650,7 @@ msgstr "重置" #: assets/templates/assets/admin_user_create_update.html:46 #: assets/templates/assets/asset_bulk_update.html:24 #: assets/templates/assets/asset_create.html:67 -#: assets/templates/assets/asset_list.html:108 +#: assets/templates/assets/asset_list.html:107 #: assets/templates/assets/asset_update.html:71 #: assets/templates/assets/domain_create_update.html:17 #: assets/templates/assets/gateway_create_update.html:59 @@ -699,7 +699,6 @@ msgstr "资产列表" #: assets/templates/assets/admin_user_assets.html:54 #: assets/templates/assets/admin_user_list.html:26 -#: assets/templates/assets/asset_list.html:90 #: assets/templates/assets/system_user_asset.html:52 #: assets/templates/assets/system_user_list.html:30 #: users/templates/users/user_group_granted_asset.html:47 @@ -728,7 +727,7 @@ msgstr "测试" #: assets/templates/assets/admin_user_detail.html:24 #: assets/templates/assets/admin_user_list.html:85 #: assets/templates/assets/asset_detail.html:24 -#: assets/templates/assets/asset_list.html:170 +#: assets/templates/assets/asset_list.html:174 #: assets/templates/assets/domain_detail.html:24 #: assets/templates/assets/domain_detail.html:103 #: assets/templates/assets/domain_gateway_list.html:85 @@ -752,7 +751,7 @@ msgstr "更新" #: assets/templates/assets/admin_user_detail.html:28 #: assets/templates/assets/admin_user_list.html:86 #: assets/templates/assets/asset_detail.html:28 -#: assets/templates/assets/asset_list.html:171 +#: assets/templates/assets/asset_list.html:175 #: assets/templates/assets/domain_detail.html:28 #: assets/templates/assets/domain_detail.html:104 #: assets/templates/assets/domain_gateway_list.html:86 @@ -783,7 +782,7 @@ msgstr "选择节点" #: assets/templates/assets/admin_user_detail.html:100 #: assets/templates/assets/asset_detail.html:200 -#: assets/templates/assets/asset_list.html:600 +#: assets/templates/assets/asset_list.html:634 #: assets/templates/assets/system_user_detail.html:183 #: assets/templates/assets/system_user_list.html:138 templates/_modal.html:22 #: terminal/templates/terminal/session_detail.html:108 @@ -815,7 +814,7 @@ msgid "Ratio" msgstr "比例" #: assets/templates/assets/admin_user_list.html:30 -#: assets/templates/assets/asset_list.html:91 +#: assets/templates/assets/asset_list.html:90 #: assets/templates/assets/domain_gateway_list.html:62 #: assets/templates/assets/domain_list.html:18 #: assets/templates/assets/label_list.html:17 @@ -856,7 +855,7 @@ msgid "Quick modify" msgstr "快速修改" #: assets/templates/assets/asset_detail.html:143 -#: assets/templates/assets/asset_list.html:89 +#: assets/templates/assets/asset_list.html:88 #: assets/templates/assets/user_asset_list.html:47 perms/models.py:35 #: perms/models.py:79 #: perms/templates/perms/asset_permission_create_update.html:47 @@ -886,89 +885,97 @@ msgstr "刷新" msgid "Update successfully!" msgstr "更新成功" -#: assets/templates/assets/asset_list.html:63 assets/views/asset.py:97 +#: assets/templates/assets/asset_list.html:62 assets/views/asset.py:97 msgid "Create asset" msgstr "创建资产" -#: assets/templates/assets/asset_list.html:67 +#: assets/templates/assets/asset_list.html:66 #: users/templates/users/user_list.html:7 msgid "Import" msgstr "导入" -#: assets/templates/assets/asset_list.html:70 +#: assets/templates/assets/asset_list.html:69 #: users/templates/users/user_list.html:10 msgid "Export" msgstr "导出" -#: assets/templates/assets/asset_list.html:88 +#: assets/templates/assets/asset_list.html:87 msgid "Hardware" msgstr "硬件" -#: assets/templates/assets/asset_list.html:100 +#: assets/templates/assets/asset_list.html:99 #: users/templates/users/user_list.html:37 msgid "Delete selected" msgstr "批量删除" -#: assets/templates/assets/asset_list.html:101 +#: assets/templates/assets/asset_list.html:100 #: users/templates/users/user_list.html:38 msgid "Update selected" msgstr "批量更新" -#: assets/templates/assets/asset_list.html:102 +#: assets/templates/assets/asset_list.html:101 msgid "Remove from this node" msgstr "从节点移除" -#: assets/templates/assets/asset_list.html:103 +#: assets/templates/assets/asset_list.html:102 #: users/templates/users/user_list.html:39 msgid "Deactive selected" msgstr "禁用所选" -#: assets/templates/assets/asset_list.html:104 +#: assets/templates/assets/asset_list.html:103 #: users/templates/users/user_list.html:40 msgid "Active selected" msgstr "激活所选" -#: assets/templates/assets/asset_list.html:121 +#: assets/templates/assets/asset_list.html:120 msgid "Add node" msgstr "新建节点" -#: assets/templates/assets/asset_list.html:122 +#: assets/templates/assets/asset_list.html:121 msgid "Rename node" msgstr "重命名节点" -#: assets/templates/assets/asset_list.html:123 +#: assets/templates/assets/asset_list.html:122 msgid "Delete node" msgstr "删除节点" -#: assets/templates/assets/asset_list.html:125 +#: assets/templates/assets/asset_list.html:124 msgid "Add assets to node" msgstr "添加资产到节点" -#: assets/templates/assets/asset_list.html:126 +#: assets/templates/assets/asset_list.html:125 msgid "Move assets to node" msgstr "移动资产到节点" -#: assets/templates/assets/asset_list.html:128 +#: assets/templates/assets/asset_list.html:127 msgid "Refresh node hardware info" msgstr "更新节点资产硬件信息" -#: assets/templates/assets/asset_list.html:129 +#: assets/templates/assets/asset_list.html:128 msgid "Test node connective" msgstr "测试节点资产可连接性" -#: assets/templates/assets/asset_list.html:204 +#: assets/templates/assets/asset_list.html:130 +msgid "Display only current node assets" +msgstr "仅显示当前节点资产" + +#: assets/templates/assets/asset_list.html:131 +msgid "Displays all child node assets" +msgstr "显示所有子节点资产" + +#: assets/templates/assets/asset_list.html:215 msgid "Create node failed" msgstr "创建节点失败" -#: assets/templates/assets/asset_list.html:216 +#: assets/templates/assets/asset_list.html:227 msgid "Have child node, cancel" msgstr "存在子节点,不能删除" -#: assets/templates/assets/asset_list.html:218 +#: assets/templates/assets/asset_list.html:229 msgid "Have assets, cancel" msgstr "存在资产,不能删除" -#: assets/templates/assets/asset_list.html:595 +#: assets/templates/assets/asset_list.html:629 #: assets/templates/assets/system_user_list.html:133 #: users/templates/users/user_detail.html:357 #: users/templates/users/user_detail.html:382 @@ -977,20 +984,20 @@ msgstr "存在资产,不能删除" msgid "Are you sure?" msgstr "你确认吗?" -#: assets/templates/assets/asset_list.html:596 +#: assets/templates/assets/asset_list.html:630 msgid "This will delete the selected assets !!!" msgstr "删除选择资产" -#: assets/templates/assets/asset_list.html:604 +#: assets/templates/assets/asset_list.html:638 msgid "Asset Deleted." msgstr "已被删除" -#: assets/templates/assets/asset_list.html:605 -#: assets/templates/assets/asset_list.html:610 +#: assets/templates/assets/asset_list.html:639 +#: assets/templates/assets/asset_list.html:644 msgid "Asset Delete" msgstr "删除" -#: assets/templates/assets/asset_list.html:609 +#: assets/templates/assets/asset_list.html:643 msgid "Asset Deleting failed." msgstr "删除失败" From 8e74a042820f5b2cb8bc18d41f0ddaa1a5bae964 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 9 May 2018 17:35:46 +0800 Subject: [PATCH 04/15] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E4=B8=80?= =?UTF-8?q?=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/system_user.py | 3 +++ apps/assets/models/base.py | 5 +++++ apps/common/api.py | 9 +-------- apps/perms/templates/perms/asset_permission_list.html | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/assets/api/system_user.py b/apps/assets/api/system_user.py index b4e46cc78..1be316567 100644 --- a/apps/assets/api/system_user.py +++ b/apps/assets/api/system_user.py @@ -58,6 +58,9 @@ class SystemUserPushApi(generics.RetrieveAPIView): def retrieve(self, request, *args, **kwargs): system_user = self.get_object() + nodes = system_user.nodes.all() + for node in nodes: + system_user.assets.add(*tuple(node.get_all_assets())) task = push_system_user_to_assets_manual.delay(system_user) return Response({"task": task.id}) diff --git a/apps/assets/models/base.py b/apps/assets/models/base.py index eda00a79a..cdb08f52c 100644 --- a/apps/assets/models/base.py +++ b/apps/assets/models/base.py @@ -104,6 +104,11 @@ class AssetUser(models.Model): if update_fields: self.save(update_fields=update_fields) + def clear_auth(self): + self._password = '' + self._private_key = '' + self.save() + def auto_gen_auth(self): password = str(uuid.uuid4()) private_key, public_key = ssh_key_gen( diff --git a/apps/common/api.py b/apps/common/api.py index 4b74b6b0d..209d09747 100644 --- a/apps/common/api.py +++ b/apps/common/api.py @@ -96,14 +96,7 @@ class LDAPTestingAPI(APIView): class DjangoSettingsAPI(APIView): def get(self, request): - if not settings.DEBUG: - return Response('Only debug mode support') - - configs = {} - for i in dir(settings): - if i.isupper(): - configs[i] = str(getattr(settings, i)) - return Response(configs) + return Response('Danger, Close now') diff --git a/apps/perms/templates/perms/asset_permission_list.html b/apps/perms/templates/perms/asset_permission_list.html index afec34269..fa1154716 100644 --- a/apps/perms/templates/perms/asset_permission_list.html +++ b/apps/perms/templates/perms/asset_permission_list.html @@ -250,7 +250,7 @@ function initTree() { {#$.fn.zTree.init($("#assetTree"), setting);#} $.fn.zTree.init($("#assetTree"), setting, zNodes); zTree = $.fn.zTree.getZTreeObj("assetTree"); - selectQueryNode(); + {#selectQueryNode();#} }); } From 7de6af89ada44a0163f98423a3e849cfe7731998 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 10 May 2018 12:19:37 +0800 Subject: [PATCH 05/15] =?UTF-8?q?[Update]=20=E4=BD=BF=E7=94=A8xterm.js?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E5=8E=9F=E6=9D=A5=E7=9A=84term.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/assets/admin_user_assets.html | 2 +- .../templates/assets/system_user_detail.html | 2 +- apps/ops/api.py | 9 +- .../templates/ops/adhoc_history_detail.html | 2 +- apps/ops/templates/ops/celery_task_log.html | 77 +- apps/ops/templates/ops/task_adhoc.html | 2 +- apps/ops/templates/ops/task_detail.html | 2 +- apps/ops/templates/ops/task_history.html | 2 +- apps/ops/templates/ops/task_list.html | 2 +- apps/ops/views.py | 3 + apps/static/js/plugins/xterm/xterm.css | 2261 ++++++++ apps/static/js/plugins/xterm/xterm.js | 5132 +++++++++++++++++ apps/static/js/plugins/xterm/xterm.js.map | 1 + .../templates/terminal/session_detail.html | 2 +- .../templates/terminal/session_list.html | 2 +- 15 files changed, 7446 insertions(+), 55 deletions(-) create mode 100644 apps/static/js/plugins/xterm/xterm.css create mode 100644 apps/static/js/plugins/xterm/xterm.js create mode 100644 apps/static/js/plugins/xterm/xterm.js.map diff --git a/apps/assets/templates/assets/admin_user_assets.html b/apps/assets/templates/assets/admin_user_assets.html index 80ff0cd5f..31314392f 100644 --- a/apps/assets/templates/assets/admin_user_assets.html +++ b/apps/assets/templates/assets/admin_user_assets.html @@ -124,7 +124,7 @@ $(document).ready(function () { var success = function (data) { var task_id = data.task; var url = '{% url "ops:celery-task-log" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", task_id); - window.open(url, '', 'width=800,height=600') + window.open(url, '', 'width=800,height=600,left=400,top=400') }; APIUpdateAttr({ url: the_url, diff --git a/apps/assets/templates/assets/system_user_detail.html b/apps/assets/templates/assets/system_user_detail.html index a02bf1e44..1e180f0ab 100644 --- a/apps/assets/templates/assets/system_user_detail.html +++ b/apps/assets/templates/assets/system_user_detail.html @@ -296,7 +296,7 @@ $(document).ready(function () { var success = function (data) { var task_id = data.task; var url = '{% url "ops:celery-task-log" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", task_id); - window.open(url, '', 'width=800,height=600') + window.open(url, '', 'width=800,height=600,left=400,top=400') }; APIUpdateAttr({ url: the_url, diff --git a/apps/ops/api.py b/apps/ops/api.py index 0134fbd4a..a68f1c529 100644 --- a/apps/ops/api.py +++ b/apps/ops/api.py @@ -70,9 +70,16 @@ class CeleryTaskLogApi(generics.RetrieveAPIView): end = False queryset = CeleryTask.objects.all() + def get_object(self): + return CeleryTask( + id="4cae9ad8-1116-45e7-b019-9b1856696fd7", + log_path="2018-05-10/ca77e6db-9ac6-4970-80d1-eecdbcc3fcc5.log", + status="finished" + ) + def get(self, request, *args, **kwargs): mark = request.query_params.get("mark") or str(uuid.uuid4()) - task = super().get_object() + task = self.get_object() log_path = task.full_log_path if not log_path or not os.path.isfile(log_path): diff --git a/apps/ops/templates/ops/adhoc_history_detail.html b/apps/ops/templates/ops/adhoc_history_detail.html index 16adbc4e3..b8a48d4e5 100644 --- a/apps/ops/templates/ops/adhoc_history_detail.html +++ b/apps/ops/templates/ops/adhoc_history_detail.html @@ -19,7 +19,7 @@ {% trans 'Run history detail' %}
  • - {% trans 'Output' %} + {% trans 'Output' %}
  • diff --git a/apps/ops/templates/ops/celery_task_log.html b/apps/ops/templates/ops/celery_task_log.html index 9b0826949..13885c2cc 100644 --- a/apps/ops/templates/ops/celery_task_log.html +++ b/apps/ops/templates/ops/celery_task_log.html @@ -2,38 +2,25 @@ term.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..96ed7bb93 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,12 @@ function updateSystemUserNode(nodes) { } jumpserver.nodes_selected = {}; $(document).ready(function () { + if($('#id_protocol_type').text() === 'rdp'){ + $('#id_quick_update').addClass('hidden'); + $('#id_sudo').addClass('hidden'); + $('#id_shell').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..a8a5c7483 100644 --- a/apps/assets/templates/assets/system_user_update.html +++ b/apps/assets/templates/assets/system_user_update.html @@ -15,10 +15,9 @@
    {% endblock %} -{% block custom_foot_js %} - -{% endblock %} \ No newline at end of file + protocolChange(); + }); +{% endblock %} From cb4afabc9117eff1847ca945ddb73d6b65dd1721 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 15 May 2018 14:44:02 +0800 Subject: [PATCH 12/15] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E5=88=9B?= =?UTF-8?q?=E5=BB=BAnode=E8=8A=82=E7=82=B9=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8Dwindows=20session=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/node.py | 8 ++++---- apps/terminal/api.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/assets/api/node.py b/apps/assets/api/node.py index b8b2707e6..bc78e408a 100644 --- a/apps/assets/api/node.py +++ b/apps/assets/api/node.py @@ -51,10 +51,10 @@ class NodeViewSet(BulkModelViewSet): else: return serializers.NodeSerializer - # def perform_create(self, serializer): - # child_key = Node.root().get_next_child_key() - # serializer.validated_data["key"] = child_key - # serializer.save() + def perform_create(self, serializer): + child_key = Node.root().get_next_child_key() + serializer.validated_data["key"] = child_key + serializer.save() class NodeWithAssetsApi(generics.ListAPIView): diff --git a/apps/terminal/api.py b/apps/terminal/api.py index eb4b6400a..c9bb68ed6 100644 --- a/apps/terminal/api.py +++ b/apps/terminal/api.py @@ -108,6 +108,9 @@ class StatusViewSet(viewsets.ModelViewSet): task_serializer_class = TaskSerializer def create(self, request, *args, **kwargs): + if self.request.query_params.get("from_guacamole", None): + return Response({"msg": "From guacamole, not support now"}) + self.handle_sessions() super().create(request, *args, **kwargs) tasks = self.request.user.terminal.task_set.filter(is_finished=False) From ed18cb317f754432439d48823d91138315863ea3 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 15 May 2018 15:05:49 +0800 Subject: [PATCH 13/15] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E5=88=9B?= =?UTF-8?q?=E5=BB=BAnode=20api=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/serializers/node.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/assets/serializers/node.py b/apps/assets/serializers/node.py index bee350591..b191b0a4f 100644 --- a/apps/assets/serializers/node.py +++ b/apps/assets/serializers/node.py @@ -53,14 +53,13 @@ class NodeSerializer(serializers.ModelSerializer): def validate(self, data): value = data.get('value') - instance = self.instance - if not instance.is_root(): - children = instance.parent.get_children().exclude(key=instance.key) - values = [child.value for child in children] - if value in values: - raise serializers.ValidationError( - 'The same level node name cannot be the same' - ) + instance = self.instance if self.instance else Node.root() + children = instance.parent.get_children().exclude(key=instance.key) + values = [child.value for child in children] + if value in values: + raise serializers.ValidationError( + 'The same level node name cannot be the same' + ) return data @staticmethod From 599431f402e868c69aa59de8bd3ba24fc5a55373 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Tue, 15 May 2018 17:32:20 +0800 Subject: [PATCH 14/15] =?UTF-8?q?[Update]=20=E5=8E=BB=E6=8E=89=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0windows=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E6=97=A0=E7=94=A8=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E7=BD=91=E5=9F=9F=E7=BD=91=E5=85=B3/=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/node.py | 2 +- apps/assets/models/node.py | 2 +- .../assets/templates/assets/_system_user.html | 20 +++++++------- .../templates/assets/domain_gateway_list.html | 6 +++-- .../assets/gateway_create_update.html | 26 +++++++++++++++++++ .../templates/terminal/session_list.html | 6 ++++- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/apps/assets/api/node.py b/apps/assets/api/node.py index 30d661a29..5a3197288 100644 --- a/apps/assets/api/node.py +++ b/apps/assets/api/node.py @@ -186,7 +186,7 @@ class NodeAddChildrenApi(generics.UpdateAPIView): continue # node.parent = instance # node.save() - node.move(instance) + node.set_parent(instance) return Response("OK") diff --git a/apps/assets/models/node.py b/apps/assets/models/node.py index bb83035c0..5ee97af9b 100644 --- a/apps/assets/models/node.py +++ b/apps/assets/models/node.py @@ -39,7 +39,7 @@ class Node(models.Model): def level(self): return len(self.key.split(':')) - def move(self, instance): + def set_parent(self, instance): children = self.get_all_children() old_key = self.key with transaction.atomic(): diff --git a/apps/assets/templates/assets/_system_user.html b/apps/assets/templates/assets/_system_user.html index 6e3b81658..98d1b6098 100644 --- a/apps/assets/templates/assets/_system_user.html +++ b/apps/assets/templates/assets/_system_user.html @@ -87,6 +87,16 @@ var sudo_id = '#' + '{{ form.sudo.id_for_label }}'; var shell_id = '#' + '{{ form.shell.id_for_label }}'; + var div_auto_generate_key = $(auto_generate_key).parent().parent(); + var div_ssh_private_key = $(private_key_id).parent().parent().parent().parent(); + var div_auto_push = $(auto_push_id).parent().parent(); + var div_sudo = $(sudo_id).parent().parent(); + var div_shell = $(shell_id).parent().parent(); + var need_change_div = [ + div_auto_generate_key, div_ssh_private_key, + div_auto_push, div_sudo, div_shell + ]; + function authFieldsDisplay() { if ($(auto_generate_key).prop('checked')) { $('.auth-fields').addClass('hidden'); @@ -96,16 +106,6 @@ } function protocolChange() { - var div_auto_generate_key = $(auto_generate_key).parent().parent(); - var div_ssh_private_key = $(private_key_id).parent().parent().parent().parent(); - var div_auto_push = $(auto_push_id).parent().parent(); - var div_sudo = $(sudo_id).parent().parent(); - var div_shell = $(shell_id).parent().parent(); - var need_change_div = [ - div_auto_generate_key, div_ssh_private_key, - div_auto_push, div_sudo, div_shell - ]; - if ($(protocol_id + " option:selected").text() === 'rdp') { $('.auth-fields').removeClass('hidden'); $.each(need_change_div, function (index, value) { 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..e57d8ed5c 100644 --- a/apps/assets/templates/assets/gateway_create_update.html +++ b/apps/assets/templates/assets/gateway_create_update.html @@ -66,3 +66,29 @@
    {% endblock %} + +{% block custom_foot_js %} + +{% endblock %} \ No newline at end of file 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 %} From ac67c231fccb9ed80d57b3d73ba9dff8b88bcfd1 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Wed, 16 May 2018 12:31:13 +0800 Subject: [PATCH 15/15] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E5=89=8D?= =?UTF-8?q?=E7=AB=AFrdp=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/templates/assets/_system_user.html | 95 +++++++++---------- .../assets/gateway_create_update.html | 39 ++++---- .../templates/assets/system_user_detail.html | 11 +-- .../templates/assets/system_user_update.html | 6 -- 4 files changed, 66 insertions(+), 85 deletions(-) diff --git a/apps/assets/templates/assets/_system_user.html b/apps/assets/templates/assets/_system_user.html index 98d1b6098..314967d22 100644 --- a/apps/assets/templates/assets/_system_user.html +++ b/apps/assets/templates/assets/_system_user.html @@ -79,59 +79,50 @@ {% endblock %} {% block custom_foot_js %} - + } +} + +function authFieldsDisplay() { + if ($(auto_generate_key).prop('checked')) { + $('.auth-fields').addClass('hidden'); + } else { + $('.auth-fields').removeClass('hidden'); + } +} + +$(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/gateway_create_update.html b/apps/assets/templates/assets/gateway_create_update.html index e57d8ed5c..e0b10ba73 100644 --- a/apps/assets/templates/assets/gateway_create_update.html +++ b/apps/assets/templates/assets/gateway_create_update.html @@ -68,27 +68,26 @@ {% endblock %} {% block custom_foot_js %} - +$(document).ready(function(){ + protocolChange(); +}) +.on('change', protocol_id, function(){ + protocolChange(); +}); + {% 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 96ed7bb93..cc686a62b 100644 --- a/apps/assets/templates/assets/system_user_detail.html +++ b/apps/assets/templates/assets/system_user_detail.html @@ -66,12 +66,12 @@ {% trans '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' %}
    @@ -237,11 +237,8 @@ function updateSystemUserNode(nodes) { jumpserver.nodes_selected = {}; $(document).ready(function () { if($('#id_protocol_type').text() === 'rdp'){ - $('#id_quick_update').addClass('hidden'); - $('#id_sudo').addClass('hidden'); - $('#id_shell').addClass('hidden'); + $('.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 a8a5c7483..7e1590db5 100644 --- a/apps/assets/templates/assets/system_user_update.html +++ b/apps/assets/templates/assets/system_user_update.html @@ -15,9 +15,3 @@
    {% endblock %} -{% block document_ready %} - $(document).ready(function () { - $('.select2').select2(); - protocolChange(); - }); -{% endblock %}