diff --git a/src-tauri/src/commands/container.rs b/src-tauri/src/commands/container.rs index dfef657..d35b2f5 100644 --- a/src-tauri/src/commands/container.rs +++ b/src-tauri/src/commands/container.rs @@ -279,6 +279,23 @@ pub async fn get_container_processes(state: tauri::State<'_, AppState>, containe let result = state.docker.top_processes(&container, options).await; + match result { + Ok(processes) => { + Ok(processes.processes.expect("Failed to get processes from docker container")) + }, + Err(e) => return Err(e.to_string()), + } +} + + +#[tauri::command] +pub async fn get_container_env_vars(state: tauri::State<'_, AppState>, container: String) -> Result>, String> { + let options = Some(TopOptions { + ps_args: "aux", + }); + + let result = state.docker.top_processes(&container, options).await; + match result { Ok(processes) => { Ok(processes.processes.expect("Failed to get processes from docker container")) diff --git a/src/components/Containers/ContainerDetails.jsx b/src/components/Containers/ContainerDetails.jsx index cac64dc..e33063b 100644 --- a/src/components/Containers/ContainerDetails.jsx +++ b/src/components/Containers/ContainerDetails.jsx @@ -21,6 +21,7 @@ import ContainerNameWidget from "./ContainerNameWidget.jsx"; import Swal from "sweetalert2"; import toast from "../../utils/toast.js"; import ContainerProcesses from "./ContainerProcesses.jsx"; +import ContainerEnvVars from "./ContainerEnvVars.jsx"; function ContainerDetails() { @@ -210,6 +211,8 @@ function ContainerDetails() { case 'PROCESSES': return + case 'ENV_VARS': + return default: return null; } @@ -315,6 +318,9 @@ function ContainerDetails() { +
{renderContent()} diff --git a/src/components/Containers/ContainerEnvVars.jsx b/src/components/Containers/ContainerEnvVars.jsx new file mode 100644 index 0000000..b6720be --- /dev/null +++ b/src/components/Containers/ContainerEnvVars.jsx @@ -0,0 +1,56 @@ +import React, {useEffect, useState} from 'react'; +import {invoke} from "@tauri-apps/api"; +import {useContainers} from "../../state/ContainerContext.jsx"; + +const ContainerEnvVars = () => { + const {selectedContainer} = useContainers(); + + const [envVars, setEnvVars] = useState({}) + + + function getInfo() { + invoke('fetch_container_info', {cId: selectedContainer.Id}).then((info) => { + let envVars = info?.Config?.Env; + + let envObj = {} + + envVars.forEach(envVar => { + let keyVal = envVar.split("=") + envObj[keyVal[0]] = keyVal[1] + }) + setEnvVars(envObj) + + }).catch((error) => { + console.error("Error fetching container info:", error); + }); + } + + useEffect(() => { + getInfo() + }, [selectedContainer]); + + + return ( +
+ + + + + + + + + + {envVars && Object.entries(envVars).map(([key, value]) => ( + + + + + ))} + +
VARIABLEVALUE
{key}{value}
+
+ ); +}; + +export default ContainerEnvVars;