From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id E618A1FF15C for ; Fri, 14 Nov 2025 13:11:27 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 72E69113F4; Fri, 14 Nov 2025 13:12:21 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Fri, 14 Nov 2025 13:11:18 +0100 Message-ID: <20251114121218.2479318-5-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114121218.2479318-1-d.csapak@proxmox.com> References: <20251114121218.2479318-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [resources.rs] Subject: [pdm-devel] [PATCH datacenter-manager v2 04/18] server: api: resources: add 'view' category to search syntax X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" so that we can filter the results by view too. Signed-off-by: Dominik Csapak --- server/src/api/resources.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs index da395975..15c2c479 100644 --- a/server/src/api/resources.rs +++ b/server/src/api/resources.rs @@ -62,6 +62,7 @@ enum MatchCategory { Remote, RemoteType, Property, + View, } impl std::str::FromStr for MatchCategory { @@ -78,6 +79,7 @@ impl std::str::FromStr for MatchCategory { "remote" => MatchCategory::Remote, "remote-type" => MatchCategory::RemoteType, "property" => MatchCategory::Property, + "view" => MatchCategory::View, _ => bail!("invalid category"), }; Ok(category) @@ -108,6 +110,7 @@ impl MatchCategory { .to_lowercase() .split(",") .any(|property| property == search_term.to_lowercase()), + MatchCategory::View => true, } } } @@ -140,6 +143,7 @@ fn resource_matches_search_term( } _ => false, }, + MatchCategory::View => return None, }, Some(Err(_)) => false, None => { @@ -171,6 +175,7 @@ fn remote_matches_search_term( MatchCategory::Template => false, MatchCategory::RemoteType => category.matches(&remote.ty.to_string(), &term.value), MatchCategory::NetworkType => false, + MatchCategory::View => true, }, Some(Err(_)) => false, None => { @@ -326,6 +331,18 @@ pub(crate) async fn get_resources_impl( let view = views::get_optional_view(view)?; + let mut view_filter_from_search = None; + filters.matches(|term| { + if let Some("view") = term.category.as_deref() { + view_filter_from_search = Some(term.value.to_string()); + } + true + }); + + let view = view.or(views::get_optional_view( + view_filter_from_search.as_deref(), + )?); + let remotes_only = is_remotes_only(&filters); for (remote_name, remote) in remotes_config { @@ -1183,7 +1200,7 @@ pub(super) fn map_pve_network( ClusterResourceNetworkType::UnknownEnumValue(variant) => { log::debug!("ignoring unknown network type variant {variant}"); None - }, + } } } _ => None, -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel