From 8764cdb7330f1c8f665f0cc9f0e553af2750592e Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 21 Aug 2025 11:43:20 +0800 Subject: [PATCH] feat: support protocols search --- apps/assets/api/protocol.py | 10 ++++++++++ apps/assets/const/protocol.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/assets/api/protocol.py b/apps/assets/api/protocol.py index ea440791d..1455e9743 100644 --- a/apps/assets/api/protocol.py +++ b/apps/assets/api/protocol.py @@ -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 diff --git a/apps/assets/const/protocol.py b/apps/assets/const/protocol.py index 7ac7bc3cb..aec405e60 100644 --- a/apps/assets/const/protocol.py +++ b/apps/assets/const/protocol.py @@ -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 = (