public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH datacenter-manager] subscription: handle no remotes being configured yet
@ 2025-12-03  9:00 Fabian Grünbichler
  0 siblings, 0 replies; only message in thread
From: Fabian Grünbichler @ 2025-12-03  9:00 UTC (permalink / raw)
  To: pdm-devel

if there are no remotes configured yet, do not display a confusing error
messages, instead wait for some remotes to be set up.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 server/src/api/nodes/subscription.rs       | 13 +++++++++++++
 ui/src/configuration/subscription_panel.rs |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/server/src/api/nodes/subscription.rs b/server/src/api/nodes/subscription.rs
index c84487f..4e6c0f0 100644
--- a/server/src/api/nodes/subscription.rs
+++ b/server/src/api/nodes/subscription.rs
@@ -77,6 +77,10 @@ fn count_subscriptions(
 }
 
 fn check_counts(stats: &SubscriptionStatistics) -> Result<(), Error> {
+    if stats.total_nodes == 0 {
+        return Ok(());
+    }
+
     let basic_or_higher_ratio =
         (stats.active_subscriptions - stats.community) as f64 / stats.total_nodes as f64;
 
@@ -112,6 +116,15 @@ pub async fn get_subscription() -> Result<PdmSubscriptionInfo, Error> {
             message: Some(format!("{err}")),
             serverid: None,
             url: Some(PRODUCT_URL.into()),
+            ..Default::default()
+        }
+    } else if statistics.total_nodes == 0 {
+        SubscriptionInfo {
+            status: SubscriptionStatus::NotFound,
+            message: Some(format!("No remotes configured yet.")),
+            serverid: None,
+            url: Some(PRODUCT_URL.into()),
+
             ..Default::default()
         }
     } else {
diff --git a/ui/src/configuration/subscription_panel.rs b/ui/src/configuration/subscription_panel.rs
index 1011132..c08fb73 100644
--- a/ui/src/configuration/subscription_panel.rs
+++ b/ui/src/configuration/subscription_panel.rs
@@ -145,6 +145,9 @@ fn rows() -> Vec<KVGridRow> {
         KVGridRow::new("statistics", tr!("Statistics")).renderer(move |_name, value, _record| {
             let statistics = serde_json::from_value::<SubscriptionStatistics>(value.clone());
             match statistics {
+                Ok(stats) if stats.total_nodes == 0 => {
+                    Column::new().with_child(Row::new().with_child("-")).into()
+                }
                 Ok(stats) => {
                     let basic_or_higher = stats.active_subscriptions - stats.community;
                     let basic_or_higher_ratio = basic_or_higher as f64 / stats.total_nodes as f64;
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-03  9:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-03  9:00 [pdm-devel] [PATCH datacenter-manager] subscription: handle no remotes being configured yet Fabian Grünbichler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal