mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
# coding: utf-8
|
|
#
|
|
from django.db.models import TextChoices
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
class AppCategory(TextChoices):
|
|
db = 'db', _('Database')
|
|
remote_app = 'remote_app', _('Remote app')
|
|
cloud = 'cloud', 'Cloud'
|
|
|
|
@classmethod
|
|
def get_label(cls, category):
|
|
return dict(cls.choices).get(category, '')
|
|
|
|
|
|
class AppType(TextChoices):
|
|
# db category
|
|
mysql = 'mysql', 'MySQL'
|
|
redis = 'redis', 'Redis'
|
|
oracle = 'oracle', 'Oracle'
|
|
pgsql = 'postgresql', 'PostgreSQL'
|
|
mariadb = 'mariadb', 'MariaDB'
|
|
sqlserver = 'sqlserver', 'SQLServer'
|
|
|
|
# remote-app category
|
|
chrome = 'chrome', 'Chrome'
|
|
mysql_workbench = 'mysql_workbench', 'MySQL Workbench'
|
|
vmware_client = 'vmware_client', 'vSphere Client'
|
|
custom = 'custom', _('Custom')
|
|
|
|
# cloud category
|
|
k8s = 'k8s', 'Kubernetes'
|
|
|
|
@classmethod
|
|
def category_types_mapper(cls):
|
|
return {
|
|
AppCategory.db: [
|
|
cls.mysql, cls.oracle, cls.redis, cls.pgsql, cls.mariadb, cls.sqlserver
|
|
],
|
|
AppCategory.remote_app: [cls.chrome, cls.mysql_workbench, cls.vmware_client, cls.custom],
|
|
AppCategory.cloud: [cls.k8s]
|
|
}
|
|
|
|
@classmethod
|
|
def type_category_mapper(cls):
|
|
mapper = {}
|
|
for category, tps in cls.category_types_mapper().items():
|
|
for tp in tps:
|
|
mapper[tp] = category
|
|
return mapper
|
|
|
|
@classmethod
|
|
def get_label(cls, tp):
|
|
return dict(cls.choices).get(tp, '')
|
|
|
|
@classmethod
|
|
def db_types(cls):
|
|
return [tp.value for tp in cls.category_types_mapper()[AppCategory.db]]
|
|
|
|
@classmethod
|
|
def remote_app_types(cls):
|
|
return [tp.value for tp in cls.category_types_mapper()[AppCategory.remote_app]]
|
|
|
|
@classmethod
|
|
def cloud_types(cls):
|
|
return [tp.value for tp in cls.category_types_mapper()[AppCategory.cloud]]
|