diff --git a/client/src/api/docker.jsx b/client/src/api/docker.jsx index bbdb1b5..6661e1b 100644 --- a/client/src/api/docker.jsx +++ b/client/src/api/docker.jsx @@ -173,6 +173,53 @@ function createTerminal(containerId) { return new WebSocket(protocol + window.location.host + '/cosmos/api/servapps/' + containerId + '/terminal/new'); } +function createService(serviceData, onProgress) { + const requestOptions = { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(serviceData) + }; + + return fetch('/cosmos/api/docker-service', requestOptions) + .then(response => { + if (!response.ok) { + throw new Error(response.statusText); + } + + // The response body is a ReadableStream. This code reads the stream and passes chunks to the callback. + const reader = response.body.getReader(); + + // Read the stream and pass chunks to the callback as they arrive + return new ReadableStream({ + start(controller) { + function read() { + return reader.read().then(({ done, value }) => { + if (done) { + controller.close(); + return; + } + // Decode the UTF-8 text + let text = new TextDecoder().decode(value); + // Split by lines in case there are multiple lines in one chunk + let lines = text.split('\n'); + for (let line of lines) { + if (line) { + // Call the progress callback + onProgress(line); + } + } + controller.enqueue(value); + return read(); + }); + } + return read(); + } + }); + }); +} + export { list, get, @@ -192,4 +239,5 @@ export { createVolume, attachTerminal, createTerminal, + createService, }; \ No newline at end of file diff --git a/client/src/assets/images/wallpaper.jpg b/client/src/assets/images/wallpaper.jpg new file mode 100644 index 0000000..887fee1 Binary files /dev/null and b/client/src/assets/images/wallpaper.jpg differ diff --git a/client/src/assets/images/wallpaper.png b/client/src/assets/images/wallpaper.png deleted file mode 100644 index 63cfa9b..0000000 Binary files a/client/src/assets/images/wallpaper.png and /dev/null differ diff --git a/client/src/components/fileUpload.jsx b/client/src/components/fileUpload.jsx new file mode 100644 index 0000000..eca1932 --- /dev/null +++ b/client/src/components/fileUpload.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { Button } from '@mui/material'; +import { UploadOutlined } from '@ant-design/icons'; + +export default function UploadButtons({OnChange, accept}) { + return ( +
+ + +
+ ); +} \ No newline at end of file diff --git a/client/src/components/tabbedView/tabbedView.jsx b/client/src/components/tabbedView/tabbedView.jsx index af9c243..a7fe856 100644 --- a/client/src/components/tabbedView/tabbedView.jsx +++ b/client/src/components/tabbedView/tabbedView.jsx @@ -37,21 +37,26 @@ const a11yProps = (index) => { }; }; -const PrettyTabbedView = ({ tabs, isLoading }) => { +const PrettyTabbedView = ({ tabs, isLoading, currentTab, setCurrentTab }) => { const [value, setValue] = useState(0); const isMobile = useMediaQuery((theme) => theme.breakpoints.down('md')); + + if((currentTab != null && typeof currentTab === 'number') && value !== currentTab) + setValue(currentTab); const handleChange = (event, newValue) => { setValue(newValue); + setCurrentTab && setCurrentTab(newValue); }; const handleSelectChange = (event) => { setValue(event.target.value); + setCurrentTab && setCurrentTab(event.target.value); }; return ( - {isMobile ? ( + {(isMobile && !currentTab) ? (