manager: render group filter properly
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Reviewed-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
1d9bc184f5
commit
1b52122a1f
@ -8,6 +8,18 @@ use pbs_api_types::JOB_ID_SCHEMA;
|
|||||||
|
|
||||||
use proxmox_backup::api2;
|
use proxmox_backup::api2;
|
||||||
|
|
||||||
|
fn render_group_filter(value: &Value, _record: &Value) -> Result<String, Error> {
|
||||||
|
if let Some(group_filters) = value.as_array() {
|
||||||
|
let group_filters:Vec<&str> = group_filters
|
||||||
|
.iter()
|
||||||
|
.filter_map(Value::as_str)
|
||||||
|
.collect();
|
||||||
|
Ok(group_filters.join(" OR "))
|
||||||
|
} else {
|
||||||
|
Ok(String::from("all"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
input: {
|
input: {
|
||||||
properties: {
|
properties: {
|
||||||
@ -35,6 +47,7 @@ fn list_sync_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
|
|||||||
.column(ColumnConfig::new("remote"))
|
.column(ColumnConfig::new("remote"))
|
||||||
.column(ColumnConfig::new("remote-store"))
|
.column(ColumnConfig::new("remote-store"))
|
||||||
.column(ColumnConfig::new("schedule"))
|
.column(ColumnConfig::new("schedule"))
|
||||||
|
.column(ColumnConfig::new("groups").renderer(render_group_filter))
|
||||||
.column(ColumnConfig::new("comment"));
|
.column(ColumnConfig::new("comment"));
|
||||||
|
|
||||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||||
@ -66,6 +79,12 @@ fn show_sync_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value,
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(groups) = data.get_mut("groups") {
|
||||||
|
if let Ok(rendered) = render_group_filter(groups, groups) {
|
||||||
|
*groups = Value::String(rendered);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let options = default_table_format_options();
|
let options = default_table_format_options();
|
||||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user