perf: web selector 默认值修改

pull/9208/head
Eric 2022-12-14 17:19:35 +08:00 committed by Eric_Lee
parent 7b0d26bbff
commit d60f9a7c69
3 changed files with 16 additions and 18 deletions

View File

@ -1,4 +1,5 @@
from django.db import models from django.db import models
from common.db.models import ChoicesMixin from common.db.models import ChoicesMixin
__all__ = ['Protocol'] __all__ = ['Protocol']
@ -102,9 +103,9 @@ class Protocol(ChoicesMixin, models.TextChoices):
'port': 80, 'port': 80,
'secret_types': ['password'], 'secret_types': ['password'],
'setting': { 'setting': {
'username_selector': 'input[type=text]', 'username_selector': 'name=username',
'password_selector': 'input[type=password]', 'password_selector': 'name=password',
'submit_selector': 'button[type=submit]', 'submit_selector': 'id=longin_button',
} }
}, },
} }
@ -112,7 +113,7 @@ class Protocol(ChoicesMixin, models.TextChoices):
@classmethod @classmethod
def settings(cls): def settings(cls):
return { return {
**cls.device_protocols(), **cls.device_protocols(),
**cls.database_protocols(), **cls.database_protocols(),
**cls.cloud_protocols() **cls.cloud_protocols()
} }

View File

@ -1,4 +1,3 @@
from assets.models import Web from assets.models import Web
from .common import AssetSerializer from .common import AssetSerializer
@ -19,12 +18,12 @@ class WebSerializer(AssetSerializer):
'label': 'URL' 'label': 'URL'
}, },
'username_selector': { 'username_selector': {
'default': 'input[type=text]' 'default': 'name=username'
}, },
'password_selector': { 'password_selector': {
'default': 'input[type=password]' 'default': 'name=password'
}, },
'submit_selector': { 'submit_selector': {
'default': 'button[type=submit]', 'default': 'id=longin_button',
}, },
} }

View File

@ -3,24 +3,23 @@ from collections import defaultdict
from django.core.cache import cache from django.core.cache import cache
from users.models import User from common.decorator import on_transaction_commit
from common.utils import get_logger
from common.utils.common import lazyproperty, timeit
from orgs.models import Organization from orgs.models import Organization
from orgs.utils import ( from orgs.utils import (
tmp_to_org, tmp_to_org,
tmp_to_root_org tmp_to_root_org
) )
from common.decorator import on_transaction_commit
from common.utils import get_logger
from common.utils.common import lazyproperty, timeit
from perms.locks import UserGrantedTreeRebuildLock from perms.locks import UserGrantedTreeRebuildLock
from perms.models import ( from perms.models import (
AssetPermission, AssetPermission,
UserAssetGrantedTreeNodeRelation UserAssetGrantedTreeNodeRelation
) )
from perms.utils.user_permission import UserGrantedTreeBuildUtils
from users.models import User
from .permission import AssetPermissionUtil from .permission import AssetPermissionUtil
logger = get_logger(__name__) logger = get_logger(__name__)
__all__ = ['UserPermTreeRefreshUtil', 'UserPermTreeExpireUtil'] __all__ = ['UserPermTreeRefreshUtil', 'UserPermTreeExpireUtil']
@ -69,7 +68,7 @@ class UserPermTreeRefreshUtil(_UserPermTreeCacheMixin):
end = time.time() end = time.time()
logger.info( logger.info(
'Refresh user [{user}] org [{org}] perm tree, user {use_time:.2f}s' 'Refresh user [{user}] org [{org}] perm tree, user {use_time:.2f}s'
''.format(user=self.user, org=org, use_time=end-start) ''.format(user=self.user, org=org, use_time=end - start)
) )
def clean_user_perm_tree_nodes_for_legacy_org(self): def clean_user_perm_tree_nodes_for_legacy_org(self):
@ -142,4 +141,3 @@ class UserPermTreeExpireUtil(_UserPermTreeCacheMixin):
p.delete(k) p.delete(k)
p.execute() p.execute()
logger.info('Expire all user perm tree') logger.info('Expire all user perm tree')