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 7826F1FF179 for ; Wed, 12 Nov 2025 17:18:15 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F15009219; Wed, 12 Nov 2025 17:19:02 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Wed, 12 Nov 2025 17:11:39 +0100 Message-ID: <20251112161900.75032-5-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112161900.75032-1-d.csapak@proxmox.com> References: <20251112161900.75032-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 Subject: [pdm-devel] [PATCH datacenter-manager 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs index cdbd90cf..30a4015e 100644 --- a/server/src/api/resources.rs +++ b/server/src/api/resources.rs @@ -60,6 +60,7 @@ enum MatchCategory { Remote, RemoteType, Property, + View, } impl std::str::FromStr for MatchCategory { @@ -75,6 +76,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) @@ -105,6 +107,7 @@ impl MatchCategory { .to_lowercase() .split(",") .any(|property| property == search_term.to_lowercase()), + MatchCategory::View => true, } } } @@ -131,6 +134,7 @@ fn resource_matches_search_term( }, MatchCategory::Remote => category.matches(remote_name, &term.value), MatchCategory::RemoteType => return None, + MatchCategory::View => return None, }, Some(Err(_)) => false, None => { @@ -161,6 +165,7 @@ fn remote_matches_search_term( MatchCategory::Property => false, MatchCategory::Template => false, MatchCategory::RemoteType => category.matches(&remote.ty.to_string(), &term.value), + MatchCategory::View => true, }, Some(Err(_)) => false, None => { @@ -316,6 +321,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 { -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel