[pbs-devel] [PATCH proxmox-backup 6/7] manager: render group filter properly
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Jul 22 16:35:09 CEST 2021
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/bin/proxmox_backup_manager/sync.rs | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/bin/proxmox_backup_manager/sync.rs b/src/bin/proxmox_backup_manager/sync.rs
index 0c9bac49..a2c36854 100644
--- a/src/bin/proxmox_backup_manager/sync.rs
+++ b/src/bin/proxmox_backup_manager/sync.rs
@@ -6,6 +6,18 @@ use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
use proxmox_backup::config;
use proxmox_backup::api2::{self, types::* };
+fn render_groups(value: &Value, _record: &Value) -> Result<String, Error> {
+ if let Some(groups) = value.as_array() {
+ let groups:Vec<&str> = groups
+ .iter()
+ .filter_map(Value::as_str)
+ .collect();
+ Ok(groups.join(", "))
+ } else {
+ Ok(String::from("all"))
+ }
+}
+
#[api(
input: {
properties: {
@@ -33,6 +45,7 @@ fn list_sync_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
.column(ColumnConfig::new("remote"))
.column(ColumnConfig::new("remote-store"))
.column(ColumnConfig::new("schedule"))
+ .column(ColumnConfig::new("groups").renderer(render_groups))
.column(ColumnConfig::new("comment"));
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
@@ -64,6 +77,12 @@ fn show_sync_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value,
_ => unreachable!(),
};
+ if let Some(groups) = data.get_mut("groups") {
+ if let Ok(rendered) = render_groups(groups, groups) {
+ *groups = Value::String(rendered);
+ }
+ }
+
let options = default_table_format_options();
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
--
2.30.2
More information about the pbs-devel
mailing list