feat: support protocols search

pull/15892/head
Bai 2025-08-21 11:43:20 +08:00 committed by feng626
parent 980394efed
commit 8764cdb733
2 changed files with 11 additions and 1 deletions

View File

@ -13,3 +13,13 @@ class ProtocolListApi(ListAPIView):
def get_queryset(self):
return list(Protocol.protocols())
def filter_queryset(self, queryset):
search = self.request.query_params.get("search", "").lower().strip()
if not search:
return queryset
queryset = [
p for p in queryset
if search in p['label'].lower() or search in p['value'].lower()
]
return queryset

View File

@ -349,7 +349,7 @@ class Protocol(ChoicesMixin, models.TextChoices):
for protocol, config in cls.settings().items():
if not xpack_enabled and config.get('xpack', False):
continue
protocols.append(protocol)
protocols.append({'label': protocol.label, 'value': protocol.value})
from assets.models.platform import PlatformProtocol
custom_protocols = (