added drag and drop to file browser

This commit is contained in:
Djeeberjr 2021-08-01 21:42:26 +02:00
parent 483ffb58ca
commit 713a96efc5

View File

@ -2,6 +2,7 @@ import React from "react"
import { useState } from "react" import { useState } from "react"
import { useOpenDirQuery } from "../generated/graphql" import { useOpenDirQuery } from "../generated/graphql"
import Breadcrum from "./Breadcrum" import Breadcrum from "./Breadcrum"
import DragAndDrop from "./DragAndDrop"
import FileBrowserElement from "./FileBrowserElement" import FileBrowserElement from "./FileBrowserElement"
import FileOpen from "./FileOpen" import FileOpen from "./FileOpen"
@ -16,46 +17,57 @@ const FileBrowser: React.FC = () => {
} }
}) })
function handleDrop(files:FileList) {
for (let i = 0; i < files.length; i++) {
const file = files[i]
console.debug(file) // TODO
}
}
return ( return (
<div> <div>
<Breadcrum path={path} onDirClick={(newPath)=>{ <DragAndDrop
setPath(newPath) handleDrop={handleDrop}
}}/> >
<div> <Breadcrum path={path} onDirClick={(newPath)=>{
{loading && setPath(newPath)
<div className="loading loading-lg"></div> // TODO: center }}/>
} <div>
<table className="table table-striped table-hover"> {loading &&
<thead> <div className="loading loading-lg"></div> // TODO: center
<tr> }
<th>Name</th> <table className="table table-striped table-hover">
<th>Size</th> <thead>
</tr> <tr>
</thead> <th>Name</th>
<tbody> <th>Size</th>
</tr>
</thead>
<tbody>
{ data?.directorys.map(v => (<FileBrowserElement { data?.directorys.map(v => (<FileBrowserElement
key={v?.id} key={v?.id}
dir={v} dir={v}
onClick={(dir)=>{ onClick={(dir)=>{
setPath(dir.id) setPath(dir.id)
}} }}
/>))} />))}
{ data?.files.map(v => (<FileBrowserElement { data?.files.map(v => (<FileBrowserElement
key={v?.id} key={v?.id}
file={v} file={v}
onClick={(file)=>{ onClick={(file)=>{
setOpenFileId(file.id) setOpenFileId(file.id)
setShowFile(true) setShowFile(true)
}} }}
/>))} />))}
</tbody> </tbody>
</table> </table>
</div> </div>
{<FileOpen id={openFileId} show={showFile} onCloseClick={()=>{ {<FileOpen id={openFileId} show={showFile} onCloseClick={()=>{
setShowFile(false) setShowFile(false)
}} />} }} />}
</DragAndDrop>
</div> </div>
) )
} }