mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-14 05:37:23 +08:00
feat(ui): Display network names and optimize list loading (#1503)
This commit is contained in:
@@ -189,6 +189,28 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_get_network_metas(
|
||||
&self,
|
||||
identify: T,
|
||||
inst_ids: Vec<uuid::Uuid>,
|
||||
) -> Result<GetNetworkMetasResponse, RemoteClientError<E>> {
|
||||
let mut metas = std::collections::HashMap::new();
|
||||
|
||||
for instance_id in inst_ids {
|
||||
let config = self
|
||||
.handle_get_network_config(identify.clone(), instance_id)
|
||||
.await?;
|
||||
metas.insert(
|
||||
instance_id,
|
||||
NetworkMeta {
|
||||
instance_name: config.network_name.unwrap_or_default(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Ok(GetNetworkMetasResponse { metas })
|
||||
}
|
||||
|
||||
async fn handle_save_network_config(
|
||||
&self,
|
||||
identify: T,
|
||||
@@ -255,6 +277,16 @@ pub struct ListNetworkInstanceIdsJsonResp {
|
||||
disabled_inst_ids: Vec<crate::proto::common::Uuid>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct NetworkMeta {
|
||||
instance_name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct GetNetworkMetasResponse {
|
||||
metas: std::collections::HashMap<uuid::Uuid, NetworkMeta>,
|
||||
}
|
||||
|
||||
pub trait PersistentConfig<E> {
|
||||
fn get_network_inst_id(&self) -> &str;
|
||||
fn get_network_config(&self) -> Result<NetworkConfig, E>;
|
||||
|
||||
Reference in New Issue
Block a user