diff --git a/src/renderer/pages/Dashboard.tsx b/src/renderer/pages/Dashboard.tsx index fcadd44..36bdb94 100644 --- a/src/renderer/pages/Dashboard.tsx +++ b/src/renderer/pages/Dashboard.tsx @@ -1,27 +1,23 @@ -import { useEffect, useState } from 'react'; +import { Fragment, useEffect } from 'react'; import stripAnsi from 'strip-ansi'; -import FloatingTerminalButton from '../components/FloatingTerminalButton'; +import { Tab } from '@headlessui/react'; import ProjectCard from '../components/ProjectCard'; import useRetrieveProjects from '../utils/useRetrieveProjects'; import UploadBox from '../components/UploadBox'; +import Button from '../components/button/Button'; +import useActiveTerminals from '../stores/useActiveTerminals'; function Dashboard() { const { projects } = useRetrieveProjects(); - const [terminalOutput, setTerminalOutput] = useState([]); + const { terminals, addOutput } = useActiveTerminals(); useEffect(() => { - window.electron.ipcRenderer.on('shell-result', (e) => { - const resultArray = e as Uint8Array; - const decoder = new TextDecoder('utf-8'); - const result = decoder.decode(resultArray); - - // Check if the result is already present in the terminalOutput array - if (!terminalOutput.includes(result)) { - // Append the result to the terminalOutput array - setTerminalOutput((prevOutput) => [...prevOutput, stripAnsi(result)]); - } + window.electron.ipcRenderer.on('shell-result', (e: any) => { + const name = e.name as string; + const result = stripAnsi(e.out) as string; + addOutput(name, result); }); - }, [terminalOutput]); // Add terminalOutput as a dependency to useEffect + }, [addOutput]); return (
@@ -31,14 +27,51 @@ function Dashboard() { Ecco i tuoi progetti
-
- {projects && - projects.map((project) => ( - - ))} - -
- + + + + {({ selected }) => ( + + )} + + + {({ selected }) => ( + + )} + + + + +
+ {projects && + projects.map((project) => ( + + ))} + +
+
+ + {terminals.map((terminal) => ( +
+
{terminal.name}
+
+ {terminal.out.map((line, i) => ( + // eslint-disable-next-line react/no-array-index-key +

+ {line} +

+ ))} +
+
+ ))} +
+
+
); }