perf: connect methods xpack

pull/9219/head
ibuler 2 years ago
parent 26794064b5
commit 675a41013e

@ -5018,7 +5018,7 @@ msgstr "离线"
#: terminal/const.py:81 terminal/const.py:82 terminal/const.py:83
#: terminal/const.py:84 terminal/const.py:85
msgid "DB Client"
msgstr "客户端"
msgstr "数据库客户端"
#: terminal/exceptions.py:8
msgid "Bulk create not support"

@ -2,6 +2,7 @@
#
from collections import defaultdict
from django.conf import settings
from django.db.models import TextChoices
from django.utils.translation import ugettext_lazy as _
@ -78,6 +79,10 @@ class NativeClient(TextChoices):
return protocol
return None
@classmethod
def xpack_methods(cls):
return [cls.sqlplus, cls.mstsc]
@classmethod
def get_methods(cls, os='windows'):
clients_map = cls.get_native_clients()
@ -87,6 +92,8 @@ class NativeClient(TextChoices):
if isinstance(_clients, dict):
_clients = _clients.get(os, _clients['default'])
for client in _clients:
if not settings.XPACK_ENABLED and client in cls.xpack_methods():
continue
methods[protocol].append({
'value': client.value,
'label': client.label,
@ -121,8 +128,10 @@ class AppletMethod:
from .models import Applet, AppletHost
methods = defaultdict(list)
has_applet_hosts = AppletHost.objects.all().exists()
if not settings.XPACK_ENABLED:
return methods
has_applet_hosts = AppletHost.objects.all().exists()
applets = Applet.objects.filter(is_active=True)
for applet in applets:
for protocol in applet.protocols:

Loading…
Cancel
Save