From 2b5c0ab129c6ecad6509edf083e90a578a4d1160 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 30 Jun 2023 09:58:47 -0500 Subject: rough in file display --- src/web/src/components/System/Files/Explorer.js | 33 +++++++++++++++++++++++++ src/web/src/components/System/Files/index.js | 30 ++++++++++++---------- src/web/src/lib/files.js | 8 ++++++ 3 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 src/web/src/components/System/Files/Explorer.js create mode 100644 src/web/src/lib/files.js (limited to 'src') diff --git a/src/web/src/components/System/Files/Explorer.js b/src/web/src/components/System/Files/Explorer.js new file mode 100644 index 00000000..6abbe5c6 --- /dev/null +++ b/src/web/src/components/System/Files/Explorer.js @@ -0,0 +1,33 @@ +import React, { useState, useEffect } from 'react'; + +import { list } from '../../../lib/files'; + +const Explorer = ({ root }) => { + const [directory, setDirectory] = useState({ files: [], directories: [] }); + const [subdirectory, setSubdirectory] = useState([]); + + useEffect(() => { + console.log('fetching...', subdirectory); + const fetch = async () => { + const dir = await list({ root, subdirectory: subdirectory.join('/') }); + setDirectory(dir); + }; + + fetch(); + }, [subdirectory]); + + const select = ({ path }) => { + setSubdirectory([...subdirectory, path]); + }; + + return ( +
+ {directory?.directories?.map(d =>
+ select({ path: d.name })}> + {d.name} +
)} +
+ ); +}; + +export default Explorer; \ No newline at end of file diff --git a/src/web/src/components/System/Files/index.js b/src/web/src/components/System/Files/index.js index 881d1246..b5ab465b 100644 --- a/src/web/src/components/System/Files/index.js +++ b/src/web/src/components/System/Files/index.js @@ -1,23 +1,27 @@ import React from 'react'; import { Tab } from 'semantic-ui-react'; -const panes = [ - { - route: 'downloads', - menuItem: 'Downloads', - render: () => Downloads, - }, - { - route: 'incomplete', - menuItem: 'Incomplete', - render: () => Incomplete, - }, -]; +import Explorer from './Explorer'; const Files = () => { + const panes = [ + { + route: 'downloads', + menuItem: 'Downloads', + render: () => , + }, + { + route: 'incomplete', + menuItem: 'Incomplete', + render: () => , + }, + ]; + return (
- +
); }; diff --git a/src/web/src/lib/files.js b/src/web/src/lib/files.js new file mode 100644 index 00000000..9c147d61 --- /dev/null +++ b/src/web/src/lib/files.js @@ -0,0 +1,8 @@ +import api from './api'; + +export const list = async ({ root, subdirectory = '' }) => { + subdirectory = btoa(subdirectory); + const response = (await api.get(`/files/${root}/directories/${subdirectory}`)).data; + + return response; +}; \ No newline at end of file -- cgit v1.2.3