mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
user files improvements
This commit is contained in:
parent
281d0e00ce
commit
3029d255ea
4 changed files with 111 additions and 37 deletions
|
@ -7,6 +7,12 @@
|
||||||
padding-bottom: 2px;
|
padding-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.searchContainer input {
|
||||||
|
border: 1px solid var(--text-color);
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.clearButton {
|
.clearButton {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
|
|
|
@ -425,7 +425,7 @@ export default class Chat extends React.Component {
|
||||||
ref={this.chatInputRef}
|
ref={this.chatInputRef}
|
||||||
className={styles.msgInput}
|
className={styles.msgInput}
|
||||||
autoFocus
|
autoFocus
|
||||||
placeholder={'Message ...'}
|
placeholder={'Üzenet ...'}
|
||||||
type={'text'}
|
type={'text'}
|
||||||
value={currMsg}
|
value={currMsg}
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect, useCallback } from 'react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
|
||||||
import LoadingIndicator from '../components/LoadingIndicator'
|
import LoadingIndicator from '../components/LoadingIndicator'
|
||||||
|
@ -203,6 +203,52 @@ export default function UserFiles({
|
||||||
|
|
||||||
const currDir = router.query.dir ? decodeURIComponent(router.query.dir) : ''
|
const currDir = router.query.dir ? decodeURIComponent(router.query.dir) : ''
|
||||||
|
|
||||||
|
const goBack = useCallback(() => {
|
||||||
|
router.back()
|
||||||
|
// FIXME: consistend going back with browser back button
|
||||||
|
//
|
||||||
|
// back button works like broser back button, unless it would result in site leave
|
||||||
|
// history: nothing > opened site/usrFiles?dir=...
|
||||||
|
// history: site > site/userFiles > site/usrFiles?dir=...
|
||||||
|
router.push(`${router.pathname}`, undefined, {
|
||||||
|
shallow: true,
|
||||||
|
})
|
||||||
|
}, [router])
|
||||||
|
|
||||||
|
const deleteDirectory = useCallback(
|
||||||
|
(dirName) => {
|
||||||
|
fetch(constants.apiUrl + 'deleteDir', {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
name: dirName,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json()
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
console.info(res)
|
||||||
|
if (res.succes) {
|
||||||
|
getRootDir(true)
|
||||||
|
alert(`a(z) '${dirName}' mappa törölve!`)
|
||||||
|
} else {
|
||||||
|
alert('Hiba törlés közben!')
|
||||||
|
console.log(res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
alert('Hálózati hiba!')
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
[router]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
router.replace(`${router.asPath.replace('.html', '')}`, undefined, {
|
router.replace(`${router.asPath.replace('.html', '')}`, undefined, {
|
||||||
shallow: true,
|
shallow: true,
|
||||||
|
@ -281,37 +327,37 @@ export default function UserFiles({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderNewButton = () => (
|
||||||
|
<div className={`buttonContainer ${styles.newButton}`}>
|
||||||
|
<div
|
||||||
|
onClick={() => {
|
||||||
|
setAddingNew(currDir ? 'file' : 'dir')
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{currDir ? 'Új fájl feltöltése...' : '➕ Új tárgy hozzáadása...'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
const renderDirList = (dirs) => {
|
const renderDirList = (dirs) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{currDir && (
|
{currDir && (
|
||||||
<div className={styles.title}>
|
<div className={styles.title}>
|
||||||
<div className={`buttonContainer ${styles.backButton}`}>
|
|
||||||
<div
|
|
||||||
onClick={() => {
|
|
||||||
router.back()
|
|
||||||
// FIXME: consistend going back with browser back button
|
|
||||||
// back button works like broser back button, unless it would result in site leave
|
|
||||||
// history: nothing > opened site/usrFiles?dir=...
|
|
||||||
// history: site > site/userFiles > site/usrFiles?dir=...
|
|
||||||
router.push(`${router.pathname}`, undefined, {
|
|
||||||
shallow: true,
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Vissza
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{currDir && <div className={styles.currDir}>{currDir}</div>}
|
{currDir && <div className={styles.currDir}>{currDir}</div>}
|
||||||
<div className={`${styles.backButton}`} />
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<div style={{ display: 'flex' }}>
|
||||||
|
<div style={{ flexGrow: 1 }}>
|
||||||
<SearchBar
|
<SearchBar
|
||||||
searchTerm={searchTerm}
|
searchTerm={searchTerm}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setSearchTerm(e)
|
setSearchTerm(e)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
{renderNewButton()}
|
||||||
|
</div>
|
||||||
<div className={`${styles.tableContainer} ${styles.header}`}>
|
<div className={`${styles.tableContainer} ${styles.header}`}>
|
||||||
<div
|
<div
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
@ -336,14 +382,17 @@ export default function UserFiles({
|
||||||
</div>
|
</div>
|
||||||
{dirs ? (
|
{dirs ? (
|
||||||
<div className={`${styles.tableContainer} ${styles.rows}`}>
|
<div className={`${styles.tableContainer} ${styles.rows}`}>
|
||||||
|
{currDir && (
|
||||||
<div
|
<div
|
||||||
|
style={{ height: 40 }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setAddingNew(currDir ? 'file' : 'dir')
|
goBack()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div>{currDir ? 'Új fájl feltöltése...' : 'Új tárgy...'}</div>
|
{'Vissza'}
|
||||||
</div>
|
</div>
|
||||||
{dirs.length !== 0 && (
|
)}
|
||||||
|
{dirs.length !== 0 ? (
|
||||||
<>
|
<>
|
||||||
{dirs.sort(dirSorter).map((dir) => {
|
{dirs.sort(dirSorter).map((dir) => {
|
||||||
const {
|
const {
|
||||||
|
@ -444,6 +493,22 @@ export default function UserFiles({
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
title={'A megnyitott mappa törlése, mivel üres'}
|
||||||
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
window.confirm(
|
||||||
|
`Biztosan törlöd a(z) '${currDir}' üres mappát?`
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
deleteDirectory(currDir)
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{'Mappa törlése'}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
@ -524,11 +589,14 @@ export default function UserFiles({
|
||||||
newSubj(newSubjName).then(() => {
|
newSubj(newSubjName).then(() => {
|
||||||
setUploading(false)
|
setUploading(false)
|
||||||
setAddingNew(null)
|
setAddingNew(null)
|
||||||
getRootDir()
|
getRootDir(true)
|
||||||
|
alert(`'${newSubjName}' létrehozva!`)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div>OK</div>
|
<div>
|
||||||
|
{addingNew === 'file' ? 'OK' : 'Új mappa létrehozása'}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -88,8 +88,8 @@
|
||||||
background-color: var(--dark-color);
|
background-color: var(--dark-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.backButton {
|
.newButton {
|
||||||
width: 15%;
|
width: 35%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue