mirror of https://github.com/jumpserver/jumpserver
perf: 添加 category node view
parent
8dfb8eeb75
commit
698ea3f2ea
|
@ -27,6 +27,7 @@ from ..tasks import (
|
||||||
check_node_assets_amount_task
|
check_node_assets_amount_task
|
||||||
)
|
)
|
||||||
from .. import serializers
|
from .. import serializers
|
||||||
|
from ..const import AllTypes
|
||||||
from .mixin import SerializeToTreeNodeMixin
|
from .mixin import SerializeToTreeNodeMixin
|
||||||
from assets.locks import NodeAddChildrenLock
|
from assets.locks import NodeAddChildrenLock
|
||||||
|
|
||||||
|
@ -197,6 +198,14 @@ class NodeChildrenAsTreeApi(SerializeToTreeNodeMixin, NodeChildrenApi):
|
||||||
return self.serialize_assets(assets, self.instance.key)
|
return self.serialize_assets(assets, self.instance.key)
|
||||||
|
|
||||||
|
|
||||||
|
class CategoryTreeApi(SerializeToTreeNodeMixin, generics.ListAPIView):
|
||||||
|
def list(self, request, *args, **kwargs):
|
||||||
|
category_types = AllTypes.category_types()
|
||||||
|
nodes = self.get_queryset().order_by('value')
|
||||||
|
nodes = self.serialize_nodes(nodes, with_asset_amount=True)
|
||||||
|
return Response(data=nodes)
|
||||||
|
|
||||||
|
|
||||||
class NodeAssetsApi(generics.ListAPIView):
|
class NodeAssetsApi(generics.ListAPIView):
|
||||||
serializer_class = serializers.AssetSerializer
|
serializer_class = serializers.AssetSerializer
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from common.db.models import IncludesTextChoicesMeta
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'Category', 'HostTypes', 'NetworkTypes', 'DatabaseTypes',
|
'Category', 'HostTypes', 'NetworkTypes', 'DatabaseTypes',
|
||||||
'RemoteAppTypes', 'CloudTypes', 'Protocol', 'AllTypes',
|
'WebTypes', 'CloudTypes', 'Protocol', 'AllTypes',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ class Category(PlatformMixin, models.TextChoices):
|
||||||
HOST = 'host', _('Host')
|
HOST = 'host', _('Host')
|
||||||
NETWORK = 'network', _("NetworkDevice")
|
NETWORK = 'network', _("NetworkDevice")
|
||||||
DATABASE = 'database', _("Database")
|
DATABASE = 'database', _("Database")
|
||||||
REMOTE_APP = 'remote_app', _("Remote app")
|
|
||||||
CLOUD = 'cloud', _("Clouding")
|
CLOUD = 'cloud', _("Clouding")
|
||||||
|
WEB = 'web', _("Web")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def platform_limits(cls):
|
def platform_limits(cls):
|
||||||
|
@ -36,8 +36,8 @@ class Category(PlatformMixin, models.TextChoices):
|
||||||
cls.DATABASE: {
|
cls.DATABASE: {
|
||||||
'has_domain': True
|
'has_domain': True
|
||||||
},
|
},
|
||||||
cls.REMOTE_APP: {
|
cls.WEB: {
|
||||||
'has_domain': True
|
'has_domain': False,
|
||||||
},
|
},
|
||||||
cls.CLOUD: {
|
cls.CLOUD: {
|
||||||
'has_domain': False,
|
'has_domain': False,
|
||||||
|
@ -97,11 +97,8 @@ class DatabaseTypes(PlatformMixin, models.TextChoices):
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|
||||||
class RemoteAppTypes(PlatformMixin, models.TextChoices):
|
class WebTypes(PlatformMixin, models.TextChoices):
|
||||||
CHROME = 'chrome', 'Chrome'
|
General = 'general', 'General'
|
||||||
VSPHERE = 'vmware_client', 'vSphere client'
|
|
||||||
MYSQL_WORKBENCH = 'mysql_workbench', 'MySQL workbench'
|
|
||||||
GENERAL_REMOTE_APP = 'general_remote_app', _("Custom")
|
|
||||||
|
|
||||||
|
|
||||||
class CloudTypes(PlatformMixin, models.TextChoices):
|
class CloudTypes(PlatformMixin, models.TextChoices):
|
||||||
|
@ -112,7 +109,7 @@ class AllTypes(metaclass=IncludesTextChoicesMeta):
|
||||||
choices: list
|
choices: list
|
||||||
includes = [
|
includes = [
|
||||||
HostTypes, NetworkTypes, DatabaseTypes,
|
HostTypes, NetworkTypes, DatabaseTypes,
|
||||||
RemoteAppTypes, CloudTypes
|
WebTypes, CloudTypes
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -140,7 +137,7 @@ class AllTypes(metaclass=IncludesTextChoicesMeta):
|
||||||
(Category.HOST, HostTypes),
|
(Category.HOST, HostTypes),
|
||||||
(Category.NETWORK, NetworkTypes),
|
(Category.NETWORK, NetworkTypes),
|
||||||
(Category.DATABASE, DatabaseTypes),
|
(Category.DATABASE, DatabaseTypes),
|
||||||
(Category.REMOTE_APP, RemoteAppTypes),
|
(Category.WEB, WebTypes),
|
||||||
(Category.CLOUD, CloudTypes)
|
(Category.CLOUD, CloudTypes)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue