device group (#10781)

1. Rename `Group` tab to `Accessible devices`
2. Add accessible device groups at the top of search list
3. option `preset-device-group-name` and command line `--assign --device_group_name`

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2025-02-15 12:13:11 +08:00
committed by GitHub
parent 8f545491a2
commit cefda0dec1
57 changed files with 269 additions and 33 deletions

View File

@@ -427,15 +427,26 @@ pub fn core_main() -> Option<Vec<String>> {
if pos < max {
address_book_tag = Some(args[pos + 1].to_owned());
}
let mut device_group_name = None;
let pos = args
.iter()
.position(|x| x == "--device_group_name")
.unwrap_or(max);
if pos < max {
device_group_name = Some(args[pos + 1].to_owned());
}
let mut body = serde_json::json!({
"id": id,
"uuid": uuid,
});
let header = "Authorization: Bearer ".to_owned() + &token;
if user_name.is_none() && strategy_name.is_none() && address_book_name.is_none()
if user_name.is_none()
&& strategy_name.is_none()
&& address_book_name.is_none()
&& device_group_name.is_none()
{
println!(
"--user_name or --strategy_name or --address_book_name is required!"
"--user_name or --strategy_name or --address_book_name or --device_group_name is required!"
);
} else {
if let Some(name) = user_name {
@@ -450,6 +461,9 @@ pub fn core_main() -> Option<Vec<String>> {
body["address_book_tag"] = serde_json::json!(name);
}
}
if let Some(name) = device_group_name {
body["device_group_name"] = serde_json::json!(name);
}
let url = crate::ui_interface::get_api_server() + "/api/devices/cli";
match crate::post_request_sync(url, body.to_string(), &header) {
Err(err) => println!("{}", err),