diff --git a/app/dashboard/src/components/CoreSettingsModal.tsx b/app/dashboard/src/components/CoreSettingsModal.tsx index 66a8808e2..95f029381 100644 --- a/app/dashboard/src/components/CoreSettingsModal.tsx +++ b/app/dashboard/src/components/CoreSettingsModal.tsx @@ -15,6 +15,7 @@ import { ModalFooter, ModalHeader, ModalOverlay, + Select, Text, Tooltip, useToast, @@ -40,6 +41,7 @@ import { getAuthToken } from "utils/authStorage"; import { Icon } from "./Icon"; import { JsonEditor } from "./JsonEditor"; import "./JsonEditor/themes.js"; +import { useNodesQuery } from "contexts/NodesContext"; export const MAX_NUMBER_OF_LOGS = 500; @@ -79,7 +81,7 @@ const getStatus = (status: string) => { }[status]; }; -const getWebsocketUrl = () => { +const getWebsocketUrl = (nodeID: string) => { try { let baseURL = new URL( import.meta.env.VITE_BASE_API.startsWith("/") @@ -89,7 +91,10 @@ const getWebsocketUrl = () => { return ( (baseURL.protocol === "https:" ? "wss://" : "ws://") + - joinPaths([baseURL.host + baseURL.pathname, "/core/logs"]) + + joinPaths([ + baseURL.host + baseURL.pathname, + !nodeID ? "/core/logs" : `/node/${nodeID}/logs`, + ]) + "?interval=1&token=" + getAuthToken() ); @@ -102,6 +107,21 @@ const getWebsocketUrl = () => { let logsTmp: string[] = []; const CoreSettingModalContent: FC = () => { + const { data: nodes } = useNodesQuery(); + const disabled = false; + const [selectedNode, setNode] = useState(""); + + const handleLog = (id: string, title: string) => { + if (id === selectedNode) return; + else if (id === "host") { + setNode(""); + setLogs([]); + } else { + setNode(id); + setLogs([]); + } + }; + const { isEditingCore } = useDashboard(); const { fetchCoreSettings, @@ -145,7 +165,7 @@ const CoreSettingModalContent: FC = () => { [] ); - const { readyState } = useWebSocket(getWebsocketUrl(), { + const { readyState } = useWebSocket(getWebsocketUrl(selectedNode), { onMessage: (e: any) => { logsTmp.push(e.data); if (logsTmp.length > MAX_NUMBER_OF_LOGS) @@ -251,8 +271,43 @@ const CoreSettingModalContent: FC = () => { - - {t("core.logs")} + + + {nodes?.[0] && ( + + )} + {t("core.logs")} + {t(`core.socket.${status}`)} { - - - + + + + + +