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),

View File

@@ -99,6 +99,10 @@ async fn start_hbbs_sync_async() {
if !strategy_name.is_empty() {
v[keys::OPTION_PRESET_STRATEGY_NAME] = json!(strategy_name);
}
let device_group_name = get_builtin_option(keys::OPTION_PRESET_DEVICE_GROUP_NAME);
if !device_group_name.is_empty() {
v[keys::OPTION_PRESET_DEVICE_GROUP_NAME] = json!(device_group_name);
}
match crate::post_request(url.replace("heartbeat", "sysinfo"), v.to_string(), "").await {
Ok(x) => {
if x == "SYSINFO_UPDATED" {

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "更新客户端的粘贴板"),
("Untagged", "无标签"),
("new-version-of-{}-tip", "{} 版本更新"),
("Accessible devices", "可访问的设备"),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Client-Zwischenablage aktualisieren"),
("Untagged", "Unmarkiert"),
("new-version-of-{}-tip", "Es ist eine neue Version von {} verfügbar"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Ενημέρωση απομακρισμένου προχείρου"),
("Untagged", "Χωρίς ετικέτα"),
("new-version-of-{}-tip", "Υπάρχει διαθέσιμη νέα έκδοση του {}"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Actualizar portapapeles del cliente"),
("Untagged", "Sin itiquetar"),
("new-version-of-{}-tip", "Hay una nueva versión de {} disponible"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "A kliens vágólapjának frissítése"),
("Untagged", "Címkézetlen"),
("new-version-of-{}-tip", "A(z) {} új verziója"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Aggiorna appunti client"),
("Untagged", "Senza tag"),
("new-version-of-{}-tip", "È disponibile una nuova versione di {}"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "클라이언트 클립보드 업데이트"),
("Untagged", "태그 없음"),
("new-version-of-{}-tip", "{} 의 새로운 버전이 출시되었습니다."),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Atjaunināt klienta starpliktuvi"),
("Untagged", "Neatzīmēts"),
("new-version-of-{}-tip", "Ir pieejama jauna {} versija"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Klembord van client bijwerken"),
("Untagged", "Ongemarkeerd"),
("new-version-of-{}-tip", "Er is een nieuwe versie van {} beschikbaar"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Uaktualnij schowek klienta"),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Обновить буфер обмена клиента"),
("Untagged", "Без метки"),
("new-version-of-{}-tip", "Доступна новая версия {}"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Osveži odjemalčevo odložišče"),
("Untagged", "Neoznačeno"),
("new-version-of-{}-tip", "Na voljo je nova različica {}"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "更新客戶端的剪貼簿"),
("Untagged", "無標籤"),
("new-version-of-{}-tip", "有新版本的 {} 可用"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", "Оновити буфер обміну клієнта"),
("Untagged", "Без міток"),
("new-version-of-{}-tip", "Доступна нова версія {}"),
("Accessible devices", ""),
].iter().cloned().collect();
}

View File

@@ -656,5 +656,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Update client clipboard", ""),
("Untagged", ""),
("new-version-of-{}-tip", ""),
("Accessible devices", ""),
].iter().cloned().collect();
}