aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2023-06-30 09:58:47 -0500
committerJP Dillingham <jp@dillingham.me>2023-06-30 09:58:47 -0500
commit2b5c0ab129c6ecad6509edf083e90a578a4d1160 (patch)
treefed8ab8274663eeb4add122bf2bf6899ba5618a1 /src
parent686b2aa091aab7f4ec185aa03901e37c553ea1f6 (diff)
downloadslskd-2b5c0ab129c6ecad6509edf083e90a578a4d1160.tar.gz
rough in file display
Diffstat (limited to 'src')
-rw-r--r--src/web/src/components/System/Files/Explorer.js33
-rw-r--r--src/web/src/components/System/Files/index.js30
-rw-r--r--src/web/src/lib/files.js8
3 files changed, 58 insertions, 13 deletions
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 (
+ <div>
+ {directory?.directories?.map(d => <div>
+ <span onClick={() => select({ path: d.name })}>
+ {d.name}
+ </span></div>)}
+ </div>
+ );
+};
+
+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: () => <Tab.Pane>Downloads</Tab.Pane>,
- },
- {
- route: 'incomplete',
- menuItem: 'Incomplete',
- render: () => <Tab.Pane>Incomplete</Tab.Pane>,
- },
-];
+import Explorer from './Explorer';
const Files = () => {
+ const panes = [
+ {
+ route: 'downloads',
+ menuItem: 'Downloads',
+ render: () => <Tab.Pane><Explorer root={'downloads'}/></Tab.Pane>,
+ },
+ {
+ route: 'incomplete',
+ menuItem: 'Incomplete',
+ render: () => <Tab.Pane><Explorer root={'incomplete'}/></Tab.Pane>,
+ },
+ ];
+
return (
<div>
- <Tab panes={panes}/>
+ <Tab
+ panes={panes}
+ />
</div>
);
};
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