tape: changer status - show full slots (for cartridge without barcode)

This commit is contained in:
Dietmar Maurer 2021-01-04 12:06:05 +01:00
parent 66e42bec05
commit 165b641c1d

View File

@ -206,12 +206,24 @@ async fn get_status(
_ => unreachable!(), _ => unreachable!(),
}; };
let render_changer_id = |value: &Value, _record: &Value| -> Result<String, Error> {
if value.is_null() {
return Ok(String::new());
}
let text = value.as_str().unwrap().to_string();
if text.is_empty() {
return Ok(String::from("--FULL--"));
} else {
Ok(text)
}
};
let options = default_table_format_options() let options = default_table_format_options()
.sortby("entry-kind", false) .sortby("entry-kind", false)
.sortby("entry-id", false) .sortby("entry-id", false)
.column(ColumnConfig::new("entry-kind")) .column(ColumnConfig::new("entry-kind"))
.column(ColumnConfig::new("entry-id")) .column(ColumnConfig::new("entry-id"))
.column(ColumnConfig::new("changer-id")) .column(ColumnConfig::new("changer-id").renderer(render_changer_id))
.column(ColumnConfig::new("loaded-slot")) .column(ColumnConfig::new("loaded-slot"))
; ;