diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 80b42be..99ac90b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -5,12 +5,16 @@ mod resources; -use crate::resources::{cron_jobs::get_cron_jobs, namespaces::get_namespaces, pods::get_pods}; +use crate::resources::{ + cron_jobs::get_cron_jobs, deployments::get_deployments, namespaces::get_namespaces, + pods::get_pods, +}; fn main() { tauri::Builder::default() .invoke_handler(tauri::generate_handler![ get_cron_jobs, + get_deployments, get_pods, get_namespaces, ]) diff --git a/src-tauri/src/resources/deployments.rs b/src-tauri/src/resources/deployments.rs new file mode 100644 index 0000000..15ef390 --- /dev/null +++ b/src-tauri/src/resources/deployments.rs @@ -0,0 +1,9 @@ +use k8s_openapi::api::apps::v1::Deployment; +use kube::core::ObjectList; + +use super::internal::get_resource_list; + +#[tauri::command] +pub async fn get_deployments(namespace: Option) -> ObjectList { + return get_resource_list(namespace).await; +} diff --git a/src-tauri/src/resources/mod.rs b/src-tauri/src/resources/mod.rs index 4b426d2..e83617c 100644 --- a/src-tauri/src/resources/mod.rs +++ b/src-tauri/src/resources/mod.rs @@ -1,4 +1,5 @@ pub mod cron_jobs; +pub mod deployments; pub mod namespaces; pub mod pods; diff --git a/src/deployments/deployments.tsx b/src/deployments/deployments.tsx new file mode 100644 index 0000000..9099611 --- /dev/null +++ b/src/deployments/deployments.tsx @@ -0,0 +1,35 @@ +import type { V1Deployment } from "@kubernetes/client-node"; +import { useQuery } from "@tanstack/react-query"; +import { invoke } from "@tauri-apps/api"; + +import { Table, TableHeader, TableBody, TableCell } from "../components/table"; +import { useCurrentNamespace } from "../namespaces/namespaces"; + +export function Deployments() { + const { namespace } = useCurrentNamespace(); + + const result = useQuery(["deployments", namespace], () => { + return invoke<{ items: V1Deployment[] }>(`get_deployments`, { namespace }); + }); + + const data = result.data?.items ?? []; + + return ( +
+ + + + {data.map((item) => ( + + {item.metadata?.name} + {item.spec?.template.spec?.containers[0].image} + + {item.status?.availableReplicas} / {item.status?.replicas} + + + ))} + +
+
+ ); +} diff --git a/src/layout.tsx b/src/layout.tsx index a03e9d5..37c0ec1 100644 --- a/src/layout.tsx +++ b/src/layout.tsx @@ -3,11 +3,7 @@ import { Link } from "@tanstack/react-router"; import type { PropsWithChildren } from "react"; import { NamespaceSelect } from "./namespaces/namespace-select"; - -const navigation = [ - { name: "Pods", href: "/pods" }, - { name: "Cron Jobs", href: "/cron-jobs" }, -] as const; +import { navigationLinks } from "./router"; export function Layout({ children }: PropsWithChildren) { return ( @@ -21,7 +17,7 @@ export function Layout({ children }: PropsWithChildren) {