Skip to content

Commit

Permalink
feat: show subtype if present
Browse files Browse the repository at this point in the history
  • Loading branch information
hrzlgnm committed Mar 6, 2024
1 parent be5e372 commit c23cc4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct ResolvedService {
hostname: String,
port: u16,
addresses: Vec<IpAddr>,
subtype: Option<String>,
}

#[tauri::command]
Expand All @@ -54,6 +55,7 @@ fn resolve_service(service_type: String, state: State<Daemon>) -> Vec<ResolvedSe
hostname: info.get_hostname().into(),
port: info.get_port(),
addresses: sorted_addresses,
subtype: info.get_subtype().clone(),
});
}
ServiceEvent::SearchStarted(_) => {
Expand Down
10 changes: 6 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct ResolvedService {
hostname: String,
port: u16,
addresses: Vec<IpAddr>,
subtype: Option<String>,
}
type ResolvedServices = Vec<ResolvedService>;

Expand All @@ -48,7 +49,7 @@ async fn resolve_service(service_type: String) -> ResolvedServices {
}

#[component]
fn ShowServices(services: ServiceTypes) -> impl IntoView {
fn ShowServicesTypes(services: ServiceTypes) -> impl IntoView {
view! {
<ul>
{services.into_iter()
Expand All @@ -59,7 +60,7 @@ fn ShowServices(services: ServiceTypes) -> impl IntoView {
}

#[component]
fn ServiceTypeList() -> impl IntoView {
fn EnumerateServiceTypes() -> impl IntoView {
let enum_action = create_action(|_input: &()| async move { enum_service_types().await });
let value = enum_action.value();
view! { <form
Expand All @@ -76,7 +77,7 @@ fn ServiceTypeList() -> impl IntoView {
None => view! { <p>"Click on button above."</p> }.into_view(),
Some(services) => {
view! {
<ShowServices services />
<ShowServicesTypes services />
}.into_view()
}
}}
Expand All @@ -91,6 +92,7 @@ fn ShowResolvedServices(services: ResolvedServices) -> impl IntoView {
.map(|n|
view! {
<div>Instance name: {n.instance_name}</div>
<div>Subtype: {n.subtype}</div>
<div>Hostname: {n.hostname}</div>
<div>Port: {n.port}</div>
<div>IPs: {n.addresses.iter().map(|n|n.to_string()).collect::<Vec<String>>().join(", ")}</div>
Expand Down Expand Up @@ -140,7 +142,7 @@ pub fn App() -> impl IntoView {
view! {
<main class="container">
<ResolveService />
<ServiceTypeList />
<EnumerateServiceTypes />
</main>
}
}

0 comments on commit c23cc4f

Please sign in to comment.