From 3293f42555fafada32def098a30274267eab21c8 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 22 Jul 2023 23:01:17 -0500 Subject: add file table --- src/web/src/components/System/Files/Explorer.js | 62 +++++++++++++++++++++---- 1 file changed, 53 insertions(+), 9 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/System/Files/Explorer.js b/src/web/src/components/System/Files/Explorer.js index 6abbe5c6..adc8d3bf 100644 --- a/src/web/src/components/System/Files/Explorer.js +++ b/src/web/src/components/System/Files/Explorer.js @@ -1,32 +1,76 @@ import React, { useState, useEffect } from 'react'; +import { + Table, + Icon, + Message +} from 'semantic-ui-react'; + import { list } from '../../../lib/files'; +import { formatBytes, formatDate } from '../../../lib/util'; +import { LoaderSegment } from '../../Shared'; -const Explorer = ({ root }) => { +const Explorer = ({ root, isActive }) => { const [directory, setDirectory] = useState({ files: [], directories: [] }); const [subdirectory, setSubdirectory] = useState([]); - + const [loading, setLoading] = useState(false); + useEffect(() => { + setLoading(true); + console.log('fetching...', subdirectory); const fetch = async () => { const dir = await list({ root, subdirectory: subdirectory.join('/') }); + console.log(dir) setDirectory(dir); + setLoading(false); }; fetch(); - }, [subdirectory]); + }, [isActive, subdirectory]); const select = ({ path }) => { setSubdirectory([...subdirectory, path]); + console.log(path) }; + const row = (icon, { name, fullName, modifiedAt, length }, onClick = () => { }) => + onClick({ path: name })} + >{name} + {modifiedAt ? formatDate(modifiedAt) : ''} + {length ? formatBytes(length) : ''} + + console.log(fullName)} style={{ cursor: 'pointer' }}/> + + ; + + if (loading) { + return ; + } + return ( -
- {directory?.directories?.map(d =>
- select({ path: d.name })}> - {d.name} -
)} -
+ <> + {!!subdirectory && + {root + '/' + subdirectory} + } + + + + Name + Date Modified + Size + + + + + {!!subdirectory && row('folder', { name: '..', fullName: '..' })} + {directory?.directories?.map((d => row('folder', d, select)))} + {directory?.files?.map(f => row('file outline', f))} + +
+ ); }; -- cgit v1.2.3